Skip to content

Commit

Permalink
remove unnecessary loop
Browse files Browse the repository at this point in the history
  • Loading branch information
nklaassen committed Aug 6, 2024
1 parent 81797b4 commit f698725
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
8 changes: 3 additions & 5 deletions lib/client/kube/kube.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,13 @@ func CheckIfCertsAreAllowedToAccessCluster(k *client.KeyRing, rootCluster, telep
if rootCluster != teleportCluster {
return nil
}
for k8sCluster, cred := range k.KubeTLSCredentials {
if k8sCluster != kubeCluster {
continue
}
if cred, ok := k.KubeTLSCredentials[kubeCluster]; ok {
log.Debugf("Got TLS cert for Kubernetes cluster %q", k8sCluster)
exist, err := checkIfCertHasKubeGroupsAndUsers(cred.Cert)
if err != nil {
return trace.Wrap(err)
} else if exist {
}
if exist {
return nil
}
}
Expand Down
8 changes: 4 additions & 4 deletions tool/tsh/common/kube_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ func issueKubeCert(ctx context.Context, tc *client.TeleportClient, clusterClient
requesterName = proto.UserCertsRequest_TSH_KUBE_LOCAL_PROXY_HEADLESS
}

key, mfaRequired, err := clusterClient.IssueUserCertsWithMFA(
keyRing, mfaRequired, err := clusterClient.IssueUserCertsWithMFA(
ctx,
client.ReissueParams{
RouteToCluster: teleportCluster,
Expand All @@ -599,7 +599,7 @@ func issueKubeCert(ctx context.Context, tc *client.TeleportClient, clusterClient
return tls.Certificate{}, trace.Wrap(err)
}
if err := kubeclient.CheckIfCertsAreAllowedToAccessCluster(
key,
keyRing,
rootClusterName,
teleportCluster,
kubeCluster); err != nil {
Expand All @@ -608,12 +608,12 @@ func issueKubeCert(ctx context.Context, tc *client.TeleportClient, clusterClient

// Save it if MFA was not required.
if mfaRequired == proto.MFARequired_MFA_REQUIRED_NO {
if err := tc.LocalAgent().AddKubeKeyRing(key); err != nil {
if err := tc.LocalAgent().AddKubeKeyRing(keyRing); err != nil {
return tls.Certificate{}, trace.Wrap(err)
}
}

cert, err := key.KubeTLSCert(kubeCluster)
cert, err := keyRing.KubeTLSCert(kubeCluster)
if err != nil {
return tls.Certificate{}, trace.Wrap(err)
}
Expand Down

0 comments on commit f698725

Please sign in to comment.