try mixin
This commit is contained in:
parent
437d22ff4f
commit
c77c434794
2 changed files with 13 additions and 49 deletions
13
src/main/python/ddadevops/hetzner_mixin.py
Normal file
13
src/main/python/ddadevops/hetzner_mixin.py
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
from .credential import gopass_credential_from_env_path
|
||||||
|
|
||||||
|
class HetznerMixin:
|
||||||
|
|
||||||
|
def __init__(self, project, project_root_path, build_commons_path, module, stage):
|
||||||
|
super().__init__(self, project, project_root_path, build_commons_path, module, stage)
|
||||||
|
self.hetzner_api_key = gopass_credential_from_env_path('HETZNER_API_KEY_PATH')
|
||||||
|
|
||||||
|
def project_vars(self):
|
||||||
|
ret = super().project_vars
|
||||||
|
if self.hetzner_api_key:
|
||||||
|
ret['hetzner_api_key'] = self.hetzner_api_key
|
||||||
|
return ret
|
|
@ -1,49 +0,0 @@
|
||||||
import os
|
|
||||||
from .credential import gopass_credential_from_env_path
|
|
||||||
from .build import init_project
|
|
||||||
from subprocess import run
|
|
||||||
|
|
||||||
STAGE = 'stage'
|
|
||||||
HTTP_NET_API_KEY = 'http_net_api_key'
|
|
||||||
HETZNER_API_KEY = 'hetzner_api_key'
|
|
||||||
PROJECT_ROOT_PATH = 'project_root_path'
|
|
||||||
BUILD_COMMONS_PATH = 'build_commons_path'
|
|
||||||
|
|
||||||
def meissa_init_project(project, project_root_path, build_commons_path, module):
|
|
||||||
project = init_project(project, project_root_path, build_commons_path, module)
|
|
||||||
project.set_property(HTTP_NET_API_KEY, \
|
|
||||||
gopass_credential_from_env_path('HTTP_NET_API_KEY_PATH'))
|
|
||||||
project.set_property(HETZNER_API_KEY, \
|
|
||||||
gopass_credential_from_env_path('HETZNER_API_KEY_PATH'))
|
|
||||||
return project
|
|
||||||
|
|
||||||
def hetzner_api_key(project):
|
|
||||||
return project.get_property(HETZNER_API_KEY)
|
|
||||||
|
|
||||||
def stage(project):
|
|
||||||
return project.get_property(STAGE)
|
|
||||||
|
|
||||||
def module(project):
|
|
||||||
return project.get_property('name')
|
|
||||||
|
|
||||||
def project_root_path(project):
|
|
||||||
return project.get_property(PROJECT_ROOT_PATH)
|
|
||||||
|
|
||||||
def build_commons_path(project):
|
|
||||||
return project.get_property(BUILD_COMMONS_PATH)
|
|
||||||
|
|
||||||
def build_target_path(project):
|
|
||||||
return project_root_path(project) + 'target/' + project.name + '/'
|
|
||||||
|
|
||||||
def tf_import_name(project):
|
|
||||||
return project.get_property('tf_import_name')
|
|
||||||
|
|
||||||
def tf_import_resource(project):
|
|
||||||
return project.get_property('tf_import_resource')
|
|
||||||
|
|
||||||
def initialize_target(project):
|
|
||||||
run('rm -rf ' + build_target_path(project), shell=True)
|
|
||||||
run('mkdir -p ' + build_target_path(project), shell=True)
|
|
||||||
run('cp *.tf ' + build_target_path(project), shell=True)
|
|
||||||
run('cp *.tfars ' + build_target_path(project), shell=True)
|
|
||||||
run('cp *.edn ' + build_target_path(project), shell=True)
|
|
Loading…
Reference in a new issue