From 11d8935d2051989827ba8218205789f4614a9edf Mon Sep 17 00:00:00 2001 From: Zdenek Behan Date: Wed, 3 Jan 2024 16:52:53 +0100 Subject: [PATCH] Add a option to force override module name The module name is implied from the git repository name. However, both r10k and puppet are very particular about module naming, and the implicit rewrites rules can get in the way. Puppet will understand any amount of dashes in the project name as `-`, rewriting `-` to `/`. For git repositories, there are often arbitrary naming rules with copious amounts of these control characters in repository names, making it nearly impossible to serve both worlds at the same time. This URL parameter (module_name) allows to override the module name directly in the URL, completely ignoring the git repository name. --- api/module.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/api/module.go b/api/module.go index 643a624..7c223e6 100644 --- a/api/module.go +++ b/api/module.go @@ -54,8 +54,14 @@ func (m ModuleController) DeployModule(c *gin.Context) { cmd = append(cmd, branch) } + module := data.ModuleName + overrideModule := c.Query("module_name") + if overrideModule != "" { + module = overrideModule + } + // Append module name and r10k configuration to the cmd string slice - cmd = append(cmd, data.ModuleName) + cmd = append(cmd, module) cmd = append(cmd, fmt.Sprintf("--config=%s", h.GetR10kConfig())) // Set additional optional r10k flags if they are set