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
feat(transform): Support string joining arrays #5148
Conversation
1e340d5
to
e3ca469
Compare
case v1.StringTransformTypeJoin: | ||
if t.String.Join == nil { | ||
return errors.Errorf("string transform join type is required for join transform") | ||
} |
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.
here the fromType should be checked, given that this transform will only work with arrays as input, you should change this to:
case v1.StringTransformTypeJoin: | |
if t.String.Join == nil { | |
return errors.Errorf("string transform join type is required for join transform") | |
} | |
case v1.StringTransformTypeJoin: | |
if fromType != v1.TransformIOTypeArray { | |
return errors.Errorf("string transform join type can only be used with arrays as input, got %s", fromType) | |
} |
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.
Added.
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 shouldn't be this function's job to validate the correctness of the API, just that the types match. We check that for StringTransformTypeConvert
above only because we need to further switch on it to know the correct type. That's why I was suggesting replacing it altogether instead of adding it. But that doesn't change much, it's just a nit. Let me know if you want to address that or we can proceed further.
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 was assuming it would to that because it does so in https://github.com/crossplane/crossplane/pull/5148/files#diff-7728e09aa45c2c48325829b0553db452c72cbff4ff04874ba739e36e0f3d7175R490
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 removed the changes
Add a new string tranform `Join` that wraps around `strings.Join` and converts any given array into a single string separated by a user defined string. Signed-off-by: Maximilian Blatt <maximilian.blatt-extern@deutschebahn.com>
9367b8f
to
8d6af61
Compare
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.
LGTM, thanks!
Description of your changes
Add a new string tranform
Join
that wraps aroundstrings.Join
and converts any given array into a single string separated by a user defined string.Docs PR: crossplane/docs#662
I have:
make reviewable
to ensure this PR is ready for review.backport release-x.y
labels to auto-backport this PR.Need help with this checklist? See the cheat sheet.