Commit Graph

44 Commits

Author SHA1 Message Date
Ed Overton
97c8cd7d1a perf: eliminate unnecessary RNode creation 2023-05-02 13:15:01 -04: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
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
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
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
monopole
360585dfaf Add YAML anchor/alias expansion. 2021-08-19 11:55:09 -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
Katrina Verey
2e8a3b7c45 Use the forked go-yaml module 2021-06-28 15:29:32 -07:00
Sam Wronski
1801d33287 Add error when datamap is nil 2021-06-18 10:14:17 -07:00
Sam Wronski
b01da61d83 Update argument name 2021-06-17 16:12:09 -07:00
Sam Wronski
a1f1c2d32f Add documentation 2021-06-17 11:47:56 -07:00
Sam Wronski
10331d9560 Add GetValidatedDataMap to rnode 2021-06-17 01:46:35 -07:00
monopole
5c4e363f11 Remove delegation to RNode in Resource. 2021-05-11 10:49:17 -07:00
monopole
660847225d Simplify gvk, speed up cluster-scoped checks. 2021-05-02 13:17:33 -07:00
monopole
235101a614 Drop uses of 'unstructured' terminology. 2021-03-15 15:59:06 -07:00
monopole
123a5d6e56 Remove the wrappy layer. 2021-03-15 15:59:06 -07:00
Natasha Sarkar
722b0131f0 return error for duplicate keys rather than panicking 2021-03-03 12:13:24 -08:00
Donny Xia
dd72ea1e6a add functions for binaryData 2021-02-11 15:34:16 -08:00
monopole
cb59e0ef5f Always tag label and annotations values as strings. 2021-01-15 17:37:46 -08:00
monopole
7c6bf2e21d When merging configmaps, retain proper quoting. 2021-01-14 11:01:06 -08:00
monopole
1a002005c1 Add RNode.Map method and test to help decoding. 2021-01-09 06:57:01 -08:00
jregan
35087ed0cc Add RNode.Set/GetDataMap to ease configmap generation. 2020-12-21 07:18:51 -08:00
Donny Xia
bae3228557 Add function to check is YNode zero 2020-12-11 14:55:44 -08:00
jregan
56c8df7b85 Add RNode implementation of label and annotation selectors. 2020-11-26 14:47:23 -08:00
jregan
ec64ef705b Add metadata getters and setters to RNode.
These setters completely remove the field if the argument
is empty, rather than setting the field to an empty value,
mimicing apimachinery behavior.
2020-11-25 07:03:12 -08:00
jregan
b88e770b1d binary data nope 2020-11-20 17:55:20 -08:00
Jeff Regan
97c18518ea Update rnode.go 2020-11-16 21:37:28 -08:00
jregan
712276176c Gather and use some of the kyaml constants. 2020-11-16 21:26:18 -08:00
Jeff Regan
02b4b56c60 Merge pull request #3233 from monopole/sliceFromBytes
Implement WNodeFactory.SliceFromBytes
2020-11-16 11:57:09 -08:00
jregan
e1c3caeba6 Introduce some RNode validation methods. 2020-11-16 11:32:23 -08:00
Justin SB
a823f3043f Expand rnode function comments to point to multi-object options.
The rnode Parse and ReadFile functions only return a single object;
suggest kio.ByteReader for the case of parsing multiple objects.
2020-11-15 13:07:28 -05:00
jregan
a4f22cb84f Add RNode fromMap method. 2020-11-14 13:10:53 -08:00
Natasha Sarkar
df0576a270 use merge key tuple instead of single merge key 2020-11-09 11:34:31 -08:00
Justin SB
eb4c5dc035 Remove some obsolete references to GrepFilter
Looks like GrepFilter was generalized to Filter.
2020-09-04 13:41:16 -04:00
jregan
24beeb429d RNode copier 2020-08-21 18:04:58 -07:00
Phani Teja Marupaka
ca04c874f2 Delete substitution and fix delete setters 2020-08-18 22:24:50 -07:00
jregan
c4c8decb74 Delete non-rnode stuff from rnode.go. 2020-08-16 07:35:11 -07:00
jregan
0590b225c7 Copy types.go to rnode.go. 2020-08-16 07:35:11 -07:00