Skip to content

Commit a54c311

Browse files
authored
switch trusted/remote cluster management to atomic write (#48009)
1 parent 24e48d6 commit a54c311

File tree

6 files changed

+914
-284
lines changed

6 files changed

+914
-284
lines changed

api/types/trustedcluster.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import (
2222
"time"
2323

2424
"github.com/gravitational/trace"
25+
26+
"github.com/gravitational/teleport/api/utils"
2527
)
2628

2729
// TrustedCluster holds information needed for a cluster that can not be directly
@@ -60,6 +62,8 @@ type TrustedCluster interface {
6062
SetReverseTunnelAddress(string)
6163
// CanChangeStateTo checks the TrustedCluster can transform into another.
6264
CanChangeStateTo(TrustedCluster) error
65+
// Clone returns a deep copy of the TrustedCluster.
66+
Clone() TrustedCluster
6367
}
6468

6569
// NewTrustedCluster is a convenience way to create a TrustedCluster resource.
@@ -259,6 +263,10 @@ func (c *TrustedClusterV2) CanChangeStateTo(t TrustedCluster) error {
259263
return nil
260264
}
261265

266+
func (c *TrustedClusterV2) Clone() TrustedCluster {
267+
return utils.CloneProtoMsg(c)
268+
}
269+
262270
// String represents a human readable version of trusted cluster settings.
263271
func (c *TrustedClusterV2) String() string {
264272
return fmt.Sprintf("TrustedCluster(Enabled=%v,Roles=%v,Token=%v,ProxyAddress=%v,ReverseTunnelAddress=%v)",

0 commit comments

Comments
 (0)