Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ jobs:
- name: Coverage
run: |
set +e
xvfb-run --auto-servernum npm run ui-coverage
xvfb-run --auto-servernum npm run ui-test:coverage
exit 0
- name: Upload Coverage Results
uses: actions/upload-artifact@v4
if: always()
with:
name: ui-coverage
name: ui-test-coverage
path: ${{ github.workspace }}/coverage
96 changes: 96 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Deploy to Kubernetes CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true

jobs:
deploy:
env:
CODE_VERSION: max
TEST_RESOURCES: test-resources

runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: "temurin"

- name: Install JBang
run: |
curl -Ls https://sh.jbang.dev | bash -s - app setup
echo "$HOME/.jbang/bin" >> $GITHUB_PATH
- name: Setup JBang (trusted sources)
run: jbang trust add https://github.com/apache/

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm

- name: Start Minikube
uses: medyagh/setup-minikube@latest
with:
driver: docker
addons: registry

- name: Cluster info
run: |
kubectl cluster-info
kubectl get pods -n kube-system
echo "current-context:" $(kubectl config current-context)
echo "environment-kubeconfig:" ${KUBECONFIG}

- name: Install
run: npm ci

- name: Compile
run: npm run compile

- name: UI Tests
run: |
eval $(minikube -p minikube docker-env)
xvfb-run --auto-servernum npm run ui-test:deploy

