2020-03-03 09:20:54 +00:00
|
|
|
from .credential import gopass_credential_from_env_path
|
2020-03-03 15:34:12 +00:00
|
|
|
from .devops_terraform_build import DevopsTerraformBuild
|
2020-03-03 09:20:54 +00:00
|
|
|
|
|
|
|
|
2020-03-03 15:34:12 +00:00
|
|
|
def add_hetzner_mixin_config(config):
|
2020-03-03 16:33:00 +00:00
|
|
|
config.update({'HetznerMixin':
|
|
|
|
{'HETZNER_API_KEY_PATH_ENVIRONMENT': 'HETZNER_API_KEY_PATH'}})
|
|
|
|
return config
|
2020-03-03 15:34:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
class HetznerMixin(DevopsTerraformBuild):
|
|
|
|
|
|
|
|
def __init__(self, project, config):
|
2020-03-03 16:36:56 +00:00
|
|
|
super().__init__(project, config)
|
2020-03-03 15:34:12 +00:00
|
|
|
hetzner_mixin_config = config['HetznerMixin']
|
|
|
|
self.hetzner_api_key = gopass_credential_from_env_path(
|
|
|
|
hetzner_mixin_config['HETZNER_API_KEY_PATH_ENVIRONMENT'])
|
2020-03-03 09:20:54 +00:00
|
|
|
|
|
|
|
def project_vars(self):
|
2020-03-03 17:30:17 +00:00
|
|
|
ret = super().project_vars()
|
2020-03-03 09:20:54 +00:00
|
|
|
if self.hetzner_api_key:
|
|
|
|
ret['hetzner_api_key'] = self.hetzner_api_key
|
2020-03-03 15:34:12 +00:00
|
|
|
return ret
|