-
Notifications
You must be signed in to change notification settings - Fork 230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
kpt/kyaml doesn't parse yaml sequence nodes correctly #1342
Comments
@natasha41575 @etefera This is a good candidate to understand more about kyaml parsing. If you don't have cycles I can pick this up. cc @mikebz |
@phanimarupaka if you have cycles feel free to take it. If not, I'm happy to take a look next week |
@seh Have you tried modifying the yaml like this
This works |
@phanimarupaka Does this really work? I don't think this is a valid Kustomization... according to https://kubectl.docs.kubernetes.io/references/kustomize/patches/ |
No, I haven't tried that, because , as @phanimarupaka noted, the documentation prescribes embedding the patch content as a string (emphasis mine):
I'm willing to try it, but if that works, then we need to fix the documentation. Also, if that does work, then It's weird that patches work (without interpolation) as embedded strings now. |
@seh well I have tried that, could not get it work though (which means that the documentation is correct)
|
@seh @msonnleitner There are 2 issues here.
@monopole @Shell32-Natsu Can patches be yaml nodes instead of enforcing them to be strings. This solves a bigger problem and can help users to easily parameterize patches. Enforcing them to be strings makes it difficult for tools to parse them as yaml and query them. |
Yes, with the current state of kustomize and kpt, using JSON Patch is difficult. We can't use setters and substitutions due to the these conflicting constraints:
My real goal is to use a parametric JSON Patch. At present, I have to write a script to generate the patch file, interpolating the dynamic values before kustomize ever sees it, which then eliminates the use of setters for the patch content. |
What kustomize supports is either a embedded string of JSON patch in kustomization or a YAML/JSON patch in a separate file. @monopole I think it's ok to accept a list of structured JSON patch. WDYT?
Sorry, the statement above is about another issue. |
There is also the "patchesJson6902" field. That one can also refer to separate files or accept the patch as an inline string, which is subject to the same limitations we face with the "patches" field. Do you intend to retain both of these fields in the future? The documentation encourages writing the content as either JSON or YAML, which leads users into this defect's waiting arms. |
+1, running into the same issue. For my use I tried to get around this by using strategicMergePatch with a |
For anyone who picks this up, I believe ultimately the fix will be in the kustomize/kyaml code; feel free to submit the fix there if needed and we can still take a look at it. |
Some pointers for new contributors who pick up this issue:
|
@yuwenma I'd like to confirm the intended behavior with For the
The
However, running
does not find any matches in Questions:
|
/assign |
Thanks for looking at this issue @annasong20
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
patches:
- target:
kind: Something
patch: |-
- op: add
path: placeholder # {"$kpt-set":"some-json-pointer"}
value: known
|
EDIT: no longer relevant |
To clarify, if you file an issue in the kustomize repo, the issue doesn't need to include implementation details (we can discuss that in the PR). But the issue should have a quick explanation of the problematic behavior vs the desired behavior. |
I will no longer be working on this issue,. Please find a summary of my findings below.
|
The following is expected workflow
@seh So summarizing your request...
If you start with
and do
kpt cfg create-setter . some-json-pointer placeholder
The output should be
and later on
kpt cfg set . some-json-pointer new-placeholder
should give output
But it doesn't work as expected. Investigate and fix it.
The text was updated successfully, but these errors were encountered: