Environment variables defined in a Kubernetes container can only reference other variables declared earlier in the list of container environment variables. See the second note from the Kubernetes docs on environment variables.
This change ensures that the $PROJECT_SOURCE and $PROJECT_ROOT devfile environment variables are the first environment variables defined in all workspace pod containers so that devfile environment variables can reference $PROJECT_SOURCE and $PROJECT_ROOT.
Instead of appending $PROJECT_SOURCE and $PROJECT_ROOT to all workspace containers, we are now prepending them.
Additionally, existing tests were modified to accommodate this change in the list of container environment variables ordering, and a new test was added for this change.
Once the workspace starts up, exec into the workspace pod and run echo $ENV_TEST. The output should be /projects/web-nodejs-sample/hey-there -- in other words, $(PROJECT_SOURCE) will get evaluated to /projects/web-nodejs-sample/.
PR Checklist
[ ] E2E tests pass (when PR is ready, comment /test v8-devworkspace-operator-e2e, v8-che-happy-path to trigger)
[ ] v8-devworkspace-operator-e2e: DevWorkspace e2e test
[ ] v8-che-happy-path: Happy path for verification integration with Che
Needs approval from an approver in each of these files:
- ~~[OWNERS](https://github.com/devfile/devworkspace-operator/blob/main/OWNERS)~~ [AObuchow]
Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
What does this PR do?
Environment variables defined in a Kubernetes container can only reference other variables declared earlier in the list of container environment variables. See the second note from the Kubernetes docs on environment variables.
This change ensures that the $PROJECT_SOURCE and $PROJECT_ROOT devfile environment variables are the first environment variables defined in all workspace pod containers so that devfile environment variables can reference $PROJECT_SOURCE and $PROJECT_ROOT.
Instead of appending $PROJECT_SOURCE and $PROJECT_ROOT to all workspace containers, we are now prepending them.
Additionally, existing tests were modified to accommodate this change in the list of container environment variables ordering, and a new test was added for this change.
What issues does this PR fix or reference?
https://github.com/devfile/devworkspace-operator/issues/1274
Is it tested? How?
quay.io/aobuchow/devworkspace-controller:project-source-first
for ease of testing.echo $ENV_TEST
. The output should be/projects/web-nodejs-sample/hey-there
-- in other words,$(PROJECT_SOURCE)
will get evaluated to/projects/web-nodejs-sample/
.PR Checklist
/test v8-devworkspace-operator-e2e, v8-che-happy-path
to trigger)v8-devworkspace-operator-e2e
: DevWorkspace e2e testv8-che-happy-path
: Happy path for verification integration with Che