-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Allow setting every array element in replacements #4424
Allow setting every array element in replacements #4424
Conversation
Hi @koba1t. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/assign @phanimarupaka |
/ok-to-test |
Would you mind also adding a test to https://github.com/kubernetes-sigs/kustomize/blob/master/api/filters/replacement/replacement_test.go to add some e2e coverage? Thank you for working on this |
@koba1t: This PR has multiple commits, and the default merge method is: merge. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
- name: deployment-name | ||
value: sample-deploy`, | ||
}, | ||
"list index contains '*' character": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the difference between this test and the above test?
Also, the test seems not to be passing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It tests to replace multi values in a single '*' character.
Sorry for the delay to reply. I think "replacements" couldn't replace for the target to multi values. e.g. source
result
It's only to replace the first element in deploy.yaml. I think it's needed to fix when using this function. And I'm trying it now. |
Hello @natasha41575. Sorry for to delay. |
Thanks for the update! I have been out for a few days, will try to take a look soon. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some very minor nits, apart from that LGTM.
@@ -119,20 +119,42 @@ func applyToNode(node *yaml.RNode, value *yaml.RNode, target *types.TargetSelect | |||
if target.Options != nil && target.Options.Create { | |||
t, err = node.Pipe(yaml.LookupCreate(value.YNode().Kind, fieldPath...)) | |||
} else { | |||
t, err = node.Pipe(yaml.Lookup(fieldPath...)) | |||
// t, err = node.Pipe(yaml.Lookup(fieldPath...)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you forget to remove this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I'll delete it.
kyaml/yaml/fns.go
Outdated
@@ -796,6 +803,12 @@ func SplitIndexNameValue(p string) (string, string, error) { | |||
return parts[0], parts[1], nil | |||
} | |||
|
|||
// IsMatchEveryIndex returns true if p is matching every elements. | |||
// e.g. "*" | |||
func IsMatchEveryIndex(p string) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest changing the name here to IsWildcard
and moving this up to line 791 to keep the IsXXXX
functions together
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with you. I fix it.
I fix any mistake from your review and add the above testcase(#4424 (comment)). |
/lgtm Thanks! |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: koba1t, natasha41575 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
So nice to see this implemented, thanks @koba1t! 🎉 |
you rock @koba1t |
Implement to #4053.
And resolve #4414 (comment) and #4391.