Skip to content

Commit 85717b4

Browse files
fix: fix skaffold label setter to work properly for cnrm resources (#7221)
1 parent c1925ed commit 85717b4

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

pkg/skaffold/kubernetes/manifest/labels.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ func (rsi *ResourceSelectorLabels) allowByGroupKind(gk apimachinery.GroupKind) b
6161
func (rsi *ResourceSelectorLabels) allowByNavpath(gk apimachinery.GroupKind, navpath string, k string) (string, bool) {
6262
for _, w := range ConfigConnectorResourceSelector {
6363
if w.Matches(gk.Group, gk.Kind) {
64+
if k != metadataField {
65+
return "", false
66+
}
6467
return "labels", true
6568
}
6669
}
@@ -85,7 +88,7 @@ func (rsi *ResourceSelectorLabels) allowByNavpath(gk apimachinery.GroupKind, nav
8588
if rf, ok := rsi.allowlist[gk]; ok {
8689
for _, allowpath := range rf.Labels {
8790
if allowpath == ".*" {
88-
if k != "metadata" {
91+
if k != metadataField {
8992
return "", false
9093
}
9194
return "labels", true

pkg/skaffold/kubernetes/manifest/namespaces.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func newNamespaceCollector() *namespaceCollector {
5555
}
5656

5757
func (r *namespaceCollector) Visit(gk schema.GroupKind, navpath string, o map[string]interface{}, k string, v interface{}, rs ResourceSelector) bool {
58-
if k != "metadata" {
58+
if k != metadataField {
5959
return true
6060
}
6161

pkg/skaffold/kubernetes/manifest/visitor.go

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ import (
2525
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/yaml"
2626
)
2727

28+
const metadataField = "metadata"
29+
2830
type ResourceSelector interface {
2931
allowByGroupKind(apimachinery.GroupKind) bool
3032
allowByNavpath(apimachinery.GroupKind, string, string) (string, bool)

0 commit comments

Comments
 (0)