- name: Upload Coverage Results
uses: actions/upload-artifact@v4
if: always()
with:
name: ui-test-screenshots
path: test-resources/screenshots/*.png

check:
if: always()
runs-on: ubuntu-latest
name: Status Check
needs: [ deploy ]
steps:
- name: Test Matrix Result
run: |
echo result = ${{ needs.deploy.result }}
- name: Status Check - success
if: ${{ needs.deploy.result == 'success' }}
run: |
echo "All tests successfully completed!"
exit 0
- name: Status Check - failure
if: ${{ needs.deploy.result != 'success' }}
run: |
echo "Status Check failed!"
exit 1
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ node_modules
*.vsix
jars/camel-dap-server.jar
test-resources
.camel-jbang
.camel-jbang*
.test-extensions
*sbom.json
coverage
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ All notable changes to the "vscode-debug-adapter-apache-camel" extension will be
## 1.4.0

- Update default Camel version used for Camel JBang from 4.7.0 to 4.8.1
- Provide command for a deployment of Camel standalone file using Camel JBang Kubernetes plugin. It is available for Camel JBang version 4.8+.

## 1.3.0

Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ This is the <a href="https://code.visualstudio.com/">Visual Studio Code</a> exte
- Supports adding extra parameters provided by the `Run with JBang *` commands. (For both running and debugging the application)
- Configuration snippets for Camel debugger launch configuration
- Configuration snippets to launch Camel application ready to accept a Camel debugger connection using JBang, Maven with Camel maven plugin or Quarkus Devs
- Deploy Integration (standalone Camel file) with [Apache Camel Kubernetes](https://camel.apache.org/manual/camel-jbang-kubernetes.html) plugin.
- It allows **one-click deployment into OpenShift** by default
- requires Camel JBang 4.8+
- for deployment into Kubernetes cluster see [how to deploy into local Kubernetes cluster](./docs/content/kubernetes-deploy.md)

### Requirements

Expand Down Expand Up @@ -92,7 +96,7 @@ Something is not working properly? In that case, feel free to [open issues, add

### Get Involved

If you'd like to help us get better, we appriciate it! Check out our [Contribution Guide](Contributing.md) on how to do that.
If you'd like to help us get better, we appreciate it! Check out our [Contribution Guide](Contributing.md) on how to do that.

### Data and Telemetry

Expand Down
29 changes: 29 additions & 0 deletions docs/content/kubernetes-deploy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# How to deploy into local Kubernetes cluster

By default, the deployment aims OpenShift cluster. In case you need to deploy into Kubernetes, there is a small modification needed:

1) open Settings UI in VS Code
2) navigate to `Extensions > Debug Adapter for Apache Camel`
3) modify setting `Camel > Debug Adapter: Kubernetes Run Parameters` as you can see on picture below

![Deploy to Kubernetes cluster with Minikube](../images/kubernetes-run-params.png)

The picture describes how to deploy to local Kubernetes cluster using Minikube. You can use eg. also `Kind`. In that case, just change to `--cluster-type=kind`.

For more information see [Camel Kubernetes plugin official documentation](https://camel.apache.org/manual/camel-jbang-kubernetes.html).

## Follow logs

You can use Camel CLI to obtain logs of current running integration. In terminal window execute:

```shell
jbang camel@apache/camel kubernetes logs --name=<name>
```

## Undeploy

To remove current integration, you can use also Camel CLI. In this case the command is:

```shell
jbang camel@apache/camel kubernetes delete --name=<name>
```
Binary file added docs/images/kubernetes-run-params.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ This extension adds <a href="https://camel.apache.org/manual/debugger.html">Came
- JBang
- or Maven with Camel maven plugin
- or Quarkus Devs
- Deploy Integration (standalone Camel file) with [Apache Camel Kubernetes](https://camel.apache.org/manual/camel-jbang-kubernetes.html) plugin.
- It allows **one-click deployment into OpenShift** by default
- requires Camel JBang 4.8+
- for deployment into Kubernetes cluster see [how to deploy into local Kubernetes cluster](./content/kubernetes-deploy.md)

### Advanced

Expand Down
28 changes: 27 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,19 @@
"default": [
"--local-kamelet-dir=."
]
},
"camel.debugAdapter.KubernetesRunParameters": {
"type": "array",
"uniqueItems": true,
"items": {
"type": "string"
},
"additionalProperties": false,
"markdownDescription": "User defined parameters to be applied at every deploy (See [Camel JBang Kubernetes](https://camel.apache.org/manual/camel-jbang-kubernetes.html)). In case of spaces, the values needs to be enclosed with quotes. Default value is `[\"--cluster-type=openshift\", \"--dev\"]`\n\n**Note**: Excluding `--camel-version` which is already being set in `#camel.debugAdapter.CamelVersion#`.\n\nFor more possible values see: `camel kubernetes run --help` or `jbang camel@apache/camel kubernetes run --help`",
"default": [
"--cluster-type=openshift",
"--dev"
]
}
}
},
Expand Down Expand Up @@ -247,6 +260,11 @@
"title": "Run with JBang All Camel Integrations from containing folder",
"icon": "$(camel-run)",
"enablement": "resourceFilename =~ /\\.(java|xml|yaml)$/"
},
{
"command": "apache.camel.kubernetes.deploy",
"title": "Deploy Integration with Apache Camel Kubernetes Run",
"icon": "$(rocket)"
}
],
"menus": {
Expand Down Expand Up @@ -293,6 +311,13 @@
"when": "resourceFilename =~ /\\.(java|xml|yaml)$/",
"group": "3_camelrun@3"
}
],
"editor/title": [
{
"command": "apache.camel.kubernetes.deploy",
"when": "resourceFilename =~ /\\.(java|xml|yaml)$/",
"group": "navigation"
}
]
}
},
Expand All @@ -306,7 +331,8 @@
"lint": "eslint src",
"test": "node ./out/test/runTest.js",
"ui-test": "node ./out/ui-test/uitest_runner.js",
"ui-coverage": "npm run ui-test -- coverage"
"ui-test:deploy": "npm run ui-test -- deploy",
"ui-test:coverage": "npm run ui-test -- coverage"
},
"devDependencies": {
"@stylistic/eslint-plugin": "^2.9.0",
Expand Down
35 changes: 33 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { getRedHatService, TelemetryEvent, TelemetryService } from "@redhat-deve
import { CamelApplicationLauncherTasksCompletionItemProvider } from './completion/CamelApplicationLauncherTasksCompletionItemProvider';
import { CamelJBangTaskProvider } from './task/CamelJBangTaskProvider';
import { CamelJBangCodelens } from './codelenses/CamelJBangCodelens';
import { execSync } from 'child_process';

let telemetryService: TelemetryService;

Expand All @@ -30,6 +31,7 @@ export const CAMEL_RUN_AND_DEBUG_WITH_JBANG_ROOT_COMMAND_ID = 'apache.camel.debu
export const CAMEL_RUN_WITH_JBANG_ROOT_COMMAND_ID = 'apache.camel.run.jbang.all.root';
export const CAMEL_RUN_AND_DEBUG_WITH_JBANG_CONTAININGFOLDER_COMMAND_ID = 'apache.camel.debug.jbang.all.containingfolder';
export const CAMEL_RUN_WITH_JBANG_CONTAININGFOLDER_COMMAND_ID = 'apache.camel.run.jbang.all.containingfolder';
export const CAMEL_JBANG_KUBERNETES_DEPLOY_COMMAND_ID = 'apache.camel.kubernetes.deploy';
export const WORKSPACE_WARNING_MESSAGE = `The action requires an opened folder/workspace to complete successfully.`;

export async function activate(context: vscode.ExtensionContext) {
Expand All @@ -53,6 +55,19 @@ export async function activate(context: vscode.ExtensionContext) {
registerRunCommand(CAMEL_RUN_WITH_JBANG_ROOT_COMMAND_ID, CamelJBangTaskProvider.labelProvidedRunAllTask, taskProvider);
registerRunCommand(CAMEL_RUN_WITH_JBANG_CONTAININGFOLDER_COMMAND_ID, CamelJBangTaskProvider.labelProvidedRunAllFromContainingFolderTask, taskProvider);

vscode.commands.registerCommand(CAMEL_JBANG_KUBERNETES_DEPLOY_COMMAND_ID, async function () {
const camelAddKubernetesPluginTask = taskProvider.createTask(CamelJBangTaskProvider.labelAddKubernetesPluginTask);
if (camelAddKubernetesPluginTask && !(await isCamelPluginInstalled('kubernetes'))) {
await vscode.tasks.executeTask(camelAddKubernetesPluginTask);
await taskProvider.waitForTaskEnd(CamelJBangTaskProvider.labelAddKubernetesPluginTask);
}
const camelDeployTask = taskProvider.createTask(CamelJBangTaskProvider.labelProvidedDeployTask);
if (camelDeployTask) {
await vscode.tasks.executeTask(camelDeployTask);
await sendCommandTrackingEvent(telemetryService, CAMEL_JBANG_KUBERNETES_DEPLOY_COMMAND_ID);
}
});

vscode.debug.registerDebugAdapterTrackerFactory(CAMEL_DEBUG_ADAPTER_ID, {
createDebugAdapterTracker(_session: vscode.DebugSession) {
return {
Expand Down Expand Up @@ -80,7 +95,7 @@ export async function activate(context: vscode.ExtensionContext) {
vscode.languages.registerCodeLensProvider(docSelector, new CamelJBangCodelens());
}

function registerDebugCommand(commandId :string, taskLabel :string) {
function registerDebugCommand(commandId: string, taskLabel: string) {
vscode.commands.registerCommand(commandId, async (uri: vscode.Uri) => {
if (!vscode.workspace.workspaceFolders) {
await vscode.window.showWarningMessage(WORKSPACE_WARNING_MESSAGE);
Expand All @@ -100,7 +115,7 @@ function registerDebugCommand(commandId :string, taskLabel :string) {
});
}

function registerRunCommand(commandId :string, taskLabel :string, taskProvider :CamelJBangTaskProvider) {
function registerRunCommand(commandId: string, taskLabel: string, taskProvider: CamelJBangTaskProvider) {
vscode.commands.registerCommand(commandId, async function () {
if (!vscode.workspace.workspaceFolders) {
await vscode.window.showWarningMessage(WORKSPACE_WARNING_MESSAGE);
Expand Down Expand Up @@ -128,3 +143,19 @@ async function sendCommandTrackingEvent(telemetryService: TelemetryService, comm
};
await telemetryService.send(telemetryEvent);
}

async function isCamelPluginInstalled(plugin: string): Promise<boolean> {
let output = '';
// it takes always few seconds to compute after click on deploy button
// - can be confusing for user without any UI feedback, it looks like nothing is happening after click on a button..
await vscode.window.withProgress({
location: vscode.ProgressLocation.Window,
cancellable: false,
title: 'Checking Camel JBang Kubernetes plugin...'
}, async (progress) => {
progress.report({ increment: 0 });
output = execSync('jbang camel@apache/camel plugin get', { stdio: 'pipe' }).toString();
progress.report({ increment: 100 });
});
return output.includes(plugin);
}
Loading
Loading