Skip to content

Commit a906040

Browse files
feat(init): handle empty config (#834)
1 parent ea30a9c commit a906040

File tree

4 files changed

+7
-9
lines changed

4 files changed

+7
-9
lines changed

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ require (
2020
github.com/mattn/go-colorable v0.1.4
2121
github.com/mattn/go-isatty v0.0.11
2222
github.com/pkg/errors v0.9.1 // indirect
23-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.6.0.20200331160105-1181c3dc1bcd
23+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.6.0.20200403105108-eb943ac1f1dc
2424
github.com/sergi/go-diff v1.0.0 // indirect
2525
github.com/spf13/cobra v0.0.5
2626
github.com/spf13/pflag v1.0.5 // indirect

go.sum

+2
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR
6161
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.6 h1:C1/pvkxkGN/H03mDxLzItaceYJDBk1HdClgR15suAzI=
6262
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.6.0.20200331160105-1181c3dc1bcd h1:ICQFQOSIOyt5n1RxOCAg1rq+DFLunpJpAK2ttjdGhUU=
6363
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.6.0.20200331160105-1181c3dc1bcd/go.mod h1:CJJ5VAbozOl0yEw7nHB9+7BXTJbIn6h7W+f6Gau5IP8=
64+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.6.0.20200403105108-eb943ac1f1dc h1:YJloAPPmGOEF+nufGL4a9Ppj6jnIMs8FjIorEM3ZBoE=
65+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.6.0.20200403105108-eb943ac1f1dc/go.mod h1:CJJ5VAbozOl0yEw7nHB9+7BXTJbIn6h7W+f6Gau5IP8=
6466
github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
6567
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
6668
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=

internal/matomo/matomo.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,11 @@ func generateRandNumber() string {
111111
return bigRand.String()
112112
}
113113

114-
// IsTelemetryDisabled returns true when the Opt-In send_telemetry attribute in the config is set.
114+
// IsTelemetryDisabled returns false when the Opt-In send_telemetry attribute in the config is set.
115115
func IsTelemetryDisabled() bool {
116116
config, err := scw.LoadConfig()
117117
if err != nil {
118118
return false
119119
}
120-
return !config.SendTelemetry
120+
return config.SendTelemetry == nil || !*config.SendTelemetry
121121
}

internal/namespaces/init/init.go

+2-6
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,10 @@ func initCommand() *core.Command {
124124

125125
// Check if a config exists
126126
// Actual creation of the new config is done in the Run()
127-
newConfig := false
128127
config, err := scw.LoadConfig()
129-
if err != nil {
130-
newConfig = true
131-
}
132128

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

247243
if args.SendTelemetry != nil {
248-
config.SendTelemetry = *args.SendTelemetry
244+
config.SendTelemetry = args.SendTelemetry
249245
}
250246

251247
// Update active profile

0 commit comments

Comments
 (0)