Finalize c4k_mixin
This commit is contained in:
parent
af8b2571e2
commit
81e3ac8078
1 changed files with 30 additions and 18 deletions
|
@ -1,27 +1,32 @@
|
||||||
|
from os import chmod
|
||||||
from string import Template
|
from string import Template
|
||||||
from subprocess import run
|
from subprocess import run
|
||||||
#from .python_util import *
|
from .python_util import *
|
||||||
#from .devops_build import DevopsBuild
|
from .devops_build import DevopsBuild
|
||||||
|
|
||||||
def add_c4k_mixin_config(config,
|
def add_c4k_mixin_config(config,
|
||||||
|
c4k_module_name=None,
|
||||||
c4k_config_dict=None,
|
c4k_config_dict=None,
|
||||||
c4k_auth_dict=None):
|
c4k_auth_dict=None):
|
||||||
|
if c4k_module_name == None:
|
||||||
|
c4k_module_name = 'NO_MODULE'
|
||||||
if c4k_config_dict == None:
|
if c4k_config_dict == None:
|
||||||
c4k_config_dict = {}
|
c4k_config_dict = {}
|
||||||
if c4k_auth_dict == None:
|
if c4k_auth_dict == None:
|
||||||
c4k_auth_dict = {}
|
c4k_auth_dict = {}
|
||||||
|
|
||||||
config.update({'C4kMixinConfig': c4k_config_dict})
|
config.update({'C4kMixin': {'Config': c4k_config_dict,
|
||||||
config.update({'C4kMixinAuth': c4k_auth_dict})
|
'Auth': c4k_auth_dict,
|
||||||
|
'Name': c4k_module_name}})
|
||||||
return config
|
return config
|
||||||
|
|
||||||
|
|
||||||
def generate_default_template(keys):
|
def generate_clojure_map(template_dict):
|
||||||
config_template = '{'
|
clojure_map_str = '{'
|
||||||
for key in keys:
|
for key, value in template_dict:
|
||||||
config_template += f':{key} "${key}"\n'
|
clojure_map_str += f':{key} {value}\n'
|
||||||
config_template += '}'
|
clojure_map_str += '}'
|
||||||
return config_template
|
return clojure_map_str
|
||||||
|
|
||||||
|
|
||||||
#DevopsBuild
|
#DevopsBuild
|
||||||
|
@ -29,17 +34,24 @@ class C4kMixin():
|
||||||
|
|
||||||
def __init__(self, project, config):
|
def __init__(self, project, config):
|
||||||
super().__init__(project, config)
|
super().__init__(project, config)
|
||||||
self.c4k_mixin_config = config['C4kMixinConfig']
|
self.c4k_mixin_config = config['C4kMixin']['Config']
|
||||||
self.c4k_mixin_auth = config['C4kMixinAuth']
|
self.c4k_mixin_auth = config['C4kMixin']['Auth']
|
||||||
|
self.c4k_module_name = config['C4kMixin']['Name']
|
||||||
|
|
||||||
def write_c4k_config(self):
|
def write_c4k_config(self):
|
||||||
raise NotImplemented
|
with open(self.build_path() + '/out_config.edn', 'w') as output_file:
|
||||||
|
output_file.write(generate_clojure_map(self.c4k_mixin_config))
|
||||||
|
|
||||||
def write_c4k_auth(self):
|
def write_c4k_auth(self):
|
||||||
raise NotImplemented
|
with open(self.build_path() + '/out_auth.edn' 'w') as output_file:
|
||||||
|
output_file.write(generate_clojure_map(self.c4k_mixin_auth))
|
||||||
|
chmod(self.build_path() + '/out_auth.edn', 0o600)
|
||||||
|
|
||||||
def c4k_apply(self):
|
def c4k_apply(self):
|
||||||
raise NotImplemented
|
cmd = [f'c4k-{self.c4k_module_name}-standalone.jar' +
|
||||||
|
self.build_path() + '/out_config.edn' +
|
||||||
|
self.build_path() + '/out_auth.edn' +
|
||||||
add_c4k_mixin_config({}, ['test', 'test2', 'fqdn'], [])
|
'> ' + self.build_path() + '/out_jitsi.yaml']
|
||||||
|
output = execute(cmd, True)
|
||||||
|
print(output)
|
||||||
|
return output
|
||||||
|
|
Loading…
Reference in a new issue