Skip to content

Commit 1ad0253

Browse files
committed
rename to k8t, add licensing
1 parent 3ae6889 commit 1ad0253

24 files changed

+107
-60
lines changed

.envrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
source_up
2+
3+
pre-commit install-hooks

.pre-commit-config.yaml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
repos:
2+
- repo: meta
3+
hooks:
4+
- id: check-hooks-apply
5+
- id: check-useless-excludes
6+
- repo: git://github.com/pre-commit/pre-commit-hooks
7+
rev: v2.2.3
8+
hooks:
9+
- id: check-merge-conflict
10+
- repo: [email protected]:Yelp/detect-secrets
11+
rev: v0.12.5
12+
hooks:
13+
- id: detect-secrets
14+
args: ['--baseline', '.secrets.baseline']
15+
- repo: git://github.com/Lucas-C/pre-commit-hooks.git
16+
rev: v1.1.7
17+
hooks:
18+
- id: insert-license
19+
files: \.py$

LICENSE.txt

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
LICENSE.txt
1+
ISC License
22

3-
:Author: Aljosha Friemann
4-
5-
:Date: 2019-10-08 18:29
3+
Copyright 2019 FL Fintech E GmbH
4+
5+
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
6+
7+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

README.md

+15-13
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# kinja
1+
# k8t
2+
3+
*Pronounced Katie [ˈkeɪti]*
24

35
Simple cluster and environment specific aware templating for kubernetes manifests.
46

@@ -21,41 +23,41 @@ check out https://github.com/ClarkSource/k8s-cd-poc
2123
Create a new project folder with a cluster directory and an empty defaults file
2224

2325
```
24-
$ kinja new project foobar
26+
$ k8t new project foobar
2527
```
2628

2729
Create a new cluster
2830

2931
```
30-
$ kinja new cluster A
32+
$ k8t new cluster A
3133
```
3234

3335
Create a new environment
3436

3537
```
36-
$ kinja new environment staging A
37-
$ kinja new environment production A
38+
$ k8t new environment staging A
39+
$ k8t new environment production A
3840
```
3941
Setup secrets on SSM
4042

4143
```
42-
$ kinja edit config
44+
$ k8t edit config
4345
secrets:
4446
provider: ssm
4547
```
4648

4749
Specify prefixes for SSM secrets
4850

