Skip to content

Commit b1bebaa

Browse files
authored
chore: add devfile.yaml to work with plugin registry (#965)
* add devfile.yaml to work with plugin reg Signed-off-by: Valeriy Svydenko <[email protected]> --------- Signed-off-by: Valeriy Svydenko <[email protected]>
1 parent 17e1e8f commit b1bebaa

File tree

4 files changed

+114
-5
lines changed

4 files changed

+114
-5
lines changed

Diff for: .devfile.yaml

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
schemaVersion: 2.2.0
2+
metadata:
3+
name: ds-plugin-registry-dev
4+
components:
5+
- name: builder
6+
container:
7+
image: quay.io/devfile/universal-developer-image:ubi8-latest
8+
memoryRequest: 256Mi
9+
memoryLimit: 8Gi
10+
cpuRequest: 100m
11+
cpuLimit: 2000m
12+
env:
13+
- name: CONCURRENTLY_OPTS
14+
value: -m 1
15+
endpoints:
16+
- name: openvsx
17+
exposure: internal
18+
targetPort: 5432
19+
commands:
20+
- id: podman-login
21+
exec:
22+
label: "1. Login to registry.redhat.io"
23+
commandLine: podman login registry.redhat.io
24+
component: builder
25+
- id: build
26+
exec:
27+
label: "2. Build and Publish a Custom Plugin Registry"
28+
component: builder
29+
workingDir: ${PROJECTS_ROOT}/devspaces/dependencies/che-plugin-registry
30+
commandLine: |
31+
set -o xtrace;
32+
rm -rf output;
33+
mkdir output;
34+
BUILDER=podman SKIP_TEST=true SKIP_FORMAT=true SKIP_LINT=true NODE_BUILD_OPTIONS="-max-old-space-size=1024" ./build.sh &&
35+
export IMAGE=image-registry.openshift-image-registry.svc:5000/$(kubectl get sa default -o json | jq -r '.metadata.namespace')/che-plugin-registry &&
36+
podman tag quay.io/devspaces/pluginregistry-rhel8:next ${IMAGE} &&
37+
podman login --tls-verify=false -u $(oc whoami | tr -d :) -p $(oc whoami -t) image-registry.openshift-image-registry.svc:5000 &&
38+
podman push --tls-verify=false "${IMAGE}"
39+
- id: configure-custom-plugin-registry
40+
exec:
41+
label: "3. Configure Che to use the Custom Plugin Registry"
42+
component: builder
43+
workingDir: ${PROJECTS_ROOT}/devspaces/dependencies/che-plugin-registry
44+
commandLine: |
45+
export IMAGE=image-registry.openshift-image-registry.svc:5000/$(kubectl get sa default -o json | jq -r '.metadata.namespace')/che-plugin-registry &&
46+
export CHECLUSTER_NAMESPACE="$(kubectl get checluster --all-namespaces -o json | jq -r '.items[0].metadata.namespace')" &&
47+
kubectl create secret -n "${CHECLUSTER_NAMESPACE}" docker-registry regcred --docker-server=image-registry.openshift-image-registry.svc:5000 --docker-username=$(oc whoami | tr -d :) --docker-password=$(oc whoami -t) &&
48+
kubectl patch serviceaccount default -n "${CHECLUSTER_NAMESPACE}" -p '{"imagePullSecrets": [{"name": "regcred"}]}' &&
49+
./patch-cluster.sh "${IMAGE}"
50+
- id: enable-embedded-openvsx
51+
exec:
52+
label: "4. Configure Che to use the embedded Eclipse Open VSX server"
53+
component: builder
54+
workingDir: ${PROJECTS_ROOT}/devspaces/dependencies/che-plugin-registry
55+
commandLine: |
56+
export CHECLUSTER_NAME="$(kubectl get checluster --all-namespaces -o json | jq -r '.items[0].metadata.name')" &&
57+
export CHECLUSTER_NAMESPACE="$(kubectl get checluster --all-namespaces -o json | jq -r '.items[0].metadata.namespace')" &&
58+
export PATCH='{"spec":{"components":{"pluginRegistry":{"openVSXURL":""}}}}' &&
59+
kubectl patch checluster "${CHECLUSTER_NAME}" --type=merge --patch "${PATCH}" -n "${CHECLUSTER_NAMESPACE}"

Diff for: .vscode/extensions.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"recommendations": [
3+
"arcanis.vscode-zipfs",
4+
"donjayamanne.githistory",
5+
"eamodio.gitlens",
6+
"GitHub.vscode-pull-request-github",
7+
"redhat.vscode-yaml",
8+
"timonwong.shellcheck"
9+
]
10+
}

