name: "Adds workspace environment variables defined in plugin to DevWorkspace"

input:
  devworkspace:
    components:

      - name: test-plugin
        plugin:
          uri: "https://my-plugin.io/test"

      - name: regular-container
        container:
          image: test-image-regular

      - name: init-container
        container:
          image: test-image-init

    commands:
      - id: make-init
        apply:
          component: init-container

    events:
      prestart: [make-init]

  devfileResources:
    "https://my-plugin.io/test":
      schemaVersion: 2.0.0
      metadata:
        name: "plugin-a"
      components:
        - name: plugin-a
          attributes:
            workspaceEnv:
              - name: TEST_ENV_1
                value: TEST_VAL_1
              - name: TEST_ENV_2
                value: TEST_VAL_2
          container:
            name: test-container
            image: test-image

output:
  devworkspace:
    components:
      - name: plugin-a
        attributes:
          controller.devfile.io/imported-by: test-plugin
          workspaceEnv:
            - name: TEST_ENV_1
              value: TEST_VAL_1
            - name: TEST_ENV_2
              value: TEST_VAL_2
        container:
          name: test-container
          image: test-image
          env:
            - name: TEST_ENV_1
              value: TEST_VAL_1
            - name: TEST_ENV_2
              value: TEST_VAL_2
      - name: regular-container
        container:
          image: test-image-regular
          env:
          - name: TEST_ENV_1
            value: TEST_VAL_1
          - name: TEST_ENV_2
            value: TEST_VAL_2
      - name: init-container
        container:
          image: test-image-init
          env:
          - name: TEST_ENV_1
            value: TEST_VAL_1
          - name: TEST_ENV_2
            value: TEST_VAL_2
    commands:
      - id: make-init
        apply:
          component: init-container
    events:
      prestart: [make-init]
