Skip to content

Commit 7a27cf6

Browse files
committed
FUSETOOLS2-2489: Migrate deployment of single file from Camel K to Debug adapter
Signed-off-by: Dominik Jelinek <[email protected]>
1 parent fb72493 commit 7a27cf6

File tree

15 files changed

+390
-19
lines changed

15 files changed

+390
-19
lines changed

.github/workflows/coverage.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ jobs:
5454
- name: Coverage
5555
run: |
5656
set +e
57-
xvfb-run --auto-servernum npm run ui-coverage
57+
xvfb-run --auto-servernum npm run ui-test:coverage
5858
exit 0
5959
- name: Upload Coverage Results
6060
uses: actions/upload-artifact@v4
6161
if: always()
6262
with:
63-
name: ui-coverage
63+
name: ui-test-coverage
6464
path: ${{ github.workspace }}/coverage

.github/workflows/deploy.yaml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: Deploy to Kubernetes CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
workflow_dispatch:
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
deploy:
16+
env:
17+
CODE_VERSION: max
18+
TEST_RESOURCES: test-resources
19+
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- name: Checkout Repository
24+
uses: actions/checkout@v4
25+
with:
26+
fetch-depth: 0
27+
28+
- name: Set up JDK 17
29+
uses: actions/setup-java@v4
30+
with:
31+
java-version: 17
32+
distribution: "temurin"
33+
34+
- name: Install JBang
35+
run: |
36+
curl -Ls https://sh.jbang.dev | bash -s - app setup
37+
echo "$HOME/.jbang/bin" >> $GITHUB_PATH
38+
- name: Setup JBang (trusted sources)
39+
run: jbang trust add https://github.com/apache/
40+
41+
- name: Setup Node
42+
uses: actions/setup-node@v4
43+
with:
44+
node-version: 20
45+
cache: npm
46+
47+
- name: Start Minikube
48+
uses: medyagh/setup-minikube@latest
49+
with:
50+
driver: docker
51+
addons: registry
52+
53+
- name: Cluster info
54+
run: |
55+
kubectl cluster-info
56+
kubectl get pods -n kube-system
57+
echo "current-context:" $(kubectl config current-context)
58+
echo "environment-kubeconfig:" ${KUBECONFIG}
59+
60+
- name: Install
61+
run: npm ci
62+
63+
- name: Compile
64+
run: npm run compile
65+
66+
- name: UI Tests
67+
run: |
68+
eval $(minikube -p minikube docker-env)
69+
xvfb-run --auto-servernum npm run ui-test:deploy
70+
71+
- name: Upload Coverage Results
72+
uses: actions/upload-artifact@v4
73+
if: always()
74+
with:
75+
name: ui-test-screenshots
76+
path: test-resources/screenshots/*.png
77+
78+
check:
79+
if: always()
80+
runs-on: ubuntu-latest
81+
name: Status Check
82+
needs: [ deploy ]
83+
steps:
84+
- name: Test Matrix Result
85+
run: |
86+
echo result = ${{ needs.deploy.result }}
87+
- name: Status Check - success
88+
if: ${{ needs.deploy.result == 'success' }}
89+
run: |
90+
echo "All tests successfully completed!"
91+
exit 0
92+
- name: Status Check - failure
93+
if: ${{ needs.deploy.result != 'success' }}
94+
run: |
95+
echo "Status Check failed!"
96+
exit 1

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ node_modules
55
*.vsix
66
jars/camel-dap-server.jar
77
test-resources
8-
.camel-jbang
8+
.camel-jbang*
99
.test-extensions
1010
*sbom.json
1111
coverage

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ All notable changes to the "vscode-debug-adapter-apache-camel" extension will be
44

55
## 1.4.0
66

7+
- Provide command for a deployment of Camel standalone file using Camel JBang Kubernetes plugin. It is available for Camel JBang version 4.8+.
8+
79
## 1.3.0
810

911
- Provide command and quick action to run with JBang from paretn folder of current opened file

README.md

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

6468
### Requirements
6569

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

9397
### Get Involved
9498

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

97101
### Data and Telemetry
98102

docs/content/kubernetes-deploy.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# How to deploy into local Kubernetes cluster
2+
3+
By default, the deployment aims OpenShift cluster. In case you need to deploy into Kubernetes, there is a small modification needed:
4+
5+
1) open Settings UI in VS Code
6+
2) navigate to `Extensions > Debug Adapter for Apache Camel`
7+
3) modify setting `Camel > Debug Adapter: Kubernetes Run Parameters` as you can see on picture below
8+
9+
![Deploy to Kubernetes cluster with Minikube](../images/kubernetes-run-params.png)
10+
11+
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`.
12+
13+
For more information see [Camel Kubernetes plugin official documentation](https://camel.apache.org/manual/camel-jbang-kubernetes.html).
14+
15+
## Follow logs
16+
17+
You can use Camel CLI to obtain logs of current running integration. In terminal window execute:
18+
19+
```shell
20+
jbang camel@apache/camel kubernetes logs --name=<name>
21+
```
22+
23+
## Undeploy
24+
25+
To remove current integration, you can use also Camel CLI. In this case the command is:
26+
27+
```shell
28+
jbang camel@apache/camel kubernetes delete --name=<name>
29+
```
129 KB
Loading

docs/index.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ This extension adds <a href="https://camel.apache.org/manual/debugger.html">Came
5151
- JBang
5252
- or Maven with Camel maven plugin
5353
- or Quarkus Devs
54+
- Deploy Integration (standalone Camel file) with [Apache Camel Kubernetes](https://camel.apache.org/manual/camel-jbang-kubernetes.html) plugin.
55+
- It allows **one-click deployment into OpenShift** by default
56+
- requires Camel JBang 4.8+
57+
- for deployment into Kubernetes cluster see [how to deploy into local Kubernetes cluster](./content/kubernetes-deploy.md)
5458

5559
### Advanced
5660

package.json

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,19 @@
111111
"default": [
112112
"--local-kamelet-dir=."
113113
]
114+
},
115+
"camel.debugAdapter.KubernetesRunParameters": {
116+
"type": "array",
117+
"uniqueItems": true,
118+
"items": {
119+
"type": "string"
120+
},
121+
"additionalProperties": false,
122+
"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`",
123+
"default": [
124+
"--cluster-type=openshift",
125+
"--dev"
126+
]
114127
}
115128
}
116129
},
@@ -247,6 +260,11 @@
247260
"title": "Run with JBang All Camel Integrations from containing folder",
248261
"icon": "$(camel-run)",
249262
"enablement": "resourceFilename =~ /\\.(java|xml|yaml)$/"
263+
},
264+
{
265+
"command": "apache.camel.kubernetes.deploy",
266+
"title": "Deploy Integration with Apache Camel Kubernetes Run",
267+
"icon": "$(rocket)"
250268
}
251269
],
252270
"menus": {
@@ -293,6 +311,13 @@
293311
"when": "resourceFilename =~ /\\.(java|xml|yaml)$/",
294312
"group": "3_camelrun@3"
295313
}
314+
],
315+
"editor/title": [
316+
{
317+
"command": "apache.camel.kubernetes.deploy",
318+
"when": "resourceFilename =~ /\\.(java|xml|yaml)$/",
319+
"group": "navigation"
320+
}
296321
]
297322
}
298323
},
@@ -306,7 +331,8 @@
306331
"lint": "eslint src",
307332
"test": "node ./out/test/runTest.js",
308333
"ui-test": "node ./out/ui-test/uitest_runner.js",
309-
"ui-coverage": "npm run ui-test -- coverage"
334+
"ui-test:deploy": "npm run ui-test -- deploy",
335+
"ui-test:coverage": "npm run ui-test -- coverage"
310336
},
311337
"devDependencies": {
312338
"@stylistic/eslint-plugin": "^2.9.0",

src/extension.ts

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { getRedHatService, TelemetryEvent, TelemetryService } from "@redhat-deve
2020
import { CamelApplicationLauncherTasksCompletionItemProvider } from './completion/CamelApplicationLauncherTasksCompletionItemProvider';
2121
import { CamelJBangTaskProvider } from './task/CamelJBangTaskProvider';
2222
import { CamelJBangCodelens } from './codelenses/CamelJBangCodelens';
23+
import { execSync } from 'child_process';
2324

2425
let telemetryService: TelemetryService;
2526

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

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

58+
vscode.commands.registerCommand(CAMEL_JBANG_KUBERNETES_DEPLOY_COMMAND_ID, async function () {
59+
const camelAddKubernetesPluginTask = taskProvider.createTask(CamelJBangTaskProvider.labelAddKubernetesPluginTask);
60+
if (camelAddKubernetesPluginTask && !(await isCamelPluginInstalled('kubernetes'))) {
61+
await vscode.tasks.executeTask(camelAddKubernetesPluginTask);
62+
await taskProvider.waitForTaskEnd(CamelJBangTaskProvider.labelAddKubernetesPluginTask);
63+
}
64+
const camelDeployTask = taskProvider.createTask(CamelJBangTaskProvider.labelProvidedDeployTask);
65+
if (camelDeployTask) {
66+
await vscode.tasks.executeTask(camelDeployTask);
67+
await sendCommandTrackingEvent(telemetryService, CAMEL_JBANG_KUBERNETES_DEPLOY_COMMAND_ID);
68+
}
69+
});
70+
5671
vscode.debug.registerDebugAdapterTrackerFactory(CAMEL_DEBUG_ADAPTER_ID, {
5772
createDebugAdapterTracker(_session: vscode.DebugSession) {
5873
return {
@@ -80,7 +95,7 @@ export async function activate(context: vscode.ExtensionContext) {
8095
vscode.languages.registerCodeLensProvider(docSelector, new CamelJBangCodelens());
8196
}
8297

83-
function registerDebugCommand(commandId :string, taskLabel :string) {
98+
function registerDebugCommand(commandId: string, taskLabel: string) {
8499
vscode.commands.registerCommand(commandId, async (uri: vscode.Uri) => {
85100
if (!vscode.workspace.workspaceFolders) {
86101
await vscode.window.showWarningMessage(WORKSPACE_WARNING_MESSAGE);
@@ -100,7 +115,7 @@ function registerDebugCommand(commandId :string, taskLabel :string) {
100115
});
101116
}
102117

103-
function registerRunCommand(commandId :string, taskLabel :string, taskProvider :CamelJBangTaskProvider) {
118+
function registerRunCommand(commandId: string, taskLabel: string, taskProvider: CamelJBangTaskProvider) {
104119
vscode.commands.registerCommand(commandId, async function () {
105120
if (!vscode.workspace.workspaceFolders) {
106121
await vscode.window.showWarningMessage(WORKSPACE_WARNING_MESSAGE);
@@ -128,3 +143,19 @@ async function sendCommandTrackingEvent(telemetryService: TelemetryService, comm
128143
};
129144
await telemetryService.send(telemetryEvent);
130145
}
146+
147+
async function isCamelPluginInstalled(plugin: string): Promise<boolean> {
148+
let output = '';
149+
// it takes always few seconds to compute after click on deploy button
150+
// - can be confusing for user without any UI feedback, it looks like nothing is happening after click on a button..
151+
await vscode.window.withProgress({
152+
location: vscode.ProgressLocation.Window,
153+
cancellable: false,
154+
title: 'Checking Camel JBang Kubernetes plugin...'
155+
}, async (progress) => {
156+
progress.report({ increment: 0 });
157+
output = execSync('jbang camel@apache/camel plugin get', { stdio: 'pipe' }).toString();
158+
progress.report({ increment: 100 });
159+
});
160+
return output.includes(plugin);
161+
}

0 commit comments

Comments
 (0)