mv credentials to init-service because of lifecycle

This commit is contained in:
Michael Jerger 2023-05-16 19:21:31 +02:00
parent b7bce9df6b
commit 1a90f2dfe2
4 changed files with 20 additions and 18 deletions

View file

@ -40,7 +40,7 @@ classDiagram
version version
} }
class Credentials { class Credentials {
<<AggregateRoot>>
} }
class CredentialMapping { class CredentialMapping {
name name
@ -72,7 +72,6 @@ classDiagram
Devops *-- "0..1" Image: spcialized_builds Devops *-- "0..1" Image: spcialized_builds
Devops *-- "0..1" C4k: spcialized_builds Devops *-- "0..1" C4k: spcialized_builds
Devops *-- "0..1" Release: mixins Devops *-- "0..1" Release: mixins
Devops *-- "0..1" Credentials: mixins
Release o-- "0..1" BuildFile: primary_build_file Release o-- "0..1" BuildFile: primary_build_file
Release o-- "0..n" BuildFile: secondary_build_files Release o-- "0..n" BuildFile: secondary_build_files
BuildFile *-- "1" Version BuildFile *-- "1" Version

View file

@ -15,7 +15,6 @@ class BuildType(Enum):
class MixinType(Enum): class MixinType(Enum):
RELEASE = 0 RELEASE = 0
CREDENTIALS = 1
class ReleaseType(Enum): class ReleaseType(Enum):

View file

@ -25,19 +25,6 @@ class DevopsFactory:
mixins = {} mixins = {}
if MixinType.RELEASE in mixin_types: if MixinType.RELEASE in mixin_types:
mixins[MixinType.RELEASE] = Release(input, version) 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) devops = Devops(input, specialized_builds=specialized_builds, mixins=mixins)

View file

@ -1,5 +1,6 @@
from pathlib import Path 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 .devops_factory import DevopsFactory
from .version import Version from .version import Version
from src.main.python.ddadevops.infrastructure import ( from src.main.python.ddadevops.infrastructure import (
@ -18,8 +19,10 @@ class InitService:
BuildFileRepository(base_dir), 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"]) mixin_types = self.devops_factory.__parse_mixin_types__(input["mixin_types"])
version = None version = None
if MixinType.RELEASE in mixin_types: 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)) primary_build_file = self.build_file_repository.get(Path(primary_build_file_id))
version = primary_build_file.get_version() 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) return self.devops_factory.build_devops(input, version=version)