Skip to content

Commit 2879c36

Browse files
'configure set' command save the STS (Security Token Service) region configuration to config file. (#1179)
1 parent b9ab5d4 commit 2879c36

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

config/configure_set.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ func doConfigureSet(w io.Writer, flags *cli.FlagSet) {
119119
profile.ReadTimeout = ReadTimeoutFlag(flags).GetIntegerOrDefault(profile.ReadTimeout)
120120
profile.ConnectTimeout = ConnectTimeoutFlag(flags).GetIntegerOrDefault(profile.ConnectTimeout)
121121
profile.RetryCount = RetryCountFlag(flags).GetIntegerOrDefault(profile.RetryCount)
122+
profile.StsRegion = StsRegionFlag(flags).GetStringOrDefault(profile.StsRegion)
122123

123124
err = profile.Validate()
124125
if err != nil {

config/configure_set_test.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// you may not use this file except in compliance with the License.
55
// You may obtain a copy of the License at
66
//
7-
// http://www.apache.org/licenses/LICENSE-2.0
7+
// http://www.apache.org/licenses/LICENSE-2.0
88
//
99
// Unless required by applicable law or agreed to in writing, software
1010
// distributed under the License is distributed on an "AS IS" BASIS,
@@ -155,4 +155,18 @@ func TestDoConfigureSet(t *testing.T) {
155155
w.Reset()
156156
doConfigureSet(w, fs)
157157
assert.Empty(t, w.String())
158+
// OIDC
159+
hookLoadConfiguration = func(fn func(path string) (*Configuration, error)) func(path string) (*Configuration, error) {
160+
return func(path string) (*Configuration, error) {
161+
return &Configuration{
162+
CurrentProfile: "default",
163+
Profiles: []Profile{
164+
{Name: "default", Mode: OIDC, OIDCProviderARN: "OIDCProviderARN", OIDCTokenFile: "OIDCTokenFile",
165+
RoleSessionName: "RoleSessionName", RamRoleArn: "RamRoleArn", AccessKeyId: "default_aliyun_access_key_id",
166+
AccessKeySecret: "default_aliyun_access_key_secret", OutputFormat: "json", RegionId: "cn-hangzhou", StsRegion: "eu-central-1"},
167+
{Name: "aaa", Mode: AK, AccessKeyId: "sdf", AccessKeySecret: "ddf", OutputFormat: "json"}}}, nil
168+
}
169+
}
170+
w.Reset()
171+
doConfigureSet(w, fs)
158172
}

config/profile.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@ func (cp *Profile) OverwriteWithFlags(ctx *cli.Context) {
187187
cp.RetryCount = RetryCountFlag(ctx.Flags()).GetIntegerOrDefault(cp.RetryCount)
188188
cp.ExpiredSeconds = ExpiredSecondsFlag(ctx.Flags()).GetIntegerOrDefault(cp.ExpiredSeconds)
189189
cp.ProcessCommand = ProcessCommandFlag(ctx.Flags()).GetStringOrDefault(cp.ProcessCommand)
190+
cp.OIDCProviderARN = OIDCProviderARNFlag(ctx.Flags()).GetStringOrDefault(cp.OIDCProviderARN)
191+
cp.OIDCTokenFile = OIDCTokenFileFlag(ctx.Flags()).GetStringOrDefault(cp.OIDCTokenFile)
190192

191193
if cp.AccessKeyId == "" {
192194
cp.AccessKeyId = util.GetFromEnv("ALIBABA_CLOUD_ACCESS_KEY_ID", "ALIBABACLOUD_ACCESS_KEY_ID", "ALICLOUD_ACCESS_KEY_ID", "ACCESS_KEY_ID")

0 commit comments

Comments
 (0)