Merge branch 'cleanup-refactorings' into 'ddd-intro'

[Skip-CI] Cleanup refactorings

See merge request domaindrivenarchitecture/dda-devops-build!8
This commit is contained in:
Pat Dyn 2023-04-28 12:16:09 +00:00
commit 0bb9a8307f
6 changed files with 6 additions and 77 deletions

View file

@ -9,14 +9,14 @@ from .provs_k3s_mixin import ProvsK3sMixin, add_provs_k3s_mixin_config
from .aws_rds_pg_mixin import AwsRdsPgMixin, add_aws_rds_pg_mixin_config from .aws_rds_pg_mixin import AwsRdsPgMixin, add_aws_rds_pg_mixin_config
from .aws_mfa_mixin import AwsMfaMixin, add_aws_mfa_mixin_config from .aws_mfa_mixin import AwsMfaMixin, add_aws_mfa_mixin_config
from .aws_backend_properties_mixin import AwsBackendPropertiesMixin, add_aws_backend_properties_mixin_config from .aws_backend_properties_mixin import AwsBackendPropertiesMixin, add_aws_backend_properties_mixin_config
from .c4k_mixin import C4kMixin, add_c4k_mixin_config from .c4k_mixin import C4kBuild, add_c4k_mixin_config
from .exoscale_mixin import ExoscaleMixin, add_exoscale_mixin_config from .exoscale_mixin import ExoscaleMixin, add_exoscale_mixin_config
from .digitalocean_backend_properties_mixin import DigitaloceanBackendPropertiesMixin, add_digitalocean_backend_properties_mixin_config from .digitalocean_backend_properties_mixin import DigitaloceanBackendPropertiesMixin, add_digitalocean_backend_properties_mixin_config
from .digitalocean_terraform_build import DigitaloceanTerraformBuild, create_digitalocean_terraform_build_config from .digitalocean_terraform_build import DigitaloceanTerraformBuild, create_digitalocean_terraform_build_config
from .hetzner_mixin import HetznerMixin, add_hetzner_mixin_config from .hetzner_mixin import HetznerMixin, add_hetzner_mixin_config
from .devops_image_build import DevopsImageBuild, create_devops_docker_build_config from .devops_image_build import DevopsImageBuild, create_devops_docker_build_config
from .devops_terraform_build import DevopsTerraformBuild, create_devops_terraform_build_config from .devops_terraform_build import DevopsTerraformBuild, create_devops_terraform_build_config
from .devops_build import DevopsBuild, create_devops_build_config, get_devops_build, get_tag_from_latest_commit from .devops_build import DevopsBuild, create_devops_build_config, get_devops_build
from .credential import gopass_password_from_path, gopass_field_from_path from .credential import gopass_password_from_path, gopass_field_from_path
from .release_mixin import ReleaseMixin from .release_mixin import ReleaseMixin

View file

@ -44,9 +44,7 @@ def add_c4k_mixin_config(
) )
return config return config
class C4kBuild(DevopsBuild):
#TODO: refactor this to C4kBuild
class C4kMixin(DevopsBuild):
def __init__(self, project, config): def __init__(self, project, config):
super().__init__(project, config) super().__init__(project, config)
self.execution_api = ExecutionApi() self.execution_api = ExecutionApi()

View file

@ -19,22 +19,6 @@ def create_devops_build_config(
def get_devops_build(project): def get_devops_build(project):
return project.get_property("devops_build") return project.get_property("devops_build")
@deprecation.deprecated(deprecated_in="3.2")
# TODO: Remove from here! # pylint: disable=W0511
def get_tag_from_latest_commit():
try:
value = run(
"git describe --abbrev=0 --tags --exact-match",
shell=True,
capture_output=True,
check=True,
)
return value.stdout.decode("UTF-8").rstrip()
except CalledProcessError:
return None
class DevopsBuild: class DevopsBuild:
def __init__(self, project, config: Optional[dict] = None, devops: Optional[Devops] = None): def __init__(self, project, config: Optional[dict] = None, devops: Optional[Devops] = None):
self.project = project self.project = project

View file

@ -1,9 +1,9 @@
import os import os
from pybuilder.core import Project from pybuilder.core import Project
from src.main.python.ddadevops.domain import DnsRecord from src.main.python.ddadevops.domain import DnsRecord
from src.main.python.ddadevops.c4k_mixin import C4kMixin, add_c4k_mixin_config from src.main.python.ddadevops.c4k_mixin import C4kBuild, add_c4k_mixin_config
class MyC4kMixin(C4kMixin): class MyC4kBuild(C4kBuild):
pass pass
def test_c4k_mixin(tmp_path): def test_c4k_mixin(tmp_path):
@ -29,7 +29,7 @@ def test_c4k_mixin(tmp_path):
assert project_config.get('C4kMixin') is not None assert project_config.get('C4kMixin') is not None
mixin = MyC4kMixin(project, project_config) mixin = MyC4kBuild(project, project_config)
mixin.initialize_build_dir() mixin.initialize_build_dir()
assert mixin.build_path() == f'{tmp_path_str}/{build_dir}/{project_name}/{module_name}' assert mixin.build_path() == f'{tmp_path_str}/{build_dir}/{project_name}/{module_name}'

View file

@ -1,4 +0,0 @@
// TODO: jem, zam - 2023_04_18: move this to an build-test repo ?
{
"version": "123.125.1-SNAPSHOT"
}

View file

@ -1,49 +0,0 @@
# TODO: jem, zam - 2023_04_18: move this to an build-test repo?
import sys
import os
from pathlib import Path
from ddadevops import *
# getting the name of the directory
# where the this file is present.
current = os.path.dirname(os.path.realpath(__file__))
# adding the current directory to
# the sys.path.
sys.path.append(current)
# now we can import the module in the current
# directory.
from pybuilder.core import task, init
from ddadevops import *
from release_mixin import ReleaseMixin, create_release_mixin_config
CONFIG_FILE = Path('config.json')
MAIN_BRANCH = 'main'
STAGE = 'test'
PROJECT_ROOT_PATH = '.'
MODULE = 'test'
BUILD_DIR_NAME = "build_dir"
class MyBuild(ReleaseMixin):
pass
@init
def initialize(project):
project.build_depends_on('ddadevops>=3.1.2')
config = create_release_mixin_config(CONFIG_FILE, MAIN_BRANCH)
config.update({'stage': STAGE,
'module': MODULE,
'project_root_path': PROJECT_ROOT_PATH,
'build_dir_name': BUILD_DIR_NAME})
build = MyBuild(project, config)
build.initialize_build_dir()
@task
def release(project):
build = get_devops_build(project)
build.prepare_release()
build.tag_and_push_release()