Skip to content
This repository has been archived by the owner on Nov 12, 2024. It is now read-only.

Commit

Permalink
FUSETOOLS2-2163 - adapt to new format of kamel binary name scheme in 2.x
Browse files Browse the repository at this point in the history
Signed-off-by: Aurélien Pupier <[email protected]>
  • Loading branch information
apupier committed Aug 8, 2023
1 parent fc43d7f commit ec8825c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/test/suite/versionUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,15 @@ suite("VersionUtils check", () => {
});

test("validate url for existing 2.0.0 version", async () => {
await validateVersion('2.0.0', Platform.LINUX, 'https://github.com/apache/camel-k/releases/download/v2.0.0/camel-k-client-2.0.0-linux-64bit.tar.gz');
await validateVersion('2.0.0', Platform.LINUX, 'https://github.com/apache/camel-k/releases/download/v2.0.0/camel-k-client-2.0.0-linux-amd64.tar.gz');
});

test("validate url for existing 2.0.0 windows version", async () => {
await validateVersion('2.0.0', Platform.WINDOWS, 'https://github.com/apache/camel-k/releases/download/v2.0.0/camel-k-client-2.0.0-windows-64bit.tar.gz');
await validateVersion('2.0.0', Platform.WINDOWS, 'https://github.com/apache/camel-k/releases/download/v2.0.0/camel-k-client-2.0.0-windows-amd64.tar.gz');
});

test("validate url for existing 2.0.0 MacOS version", async () => {
await validateVersion('2.0.0', Platform.MACOS, 'https://github.com/apache/camel-k/releases/download/v2.0.0/camel-k-client-2.0.0-mac-64bit.tar.gz');
await validateVersion('2.0.0', Platform.MACOS, 'https://github.com/apache/camel-k/releases/download/v2.0.0/camel-k-client-2.0.0-darwin-amd64.tar.gz');
});

test("validate invalid url for xyz1 version", async () => {
Expand Down
22 changes: 19 additions & 3 deletions src/versionUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ function setVersionAndTellUser(msg: string, newVersion: string) {
extension.setRuntimeVersionSetting(newVersion);
}

function toKamelOsString(platform: Platform | undefined): string | undefined {
function toKamel1xOsString(platform: Platform | undefined): string | undefined {
switch (platform) {
case Platform.WINDOWS:
return 'windows';
Expand All @@ -215,8 +215,21 @@ function toKamelOsString(platform: Platform | undefined): string | undefined {
return undefined;
}

function toKamel2xOsString(platform: Platform | undefined): string | undefined {
switch (platform) {
case Platform.WINDOWS:
return 'windows';
case Platform.LINUX:
return 'linux';
case Platform.MACOS:
return 'darwin';
}
return undefined;
}

export async function getDownloadURLForCamelKTag(camelKVersion: string, platform: Platform): Promise<string> {
const platformStr = toKamelOsString(platform);
const platformStr1x = toKamel1xOsString(platform);
const platformStr2x = toKamel2xOsString(platform);
const tagName: string = isOldTagNaming(camelKVersion) ? camelKVersion : `v${camelKVersion}`;
const tagURL = `https://api.github.com/repos/apache/camel-k/releases/tags/${tagName}`;
const headers: [string, string][] = [];
Expand All @@ -230,7 +243,10 @@ export async function getDownloadURLForCamelKTag(camelKVersion: string, platform
const assetsJSON: any = await latestJSON.assets;
for (const asset of assetsJSON) {
const aUrl: string = asset.browser_download_url;
if (aUrl.includes(`-${platformStr}-`)) {
if (aUrl.includes('camel-k-client-1') && aUrl.includes(`-${platformStr1x}-`)) {
return aUrl;
}
if (aUrl.includes('camel-k-client-2') && aUrl.includes('amd64') && aUrl.includes(`-${platformStr2x}-`)) {
return aUrl;
}
}
Expand Down

0 comments on commit ec8825c

Please sign in to comment.