Skip to content
32 changes: 16 additions & 16 deletions NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
26 changes: 20 additions & 6 deletions cli/cmd/init_install_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}
Expand All @@ -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.")
Expand Down
59 changes: 59 additions & 0 deletions cli/cmd/init_install_config_interactive_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
})
})
})
32 changes: 16 additions & 16 deletions internal/tmpl/NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
Loading