Skip to content

Commit

Permalink
fix branch detection in env api
Browse files Browse the repository at this point in the history
  • Loading branch information
dhollinger committed Apr 5, 2022
1 parent 9d602cf commit 4091fb2
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion api/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type EnvironmentController struct{}
func (e EnvironmentController) DeployEnvironment(c *gin.Context) {
var data parsers.Data
var h helpers.Helper
var branch string

// Set the base r10k command into a slice of strings
cmd := []string{"r10k", "deploy", "environment"}
Expand All @@ -41,10 +42,17 @@ func (e EnvironmentController) DeployEnvironment(c *gin.Context) {
}

// Setup the environment for r10k from the configuration
env := h.GetEnvironment(conf.R10k.DefaultBranch, conf.R10k.Prefix, conf.R10k.AllowUppercase)
if data.Branch == "" {
branch = conf.R10k.DefaultBranch
} else {
branch = data.Branch
}

env := h.GetEnvironment(branch, conf.R10k.Prefix, conf.R10k.AllowUppercase)

// Append the environment and r10k configuration into the string slice `cmd`
cmd = append(cmd, env)

cmd = append(cmd, fmt.Sprintf("--config=%s", h.GetR10kConfig()))

// Set additional optional r10k options if they are set
Expand Down

0 comments on commit 4091fb2

Please sign in to comment.