Skip to content

Commit

Permalink
refactor: Remove unnecessary variadic arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
Laubi committed Jan 23, 2025
1 parent 9375567 commit d650c54
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions pkg/project/v2/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,35 +102,33 @@ func (p Project) String() string {

// ForEveryConfigDo executes the given ActionOverConfig actions for each configuration defined in the project for each environment
// Actions can not modify the configs inside the Project.
func (p Project) ForEveryConfigDo(actions ...ActionOverConfig) {
p.forEveryConfigDo("", actions)
func (p Project) ForEveryConfigDo(action ActionOverConfig) {
p.forEveryConfigDo("", action)
}

// ForEveryConfigInEnvironmentDo executes the given ActionOverConfig actions for each configuration defined in the project for a given environment.
// It behaves like ForEveryConfigDo just limited to a single environment.
// Actions can not modify the configs inside the Project.
func (p Project) ForEveryConfigInEnvironmentDo(environment string, actions ...ActionOverConfig) {
p.forEveryConfigDo(environment, actions)
func (p Project) ForEveryConfigInEnvironmentDo(environment string, action ActionOverConfig) {
p.forEveryConfigDo(environment, action)
}

// forEveryConfigDo applies the given action to every configuration, either for a single environment if requested,
// or for all environments if the environemnt parameter is empty.
func (p Project) forEveryConfigDo(environment string, actions []ActionOverConfig) {
func (p Project) forEveryConfigDo(environment string, action ActionOverConfig) {
for env, cpt := range p.Configs {
if environment == "" || environment == env {
cpt.ForEveryConfigDo(actions...)
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(actions ...ActionOverConfig) {
func (cpt ConfigsPerType) ForEveryConfigDo(action ActionOverConfig) {
for _, cs := range cpt {
for _, c := range cs {
for _, f := range actions {
f(c)
}
action(c)
}
}
}
Expand Down

0 comments on commit d650c54

Please sign in to comment.