diff --git a/doc/architecture/Domain.md b/doc/architecture/Domain.md index b2838b1..9a59a4c 100644 --- a/doc/architecture/Domain.md +++ b/doc/architecture/Domain.md @@ -40,7 +40,7 @@ classDiagram version } class Credentials { - + <> } class CredentialMapping { name @@ -72,7 +72,6 @@ classDiagram Devops *-- "0..1" Image: spcialized_builds Devops *-- "0..1" C4k: spcialized_builds Devops *-- "0..1" Release: mixins - Devops *-- "0..1" Credentials: mixins Release o-- "0..1" BuildFile: primary_build_file Release o-- "0..n" BuildFile: secondary_build_files BuildFile *-- "1" Version diff --git a/src/main/python/ddadevops/domain/common.py b/src/main/python/ddadevops/domain/common.py index 95121b5..0ed8664 100644 --- a/src/main/python/ddadevops/domain/common.py +++ b/src/main/python/ddadevops/domain/common.py @@ -15,7 +15,6 @@ class BuildType(Enum): class MixinType(Enum): RELEASE = 0 - CREDENTIALS = 1 class ReleaseType(Enum): diff --git a/src/main/python/ddadevops/domain/devops_factory.py b/src/main/python/ddadevops/domain/devops_factory.py index afeb58d..6cb4a6d 100644 --- a/src/main/python/ddadevops/domain/devops_factory.py +++ b/src/main/python/ddadevops/domain/devops_factory.py @@ -25,19 +25,6 @@ class DevopsFactory: mixins = {} if MixinType.RELEASE in mixin_types: mixins[MixinType.RELEASE] = Release(input, version) - if MixinType.CREDENTIALS in mixin_types: - if BuildType.C4K in build_types: - default_mappings = [ - { - "gopass_path": "server/meissa/grafana-cloud", - "gopass_field": "grafana-cloud-user", - }, - { - "gopass_path": "server/meissa/grafana-cloud", - "name": "grafana_cloud_password", - } - ] - mixins[MixinType.CREDENTIALS] = Credentials(input, default_mappings) devops = Devops(input, specialized_builds=specialized_builds, mixins=mixins) diff --git a/src/main/python/ddadevops/domain/init_service.py b/src/main/python/ddadevops/domain/init_service.py index e6d690e..087641f 100644 --- a/src/main/python/ddadevops/domain/init_service.py +++ b/src/main/python/ddadevops/domain/init_service.py @@ -1,5 +1,6 @@ from pathlib import Path -from .common import Devops, MixinType +from .common import Devops, MixinType, BuildType +from .credentials import Credentials from .devops_factory import DevopsFactory from .version import Version from src.main.python.ddadevops.infrastructure import ( @@ -18,8 +19,10 @@ class InitService: BuildFileRepository(base_dir), ) - def initialize(self, input: dict) -> Devops: + def initialize(self, input: dict) -> Devops: + build_types = self.devops_factory.__parse_build_types__(input["build_types"]) mixin_types = self.devops_factory.__parse_mixin_types__(input["mixin_types"]) + version = None if MixinType.RELEASE in mixin_types: @@ -27,4 +30,18 @@ class InitService: primary_build_file = self.build_file_repository.get(Path(primary_build_file_id)) version = primary_build_file.get_version() + + if BuildType.C4K in build_types: + default_mappings = [ + { + "gopass_path": "server/meissa/grafana-cloud", + "gopass_field": "grafana-cloud-user", + }, + { + "gopass_path": "server/meissa/grafana-cloud", + "name": "grafana_cloud_password", + } + ] + credentials = Credentials(input, default_mappings) + return self.devops_factory.build_devops(input, version=version)