You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ma...@apache.org on 2022/10/20 01:41:22 UTC
[camel-karavan] 01/02: Openshift and image build properties
This is an automated email from the ASF dual-hosted git repository.
marat pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-karavan.git
commit 42066bdf73b6f763f907757ea73853b9348546ef
Author: Marat Gubaidullin <ma...@gmail.com>
AuthorDate: Wed Oct 19 20:17:57 2022 -0400
Openshift and image build properties
---
karavan-vscode/package.json | 68 +++++++++++++++++++++++++++++++++++------
karavan-vscode/src/extension.ts | 16 +++++++---
karavan-vscode/src/utils.ts | 8 +++--
3 files changed, 77 insertions(+), 15 deletions(-)
diff --git a/karavan-vscode/package.json b/karavan-vscode/package.json
index 4fb1df8..85e9a13 100644
--- a/karavan-vscode/package.json
+++ b/karavan-vscode/package.json
@@ -79,6 +79,18 @@
"scope": "machine",
"order": 20
},
+ "camel.deployTarget": {
+ "type": "string",
+ "default": "openshift",
+ "enum": [
+ "kubernetes",
+ "openshift",
+ "none"
+ ],
+ "description": "Deploy Target",
+ "scope": "machine",
+ "order": 22
+ },
"camel.quarkus-version": {
"type": "string",
"default": "2.13.2.Final",
@@ -88,7 +100,7 @@
},
"camel.maxMessages": {
"type": "integer",
- "default": 10,
+ "default": 0,
"description": "Maximum number of messages to process before stopping",
"scope": "machine",
"order": 30
@@ -152,7 +164,7 @@
],
"description": "Default application.properties template",
"scope": "machine",
- "order": 99
+ "order": 90
},
"Karavan.quarkusApplicationProperties": {
"type": "array",
@@ -161,18 +173,56 @@
"type": "string"
},
"default": [
- "camel.jbang.quarkusVersion=$RUNTIME_VERSION",
- "quarkus.kubernetes-client.trust-certs=true",
- "quarkus.container-image.builder=jib",
- "quarkus.container-image.group=karavan",
+ "camel.jbang.quarkusVersion=$RUNTIME_VERSION"
+ ],
+ "description": "Default application.properties template for Quarkus Runtime",
+ "scope": "machine",
+ "order": 95
+ },
+ "Karavan.imageBuildProperties": {
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string"
+ },
+ "default": [
+ "quarkus.container-image.group=${KUBERNETES_NAMESPACE}",
"quarkus.container-image.name=$NAME",
+ "quarkus.container-image.builder=jib",
+ "quarkus.container-image.build=true",
+ "quarkus.container-image.push=true",
+ "quarkus.container-image.registry=image-registry.openshift-image-registry.svc:5000",
+ "quarkus.container-image.insecure=true",
+ "quarkus.container-image.username=sa",
+ "quarkus.container-image.password=${TOKEN}",
+ "quarkus.container-image.tag=${DATE}"
+ ],
+ "description": "Default application.properties template for image build",
+ "scope": "machine",
+ "order": 96
+ },
+ "Karavan.openshiftProperties": {
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "type": "string"
+ },
+ "default": [
+ "quarkus.kubernetes.deploy=true",
+ "quarkus.kubernetes.labels.\"app.openshift.io/runtime\"=camel",
+ "quarkus.kubernetes-client.trust-certs=true",
+ "quarkus.kubernetes-client.master-url=kubernetes.default.svc",
+ "quarkus.kubernetes-client.namespace=${KUBERNETES_NAMESPACE}",
+ "quarkus.kubernetes-client.token=${TOKEN}",
+ "quarkus.openshift.deployment-kind=Deployment",
+ "quarkus.openshift.add-version-to-label-selectors=false",
"quarkus.openshift.route.expose=false",
"quarkus.openshift.part-of=$NAME",
"quarkus.openshift.replicas=1"
],
- "description": "Default application.properties template for Quarkus Runtime",
+ "description": "Default application.properties template for Openshift",
"scope": "machine",
- "order": 100
+ "order": 97
}
}
},
@@ -450,4 +500,4 @@
"shelljs": "^0.8.5",
"uuid": "8.3.2"
}
-}
+}
\ No newline at end of file
diff --git a/karavan-vscode/src/extension.ts b/karavan-vscode/src/extension.ts
index a61977c..bef26f8 100644
--- a/karavan-vscode/src/extension.ts
+++ b/karavan-vscode/src/extension.ts
@@ -113,17 +113,25 @@ export function activate(context: ExtensionContext) {
const applicationCommand = commands.registerCommand("karavan.create-application", (...args: any[]) => {
if (rootPath){
const defaultRuntime: string = workspace.getConfiguration().get("camel.runtimes") || '';
+ const deployTarget: string = workspace.getConfiguration().get("camel.deployTarget") || 'openshift';
const runtimeOptions: QuickPickItem [] = [
{label: "quarkus", picked: "quarkus" === defaultRuntime},
{label: "spring-boot", picked: "spring-boot" === defaultRuntime},
{label: "camel-main", picked: "camel-main" === defaultRuntime}
];
+ const deployOptions: QuickPickItem [] = [
+ {label: "kubernetes", picked: "kubernetes" === deployTarget},
+ {label: "openshift", picked: "openshift" === deployTarget},
+ {label: "none", picked: "none" === deployTarget}
+ ];
utils.hasApplicationProperties(rootPath).then(hasAP => {
if (hasAP){
window.showInformationMessage("Folder already contains application.properties");
} else {
- window.showQuickPick(runtimeOptions, { title: "Select Runtime", canPickMany: false }).then((value) => {
- if (value) inputExportGav(value.label)
+ window.showQuickPick(runtimeOptions, { title: "Select Runtime", canPickMany: false }).then((runtime) => {
+ window.showQuickPick(deployOptions, { title: "Select Deploy Target", canPickMany: false }).then((target) => {
+ if (runtime && target) inputExportGav(runtime.label, target.label)
+ })
})
}
})
@@ -194,7 +202,7 @@ export async function inputExportFolder(rootPath?: string) {
/**
* export with gav
*/
-export async function inputExportGav(runtime: string) {
+export async function inputExportGav(runtime: string, target: string) {
window.showInputBox({
title: "Export project with " + runtime,
ignoreFocusOut: true,
@@ -208,7 +216,7 @@ export async function inputExportGav(runtime: string) {
}
}).then(gav => {
if (gav) {
- utils.crateApplicationproperties(runtime, gav)
+ utils.createApplicationproperties(runtime, gav, target)
}
});
}
diff --git a/karavan-vscode/src/utils.ts b/karavan-vscode/src/utils.ts
index 3d3279d..7949a46 100644
--- a/karavan-vscode/src/utils.ts
+++ b/karavan-vscode/src/utils.ts
@@ -206,7 +206,7 @@ export async function write(fullPath: string, code: string) {
);
}
-export async function crateApplicationproperties(runtime: string, gav: string, ) {
+export async function createApplicationproperties(runtime: string, gav: string, deployTarget: string ) {
if (workspace.workspaceFolders) {
const uriFolder: Uri = workspace.workspaceFolders[0].uri;
const parts = uriFolder.fsPath.split(path.sep);
@@ -214,10 +214,14 @@ export async function crateApplicationproperties(runtime: string, gav: string, )
const runtimeVersion: string = workspace.getConfiguration().get("camel." + runtime + "-version") || '';
const props: string [] = workspace.getConfiguration().get("Karavan.applicationProperties") || [];
+ const imageBuildProps: string [] = workspace.getConfiguration().get("Karavan.imageBuildProperties") || [];
+ const targetProps: string [] =
+ deployTarget === 'openshift' ? (workspace.getConfiguration().get("Karavan.openshiftProperties") || [])
+ : [];
const runtimeDefaults: [] = (runtime === 'quarkus')
? workspace.getConfiguration().get("Karavan.quarkusApplicationProperties") || []
: [];
- const text = props.concat(runtimeDefaults).map(v => {
+ const text = props.concat(runtimeDefaults).concat(imageBuildProps).concat(targetProps).map(v => {
if (v.includes('$NAME')) return v.replace('$NAME', name)
else if (v.includes('$GAV')) return v.replace('$GAV', gav)
else if (v.includes('$RUNTIME_VERSION')) return v.replace('$RUNTIME_VERSION', runtimeVersion) // $RUNTIME_VERSION should be before $RUNTIME