Skip to content

Commit

Permalink
#81 replace doguConfigEntryRepos with the ones from registry-lib
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-dammeier committed Oct 8, 2024
1 parent a4a9c79 commit 5d76fc2
Show file tree
Hide file tree
Showing 21 changed files with 560 additions and 380 deletions.
5 changes: 5 additions & 0 deletions pkg/adapter/config/kubernetes/doguConfigRepository.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ type DoguConfigRepository struct {
repo repository.DoguConfigRepository
}

func (e DoguConfigRepository) GetAll(ctx context.Context, doguNames []common.SimpleDoguName) (map[common.SimpleDoguName]config.DoguConfig, error) {
//TODO implement me
panic("implement me")
}

func NewDoguConfigRepository(repo repository.DoguConfigRepository) *DoguConfigRepository {
return &DoguConfigRepository{repo: repo}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ type SensitiveDoguConfigRepository struct {
repo repository.DoguConfigRepository
}

func (e SensitiveDoguConfigRepository) GetAll(ctx context.Context, doguNames []common.SimpleDoguName) (map[common.SimpleDoguName]config.DoguConfig, error) {
//TODO implement me
panic("implement me")
}

func NewSensitiveDoguConfigRepository(repo repository.DoguConfigRepository) *SensitiveDoguConfigRepository {
return &SensitiveDoguConfigRepository{repo: repo}
}
Expand Down
15 changes: 6 additions & 9 deletions pkg/adapter/kubernetes/blueprintcr/v1/doguConfigDiff.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@ type DoguConfigEntryDiff struct {

type SensitiveDoguConfigDiff []SensitiveDoguConfigEntryDiff
type SensitiveDoguConfigEntryDiff struct {
Key string `json:"key"`
Actual DoguConfigValueState `json:"actual"`
Expected DoguConfigValueState `json:"expected"`
DoguNotInstalled bool `json:"doguNotInstalled,omitempty"`
NeededAction ConfigAction `json:"neededAction"`
Key string `json:"key"`
Actual DoguConfigValueState `json:"actual"`
Expected DoguConfigValueState `json:"expected"`
NeededAction ConfigAction `json:"neededAction"`
}

func convertToCombinedDoguConfigDiffDomain(doguName string, dto CombinedDoguConfigDiff) domain.CombinedDoguConfigDiffs {
Expand Down Expand Up @@ -87,8 +86,7 @@ func convertToSensitiveDoguConfigEntryDiffDomain(doguName string, dto SensitiveD
Value: dto.Expected.Value,
Exists: dto.Expected.Exists,
},
DoguAlreadyInstalled: !dto.DoguNotInstalled,
NeededAction: domain.ConfigAction(dto.NeededAction),
NeededAction: domain.ConfigAction(dto.NeededAction),
}
}

Expand Down Expand Up @@ -141,7 +139,6 @@ func convertToSensitiveDoguConfigEntryDiffDTO(domainModel domain.SensitiveDoguCo
Value: domainModel.Expected.Value,
Exists: domainModel.Expected.Exists,
},
DoguNotInstalled: !domainModel.DoguAlreadyInstalled,
NeededAction: ConfigAction(domainModel.NeededAction),
NeededAction: ConfigAction(domainModel.NeededAction),
}
}
24 changes: 8 additions & 16 deletions pkg/adapter/kubernetes/blueprintcr/v1/doguConfigDiff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ func Test_convertToCombinedDoguConfigDiffDTO(t *testing.T) {
Value: "1024m",
Exists: true,
},
DoguAlreadyInstalled: true,
NeededAction: domain.ConfigActionSet,
NeededAction: domain.ConfigActionSet,
},
{
Key: common.SensitiveDoguConfigKey{DoguConfigKey: common.DoguConfigKey{
Expand All @@ -113,8 +112,7 @@ func Test_convertToCombinedDoguConfigDiffDTO(t *testing.T) {
Value: "512m",
Exists: true,
},
DoguAlreadyInstalled: false,
NeededAction: domain.ConfigActionSet,
NeededAction: domain.ConfigActionSet,
},
},
},
Expand All @@ -130,8 +128,7 @@ func Test_convertToCombinedDoguConfigDiffDTO(t *testing.T) {
Value: "1024m",
Exists: true,
},
DoguNotInstalled: false,
NeededAction: "set",
NeededAction: "set",
},
{
Key: "container_config/swap_limit",
Expand All @@ -142,8 +139,7 @@ func Test_convertToCombinedDoguConfigDiffDTO(t *testing.T) {
Value: "512m",
Exists: true,
},
DoguNotInstalled: true,
NeededAction: "set",
NeededAction: "set",
},
},
},
Expand Down Expand Up @@ -244,8 +240,7 @@ func Test_convertToCombinedDoguConfigDiffDomain(t *testing.T) {
Value: "1024m",
Exists: true,
},
DoguNotInstalled: false,
NeededAction: "set",
NeededAction: "set",
},
{
Key: "container_config/swap_limit",
Expand All @@ -256,8 +251,7 @@ func Test_convertToCombinedDoguConfigDiffDomain(t *testing.T) {
Value: "512m",
Exists: true,
},
DoguNotInstalled: true,
NeededAction: "set",
NeededAction: "set",
},
},
},
Expand All @@ -276,8 +270,7 @@ func Test_convertToCombinedDoguConfigDiffDomain(t *testing.T) {
Value: "1024m",
Exists: true,
},
DoguAlreadyInstalled: true,
NeededAction: domain.ConfigActionSet,
NeededAction: domain.ConfigActionSet,
},
{
Key: common.SensitiveDoguConfigKey{DoguConfigKey: common.DoguConfigKey{
Expand All @@ -291,8 +284,7 @@ func Test_convertToCombinedDoguConfigDiffDomain(t *testing.T) {
Value: "512m",
Exists: true,
},
DoguAlreadyInstalled: false,
NeededAction: domain.ConfigActionSet,
NeededAction: domain.ConfigActionSet,
},
},
},
Expand Down
59 changes: 59 additions & 0 deletions pkg/application/mock_doguConfigRepository_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 59 additions & 0 deletions pkg/application/mock_sensitiveDoguConfigRepository_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 11 additions & 11 deletions pkg/application/stateDiffUseCase.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ type StateDiffUseCase struct {
doguInstallationRepo doguInstallationRepository
componentInstallationRepo componentInstallationRepository
globalConfigRepo globalConfigRepository
doguConfigRepo doguConfigEntryRepository
sensitiveDoguConfigRepo sensitiveDoguConfigEntryRepository
doguConfigRepo doguConfigRepository
sensitiveDoguConfigRepo sensitiveDoguConfigRepository
}

