Skip to content

Commit 1cab0dd

Browse files
authored
Merge branch 'main' into feature/onboard-logs-service
2 parents e53ea7a + db45e4b commit 1cab0dd

File tree

1 file changed

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

1 file changed

+12
-6
lines changed

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"k8s.io/client-go/rest"
2020

2121
"github.com/stackitcloud/stackit-cli/internal/pkg/args"
22+
"github.com/stackitcloud/stackit-cli/internal/pkg/auth"
2223
"github.com/stackitcloud/stackit-cli/internal/pkg/examples"
2324
"github.com/stackitcloud/stackit-cli/internal/pkg/print"
2425
"github.com/stackitcloud/stackit-cli/internal/pkg/services/ske/client"
@@ -150,20 +151,25 @@ func parseClusterConfig(p *print.Printer, cmd *cobra.Command) (*clusterConfig, e
150151
if execCredential == nil || execCredential.Spec.Cluster == nil {
151152
return nil, fmt.Errorf("ExecCredential contains not all needed fields")
152153
}
153-
config := &clusterConfig{}
154-
err = json.Unmarshal(execCredential.Spec.Cluster.Config.Raw, config)
154+
clusterConfig := &clusterConfig{}
155+
err = json.Unmarshal(execCredential.Spec.Cluster.Config.Raw, clusterConfig)
155156
if err != nil {
156157
return nil, fmt.Errorf("unmarshal: %w", err)
157158
}
158159

159-
config.cacheKey = fmt.Sprintf("ske-login-%x", sha256.Sum256([]byte(execCredential.Spec.Cluster.Server)))
160+
authEmail, err := auth.GetAuthEmail()
161+
if err != nil {
162+
return nil, fmt.Errorf("error getting auth email: %w", err)
163+
}
164+
165+
clusterConfig.cacheKey = fmt.Sprintf("ske-login-%x", sha256.Sum256([]byte(execCredential.Spec.Cluster.Server+"\x00"+authEmail)))
160166

161167
// NOTE: Fallback if region is not set in the kubeconfig (this was the case in the past)
162-
if config.Region == "" {
163-
config.Region = globalflags.Parse(p, cmd).Region
168+
if clusterConfig.Region == "" {
169+
clusterConfig.Region = globalflags.Parse(p, cmd).Region
164170
}
165171

166-
return config, nil
172+
return clusterConfig, nil
167173
}
168174

169175
func getCachedKubeConfig(key string) *rest.Config {

0 commit comments

Comments
 (0)