Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
a-palchikov committed Dec 9, 2020
1 parent d6ef31f commit 7511c94
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
5 changes: 4 additions & 1 deletion lib/reversetunnel/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,10 @@ func (a *Agent) run() {
defer conn.Close()

// Successfully connected to remote cluster.
a.log.WithField("addr", conn.LocalAddr().String()).WithField("remote-addr", conn.RemoteAddr().String()).Info("Connected.")
a.log.WithFields(log.Fields{
"addr": conn.LocalAddr().String(),
"remote-addr": conn.RemoteAddr().String(),
}).Info("Connected.")

// wrap up remaining business logic in closure for easy
// conditional execution.
Expand Down
6 changes: 6 additions & 0 deletions lib/services/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,12 @@ func (r *Metadata) Merge(src proto.Message) {
expires := *m.Expires
r.Expires = &expires
}
if len(m.Labels) != 0 {
r.Labels = make(map[string]string)
for k, v := range m.Labels {
r.Labels[k] = v
}
}
}

const (
Expand Down
13 changes: 12 additions & 1 deletion lib/services/services_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,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.UTC)
expires := now.Add(1 * time.Hour)
srv := &ServerV2{
Expand Down Expand Up @@ -159,11 +160,16 @@ func TestServerDeepCopy(t *testing.T) {
},
},
}

// exercise
srv2 := srv.DeepCopy()
require.Empty(t, cmp.Diff(srv, srv2))

// verify
require.Empty(t, cmp.Diff(srv, srv2))
require.IsType(t, srv2, &ServerV2{})

// Mutate the second value but expect the original to be unaffected
srv2.(*ServerV2).Metadata.Labels["foo"] = "bar"
srv2.(*ServerV2).Spec.CmdLabels = map[string]CommandLabelV2{
"srv-cmd": {
Period: Duration(3 * time.Second),
Expand All @@ -172,7 +178,12 @@ func TestServerDeepCopy(t *testing.T) {
}
expires2 := now.Add(10 * time.Minute)
srv2.(*ServerV2).Metadata.Expires = &expires2

// exercise
srv3 := srv.DeepCopy()

// verify
require.Empty(t, cmp.Diff(srv, srv3))
require.NotEmpty(t, cmp.Diff(srv.GetMetadata().Labels, srv2.GetMetadata().Labels))
require.NotEmpty(t, cmp.Diff(srv2, srv3))
}

0 comments on commit 7511c94

Please sign in to comment.