Skip to content

Commit 661e497

Browse files
genebeandhollinger
authored andcommitted
Use provided r10k command_path
Prior to this, the Config struct had a setting under the R10k struct called CommandPath that could be set in the config file, but was ignored as both places that would use it were hard coded to instead use the string `r10k`. This resulted in the application looking in the path for the r10k binary. A default is set in config.go also, but that seems to have also been ignored. This fixes #152
1 parent 0396177 commit 661e497

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,12 @@ Type: bool
221221
Description: Run `puppet generate types` after updating an environment
222222
Default: `true`
223223

224+
### `command_path`
225+
226+
Type: `string`
227+
Description: Allow overriding the default path to r10k.
228+
Default: `/opt/puppetlabs/puppetserver/bin/r10k`
229+
224230
## Usage
225231

226232
Webhook API provides following paths

api/environment.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func (e EnvironmentController) DeployEnvironment(c *gin.Context) {
2424
var branch string
2525

2626
// Set the base r10k command into a slice of strings
27-
cmd := []string{"r10k", "deploy", "environment"}
27+
cmd := []string{h.GetR10kCommand(), "deploy", "environment"}
2828

2929
// Get the configuration
3030
conf := config.GetConfig()

api/module.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func (m ModuleController) DeployModule(c *gin.Context) {
2424
var h helpers.Helper
2525

2626
// Set the base r10k command into a string slice
27-
cmd := []string{"r10k", "deploy", "module"}
27+
cmd := []string{h.GetR10kCommand(), "deploy", "module"}
2828

2929
// Get the configuration
3030
conf := config.GetConfig()

lib/helpers/r10k-command.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package helpers
2+
3+
import "github.com/voxpupuli/webhook-go/config"
4+
5+
const Command = "r10k"
6+
7+
func (h *Helper) GetR10kCommand() string {
8+
conf := config.GetConfig().R10k
9+
commandPath := conf.CommandPath
10+
if commandPath == "" {
11+
return Command
12+
}
13+
return commandPath
14+
}

0 commit comments

Comments
 (0)