4951
```
50-
$ kinja edit config --cluster A --environment staging
52+
$ k8t edit config --cluster A --environment staging
5153
secrets:
5254
prefix: "staging/application"```
5355
```
5456

5557
Values can be easily added/modified in the same way
5658

5759
```
58-
$ kinja edit values --cluster Ano creds to it anyway or dont know where to get
60+
$ k8t edit values --cluster Ano creds to it anyway or dont know where to get
5961
```
6062

6163
A typical setup should look something like this
@@ -100,13 +102,13 @@ A typical setup should look something like this
100102
While validation is done before generating, templates can be validated for environment files easily.
101103

102104
```
103-
$ kinja validate
105+
$ k8t validate
104106
```
105107

106108
To validate for clusters/environments the usual options can be used
107109

108110
```
109-
$ kinja validate -c A -e production
111+
$ k8t validate -c A -e production
110112
```
111113

112114
### generate files
@@ -115,10 +117,10 @@ The **--cluster** flag will load variables from a directory. By default the file
115117
loaded, however an environment can be specified with **--environment**.
116118

117119
```
118-
$ kinja gen -c A -e staging
120+
$ k8t gen -c A -e staging
119121
```
120122

121-
Additionally kinja will attempt to load a file **defaults.yaml** in the root directory. This way a set of default
123+
Additionally k8t will attempt to load a file **defaults.yaml** in the root directory. This way a set of default
122124
variables can be specified and selectively overriden via cluster and environment.
123125

124126
Additional values can be given via flag **--value-file** in the form of a file or **--value KEY VALUE**, both can be
@@ -127,7 +129,7 @@ supplied multiple times.
127129
Variables will be merged via deep merging. Default merge strategy is left-to-right. For the merge order see the output of
128130

129131
```
130-
$ kinja --help
132+
$ k8t --help
131133
```
132134

133135
### Overriding templates

k8t/__init__.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# -*- coding: utf-8 -*-
2+
# vim:fenc=utf-8
3+
#
4+
# Copyright © 2018 Clark Germany GmbH
5+
6+
__version__ = '0.0.1'
7+
__license__ = """Copyright 2019 FL Fintech E GmbH
8+
9+
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
10+
11+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE."""

kinja/__main__.py renamed to k8t/__main__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
#
44
# Copyright © 2018 Clark Germany GmbH
55

6-
from kinja.cli import main
6+
from k8t.cli import main
77

88
main()

kinja/cli.py renamed to k8t/cli.py

+20-9
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,20 @@
99

1010
import click
1111
import coloredlogs
12-
from kinja.clusters import get_cluster_path, list_clusters, load_cluster
13-
from kinja.config import load_configuration
14-
from kinja.engine import build
15-
from kinja.environments import list_environments
16-
from kinja.templates import analyze, validate
17-
from kinja.util import MERGE_METHODS, deep_merge, touch
18-
from kinja.values import load_defaults, load_value_file
12+
from k8t import __license__, __version__
13+
from k8t.clusters import get_cluster_path, list_clusters, load_cluster
14+
from k8t.config import load_configuration
15+
from k8t.engine import build
16+
from k8t.environments import list_environments
17+
from k8t.templates import analyze, validate
18+
from k8t.util import MERGE_METHODS, deep_merge, touch
19+
from k8t.values import load_defaults, load_value_file
1920
from simple_tools.interaction import confirm
2021
from termcolor import colored
2122

2223

2324
def check_directory(path: str) -> bool:
24-
return os.path.exists(os.path.join(path, '.ktpl'))
25+
return os.path.exists(os.path.join(path, '.k8t'))
2526

2627

2728
@click.group()
@@ -35,6 +36,16 @@ def root(debug):
3536
logging.WARN if not debug else logging.INFO)
3637

3738

39+
@root.command(name='version')
40+
def print_version():
41+
print(f"k8t {__version__}")
42+
43+
44+
@root.command(name='license')
45+
def print_license():
46+
print(__license__)
47+
48+
3849
@root.command(name='validate')
3950
@click.option('-m', '--method', type=click.Choice(MERGE_METHODS), default='ltr', show_default=True)
4051
@click.option('--cluster', '-c')
@@ -147,7 +158,7 @@ def new_project(directory):
147158
sys.exit(1)
148159
os.makedirs(directory, exist_ok=True)
149160

150-
touch(os.path.join(directory, '.ktpl'))
161+
touch(os.path.join(directory, '.k8t'))
151162

152163
os.makedirs(os.path.join(directory, 'clusters'), exist_ok=True)
153164
os.makedirs(os.path.join(directory, 'templates'), exist_ok=True)

kinja/clusters.py renamed to k8t/clusters.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
import os
77
from typing import Any, Dict, List
88

9-
from kinja.environments import load_environment
10-
from kinja.logger import LOGGER
11-
from kinja.util import deep_merge
12-
from kinja.values import load_value_file
9+
from k8t.environments import load_environment
10+
from k8t.logger import LOGGER
11+
from k8t.util import deep_merge
12+
from k8t.values import load_value_file
1313

1414

1515
def list_clusters(path: str) -> List[str]:

kinja/config.py renamed to k8t/config.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
from typing import Any, Dict
88

99
import yaml
10-
from kinja.util import merge
10+
11+
from k8t.util import merge
1112

1213

1314
def load_configuration(path: str, cluster: str, environment: str) -> dict:

kinja/engine.py renamed to k8t/engine.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66
import os
77

88
from jinja2 import Environment, FileSystemLoader
9-
from kinja.clusters import get_cluster_path
10-
from kinja.environments import get_environment_path
11-
from kinja.logger import LOGGER
12-
from kinja.secrets import get_secret
13-
from kinja.util import b64decode, b64encode, hashf, random_password
9+
10+
from k8t.clusters import get_cluster_path
11+
from k8t.environments import get_environment_path
12+
from k8t.logger import LOGGER
13+
from k8t.secrets import get_secret
14+
from k8t.util import b64decode, b64encode, hashf, random_password
1415

1516

1617
def build(path: str, cluster: str, environment: str):

kinja/environments.py renamed to k8t/environments.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import os
77
from typing import Any, Dict, List
88

9-
from kinja.values import load_value_file
9+
from k8t.values import load_value_file
1010

1111

1212
def list_environments(path: str) -> List[str]:
File renamed without changes.

kinja/secret_providers.py renamed to k8t/secret_providers.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
# Author: Aljosha Friemann <[email protected]>
55

66
import boto3
7-
from kinja.logger import LOGGER
7+
8+
from k8t.logger import LOGGER
89

910

1011
def ssm(key: str) -> str:

kinja/secrets.py renamed to k8t/secrets.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
# Copyright © 2019 Clark Germany GmbH
44
# Author: Aljosha Friemann <[email protected]>
55

6-
from kinja import secret_providers
7-
from kinja.config import load_configuration
6+
from k8t import secret_providers
7+
from k8t.config import load_configuration
88

99

1010
def get_secret(key: str, path: str, cluster: str, environment: str) -> str:

kinja/templates.py renamed to k8t/templates.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
from typing import Set, Tuple
88

99
from jinja2 import meta, nodes
10-
from kinja.logger import LOGGER
10+
11+
from k8t.logger import LOGGER
1112

1213
PROHIBITED_VARIABLE_NAMES = ['namespace']
1314

kinja/util.py renamed to k8t/util.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from functools import reduce
1212
from typing import Any
1313

14-
from kinja.logger import LOGGER
14+
from k8t.logger import LOGGER
1515

1616
try:
1717
from secrets import choice

kinja/values.py renamed to k8t/values.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
import os
77

88
import yaml
9-
from kinja.logger import LOGGER
9+
10+
from k8t.logger import LOGGER
1011

1112

1213
def load_value_file(path: str):

kinja/__init__.py

-6
This file was deleted.

setup.cfg

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
[metadata]
2-
name = kinja
2+
name = k8t
33
version = 0.0.1
4-
url = https://github.com/ClarkSource/kinja
4+
url = https://github.com/ClarkSource/k8t
55
author = Aljosha Friemann
66
author_email = [email protected]
77
description = Kubernetes templating engine based on Jinja2
88
long_description = file: README.rst
9-
long_description_content_type = text/x-rst
9+
long_description_content_type = text/markdown
1010
keywords = kubernetes, jinja
1111
platforms = linux
1212
license_file = LICENSE.txt

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
from setuptools import setup
44

55
setup(
6-
entry_points={'console_scripts': ['kinja=kinja.cli:main']}
6+
entry_points={'console_scripts': ['k8t=k8t.cli:main']}
77
)

tests/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# -*- coding: utf-8 -*-
2-
# vim:fenc=utf-8
32
#
43
# Copyright © 2018 Clark Germany GmbH
4+
# Author: Aljosha Friemann <[email protected]>

tests/config.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Copyright © 2019 Clark Germany GmbH
44
# Author: Aljosha Friemann <[email protected]>
55

6-
from kinja.config import validate
6+
from k8t.config import validate
77

88

99
def test_validate():

tests/util.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# -*- coding: utf-8 -*-
2-
# vim:fenc=utf-8
32
#
43
# Copyright © 2018 Clark Germany GmbH
4+
# Author: Aljosha Friemann <[email protected]>
55

66
import random
77

8-
from kinja.util import (b64decode, b64encode, deep_merge, hashf, merge,
9-
random_password)
8+
from k8t.util import (b64decode, b64encode, deep_merge, hashf, merge,
9+
random_password)
1010

1111

1212
def test_merge_memory_safety():

tox.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ deps = pytest
1313
pytest-cov
1414
commands = py.test \
1515
--junit-xml=reports/junit/{envname}.xml \
16-
--cov-config coverage.cfg --cov kinja --cov-report term --cov-report html:reports/coverage \
16+
--cov-config coverage.cfg --cov k8t --cov-report term --cov-report html:reports/coverage \
1717
{posargs}
1818

1919
[testenv:watch]

0 commit comments

Comments
 (0)