Skip to content

Commit 813914b

Browse files
authored
fix(ske/login): use region from kubeconfig (#989)
* fix STACKITProjectID json key * get region from execCredential cluster config and fallback to region from CLI config
1 parent 6ab8220 commit 813914b

File tree

1 file changed

+6
-4
lines changed
  • internal/cmd/ske/kubeconfig/login

1 file changed

+6
-4
lines changed

internal/cmd/ske/kubeconfig/login/login.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,11 @@ func NewCmd(params *params.CmdParams) *cobra.Command {
120120
}
121121

122122
type clusterConfig struct {
123-
STACKITProjectID string `json:"stackitProjectId"`
123+
STACKITProjectID string `json:"stackitProjectID"`
124124
ClusterName string `json:"clusterName"`
125+
Region string `json:"region"`
125126

126127
cacheKey string
127-
Region string
128128
}
129129

130130
func parseClusterConfig(p *print.Printer, cmd *cobra.Command) (*clusterConfig, error) {
@@ -157,8 +157,10 @@ func parseClusterConfig(p *print.Printer, cmd *cobra.Command) (*clusterConfig, e
157157

158158
config.cacheKey = fmt.Sprintf("ske-login-%x", sha256.Sum256([]byte(execCredential.Spec.Cluster.Server)))
159159

160-
globalFlags := globalflags.Parse(p, cmd)
161-
config.Region = globalFlags.Region
160+
// NOTE: Fallback if region is not set in the kubeconfig (this was the case in the past)
161+
if config.Region == "" {
162+
config.Region = globalflags.Parse(p, cmd).Region
163+
}
162164

163165
return config, nil
164166
}

0 commit comments

Comments
 (0)