From 42e3392f09e846bbf6df4a455f231d5069cc5978 Mon Sep 17 00:00:00 2001 From: git-hyagi <45576767+git-hyagi@users.noreply.github.com> Date: Tue, 24 Oct 2023 16:37:52 -0300 Subject: [PATCH] Fix an issue in pulp_settings defining tuples fixes: #1122 --- CHANGES/1122.bugfix | 1 + controllers/repo_manager/secret.go | 9 ++++++++- main.go | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 CHANGES/1122.bugfix diff --git a/CHANGES/1122.bugfix b/CHANGES/1122.bugfix new file mode 100644 index 000000000..daf89c8b0 --- /dev/null +++ b/CHANGES/1122.bugfix @@ -0,0 +1 @@ +Fixed an error in wrong definition of tuples in `settings.py`. diff --git a/controllers/repo_manager/secret.go b/controllers/repo_manager/secret.go index e7cb1d3ff..7ee742442 100644 --- a/controllers/repo_manager/secret.go +++ b/controllers/repo_manager/secret.go @@ -19,6 +19,7 @@ package repo_manager import ( "encoding/json" "fmt" + "regexp" "strconv" "strings" @@ -421,7 +422,13 @@ func addCustomPulpSettings(pulp *repomanagerpulpprojectorgv1beta2.Pulp, pulpSett convertToString := cases.Title(language.English, cases.Compact).String(strconv.FormatBool(settingsJson[k].(bool))) convertedSettings = convertedSettings + fmt.Sprintf("%v = %v\n", strings.ToUpper(k), convertToString) default: - convertedSettings = convertedSettings + fmt.Sprintf("%v = \"%v\"\n", strings.ToUpper(k), settingsJson[k]) + // if it is a tuple, we should not parse it as a string (do not add the quotes) + r, _ := regexp.Compile(`\(.*\)`) + if r.MatchString(settingsJson[k].(string)) { + convertedSettings = convertedSettings + fmt.Sprintf("%v = %v\n", strings.ToUpper(k), settingsJson[k]) + } else { + convertedSettings = convertedSettings + fmt.Sprintf("%v = \"%v\"\n", strings.ToUpper(k), settingsJson[k]) + } } } diff --git a/main.go b/main.go index 0b3438be7..3588e650e 100644 --- a/main.go +++ b/main.go @@ -170,7 +170,7 @@ func main() { os.Exit(1) } - setupLog.Info("pulp-operator version: 1.0.0-beta.3") + setupLog.Info("pulp-operator version: 1.0.1-beta.3") setupLog.Info("starting manager") if err := mgr.Start(ctrl.SetupSignalHandler()); err != nil { setupLog.Error(err, "problem running manager")