You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2022/06/15 04:22:28 UTC
[camel] branch main updated: Cleanup deprecated (#7783)
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 30283bba874 Cleanup deprecated (#7783)
30283bba874 is described below
commit 30283bba87437f7a9966e917dc4f573b9e8abb1c
Author: Marat Gubaidullin <ma...@gmail.com>
AuthorDate: Wed Jun 15 00:22:22 2022 -0400
Cleanup deprecated (#7783)
---
dsl/camel-jbang/camel-jbang-core/pom.xml | 18 -
.../camel/dsl/jbang/core/commands/Build.java | 35 --
.../dsl/jbang/core/commands/CamelJBangMain.java | 16 -
.../camel/dsl/jbang/core/commands/Deploy.java | 121 ------
.../camel/dsl/jbang/core/commands/Image.java | 237 ------------
.../dsl/jbang/core/commands/KubernetesHelper.java | 242 ------------
.../camel/dsl/jbang/core/commands/Manifest.java | 113 ------
.../camel/dsl/jbang/core/commands/Package.java | 35 --
.../camel/dsl/jbang/core/commands/Profile.java | 38 --
.../dsl/jbang/core/commands/ProfileHelper.java | 89 -----
.../camel/dsl/jbang/core/commands/Search.java | 47 ---
.../dsl/jbang/core/commands/SearchComponents.java | 89 -----
.../dsl/jbang/core/commands/SearchKamelets.java | 82 -----
.../dsl/jbang/core/commands/SearchLanguages.java | 87 -----
.../dsl/jbang/core/commands/SearchOthers.java | 88 -----
.../camel/dsl/jbang/core/commands/UberJar.java | 410 ---------------------
.../camel/dsl/jbang/core/commands/Undeploy.java | 84 -----
17 files changed, 1831 deletions(-)
diff --git a/dsl/camel-jbang/camel-jbang-core/pom.xml b/dsl/camel-jbang/camel-jbang-core/pom.xml
index 4a304f38230..a72cf1a9db4 100644
--- a/dsl/camel-jbang/camel-jbang-core/pom.xml
+++ b/dsl/camel-jbang/camel-jbang-core/pom.xml
@@ -94,24 +94,6 @@
<artifactId>jansi</artifactId>
<version>${jansi-version}</version>
</dependency>
- <!-- Kubernetes client -->
- <dependency>
- <groupId>io.fabric8</groupId>
- <artifactId>kubernetes-client</artifactId>
- <version>${kubernetes-client-version}</version>
- </dependency>
- <!-- OpenShift client -->
- <dependency>
- <groupId>io.fabric8</groupId>
- <artifactId>openshift-client</artifactId>
- <version>${kubernetes-client-version}</version>
- </dependency>
- <!-- Docker generator -->
- <dependency>
- <groupId>com.google.cloud.tools</groupId>
- <artifactId>jib-core</artifactId>
- <version>${jib-version}</version>
- </dependency>
<!-- Code generator -->
<dependency>
<groupId>org.apache.camel</groupId>
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Build.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Build.java
deleted file mode 100644
index 44974cfea34..00000000000
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Build.java
+++ /dev/null
@@ -1,35 +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"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://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.
- */
-package org.apache.camel.dsl.jbang.core.commands;
-
-import picocli.CommandLine;
-import picocli.CommandLine.Command;
-
-@Command(name = "build", description = "Build Camel container image and resources (use --help to see sub commands)")
-@Deprecated
-class Build extends CamelCommand {
-
- public Build(CamelJBangMain main) {
- super(main);
- }
-
- @Override
- public Integer call() throws Exception {
- new CommandLine(this).execute("--help");
- return 0;
- }
-}
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/CamelJBangMain.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/CamelJBangMain.java
index cbd58a2562d..69a880c009a 100644
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/CamelJBangMain.java
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/CamelJBangMain.java
@@ -44,20 +44,6 @@ public class CamelJBangMain implements Callable<Integer> {
.addSubcommand("camel-main", new CommandLine(new ExportCamelMain(main)))
.addSubcommand("spring-boot", new CommandLine(new ExportSpringBoot(main)))
.addSubcommand("quarkus", new CommandLine(new ExportQuarkus(main))));
- /* // TODO: do not show commands that are deprecated and to be either removed or reworked
- .addSubcommand("package", new CommandLine(new Package(main))
- .addSubcommand("uber-jar", new CommandLine(new UberJar(main))))
- .addSubcommand("build", new CommandLine(new Build(main))
- .addSubcommand("manifests", new CommandLine(new Manifest(main)))
- .addSubcommand("image", new CommandLine(new Image(main))))
- .addSubcommand("deploy", new CommandLine(new Deploy(main)))
- .addSubcommand("undeploy", new CommandLine(new Undeploy(main)));
- .addSubcommand("search", new CommandLine(new Search())
- .addSubcommand("kamelets", new SearchKamelets())
- .addSubcommand("components", new SearchComponents())
- .addSubcommand("languages", new SearchLanguages())
- .addSubcommand("others", new SearchOthers()))
- */
commandLine.getCommandSpec().versionProvider(() -> {
CamelCatalog catalog = new DefaultCamelCatalog();
@@ -65,8 +51,6 @@ public class CamelJBangMain implements Callable<Integer> {
return new String[] { v };
});
- String profile = ProfileHelper.getProfile(args);
- ProfileHelper.augmentWithProperties(commandLine, profile, args);
int exitCode = commandLine.execute(args);
System.exit(exitCode);
}
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Deploy.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Deploy.java
deleted file mode 100644
index 34c35a2aa5a..00000000000
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Deploy.java
+++ /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"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://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.
- */
-package org.apache.camel.dsl.jbang.core.commands;
-
-import io.fabric8.kubernetes.api.model.Service;
-import io.fabric8.kubernetes.api.model.Status;
-import io.fabric8.kubernetes.api.model.apps.Deployment;
-import io.fabric8.kubernetes.client.DefaultKubernetesClient;
-import io.fabric8.kubernetes.client.KubernetesClient;
-import io.fabric8.kubernetes.client.KubernetesClientException;
-import io.fabric8.openshift.api.model.Route;
-import io.fabric8.openshift.client.DefaultOpenShiftClient;
-import io.fabric8.openshift.client.OpenShiftClient;
-import picocli.CommandLine;
-
-@CommandLine.Command(name = "deploy", description = "Deploy resources to Kubernetes, OpenShift, Minikube")
-@Deprecated
-public class Deploy extends CamelCommand {
-
- @CommandLine.Option(names = { "--namespace" }, required = true, description = "Namespace", defaultValue = "default")
- private String namespace;
- @CommandLine.Option(names = { "--name" }, description = "Application name", required = true)
- private String name;
- @CommandLine.Option(names = { "--version" }, description = "Application version (label)")
- private String version = "latest";
- @CommandLine.Option(names = { "--image" }, description = "Deployment container image name")
- private String image;
- @CommandLine.Option(names = { "--container-port" }, description = "Container port", defaultValue = "8080")
- private int containerPort;
- @CommandLine.Option(names = { "--service-port" }, description = "Service port", defaultValue = "80")
- private int servicePort;
- @CommandLine.Option(names = { "--node-port" }, description = "Node port (minikube)", defaultValue = "30777")
- private int nodePort;
- @CommandLine.Option(names = { "--replicas" }, description = "Number of replicas of the application", defaultValue = "1")
- private int replicas;
- @CommandLine.Option(names = { "--minikube" }, description = "Target is minikube")
- private boolean minikube;
- @CommandLine.Option(names = { "--openshift" }, description = "Target is openshift")
- private boolean openshift;
- @CommandLine.Option(names = { "--server" }, description = "Master URL")
- private String server;
- @CommandLine.Option(names = { "--token" }, description = "Token")
- private String token;
- @CommandLine.Option(names = { "-u", "--username" }, description = "Username")
- private String username;
- @CommandLine.Option(names = { "-p", "--password" }, description = "Password")
- private String password;
-
- public Deploy(CamelJBangMain main) {
- super(main);
- }
-
- @Override
- public Integer call() throws Exception {
- if (openshift) {
- image = image == null ? namespace + "/" + name + ":" + version : image;
- if (!image.startsWith("image-registry.openshift-image-registry.svc:5000") && image.split("/").length != 3) {
- image = "image-registry.openshift-image-registry.svc:5000/" + image;
- }
- System.out.println("Generating Deployment...");
- Deployment deployment = KubernetesHelper.createDeployment(namespace, name, image, version, containerPort, replicas);
- System.out.println("Generating Service...");
- Service service
- = KubernetesHelper.createService(namespace, name, version, servicePort, containerPort, minikube, nodePort);
- System.out.println("Generating Route...");
- Route route = KubernetesHelper.createRoute(namespace, name, version, containerPort);
-
- try (OpenShiftClient client
- = new DefaultOpenShiftClient(KubernetesHelper.getOpenShiftConfig(server, username, password, token))) {
- System.out.println("Creating Deployment in Openshift");
- client.apps().deployments().inNamespace(namespace).createOrReplace(deployment);
- client.services().inNamespace(namespace).delete(service);
- System.out.println("Creating Service in Openshift");
- client.services().inNamespace(namespace).createOrReplace(service);
- System.out.println("Creating Route in Openshift");
- client.routes().inNamespace(namespace).createOrReplace(route);
- } catch (KubernetesClientException ex) {
- Status status = ex.getStatus();
- if (status != null) {
- System.out.println("ERROR: " + status.getCode() + " " + status.getStatus() + " " + status.getReason() + " "
- + ex.getMessage());
- } else {
- System.out.println("ERROR " + ex.getMessage());
- }
- }
- } else {
- System.out.println("Generating Deployment for " + (minikube ? "Minikube" : "Kubernetes"));
- Deployment deployment = KubernetesHelper.createDeployment(namespace, name, image, version, containerPort, replicas);
- System.out.println("Generating Service " + (minikube ? "Minikube" : "Kubernetes"));
- Service service
- = KubernetesHelper.createService(namespace, name, version, servicePort, containerPort, minikube, nodePort);
-
- try (KubernetesClient client
- = new DefaultKubernetesClient(KubernetesHelper.getConfig(server, username, password, token))) {
- System.out.println("Creating Deployment in " + (minikube ? "Minikube" : "Kubernetes"));
- client.apps().deployments().inNamespace(namespace).createOrReplace(deployment);
- client.services().inNamespace(namespace).delete(service);
- System.out.println("Creating Service in " + (minikube ? "Minikube" : "Kubernetes"));
- client.services().inNamespace(namespace).createOrReplace(service);
- } catch (Exception ex) {
- System.out.println("ERROR: " + ex.getMessage());
- ex.printStackTrace();
- }
- }
- return 0;
- }
-}
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Image.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Image.java
deleted file mode 100644
index 366c4182f17..00000000000
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Image.java
+++ /dev/null
@@ -1,237 +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"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://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.
- */
-package org.apache.camel.dsl.jbang.core.commands;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.nio.file.Paths;
-import java.util.Arrays;
-import java.util.concurrent.TimeUnit;
-import java.util.function.Consumer;
-
-import com.google.cloud.tools.jib.api.Containerizer;
-import com.google.cloud.tools.jib.api.DockerDaemonImage;
-import com.google.cloud.tools.jib.api.InvalidImageReferenceException;
-import com.google.cloud.tools.jib.api.Jib;
-import com.google.cloud.tools.jib.api.LogEvent;
-import com.google.cloud.tools.jib.api.RegistryImage;
-import com.google.cloud.tools.jib.api.buildplan.AbsoluteUnixPath;
-import io.fabric8.kubernetes.client.dsl.LogWatch;
-import io.fabric8.openshift.api.model.Build;
-import io.fabric8.openshift.api.model.BuildConfig;
-import io.fabric8.openshift.api.model.ImageStream;
-import io.fabric8.openshift.client.DefaultOpenShiftClient;
-import io.fabric8.openshift.client.OpenShiftClient;
-import picocli.CommandLine;
-
-@CommandLine.Command(name = "image", description = "Create Docker and OCI container images")
-@Deprecated
-public class Image extends CamelCommand {
-
- private static final int LOG_TAIL_SIZE = 10;
-
- @CommandLine.Option(names = { "-f", "--from" }, description = "Base Image", defaultValue = "gcr.io/distroless/java:11")
- private String from;
- @CommandLine.Option(names = { "-j", "--jar" }, description = "Jar file", defaultValue = "camel-runner.jar")
- private String jar;
- @CommandLine.Option(names = { "--push" }, description = "Push to the registry")
- private boolean push;
- @CommandLine.Option(names = { "-r", "--registry" }, description = "Registry image reference")
- private String registry;
- @CommandLine.Option(names = { "-u", "--username" }, description = "Registry username")
- private String username;
- @CommandLine.Option(names = { "-p", "--password" }, description = "Registry password (token)")
- private String password;
- @CommandLine.Option(names = { "--openshift" }, description = "Build in OpenShift")
- private boolean openshift;
- @CommandLine.Option(names = { "--build-config" }, description = "Build in OpenShift using BuildConfig")
- private boolean buildConfig;
- @CommandLine.Option(names = { "--image" }, description = "Image name")
- private String image;
- @CommandLine.Option(names = { "--server" }, description = "Master URL")
- private String server;
- @CommandLine.Option(names = { "--token" }, description = "Token")
- private String token;
- @CommandLine.Option(names = { "--namespace" }, description = "Namespace", defaultValue = "default")
- private String namespace;
- @CommandLine.Option(names = { "--name" }, description = "Application name", required = true)
- private String name;
- @CommandLine.Option(names = { "--version" }, description = "Application version (label)", required = true)
- private String version;
- @CommandLine.Option(names = { "--source-image" }, description = "Source image name (for OpenShift BuildConfig)",
- defaultValue = "java:openjdk-11-ubi8")
- private String sourceImage;
-
- public Image(CamelJBangMain main) {
- super(main);
- }
-
- @Override
- public Integer call() throws Exception {
- File jarFile = Paths.get(jar).toFile();
- image = image == null ? namespace + "/" + name + ":" + version : image;
- if (openshift && buildConfig) {
- buildInOpenshiftWithBuildConfig(jarFile);
- } else {
- String host = openshift ? getOpenshiftRegistryHost() : registry;
- String imageReference = host + "/" + image;
- Jib.from(from)
- .addLayer(Arrays.asList(Paths.get(jar)), "/deployments/")
- .setWorkingDirectory(AbsoluteUnixPath.get("/deployments"))
- .setEntrypoint("java", "-jar", jarFile.getName())
- .containerize(push ? getRegistry(imageReference) : getDockerImage());
- }
- return 0;
- }
-
- private String getOpenshiftRegistryHost() {
- try (OpenShiftClient client
- = new DefaultOpenShiftClient(KubernetesHelper.getOpenShiftConfig(server, username, password, token))) {
- return client.routes().inNamespace("openshift-image-registry").list().getItems().get(0).getSpec().getHost();
- }
- }
-
- private void buildInOpenshiftWithBuildConfig(File jarFile) throws InvalidImageReferenceException {
- System.out.println("Generating resources...");
- try (OpenShiftClient client
- = new DefaultOpenShiftClient(KubernetesHelper.getOpenShiftConfig(server, username, password, token))) {
- ImageStream imageStream = KubernetesHelper.createImageStream(namespace, name, version);
- BuildConfig buildConfig
- = KubernetesHelper.createBuildConfig(namespace, name, version, jarFile.getName(), sourceImage);
- System.out.println("Creating ImageStream...");
- client.imageStreams().createOrReplace(imageStream);
- System.out.println("Creating BuildConfig...");
- client.buildConfigs().createOrReplace(buildConfig);
- System.out.println("Creating Build...");
- Build build = client.buildConfigs()
- .inNamespace(namespace)
- .withName(buildConfig.getMetadata().getName())
- .instantiateBinary()
- .asFile(jarFile.getName())
- .withTimeout(5, TimeUnit.MINUTES)
- .fromFile(jarFile);
- while (isNew(build) || isPending(build) || isRunning(build)) {
- final String buildName = build.getMetadata().getName();
- Build updated = client.builds().withName(buildName).get();
- if (updated == null) {
- throw new IllegalStateException("Build:" + build.getMetadata().getName() + " is no longer present!");
- } else if (updated.getStatus() == null) {
- throw new IllegalStateException("Build:" + build.getMetadata().getName() + " has no status!");
- } else if (isNew(updated) || isPending(updated) || isRunning(updated)) {
- build = updated;
- try (LogWatch w
- = client.builds().withName(buildName).withPrettyOutput().watchLog();
- Reader reader = new InputStreamReader(w.getOutput())) {
- display(reader);
- } catch (IOException e) {
- // This may happen if the LogWatch is closed while we are still reading.
- // We shouldn't let the build fail, so let's log a warning and display last few lines of the log
- System.out.println("Log stream closed, redisplaying last " + LOG_TAIL_SIZE + " entries:");
- try {
- display(client.builds().withName(buildName).tailingLines(LOG_TAIL_SIZE)
- .getLogReader());
- } catch (IOException ex) {
- // Let's ignore this.
- }
- }
- } else if (isComplete(updated)) {
- break;
- } else if (isCancelled(updated)) {
- throw new IllegalStateException("Build:" + buildName + " cancelled!");
- } else if (isFailed(updated)) {
- throw new IllegalStateException(
- "Build:" + buildName + " failed! " + updated.getStatus().getMessage());
- } else if (isError(updated)) {
- throw new IllegalStateException(
- "Build:" + buildName + " encountered error! " + updated.getStatus().getMessage());
- }
- }
- }
- }
-
- private Containerizer getDockerImage() throws InvalidImageReferenceException {
- String image = namespace + "/" + name + ":" + version;
- return Containerizer.to(DockerDaemonImage.named(image)).addEventHandler(LogEvent.class, getEventConsumer());
- }
-
- private Containerizer getRegistry(String imageReference) throws InvalidImageReferenceException {
- return Containerizer.to(
- RegistryImage.named(imageReference).addCredential(username, password))
- .addEventHandler(LogEvent.class, getEventConsumer());
- }
-
- private Consumer<LogEvent> getEventConsumer() {
- return event -> System.out.println(event.getLevel() + ": " + event.getMessage());
- }
-
- private static void display(Reader logReader) throws IOException {
- BufferedReader reader = new BufferedReader(logReader);
- for (String line = reader.readLine(); line != null; line = reader.readLine()) {
- System.out.println(line);
- }
- }
-
- static boolean isNew(Build build) {
- return build != null && build.getStatus() != null
- && BuildStatus.New.name().equalsIgnoreCase(build.getStatus().getPhase());
- }
-
- static boolean isPending(Build build) {
- return build != null && build.getStatus() != null
- && BuildStatus.Pending.name().equalsIgnoreCase(build.getStatus().getPhase());
- }
-
- static boolean isRunning(Build build) {
- return build != null && build.getStatus() != null
- && BuildStatus.Running.name().equalsIgnoreCase(build.getStatus().getPhase());
- }
-
- static boolean isComplete(Build build) {
- return build != null && build.getStatus() != null
- && BuildStatus.Complete.name().equalsIgnoreCase(build.getStatus().getPhase());
- }
-
- static boolean isFailed(Build build) {
- return build != null && build.getStatus() != null
- && BuildStatus.Failed.name().equalsIgnoreCase(build.getStatus().getPhase());
- }
-
- static boolean isError(Build build) {
- return build != null && build.getStatus() != null
- && BuildStatus.Error.name().equalsIgnoreCase(build.getStatus().getPhase());
- }
-
- static boolean isCancelled(Build build) {
- return build != null && build.getStatus() != null
- && BuildStatus.Cancelled.name().equalsIgnoreCase(build.getStatus().getPhase());
- }
-
- public enum BuildStatus {
-
- New,
- Pending,
- Running,
- Complete,
- Failed,
- Error,
- Cancelled;
-
- }
-}
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/KubernetesHelper.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/KubernetesHelper.java
deleted file mode 100644
index 9b906c3b7d5..00000000000
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/KubernetesHelper.java
+++ /dev/null
@@ -1,242 +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"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://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.
- */
-package org.apache.camel.dsl.jbang.core.commands;
-
-import java.util.Map;
-
-import io.fabric8.kubernetes.api.model.EnvVar;
-import io.fabric8.kubernetes.api.model.EnvVarBuilder;
-import io.fabric8.kubernetes.api.model.ObjectMetaBuilder;
-import io.fabric8.kubernetes.api.model.Service;
-import io.fabric8.kubernetes.api.model.ServiceBuilder;
-import io.fabric8.kubernetes.api.model.ServicePortBuilder;
-import io.fabric8.kubernetes.api.model.ServiceSpecBuilder;
-import io.fabric8.kubernetes.api.model.apps.Deployment;
-import io.fabric8.kubernetes.api.model.apps.DeploymentBuilder;
-import io.fabric8.kubernetes.client.Config;
-import io.fabric8.kubernetes.client.ConfigBuilder;
-import io.fabric8.openshift.api.model.BinaryBuildSource;
-import io.fabric8.openshift.api.model.BuildConfig;
-import io.fabric8.openshift.api.model.BuildConfigBuilder;
-import io.fabric8.openshift.api.model.ImageStream;
-import io.fabric8.openshift.api.model.ImageStreamBuilder;
-import io.fabric8.openshift.api.model.Route;
-import io.fabric8.openshift.api.model.RouteBuilder;
-import io.fabric8.openshift.api.model.RoutePortBuilder;
-import io.fabric8.openshift.client.OpenShiftConfig;
-import io.fabric8.openshift.client.OpenShiftConfigBuilder;
-
-@Deprecated
-public final class KubernetesHelper {
-
- private KubernetesHelper() {
- }
-
- public static BuildConfig createBuildConfig(
- String namespace, String name, String version, String filename, String sourceImage) {
-
- ObjectMetaBuilder metadata = new ObjectMetaBuilder()
- .withName(name)
- .withAnnotations(Map.of("jarFileName", filename))
- .withLabels(getLabels(name, version));
- if (namespace != null) {
- metadata.withNamespace(namespace);
- }
-
- return new BuildConfigBuilder()
- .withMetadata(metadata.build())
- .withNewSpec()
- .withNewSource().withType("Binary").withBinary(new BinaryBuildSource(filename)).endSource()
- .withNewOutput()
- .withNewTo().withKind("ImageStreamTag").withName(name + ":" + version).endTo()
- .endOutput()
- .withNewStrategy().withType("Source")
- .withNewSourceStrategy().withNewFrom().withKind("ImageStreamTag").withNamespace("openshift")
- .withName(sourceImage).endFrom()
- .endSourceStrategy()
- .endStrategy()
- .withNewSource().withType("Binary")
- .endSource()
- .endSpec()
- .build();
- }
-
- public static ImageStream createImageStream(String namespace, String name, String version) {
-
- ObjectMetaBuilder metadata = new ObjectMetaBuilder()
- .withName(name)
- .withLabels(getLabels(name, version));
- if (namespace != null) {
- metadata.withNamespace(namespace);
- }
-
- return new ImageStreamBuilder()
- .withMetadata(metadata.build())
- .withNewSpec()
- .withNewLookupPolicy(false)
- .endSpec()
- .build();
- }
-
- public static Route createRoute(String namespace, String name, String version, int targetPort) {
-
- ObjectMetaBuilder metadata = new ObjectMetaBuilder()
- .withName(name)
- .withLabels(getLabels(name, version));
- if (namespace != null) {
- metadata.withNamespace(namespace);
- }
-
- return new RouteBuilder()
- .withMetadata(metadata.build())
- .withNewSpec()
- .withPort(new RoutePortBuilder().withNewTargetPort(targetPort).build())
- .withNewTo().withKind("Service").withName(name)
- .endTo()
- .endSpec()
- .build();
- }
-
- public static Service createService(
- String namespace, String name, String version, int port, int targetPort, boolean minikube, int nodePort) {
-
- ObjectMetaBuilder metadata = new ObjectMetaBuilder()
- .withName(name)
- .withLabels(getLabels(name, version));
- if (namespace != null) {
- metadata.withNamespace(namespace);
- }
-
- ServicePortBuilder servicePort = new ServicePortBuilder()
- .withName("http")
- .withPort(port)
- .withNewTargetPort(targetPort);
- if (minikube) {
- servicePort.withNodePort(nodePort);
- }
-
- ServiceSpecBuilder spec = new ServiceSpecBuilder()
- .withSelector(getSelector(name, version))
- .withPorts(servicePort.build());
- if (minikube) {
- spec.withType("NodePort");
- }
-
- return new ServiceBuilder()
- .withMetadata(metadata.build())
- .withSpec(spec.build())
- .build();
- }
-
- public static Deployment createDeployment(
- String namespace, String name, String image, String version, int containerPort, int replica) {
-
- if (image == null) {
- image = namespace + "/" + name + ":" + version;
- }
-
- EnvVar envVar = new EnvVarBuilder()
- .withName("KUBERNETES_NAMESPACE")
- .withNewValueFrom()
- .withNewFieldRef()
- .withFieldPath("metadata.namespace")
- .endFieldRef()
- .endValueFrom()
- .build();
-
- ObjectMetaBuilder metadata = new ObjectMetaBuilder()
- .withName(name)
- .withLabels(getLabels(name, version));
- if (namespace != null) {
- metadata.withNamespace(namespace);
- }
-
- return new DeploymentBuilder()
- .withMetadata(metadata.build())
- .withNewSpec()
- .withReplicas(replica)
- .withNewSelector()
- .addToMatchLabels(getMatchLabels(name))
- .endSelector()
- .withNewTemplate()
- .withNewMetadata()
- .addToLabels(getLabels(name, version))
- .endMetadata()
- .withNewSpec()
- .addNewContainer()
- .withName(name)
- .withImage(image)
- .withImagePullPolicy("IfNotPresent")
- .addNewPort()
- .withContainerPort(containerPort)
- .withName("http")
- .withProtocol("TCP")
- .endPort()
- .addNewEnv()
- .withName("KUBERNETES_NAMESPACE")
- .withValueFrom(envVar.getValueFrom())
- .endEnv()
- .endContainer()
- .endSpec()
- .endTemplate()
- .endSpec()
- .build();
- }
-
- public static Map<String, String> getLabels(String name, String version) {
- return Map.of(
- "app", name,
- "app.kubernetes.io/name", name,
- "app.kubernetes.io/component", name,
- "app.kubernetes.io/instance", name,
- "app.kubernetes.io/version", version,
- "app.kubernetes.io/part-of", name,
- "app.openshift.io/runtime", "camel",
- "app.kubernetes.io/runtime", "camel");
- }
-
- public static Map<String, String> getMatchLabels(String name) {
- return Map.of(
- "app", name);
- }
-
- public static Map<String, String> getSelector(String name, String version) {
- return Map.of(
- "app.kubernetes.io/name", name,
- "app.kubernetes.io/version", version);
- }
-
- public static OpenShiftConfig getOpenShiftConfig(String server, String username, String password, String token) {
- if (token != null) {
- return new OpenShiftConfigBuilder().withMasterUrl(server).withOauthToken(token).withTrustCerts(true).build();
- } else {
- return new OpenShiftConfigBuilder().withMasterUrl(server).withUsername(username).withPassword(password)
- .withTrustCerts(true).build();
- }
- }
-
- public static Config getConfig(String server, String username, String password, String token) {
- if (token != null && server != null) {
- return new ConfigBuilder().withMasterUrl(server).withOauthToken(token).withTrustCerts(true).build();
- } else if (username != null && token != null && server != null) {
- return new ConfigBuilder().withMasterUrl(server).withUsername(username).withPassword(password).withTrustCerts(true)
- .build();
- } else {
- return new ConfigBuilder().build();
- }
- }
-}
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Manifest.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Manifest.java
deleted file mode 100644
index 4ab7901908b..00000000000
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Manifest.java
+++ /dev/null
@@ -1,113 +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"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://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.
- */
-package org.apache.camel.dsl.jbang.core.commands;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-
-import io.fabric8.kubernetes.api.model.Service;
-import io.fabric8.kubernetes.api.model.apps.Deployment;
-import io.fabric8.kubernetes.client.utils.Serialization;
-import io.fabric8.openshift.api.model.BuildConfig;
-import io.fabric8.openshift.api.model.ImageStream;
-import io.fabric8.openshift.api.model.Route;
-import picocli.CommandLine;
-
-@CommandLine.Command(name = "manifests", description = "Create Kubernetes resources")
-@Deprecated
-public class Manifest extends CamelCommand {
-
- @CommandLine.Option(names = { "--path" }, description = "Output folder path", defaultValue = "manifests")
- private String path;
- @CommandLine.Option(names = { "--namespace" }, description = "Namespace")
- private String namespace;
- @CommandLine.Option(names = { "--name" }, description = "Application name", required = true)
- private String name;
- @CommandLine.Option(names = { "--version" }, description = "Application version (label)", required = true)
- private String version;
- @CommandLine.Option(names = { "--image" }, description = "Deployment container image name", required = true)
- private String image;
- @CommandLine.Option(names = { "--source-image" }, description = "Source image name (for OpenShift buildConfig)",
- defaultValue = "java:openjdk-11-ubi8")
- private String sourceImage;
- @CommandLine.Option(names = { "--container-port" }, description = "Container port", defaultValue = "8080")
- private int containerPort;
- @CommandLine.Option(names = { "--service-port" }, description = "Service port", defaultValue = "80")
- private int servicePort;
- @CommandLine.Option(names = { "--node-port" }, description = "Node port (minikube)", defaultValue = "30777")
- private int nodePort;
- @CommandLine.Option(names = { "--replicas" }, description = "Number of replicas of the application", defaultValue = "1")
- private int replicas;
- @CommandLine.Option(names = { "--minikube" }, description = "Target is minikube")
- private boolean minikube;
- @CommandLine.Option(names = { "--openshift" }, description = "Target is openshift")
- private boolean openshift;
- @CommandLine.Option(names = { "-j", "--jar" }, description = "Jar file", defaultValue = "camel-runner.jar")
- private String jar;
-
- public Manifest(CamelJBangMain main) {
- super(main);
- }
-
- @Override
- public Integer call() throws Exception {
- try {
- System.out.println("Generating resources...");
- if (minikube) {
- Deployment deployment
- = KubernetesHelper.createDeployment(namespace, name, image, version, containerPort, replicas);
- Service service = KubernetesHelper.createService(namespace, name, version, servicePort, containerPort, minikube,
- nodePort);
- write(deployment, "deployment.yaml");
- write(service, "service.yaml");
- } else if (openshift) {
- Deployment deployment
- = KubernetesHelper.createDeployment(namespace, name, image, version, containerPort, replicas);
- Service service = KubernetesHelper.createService(namespace, name, version, servicePort, containerPort, minikube,
- nodePort);
- Route route = KubernetesHelper.createRoute(namespace, name, version, containerPort);
- ImageStream imageStream = KubernetesHelper.createImageStream(namespace, name, version);
- File jarFile = Paths.get(jar).toFile();
- BuildConfig buildConfig
- = KubernetesHelper.createBuildConfig(namespace, name, version, jarFile.getName(), sourceImage);
- write(deployment, "deployment.yaml");
- write(service, "service.yaml");
- write(route, "route.yaml");
- write(imageStream, "image-stream.yaml");
- write(buildConfig, "build-config.yaml");
- }
- } catch (Exception ex) {
- }
- return 0;
- }
-
- private void write(Object object, String filename) throws IOException {
- Path output = Paths.get(path != null ? path : System.getProperty("user.dir"));
- if (!Files.exists(output)) {
- System.out.println("Creating output folder " + output);
- Files.createDirectories(output);
- }
- System.out.println("Writing " + filename);
- Files.write(Paths.get(output.toString(), filename),
- Serialization.asYaml(object).getBytes(StandardCharsets.UTF_8));
- }
-
-}
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Package.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Package.java
deleted file mode 100644
index 8d01405194c..00000000000
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Package.java
+++ /dev/null
@@ -1,35 +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"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://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.
- */
-package org.apache.camel.dsl.jbang.core.commands;
-
-import picocli.CommandLine;
-import picocli.CommandLine.Command;
-
-@Command(name = "package", description = "Package Camel application (use --help to see sub commands)")
-@Deprecated
-class Package extends CamelCommand {
-
- public Package(CamelJBangMain main) {
- super(main);
- }
-
- @Override
- public Integer call() throws Exception {
- new CommandLine(this).execute("--help");
- return 0;
- }
-}
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Profile.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Profile.java
deleted file mode 100644
index bc7e5168b81..00000000000
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Profile.java
+++ /dev/null
@@ -1,38 +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"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://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.
- */
-package org.apache.camel.dsl.jbang.core.commands;
-
-import java.util.List;
-import java.util.concurrent.Callable;
-
-import picocli.CommandLine;
-
-@CommandLine.Command()
-public class Profile implements Callable<Integer> {
-
- @CommandLine.Option(names = { "--profile" }, scope = CommandLine.ScopeType.INHERIT, defaultValue = "application",
- description = "Profile to use (Loads properties file with the same profile name).")
- private String profile;
-
- @CommandLine.Unmatched
- private List<String> unmatched;
-
- @Override
- public Integer call() throws Exception {
- return 0;
- }
-}
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ProfileHelper.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ProfileHelper.java
deleted file mode 100644
index 1e2d8eb93f9..00000000000
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ProfileHelper.java
+++ /dev/null
@@ -1,89 +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"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://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.
- */
-package org.apache.camel.dsl.jbang.core.commands;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.util.Objects;
-import java.util.Properties;
-
-import picocli.CommandLine;
-
-/**
- * Helper for CLI arguments with profile
- */
-public final class ProfileHelper {
-
- private static final String DEFAULT_PROFILE = "application";
- private static final String PROFILE = "profile";
- private static final String PROPERTY_PREFIX = "camel.jbang";
- private static final String COMMAND_PREFIX = "camel";
- private static final String PROPERTIES_FILENAME = "application.properties";
-
- private ProfileHelper() {
- }
-
- public static String getProfile(String... args) {
- CommandLine.ParseResult results = new CommandLine(new Profile())
- .setStopAtUnmatched(false)
- .setStopAtPositional(false).parseArgs(args);
- if (results.hasMatchedOption(PROFILE)) {
- return results.matchedOption(PROFILE).getValue().toString();
- } else {
- return DEFAULT_PROFILE;
- }
- }
-
- public static void augmentWithProperties(CommandLine commandLine, String profile, String... args) {
- Properties fileProperties = readProperties();
- if (!fileProperties.isEmpty()) {
- if (!Objects.equals(profile, DEFAULT_PROFILE)) {
- // only show if not default
- System.out.println("Augmenting properties with profile " + profile);
- }
- Properties properties = replacePrefix(fileProperties, profile);
- commandLine.setDefaultValueProvider(new CommandLine.PropertiesDefaultProvider(properties));
- }
- }
-
- private static Properties replacePrefix(Properties properties, String profile) {
- Properties result = new Properties();
- String profilePrefix = "%" + profile + ".";
- properties.forEach((key, value) -> {
- if (key.toString().startsWith(PROPERTY_PREFIX) && !properties.containsKey(profilePrefix + PROPERTY_PREFIX)) {
- result.put(key.toString().replace(PROPERTY_PREFIX, COMMAND_PREFIX), value);
- } else if (key.toString().startsWith(profilePrefix + PROPERTY_PREFIX)) {
- result.put(key.toString().replace(profilePrefix + PROPERTY_PREFIX, COMMAND_PREFIX), value);
- }
- });
- return result;
- }
-
- private static Properties readProperties() {
- File defaultsFile = new File(PROPERTIES_FILENAME);
- Properties properties = new Properties();
- if (defaultsFile.exists()) {
- try (FileInputStream fis = new FileInputStream(defaultsFile)) {
- properties.load(fis);
- } catch (IOException e) {
- // ignore
- }
- }
- return properties;
- }
-}
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Search.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Search.java
deleted file mode 100644
index 3974a5a7912..00000000000
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Search.java
+++ /dev/null
@@ -1,47 +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"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://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.
- */
-package org.apache.camel.dsl.jbang.core.commands;
-
-import java.util.concurrent.Callable;
-
-import picocli.CommandLine;
-import picocli.CommandLine.Command;
-import picocli.CommandLine.Option;
-
-@Command(name = "search", description = "Search for Kamelets, components and patterns (use --help)")
-@Deprecated
-class Search extends AbstractSearch implements Callable<Integer> {
- //CHECKSTYLE:OFF
- @Option(names = { "-h", "--help" }, usageHelp = true, description = "Display the help and sub-commands")
- private boolean helpRequested = false;
- //CHECKSTYLE:ON
-
- public Search() {
- super(null, null);
- }
-
- public void printHeader() {
- // NO-OP
- }
-
- @Override
- public Integer call() throws Exception {
- new CommandLine(this).execute("--help");
-
- return 0;
- }
-}
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/SearchComponents.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/SearchComponents.java
deleted file mode 100644
index 6bcafb7bc71..00000000000
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/SearchComponents.java
+++ /dev/null
@@ -1,89 +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"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://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.
- */
-package org.apache.camel.dsl.jbang.core.commands;
-
-import java.util.concurrent.Callable;
-import java.util.regex.Pattern;
-
-import org.apache.camel.dsl.jbang.core.common.MatchExtractor;
-import org.apache.camel.dsl.jbang.core.common.exceptions.ResourceDoesNotExist;
-import org.apache.camel.dsl.jbang.core.components.ComponentConverter;
-import org.apache.camel.dsl.jbang.core.components.ComponentDescriptionMatching;
-import org.apache.camel.dsl.jbang.core.components.ComponentPrinter;
-import org.apache.camel.dsl.jbang.core.types.Component;
-import picocli.CommandLine.Command;
-import picocli.CommandLine.Option;
-
-@Command(name = "components", description = "Search for Camel components")
-@Deprecated
-class SearchComponents extends AbstractSearch implements Callable<Integer> {
-
- /*
- * Matches the following line. Separate them into groups and pick the last
- * which contains the description:
- *
- * * xref:ROOT:index.adoc[Components]
- */
- private static final Pattern PATTERN = Pattern.compile("(.*):(.*)\\[(.*)\\]");
-
- //CHECKSTYLE:OFF
- @Option(names = { "-h", "--help" }, usageHelp = true, description = "Display the help and sub-commands")
- private boolean helpRequested = false;
- //CHECKSTYLE:ON
-
- @Option(names = { "--search-term" }, defaultValue = "", description = "Default debug level")
- private String searchTerm;
-
- @Option(names = { "--base-resource-location" }, defaultValue = "github:apache", hidden = true,
- description = "Where to download the resources from")
- private String resourceLocation;
-
- @Option(names = { "--branch" }, defaultValue = "main", hidden = true,
- description = "The branch to use when downloading or searching resources (mostly used for development/testing)")
- private String branch;
-
- @Override
- public void printHeader() {
- System.out.printf("%-35s %-45s %s%n", "COMPONENT", "DESCRIPTION", "LINK");
- System.out.printf("%-35s %-45s %s%n", "-------", "-----------", "-----");
- }
-
- @Override
- public Integer call() throws Exception {
- setResourceLocation(resourceLocation, "camel:docs/components/modules/ROOT/nav.adoc");
- setBranch(branch);
-
- MatchExtractor<Component> matchExtractor;
- if (searchTerm.isEmpty()) {
- matchExtractor = new MatchExtractor<>(PATTERN, new ComponentConverter(), new ComponentPrinter());
-
- } else {
- matchExtractor = new MatchExtractor<>(
- PATTERN, new ComponentConverter(),
- new ComponentDescriptionMatching(searchTerm));
-
- }
-
- try {
- search(matchExtractor);
- return 0;
- } catch (ResourceDoesNotExist e) {
- System.err.println(e.getMessage());
- return 1;
- }
- }
-}
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/SearchKamelets.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/SearchKamelets.java
deleted file mode 100644
index 11e167ff25b..00000000000
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/SearchKamelets.java
+++ /dev/null
@@ -1,82 +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"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://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.
- */
-package org.apache.camel.dsl.jbang.core.commands;
-
-import java.util.concurrent.Callable;
-import java.util.regex.Pattern;
-
-import org.apache.camel.dsl.jbang.core.common.MatchExtractor;
-import org.apache.camel.dsl.jbang.core.kamelets.KameletConverter;
-import org.apache.camel.dsl.jbang.core.kamelets.KameletDescriptionMatching;
-import org.apache.camel.dsl.jbang.core.kamelets.KameletPrinter;
-import org.apache.camel.dsl.jbang.core.types.Kamelet;
-import picocli.CommandLine.Command;
-import picocli.CommandLine.Option;
-
-@Command(name = "kamelets", description = "Search for a Kamelet in the Kamelet catalog")
-@Deprecated
-class SearchKamelets extends AbstractSearch implements Callable<Integer> {
- /*
- * Matches the following line. Separate them into groups and pick the last
- * which contains the description:
- *
- * xref:ROOT:mariadb-sink.adoc[image:kamelets/mariadb-sink.svg[] MariaDB Sink]
- */
- private static final Pattern PATTERN = Pattern.compile("(.*):(.*):(.*)\\[(.*)\\[\\] (.*)\\]");
-
- //CHECKSTYLE:OFF
- @Option(names = { "-h", "--help" }, usageHelp = true, description = "Display the help and sub-commands")
- private boolean helpRequested = false;
- //CHECKSTYLE:ON
-
- @Option(names = { "--search-term" }, defaultValue = "", description = "Default debug level")
- private String searchTerm;
-
- @Option(names = { "--base-resource-location" }, defaultValue = "github:apache", hidden = true,
- description = "Where to download the resources from")
- private String resourceLocation;
-
- @Option(names = { "--branch" }, defaultValue = "main", hidden = true,
- description = "The branch to use when downloading resources from (used for development/testing)")
- private String branch;
-
- @Override
- public void printHeader() {
- System.out.printf("%-35s %-45s %s%n", "KAMELET", "DESCRIPTION", "LINK");
- System.out.printf("%-35s %-45s %s%n", "-------", "-----------", "-----");
- }
-
- @Override
- public Integer call() throws Exception {
- setResourceLocation(resourceLocation, "camel-kamelets:docs/modules/ROOT/nav.adoc");
- setBranch(branch);
-
- MatchExtractor<Kamelet> matchExtractor;
-
- if (searchTerm.isEmpty()) {
- matchExtractor = new MatchExtractor<>(PATTERN, new KameletConverter(), new KameletPrinter());
- } else {
- matchExtractor = new MatchExtractor<>(
- PATTERN, new KameletConverter(),
- new KameletDescriptionMatching(searchTerm));
- }
-
- search(matchExtractor);
-
- return 0;
- }
-}
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/SearchLanguages.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/SearchLanguages.java
deleted file mode 100644
index 007e4e32dae..00000000000
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/SearchLanguages.java
+++ /dev/null
@@ -1,87 +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"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://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.
- */
-package org.apache.camel.dsl.jbang.core.commands;
-
-import java.util.concurrent.Callable;
-import java.util.regex.Pattern;
-
-import org.apache.camel.dsl.jbang.core.common.MatchExtractor;
-import org.apache.camel.dsl.jbang.core.common.exceptions.ResourceDoesNotExist;
-import org.apache.camel.dsl.jbang.core.languages.LanguageConverter;
-import org.apache.camel.dsl.jbang.core.languages.LanguageDescriptionMatching;
-import org.apache.camel.dsl.jbang.core.languages.LanguagePrinter;
-import org.apache.camel.dsl.jbang.core.types.Language;
-import picocli.CommandLine.Command;
-import picocli.CommandLine.Option;
-
-@Command(name = "languages", description = "Search for Camel expression languages")
-@Deprecated
-class SearchLanguages extends AbstractSearch implements Callable<Integer> {
- /*
- * Matches the following line. Separate them into groups and pick the last
- * which contains the description:
- *
- * * xref:ROOT:index.adoc[Components]
- */
- private static final Pattern PATTERN = Pattern.compile("(.*):(.*)\\[(.*)\\]");
-
- //CHECKSTYLE:OFF
- @Option(names = { "-h", "--help" }, usageHelp = true, description = "Display the help and sub-commands")
- private boolean helpRequested = false;
- //CHECKSTYLE:ON
-
- @Option(names = { "--search-term" }, defaultValue = "", description = "Default debug level")
- private String searchTerm;
-
- @Option(names = { "--base-resource-location" }, defaultValue = "github:apache", hidden = true,
- description = "Where to download the resources from")
- private String resourceLocation;
-
- @Option(names = { "--branch" }, defaultValue = "main", hidden = true,
- description = "The branch to use when downloading or searching resources (mostly used for development/testing)")
- private String branch;
-
- @Override
- public void printHeader() {
- System.out.printf("%-35s %-45s %s%n", "LANGUAGE", "DESCRIPTION", "LINK");
- System.out.printf("%-35s %-45s %s%n", "-------", "-----------", "-----");
- }
-
- @Override
- public Integer call() throws Exception {
- setResourceLocation(resourceLocation, "camel:docs/components/modules/languages/nav.adoc");
- setBranch(branch);
-
- MatchExtractor<Language> matchExtractor;
- if (searchTerm.isEmpty()) {
- matchExtractor = new MatchExtractor<>(PATTERN, new LanguageConverter(), new LanguagePrinter());
-
- } else {
- matchExtractor = new MatchExtractor<>(
- PATTERN, new LanguageConverter(),
- new LanguageDescriptionMatching(searchTerm));
-
- }
- try {
- search(matchExtractor);
- return 0;
- } catch (ResourceDoesNotExist e) {
- System.err.println(e.getMessage());
- return 1;
- }
- }
-}
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/SearchOthers.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/SearchOthers.java
deleted file mode 100644
index 47b483bb953..00000000000
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/SearchOthers.java
+++ /dev/null
@@ -1,88 +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"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://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.
- */
-package org.apache.camel.dsl.jbang.core.commands;
-
-import java.util.concurrent.Callable;
-import java.util.regex.Pattern;
-
-import org.apache.camel.dsl.jbang.core.common.MatchExtractor;
-import org.apache.camel.dsl.jbang.core.common.exceptions.ResourceDoesNotExist;
-import org.apache.camel.dsl.jbang.core.others.OtherConverter;
-import org.apache.camel.dsl.jbang.core.others.OtherDescriptionMatching;
-import org.apache.camel.dsl.jbang.core.others.OtherPrinter;
-import org.apache.camel.dsl.jbang.core.types.Other;
-import picocli.CommandLine.Command;
-import picocli.CommandLine.Option;
-
-@Command(name = "others", description = "Search for Camel miscellaneous components")
-@Deprecated
-class SearchOthers extends AbstractSearch implements Callable<Integer> {
- /*
- * Matches the following line. Separate them into groups and pick the last
- * which contains the description:
- *
- * * xref:ROOT:index.adoc[Components]
- */
- private static final Pattern PATTERN = Pattern.compile("(.*):(.*)\\[(.*)\\]");
-
- //CHECKSTYLE:OFF
- @Option(names = { "-h", "--help" }, usageHelp = true, description = "Display the help and sub-commands")
- private boolean helpRequested = false;
- //CHECKSTYLE:ON
-
- @Option(names = { "--search-term" }, defaultValue = "", description = "Default debug level")
- private String searchTerm;
-
- @Option(names = { "--base-resource-location" }, defaultValue = "github:apache", hidden = true,
- description = "Where to download the resources from")
- private String resourceLocation;
-
- @Option(names = { "--branch" }, defaultValue = "main", hidden = true,
- description = "The branch to use when downloading or searching resources (mostly used for development/testing)")
- private String branch;
-
- @Override
- public void printHeader() {
- System.out.printf("%-35s %-45s %s%n", "COMPONENT", "DESCRIPTION", "LINK");
- System.out.printf("%-35s %-45s %s%n", "-------", "-----------", "-----");
- }
-
- @Override
- public Integer call() throws Exception {
- setResourceLocation(resourceLocation, "camel:docs/components/modules/others/nav.adoc");
- setBranch(branch);
-
- MatchExtractor<Other> matchExtractor;
- if (searchTerm.isEmpty()) {
- matchExtractor = new MatchExtractor<>(PATTERN, new OtherConverter(), new OtherPrinter());
-
- } else {
- matchExtractor = new MatchExtractor<>(
- PATTERN, new OtherConverter(),
- new OtherDescriptionMatching(searchTerm));
-
- }
-
- try {
- search(matchExtractor);
- return 0;
- } catch (ResourceDoesNotExist e) {
- System.err.println(e.getMessage());
- return 1;
- }
- }
-}
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/UberJar.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/UberJar.java
deleted file mode 100644
index 3e1ceda1589..00000000000
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/UberJar.java
+++ /dev/null
@@ -1,410 +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"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://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.
- */
-package org.apache.camel.dsl.jbang.core.commands;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.net.URI;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
-import java.nio.file.StandardCopyOption;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.function.Predicate;
-import java.util.jar.JarEntry;
-import java.util.jar.JarInputStream;
-import java.util.jar.JarOutputStream;
-
-import groovy.grape.Grape;
-import groovy.lang.GroovyClassLoader;
-import org.apache.camel.main.KameletMain;
-import org.apache.camel.main.MavenGav;
-import org.apache.camel.util.FileUtil;
-import org.apache.camel.util.IOHelper;
-import org.apache.camel.util.OrderedProperties;
-import org.apache.camel.util.StringHelper;
-import picocli.CommandLine;
-import picocli.CommandLine.Command;
-import picocli.CommandLine.Option;
-
-@Command(name = "uber-jar", description = "Package application as a single uber-jar")
-@Deprecated
-class UberJar extends CamelCommand {
-
- private static final String BUILD_DIR = ".camel-jbang/work";
- private static final String CLASSES_DIR = BUILD_DIR + "/classes";
- private static final String LIB_DIR = BUILD_DIR + "/lib";
- private static final String BOOTSTRAP_DIR = BUILD_DIR + "/bootstrap";
-
- private static final String[] SETTINGS_PROP_SOURCE_KEYS = new String[] {
- "camel.main.routesIncludePattern",
- "camel.component.properties.location",
- "camel.component.kamelet.location",
- "camel.jbang.classpathFiles"
- };
-
- @CommandLine.Option(names = { "-j", "--jar" }, defaultValue = "camel-runner.jar", description = "Jar filename")
- private String jar = "camel-runner.jar";
-
- @Option(names = { "--fresh" }, description = "Make sure we use fresh (i.e. non-cached) resources")
- private boolean fresh;
-
- public UberJar(CamelJBangMain main) {
- super(main);
- }
-
- @Override
- public Integer call() throws Exception {
- File profile = new File(getProfile() + ".properties");
-
- // the settings file has information what to package in uber-jar so we need to read it from the run command
- File settings = new File(Run.WORK_DIR + "/" + Run.RUN_SETTINGS_FILE);
- if (fresh || !settings.exists()) {
- // allow to automatic build
- System.out.println("Generating fresh run data");
- int silent = runSilently();
- if (silent != 0) {
- return silent;
- }
- } else {
- System.out.println("Reusing existing run data");
- }
-
- System.out.println("Packaging " + jar);
- File buildDir = new File(BUILD_DIR);
- FileUtil.removeDir(buildDir);
- buildDir.mkdirs();
-
- // resolve all the needed dependencies
- ClassLoader parentCL = KameletMain.class.getClassLoader();
- final GroovyClassLoader gcl = new GroovyClassLoader(parentCL);
-
- // application sources
- buildDir = new File(CLASSES_DIR);
- buildDir.mkdirs();
- copySourceFiles(settings, buildDir);
- // work sources
- copyWorkFiles(Run.WORK_DIR, buildDir);
- // settings and profile
- copySettingsAndProfile(settings, profile);
- // log4j configuration
- InputStream is = UberJar.class.getResourceAsStream("/log4j2.properties");
- safeCopy(is, new File(CLASSES_DIR, "log4j2.properties"));
- is = UberJar.class.getResourceAsStream("/log4j2.component.properties");
- safeCopy(is, new File(CLASSES_DIR, "log4j2.component.properties"));
-
- List<String> lines = Files.readAllLines(settings.toPath());
- String version = null;
-
- // include log4j dependencies
- lines.add("dependency=org.apache.logging.log4j:log4j-api:2.17.2");
- lines.add("dependency=org.apache.logging.log4j:log4j-core:2.17.2");
- lines.add("dependency=org.apache.logging.log4j:log4j-slf4j-impl:2.17.2");
- lines.add("dependency=org.fusesource.jansi:jansi:2.4.0");
- // nested jar classloader
- lines.add("dependency=com.needhamsoftware.unojar:core:1.0.2");
-
- // include camel-kamelet-main/camel-uberjar-main as they are needed
- Optional<MavenGav> first = lines.stream()
- .filter(l -> l.startsWith("dependency="))
- .map(l -> MavenGav.parseGav(null, StringHelper.after(l, "dependency=")))
- .filter(g -> "org.apache.camel".equals(g.getGroupId()))
- .findFirst();
- if (first.isPresent()) {
- version = first.get().getVersion();
- lines.add(0, "dependency=mvn:org.apache.camel:camel-kamelet-main:" + version);
- lines.add(0, "dependency=mvn:org.apache.camel:camel-uberjar-main:" + version);
- }
- if (version == null) {
- throw new IllegalStateException("Cannot determine Camel version");
- }
-
- // JARs should be in lib sub-folder
- buildDir = new File(LIB_DIR);
- buildDir.mkdirs();
- for (String l : lines) {
- // support 3rd party maven repositories
- File grapeConfig = new File(".camel-jbang/camelGrapeConfig.xml");
- if (grapeConfig.exists()) {
- System.setProperty("grape.config", grapeConfig.getAbsolutePath());
- }
-
- if (l.startsWith("dependency=")) {
- l = StringHelper.after(l, "dependency=");
- MavenGav gav = MavenGav.parseGav(null, l);
- Map<String, Object> map = new HashMap<>();
- map.put("classLoader", gcl);
- map.put("group", gav.getGroupId());
- map.put("module", gav.getArtifactId());
- map.put("version", gav.getVersion());
- map.put("classifier", "");
-
- URI[] u = Grape.resolve(map, map);
- copyJars(u, buildDir);
- }
- }
-
- // MANIFEST.MF
- manifest(version);
-
- // app sources as classes
- applicationClasses();
-
- // boostrap classloader
- boostrapClassLoader();
-
- // and build uber jar
- archiveUberJar();
-
- // cleanup work folder
- FileUtil.removeDir(new File(BUILD_DIR));
-
- return 0;
- }
-
- private Integer runSilently() throws Exception {
- Run run = new Run(getMain());
- Integer code = run.runSilent();
- return code;
- }
-
- private void copySettingsAndProfile(File settings, File profile) throws Exception {
- // the settings file itself
- doCopySettingsAndProfile(settings, new File(CLASSES_DIR, Run.RUN_SETTINGS_FILE), null);
- // and profile if exists
- if (profile.exists()) {
- // skip these
- Predicate<String> skip = line -> line.startsWith("camel.main.routesIncludePattern")
- || line.startsWith("camel.jbang.classpathFiles")
- || line.startsWith("camel.component.kamelet.location")
- || line.startsWith("camel.component.properties.location");
- doCopySettingsAndProfile(profile, new File(CLASSES_DIR, profile.getName()), skip);
- }
- }
-
- private void doCopySettingsAndProfile(File source, File target, Predicate<String> skipKeys) throws Exception {
- // need to adjust file: scheme to classpath as the files are now embedded in the uber-jar directly
- List<String> lines = Files.readAllLines(source.toPath());
- FileOutputStream fos = new FileOutputStream(target, false);
- for (String line : lines) {
- line = line.trim();
- if (line.startsWith("camel.main.routesCompileDirectory")) {
- continue; // skip as uber-jar should not compile to disk
- }
- if (skipKeys != null && skipKeys.test(line)) {
- continue;
- }
- for (String k : SETTINGS_PROP_SOURCE_KEYS) {
- line = fileToClasspath(line, k);
- }
- fos.write(line.getBytes(StandardCharsets.UTF_8));
- fos.write("\n".getBytes(StandardCharsets.UTF_8));
- }
- IOHelper.close(fos);
- }
-
- private static String fileToClasspath(String line, String key) {
- String value = StringHelper.after(line, key + "=");
- if (value != null) {
- // file:foo.java is compiled to .class so we need to replace it
- value = value.replaceAll("file:", "classpath:");
- value = value.replaceAll(".java", ".class");
- // special fix for generated files inside .camel-jbang
- value = value.replaceAll("classpath:.camel-jbang/", "classpath:");
- line = key + "=" + value;
- }
- return line;
- }
-
- private void boostrapClassLoader() throws Exception {
- File dir = new File(BOOTSTRAP_DIR);
- dir.mkdirs();
-
- // nested-jar classloader is named core
- File bootstrapJar = new File(LIB_DIR, "/core-1.0.2.jar");
-
- JarInputStream jis = new JarInputStream(new FileInputStream(bootstrapJar));
- JarEntry je;
- while ((je = jis.getNextJarEntry()) != null) {
- if (!je.isDirectory()) {
- String name = je.getName();
- if (name.endsWith(".class")) {
- name = BOOTSTRAP_DIR + "/" + name;
- String path = FileUtil.onlyPath(name);
- // ensure sub-folders are created
- new File(path).mkdirs();
- FileOutputStream fos = new FileOutputStream(name);
- IOHelper.copy(jis, fos);
- IOHelper.close(fos);
- }
- }
- }
-
- // delete to avoid duplicate
- bootstrapJar.delete();
- }
-
- private void applicationClasses() throws Exception {
- // build application.jar that has the user source
- JarOutputStream jos = new JarOutputStream(new FileOutputStream(LIB_DIR + "/application.jar", false));
-
- File dir = new File(CLASSES_DIR);
- if (dir.exists() && dir.isDirectory()) {
- File[] files = dir.listFiles();
- if (files != null) {
- for (File f : files) {
- JarEntry je = new JarEntry(f.getName());
- jos.putNextEntry(je);
- IOHelper.copyAndCloseInput(new FileInputStream(f), jos);
- }
- }
- }
-
- jos.flush();
- IOHelper.close(jos);
- }
-
- private void manifest(String version) throws Exception {
- InputStream is = Init.class.getClassLoader().getResourceAsStream("templates/manifest.tmpl");
- if (is == null) {
- throw new FileNotFoundException("templates/manifest.tmpl");
- }
- String context = IOHelper.loadText(is);
- IOHelper.close(is);
- context = context.replaceFirst("\\{\\{ \\.Version }}", version);
-
- File f = new File(BUILD_DIR, "META-INF");
- f.mkdirs();
- IOHelper.writeText(context, new FileOutputStream(f + "/MANIFEST.MF", false));
- }
-
- private void archiveUberJar() throws Exception {
- JarOutputStream jos = new JarOutputStream(new FileOutputStream(jar, false));
-
- // include manifest first
- File fm = new File(BUILD_DIR, "META-INF/MANIFEST.MF");
- JarEntry je = new JarEntry("META-INF/MANIFEST.MF");
- jos.putNextEntry(je);
- IOHelper.copyAndCloseInput(new FileInputStream(fm), jos);
- // include boostrap
- for (File fl : new File(BOOTSTRAP_DIR, "com/needhamsoftware/unojar").listFiles()) {
- if (fl.isFile()) {
- je = new JarEntry("com/needhamsoftware/unojar/" + fl.getName());
- jos.putNextEntry(je);
- IOHelper.copyAndCloseInput(new FileInputStream(fl), jos);
- }
- }
- // include JARs
- for (File fl : new File(LIB_DIR).listFiles()) {
- if (fl.isFile()) {
- if (fl.getName().startsWith("camel-uberjar-main")) {
- // must be in main folder
- je = new JarEntry("main/" + fl.getName());
- } else {
- je = new JarEntry("lib/" + fl.getName());
- }
- jos.putNextEntry(je);
- IOHelper.copyAndCloseInput(new FileInputStream(fl), jos);
- }
- }
-
- jos.flush();
- IOHelper.close(jos);
- }
-
- private void copySourceFiles(File settings, File target) throws Exception {
- // read the settings file and find the files to copy
- OrderedProperties prop = new OrderedProperties();
- prop.load(new FileInputStream(settings));
-
- for (String k : SETTINGS_PROP_SOURCE_KEYS) {
- String files = prop.getProperty(k);
- if (files != null) {
- for (String f : files.split(",")) {
- String scheme = getScheme(f);
- if (scheme != null) {
- f = f.substring(scheme.length() + 1);
- }
- File source = new File(f);
- File out = new File(target, source.getName());
- safeCopy(source, out, true);
- }
- }
- }
- }
-
- private void copyWorkFiles(String work, File target) throws Exception {
- String profile = getProfile() + ".properties";
- File[] files = new File(work).listFiles();
- if (files != null) {
- for (File source : files) {
- // only copy files and skip settings/profile file as we do this later specially
- if (source.isDirectory() || source.getName().equals(Run.RUN_SETTINGS_FILE)
- || source.getName().equals(profile)) {
- continue;
- }
- File out = new File(target, source.getName());
- safeCopy(source, out, true);
- }
- }
- }
-
- private void copyJars(URI[] uris, File target) throws Exception {
- for (URI u : uris) {
- File f = new File(u.toURL().getFile());
- File out = new File(target, f.getName());
- safeCopy(f, out, false);
- }
- }
-
- private void safeCopy(File source, File target, boolean override) throws Exception {
- if (!source.exists()) {
- return;
- }
-
- if (!target.exists()) {
- Files.copy(source.toPath(), target.toPath());
- } else if (override) {
- Files.copy(source.toPath(), target.toPath(),
- StandardCopyOption.REPLACE_EXISTING);
- }
- }
-
- private void safeCopy(InputStream source, File target) throws Exception {
- if (source == null) {
- return;
- }
-
- if (!target.exists()) {
- Files.copy(source, target.toPath());
- }
- }
-
- private static String getScheme(String name) {
- int pos = name.indexOf(":");
- if (pos != -1) {
- return name.substring(0, pos);
- }
- return null;
- }
-
-}
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Undeploy.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Undeploy.java
deleted file mode 100644
index 834bfe5a69b..00000000000
--- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Undeploy.java
+++ /dev/null
@@ -1,84 +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"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://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.
- */
-package org.apache.camel.dsl.jbang.core.commands;
-
-import java.util.Map;
-
-import io.fabric8.kubernetes.client.DefaultKubernetesClient;
-import io.fabric8.kubernetes.client.KubernetesClient;
-import io.fabric8.openshift.client.DefaultOpenShiftClient;
-import io.fabric8.openshift.client.OpenShiftClient;
-import picocli.CommandLine;
-
-@CommandLine.Command(name = "undeploy", description = "Undeploy resources from Kubernetes, OpenShift, Minikube")
-@Deprecated
-public class Undeploy extends CamelCommand {
-
- @CommandLine.Option(names = { "--namespace" }, required = true, description = "Namespace", defaultValue = "default")
- private String namespace;
- @CommandLine.Option(names = { "--name" }, description = "Application name", required = true)
- private String name;
- @CommandLine.Option(names = { "--version" }, description = "Application version", required = true)
- private String version;
- @CommandLine.Option(names = { "--openshift" }, description = "Target is openshift")
- private boolean openshift;
- @CommandLine.Option(names = { "--server" }, description = "Master URL")
- private String server;
- @CommandLine.Option(names = { "--token" }, description = "Token")
- private String token;
- @CommandLine.Option(names = { "-u", "--username" }, description = "Username")
- private String username;
- @CommandLine.Option(names = { "-p", "--password" }, description = "Password")
- private String password;
-
- public Undeploy(CamelJBangMain main) {
- super(main);
- }
-
- @Override
- public Integer call() throws Exception {
- Map labels = KubernetesHelper.getLabels(name, version);
- if (openshift) {
- try (OpenShiftClient client
- = new DefaultOpenShiftClient(KubernetesHelper.getOpenShiftConfig(server, username, password, token))) {
- System.out.println("Deleting Routes...");
- client.routes().inNamespace(namespace).withLabels(labels).delete();
- System.out.println("Deleting Service...");
- client.services().inNamespace(namespace).withLabels(labels).delete();
- System.out.println("Deleting Deployment...");
- client.apps().deployments().inNamespace(namespace).withLabels(labels).delete();
- System.out.println("Deleting ImageStream...");
- client.imageStreams().inNamespace(namespace).withLabels(labels).delete();
- System.out.println("Deleting BuildConfig...");
- client.buildConfigs().inNamespace(namespace).withLabels(labels).delete();
- }
- } else {
- try (KubernetesClient client
- = new DefaultKubernetesClient(KubernetesHelper.getConfig(server, username, password, token))) {
- System.out.println("Deleting Service...");
- client.services().inNamespace(namespace).withLabels(labels).delete();
- System.out.println("Deleting Deployment...");
- client.apps().deployments().inNamespace(namespace).withLabels(labels).delete();
- } catch (Exception ex) {
- System.out.println("Error undeploy " + ex.getMessage());
- ex.printStackTrace();
- }
- }
- return 0;
- }
-
-}