feat: add kustomize unified 'patches' field support#199
Merged
Conversation
Add support for kustomize's unified 'patches:' field which auto-detects Strategic Merge vs JSON Patch and supports both inline content (via 'patch:') and external file references (via 'path:'). See https://github.com/kubernetes-sigs/kustomize/blob/master/examples/inlinePatch.md Closes #94 Changes: - Add Patches []string field to ChartifyOpts and PatchOpts - Implement handler in Patch() that parses each file as either a single patch document, a list of documents, or a multi-document YAML stream - External 'path:' references are copied into tempDir (consistent with transformer path resolution from #90) - Add -patch CLI flag (repeatable) to cmd/chartify - Add jsonpatches and patch-files dirs to removedPathList for cleanup - Add unit tests (TestParsePatchDocuments, TestMarshalPatchEntry, TestPatch_Patches) covering single doc, list, multi-doc, edge cases - Add integration tests with snapshots for inline, list, and path forms Signed-off-by: yxxhero <yxxhero@users.noreply.github.com> Signed-off-by: yxxhero <aiopsclub@163.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add support for kustomize's unified
patches:field which auto-detects Strategic Merge vs JSON Patch and supports both inline content (viapatch:) and external file references (viapath:).See https://github.com/kubernetes-sigs/kustomize/blob/master/examples/inlinePatch.md
Closes #94
Changes
Library API
Patches []stringfield toChartifyOptsandPatchOptspath:references are copied into tempDir (consistent with transformer path resolution from Usage of kustomize transformers with "path" instead of "patch" #90)jsonpatchesandpatch-filesdirs toremovedPathListfor cleanup (jsonpatcheswas previously leaking)CLI
-patchflag (repeatable) tocmd/chartifyUsage
Test plan
TestParsePatchDocuments(8 cases),TestMarshalPatchEntry(2 cases),TestPatch_Patches(2 cases)go fmt,go vet,go buildall passkube_version_and_api_versionswhich depends on cluster state)