minor fixes
This commit is contained in:
parent
70a671a06d
commit
dc9236d766
12 changed files with 25 additions and 26 deletions
2
build.py
2
build.py
|
@ -28,7 +28,7 @@ use_plugin("python.distutils")
|
||||||
default_task = "publish"
|
default_task = "publish"
|
||||||
|
|
||||||
name = "ddadevops"
|
name = "ddadevops"
|
||||||
version = "4.0.0-dev52"
|
version = "4.0.0-dev57"
|
||||||
summary = "tools to support builds combining gopass, terraform, dda-pallet, aws & hetzner-cloud"
|
summary = "tools to support builds combining gopass, terraform, dda-pallet, aws & hetzner-cloud"
|
||||||
description = __doc__
|
description = __doc__
|
||||||
authors = [Author("meissa GmbH", "buero@meissa-gmbh.de")]
|
authors = [Author("meissa GmbH", "buero@meissa-gmbh.de")]
|
||||||
|
|
|
@ -2,7 +2,7 @@ from pathlib import Path
|
||||||
from dda_python_terraform import Terraform, IsFlagged
|
from dda_python_terraform import Terraform, IsFlagged
|
||||||
from packaging import version
|
from packaging import version
|
||||||
|
|
||||||
from ..domain import Devops, BuildType, TerraformDomain
|
from ..domain import Devops, BuildType
|
||||||
from ..infrastructure import FileApi, ResourceApi, TerraformApi
|
from ..infrastructure import FileApi, ResourceApi, TerraformApi
|
||||||
|
|
||||||
|
|
||||||
|
@ -79,10 +79,10 @@ class TerraformService:
|
||||||
self.__print_terraform_command__(terraform, devops)
|
self.__print_terraform_command__(terraform, devops)
|
||||||
if terraform_domain.tf_use_workspace:
|
if terraform_domain.tf_use_workspace:
|
||||||
try:
|
try:
|
||||||
terraform.workspace("select", self.stage)
|
terraform.workspace("select", devops.stage)
|
||||||
self.__print_terraform_command__(terraform, devops)
|
self.__print_terraform_command__(terraform, devops)
|
||||||
except:
|
except:
|
||||||
terraform.workspace("new", self.stage)
|
terraform.workspace("new", devops.stage)
|
||||||
self.__print_terraform_command__(terraform, devops)
|
self.__print_terraform_command__(terraform, devops)
|
||||||
return terraform
|
return terraform
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ class TerraformService:
|
||||||
var=terraform_domain.project_vars(),
|
var=terraform_domain.project_vars(),
|
||||||
var_file=terraform_domain.tf_additional_tfvar_files,
|
var_file=terraform_domain.tf_additional_tfvar_files,
|
||||||
)
|
)
|
||||||
self.__print_terraform_command__(terraform)
|
self.__print_terraform_command__(terraform, devops)
|
||||||
if return_code not in (0, 2):
|
if return_code not in (0, 2):
|
||||||
raise RuntimeError(return_code, "terraform error:", stderr)
|
raise RuntimeError(return_code, "terraform error:", stderr)
|
||||||
if return_code == 2:
|
if return_code == 2:
|
||||||
|
@ -199,6 +199,7 @@ class TerraformService:
|
||||||
tf_import_resource,
|
tf_import_resource,
|
||||||
):
|
):
|
||||||
terraform_domain = devops.specialized_builds[BuildType.TERRAFORM]
|
terraform_domain = devops.specialized_builds[BuildType.TERRAFORM]
|
||||||
|
terraform = self.init_client(devops)
|
||||||
return_code, _, stderr = terraform.import_cmd(
|
return_code, _, stderr = terraform.import_cmd(
|
||||||
tf_import_name,
|
tf_import_name,
|
||||||
tf_import_resource,
|
tf_import_resource,
|
||||||
|
@ -207,6 +208,6 @@ class TerraformService:
|
||||||
var=terraform_domain.project_vars(),
|
var=terraform_domain.project_vars(),
|
||||||
var_file=terraform_domain.tf_additional_tfvar_files,
|
var_file=terraform_domain.tf_additional_tfvar_files,
|
||||||
)
|
)
|
||||||
self.print_terraform_command(terraform, devops)
|
self.__print_terraform_command__(terraform, devops)
|
||||||
if return_code > 0:
|
if return_code > 0:
|
||||||
raise RuntimeError(return_code, "terraform error:", stderr)
|
raise RuntimeError(return_code, "terraform error:", stderr)
|
||||||
|
|
|
@ -86,7 +86,7 @@ class DevopsTerraformBuild(DevopsBuild):
|
||||||
|
|
||||||
def destroy(self, auto_approve=False):
|
def destroy(self, auto_approve=False):
|
||||||
devops = self.devops_repo.get_devops(self.project)
|
devops = self.devops_repo.get_devops(self.project)
|
||||||
self.teraform_service.refresh(devops)
|
self.teraform_service.destroy(devops, auto_approve=auto_approve)
|
||||||
self.post_build()
|
self.post_build()
|
||||||
|
|
||||||
def tf_import(
|
def tf_import(
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
from .devops_terraform_build import (
|
from .devops_terraform_build import (
|
||||||
DevopsTerraformBuild,
|
DevopsTerraformBuild,
|
||||||
create_devops_terraform_build_config,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from typing import List, Optional
|
from typing import List, Dict, Optional
|
||||||
from .common import (
|
from .common import (
|
||||||
Validateable,
|
Validateable,
|
||||||
CredentialMappingDefault,
|
CredentialMappingDefault,
|
||||||
|
@ -66,7 +66,7 @@ class C4k(Validateable, CredentialMappingDefault):
|
||||||
return f"c4k-{self.c4k_executable_name}-standalone.jar {config_path} {auth_path} > {output_path}"
|
return f"c4k-{self.c4k_executable_name}-standalone.jar {config_path} {auth_path} > {output_path}"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_mapping_default(cls) -> List[map]:
|
def get_mapping_default(cls) -> List[Dict[str, str]]:
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
"gopass_path": "server/meissa/grafana-cloud",
|
"gopass_path": "server/meissa/grafana-cloud",
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from typing import List
|
from typing import List, Dict
|
||||||
|
|
||||||
|
|
||||||
def filter_none(list_to_filter):
|
def filter_none(list_to_filter):
|
||||||
|
@ -59,9 +59,10 @@ class Validateable:
|
||||||
|
|
||||||
class CredentialMappingDefault:
|
class CredentialMappingDefault:
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_mapping_default(cls) -> List[map]:
|
def get_mapping_default(cls) -> List[Dict[str, str]]:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
|
||||||
class DnsRecord(Validateable):
|
class DnsRecord(Validateable):
|
||||||
def __init__(self, fqdn, ipv4=None, ipv6=None):
|
def __init__(self, fqdn, ipv4=None, ipv6=None):
|
||||||
self.fqdn = fqdn
|
self.fqdn = fqdn
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from typing import List
|
from typing import List, Dict
|
||||||
from .common import (
|
from .common import (
|
||||||
filter_none,
|
filter_none,
|
||||||
Validateable,
|
Validateable,
|
||||||
|
@ -38,7 +38,7 @@ class Image(Validateable):
|
||||||
return "/".join(filter_none(commons_path)) + "/"
|
return "/".join(filter_none(commons_path)) + "/"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_mapping_default(cls) -> List[map]:
|
def get_mapping_default(cls) -> List[Dict[str, str]]:
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
"gopass_path": "meissa/web/docker.com",
|
"gopass_path": "meissa/web/docker.com",
|
||||||
|
|
|
@ -37,9 +37,9 @@ class InitService:
|
||||||
)
|
)
|
||||||
|
|
||||||
def initialize(self, inp: dict) -> Devops:
|
def initialize(self, inp: dict) -> Devops:
|
||||||
build_types = self.devops_factory.__parse_build_types__(inp["build_types"])
|
build_types = self.devops_factory.__parse_build_types__(inp.get("build_types", []))
|
||||||
mixin_types = self.devops_factory.__parse_mixin_types__(inp["mixin_types"])
|
mixin_types = self.devops_factory.__parse_mixin_types__(inp.get("mixin_types", []))
|
||||||
provider_types = TerraformDomain.parse_provider_types(inp["tf_provider_types"])
|
provider_types = TerraformDomain.parse_provider_types(inp.get("tf_provider_types", []))
|
||||||
|
|
||||||
version = None
|
version = None
|
||||||
default_mappings = []
|
default_mappings = []
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from typing import List
|
from typing import List, Dict
|
||||||
from .common import Validateable, CredentialMappingDefault
|
from .common import Validateable, CredentialMappingDefault
|
||||||
|
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ class Digitalocean(Validateable, CredentialMappingDefault):
|
||||||
}
|
}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_mapping_default(cls) -> List[map]:
|
def get_mapping_default(cls) -> List[Dict[str, str]]:
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
"gopass_path": "server/devops/digitalocean/s3",
|
"gopass_path": "server/devops/digitalocean/s3",
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
from typing import List, Optional
|
from typing import List
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from .common import (
|
from .common import (
|
||||||
Validateable,
|
Validateable,
|
||||||
ProviderType,
|
ProviderType,
|
||||||
DnsRecord,
|
|
||||||
Devops,
|
|
||||||
filter_none,
|
filter_none,
|
||||||
)
|
)
|
||||||
from .provider_digitalocean import Digitalocean
|
from .provider_digitalocean import Digitalocean
|
||||||
|
@ -70,7 +68,7 @@ class TerraformDomain(Validateable):
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def resources_from_package(self) -> List[str]:
|
def resources_from_package(self) -> List[str]:
|
||||||
result = ["version.tf", "terraform_build_vars.tf"]
|
result = ["versions.tf", "terraform_build_vars.tf"]
|
||||||
for provider in self.providers.values():
|
for provider in self.providers.values():
|
||||||
result += provider.resources_from_package()
|
result += provider.resources_from_package()
|
||||||
result += self.tf_additional_resources_from_package
|
result += self.tf_additional_resources_from_package
|
||||||
|
|
|
@ -36,7 +36,7 @@ class Version(Validateable):
|
||||||
return self.to_string().__hash__()
|
return self.to_string().__hash__()
|
||||||
|
|
||||||
def is_snapshot(self):
|
def is_snapshot(self):
|
||||||
return not self.snapshot_suffix is None
|
return self.snapshot_suffix is not None
|
||||||
|
|
||||||
def to_string(self) -> str:
|
def to_string(self) -> str:
|
||||||
version_no = ".".join([str(x) for x in self.version_list])
|
version_no = ".".join([str(x) for x in self.version_list])
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
from subprocess import check_output, Popen, PIPE, run
|
from subprocess import Popen, PIPE, run
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from sys import stdout
|
from sys import stdout
|
||||||
from os import chmod, environ
|
from os import chmod, environ
|
||||||
from pkg_resources import resource_string
|
|
||||||
from json import load, dumps
|
from json import load, dumps
|
||||||
import yaml
|
import yaml
|
||||||
|
from pkg_resources import resource_string
|
||||||
|
|
||||||
|
|
||||||
class ResourceApi:
|
class ResourceApi:
|
||||||
|
|
Loading…
Reference in a new issue