Skip to content

Commit

Permalink
refactor: inline validate function
Browse files Browse the repository at this point in the history
Moved the `validators` up to the package as initializing them every time makes no sense, and inline the call as otherwise there would be only one statement in the function.
  • Loading branch information
Laubi committed Dec 12, 2024
1 parent 4efc711 commit dc2f197
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions pkg/deploy/internal/validate/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,15 @@ type Validator interface {
Validate(p project.Project, c config.Config) error
}

var validators = []Validator{
classic.NewValidator(),
&setting.DeprecatedSchemaValidator{},
&setting.InsertAfterSameScopeValidator{},
}

// Validate verifies that the passed projects are sound to an extent that can be checked before deployment.
// This means, that only checks can be performed that work on 'static' data.
func Validate(projects []project.Project) error {
defaultValidators := []Validator{
classic.NewValidator(),
&setting.DeprecatedSchemaValidator{},
&setting.InsertAfterSameScopeValidator{},
}

return validate(projects, defaultValidators)
}

func validate(projects []project.Project, validators []Validator) error {
errs := make(errors.EnvironmentDeploymentErrors)

for _, p := range projects {
Expand Down

0 comments on commit dc2f197

Please sign in to comment.