granadaCoder
granadaCoder

Reputation: 27852

Hyphen and/or period in environment variable name is causing issue

This is working.

oc new-app --docker-image=docker.mycompany.com/myusername/my-imagestuff:latest -e SPRING_DATASOURCE_URL="jdbc:sqlserver://blahblahblah;” -e SPRING_DATASOURCE_USERNAME=“myUserName1” -e SPRING_DATASOURCE_PASSWORD=“MyP#ssword” -e

so I went back and added the datasource-classname

oc new-app --docker-image=docker.mycompany.com/myusername/my-imagestuff:latest -e SPRING_DATASOURCE_URL="jdbc:sqlserver://blahblahblah;” -e SPRING_DATASOURCE_USERNAME=“myUserName1” -e SPRING_DATASOURCE_PASSWORD=“MyP#ssword” -e SPRING_DATASOURCE_DRIVER-CLASS-NAME="com.microsoft.sqlserver.jdbc.SQLServerDriver"

and now my deployments are failing with this error:

error: invalid parameter assignment in "SPRING_DATASOURCE_DRIVER-CLASS-NAME=com.microsoft.sqlserver.jdbc.SQLServerDriver"

What is the magic sauce of hyphen / hyphens and/or periods / dots in the environment variable and value ?

Thanks!

Upvotes: 0

Views: 2786

Answers (2)

Paul Calabro
Paul Calabro

Reputation: 1906

You're unable to use environment variables that contain hyphens or periods because those characters are not valid in shell variable names:

➜  tmp.0ngsgXro foo.bar=1
   zsh: command not found: foo.bar=1

➜  tmp.0ngsgXro foo-bar=1
   zsh: command not found: foo-bar=1

➜  tmp.0ngsgXro foo_bar=1
➜  tmp.0ngsgXro echo $foo_bar
   1

You're trying to create an environment variable in your container that violates the rules of the underlying shell.

Upvotes: 3

granadaCoder
granadaCoder

Reputation: 27852

So out of desperation, I changed the hyphens to underscores.

Note the last argument of SPRING_DATASOURCE_DRIVER_CLASS_NAME

oc new-app --docker-image=docker.mycompany.com/myusername/my-imagestuff:latest -e SPRING_DATASOURCE_URL="jdbc:sqlserver://blahblahblah;” -e SPRING_DATASOURCE_USERNAME=“myUserName1” -e SPRING_DATASOURCE_PASSWORD=“MyP#ssword” -e SPRING_DATASOURCE_DRIVER_CLASS_NAME="com.microsoft.sqlserver.jdbc.SQLServerDriver"

And my app is working. So I am writing this answer.

I do not understand this voodoo.

If someone can explain it, I'd be grateful.

Upvotes: 1

Related Questions