* Fix kyaml/yaml field access deref nil value for methods that look "nil-safe"
This change is addressing observed panics within kustomize that obscure the
actual failure. The primary observed problem case involves RNode.Content.
* Fix test case
* Fixes from review
Assert keeps going after failure, but require immediately fails
the tests, making it easier to find the output related to the test
failure, rather than having to comb through a bunch of subsequent
assertion failures. For equality tests, we may or may not want to
continue, but for error checks we almost always want to immediately
fail the test. Exceptions can be changed as-needed.
Related issues:
* https://github.com/kubernetes-sigs/kustomize/issues/5031
* https://github.com/kubernetes-sigs/kustomize/issues/5171
After noting this behaviour was not present in
d89b448c74 a `git bisect` pointed to the
change 1b7db20504. The issue with that
change is that upon seeing a `null` node it would replace it with a node
whose value was equivalent but without a `!!null` tag. This meant that
one application of a patch would have the desired approach: the result
would be `null` in the output, but on a second application of a similar
patch the field would be rendered as `"null"`.
To avoid this, define a new attribute on `RNode`s that is checked before
clearing any node we should keep. The added
`TestApplySmPatch_Idempotency` test verifies this behaviour.
See also https://github.com/kubernetes-sigs/kustomize/pull/5365 for an
alternative approach
When a patch appends a new node, it should honor the key style from the
patch. Prior to this commit, no style was applied, leading to problems
when the key value could be interpreted as a different type based on its
content. For example, "9110" needs quoting to ensure it is seen as a
string in yaml.
* return copied Node
* add a test case about imageTagTransformer for anchor scenario
* add TestPatchTransformerAnchor
* TestReplacementTransformerAnchor
This commit optimizes in three ways:
1. For heavily used functions, allocate memory to avoid overhead
associated with map and array re-sizing.
2. Where appropriate, limit annotation and label retrievals to only the
desired keys.
3. Adjust annotation and label retrieval to avoid unnecessary temporary
object creation.
* Ahead-of-time wildcard path expansion solution
* Wrapped PathGetter solution
This approach doesn't work when multiple existing sequence elements
should match, i.e. because the sequence contains maps and we're
searching on a key they all contain (target all containers with a certain
image would be one use case for this). PathGetter just takes the first
match in that case, which is not what we want.
* Add creation support to PathMatcher
* Regression test for existing bug when creation is enabled and sequence query should match multiple elements
* PathMatcher Create tests and support for sequence appending
* revert hyphen append support
PathGetter treats it as meaning 'last' not 'append' and does not have test coverage for its handling of this when create is set. Semantics are dubious given that multiple Replacement fieldPaths may be specified, which would cause successive appends.
* This also provides a solution to issue 1493
* Review feedback
* check tag values for double quoting
* reuse setentry
* don't override single quotes in merge and fix cm generator immutable val
* get rid of comment
* starlark annotation tests
* don't commit test image changes
* set network to bool
* isSet bool
* updating e2e config tool
* leave createtag
* fn command failing unmarshal test
* fn command test
* don't set style in run-fs
* use setentry to set tag
* remove e2e test changes and make IsStringValue an RNode method
* WIP
* Fix merge corner cases
* Add test for explicit !!merge tag
* Fix tests
* Cleanup
* Cleanup
* Fix deanchoring lists
* Add test case for keeping comments
* Add MapEntrySetter and fix json marshalling after deanchoring
* Keep duplicated keys
* Move MergeTag definition to yaml alias
* Remove go-spew from api
* Add support for sequence nodes on merge tags
* Add docstring to MapEntrySetter.Key
* Add docstring to MapEntrySetter struct
* Add tests to MapEntrySetter
* Fix duplicate merge key
* Revert whitespace changes on forked go-yaml
* Remove AssocMapEntry function
* Refactoring merge order
* Return errors on VisitFields and PipeE
* Add tests for each non-conforming map merges
The Pipe method is not as intuitive as these helpers. These helpers
are convenient and useful. Deprecating them before we have better
alternatives is premature.