Skip to content

Commit

Permalink
Use provided r10k command_path
Browse files Browse the repository at this point in the history
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
  • Loading branch information
genebean committed May 7, 2024
1 parent 89c6987 commit 4408e1e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion api/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion api/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
14 changes: 14 additions & 0 deletions lib/helpers/r10k-command.go
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit 4408e1e

Please sign in to comment.