Skip to content

Commit

Permalink
upsert trusted cluster cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
fspmarshall committed Oct 30, 2024
1 parent 6160a3d commit 8f8b1dd
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/auth/trustedcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,21 @@ 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
var foundTrustedCluster bool
if tc.GetName() != "" {
var err error
existingCluster, err = a.GetTrustedCluster(ctx, tc.GetName())
if err != nil && !trace.IsNotFound(err) {
return nil, trace.Wrap(err)
}

if err == nil {
foundTrustedCluster = true
}
}

// if there is no existing cluster, switch to the create case
if existingCluster == nil {
if !foundTrustedCluster {
return a.createTrustedCluster(ctx, tc)
}

Expand Down

0 comments on commit 8f8b1dd

Please sign in to comment.