Skip to content

Commit d3b7dd2

Browse files
committed
Support ignore profile with ALIBABACLOUD_IGNORE_PROFILE=TRUE
1 parent b2ef439 commit d3b7dd2

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

config/configuration.go

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -116,21 +116,26 @@ func LoadProfile(path string, name string) (Profile, error) {
116116
}
117117

118118
func LoadProfileWithContext(ctx *cli.Context) (profile Profile, err error) {
119-
var currentPath string
120-
if path, ok := ConfigurePathFlag(ctx.Flags()).GetValue(); ok {
121-
currentPath = path
119+
if os.Getenv("ALIBABACLOUD_IGNORE_PROFILE") == "TRUE" {
120+
profile = NewProfile("default")
121+
profile.RegionId = "cn-hangzhou"
122122
} else {
123-
currentPath = GetConfigPath() + "/" + configFile
123+
var currentPath string
124+
if path, ok := ConfigurePathFlag(ctx.Flags()).GetValue(); ok {
125+
currentPath = path
126+
} else {
127+
currentPath = GetConfigPath() + "/" + configFile
128+
}
129+
if name, ok := ProfileFlag(ctx.Flags()).GetValue(); ok {
130+
profile, err = LoadProfile(currentPath, name)
131+
} else {
132+
profile, err = LoadProfile(currentPath, "")
133+
}
134+
if err != nil {
135+
return
136+
}
124137
}
125-
if name, ok := ProfileFlag(ctx.Flags()).GetValue(); ok {
126-
profile, err = LoadProfile(currentPath, name)
127138

128-
} else {
129-
profile, err = LoadProfile(currentPath, "")
130-
}
131-
if err != nil {
132-
return
133-
}
134139
//Load from flags
135140
profile.OverwriteWithFlags(ctx)
136141
err = profile.Validate()

0 commit comments

Comments
 (0)