Search code examples
openshiftopenshift-3openshift-enterprise

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!


Solution

  • 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.