Skip to content

Commit

Permalink
FUSETOOLS2-2163 - Upgrade to Camel K 2.1.0
Browse files Browse the repository at this point in the history
- remove command to deploy with a resource as it was provided only for
files and this feature has been deprecated in 2.0 and removed in 2.1
- the telemetry indicates that his feature was almost never used anyway
see apache/camel-k#4853 (comment)

Signed-off-by: Aurélien Pupier <apupier@redhat.com>
  • Loading branch information
apupier committed Nov 6, 2023
1 parent e4c5048 commit 12ea789
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 190 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/insider.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
- name: Configure Kamel (ubuntu)
if: matrix.os == 'ubuntu-latest'
run: |
curl -Lo kamel.tar.gz https://github.com/apache/camel-k/releases/download/v2.0.0/camel-k-client-2.0.0-linux-64bit.tar.gz
curl -Lo kamel.tar.gz https://github.com/apache/camel-k/releases/download/v2.1.0/camel-k-client-2.1.0-linux-amd64.tar.gz
tar -zxvf kamel.tar.gz
chmod +x kamel
sudo mv kamel /usr/local/bin/
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:
- name: Configure Kamel (ubuntu)
if: matrix.os == 'ubuntu-latest'
run: |
curl -Lo kamel.tar.gz https://github.com/apache/camel-k/releases/download/v2.0.0/camel-k-client-2.0.0-linux-64bit.tar.gz
curl -Lo kamel.tar.gz https://github.com/apache/camel-k/releases/download/v2.1.0/camel-k-client-2.1.0-linux-amd64.tar.gz
tar -zxvf kamel.tar.gz
chmod +x kamel
sudo mv kamel /usr/local/bin/
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ All notable changes to the "vscode-camelk" extension will be documented in this

- Requires jbang for java standalone completion. It allows also to get rid of internal dependency to `kamel local` which is removed from kamel 2.x.
- Fix Java standalone support on Windows
- Update default runtime version to v2.0.0
- Update default runtime version to v2.1.0
- Removal of `Start integration with resources` command as Camel K 2.1 is no more supporting it with files (which was the only implemented use case)

## 0.0.35

