kpt: Some commands fail on YAML that only contains a list

This produces an error: wrong Node Kind for expected: MappingNode was SequenceNode. Seems like SequenceNode should be allowed?

FieldClearer and FieldMatcher types seem to disallow this.

(
REPRO_HOME=$(mktemp -d)

cat <<EOF >$REPRO_HOME/list_only.yaml
# A comment
- key: value
- string
EOF

kpt pkg init $REPRO_HOME
kpt cfg create-setter $REPRO_HOME key value --stack-trace
)
echo '- key: value\n- string'|kpt cfg cat
error: wrong Node Kind for  expected: MappingNode was SequenceNode: value: {- key: value
- string}

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 2
  • Comments: 21 (10 by maintainers)

Most upvoted comments

Hi @phanimarupaka, I tried using .krmignore, but I kept getting the wrong Node Kind error. Can you clarify when that feature was supported? Is it in kpt 0.37.1? And what is its syntax?

I’m getting this error message:

kpt cfg set -R . xxxxx
error: /<redacted>/upstream/manifests/namespace-install/overlays/argo-server-deployment.yaml: wrong Node Kind for  expected: MappingNode was SequenceNode: value: {- op: add
  path: /spec/template/spec/containers/0/args/-
  value: --namespaced}

I put a .krmignore file in upstream/manifests with the following content:

namespace-install/overlays/argo-server-deployment.yaml
argo-server-deployment.yaml

However, neither the relative path, nor the file name seem to be read. I’m still getting the error message during kpt cfg set.

Such top-level lists arise in JSON Patch files written as YAML. It’s necessary to place such patch definitions in files separate from a kustomization.yaml file in order to use setters and substitutions in the content of the patch.

See #510 and #1324 for more of that story.

@natasha41575 @runewake2 I’d consider picking up this ticket if you are blocked on one of the bigger tasks.