Skip to content

Commit

Permalink
chore(kuma-cp): always clone labels
Browse files Browse the repository at this point in the history
Signed-off-by: Mike Beaumont <[email protected]>
  • Loading branch information
michaelbeaumont committed Nov 5, 2024
1 parent 9fd4dc4 commit 5b090e0
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
3 changes: 2 additions & 1 deletion pkg/core/resources/model/rest/v1alpha1/meta.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package v1alpha1

import (
"maps"
"time"

core_model "github.com/kumahq/kuma/pkg/core/resources/model"
Expand Down Expand Up @@ -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)
}
4 changes: 2 additions & 2 deletions pkg/kds/util/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
}
Expand Down Expand Up @@ -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)
}
3 changes: 2 additions & 1 deletion pkg/plugins/resources/memory/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package memory
import (
"context"
"fmt"
"maps"
"strconv"
"strings"
"sync"
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion pkg/plugins/resources/postgres/resource_matadata.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package postgres

import (
"maps"
"time"

core_model "github.com/kumahq/kuma/pkg/core/resources/model"
Expand Down Expand Up @@ -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)
}
3 changes: 2 additions & 1 deletion pkg/test/resources/model/resource.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package model

import (
"maps"
"time"

core_model "github.com/kumahq/kuma/pkg/core/resources/model"
Expand Down Expand Up @@ -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)
}

0 comments on commit 5b090e0

Please sign in to comment.