Expand Down
3 changes: 0 additions & 3 deletions docs/content/integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ You can start a new Camel K integration with or without additional options such
- **Secret - Apache Camel K Integration with Kubernetes Secret as Runtime Configuration**
Select a Secret from a list of the published Secrets in your current Kubernetes system. For more information about configuration with ConfigMaps or Secrets, see [Configuration via ConfigMap or Secret](https://camel.apache.org/camel-k/next/configuration/runtime-config.html) in the Apache Camel K documentation.

- **Resource - Apache Camel K Integration with Resource file**
Select one or more resource files from the file selection dialog.

- **Property - Apache Camel K Integration with Property**
Specify property name/property value pairs, with the option to specify more than one. For more information about configuration with properties, see [Configure Integrations](https://camel.apache.org/camel-k/latest/configuration/configuration.html) in the Apache Camel K documentation.

Expand Down
7 changes: 1 addition & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
},
"camelk.yaml.schema": {
"type": "string",
"default": "https://raw.githubusercontent.com/apache/camel/camel-3.20.1/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camel-yaml-dsl.json",
"default": "https://raw.githubusercontent.com/apache/camel/camel-4.0.0/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camel-yaml-dsl.json",
"description": "Yaml Schema applied when Camel K modeline is set. (I.e. file starting with '# camel-k: ')"
},
"redhat.telemetry.enabled": {
Expand Down Expand Up @@ -288,11 +288,6 @@
"format": "<akey>=<avalue>",
"uniqueItems": true
},
"resources": {
"type": "array",
"description": "List of additional resources.",
"uniqueItems": true
},
"secret": {
"type": "string",
"description": "Secret key. The secret corresponding to the key is added to the integration as runtime configuration."
Expand Down
35 changes: 2 additions & 33 deletions src/IntegrationUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ import { TelemetryEvent } from '@redhat-developer/vscode-redhat-telemetry/lib';
let selectedConfigMap : any = undefined;
let selectedSecret : any = undefined;
let devMode = false;
let selectedResource : any = undefined;
let errorEncountered = false;
let selectedProperty : any = undefined;
let selectedDependency : any = undefined;
Expand Down Expand Up @@ -135,18 +134,6 @@ import { TelemetryEvent } from '@redhat-developer/vscode-redhat-telemetry/lib';
errorEncountered = true;
});
break;
case constants.resourceIntegration:
await getSelectedResources().then( (selection) => {
selectedResource = selection;
if (selectedResource === undefined) {
reject (new Error('No Resource selected.'));
errorEncountered = true;
}
}).catch ( (error) => {
reject(error);
errorEncountered = true;
});
break;
case constants.propertyIntegration:
await getSelectedProperties().then ( (selection) => {
selectedProperty = selection;
Expand Down Expand Up @@ -187,7 +174,7 @@ import { TelemetryEvent } from '@redhat-developer/vscode-redhat-telemetry/lib';

if (!errorEncountered) {
try {
const isSuccess = await createNewIntegration(context, devMode, selectedConfigMap, selectedSecret, selectedResource, selectedProperty, selectedDependency);
const isSuccess = await createNewIntegration(context, devMode, selectedConfigMap, selectedSecret, selectedProperty, selectedDependency);
sendStartIntegrationTelemetryEvent(choice, context);
resolve(isSuccess);
} catch(err) {
Expand Down Expand Up @@ -270,17 +257,6 @@ function getSelectedSecret(): Promise<string | undefined> {
});
}

function getSelectedResources(): Promise<string[]> {
return new Promise<string[]> ( async (resolve, reject) => {
const fileUris = await vscode.window.showOpenDialog(ResourceOptions);
if (fileUris === undefined || fileUris.length === 0) {
reject(new Error('No Resource file(s) specified.'));
} else {
resolve(fileUris.map(fileUri => path.normalize(fileUri.path)));
}
});
}

function getSelectedProperties(): Promise<string[]> {
return new Promise<string[]> ( async (resolve, reject) => {
let hasMoreProperties = true;
Expand Down Expand Up @@ -358,7 +334,7 @@ function getSelectedDependencies(): Promise<string[]> {
}

// use command-line "kamel" utility to start a new integration
export function createNewIntegration(integrationFileUri: vscode.Uri, devMode? : boolean, configmap? : string, secret? : string, resourceArray? : string[], propertyArray? : string[], dependencyArray? : string[]): Promise<boolean> {
export function createNewIntegration(integrationFileUri: vscode.Uri, devMode? : boolean, configmap? : string, secret? : string, propertyArray? : string[], dependencyArray? : string[]): Promise<boolean> {
return new Promise( async (resolve, reject) => {
const filename = integrationFileUri.fsPath;
const foldername = path.dirname(filename);
Expand All @@ -372,7 +348,6 @@ export function createNewIntegration(integrationFileUri: vscode.Uri, devMode? :
devMode,
configmap,
secret,
resourceArray,
dependencyArray,
propertyArray);
if (devMode && devMode === true) {
Expand Down Expand Up @@ -407,7 +382,6 @@ export function computeKamelArgs(absoluteRoot: string,
devMode: boolean | undefined,
configmap: string | undefined,
secret: string | undefined,
resourceArray: string[] | undefined,
dependencyArray: string[] | undefined,
propertyArray: string[] | undefined,
traitsArray?: string[] | undefined,
Expand All @@ -433,11 +407,6 @@ export function computeKamelArgs(absoluteRoot: string,
if (profile && profile.trim().length > 0) {
kamelArgs.push(`--profile=${profile}`);
}
if (resourceArray && resourceArray.length > 0) {
resourceArray.forEach(resource => {
kamelArgs.push(`--resource=file:${resource}`);
});
}
if (dependencyArray && dependencyArray.length > 0) {
dependencyArray.forEach(dependency => {
kamelArgs.push(`--dependency=${dependency}`);
Expand Down
2 changes: 0 additions & 2 deletions src/task/CamelKRunTaskDefinition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export interface CamelKRunTaskDefinition extends vscode.TaskDefinition {
file: string;
profile?: string;
properties?: Array<string>;
resources?: Array<string>;
secret?: string;
traits?: Array<string>;
volumes?: Array<string>;
Expand Down Expand Up @@ -73,7 +72,6 @@ export class CamelKRunTaskProvider implements vscode.TaskProvider {
definition.dev,
definition.configmap,
definition.secret,
definition.resources,
definition.dependencies,
definition.properties,
definition.traits,
Expand Down
12 changes: 0 additions & 12 deletions src/test/suite/CamelKRunTaskDefinition.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,18 +112,6 @@ suite("Camel K Run Task definition", function() {
assert.include(execution.commandLine, '-p prop2=value2');
});

test("ensure include resources", async() => {
const def: CamelKRunTaskDefinition = {
"file" : "dummyFileValue.xml",
"resources": ["adummyresource1.txt", "adummyresource2.txt"],
"type": CamelKRunTaskProvider.START_CAMELK_TYPE
};
const task = await new CamelKRunTaskProvider().getRunTask(def);
const execution = task.execution as ShellExecution;
assert.include(execution.commandLine, '--resource=file:adummyresource1.txt');
assert.include(execution.commandLine, '--resource=file:adummyresource2.txt');
});

test("ensure include secret", async() => {
const def: CamelKRunTaskDefinition = {
"file" : "dummyFileValue.xml",
Expand Down
121 changes: 0 additions & 121 deletions src/test/suite/StartIntegrationWithResource.test.ts

This file was deleted.

14 changes: 9 additions & 5 deletions src/test/suite/versionUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,19 @@ 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');
test("validate url for existing 2.1.0 version", async () => {
await validateVersion('2.1.0', Platform.LINUX, 'https://github.com/apache/camel-k/releases/download/v2.1.0/camel-k-client-2.1.0-linux-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');
test("validate url for existing 2.1.0 windows version", async () => {
await validateVersion('2.1.0', Platform.WINDOWS, 'https://github.com/apache/camel-k/releases/download/v2.1.0/camel-k-client-2.1.0-windows-amd64.tar.gz');
});

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

test("validate invalid url for xyz1 version", async () => {
Expand Down
26 changes: 21 additions & 5 deletions src/versionUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ import { platform } from './installer';
import fetch from 'cross-fetch';
import { Platform } from './shell';

export const version = '2.0.0'; //need to retrieve this if possible, but have a default
export const version = '2.1.0'; //need to retrieve this if possible, but have a default

/*
* Can be retrieved using `curl -i https://api.github.com/repos/apache/camel-k/releases/latest | grep last-modified`
* To be updated when updating the default "version" attribute
*/
const LAST_MODIFIED_DATE_OF_DEFAULT_VERSION = 'Mon, 24 Jul 2023 07:56:50 GMT';
const LAST_MODIFIED_DATE_OF_DEFAULT_VERSION = 'Mon, 23 Oct 2023 08:52:28 GMT';
let latestVersionFromOnline: string;

export async function testVersionAvailable(versionToUse: string): Promise<boolean> {
Expand Down 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 12ea789

Please sign in to comment.