Skip to content

Commit

Permalink
refactor: Use new iterator in more places
Browse files Browse the repository at this point in the history
  • Loading branch information
Laubi committed Jan 23, 2025
1 parent ec29da5 commit 76f3148
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
13 changes: 7 additions & 6 deletions cmd/monaco/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,28 +192,29 @@ func validateProjectsWithEnvironments(projects []project.Project, envs manifest.
}

func collectOpenPipelineCoordinatesByKind(cfgPerType v2.ConfigsPerType, dest KindCoordinates) {
cfgPerType.ForEveryConfigDo(func(cfg config.Config) {
for cfg := range cfgPerType.AllConfigs {
if cfg.Skip {
return
continue
}

if openPipelineType, ok := cfg.Type.(config.OpenPipelineType); ok {
dest[openPipelineType.Kind] = append(dest[openPipelineType.Kind], cfg.Coordinate)
}
})
}
}

func collectPlatformCoordinates(cfgPerType v2.ConfigsPerType) []coordinate.Coordinate {
plaformCoordinates := []coordinate.Coordinate{}
cfgPerType.ForEveryConfigDo(func(cfg config.Config) {

for cfg := range cfgPerType.AllConfigs {
if cfg.Skip {
return
continue
}

if configRequiresPlatform(cfg) {
plaformCoordinates = append(plaformCoordinates, cfg.Coordinate)
}
})
}
return plaformCoordinates
}

Expand Down
14 changes: 3 additions & 11 deletions pkg/project/v2/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,17 +118,9 @@ func (p Project) ForEveryConfigInEnvironmentDo(environment string, action Action
func (p Project) forEveryConfigDo(environment string, action ActionOverConfig) {
for env, cpt := range p.Configs {
if environment == "" || environment == env {
cpt.ForEveryConfigDo(action)
}
}
}

// ForEveryConfigDo executes the given ActionOverConfig actions for each configuration defined in the ConfigsPerType.
// Actions can not modify the configs inside the ConfigsPerType.
func (cpt ConfigsPerType) ForEveryConfigDo(action ActionOverConfig) {
for _, cs := range cpt {
for _, c := range cs {
action(c)
for c := range cpt.AllConfigs {
action(c)
}
}
}
}
Expand Down

0 comments on commit 76f3148

Please sign in to comment.