@@ -167,19 +167,11 @@ func (dingoadm *DingoAdm) init() error {
167
167
var cluster storage.Cluster
168
168
// check current active cluster config in env or not
169
169
170
- if activatedClusterName , exists := os . LookupEnv ( comm . KEY_ENV_ACTIVATE_CLUSTER ); exists && len ( activatedClusterName ) > 0 {
170
+ if activatedClusterName := getActivatedClusterFromEnv ( ); activatedClusterName != "" {
171
171
cluster , err = s .GetClusterByName (activatedClusterName )
172
172
if err != nil {
173
173
log .Error ("Get cluster by name failed" ,
174
174
log .Field ("Error" , err ))
175
- return errno .ERR_GET_CLUSTER_BY_NAME_FAILED .E (err )
176
- }
177
- } else if activatedClusterName , exists = os .LookupEnv (strings .ToLower (comm .KEY_ENV_ACTIVATE_CLUSTER )); exists && len (activatedClusterName ) > 0 {
178
- cluster , err = s .GetClusterByName (activatedClusterName )
179
- if err != nil {
180
- log .Error ("Get cluster by name failed" ,
181
- log .Field ("Error" , err ))
182
- return errno .ERR_GET_CLUSTER_BY_NAME_FAILED .E (err )
183
175
}
184
176
} else {
185
177
cluster , err = s .GetCurrentCluster ()
@@ -219,6 +211,20 @@ func (dingoadm *DingoAdm) init() error {
219
211
return nil
220
212
}
221
213
214
+ func getActivatedClusterFromEnv () string {
215
+ // Check original case first
216
+ if activatedClusterName , exists := os .LookupEnv (comm .KEY_ENV_ACTIVATE_CLUSTER ); exists && len (activatedClusterName ) > 0 {
217
+ return activatedClusterName
218
+ }
219
+
220
+ // Check lowercase version as fallback
221
+ if activatedClusterName , exists := os .LookupEnv (strings .ToLower (comm .KEY_ENV_ACTIVATE_CLUSTER )); exists && len (activatedClusterName ) > 0 {
222
+ return activatedClusterName
223
+ }
224
+
225
+ return ""
226
+ }
227
+
222
228
func (dingoadm * DingoAdm ) detectVersion () {
223
229
latestVersion , err := tools .GetLatestVersion (Version )
224
230
if err != nil || len (latestVersion ) == 0 {
0 commit comments