diff --git a/pkg/core/resources/model/rest/v1alpha1/meta.go b/pkg/core/resources/model/rest/v1alpha1/meta.go index f9fa33a8c43b..e0a86c2092c3 100644 --- a/pkg/core/resources/model/rest/v1alpha1/meta.go +++ b/pkg/core/resources/model/rest/v1alpha1/meta.go @@ -1,6 +1,7 @@ package v1alpha1 import ( + "maps" "time" core_model "github.com/kumahq/kuma/pkg/core/resources/model" @@ -42,5 +43,5 @@ func (r ResourceMeta) GetModificationTime() time.Time { } func (r ResourceMeta) GetLabels() map[string]string { - return r.Labels + return maps.Clone(r.Labels) } diff --git a/pkg/kds/util/meta.go b/pkg/kds/util/meta.go index 8ba29d994ebe..2080c217238f 100644 --- a/pkg/kds/util/meta.go +++ b/pkg/kds/util/meta.go @@ -35,7 +35,7 @@ func WithLabel(key, value string) CloneResourceMetaOpt { } func CloneResourceMeta(m model.ResourceMeta, fs ...CloneResourceMetaOpt) model.ResourceMeta { - labels := maps.Clone(m.GetLabels()) + labels := m.GetLabels() if labels == nil { labels = map[string]string{} } @@ -86,5 +86,5 @@ func (r *resourceMeta) GetModificationTime() time.Time { } func (r *resourceMeta) GetLabels() map[string]string { - return r.labels + return maps.Clone(r.labels) } diff --git a/pkg/plugins/resources/memory/store.go b/pkg/plugins/resources/memory/store.go index 8503dc273f05..bc51202ec358 100644 --- a/pkg/plugins/resources/memory/store.go +++ b/pkg/plugins/resources/memory/store.go @@ -3,6 +3,7 @@ package memory import ( "context" "fmt" + "maps" "strconv" "strings" "sync" @@ -70,7 +71,7 @@ func (m memoryMeta) GetModificationTime() time.Time { } func (m memoryMeta) GetLabels() map[string]string { - return m.Labels + return maps.Clone(m.Labels) } type memoryVersion uint64 diff --git a/pkg/plugins/resources/postgres/resource_matadata.go b/pkg/plugins/resources/postgres/resource_matadata.go index 33c954d18630..94ed72310676 100644 --- a/pkg/plugins/resources/postgres/resource_matadata.go +++ b/pkg/plugins/resources/postgres/resource_matadata.go @@ -1,6 +1,7 @@ package postgres import ( + "maps" "time" core_model "github.com/kumahq/kuma/pkg/core/resources/model" @@ -42,5 +43,5 @@ func (r *resourceMetaObject) GetModificationTime() time.Time { } func (r *resourceMetaObject) GetLabels() map[string]string { - return r.Labels + return maps.Clone(r.Labels) } diff --git a/pkg/test/resources/model/resource.go b/pkg/test/resources/model/resource.go index 1ef934f25dea..c9cb9ac31932 100644 --- a/pkg/test/resources/model/resource.go +++ b/pkg/test/resources/model/resource.go @@ -1,6 +1,7 @@ package model import ( + "maps" "time" core_model "github.com/kumahq/kuma/pkg/core/resources/model" @@ -83,5 +84,5 @@ func (m *ResourceMeta) GetModificationTime() time.Time { } func (m *ResourceMeta) GetLabels() map[string]string { - return m.Labels + return maps.Clone(m.Labels) }