Skip to content

Commit fe096cc

Browse files
committed
Fix create-setters matching setter values in internal kpt annotations
Signed-off-by: Aravindhan Ayyanathan <aravindhan.a@est.tech>
1 parent 47255bb commit fe096cc

2 files changed

Lines changed: 33 additions & 0 deletions

File tree

functions/go/create-setters/createsetters/create_setters.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,12 @@ func (cs *CreateSetters) visitScalar(object *yaml.RNode, path string) error {
248248
return nil
249249
}
250250

251+
// skip internal kpt annotations — these are runtime metadata, not user-authored content
252+
if strings.Contains(path, ".annotations.internal.config.kubernetes.io") ||
253+
strings.Contains(path, ".annotations.config.kubernetes.io") {
254+
return nil
255+
}
256+
251257
// doesn't add the comment to the nodes with multiple line values
252258
if hasMultipleLines(object.YNode().Value) {
253259
return nil

functions/go/create-setters/createsetters/create_setters_test.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,33 @@ metadata:
518518
name: nginx-development # kpt-set: nginx-${app}
519519
spec:
520520
image: dev # kpt-set: ${role}
521+
`,
522+
},
523+
{
524+
name: "skip internal kpt annotations",
525+
config: `
526+
data:
527+
replicas: "4"
528+
`,
529+
input: `apiVersion: apps/v1
530+
kind: Deployment
531+
metadata:
532+
name: nginx
533+
annotations:
534+
internal.config.kubernetes.io/package-path: /tmp/some-path-with-4-in-it
535+
config.kubernetes.io/local-config: "true"
536+
spec:
537+
replicas: 4
538+
`,
539+
expectedResources: `apiVersion: apps/v1
540+
kind: Deployment
541+
metadata:
542+
name: nginx
543+
annotations:
544+
internal.config.kubernetes.io/package-path: /tmp/some-path-with-4-in-it
545+
config.kubernetes.io/local-config: "true"
546+
spec:
547+
replicas: 4 # kpt-set: ${replicas}
521548
`,
522549
},
523550
}

0 commit comments

Comments
 (0)