Skip to content

Commit

Permalink
Add a 'branch_only' parameter for /module
Browse files Browse the repository at this point in the history
When passing this parameter, it tries to detect the branch from the
module as well and apply it using the -e parameter to r10k. For modules
that are branch-linked with the main repository, this will trigger an
update *only* to the respective environment, rather than all
environments.

* For pushes into a branch of the module corresponding to an
environment, this merely saves processing time.
* For pushes to the default branch (of the module) which would affect
all environments, this will block updates to all environments except
for the default one (ie. production). This helps prevent unsolicited
updates of an environment that could break it, until the environment
itself is updated by other means (eg. by pushing into the respective
branch of the source repository or module).
  • Loading branch information
raincz authored and dhollinger committed Feb 11, 2024
1 parent 3f2ec1e commit 8e91113
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions api/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@ func (m ModuleController) DeployModule(c *gin.Context) {
return
}

useBranch := c.Query("branch_only")
if useBranch != "" {
branch := ""
if data.Branch == "" {
branch = conf.R10k.DefaultBranch
} else {
branch = data.Branch
}
cmd = append(cmd, "-e")
cmd = append(cmd, branch)
}

// Append module name and r10k configuration to the cmd string slice
cmd = append(cmd, data.ModuleName)
cmd = append(cmd, fmt.Sprintf("--config=%s", h.GetR10kConfig()))
Expand Down

0 comments on commit 8e91113

Please sign in to comment.