Skip to content
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

Content references in actions for editor specific action definitions. #13273

Merged
merged 5 commits into from
May 21, 2019

Conversation

metlos
Copy link
Contributor

@metlos metlos commented May 2, 2019

What does this PR do?

This is a POC implementation of #13057 with the devfile using the following schema:

commands:
- name: test and manual test
  attributes:
    group: test   
  actions:
  - type: exec
    component: mvn-stack
    command: mvn clean package
  - component: runtime
    command: java -jar service.jar
    workdir: $CHE_PROJECTS_ROOT/service/target
- name: run
  actions:
  - type: vscode-task
    reference: ../ide-config/vs-code/tasks.json
- name: debug
  actions:
  - type: vscode-launch
    reference: ../ide-config/vs-code/launch.json

While this is most probably subject to change, the contents of the referenced editor configuration is stored inside the workspace config as an attribute of a workspace command called actionReferenceContent. The workspace config commands (don't confuse those with the devfile commands!) have been modified to either have a commandline or content.

Note though that as we move towards representing the workspace using just the devfile, this is subject to change.

For now, to play with this, consider the following example:

Devfile

specVersion: 0.0.1
name: che-plugin-broker 
projects:
- name: che-plugin-broker
  clonePath: src/github.com/eclipse/che-plugin-broker
  source:
    type: git
    location: https://github.com/eclipse/che-plugin-broker.git
components:
- alias: golang
  type: dockerimage
  image: golang
  memoryLimit: 512M  
  mountSources: true
  command: ['sleep', 'infinity']
  env:
  - name: GOPATH
    value: $(CHE_PROJECTS_ROOT)
  - name: GOCACHE
    value: $(GOPATH)/.cache
commands:
- name: test
  actions:
  - type: exec
    component: golang
    command: "cd $GOPATH/src/github.com/eclipse/che-plugin-broker; go test -v -race ./..."    
- name: tasks
  actions:
  - type: vscode-tasks
    referenceContent: |
            {
                    "version": "2.0.0",
                    "tasks": {}
            }

is converted into the workspace like this:

{
    "links": {
        "self": "http:\/\/che-eclipse-che.192.168.99.102.nip.io\/api\/devfile\/workspace8y4p5qqd0j0vzz56",
        "ide": "http:\/\/che-eclipse-che.192.168.99.102.nip.io\/che\/che-plugin-broker"
    },
    "attributes": {
        "created": "1556801595390"
    },
    "namespace": "che",
    "temporary": false,
    "id": "workspace8y4p5qqd0j0vzz56",
    "status": "STOPPED",
    "config": {
        "defaultEnv": "default",
        "environments": {
            "default": {
                "machines": {
                    "golang": {
                        "attributes": [],
                        "servers": [],
                        "volumes": {
                            "projects": {
                                "path": "\/projects"
                            }
                        },
                        "installers": [],
                        "env": []
                    }
                },
                "recipe": {
                    "type": "kubernetes",
                    "content": "---\napiVersion: \"v1\"\nkind: \"List\"\nitems:\n- apiVersion: \"apps\/v1\"\n  kind: \"Deployment\"\n  metadata:\n    annotations: {}\n    labels:\n      che.component.name: \"golang\"\n    name: \"golang\"\n  spec:\n    selector:\n      matchLabels:\n        che.component.name: \"golang\"\n    template:\n      metadata:\n        annotations:\n          org.eclipse.che.container.golang.machine_name: \"golang\"\n        labels:\n          che.component.name: \"golang\"\n        name: \"golang\"\n      spec:\n        containers:\n        - command:\n          - \"sleep\"\n          - \"infinity\"\n          env:\n          - name: \"GOPATH\"\n            value: \"$(CHE_PROJECTS_ROOT)\"\n          - name: \"GOCACHE\"\n            value: \"$(GOPATH)\/.cache\"\n          image: \"golang\"\n          name: \"golang\"\n          resources:\n            limits:\n              memory: \"512M\"\n            requests: {}\n        nodeSelector: {}\n",
                    "contentType": "application\/x-yaml"
                }
            }
        },
        "projects": [
            {
                "links": [],
                "name": "che-plugin-broker",
                "attributes": [],
                "source": {
                    "location": "https:\/\/github.com\/eclipse\/che-plugin-broker.git",
                    "type": "git",
                    "parameters": []
                },
                "path": "\/src\/github.com\/eclipse\/che-plugin-broker",
                "problems": [],
                "mixins": []
            }
        ],
        "name": "che-plugin-broker",
        "attributes": {
            "editor": "org.eclipse.che.editor.theia:1.0.0",
            "plugins": "che-machine-exec-plugin:0.0.1"
        },
        "commands": [
            {
                "commandLine": "cd $GOPATH\/src\/github.com\/eclipse\/che-plugin-broker; go test -v -race .\/...",
                "name": "test",
                "attributes": {
                    "componentAlias": "golang",
                    "machineName": "golang"
                },
                "type": "exec"
            },
            {
                "name": "tasks",
                "attributes": {
                    "actionReferenceContent": "{\n        \"version\": \"2.0.0\",\n        \"tasks\": {}\n}\n"
                },
                "type": "vscode-tasks"
            }
        ],
        "links": []
    }
}

What issues does this PR fix or reference?

#13057

@metlos metlos changed the title WIP content references in actions for editor specific action definitions. Content references in actions for editor specific action definitions. May 7, 2019
@metlos
Copy link
Contributor Author

metlos commented May 7, 2019

ci-build

@l0rd
Copy link
Contributor

l0rd commented May 15, 2019

@metlos can reference be an URL as well?

Copy link
Member

@sleshchenko sleshchenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good to me.

I have a question about

- name: run
  actions:
  - type: vscode-task
    reference: ../ide-config/vs-code/tasks.json

tasks.json may contain multiple tasks, right?
If yes, how client is supposed to handle it? Run all tasks when this command is invoked? Display different tasks as different commands?

@l0rd
Copy link
Contributor

l0rd commented May 15, 2019

@metlos a couple of questions raised my mind reading this PR description:

type: exec # I frankly still don't understand what we need this for --> is it a copy/paste or do you think we do not need it? If it's not a copy/paste can you explain why we should not need it?

"While this is most probably subject to change" --> why?

@metlos
Copy link
Contributor Author

metlos commented May 16, 2019

@metlos a couple of questions raised my mind reading this PR description:

type: exec # I frankly still don't understand what we need this for --> is it a copy/paste or do you think we do not need it? If it's not a copy/paste can you explain why we should not need it?

This is a copy&paste, I've removed it.

"While this is most probably subject to change" --> why?

Mostly just wishful thinking :) It's just a matter of taste, but IMHO we're overloading the meaning of a command and actions with this too much (as witnessed by @sleshchenko 's comment #13273 (review) here and my objections on #13057). This was discussed already at the issue, but more importantly the biggest unsolved question is how to figure out in what container to run the process of a task. If we're not able to solve that within the current design, I think we will need to move to the file-based approach.

@metlos
Copy link
Contributor Author

metlos commented May 20, 2019

@metlos can reference be an URL as well?

sorry, I didn't notice the question. Yes, this should be possible, because it uses the same content resolution mechanism as the reference of the kubernetes components.

@metlos
Copy link
Contributor Author

metlos commented May 20, 2019

Code looks good to me.

I have a question about

- name: run
  actions:
  - type: vscode-task
    reference: ../ide-config/vs-code/tasks.json

tasks.json may contain multiple tasks, right?
If yes, how client is supposed to handle it? Run all tasks when this command is invoked? Display different tasks as different commands?

The logic is supposed to be that the referenced "actions" (e.g. contents of tasks.json) are interpreted by the editor. So this command actually does not appear as a task to run at all. It is the contents that are imported into the editor.

@metlos
Copy link
Contributor Author

metlos commented May 20, 2019

ci-build

Signed-off-by: Lukas Krejci <[email protected]>
@metlos
Copy link
Contributor Author

metlos commented May 20, 2019

ci-test

@che-bot
Copy link
Contributor

che-bot commented May 20, 2019

Results of automated E2E tests of Eclipse Che Multiuser on OCP:
Build details
Test report
docker image: eclipseche/che-server:13273
https://github.com/orgs/eclipse/teams/eclipse-che-qa please check this report.

Copy link
Member

@sleshchenko sleshchenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please consider adding this feature description to README.md of devfile module. I'm OK with adding it in a separate PR.

LGTM

@@ -41,6 +41,15 @@
*/
String PLUGIN_ATTRIBUTE = "plugin";

/**
* An attribute of the command to store the original path to the file that contains the editor
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it makes sense to reference class here to make it clear which command is referenced here, devfile or workspace config

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is in the ws config Command class and is therefore used for the ws config.

@metlos
Copy link
Contributor Author

metlos commented May 21, 2019

Please consider adding this feature description to README.md of devfile module. I'm OK with adding it in a separate PR.

Good point, but I actually want to wait with this until we have a fully working solution on the UI side (the problem with the running of tasks in different containers is not solved yet). Depending on how things pan out on the UI side, we might need to re-consider the approach to this in the devfile.

@metlos metlos merged commit 0ce7b1d into eclipse-che:master May 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants