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"
|
||||
|
||||
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"
|
||||
description = __doc__
|
||||
authors = [Author("meissa GmbH", "buero@meissa-gmbh.de")]
|
||||
|
|
|
@ -2,7 +2,7 @@ from pathlib import Path
|
|||
from dda_python_terraform import Terraform, IsFlagged
|
||||
from packaging import version
|
||||
|
||||
from ..domain import Devops, BuildType, TerraformDomain
|
||||
from ..domain import Devops, BuildType
|
||||
from ..infrastructure import FileApi, ResourceApi, TerraformApi
|
||||
|
||||
|
||||
|
@ -79,10 +79,10 @@ class TerraformService:
|
|||
self.__print_terraform_command__(terraform, devops)
|
||||
if terraform_domain.tf_use_workspace:
|
||||
try:
|
||||
terraform.workspace("select", self.stage)
|
||||
terraform.workspace("select", devops.stage)
|
||||
self.__print_terraform_command__(terraform, devops)
|
||||
except:
|
||||
terraform.workspace("new", self.stage)
|
||||
terraform.workspace("new", devops.stage)
|
||||
self.__print_terraform_command__(terraform, devops)
|
||||
return terraform
|
||||
|
||||
|
@ -115,7 +115,7 @@ class TerraformService:
|
|||
var=terraform_domain.project_vars(),
|
||||
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):
|
||||
raise RuntimeError(return_code, "terraform error:", stderr)
|
||||
if return_code == 2:
|
||||
|
@ -199,6 +199,7 @@ class TerraformService:
|
|||
tf_import_resource,
|
||||
):
|
||||
terraform_domain = devops.specialized_builds[BuildType.TERRAFORM]
|
||||
terraform = self.init_client(devops)
|
||||
return_code, _, stderr = terraform.import_cmd(
|
||||
tf_import_name,
|
||||
tf_import_resource,
|
||||
|
@ -207,6 +208,6 @@ class TerraformService:
|
|||
var=terraform_domain.project_vars(),
|
||||
var_file=terraform_domain.tf_additional_tfvar_files,
|
||||
)
|
||||
self.print_terraform_command(terraform, devops)
|
||||
self.__print_terraform_command__(terraform, devops)
|
||||
if return_code > 0:
|
||||
raise RuntimeError(return_code, "terraform error:", stderr)
|
||||
|
|
|
@ -86,7 +86,7 @@ class DevopsTerraformBuild(DevopsBuild):
|
|||
|
||||
def destroy(self, auto_approve=False):
|
||||
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()
|
||||
|
||||
def tf_import(
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
from .devops_terraform_build import (
|
||||
DevopsTerraformBuild,
|
||||
create_devops_terraform_build_config,
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from typing import List, Optional
|
||||
from typing import List, Dict, Optional
|
||||
from .common import (
|
||||
Validateable,
|
||||
CredentialMappingDefault,
|
||||
|
@ -66,7 +66,7 @@ class C4k(Validateable, CredentialMappingDefault):
|
|||
return f"c4k-{self.c4k_executable_name}-standalone.jar {config_path} {auth_path} > {output_path}"
|
||||
|
||||
@classmethod
|
||||
def get_mapping_default(cls) -> List[map]:
|
||||
def get_mapping_default(cls) -> List[Dict[str, str]]:
|
||||
return [
|
||||
{
|
||||
"gopass_path": "server/meissa/grafana-cloud",
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from enum import Enum
|
||||
from typing import List
|
||||
from typing import List, Dict
|
||||
|
||||
|
||||
def filter_none(list_to_filter):
|
||||
|
@ -59,9 +59,10 @@ class Validateable:
|
|||
|
||||
class CredentialMappingDefault:
|
||||
@classmethod
|
||||
def get_mapping_default(cls) -> List[map]:
|
||||
def get_mapping_default(cls) -> List[Dict[str, str]]:
|
||||
return []
|
||||
|
||||
|
||||
class DnsRecord(Validateable):
|
||||
def __init__(self, fqdn, ipv4=None, ipv6=None):
|
||||
self.fqdn = fqdn
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from typing import List
|
||||
from typing import List, Dict
|
||||
from .common import (
|
||||
filter_none,
|
||||
Validateable,
|
||||
|
@ -38,7 +38,7 @@ class Image(Validateable):
|
|||
return "/".join(filter_none(commons_path)) + "/"
|
||||
|
||||
@classmethod
|
||||
def get_mapping_default(cls) -> List[map]:
|
||||
def get_mapping_default(cls) -> List[Dict[str, str]]:
|
||||
return [
|
||||
{
|
||||
"gopass_path": "meissa/web/docker.com",
|
||||
|
|
|
@ -37,9 +37,9 @@ class InitService:
|
|||
)
|
||||
|
||||
def initialize(self, inp: dict) -> Devops:
|
||||
build_types = self.devops_factory.__parse_build_types__(inp["build_types"])
|
||||
mixin_types = self.devops_factory.__parse_mixin_types__(inp["mixin_types"])
|
||||
provider_types = TerraformDomain.parse_provider_types(inp["tf_provider_types"])
|
||||
build_types = self.devops_factory.__parse_build_types__(inp.get("build_types", []))
|
||||
mixin_types = self.devops_factory.__parse_mixin_types__(inp.get("mixin_types", []))
|
||||
provider_types = TerraformDomain.parse_provider_types(inp.get("tf_provider_types", []))
|
||||
|
||||
version = None
|
||||
default_mappings = []
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from typing import List
|
||||
from typing import List, Dict
|
||||
from .common import Validateable, CredentialMappingDefault
|
||||
|
||||
|
||||
|
@ -29,7 +29,7 @@ class Digitalocean(Validateable, CredentialMappingDefault):
|
|||
}
|
||||
|
||||
@classmethod
|
||||
def get_mapping_default(cls) -> List[map]:
|
||||
def get_mapping_default(cls) -> List[Dict[str, str]]:
|
||||
return [
|
||||
{
|
||||
"gopass_path": "server/devops/digitalocean/s3",
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
from typing import List, Optional
|
||||
from typing import List
|
||||
from pathlib import Path
|
||||
from .common import (
|
||||
Validateable,
|
||||
ProviderType,
|
||||
DnsRecord,
|
||||
Devops,
|
||||
filter_none,
|
||||
)
|
||||
from .provider_digitalocean import Digitalocean
|
||||
|
@ -70,7 +68,7 @@ class TerraformDomain(Validateable):
|
|||
return result
|
||||
|
||||
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():
|
||||
result += provider.resources_from_package()
|
||||
result += self.tf_additional_resources_from_package
|
||||
|
|
|
@ -36,7 +36,7 @@ class Version(Validateable):
|
|||
return self.to_string().__hash__()
|
||||
|
||||
def is_snapshot(self):
|
||||
return not self.snapshot_suffix is None
|
||||
return self.snapshot_suffix is not None
|
||||
|
||||
def to_string(self) -> str:
|
||||
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 sys import stdout
|
||||
from os import chmod, environ
|
||||
from pkg_resources import resource_string
|
||||
from json import load, dumps
|
||||
import yaml
|
||||
from pkg_resources import resource_string
|
||||
|
||||
|
||||
class ResourceApi:
|
||||
|
|
Loading…
Reference in a new issue