Skip to content

Support workspace env #529

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

Closed
wants to merge 4 commits into from
Closed

Conversation

amisevsk
Copy link
Collaborator

@amisevsk amisevsk commented Jul 29, 2021

What does this PR do?

Adds support for workspaceEnv as in devfile 1.0 via the attribute workspaceEnv on components. Environment variables can be added to all containers in a DevWorkspace by specifying e.g.

components:
  - name: my-component
    attributes:
      workspaceEnv: 
        TEST_ENV_1: TEST_VAL_1
        TEST_ENV_2: TEST_VAL_2

What issues does this PR fix or reference?

Closes #530

Is it tested? How?

Test cases are added. Can be tested directly using the DevWorkspace

cat <<EOF | kubectl apply -f -
kind: DevWorkspace
apiVersion: workspace.devfile.io/v1alpha2
metadata:
  name: theia-next
spec:
  started: true
  template:
    attributes:
      controller.devfile.io/storage-type: "ephemeral"
    components:
      - name: tooling
        attributes:
          workspaceEnv: 
            TEST_ENV_1: TEST_VAL_1
            TEST_ENV_2: TEST_VAL_2
        container:
          image: quay.io/wto/web-terminal-tooling
          args: ["tail", "-f", "/dev/null"]
      - name: theia
        plugin:
          uri: https://che-plugin-registry-main.surge.sh/v3/plugins/eclipse/che-theia/next/devfile.yaml

PR Checklist

  • E2E tests pass (when PR is ready, comment /test v7-devworkspaces-operator-e2e, v7-devworkspace-happy-path to trigger)
    • v7-devworkspaces-operator-e2e: DevWorkspace e2e test
    • v7-devworkspace-happy-path: DevWorkspace e2e test

amisevsk added 3 commits July 29, 2021 15:36
Add support for workspaceEnv (i.e. environment variables provided by a
component that get added to all other components) though setting an
attribute 'workspaceEnv' in a component. If that component is added to
the workspace (either directly or through a plugin) the environment
variables defined within are added to all containers and init containers
in the workspace.

Example: a component

  components:
  - name: my-component
    attributes:
      workspaceEnv:
        - name: MY_ENV
          value: my-value
        - name: MY_ENV_2
          value: my-value-2

will add the MY_ENV and MY_ENV_2 environment variables to all containers
in the DevWorkspace.

Signed-off-by: Angel Misevski <[email protected]>
Extract common setup for tests to a separate function

Signed-off-by: Angel Misevski <[email protected]>
@amisevsk amisevsk requested a review from sleshchenko as a code owner July 29, 2021 19:38
@openshift-ci
Copy link

openshift-ci bot commented Jul 29, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: amisevsk

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot requested a review from JPinkney July 29, 2021 19:38
@amisevsk
Copy link
Collaborator Author

This PR is a little half-baked since GitHub submitted it while I was writing the description :/

Switch the definition of workspaceEnv from

    attributes:
      workspaceEnv:
        - name: TEST_ENV_1
          value: TEST_VAL_1
        - name: TEST_ENV_2
          value: TEST_VAL_2

to

    attributes:
      workspaceEnv:
        TEST_ENV_1: TEST_VAL_1
        TEST_ENV_2: TEST_VAL_2

Signed-off-by: Angel Misevski <[email protected]>
@amisevsk amisevsk mentioned this pull request Jul 29, 2021
8 tasks
@amisevsk
Copy link
Collaborator Author

Needs to be reworked, will reopen once it's actually done right 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for defining environment variables for all containers in a component
1 participant