Skip to content

Commit

Permalink
update cm cmp logic.
Browse files Browse the repository at this point in the history
Signed-off-by: qicz <qiczzhu@gmail.com>
  • Loading branch information
qicz committed Jun 26, 2023
1 parent 2887058 commit 328a7dc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/infrastructure/kubernetes/infra_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (i *Infra) createOrUpdateConfigMap(ctx context.Context, r ResourceRender) e
}

return i.Client.CreateOrUpdate(ctx, key, current, cm, func() bool {
return !reflect.DeepEqual(cm.Data, current.Data)
return !reflect.DeepEqual(cm.Data, current.Data) || !reflect.DeepEqual(cm.BinaryData, current.BinaryData)
})
}

Expand Down
14 changes: 14 additions & 0 deletions internal/infrastructure/kubernetes/proxy_infra_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ package kubernetes

import (
"context"
"reflect"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
Expand All @@ -30,6 +32,18 @@ func newTestInfra(t *testing.T) *Infra {
return newTestInfraWithClient(t, cli)
}

func TestCmpBytes(t *testing.T) {
m1 := map[string][]byte{}
m1["a"] = []byte("aaa")
m2 := map[string][]byte{}
m2["a"] = []byte("aaa")

assert.True(t, reflect.DeepEqual(m1, m2))
assert.False(t, reflect.DeepEqual(nil, m2))
assert.False(t, reflect.DeepEqual(m1, nil))
assert.True(t, reflect.DeepEqual(nil, nil))
}

func newTestInfraWithClient(t *testing.T, cli client.Client) *Infra {
cfg, err := config.New()
require.NoError(t, err)
Expand Down

0 comments on commit 328a7dc

Please sign in to comment.