Skip to content
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

Fix #2361: allow multiline properties by correctly encoding them #2369

Merged
merged 3 commits into from
Jun 9, 2021

Conversation

nicolaferraro
Copy link
Member

Fix #2361

@squakez mind having a look?

Release Note

Multi-line properties can be used in KameletBindings

@nicolaferraro nicolaferraro added the kind/bug Something isn't working label Jun 7, 2021
Copy link
Contributor

@squakez squakez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cannot easily understand the meaning of the toPropertyEntry function. I'd suggest to include a set of unit test in run_test.go just for this private function with clear input/output expectation. It will improve the readability and future updates.

pkg/cmd/run.go Outdated
item = strings.ReplaceAll(item, `=`, `\=`)
item = strings.ReplaceAll(item, `:`, `\:`)
return item
func toPropertyEntry(props *properties.Properties, key string) (string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function is repeated in another unit, I'd avoid to include repeated code.

pkg/cmd/run.go Outdated
item = strings.ReplaceAll(item, `:`, `\:`)
return item
func toPropertyEntry(props *properties.Properties, key string) (string, error) {
value, _ := props.Get(key)
Copy link
Contributor

@squakez squakez Jun 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can instead provide that value variable as a input variable of the fuction instead of props. You only use props to extract this value AFAICS

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now I've seen you already did it this way in the other function in common.go. I'd suggest just using this one then.

@nicolaferraro
Copy link
Member Author

Right about refactoring the toPropertyEntry function. The meaning is to encode a k/v pair into a property-file line that can be written directly into a .properties file. A config entry in the integration/kit/platform will contain an encoded line for each property, which usually means a line having k = v, but it sometimes needs encoding e.g. when the value spans over multiple lines. I let the library encode the entry.

Copy link
Contributor

@squakez squakez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good, thanks!

@nicolaferraro nicolaferraro merged commit 47c606d into apache:main Jun 9, 2021
@nicolaferraro nicolaferraro deleted the fix-2361 branch June 9, 2021 10:09
@nicolaferraro nicolaferraro mentioned this pull request Jul 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't set multiline properties in Kamelet bindings
3 participants