diff --git a/NOTICE b/NOTICE index 2607ce1a..644932ff 100644 --- a/NOTICE +++ b/NOTICE @@ -155,9 +155,9 @@ License URL: https://github.com/cloudflare/circl/blob/v1.6.3/LICENSE ---------- Module: github.com/codesphere-cloud/cs-go -Version: v0.21.1 +Version: v0.22.0 License: Apache-2.0 -License URL: https://github.com/codesphere-cloud/cs-go/blob/v0.21.1/LICENSE +License URL: https://github.com/codesphere-cloud/cs-go/blob/v0.22.0/LICENSE ---------- Module: github.com/codesphere-cloud/oms/internal/tmpl @@ -797,9 +797,9 @@ License URL: https://github.com/open-telemetry/opentelemetry-proto-go/blob/otlp/ ---------- Module: go.yaml.in/yaml/v2 -Version: v2.4.3 +Version: v2.4.4 License: Apache-2.0 -License URL: https://github.com/yaml/go-yaml/blob/v2.4.3/LICENSE +License URL: https://github.com/yaml/go-yaml/blob/v2.4.4/LICENSE ---------- Module: go.yaml.in/yaml/v3 @@ -929,9 +929,9 @@ License URL: https://github.com/helm/helm/blob/v4.1.3/LICENSE ---------- Module: k8s.io/api -Version: v0.35.2 +Version: v0.35.3 License: Apache-2.0 -License URL: https://github.com/kubernetes/api/blob/v0.35.2/LICENSE +License URL: https://github.com/kubernetes/api/blob/v0.35.3/LICENSE ---------- Module: k8s.io/apiextensions-apiserver/pkg/apis/apiextensions @@ -941,15 +941,15 @@ License URL: https://github.com/kubernetes/apiextensions-apiserver/blob/v0.35.1/ ---------- Module: k8s.io/apimachinery/pkg -Version: v0.35.2 +Version: v0.35.3 License: Apache-2.0 -License URL: https://github.com/kubernetes/apimachinery/blob/v0.35.2/LICENSE +License URL: https://github.com/kubernetes/apimachinery/blob/v0.35.3/LICENSE ---------- Module: k8s.io/apimachinery/third_party/forked/golang -Version: v0.35.2 +Version: v0.35.3 License: BSD-3-Clause -License URL: https://github.com/kubernetes/apimachinery/blob/v0.35.2/third_party/forked/golang/LICENSE +License URL: https://github.com/kubernetes/apimachinery/blob/v0.35.3/third_party/forked/golang/LICENSE ---------- Module: k8s.io/apiserver/pkg/endpoints/deprecation @@ -959,21 +959,21 @@ License URL: https://github.com/kubernetes/apiserver/blob/v0.35.1/LICENSE ---------- Module: k8s.io/cli-runtime/pkg -Version: v0.35.2 +Version: v0.35.3 License: Apache-2.0 -License URL: https://github.com/kubernetes/cli-runtime/blob/v0.35.2/LICENSE +License URL: https://github.com/kubernetes/cli-runtime/blob/v0.35.3/LICENSE ---------- Module: k8s.io/client-go -Version: v0.35.2 +Version: v0.35.3 License: Apache-2.0 -License URL: https://github.com/kubernetes/client-go/blob/v0.35.2/LICENSE +License URL: https://github.com/kubernetes/client-go/blob/v0.35.3/LICENSE ---------- Module: k8s.io/client-go/third_party/forked/golang/template -Version: v0.35.2 +Version: v0.35.3 License: BSD-3-Clause -License URL: https://github.com/kubernetes/client-go/blob/v0.35.2/third_party/forked/golang/LICENSE +License URL: https://github.com/kubernetes/client-go/blob/v0.35.3/third_party/forked/golang/LICENSE ---------- Module: k8s.io/component-base/version diff --git a/cli/cmd/init_install_config.go b/cli/cmd/init_install_config.go index d4b59645..bc346cb9 100644 --- a/cli/cmd/init_install_config.go +++ b/cli/cmd/init_install_config.go @@ -193,9 +193,19 @@ func (c *InitInstallConfigCmd) InitInstallConfig(icg installer.InstallConfigMana c.updateConfigFromOpts(icg.GetInstallConfig()) } - errors := icg.ValidateInstallConfig() - if len(errors) > 0 { - return fmt.Errorf("configuration validation failed: %s", strings.Join(errors, ", ")) + validationWarnings := icg.ValidateInstallConfig() + if len(validationWarnings) > 0 { + if !c.Opts.Interactive { + return fmt.Errorf("configuration validation failed: %s", strings.Join(validationWarnings, ", ")) + } + log.Println("\n" + strings.Repeat("!", 70)) + log.Printf("Configuration has %d warning(s):\n", len(validationWarnings)) + for _, w := range validationWarnings { + log.Printf(" WARNING: %s\n", w) + } + log.Println(strings.Repeat("!", 70)) + log.Println("The configuration files will be generated.") + log.Println("Please review and fix the issues in the generated files before use!") } if err := icg.GenerateSecrets(); err != nil { @@ -210,7 +220,7 @@ func (c *InitInstallConfigCmd) InitInstallConfig(icg installer.InstallConfigMana return fmt.Errorf("failed to write vault file: %w", err) } - c.printSuccessMessage() + c.printSuccessMessage(len(validationWarnings)) return nil } @@ -221,9 +231,13 @@ func (c *InitInstallConfigCmd) printWelcomeMessage() { log.Println() } -func (c *InitInstallConfigCmd) printSuccessMessage() { +func (c *InitInstallConfigCmd) printSuccessMessage(warningCount int) { log.Println("\n" + strings.Repeat("=", 70)) - log.Println("Configuration files successfully generated!") + if warningCount > 0 { + log.Printf("Configuration files generated with %d warning(s)! Review before use!\n", warningCount) + } else { + log.Println("Configuration files successfully generated!") + } log.Println(strings.Repeat("=", 70)) log.Println("\nIMPORTANT: Keys and certificates have been generated and embedded in the vault file.") diff --git a/cli/cmd/init_install_config_interactive_test.go b/cli/cmd/init_install_config_interactive_test.go index 32583196..ad51877a 100644 --- a/cli/cmd/init_install_config_interactive_test.go +++ b/cli/cmd/init_install_config_interactive_test.go @@ -142,4 +142,63 @@ var _ = Describe("Interactive profile usage", func() { Expect(config.Cluster.Monitoring).To(BeNil()) }) }) + + Context("when interactive mode has validation warnings", func() { + It("should generate config files despite validation errors", func() { + mockIcg := installer.NewMockInstallConfigManager(GinkgoT()) + + mockIcg.EXPECT().ApplyProfile("dev").Return(nil) + mockIcg.EXPECT().CollectInteractively().Return(nil) + mockIcg.EXPECT().ValidateInstallConfig().Return([]string{"OpenBao URI must be a valid URL"}) + mockIcg.EXPECT().GenerateSecrets().Return(nil) + mockIcg.EXPECT().WriteInstallConfig("config.yaml", false).Return(nil) + mockIcg.EXPECT().WriteVault("vault.yaml", false).Return(nil) + + c := &InitInstallConfigCmd{ + Opts: &InitInstallConfigOpts{ + GlobalOptions: &GlobalOptions{}, + ConfigFile: "config.yaml", + VaultFile: "vault.yaml", + Profile: "dev", + Interactive: true, + }, + FileWriter: util.NewFilesystemWriter(), + } + + err := c.InitInstallConfig(mockIcg) + Expect(err).NotTo(HaveOccurred()) + }) + + It("should still fail in non-interactive mode with validation errors", func() { + configFile, err := os.CreateTemp("", "config-*.yaml") + Expect(err).NotTo(HaveOccurred()) + defer func() { _ = os.Remove(configFile.Name()) }() + err = configFile.Close() + Expect(err).NotTo(HaveOccurred()) + + vaultFile, err := os.CreateTemp("", "vault-*.yaml") + Expect(err).NotTo(HaveOccurred()) + defer func() { _ = os.Remove(vaultFile.Name()) }() + err = vaultFile.Close() + Expect(err).NotTo(HaveOccurred()) + + c := &InitInstallConfigCmd{ + Opts: &InitInstallConfigOpts{ + GlobalOptions: &GlobalOptions{}, + ConfigFile: configFile.Name(), + VaultFile: vaultFile.Name(), + Profile: "dev", + Interactive: false, + CodesphereOpenBaoUri: "not-a-valid-url", + }, + FileWriter: util.NewFilesystemWriter(), + } + + icg := installer.NewInstallConfigManager() + + err = c.InitInstallConfig(icg) + Expect(err).To(HaveOccurred()) + Expect(err.Error()).To(ContainSubstring("configuration validation failed")) + }) + }) }) diff --git a/internal/tmpl/NOTICE b/internal/tmpl/NOTICE index 2607ce1a..644932ff 100644 --- a/internal/tmpl/NOTICE +++ b/internal/tmpl/NOTICE @@ -155,9 +155,9 @@ License URL: https://github.com/cloudflare/circl/blob/v1.6.3/LICENSE ---------- Module: github.com/codesphere-cloud/cs-go -Version: v0.21.1 +Version: v0.22.0 License: Apache-2.0 -License URL: https://github.com/codesphere-cloud/cs-go/blob/v0.21.1/LICENSE +License URL: https://github.com/codesphere-cloud/cs-go/blob/v0.22.0/LICENSE ---------- Module: github.com/codesphere-cloud/oms/internal/tmpl @@ -797,9 +797,9 @@ License URL: https://github.com/open-telemetry/opentelemetry-proto-go/blob/otlp/ ---------- Module: go.yaml.in/yaml/v2 -Version: v2.4.3 +Version: v2.4.4 License: Apache-2.0 -License URL: https://github.com/yaml/go-yaml/blob/v2.4.3/LICENSE +License URL: https://github.com/yaml/go-yaml/blob/v2.4.4/LICENSE ---------- Module: go.yaml.in/yaml/v3 @@ -929,9 +929,9 @@ License URL: https://github.com/helm/helm/blob/v4.1.3/LICENSE ---------- Module: k8s.io/api -Version: v0.35.2 +Version: v0.35.3 License: Apache-2.0 -License URL: https://github.com/kubernetes/api/blob/v0.35.2/LICENSE +License URL: https://github.com/kubernetes/api/blob/v0.35.3/LICENSE ---------- Module: k8s.io/apiextensions-apiserver/pkg/apis/apiextensions @@ -941,15 +941,15 @@ License URL: https://github.com/kubernetes/apiextensions-apiserver/blob/v0.35.1/ ---------- Module: k8s.io/apimachinery/pkg -Version: v0.35.2 +Version: v0.35.3 License: Apache-2.0 -License URL: https://github.com/kubernetes/apimachinery/blob/v0.35.2/LICENSE +License URL: https://github.com/kubernetes/apimachinery/blob/v0.35.3/LICENSE ---------- Module: k8s.io/apimachinery/third_party/forked/golang -Version: v0.35.2 +Version: v0.35.3 License: BSD-3-Clause -License URL: https://github.com/kubernetes/apimachinery/blob/v0.35.2/third_party/forked/golang/LICENSE +License URL: https://github.com/kubernetes/apimachinery/blob/v0.35.3/third_party/forked/golang/LICENSE ---------- Module: k8s.io/apiserver/pkg/endpoints/deprecation @@ -959,21 +959,21 @@ License URL: https://github.com/kubernetes/apiserver/blob/v0.35.1/LICENSE ---------- Module: k8s.io/cli-runtime/pkg -Version: v0.35.2 +Version: v0.35.3 License: Apache-2.0 -License URL: https://github.com/kubernetes/cli-runtime/blob/v0.35.2/LICENSE +License URL: https://github.com/kubernetes/cli-runtime/blob/v0.35.3/LICENSE ---------- Module: k8s.io/client-go -Version: v0.35.2 +Version: v0.35.3 License: Apache-2.0 -License URL: https://github.com/kubernetes/client-go/blob/v0.35.2/LICENSE +License URL: https://github.com/kubernetes/client-go/blob/v0.35.3/LICENSE ---------- Module: k8s.io/client-go/third_party/forked/golang/template -Version: v0.35.2 +Version: v0.35.3 License: BSD-3-Clause -License URL: https://github.com/kubernetes/client-go/blob/v0.35.2/third_party/forked/golang/LICENSE +License URL: https://github.com/kubernetes/client-go/blob/v0.35.3/third_party/forked/golang/LICENSE ---------- Module: k8s.io/component-base/version