-
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
use field options to refine replacements #3773
use field options to refine replacements #3773
Conversation
159df07
to
bea04d5
Compare
9282e4d
to
4f8425c
Compare
@monopole updated to allow prefixing/suffixing and added a test with a path |
4f8425c
to
81abc07
Compare
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: 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 |
81abc07
to
0d0e6b9
Compare
} | ||
value := strings.Split(yaml.GetValue(rn), options.Delimiter) | ||
var index int | ||
if options.Index > len(value) || options.Index < 0 { // take the last element |
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.
This also seems like invalid configuration to me that should result in an error. It makes sense to provide a way to target the last element regardless of how many there are, but I'd say that should be done with a specific value, i.e. -1
, or for negative indexes to be supported in general. But I feel like > current length
and < 0
both meaning "last" could get confusing, especially given that current length can change independently of the Kustomization this is written in.
Edit: making negative indexing select the end when specified in source and indicate a prefix in target is also confusing
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 have updated it to throw an error if the source index is out of bounds
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's a good idea to be relaxed about inputs (and strict on outputs).
However, I cannot think of a no-surprises default behavior for an out-of-range index after the split when trying to get the source value.
So - seems that it should error (fail build). Meaning that a split resulting in an empty array is always an error.
0d0e6b9
to
7998c34
Compare
7998c34
to
a40c74e
Compare
/lgtm |
#3492, #3772
Use
delimiter
,index
, andcreate
options.@monopole I was hoping you could clarify what you intended for the
encoding
option to do (from this comment).