newrelic/centurion

--override-env doesn't accept envvars with = in the value

intjonathan opened this issue · 2 comments

This is an unfortunate pattern in Java apps, which take -D or -X arguments in environment strings. Here's an example from Cassandra:

--override-env "JVM_OPTS='-Dcassandra.replace_address=10.1.1.254'"

The string the actual container gets is

"JVM_OPTS='-Dcassandra.replace_address"

This stems from the overly-simplistic String#split call here:
https://github.com/newrelic/centurion/blob/master/bin/centurion#L63

Seems like something more intelligent could be devised.

As a quick fix we could use envvar.split('=', 2). That would assume that the variable name doesn't contain a literal = and any ='s in the value will be simply passed along.

The invocation could look like this, then

--override-env "JVM_OPTS=-Dcassandra.replace_address=10.1.1.254"

Oh, the JVM and it's lovely CLI options. I like @wulczer's approach.