func NewStateDiffUseCase(
blueprintSpecRepo domainservice.BlueprintSpecRepository,
doguInstallationRepo domainservice.DoguInstallationRepository,
componentInstallationRepo domainservice.ComponentInstallationRepository,
globalConfigRepo domainservice.GlobalConfigRepository,
doguConfigRepo domainservice.DoguConfigEntryRepository,
sensitiveDoguConfigRepo domainservice.SensitiveDoguConfigEntryRepository,
doguConfigRepo domainservice.DoguConfigRepository,
sensitiveDoguConfigRepo domainservice.SensitiveDoguConfigRepository,
) *StateDiffUseCase {
return &StateDiffUseCase{
blueprintSpecRepo: blueprintSpecRepo,
Expand Down Expand Up @@ -92,9 +92,9 @@ func (useCase *StateDiffUseCase) collectEcosystemState(ctx context.Context, effe
logger.Info("collect needed global config")
globalConfig, globalConfigErr := useCase.globalConfigRepo.Get(ctx)
logger.Info("collect needed dogu config")
doguConfig, doguConfigErr := useCase.doguConfigRepo.GetAllByKey(ctx, effectiveBlueprint.Config.GetDoguConfigKeys())
configByDogu, doguConfigErr := useCase.doguConfigRepo.GetAll(ctx, effectiveBlueprint.Config.GetDogusWithChangedConfig())
logger.Info("collect needed sensitive dogu config")
sensitiveDoguConfig, sensitiveConfigErr := useCase.sensitiveDoguConfigRepo.GetAllByKey(ctx, effectiveBlueprint.Config.GetSensitiveDoguConfigKeys())
sensitiveConfigByDogu, sensitiveConfigErr := useCase.sensitiveDoguConfigRepo.GetAll(ctx, effectiveBlueprint.Config.GetDogusWithChangedSensitiveConfig())

joinedError := errors.Join(doguErr, componentErr, globalConfigErr, doguConfigErr, sensitiveConfigErr)

Expand All @@ -106,10 +106,10 @@ func (useCase *StateDiffUseCase) collectEcosystemState(ctx context.Context, effe
}

return ecosystem.EcosystemState{
InstalledDogus: installedDogus,
InstalledComponents: installedComponents,
GlobalConfig: globalConfig,
DoguConfig: doguConfig,
SensitiveDoguConfig: sensitiveDoguConfig,
InstalledDogus: installedDogus,
InstalledComponents: installedComponents,
GlobalConfig: globalConfig,
ConfigByDogu: configByDogu,
SensitiveConfigByDogu: sensitiveConfigByDogu,
}, nil
}
Loading

0 comments on commit 5d76fc2

Please sign in to comment.