Skip to content

use viper.Get* instead of cmd.Flags().Get* #2044

@butonic

Description

@butonic

we merged the viper coobra cli pr but did not notice that env vars are not being picked up.

At least opencloud init will still ask, even if OC_INSECURE=true

Do you want to configure OpenCloud with certificate checking disabled?
This is not recommended for public instances! [yes | no = default]

I noticed this in the devtools compose, so it will happen in the opencloud compose and helm charts as well ...

The minimal fix is

diff --git a/opencloud/pkg/command/init.go b/opencloud/pkg/command/init.go
index 42b72f736ea..8e2dc6bb6d8 100644
--- a/opencloud/pkg/command/init.go
+++ b/opencloud/pkg/command/init.go
@@ -23,7 +23,7 @@ func InitCommand(_ *config.Config) *cobra.Command {
                Short:   "initialise an OpenCloud config",
                GroupID: CommandGroupServer,
                RunE: func(cmd *cobra.Command, args []string) error {
-                       insecureFlag, _ := cmd.Flags().GetString("insecure")
+                       insecureFlag := viper.GetString("insecure")
                        insecure := false
                        if insecureFlag == "ask" {
                                answer := strings.ToLower(stringPrompt("Do you want to confi
gure OpenCloud with certificate checking disabled?\n This is not recommended for public inst
ances! [yes | no = default]"))

Metadata

Metadata

Assignees

Type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions