diff --git a/api/types/server.go b/api/types/server.go index 951896f0ae8..bb987d23668 100644 --- a/api/types/server.go +++ b/api/types/server.go @@ -26,6 +26,8 @@ import ( "github.com/gravitational/teleport/api/utils" "github.com/gravitational/trace" + + "github.com/gogo/protobuf/proto" ) // Server represents a Node, Proxy or Auth server in a Teleport cluster @@ -334,18 +336,7 @@ func (s *ServerV2) CheckAndSetDefaults() error { // DeepCopy creates a clone of this server value func (s *ServerV2) DeepCopy() Server { - newServer := *s - if s.Metadata.Expires != nil { - expires := *s.Metadata.Expires - newServer.Metadata.Expires = &expires - } - if len(s.Metadata.Labels) != 0 { - newServer.Metadata.Labels = make(map[string]string) - for k, v := range s.Metadata.Labels { - newServer.Metadata.Labels[k] = v - } - } - return &newServer + return proto.Clone(s).(*ServerV2) } // CommandLabel is a label that has a value as a result of the diff --git a/lib/services/servers_test.go b/lib/services/servers_test.go index e06ac2fa7f7..fab207ed9f2 100644 --- a/lib/services/servers_test.go +++ b/lib/services/servers_test.go @@ -137,7 +137,7 @@ func (s *ServerSuite) TestGuessProxyHostAndVersion(c *check.C) { c.Assert(err, check.IsNil) } -func TestUnmarshalServerResourceKubernetes(t *testing.T) { +func TestUnmarshalServerKubernetes(t *testing.T) { // Regression test for // https://github.com/gravitational/teleport/issues/4862 // diff --git a/lib/services/services_test.go b/lib/services/services_test.go index d87a9f83757..d34e84daf17 100644 --- a/lib/services/services_test.go +++ b/lib/services/services_test.go @@ -108,7 +108,7 @@ func (s *ServicesSuite) TestLabelKeyValidation(c *check.C) { func TestServerDeepCopy(t *testing.T) { t.Parallel() // setup - now := time.Date(1984, time.April, 4, 0, 0, 0, 0, time.Local) + now := time.Date(1984, time.April, 4, 0, 0, 0, 0, time.UTC) expires := now.Add(1 * time.Hour) srv := &ServerV2{ Kind: KindNode,