Skip to content

Commit

Permalink
#4 implement validateBlueprintStatically in blueprint application ser…
Browse files Browse the repository at this point in the history
…vice
  • Loading branch information
alexander-dammeier committed Nov 29, 2023
1 parent 313a454 commit 721d2f5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
2 changes: 1 addition & 1 deletion pkg/application/adpaterinterfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type DoguInstallationRepository interface {
}

type BlueprintRepository interface {
getByName(doguName string) (domain.BlueprintV2, error)
getById(doguName string) (domain.BlueprintV2, error)
getAll() ([]domain.BlueprintV2, error)
save(domain.BlueprintV2) error
delete(domain.BlueprintV2) error
Expand Down
17 changes: 5 additions & 12 deletions pkg/application/blueprintUseCase.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,16 @@ import (
import "github.com/cloudogu/k8s-blueprint-operator/pkg/domainservice"

type BlueprintUseCase struct {
repo BlueprintRepository
doguUseCase DoguInstallationUseCase
}

func (useCase BlueprintUseCase) validateBlueprintStatically(blueprint domain.BlueprintV2) error {
err := blueprint.Validate()
func (useCase BlueprintUseCase) validateBlueprintStatically(blueprintId string) error {
blueprint, err := useCase.repo.getById(blueprintId)
if err != nil {
err = fmt.Errorf("blueprint is invalid: %w", err)
return fmt.Errorf("cannot validate blueprint: %w", err)
}
return err
}

func (useCase BlueprintUseCase) validateEcosystemState(blueprint domain.BlueprintV2) error {
err := blueprint.Validate()
if err != nil {
err = fmt.Errorf("blueprint is invalid: %w", err)
}
return err
return blueprint.Validate()
}

func (useCase BlueprintUseCase) MakeBlueprintUpgrade(blueprint domain.BlueprintV2, mask domain.BlueprintMaskV1) {
Expand Down

0 comments on commit 721d2f5

Please sign in to comment.