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

Any ideas on disabling property expansion in kamel run? #3422

Closed
barius opened this issue Jul 7, 2022 · 7 comments
Closed

Any ideas on disabling property expansion in kamel run? #3422

barius opened this issue Jul 7, 2022 · 7 comments
Labels
kind/question Further information is requested

Comments

@barius
Copy link

barius commented Jul 7, 2022

The use case is that I'm trying to log to different files in each pod on environment variable HOSTNAME. In application.properties :

quarkus.log.file.enable=true
quarkus.log.file.path=/log/log.test-logging.${HOSTNAME}

Kamel does this expansion on kamel run and ${HOSTNAME} is resolved to my local machine rather than k8s pod name.

Since Quarkus also provides property expression/expansion, could there be any method or thoughts to differentiate the two? e.g. changing prefix and postfix of "github.com/magiconair/properties" or add a switch to disable it?

Regards :)

@squakez
Copy link
Contributor

squakez commented Jul 7, 2022

@squakez squakez added kind/question Further information is requested area/programming-model labels Jul 7, 2022
@barius
Copy link
Author

barius commented Jul 7, 2022

@squakez If I use Camel properties, should I pass the properties via kamel run -p? Or --trait camel.properties=?

@barius
Copy link
Author

barius commented Jul 7, 2022

-t camel.properties='quarkus.log.file.path=/log/log.test-logging.${HOSTNAME}' works :)
Now that the log file is distinct per pod. Thanks!

Also, how to pass multiple properties this way? Multiple -t camel.properties= seems to not work, and -t camel.properties=[foo=bar,baz=blabla] won't work :(

@squakez
Copy link
Contributor

squakez commented Jul 7, 2022

You can both use a properties file or pass a list of properties. The kamel run will replace into trait for you. Ie:

test.properties
a=x
b=y
...
kamel run Test.java -o yaml -p file:test.properties

and

kamel run Test.java -o yaml -t camel.properties=a=x -t camel.properties=b=y

will produce the same output.

@barius
Copy link
Author

barius commented Jul 11, 2022

yep, -p and -t camel.properties are interchangeable unless property expansion is involved, since the Go package github.com/magiconair/properties used in camel-k does some shallow parsing to -p properties.
Anyway this is no big issue and I can use some wrapper script to pass a property file as multiple -t camel.properties arguments :P

@squakez
Copy link
Contributor

squakez commented Jul 11, 2022

I was answering to:

Multiple -t camel.properties= seems to not work, and -t camel.properties=[foo=bar,baz=blabla] won't work :(

the way to use multiple properties via trait is the one provided in the previous comment.

@barius
Copy link
Author

barius commented Jul 19, 2022

yes, I have tried again and multiple -t camel.properties= is now OK.
Now I use a wrapper script to expand a properties file into several -t camel.properties= args and it's ok.
Shall we close this issue?

@squakez squakez closed this as completed Jul 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants