File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -145,6 +145,9 @@ func (c *Config) String() string {
145145 c2 := c .clone ()
146146 c2 .SecretKey = hideSecretKey (c2 .SecretKey )
147147 for _ , p := range c2 .Profiles {
148+ if p == nil {
149+ continue
150+ }
148151 p .SecretKey = hideSecretKey (p .SecretKey )
149152 }
150153
Original file line number Diff line number Diff line change @@ -847,3 +847,32 @@ profiles:
847847func TestEmptyConfig (t * testing.T ) {
848848 testhelpers .Assert (t , (& Config {}).IsEmpty (), "Config must be empty" )
849849}
850+
851+ func TestEmptyProfile (t * testing.T ) {
852+ incompleteProfiles := `
853+ profiles:
854+ profile1:
855+ access_key: SCW234567890ABCDEFGH
856+ secret_key: 6f6e6574-6f72-756c-6c74-68656d616c6c
857+ # default_organization_id: 11111111-1111-1111-1111-111111111111
858+ # default_project_id: 11111111-1111-1111-1111-111111111111
859+ # default_zone: fr-par-1
860+ # default_region: fr-pargs
861+ # api_url: https://api.scaleway.com
862+ # insecure: false
863+
864+ profile2:
865+ # access_key: SCW1234567890ABCDEFG
866+ # secret_key: 7363616c-6577-6573-6862-6f7579616161
867+ `
868+
869+ config , err := unmarshalConfV2 ([]byte (incompleteProfiles ))
870+ testhelpers .AssertNoError (t , err )
871+ testhelpers .Equals (t , 2 , len (config .Profiles ))
872+ testhelpers .Equals (t , `profiles:
873+ profile1:
874+ access_key: SCW234567890ABCDEFGH
875+ secret_key: 6f6e6574-xxxx-xxxx-xxxx-xxxxxxxxxxxx
876+ profile2: null
877+ ` , config .String ())
878+ }
You can’t perform that action at this time.
0 commit comments