diff --git a/config/configure_set.go b/config/configure_set.go index 7b7e64eef..4b89d93f1 100644 --- a/config/configure_set.go +++ b/config/configure_set.go @@ -119,6 +119,7 @@ func doConfigureSet(w io.Writer, flags *cli.FlagSet) { profile.ReadTimeout = ReadTimeoutFlag(flags).GetIntegerOrDefault(profile.ReadTimeout) profile.ConnectTimeout = ConnectTimeoutFlag(flags).GetIntegerOrDefault(profile.ConnectTimeout) profile.RetryCount = RetryCountFlag(flags).GetIntegerOrDefault(profile.RetryCount) + profile.StsRegion = StsRegionFlag(flags).GetStringOrDefault(profile.StsRegion) err = profile.Validate() if err != nil { diff --git a/config/configure_set_test.go b/config/configure_set_test.go index d434487e1..f14d835e2 100644 --- a/config/configure_set_test.go +++ b/config/configure_set_test.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, @@ -155,4 +155,18 @@ func TestDoConfigureSet(t *testing.T) { w.Reset() doConfigureSet(w, fs) assert.Empty(t, w.String()) + // OIDC + hookLoadConfiguration = func(fn func(path string) (*Configuration, error)) func(path string) (*Configuration, error) { + return func(path string) (*Configuration, error) { + return &Configuration{ + CurrentProfile: "default", + Profiles: []Profile{ + {Name: "default", Mode: OIDC, OIDCProviderARN: "OIDCProviderARN", OIDCTokenFile: "OIDCTokenFile", + RoleSessionName: "RoleSessionName", RamRoleArn: "RamRoleArn", AccessKeyId: "default_aliyun_access_key_id", + AccessKeySecret: "default_aliyun_access_key_secret", OutputFormat: "json", RegionId: "cn-hangzhou", StsRegion: "eu-central-1"}, + {Name: "aaa", Mode: AK, AccessKeyId: "sdf", AccessKeySecret: "ddf", OutputFormat: "json"}}}, nil + } + } + w.Reset() + doConfigureSet(w, fs) } diff --git a/config/profile.go b/config/profile.go index 20525aad8..2db4f32be 100644 --- a/config/profile.go +++ b/config/profile.go @@ -187,6 +187,8 @@ func (cp *Profile) OverwriteWithFlags(ctx *cli.Context) { cp.RetryCount = RetryCountFlag(ctx.Flags()).GetIntegerOrDefault(cp.RetryCount) cp.ExpiredSeconds = ExpiredSecondsFlag(ctx.Flags()).GetIntegerOrDefault(cp.ExpiredSeconds) cp.ProcessCommand = ProcessCommandFlag(ctx.Flags()).GetStringOrDefault(cp.ProcessCommand) + cp.OIDCProviderARN = OIDCProviderARNFlag(ctx.Flags()).GetStringOrDefault(cp.OIDCProviderARN) + cp.OIDCTokenFile = OIDCTokenFileFlag(ctx.Flags()).GetStringOrDefault(cp.OIDCTokenFile) if cp.AccessKeyId == "" { cp.AccessKeyId = util.GetFromEnv("ALIBABA_CLOUD_ACCESS_KEY_ID", "ALIBABACLOUD_ACCESS_KEY_ID", "ALICLOUD_ACCESS_KEY_ID", "ACCESS_KEY_ID")