Skip to content

Commit

Permalink
Rework plugin samples to separate components better
Browse files Browse the repository at this point in the history
Move remote-runtime-injector and vsx-installer to separate plugins that
are imported by theia, rather than having a huge theia plugin definition

Signed-off-by: Angel Misevski <amisevsk@redhat.com>
  • Loading branch information
amisevsk committed Jan 26, 2021
1 parent 4eb99ea commit e6cf53a
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 42 deletions.
27 changes: 27 additions & 0 deletions samples/plugins/remote-runtime-injector.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
kind: DevWorkspaceTemplate
apiVersion: workspace.devfile.io/v1alpha2
metadata:
name: remote-runtime-injector
spec:
components:
- name: remote-runtime-injector
attributes:
"app.kubernetes.io/part-of": che-theia.eclipse.org
"app.kubernetes.io/component": bootstrapper
container: #### corresponds to `initContainer` definition in old meta.yaml.
image: "quay.io/eclipse/che-theia-endpoint-runtime-binary:7.20.0"
volumeMounts:
- path: "/remote-endpoint"
name: remote-endpoint
env:
- name: PLUGIN_REMOTE_ENDPOINT_EXECUTABLE
value: /remote-endpoint/plugin-remote-endpoint
- name: REMOTE_ENDPOINT_VOLUME_NAME
value: remote-endpoint
commands:
- id: inject-theia-in-remote-sidecar
apply:
component: remote-runtime-injector
events:
preStart:
- inject-theia-in-remote-sidecar
51 changes: 9 additions & 42 deletions samples/plugins/theia-next.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,16 @@ spec:
volume: {}
- name: remote-endpoint
volume: {} # TODO: Fix this once ephemeral volumes are supported
- name: vsx-installer # Mainly reads the container objects and searches for those
# with che-theia.eclipse.org/vscode-extensions attributes to get VSX urls
# Those found in the dedicated containers components are with a sidecar,
# Those found in the che-theia container are without a sidecar.
attributes:
"app.kubernetes.io/part-of": che-theia.eclipse.org
"app.kubernetes.io/component": bootstrapper
container:
args:
- /bin/sh
- '-c'
- >
workspace=$(curl -fsS --cacert /var/run/secrets/kubernetes.io/serviceaccount/ca.crt -H "Authorization: Bearer $(cat /var/run/secrets/kubernetes.io/serviceaccount/token)" https://kubernetes.default.svc/apis/workspace.devfile.io/v1alpha2/namespaces/${CHE_WORKSPACE_NAMESPACE}/devworkspaces/${CHE_WORKSPACE_NAME}) && for container in $(echo $workspace | sed -e 's;[[,]\({"attributes":{"app.kubernetes.io\);\n\1;g' | grep '"che-theia.eclipse.org/vscode-extensions":' | grep -e '^{"attributes".*'); do dest=$(echo "$container" | sed 's;.*{"name":"THEIA_PLUGINS","value":"local-dir://\([^"][^"]*\)"}.*;\1;' - ) ; urls=$(echo "$container" | sed 's;.*"che-theia.eclipse.org/vscode-extensions":\[\([^]][^]]*\)\]}.*;\1;' - ) ; mkdir -p $dest; for url in $(echo $urls | sed 's/[",]/ /g' - ); do echo; echo downloading $urls to $dest; curl -L $url > $dest/$(basename $url); done; done
image: 'quay.io/samsahai/curl:latest'
volumeMounts:
- path: "/plugins"
name: plugins
- name: vsx-installer
plugin:
kubernetes:
name: vsx-installer
namespace: devworkspace-plugins
- name: remote-runtime-injector
attributes:
"app.kubernetes.io/part-of": che-theia.eclipse.org
"app.kubernetes.io/component": bootstrapper
container: #### corresponds to `initContainer` definition in old meta.yaml.
image: "quay.io/eclipse/che-theia-endpoint-runtime-binary:7.20.0"
volumeMounts:
- path: "/remote-endpoint"
name: remote-endpoint
env:
- name: PLUGIN_REMOTE_ENDPOINT_EXECUTABLE
value: /remote-endpoint/plugin-remote-endpoint
- name: REMOTE_ENDPOINT_VOLUME_NAME
value: remote-endpoint
plugin:
kubernetes:
name: remote-runtime-injector
namespace: devworkspace-plugins
- name: theia-ide
attributes:
"app.kubernetes.io/name": che-theia.eclipse.org
Expand Down Expand Up @@ -101,15 +80,3 @@ spec:
exposure: public
targetPort: 13133
protocol: http
commands:
# Commands coming from plugin editor
- id: inject-theia-in-remote-sidecar
apply:
component: remote-runtime-injector
- id: copy-vsx
apply:
component: vsx-installer
events:
preStart:
- inject-theia-in-remote-sidecar
- copy-vsx
40 changes: 40 additions & 0 deletions samples/plugins/vsx-installer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
kind: DevWorkspaceTemplate
apiVersion: workspace.devfile.io/v1alpha2
metadata:
name: vsx-installer
spec:
components:
- name: vsx-installer # Mainly reads the container objects and searches for those
# with che-theia.eclipse.org/vscode-extensions attributes to get VSX urls
# Those found in the dedicated containers components are with a sidecar,
# Those found in the che-theia container are without a sidecar.
attributes:
"app.kubernetes.io/part-of": che-theia.eclipse.org
"app.kubernetes.io/component": bootstrapper
container:
image: 'quay.io/samsahai/curl:latest'
volumeMounts:
- path: "/plugins"
name: plugins
args:
- /bin/sh
- '-c'
- |
KUBE_API_ENDPOINT="https://kubernetes.default.svc/apis/workspace.devfile.io/v1alpha2/namespaces/${CHE_WORKSPACE_NAMESPACE}/devworkspaces/${CHE_WORKSPACE_NAME}" &&\
TOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token) &&\
WORKSPACE=$(curl -fsS --cacert /var/run/secrets/kubernetes.io/serviceaccount/ca.crt -H "Authorization: Bearer ${TOKEN}" $KUBE_API_ENDPOINT) &&\
for container in $(echo $WORKSPACE | sed -e 's;[[,]\({"attributes":{"app.kubernetes.io\);\n\1;g' | grep '"che-theia.eclipse.org/vscode-extensions":' | grep -e '^{"attributes".*'); do \
dest=$(echo "$container" | sed 's;.*{"name":"THEIA_PLUGINS","value":"local-dir://\([^"][^"]*\)"}.*;\1;' - ) ;\
urls=$(echo "$container" | sed 's;.*"che-theia.eclipse.org/vscode-extensions":\[\([^]][^]]*\)\]}.*;\1;' - ) ;\
mkdir -p $dest ;\
for url in $(echo $urls | sed 's/[",]/ /g' - ); do \
echo; echo downloading $urls to $dest; curl -L $url > $dest/$(basename $url) ;\
done \
done \
commands:
- id: copy-vsx
apply:
component: vsx-installer
events:
preStart:
- copy-vsx

0 comments on commit e6cf53a

Please sign in to comment.