Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(init): handle empty config #834

Merged
merged 2 commits into from
Apr 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ require (
github.com/mattn/go-colorable v0.1.4
github.com/mattn/go-isatty v0.0.11
github.com/pkg/errors v0.9.1 // indirect
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.6.0.20200331160105-1181c3dc1bcd
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.6.0.20200403105108-eb943ac1f1dc
github.com/sergi/go-diff v1.0.0 // indirect
github.com/spf13/cobra v0.0.5
github.com/spf13/pflag v1.0.5 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.6 h1:C1/pvkxkGN/H03mDxLzItaceYJDBk1HdClgR15suAzI=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.6.0.20200331160105-1181c3dc1bcd h1:ICQFQOSIOyt5n1RxOCAg1rq+DFLunpJpAK2ttjdGhUU=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.6.0.20200331160105-1181c3dc1bcd/go.mod h1:CJJ5VAbozOl0yEw7nHB9+7BXTJbIn6h7W+f6Gau5IP8=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.6.0.20200403105108-eb943ac1f1dc h1:YJloAPPmGOEF+nufGL4a9Ppj6jnIMs8FjIorEM3ZBoE=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.6.0.20200403105108-eb943ac1f1dc/go.mod h1:CJJ5VAbozOl0yEw7nHB9+7BXTJbIn6h7W+f6Gau5IP8=
github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
Expand Down
4 changes: 2 additions & 2 deletions internal/matomo/matomo.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,11 @@ func generateRandNumber() string {
return bigRand.String()
}

// IsTelemetryDisabled returns true when the Opt-In send_telemetry attribute in the config is set.
// IsTelemetryDisabled returns false when the Opt-In send_telemetry attribute in the config is set.
func IsTelemetryDisabled() bool {
config, err := scw.LoadConfig()
if err != nil {
return false
}
return !config.SendTelemetry
return config.SendTelemetry == nil || !*config.SendTelemetry
}
8 changes: 2 additions & 6 deletions internal/namespaces/init/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,10 @@ func initCommand() *core.Command {

// Check if a config exists
// Actual creation of the new config is done in the Run()
newConfig := false
config, err := scw.LoadConfig()
if err != nil {
newConfig = true
}

// If it is not a new config, ask if we want to override the existing config
if !newConfig {
if err == nil && !config.IsEmpty() {
_, _ = interactive.PrintlnWithoutIndent(`
Current config is located at ` + scw.GetConfigPath() + `
` + terminal.Style(fmt.Sprint(config), color.Faint) + `
Expand Down Expand Up @@ -245,7 +241,7 @@ func initCommand() *core.Command {
}

if args.SendTelemetry != nil {
config.SendTelemetry = *args.SendTelemetry
config.SendTelemetry = args.SendTelemetry
}

// Update active profile
Expand Down