From dade525ab75e185efb5e3d64e8e8eb1f2001e9f5 Mon Sep 17 00:00:00 2001 From: Forrest Marshall Date: Wed, 30 Oct 2024 13:37:19 -0700 Subject: [PATCH] upsert trusted cluster cleanup --- lib/auth/trustedcluster.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/auth/trustedcluster.go b/lib/auth/trustedcluster.go index acbc46dc4f281..784d6aad010dc 100644 --- a/lib/auth/trustedcluster.go +++ b/lib/auth/trustedcluster.go @@ -54,13 +54,15 @@ func (a *Server) UpsertTrustedCluster(ctx context.Context, tc types.TrustedClust // It is recommended to omit trusted cluster name because the trusted cluster name // is updated to the roots cluster name during the handshake with the root cluster. var existingCluster types.TrustedCluster - var cas []types.CertAuthority if tc.GetName() != "" { - var err error - existingCluster, err = a.GetTrustedCluster(ctx, tc.GetName()) + ec, err := a.GetTrustedCluster(ctx, tc.GetName()) if err != nil && !trace.IsNotFound(err) { return nil, trace.Wrap(err) } + + if err == nil { + existingCluster = ec + } } // if there is no existing cluster, switch to the create case