From 2a6e6d0be666b50a8dee7bf2bbbdb712086e4fae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Pupier?= Date: Tue, 24 Oct 2023 10:16:33 +0200 Subject: [PATCH] FUSETOOLS2-2163 - Upgrade to Camel K 2.1.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 https://github.com/apache/camel-k/issues/4853#issuecomment-1777111613 Signed-off-by: Aurélien Pupier --- .github/workflows/insider.yml | 2 +- .github/workflows/main.yml | 2 +- CHANGELOG.md | 3 +- docs/content/integration.md | 3 - package.json | 7 +- src/IntegrationUtils.ts | 35 +---- src/task/CamelKRunTaskDefinition.ts | 2 - .../StartIntegrationWithResource.test.ts | 121 ------------------ src/test/suite/versionUtils.test.ts | 12 +- src/versionUtils.ts | 4 +- 10 files changed, 17 insertions(+), 174 deletions(-) delete mode 100644 src/test/suite/StartIntegrationWithResource.test.ts diff --git a/.github/workflows/insider.yml b/.github/workflows/insider.yml index eec0337a2..a377b49c8 100644 --- a/.github/workflows/insider.yml +++ b/.github/workflows/insider.yml @@ -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/ diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f6c81e85e..213283f32 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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/ diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c28def07..a52e4bd0f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/docs/content/integration.md b/docs/content/integration.md index 82c1e18df..a4697ffb7 100644 --- a/docs/content/integration.md +++ b/docs/content/integration.md @@ -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. diff --git a/package.json b/package.json index e8e3e1b65..9c7f11dbc 100644 --- a/package.json +++ b/package.json @@ -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": { @@ -288,11 +288,6 @@ "format": "=", "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." diff --git a/src/IntegrationUtils.ts b/src/IntegrationUtils.ts index b1991312f..1dff394c6 100644 --- a/src/IntegrationUtils.ts +++ b/src/IntegrationUtils.ts @@ -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; @@ -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; @@ -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) { @@ -270,17 +257,6 @@ function getSelectedSecret(): Promise { }); } -function getSelectedResources(): Promise { - return new Promise ( 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 { return new Promise ( async (resolve, reject) => { let hasMoreProperties = true; @@ -358,7 +334,7 @@ function getSelectedDependencies(): Promise { } // 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 { +export function createNewIntegration(integrationFileUri: vscode.Uri, devMode? : boolean, configmap? : string, secret? : string, propertyArray? : string[], dependencyArray? : string[]): Promise { return new Promise( async (resolve, reject) => { const filename = integrationFileUri.fsPath; const foldername = path.dirname(filename); @@ -372,7 +348,6 @@ export function createNewIntegration(integrationFileUri: vscode.Uri, devMode? : devMode, configmap, secret, - resourceArray, dependencyArray, propertyArray); if (devMode && devMode === true) { @@ -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, @@ -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}`); diff --git a/src/task/CamelKRunTaskDefinition.ts b/src/task/CamelKRunTaskDefinition.ts index 8715d91e7..53d040d74 100644 --- a/src/task/CamelKRunTaskDefinition.ts +++ b/src/task/CamelKRunTaskDefinition.ts @@ -32,7 +32,6 @@ export interface CamelKRunTaskDefinition extends vscode.TaskDefinition { file: string; profile?: string; properties?: Array; - resources?: Array; secret?: string; traits?: Array; volumes?: Array; @@ -73,7 +72,6 @@ export class CamelKRunTaskProvider implements vscode.TaskProvider { definition.dev, definition.configmap, definition.secret, - definition.resources, definition.dependencies, definition.properties, definition.traits, diff --git a/src/test/suite/StartIntegrationWithResource.test.ts b/src/test/suite/StartIntegrationWithResource.test.ts deleted file mode 100644 index 381110b28..000000000 --- a/src/test/suite/StartIntegrationWithResource.test.ts +++ /dev/null @@ -1,121 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License", destination); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -'use strict'; - -import * as extension from '../../extension'; -import * as sinon from 'sinon'; -import * as vscode from 'vscode'; -import * as config from '../../config'; -import * as IntegrationConstants from '../../IntegrationConstants'; -import { skipOnJenkins, openCamelKTreeView, skipIfNoCamelKInstance } from "./Utils"; -import { assert, expect } from 'chai'; -import * as shelljs from 'shelljs'; -import * as kamel from '../../kamel'; -import { getTelemetryServiceInstance } from '../../Telemetry'; -import { cleanDeployedIntegration, checkIntegrationDeployed, checkIntegrationRunning, openCamelFile } from './Utils/DeployTestUtil'; -import * as tmp from 'tmp'; - -export const RUNNING_TIMEOUT = 720000; -export const DEPLOYED_TIMEOUT = 10000; -export const UNDEPLOY_TIMEOUT = 20000; -export const PROVIDER_POPULATED_TIMEOUT = 20000; -export const EDITOR_OPENED_TIMEOUT = 5000; -const TOTAL_TIMEOUT: number = RUNNING_TIMEOUT + DEPLOYED_TIMEOUT + EDITOR_OPENED_TIMEOUT + UNDEPLOY_TIMEOUT + PROVIDER_POPULATED_TIMEOUT; - -suite('Check can deploy with resource', () => { - - let showQuickpickStub: sinon.SinonStub; - let showOpenDialogStub: sinon.SinonStub; - let telemetrySpy: sinon.SinonSpy; - - setup(async() => { - showQuickpickStub = sinon.stub(vscode.window, 'showQuickPick'); - showOpenDialogStub = sinon.stub(vscode.window, 'showOpenDialog'); - // Workaround due to bug in shelljs: https://github.com/shelljs/shelljs/issues/704 - const nodePath = shelljs.which('node'); - shelljs.config.execPath = nodePath ? nodePath.toString() : ''; - telemetrySpy = sinon.spy(await getTelemetryServiceInstance(), 'send'); - }); - - teardown(async () => { - showQuickpickStub.restore(); - showOpenDialogStub.restore(); - await cleanDeployedIntegration(telemetrySpy); - await config.addNamespaceToConfig(undefined); - await config.addOperatorIdToConfig(undefined); - telemetrySpy.restore(); - tmp.setGracefulCleanup(); - }); - - const testDeploymentWithResource = test('Check can deploy with a single resource', async() => { - skipOnJenkins(testDeploymentWithResource); - skipIfNoCamelKInstance(testDeploymentWithResource); - const resource = tmp.fileSync({ prefix: "simple" }); - await testDeployWithResources([resource], showQuickpickStub, showOpenDialogStub); - }).timeout(TOTAL_TIMEOUT); - - const testDeploymentWithResourceInPathWithSpace = test('Check can deploy with a single resource with space in path', async() => { - skipOnJenkins(testDeploymentWithResourceInPathWithSpace); - skipIfNoCamelKInstance(testDeploymentWithResourceInPathWithSpace); - const dir = tmp.dirSync({prefix: "with a space"}).name; - const resource = tmp.fileSync({ dir: dir, prefix: "simpleWithParentFolderHavingSpace" }); - expect(resource.name).includes(' '); - await testDeployWithResources([resource], showQuickpickStub, showOpenDialogStub); - }).timeout(TOTAL_TIMEOUT); - - const testDeploymentWithSeveralResources = test('Check can deploy with several resources', async() => { - skipOnJenkins(testDeploymentWithSeveralResources); - skipIfNoCamelKInstance(testDeploymentWithSeveralResources); - const resource1 = tmp.fileSync({ prefix: "simple1" }); - const resource2 = tmp.fileSync({ prefix: "simple2" }); - await testDeployWithResources([resource1, resource2], showQuickpickStub, showOpenDialogStub); - }).timeout(TOTAL_TIMEOUT); - -}); - -async function testDeployWithResources(resources: tmp.FileResult[], showQuickpickStub: sinon.SinonStub, showOpenDialogStub: sinon.SinonStub) { - const uriOfResources = resources.map(resource => {return vscode.Uri.file(resource.name);}); - const createdFile: vscode.Uri | undefined = await openCamelFile('TestJavaDeployWithResources.java'); - - await openCamelKTreeView(); - assert.isEmpty(extension.camelKIntegrationsProvider.getTreeNodes()); - showQuickpickStub.reset(); - showQuickpickStub.onFirstCall().returns(IntegrationConstants.resourceIntegration); - showOpenDialogStub.onFirstCall().returns(uriOfResources); - - await vscode.commands.executeCommand('camelk.startintegration'); - - await checkIntegrationDeployed(1); - await checkIntegrationRunning(0); - - const filenames = uriOfResources.map(uriOfResource => uriOfResource.fsPath.substring(uriOfResource.fsPath.lastIndexOf('/') + 1)); - await checkResourcesAvailableForDeployedIntegration(filenames); - return createdFile; -} - -async function checkResourcesAvailableForDeployedIntegration(fileNames: string[]) { - const describeShell = shelljs.exec(`"${await kamel.create().getPath()}" describe integration test-java-deploy-with-resources`); - const description: string = describeShell.stdout; - console.log('Description for deployment with resources: ' + description); - const lineReturnAndSpaces = /\r?\n|\r|\s/g; - const descWithoutLineReturnAndSpaces = description.replace(lineReturnAndSpaces, ''); - const configuration = descWithoutLineReturnAndSpaces.substring(descWithoutLineReturnAndSpaces.indexOf('Traits:Mount:Configuration:') + 'Traits:Mount:Configuration:'.length); - console.log(`configuration to check: ${configuration}`); - for (const fileName of fileNames) { - expect(configuration).contains(fileName); - } -} diff --git a/src/test/suite/versionUtils.test.ts b/src/test/suite/versionUtils.test.ts index 6f6b4c4fb..62166d934 100644 --- a/src/test/suite/versionUtils.test.ts +++ b/src/test/suite/versionUtils.test.ts @@ -98,12 +98,16 @@ suite("VersionUtils check", () => { 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'); }); - 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 () => { diff --git a/src/versionUtils.ts b/src/versionUtils.ts index 928cac4cc..bd0bff327 100644 --- a/src/versionUtils.ts +++ b/src/versionUtils.ts @@ -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 {