Skip to content

kubecfg show seems to silently strip out non-string annotations #371

@lukebond

Description

@lukebond

a bug in my code found a bug in kubecfg show.

$ cat >ok.jsonnet <<EOF
{
  apiVersion: 'v1',
  kind: 'ConfigMap',
  metadata: {
    annotations: {
      foo: 'true',
    },
    name: 'default',
  },
}
EOF
$ kubecfg show ok.jsonnet --show-provenance
---
apiVersion: v1
kind: ConfigMap
metadata:
  annotations:
    foo: "true"
    kubecfg.github.com/provenance-file: annorepro-simpler.jsonnet
    kubecfg.github.com/provenance-path: $
  name: default

looks good. but this:

$ cat >bad.jsonnet <<EOF
{
  apiVersion: 'v1',
  kind: 'ConfigMap',
  metadata: {
    annotations: {
      foo: true,
    },
    name: 'default',
  },
}
EOF
$ kubecfg show bad.jsonnet --show-provenance
---
apiVersion: v1
kind: ConfigMap
metadata:
  annotations:
    kubecfg.github.com/provenance-file: annorepro-simpler.jsonnet
    kubecfg.github.com/provenance-path: $
  name: default

at first glance it looks like kubecfg show is blowing away the annotations block with its own. but actually it's dropping one that's of the wrong type. see the diff:

+++ bad.jsonnet 2023-11-24 12:17:05.844204920 +0100
@@ -3,7 +3,7 @@
   kind: 'ConfigMap',
   metadata: {
     annotations: {
-      foo: 'true',
+      foo: true,
     },
     name: 'default',
   },

whilst the mistake is mine, it would be better if kubecfg threw an error here.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions