Repository navigation
Feat | Add --ignore-array-order option - #511
Draft
quangkhainguyen wants to merge 3 commits into
Draft
quangkhainguyen wants to merge 3 commits into
quangkhainguyen wants to merge 3 commits into
Conversation
Add `--ignore-array-order` (env `IGNORE_ARRAY_ORDER`) to ignore the element order of selected arrays, such as env vars or volumes, when diffing rendered manifests. The option is opt-in and empty by default. - Add pkg/arrayorder with a JSONPath subset: .field, ..field, [*], [n], ['a.b'] and a root `[?(@.kind == 'Deployment')]` string equality filter. - Sort matched arrays on deep copies before matching, so output manifests keep their original order. - Align paired elements by identity, then by `name`, when rendering the diff. Changed entries stay at their sorted position instead of showing up as removed and re-added. - Wire the option through cmd, GeneratePreview and matching.GenerateAppDiffs. - Add unit tests. - Document the option in docs/options.md and docs/filter-output.md.
Add branch-22 test cases for `--ignore-array-order`. The target reorders `env`, `volumes` and `args` of a Deployment and changes one env var value. - target-1: without the option, all reorderings show up in the diff. - target-2: with the option, only the env value change and the `args` reorder remain. The test data branches live in a fork. Add `TestCase.GitHubRepo` to clone the branches from, and pass as --repo, a repository other than the default. Replace the hardcoded repository in cloneBranch, buildArgs and runWithDocker with gitHubRepo(tc). Drop GitHubRepo from both test cases once the branches exist in the main repository.
This branch has not been deployed
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.
Draft - waiting for feedback on the feature request
What
Adds an opt-in
--ignore-array-orderoption (envIGNORE_ARRAY_ORDER). It takes alist of JSONPaths. Arrays matched by a path are compared without regard to element
order. The default is empty, so the current behavior is unchanged.
Behavior
.field,..field,[*],[n],['a.b']and a root filter$[?(@.kind == 'Deployment')]. Anything else is rejected with an error.--output-app-manifestsand--output-branch-manifestskeep the original order.nameif all have one, otherwise by their JSON form.A changed or renamed entry therefore does not make unchanged neighbors look
removed and re-added.
Open questions
kindfilter wanted, or should it be dropped?Tests
branch-22(target-1 without the option, target-2 with it).Its data branches currently live in my fork. They would need to be created in
this repository as
integration-test/branch-22/baseandtarget, and theGitHubRepofield of the two test cases removed.Warning
Array order is not always irrelevant (
$(VAR)expansion inenv,command,args,initContainers). This is documented indocs/filter-output.md.