From 9e250183f6c1cb62dff673471ed76276285cb96f Mon Sep 17 00:00:00 2001 From: Anatolii Bazko Date: Wed, 7 Jun 2023 16:39:40 +0300 Subject: [PATCH] feat: [che-operator] devfile improvements (#1698) * feat: Devfile improvements Signed-off-by: Anatolii Bazko --- .vscode/extensions.json | 7 ++++ .vscode/launch.json | 4 --- .vscode/tasks.json | 7 +--- devfile.yaml | 76 +++++++++++++++++++++++++++++++++-------- 4 files changed, 70 insertions(+), 24 deletions(-) create mode 100644 .vscode/extensions.json diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 000000000..9840b8971 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,7 @@ +{ + "recommendations": [ + "golang.go", + "mads-hartmann.bash-ide-vscode", + "redhat.vscode-yaml", + ] +} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json index 2ffd04a6d..cda1c4bea 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -17,10 +17,6 @@ "program": "${workspaceFolder}/main.go", "envFile": "/tmp/che-operator-dev/vscode.env", "cwd": "${workspaceFolder}", - "args": [ - "--defaults-path", - "config/manager/manager.yaml" - ] }, { "type": "bashdb", diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 311b41970..c0f96d7da 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -3,12 +3,7 @@ "tasks": [ { "label": "Compile Che operator code", - "command": "make compile", - "options": { - "env": { - "ARCH": "amd64" - } - }, + "command": "make build", "type": "shell", "args": [], "problemMatcher": [ diff --git a/devfile.yaml b/devfile.yaml index 6fe1a9089..c17295e59 100644 --- a/devfile.yaml +++ b/devfile.yaml @@ -29,32 +29,80 @@ components: value: /home/user/go - name: GOCACHE value: /tmp/.cache + - name: IMAGE_TOOL + value: podman + - name: KUBECONFIG + value: /home/user/.kube/config commands: + - id: install-go-1-18 + exec: + label: POST START EVENT - Install go 1.18 + component: tooling-container + commandLine: | + cd /tmp && wget https://go.dev/dl/go1.18.6.linux-amd64.tar.gz && \ + mkdir $HOME/go1.18 && \ + tar -xvzf go1.18.6.linux-amd64.tar.gz -C $HOME/go1.18 --strip-components 1 && \ + if ! grep -q "export PATH=\$HOME/go1.18/bin:\$PATH" $HOME/.bashrc; then echo "export PATH=\$HOME/go1.18/bin:\$PATH" >> $HOME/.bashrc; fi + - id: install-chectl + exec: + label: POST START EVENT - Install chectl + component: tooling-container + commandLine: | + tag=$(curl https://api.github.com/repos/che-incubator/chectl/tags | jq -r '.[0].name') && \ + cd /tmp && wget https://github.com/che-incubator/chectl/releases/download/${tag}/chectl-linux-x64.tar.gz && \ + mkdir $HOME/chectl && \ + tar -xvzf chectl-linux-x64.tar.gz -C $HOME/chectl --strip-components 1 && \ + if ! grep -q "export PATH=\$HOME/chectl/bin:\$PATH" $HOME/.bashrc; then echo "export PATH=\$HOME/chectl/bin:\$PATH" >> $HOME/.bashrc; fi + - id: install-goimports + exec: + label: POST START EVENT - Install goimports + component: tooling-container + commandLine: | + $HOME/go1.18/bin/go install golang.org/x/tools/cmd/goimports@latest && \ + if ! grep -q "PATH=\$PATH:\$GOPATH/bin" $HOME/.bashrc; then echo "export PATH=\$PATH:\$GOPATH/bin" >> $HOME/.bashrc; fi + - id: install-git-autocompletion + exec: + label: POST START EVENT - Install git autocompletion + component: tooling-container + commandLine: if ! grep -q "source /usr/share/bash-completion/completions/git" $HOME/.bashrc; then echo "source /usr/share/bash-completion/completions/git" >> $HOME/.bashrc; fi + - id: install-oc-autocompletion + exec: + label: POST START EVENT - Install oc autocompletion + component: tooling-container + commandLine: | + oc completion bash > $HOME/oc_bash_completion && \ + if ! grep -q "source \$HOME/oc_bash_completion" $HOME/.bashrc; then echo "source \$HOME/oc_bash_completion" >> $HOME/.bashrc; fi - id: go-build exec: - label: 1. Build Eclipse Che Operator binary + label: Build Eclipse Che Operator binary component: tooling-container commandLine: make build - id: go-run exec: - label: 2. Run Eclipse Che Operator + label: Run Eclipse Che Operator component: tooling-container commandLine: make run + - id: go-test + exec: + label: Run unit tests + component: tooling-container + commandLine: make test - id: go-debug exec: - label: 3. Run and debug Eclipse Che Operator + label: Run and debug Eclipse Che Operator component: tooling-container commandLine: make debug - - id: bundle + - id: update-dev-resources exec: - label: 4. Generate OLM bundle for next channel + label: Update all development resources component: tooling-container - commandLine: CHANNEL=next make bundle - - id: docker-build-push - exec: - label: 5. Build and push Eclipse Che Operator container image - component: tooling-container - commandLine: > - read -p "ENTER the image registry (for example \"quay.io\"): " IMAGE_REGISTRY_HOST && - read -p "ENTER the image organization (for example \"eclipse\"): " IMAGE_REGISTRY_USER_NAME && - IMAGE_TOOL=podman make docker-build docker-push IMG="${IMAGE_REGISTRY_HOST}/${IMAGE_REGISTRY_USER_NAME}/che-operator:next" + commandLine: make update-dev-resources +events: + postStart: + - install-go-1-18 + - install-chectl + - install-goimports + - install-git-autocompletion + - install-oc-autocompletion + +