Skip to content
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 @@ -19,7 +19,7 @@ require (
github.com/kubernetes-client/go-base v0.0.0-20190205182333-3d0e39759d98
github.com/mattn/go-colorable v0.1.13
github.com/mattn/go-isatty v0.0.17
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.14.0.20230308172750-e6fa6ad07480
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.14.0.20230310155856-7a2786489bc6
github.com/spf13/cobra v1.6.1
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.8.2
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ github.com/pkg/term v1.1.0/go.mod h1:E25nymQcrSllhX42Ok8MRm1+hyBdHY0dCeiKZ9jpNGw
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.14.0.20230308172750-e6fa6ad07480 h1:NG+457cV++Hm3nB29tX+8a6doqx5VIksxGBnfYQGlIQ=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.14.0.20230308172750-e6fa6ad07480/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.14.0.20230310155856-7a2786489bc6 h1:bAqxZt/1FAD/M4XLqWYHySz5kNcoQ7Mrdo7imgWAyaQ=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.14.0.20230310155856-7a2786489bc6/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg=
github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ=
github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA=
Expand Down
20 changes: 20 additions & 0 deletions internal/namespaces/config/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"os"
"reflect"
"strings"

"github.com/scaleway/scaleway-sdk-go/validation"

Expand Down Expand Up @@ -569,13 +570,27 @@ func configInfoCommand() *core.Command {
return nil, err
}

profileEnv := scw.LoadEnvProfile()

// Search for env variable that will override profile
// Will be used to display them
overridedVariables := []string(nil)
for _, key := range getProfileKeys() {
value, err := getProfileField(profileEnv, key)
if err == nil && !value.IsZero() {
overridedVariables = append(overridedVariables, key)
}
}

profileName := core.ExtractProfileName(ctx)
// use config.GetProfile instead of getProfile as we want the profile merged with the default
profile, err := config.GetProfile(profileName)
if err != nil {
return nil, err
}

profile = scw.MergeProfiles(profile, profileEnv)

values := map[string]any{}
for _, key := range getProfileKeys() {
value, err := getProfileValue(profile, key)
Expand All @@ -584,6 +599,11 @@ func configInfoCommand() *core.Command {
}
}

if len(overridedVariables) > 0 {
msg := "Some variables are overridden by the environment: " + strings.Join(overridedVariables, ", ")
fmt.Println(terminal.Style(msg, color.FgRed))
}

return struct {
ConfigPath string
ProfileName string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Profile.default-region fr-par
Profile.default-zone fr-par-1
Profile.insecure true
Profile.secret-key 11111111-1111-1111-1111-111111111111
Profile.send-telemetry true
🟩🟩🟩 JSON STDOUT 🟩🟩🟩
{
"ConfigPath": "/tmp/scw/.config/scw/config.yaml",
Expand All @@ -22,6 +23,6 @@ Profile.secret-key 11111111-1111-1111-1111-111111111111
"default-zone": "fr-par-1",
"insecure": true,
"secret-key": "11111111-1111-1111-1111-111111111111",
"send-telemetry": null
"send-telemetry": true
}
}