Skip to content

Commit

Permalink
Allow legacy --puppetfile flag to be used
Browse files Browse the repository at this point in the history
This allows for utilizing the current version of webhook-go in
environments saddled with legacy versions of r10k that don't yet have
the new --modules flag.
  • Loading branch information
genebean authored and dhollinger committed May 8, 2024
1 parent 89c6987 commit 0396177
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,12 @@ Type: bool
Description: Deploy modules in environments.
Default: `true`

### `use_legacy_puppetfile_flag`

Type: bool
Description: Use the legacy `--puppetfile` flag instead of `--modules`. This should only be used when your version of r10k doesn't support the newer flag.
Default: `false`

### `generate_types`

Type: bool
Expand Down
6 changes: 5 additions & 1 deletion api/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ func (e EnvironmentController) DeployEnvironment(c *gin.Context) {
cmd = append(cmd, "--generate-types")
}
if conf.R10k.DeployModules {
cmd = append(cmd, "--modules")
if conf.R10k.UseLegacyPuppetfileFlag {
cmd = append(cmd, "--puppetfile")
} else {
cmd = append(cmd, "--modules")
}
}

// Pass the command to the execute function and act on the result and any error
Expand Down
18 changes: 10 additions & 8 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,15 @@ type Config struct {
ServerUri string `mapstructure:"server_uri"`
} `mapstructure:"chatops"`
R10k struct {
CommandPath string `mapstructure:"command_path"`
ConfigPath string `mapstructure:"config_path"`
DefaultBranch string `mapstructure:"default_branch"`
Prefix string `mapstructure:"prefix"`
AllowUppercase bool `mapstructure:"allow_uppercase"`
Verbose bool `mapstructure:"verbose"`
DeployModules bool `mapstructure:"deploy_modules"`
GenerateTypes bool `mapstructure:"generate_types"`
CommandPath string `mapstructure:"command_path"`
ConfigPath string `mapstructure:"config_path"`
DefaultBranch string `mapstructure:"default_branch"`
Prefix string `mapstructure:"prefix"`
AllowUppercase bool `mapstructure:"allow_uppercase"`
Verbose bool `mapstructure:"verbose"`
DeployModules bool `mapstructure:"deploy_modules"`
UseLegacyPuppetfileFlag bool `mapstructure:"use_legacy_puppetfile_flag"`
GenerateTypes bool `mapstructure:"generate_types"`
} `mapstructure:"r10k"`
}

Expand Down Expand Up @@ -88,6 +89,7 @@ func setDefaults(v *viper.Viper) *viper.Viper {
v.SetDefault("r10k.verbose", true)
v.SetDefault("r10k.deploy_modules", true)
v.SetDefault("r10k.generate_types", true)
v.SetDefault("r10k.use_legacy_puppetfile_flag", false)

return v
}
Expand Down

0 comments on commit 0396177

Please sign in to comment.