-
Notifications
You must be signed in to change notification settings - Fork 44
/
build_kubernetes.py
53 lines (50 loc) · 1.75 KB
/
build_kubernetes.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import click
@click.command(help='Build the kubernetes.yml file')
@click.option('--tls', default=False, type=bool, is_flag=True, help='Whether or not to build the kubernetes.yml with tls support')
@click.option('--minio', default=False, type=bool, is_flag=True, help='Whether or not to build the kubernetes.yml with a minio deployment')
@click.option('--auth', default=False, type=bool, is_flag=True, help='Whether or not to build the kubernetes.yml with a authentication support')
@click.option('--aws-proxy', default=False, type=bool, is_flag=True, help='An additional proxy to aws for legacy reasons, maps /storage => aws bucket')
def build_kubernetes(tls, minio, auth, aws_proxy):
import os
import json
import glob
from math import log10
from itertools import count
from jinja2 import Environment, FileSystemLoader
#
root_dir = os.path.realpath(os.path.join(os.path.dirname(__file__), '..'))
version = open(os.path.join(root_dir, 'VERSION'), 'r').read().strip()
appyter_path = os.path.join(root_dir, 'appyters')
appyters = [
dict(
path=os.path.dirname(path),
**json.load(open(path, 'r')),
)
for path in glob.glob(os.path.join(appyter_path, '*', 'appyter.json'))
]
env = Environment(
loader=FileSystemLoader(os.path.join(os.path.dirname(__file__), 'templates')),
)
template = env.get_template('kubernetes.yml.j2')
kubernetes = template.render(
appyters=appyters,
count=count,
enumerate=enumerate,
int=int,
iter=iter,
len=len,
log10=log10,
next=next,
os=os,
root_dir=root_dir,
version=version,
tls=tls,
auth=auth,
minio=minio,
aws_proxy=aws_proxy,
)
print(kubernetes)
if __name__ == '__main__':
from dotenv import load_dotenv
load_dotenv()
build_kubernetes()