forked from eclipse/openvsx
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.devfile.yaml
More file actions
306 lines (290 loc) · 13.4 KB
/
.devfile.yaml
File metadata and controls
306 lines (290 loc) · 13.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
schemaVersion: 2.3.0
metadata:
name: openvsx
components:
- name: tool
container:
image: quay.io/devfile/universal-developer-image:ubi9-latest
memoryRequest: 256Mi
memoryLimit: 8Gi
cpuRequest: 100m
cpuLimit: 2000m
env:
- name: OPENVSX_NAMESPACE
value: openvsx
volumeMounts:
- name: local
path: /home/user/.local/
- name: elasticsearch
container:
image: docker.elastic.co/elasticsearch/elasticsearch:8.7.1
memoryRequest: 256Mi
memoryLimit: 2Gi
cpuRequest: 100m
cpuLimit: 800m
endpoints:
- exposure: internal
name: elasticsearch
protocol: tcp
targetPort: 9200
- exposure: internal
name: es9300
protocol: tcp
targetPort: 9300
- exposure: public
name: che-server
targetPort: 8080
- exposure: public
name: che-webui
targetPort: 3000
env:
- name: bootstrap.memory_lock
value: 'true'
- name: cluster.routing.allocation.disk.threshold_enabled
value: 'false'
- name: discovery.type
value: single-node
- name: xpack.ml.enabled
value: 'false'
- name: xpack.security.enabled
value: 'false'
- name: postgresql
container:
image: 'image-registry.openshift-image-registry.svc:5000/openshift/postgresql:15-el8'
memoryRequest: 256Mi
memoryLimit: 2Gi
cpuRequest: 100m
cpuLimit: '1'
env:
- name: POSTGRESQL_USER
value: openvsx
- name: POSTGRESQL_PASSWORD
value: openvsx
- name: POSTGRESQL_DATABASE
value: openvsx
- volume:
ephemeral: true
name: local
commands:
- id: build-cli
exec:
label: "1.1. Build OVSX CLI"
component: tool
workingDir: ${PROJECTS_ROOT}/openvsx/cli
commandLine: |
yarn install &&
yarn prepare
- id: build-webui
exec:
label: "1.2. Build UI Component"
component: tool
workingDir: ${PROJECTS_ROOT}/openvsx/webui
commandLine: |
yarn install &&
yarn build &&
yarn build:default
- id: build-server
exec:
label: "1.3. Build Server Component"
component: tool
workingDir: ${PROJECTS_ROOT}/openvsx
commandLine: |
server/gradlew -p server assemble downloadTestExtensions
- id: run-server
exec:
label: "1.4. Run OpenVSX Server"
component: tool
workingDir: ${PROJECTS_ROOT}/openvsx/server
commandLine: |
./scripts/generate-properties.sh &&
sed -i 's/localhost:5432\/postgres/localhost:5432\/openvsx/g' src/dev/resources/application.yml &&
sed -i 's/username: gitpod/username: openvsx/g' src/dev/resources/application.yml &&
sed -i 's/password: gitpod/password: openvsx/g' src/dev/resources/application.yml &&
./gradlew runServer
- id: run-webui
exec:
label: "1.5. Run OpenVSX WebUI"
component: tool
workingDir: ${PROJECTS_ROOT}/openvsx/webui
commandLine: |
yarn start:default
- id: cli-publish
exec:
label: "1.6. Publish extensions by OVSX CLI"
component: tool
workingDir: ${PROJECTS_ROOT}/openvsx
commandLine: |
nvm use v${NODEJS_20_VERSION}
export OVSX_REGISTRY_URL=http://localhost:8080
export OVSX_PAT=super_token
export PUBLISHERS="DotJoshJohnson eamodio felixfbecker formulahendry HookyQR ms-azuretools ms-mssql ms-python ms-vscode octref redhat ritwickdey sburg vscode vscodevim Wscats"
for pub in $PUBLISHERS; do cli/lib/ovsx create-namespace $pub; done
find server/build/test-extensions-builtin -name '*.vsix' -exec cli/lib/ovsx publish '{}' \;
find server/build/test-extensions -name '*.vsix' -exec cli/lib/ovsx publish '{}' \;
# Commands to deploy OpenVSX to OpenShift
- id: create-namespace
exec:
label: "2.1. Create Namespace for OpenVSX"
component: tool
commandLine: |
oc new-project $OPENVSX_NAMESPACE
- id: build-openvsx-image
exec:
label: "2.2. Build and Publish OpenVSX Image"
component: tool
workingDir: ${PROJECTS_ROOT}/openvsx/deploy/openshift
commandLine: |
read -p "Please enter the value for OPENVSX_VERSION (default: v0.27.0): " OPENVSX_VERSION
OPENVSX_VERSION=${OPENVSX_VERSION:-v0.27.0}
export OPENVSX_VERSION
echo "OPENVSX_VERSION is set to $OPENVSX_VERSION"
podman build -t "openvsx:$OPENVSX_VERSION" --build-arg "OPENVSX_VERSION=$OPENVSX_VERSION" -f openvsx.Dockerfile .&&
export IMAGE=image-registry.openshift-image-registry.svc:5000/$OPENVSX_NAMESPACE/openvsx &&
podman tag openvsx:$OPENVSX_VERSION ${IMAGE} &&
podman login --tls-verify=false -u $(oc whoami | tr -d :) -p $(oc whoami -t) image-registry.openshift-image-registry.svc:5000 &&
podman push --tls-verify=false "${IMAGE}"
- id: build-ovsx-cli-image
exec:
label: "2.3. Build and Publish OpenVSX CLI Image"
component: tool
workingDir: ${PROJECTS_ROOT}/openvsx/deploy/openshift
commandLine: |
read -p "Please enter the value for OVSX_VERSION (default: 0.10.5): " OVSX_VERSION
OVSX_VERSION=${OVSX_VERSION:-0.10.5}
export OVSX_VERSION
echo "OVSX_VERSION is set to $OVSX_VERSION"
podman build -t "openvsx-cli:$OVSX_VERSION" --build-arg "OVSX_VERSION=$OVSX_VERSION" -f cli.Dockerfile .&&
export IMAGE=image-registry.openshift-image-registry.svc:5000/$OPENVSX_NAMESPACE/openvsx-cli &&
podman tag openvsx-cli:$OVSX_VERSION ${IMAGE} &&
podman login --tls-verify=false -u $(oc whoami | tr -d :) -p $(oc whoami -t) image-registry.openshift-image-registry.svc:5000 &&
podman push --tls-verify=false "${IMAGE}"
- id: deploy-openvsx
exec:
label: "2.4. Deploy OpenVSX"
component: tool
workingDir: ${PROJECTS_ROOT}/openvsx/deploy/openshift
commandLine: |
oc process -f openvsx-deployment.yml \
-p OPENVSX_SERVER_IMAGE=image-registry.openshift-image-registry.svc:5000/$OPENVSX_NAMESPACE/openvsx \
-p OPENVSX_CLI_IMAGE=image-registry.openshift-image-registry.svc:5000/$OPENVSX_NAMESPACE/openvsx-cli \
| oc apply -f -
- id: deploy-custom-openvsx
exec:
label: "2.4.1. Deploy Custom OpenVSX"
component: tool
workingDir: ${PROJECTS_ROOT}/openvsx/deploy/openshift
commandLine: |
read -p "Please enter OpenVSX image: " OPENVSX_SERVER_IMAGE
OPENVSX_SERVER_IMAGE=${OPENVSX_SERVER_IMAGE}
export OPENVSX_SERVER_IMAGE
echo "OPENVSX_SERVER_IMAGE is set to $OPENVSX_SERVER_IMAGE"
oc process -f openvsx-deployment-no-es.yml \
-p OPENVSX_SERVER_IMAGE="${OPENVSX_SERVER_IMAGE}" \
| oc apply -f -
- id: add-openvsx-user-with-pat
exec:
label: "2.5. Add OpenVSX user with PAT to the DB"
component: tool
commandLine: |
# Prompt for OpenVSX user name
read -p "Please enter OpenVSX user name (default: eclipse-che): " OPENVSX_USER_NAME
OPENVSX_USER_NAME=${OPENVSX_USER_NAME:-eclipse-che}
export OPENVSX_USER_NAME
echo "OPENVSX_USER_NAME is set to: $OPENVSX_USER_NAME"
# Prompt for OpenVSX PAT
read -p "Please enter the value for OpenVSX user PAT (default: eclipse_che_token): " OPENVSX_USER_PAT
OPENVSX_USER_PAT=${OPENVSX_USER_PAT:-eclipse_che_token}
export OPENVSX_USER_PAT
echo "OPENVSX_USER_PAT is set to: $OPENVSX_USER_PAT"
# Find PostgreSQL pod
export POSTGRESQL_POD_NAME=$(kubectl get pods -n "$OPENVSX_NAMESPACE" \
-o jsonpath="{.items[*].metadata.name}" | tr ' ' '\n' | grep '^postgresql' | head -n 1)
if [ -z "$POSTGRESQL_POD_NAME" ]; then
echo "❌ Could not find a pod matching 'postgresql' in namespace $OPENVSX_NAMESPACE"
exit 1
fi
echo "Found PostgreSQL pod: $POSTGRESQL_POD_NAME"
# Wait until the pod is Running and Ready
echo "⏳ Waiting for PostgreSQL pod to be running..."
while true; do
STATUS=$(kubectl get pod -n "$OPENVSX_NAMESPACE" "$POSTGRESQL_POD_NAME" -o jsonpath="{.status.phase}")
READY=$(kubectl get pod -n "$OPENVSX_NAMESPACE" "$POSTGRESQL_POD_NAME" -o jsonpath="{.status.containerStatuses[0].ready}")
if [[ "$STATUS" == "Running" && "$READY" == "true" ]]; then
echo "✅ PostgreSQL pod is running and ready."
break
fi
sleep 5
done
sleep 10 # Wait for the database to be ready
# Execute SQL inserts
echo "⚙️ Inserting user and PAT into OpenVSX database..."
kubectl exec -n "$OPENVSX_NAMESPACE" "$POSTGRESQL_POD_NAME" -- bash -c \
"psql -d openvsx -c \"INSERT INTO user_data (id, login_name, role) VALUES (1001, '$OPENVSX_USER_NAME', 'privileged');\""
kubectl exec -n "$OPENVSX_NAMESPACE" "$POSTGRESQL_POD_NAME" -- bash -c \
"psql -d openvsx -c \"INSERT INTO personal_access_token (id, user_data, value, active, created_timestamp, accessed_timestamp, description) VALUES (1001, 1001, '$OPENVSX_USER_PAT', true, current_timestamp, current_timestamp, 'extensions publisher');\""
echo "✅ OpenVSX user and token inserted successfully."
- id: enable-internal-openvsx
exec:
label: "2.6. Configure Che to use the internal OpenVSX registry"
component: tool
workingDir: ${PROJECTS_ROOT}/openvsx/deploy/openshift
commandLine: |
export CHECLUSTER_NAME="$(kubectl get checluster --all-namespaces -o json | jq -r '.items[0].metadata.name')" &&
export CHECLUSTER_NAMESPACE="$(kubectl get checluster --all-namespaces -o json | jq -r '.items[0].metadata.namespace')" &&
export OPENVSX_ROUTE_URL="$(oc get route internal -n "$OPENVSX_NAMESPACE" -o jsonpath='{.spec.host}')" &&
export PATCH='{"spec":{"components":{"pluginRegistry":{"openVSXURL":"https://'"$OPENVSX_ROUTE_URL"'"}}}}' &&
kubectl patch checluster "${CHECLUSTER_NAME}" --type=merge --patch "${PATCH}" -n "${CHECLUSTER_NAMESPACE}"
- id: publish-extension-url
exec:
label: "2.7. Publish a VS Code Extension from a URL"
component: tool
commandLine: |
read -p "Please enter extension's namespace name: " EXTENSION_NAMESPACE_NAME
EXTENSION_NAMESPACE_NAME=${EXTENSION_NAMESPACE_NAME}
export EXTENSION_NAMESPACE_NAME
echo "EXTENSION_NAMESPACE_NAME is set to $EXTENSION_NAMESPACE_NAME"
read -p "Please enter extension's download URL: " EXTENSION_DOWNLOAD_URL
EXTENSION_DOWNLOAD_URL=${EXTENSION_DOWNLOAD_URL}
export EXTENSION_DOWNLOAD_URL
echo "EXTENSION_DOWNLOAD_URL is set to $EXTENSION_DOWNLOAD_URL"
OVSX_POD_NAME=$(kubectl get pods -n "$OPENVSX_NAMESPACE" -o jsonpath="{.items[*].metadata.name}" \
| tr ' ' '\n' | grep '^ovsx-cli' || true)
if [ -z "$OVSX_POD_NAME" ]; then
OVSX_POD_NAME=$(kubectl get pods -n "$OPENVSX_NAMESPACE" -o jsonpath="{.items[*].metadata.name}" \
| tr ' ' '\n' | grep '^openvsx-server' || true)
fi
kubectl exec -n "${OPENVSX_NAMESPACE}" "${OVSX_POD_NAME}" -- bash -c "wget -O /tmp/extension.vsix '$EXTENSION_DOWNLOAD_URL' " &&
kubectl exec -n "${OPENVSX_NAMESPACE}" "${OVSX_POD_NAME}" -- bash -c "ovsx create-namespace '$EXTENSION_NAMESPACE_NAME'" || true &&
kubectl exec -n "${OPENVSX_NAMESPACE}" "${OVSX_POD_NAME}" -- bash -c "ovsx publish /tmp/extension.vsix" &&
kubectl exec -n "${OPENVSX_NAMESPACE}" "${OVSX_POD_NAME}" -- bash -c "rm /tmp/extension.vsix"
- id: publish-extension-file
exec:
label: "2.8. Publish a VS Code Extension from a VSIX file"
component: tool
commandLine: |
read -p "Please enter extension's namespace name: " EXTENSION_NAMESPACE_NAME
EXTENSION_NAMESPACE_NAME=${EXTENSION_NAMESPACE_NAME}
export EXTENSION_NAMESPACE_NAME
echo "EXTENSION_NAMESPACE_NAME is set to $EXTENSION_NAMESPACE_NAME"
read -p "Please enter extension's vsix path: " EXTENSION_PATH
EXTENSION_PATH=${EXTENSION_PATH}
export EXTENSION_PATH
echo "EXTENSION_PATH is set to $EXTENSION_PATH"
EXTENSION_NAME=$(basename "$EXTENSION_PATH")
export EXTENSION_NAME
OVSX_POD_NAME=$(kubectl get pods -n "$OPENVSX_NAMESPACE" -o jsonpath="{.items[*].metadata.name}" \
| tr ' ' '\n' | grep '^ovsx-cli' || true)
if [ -z "$OVSX_POD_NAME" ]; then
OVSX_POD_NAME=$(kubectl get pods -n "$OPENVSX_NAMESPACE" -o jsonpath="{.items[*].metadata.name}" \
| tr ' ' '\n' | grep '^openvsx-server' || true)
fi
kubectl cp "${EXTENSION_PATH}" "${OPENVSX_NAMESPACE}/${OVSX_POD_NAME}:/tmp/${EXTENSION_NAME}" &&
kubectl exec -n "${OPENVSX_NAMESPACE}" "${OVSX_POD_NAME}" -- bash -c "ovsx create-namespace '$EXTENSION_NAMESPACE_NAME'" || true &&
kubectl exec -n "${OPENVSX_NAMESPACE}" "${OVSX_POD_NAME}" -- bash -c "ovsx publish /tmp/${EXTENSION_NAME}" &&
kubectl exec -n "${OPENVSX_NAMESPACE}" "${OVSX_POD_NAME}" -- bash -c "rm /tmp/${EXTENSION_NAME}"
- id: publish-extensions
exec:
label: "2.9. Publish list of VS Code Extensions"
component: tool
workingDir: ${PROJECTS_ROOT}/openvsx/deploy/openshift
commandLine: ./scripts/publish_extensions.sh