Diff for: dependencies/che-plugin-registry/build/dockerfiles/Dockerfile

+2-5
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,9 @@ COPY ./build/dockerfiles/content_set*.repo /etc/yum.repos.d/
4242
COPY ./build/dockerfiles/rhel.install.sh /tmp
4343
RUN /tmp/rhel.install.sh && rm -f /tmp/rhel.install.sh
4444

45-
# Use the final root filesystem as default directory
46-
WORKDIR /
47-
4845
# Copy OpenVSX server files
4946
COPY --chown=0:0 /openvsx-server.tar.gz .
50-
RUN tar -xf openvsx-server.tar.gz && rm openvsx-server.tar.gz
47+
RUN tar --no-same-owner -xf openvsx-server.tar.gz && rm openvsx-server.tar.gz
5148
# Copy our configuration file for OpenVSX server
5249
COPY /build/dockerfiles/application.yaml /openvsx-server/config/
5350
RUN chmod -R g+rwx /openvsx-server
@@ -76,7 +73,7 @@ COPY README.md .htaccess /var/www/html/
7673
COPY /build/scripts/*.sh resources.tgz che-*.yaml /build/
7774

7875
RUN chmod 755 /usr/local/bin/*.sh && \
79-
tar -xvf /build/resources.tgz -C /build/ && \
76+
tar --no-same-owner -xvf /build/resources.tgz -C /build/ && \
8077
rm -rf /build/output/v3/che-editors.yaml && \
8178
/build/list_referenced_images.sh /build/output/v3 --use-generated-content > /build/output/v3/external_images.txt && cat /build/output/v3/external_images.txt && \
8279
chmod -R g+rwX /build && \

Diff for: dependencies/che-plugin-registry/patch-cluster.sh

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash
2+
#
3+
# Copyright (c) 2023 Red Hat, Inc.
4+
# This program and the accompanying materials are made
5+
# available under the terms of the Eclipse Public License 2.0
6+
# which is available at https://www.eclipse.org/legal/epl-2.0/
7+
#
8+
# SPDX-License-Identifier: EPL-2.0
9+
#
10+
# Arguments
11+
# $1 - the new plugin registry image
12+
#
13+
14+
set -e -u
15+
16+
IMAGE=$1
17+
CHECLUSTER_NAME="$(kubectl get checluster --all-namespaces -o json | jq -r '.items[0].metadata.name')"
18+
CHECLUSTER_NAMESPACE="$(kubectl get checluster --all-namespaces -o json | jq -r '.items[0].metadata.namespace')"
19+
20+
TMPDIR="$(mktemp -d)"
21+
trap 'rm -rf -- "$TMPDIR"' EXIT
22+
cat << EOF > "${TMPDIR}"/patch-file.yaml
23+
spec:
24+
components:
25+
pluginRegistry:
26+
deployment:
27+
containers:
28+
- name: plugin-registry
29+
image: ${IMAGE}
30+
EOF
31+
32+
echo "Patching CheCluster ${CHECLUSTER_NAME} in namespace ${CHECLUSTER_NAMESPACE} to use ${IMAGE} as plugin registry image."
33+
echo
34+
echo "Original CheCluster .spec.components.pluginRegistry:"
35+
kubectl get -n "${CHECLUSTER_NAMESPACE}" checluster "${CHECLUSTER_NAME}" -o json | jq '.spec.components.pluginRegistry'
36+
echo
37+
echo "Patch file:"
38+
cat "${TMPDIR}"/patch-file.yaml
39+
echo
40+
kubectl patch -n "${CHECLUSTER_NAMESPACE}" checluster "${CHECLUSTER_NAME}" --type merge --patch "$(cat "${TMPDIR}"/patch-file.yaml)"
41+
echo
42+
echo "Patched CheCluster .spec.components.pluginRegistry:"
43+
kubectl get -n "${CHECLUSTER_NAMESPACE}" checluster "${CHECLUSTER_NAME}" -o json | jq '.spec.components.pluginRegistry'

0 commit comments

Comments
 (0)