diff --git a/README.md b/README.md index 8ca7245..6db7192 100644 --- a/README.md +++ b/README.md @@ -215,6 +215,12 @@ Type: bool Description: Run `puppet generate types` after updating an environment Default: `true` +### `command_path` + +Type: `string` +Description: Allow overriding the default path to r10k. +Default: `/opt/puppetlabs/puppetserver/bin/r10k` + ## Usage Webhook API provides following paths diff --git a/api/environment.go b/api/environment.go index 5e69e39..525bc52 100644 --- a/api/environment.go +++ b/api/environment.go @@ -24,7 +24,7 @@ func (e EnvironmentController) DeployEnvironment(c *gin.Context) { var branch string // Set the base r10k command into a slice of strings - cmd := []string{"r10k", "deploy", "environment"} + cmd := []string{h.GetR10kCommand(), "deploy", "environment"} // Get the configuration conf := config.GetConfig() diff --git a/api/module.go b/api/module.go index 34228a0..436690d 100644 --- a/api/module.go +++ b/api/module.go @@ -24,7 +24,7 @@ func (m ModuleController) DeployModule(c *gin.Context) { var h helpers.Helper // Set the base r10k command into a string slice - cmd := []string{"r10k", "deploy", "module"} + cmd := []string{h.GetR10kCommand(), "deploy", "module"} // Get the configuration conf := config.GetConfig() diff --git a/lib/helpers/r10k-command.go b/lib/helpers/r10k-command.go new file mode 100644 index 0000000..5a62943 --- /dev/null +++ b/lib/helpers/r10k-command.go @@ -0,0 +1,14 @@ +package helpers + +import "github.com/voxpupuli/webhook-go/config" + +const Command = "r10k" + +func (h *Helper) GetR10kCommand() string { + conf := config.GetConfig().R10k + commandPath := conf.CommandPath + if commandPath == "" { + return Command + } + return commandPath +}