Commit Graph

233 Commits

Author SHA1 Message Date
Simon Bein
c79916b1ba Add DeepCopy for ResourceMeta and ObjectMeta 2023-04-24 20:19:33 +02:00
Yutaro
42bf3c0e2b prevent all uses of YAML aliases from being overwritten by a transformer (#5096)
* return copied Node

* add a test case about imageTagTransformer for anchor scenario

* add TestPatchTransformerAnchor

* TestReplacementTransformerAnchor
2023-03-31 16:07:50 -07:00
Ed Overton
a0e94c1642 fix: correct visitMappingNodeFields
This commit adjusts visitMappingNodeFields so that it no longer assumes
the mapping node has unique keys.
2022-12-22 11:51:15 -05:00
Ed Overton
20b0d3c7ce perf: optimize RNode GetAnnotations and GetLabels
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.
2022-12-20 17:24:35 -05:00
Ed Overton
194a017c81 refactor: single function to visit mapping node content
Refactor mapping node content traversal so that all code paths execute
through the same root function.
2022-12-20 17:21:05 -05:00
Katrina Verey
903fbb6ed2 Wildcard support for creation in ReplacementTransformer (#4886)
* 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
2022-12-06 12:40:37 -08:00
Brian Pursley
1b7db20504 merge2: preserve explicitly set null values
Fixed bug where an explicitly set null value in yaml was
cleared, even when the patch did not operate on that field.
2022-11-26 16:33:14 -05:00
Kubernetes Prow Robot
e638e408b0 Merge pull request #4802 from oscr/the-the
grammar: replace all occurrences of "the the" with "the"
2022-11-16 08:22:48 -08:00
Florian Lehner
c2312c4018 kyaml/yaml: preallocate memory
Signed-off-by: Florian Lehner <dev@der-flo.net>
2022-10-06 05:38:18 +02:00
Oscar Utbult
88cf251ef7 grammar: replace all occurrences of "the the" with "the" 2022-09-17 22:28:56 +02:00
Katrina Verey
79a9154cf8 Improve error message when namespace transformer is given invalid fieldspecs
Also remove invalid+ignored fieldspecs from the defaults
2022-08-16 18:18:44 -04:00
Katrina Verey
55a37de686 Fix other linters on modified lines 2022-08-10 19:34:25 -04:00
Katrina Verey
f6b72077c8 Stop using deprecated ioutil functions 2022-08-10 18:22:46 -04:00
annelausf
188e35fbfd Added code for fields with dots(.) in their names work as needed (#4591)
* Added code for fields with dots(.) in their names work as needed

Co-authored-by: sarjamil <sjamil@salesforce.com>

* Fixed imports

Co-authored-by: sarjamil <sjamil@salesforce.com>

* Removed comments

Co-authored-by: sarjamil <sjamil@salesforce.com>

* Fix filter method

Co-authored-by: sarjamil <sjamil@salesforce.com>

* Fixed failing tests

Co-authored-by: sarjamil <sjamil@salesforce.com>

* Remove comments

Add co-author to PR.

Co-authored-by: sarjamil <sjamil@salesforce.com>

* Add co-author to PR.

Co-authored-by: sarjamil sjamil@salesforce.com

Co-authored-by: sarjamil <sjamil@salesforce.com>
2022-05-02 14:30:33 -07:00
koba1t
01ab069bd2 fix error message 2022-04-13 04:55:21 +09:00
koba1t
cdc4a5083b fix lint error 2022-04-12 12:53:58 +09:00
koba1t
5e84de2a89 fix errror message using replacement wildcard and create option 2022-04-12 05:14:24 +09:00
Katrina Verey
2a9adbeb1e Makefile cleanup 2022-03-31 19:02:19 -04:00
Katrina Verey
71bf0d5d14 Update full linter list and enable some easily resolved new ones 2022-03-31 11:37:26 -04:00
Katrina Verey
14947e449b Address new linter complaints 2022-03-31 11:37:26 -04:00
Anna Song
497d2ee031 Added test for bug 4487: cannot parse keys with dots 2022-03-25 17:45:55 -04:00
Shoshana Malfatto
7b0ec99d90 retain quotes in namespace transformer filter (#4421)
* 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
2022-03-23 14:25:19 -07:00
Rafael Leal
97de780feb Fix error during expansion of !!merge <<: anchor tags (#4383)
* 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
2022-03-23 09:36:17 -07:00
koba1t
5ed96a34d7 rename IsMatchEveryIndex to IsWildcard 2022-02-10 05:13:29 +09:00
koba1t
22f9daa3ab replacements allow to replace multi values 2022-02-04 04:09:50 +09:00
koba1t
26b9af0379 Allow setting every array element in replacements 2022-01-27 06:17:23 +09:00
Mengqi Yu
cd2c6a1ad1 Remove the deprecation warning for a few RNode helpers
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.
2021-12-03 11:47:34 -08:00
Katrina Verey
70a8ed6ed3 Add go 1.17 build tags, which go fmt auto-synchronizes 2021-09-24 17:28:21 -07:00
Phani Teja Marupaka
e997cc5486 Handle parsing of bare sequence yaml nodes 2021-09-17 14:19:27 -07:00
monopole
360585dfaf Add YAML anchor/alias expansion. 2021-08-19 11:55:09 -07:00
Jeff Regan
6c4e8019f8 Merge pull request #4094 from brianpursley/merge3-test
Add unit tests to cover existing behavior of three way merge and strategic merge patch
2021-08-19 07:41:18 -07:00
Katrina Verey
7a41e479c9 Filter helper for fallback field lookup 2021-08-17 11:13:10 -07:00
brianpursley
adedca09f2 Add unit tests for current behavior of three way merge 2021-08-02 20:36:28 -04:00
Natasha Sarkar
477d8930e0 fix kyaml issue with multiline scalars 2021-07-14 15:19:21 -07:00
phani
0f736ec7fd Handle comments for seq indent derivation (#4064)
* Handle comments for seq indent derivation

* Suggested changes
2021-07-13 17:46:26 -07:00
Phani Teja Marupaka
29be7fabe4 Suggested changes 2021-07-12 23:34:03 -07:00
Phani Teja Marupaka
74e867833a First sequence indent wins 2021-07-09 14:10:30 -07:00
Phani Teja Marupaka
c07ffa5c1e Update comments, tests, not expose indent option 2021-07-09 00:17:09 -07:00
Phani Teja Marupaka
f81201b74d Add options, keep seqindent annotation equivalent to index annotation 2021-07-08 14:54:23 -07:00
Phani Teja Marupaka
6dbc74b32e Suggested changes 2021-07-07 23:22:15 -07:00
Phani Teja Marupaka
ed38b5fe2b Make seq indent configurable and add retain seq indent functionality 2021-07-07 16:53:40 -07:00
phani
e1804cbc76 Retain field order after running any arbitrary functions on resources (#4021)
* Reorder resource fields

* Fix comment conflict

* Update e2e test ordering

* Suggested changes
2021-07-07 10:12:44 -07:00
Mengqi Yu
02d14d724a add missing json tags 2021-06-30 12:15:50 -07:00
Natasha Sarkar
5427ab7cc3 Merge pull request #4013 from KnVerey/go-yaml-fork
Internal go-yaml/yaml fork
2021-06-30 10:41:27 -07:00
Katrina Verey
e583f199b8 Comment out part of script that is likely only needed on first run 2021-06-30 10:18:11 -07:00
Natasha Sarkar
4b66043735 compact sequence indent 2021-06-30 10:14:45 -07:00
Natasha Sarkar
979f03e76c remove serialization hack after bump 2021-06-30 10:14:44 -07:00
Katrina Verey
2e8a3b7c45 Use the forked go-yaml module 2021-06-28 15:29:32 -07:00
Phani Teja Marupaka
1aa7a1e709 Handle null values while formatting 2021-06-27 16:55:16 -07:00
Kubernetes Prow Robot
cb4f5c3983 Merge pull request #4006 from runewake2/validate-data-map
Introduce Validate Data Map Function
2021-06-18 12:34:06 -07:00