-
Notifications
You must be signed in to change notification settings - Fork 153
/
.devfile.yaml
225 lines (212 loc) · 9.5 KB
/
.devfile.yaml
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
schemaVersion: 2.3.0
metadata:
name: openvsx
components:
- name: tool
container:
image: quay.io/devfile/universal-developer-image:ubi8-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: build-openvsx-image
exec:
label: "2.1. Build and Publish OpenVSX Image"
component: tool
workingDir: ${PROJECTS_ROOT}/openvsx/openshift
commandLine: |
read -p "Please enter the value for OPENVSX_VERSION (default: v0.18.0): " OPENVSX_VERSION
OPENVSX_VERSION=${OPENVSX_VERSION:-v0.18.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 .&&
oc new-project $OPENVSX_NAMESPACE
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.2. Build and Publish OpenVSX CLI Image"
component: tool
workingDir: ${PROJECTS_ROOT}/openvsx/openshift
commandLine: |
podman build -t "openvsx-cli" -f cli.Dockerfile .&&
export IMAGE=image-registry.openshift-image-registry.svc:5000/$OPENVSX_NAMESPACE/openvsx-cli &&
podman tag openvsx-cli ${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.3. Deploy OpenVSX"
component: tool
workingDir: ${PROJECTS_ROOT}/openvsx/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: add-openvsx-user-with-pat
exec:
label: "2.4. Add OpenVSX user with PAT to the DB"
component: tool
commandLine: |
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"
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"
export POSTGRESQL_POD_NAME=$(kubectl get pods -n "$OPENVSX_NAMESPACE" -o jsonpath="{.items[*].metadata.name}" | tr ' ' '\n' | grep ^postgresql) &&
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');\""
- id: enable-internal-openvsx
exec:
label: "2.5. Configure Che to use the internal OpenVSX registry"
component: tool
workingDir: ${PROJECTS_ROOT}/openvsx/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
exec:
label: "2.6. Publish VS Code Extension to the internal OpenVSX"
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"
export OVSX_POD_NAME=$(kubectl get pods -n "$OPENVSX_NAMESPACE" -o jsonpath="{.items[*].metadata.name}" | tr ' ' '\n' | grep ^ovsx-cli) &&
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-extensions
exec:
label: "2.7. Publish list of VS Code Extensions"
component: tool
workingDir: ${PROJECTS_ROOT}/openvsx/openshift
commandLine: ./scripts/publish_extensions.sh