Skip to content

Commit

Permalink
Use latest openvsx-server image; use versions instead of allVersions (#…
Browse files Browse the repository at this point in the history
…1776)

* chore:use latest openvsx-server image; use versions instead of allVersions

Signed-off-by: Valeriy Svydenko <[email protected]>

* use one method to get info from openVSX

Signed-off-by: Valeriy Svydenko <[email protected]>

---------

Signed-off-by: Valeriy Svydenko <[email protected]>
  • Loading branch information
svor committed Sep 12, 2023
1 parent 9dc3774 commit c2fe802
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 24 deletions.
2 changes: 1 addition & 1 deletion build/dockerfiles/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#

# OpenVSX
FROM ghcr.io/eclipse/openvsx-server:8fbf749 AS openvsx-server
FROM ghcr.io/eclipse/openvsx-server:d7fba39 AS openvsx-server

# UBI Builder
# https://registry.access.redhat.com/ubi8/ubi
Expand Down
33 changes: 23 additions & 10 deletions build/dockerfiles/import-vsix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,32 @@ export OVSX_PAT=eclipse_che_token

containsElement () { for e in "${@:2}"; do [[ "$e" = "$1" ]] && return 0; done; return 1; }

vsixMetadata="" #now global so it can be set/checked via function
getMetadata(){
function getOpenVSXData(){
vsixName=$1
key=$2
parameters=$3

# build the request url
if [[ -n "$parameters" ]]; then
url="https://open-vsx.org/api/${vsixName}/${key}?${parameters}"
else
url="https://open-vsx.org/api/${vsixName}/${key}"
fi

# check there is no error field in the metadata and retry if there is
for j in 1 2 3 4 5
do
vsixMetadata=$(curl -sLS "https://open-vsx.org/api/${vsixName}/${key}")
if [[ $(echo "${vsixMetadata}" | jq -r ".error") != null ]]; then
echo "Attempt $j/5: Error while getting metadata for ${vsixName} version ${key}"
result=$(curl -sLS "${url}")
if [[ $(echo "${result}" | jq -r ".error") != null ]]; then
echo "Attempt $j/5: Error while getting metadata for ${vsixFullName} version ${key}"

if [[ $j -eq 5 ]]; then
echo "[ERROR] Maximum of 5 attempts reached - must exit!"
echo "[ERROR] Maximum of 5 attempts reached - must exit with failure!"
exit 1
fi
continue
else
echo "$result"
break
fi
done
Expand Down Expand Up @@ -90,17 +98,22 @@ for i in $(seq 0 "$((numberOfExtensions - 1))"); do
# grab metadata for the vsix file
# if version wasn't set, use latest
if [[ $vsixVersion == null ]]; then
getMetadata "${vsixName}" "latest"
vsixMetadata=$(getOpenVSXData "${vsixName}" "latest")
versionsPage=$(getOpenVSXData "${vsixName}" "versions" "size=200")
# if version wasn't set in json, grab it from metadata and add it into the file
# get all versions of the extension
allVersions=$(echo "${vsixMetadata}" | jq -r '.allVersions')
allVersions=$(echo "${versionsPage}" | jq -r '.versions')
if [[ "$allVersions" == "{}" ]]; then
echo "No versions found for ${vsixName}"
exit 1
fi
key_value_pairs=$(echo "$allVersions" | jq -r 'to_entries[] | [ .key, .value ] | @tsv')

# go through all versions of the extension to find the latest stable version that is compatible with the VS Code version
resultedVersion=null
while IFS=$'\t' read -r key value; do
# get metadata for the version
getMetadata "${vsixName}" "${key}"
vsixMetadata=$(getOpenVSXData "${vsixName}" "${key}")

# check if the version is pre-release
preRelease=$(echo "${vsixMetadata}" | jq -r '.preRelease')
Expand Down Expand Up @@ -136,7 +149,7 @@ for i in $(seq 0 "$((numberOfExtensions - 1))"); do
vsixVersion=$resultedVersion
fi
else
getMetadata "${vsixName}" "${vsixVersion}"
vsixMetadata=$(getOpenVSXData "${vsixName}" "${vsixVersion}")
fi

# extract the download link from the json metadata
Expand Down
26 changes: 13 additions & 13 deletions openvsx-sync.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
"id": "vscode.github-authentication"
},
{
"id": "github.vscode-pull-request-github"
"id": "GitHub.vscode-pull-request-github"
},
{
"id": "vscode.typescript-language-features"
},
{
"id": "bazelbuild.vscode-bazel"
"id": "BazelBuild.vscode-bazel"
},
{
"id": "octref.vetur"
Expand Down Expand Up @@ -42,13 +42,13 @@
"id": "eamodio.gitlens"
},
{
"id": "golang.go"
"id": "golang.Go"
},
{
"id": "dart-code.dart-code"
"id": "Dart-Code.dart-code"
},
{
"id": "dart-code.flutter"
"id": "Dart-Code.flutter"
},
{
"id": "redhat.vscode-yaml"
Expand Down Expand Up @@ -123,7 +123,7 @@
"id": "scalameta.metals"
},
{
"id": "sonarsource.sonarlint-vscode"
"id": "SonarSource.sonarlint-vscode"
},
{
"id": "vscode.git-base"
Expand All @@ -135,19 +135,19 @@
"id": "atlassian.atlascode"
},
{
"id": "broadcommfd.cobol-language-support"
"id": "BroadcomMFD.cobol-language-support"
},
{
"id": "broadcommfd.debugger-for-mainframe"
"id": "BroadcomMFD.debugger-for-mainframe"
},
{
"id": "broadcommfd.hlasm-language-support"
"id": "BroadcomMFD.hlasm-language-support"
},
{
"id": "zowe.vscode-extension-for-zowe"
"id": "Zowe.vscode-extension-for-zowe"
},
{
"id": "broadcommfd.explorer-for-endevor"
"id": "BroadcomMFD.explorer-for-endevor"
},
{
"id": "zxh404.vscode-proto3"
Expand Down Expand Up @@ -183,13 +183,13 @@
"id": "redhat.vscode-commons"
},
{
"id": "broadcommfd.ccf"
"id": "BroadcomMFD.ccf"
},
{
"id": "4ops.terraform"
},
{
"id": "randomchance.logstash"
"id": "RandomChance.logstash"
},
{
"id": "fbaligand.vscode-logstash-editor"
Expand Down

0 comments on commit c2fe802

Please sign in to comment.