Skip to content

Commit

Permalink
update envoygatewaybindaddresses copy to prevent job diff on null vs …
Browse files Browse the repository at this point in the history
…empty
  • Loading branch information
drewbailey committed Jan 19, 2021
1 parent 823fc89 commit a4405a9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
9 changes: 6 additions & 3 deletions nomad/structs/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -1352,9 +1352,12 @@ func (p *ConsulGatewayProxy) Copy() *ConsulGatewayProxy {
return nil
}

bindAddresses := make(map[string]*ConsulGatewayBindAddress, len(p.EnvoyGatewayBindAddresses))
for k, v := range p.EnvoyGatewayBindAddresses {
bindAddresses[k] = v.Copy()
var bindAddresses map[string]*ConsulGatewayBindAddress
if p.EnvoyGatewayBindAddresses != nil {
bindAddresses = make(map[string]*ConsulGatewayBindAddress, len(p.EnvoyGatewayBindAddresses))
for k, v := range p.EnvoyGatewayBindAddresses {
bindAddresses[k] = v.Copy()
}
}

return &ConsulGatewayProxy{
Expand Down
17 changes: 17 additions & 0 deletions nomad/structs/services_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,23 @@ func TestConsulConnect_CopyEquals(t *testing.T) {
require.False(t, c.Equals(o))
}

func TestConsulConnect_GatewayProxy_CopyEquals(t *testing.T) {
t.Parallel()

c := &ConsulGatewayProxy{
ConnectTimeout: helper.TimeToPtr(1 * time.Second),
EnvoyGatewayBindTaggedAddresses: false,
EnvoyGatewayBindAddresses: nil,
}

require.NoError(t, c.Validate())

// Copies should be equivalent
o := c.Copy()
require.Equal(t, c, o)
require.True(t, c.Equals(o))
}

func TestSidecarTask_MergeIntoTask(t *testing.T) {
t.Parallel()

Expand Down

0 comments on commit a4405a9

Please sign in to comment.