This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch camel-4.8.x in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-4.8.x by this push: new b2e1317a29a CAMEL-21278 : Camel Jbang Kubernetes plugin - add builders to model (#16731) b2e1317a29a is described below commit b2e1317a29a9e863685c4dde73d244bc88d85e4d Author: Gaƫlle Fournier <gaelle.fournier.w...@gmail.com> AuthorDate: Wed Jan 8 07:15:27 2025 +0100 CAMEL-21278 : Camel Jbang Kubernetes plugin - add builders to model (#16731) --- .../commands/kubernetes/traits/OpenApiTrait.java | 13 +- .../commands/kubernetes/traits/TraitHelper.java | 4 +- .../kubernetes/traits/model/AddonsBuilder.java | 45 +++++ .../kubernetes/traits/model/CamelBuilder.java | 48 +++++ .../kubernetes/traits/model/ContainerBuilder.java | 188 +++++++++++++++++++ .../traits/model/EnvironmentBuilder.java | 48 +++++ .../kubernetes/traits/model/IngressBuilder.java | 91 +++++++++ .../kubernetes/traits/model/KnativeBuilder.java | 118 ++++++++++++ .../traits/model/KnativeServiceBuilder.java | 111 +++++++++++ .../kubernetes/traits/model/MountBuilder.java | 83 +++++++++ .../kubernetes/traits/model/OpenapiBuilder.java | 48 +++++ .../kubernetes/traits/model/RouteBuilder.java | 126 +++++++++++++ .../traits/model/ServiceBindingBuilder.java | 48 +++++ .../kubernetes/traits/model/ServiceBuilder.java | 53 ++++++ .../kubernetes/traits/model/TraitsBuilder.java | 206 +++++++++++++++++++++ 15 files changed, 1220 insertions(+), 10 deletions(-) diff --git a/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/traits/OpenApiTrait.java b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/traits/OpenApiTrait.java index 4f400d32e76..4cc1b719ee6 100644 --- a/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/traits/OpenApiTrait.java +++ b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/traits/OpenApiTrait.java @@ -20,9 +20,10 @@ package org.apache.camel.dsl.jbang.core.commands.kubernetes.traits; import java.util.Optional; import org.apache.camel.RuntimeCamelException; -import org.apache.camel.dsl.jbang.core.commands.kubernetes.traits.model.Mount; +import org.apache.camel.dsl.jbang.core.commands.kubernetes.traits.model.MountBuilder; import org.apache.camel.dsl.jbang.core.commands.kubernetes.traits.model.Openapi; import org.apache.camel.dsl.jbang.core.commands.kubernetes.traits.model.Traits; +import org.apache.camel.dsl.jbang.core.commands.kubernetes.traits.model.TraitsBuilder; import org.apache.camel.util.ObjectHelper; public class OpenApiTrait extends BaseTrait { @@ -53,13 +54,9 @@ public class OpenApiTrait extends BaseTrait { if (ObjectHelper.isNotEmpty(openApiTrait.getConfigmaps())) { MountTrait delegate = new MountTrait(); - // ugly code - // TODO : builder or fluent - Traits traits = new Traits(); - Mount mount = new Mount(); - mount.setResources(openApiTrait.getConfigmaps()); - traits.setMount(mount); - delegate.apply(traits, context); + delegate.apply( + TraitsBuilder.traits().withMount(MountBuilder.mount().withResources(openApiTrait.getConfigmaps())).build(), + context); } } } diff --git a/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/traits/TraitHelper.java b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/traits/TraitHelper.java index 153a1616b26..f8d3461f5c5 100644 --- a/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/traits/TraitHelper.java +++ b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/traits/TraitHelper.java @@ -34,7 +34,7 @@ import org.apache.camel.catalog.CamelCatalog; import org.apache.camel.dsl.jbang.core.commands.kubernetes.KubernetesHelper; import org.apache.camel.dsl.jbang.core.commands.kubernetes.MetadataHelper; import org.apache.camel.dsl.jbang.core.commands.kubernetes.support.SourceMetadata; -import org.apache.camel.dsl.jbang.core.commands.kubernetes.traits.model.Addons; +import org.apache.camel.dsl.jbang.core.commands.kubernetes.traits.model.AddonsBuilder; import org.apache.camel.dsl.jbang.core.commands.kubernetes.traits.model.Camel; import org.apache.camel.dsl.jbang.core.commands.kubernetes.traits.model.Container; import org.apache.camel.dsl.jbang.core.commands.kubernetes.traits.model.Environment; @@ -140,7 +140,7 @@ public final class TraitHelper { for (Map.Entry<String, Map<String, Object>> traitConfig : traitConfigMap.entrySet()) { if (!knownTraits.contains(traitConfig.getKey())) { traitModel.getAddons().put(traitConfig.getKey(), - new Addons(traitConfig.getValue())); + new AddonsBuilder().withAdditionalProperties(traitConfig.getValue()).build()); } } } diff --git a/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/traits/model/AddonsBuilder.java b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/traits/model/AddonsBuilder.java new file mode 100644 index 00000000000..e36c62e67fa --- /dev/null +++ b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/traits/model/AddonsBuilder.java @@ -0,0 +1,45 @@ +/* + * 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.kubernetes.traits.model; + +import java.util.Map; + +public final class AddonsBuilder { + private Map<String, Object> additionalProperties; + + public AddonsBuilder() { + } + + public AddonsBuilder(Addons other) { + this.additionalProperties = other.getAdditionalProperties(); + } + + public static AddonsBuilder addons() { + return new AddonsBuilder(); + } + + public AddonsBuilder withAdditionalProperties(Map<String, Object> additionalProperties) { + this.additionalProperties = additionalProperties; + return this; + } + + public Addons build() { + Addons addons = new Addons(); + addons.setAdditionalProperties(additionalProperties); + return addons; + } +} diff --git a/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/traits/model/CamelBuilder.java b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/traits/model/CamelBuilder.java new file mode 100644 index 00000000000..9fc6c5bb945 --- /dev/null +++ b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/traits/model/CamelBuilder.java @@ -0,0 +1,48 @@ +/* + * 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.kubernetes.traits.model; + +import java.util.List; + +public final class CamelBuilder { + private Boolean enabled; + private List<String> properties; + + private CamelBuilder() { + } + + public static CamelBuilder camel() { + return new CamelBuilder(); + } + + public CamelBuilder withEnabled(Boolean enabled) { + this.enabled = enabled; + return this; + } + + public CamelBuilder withProperties(List<String> properties) { + this.properties = properties; + return this; + } + + public Camel build() { + Camel camel = new Camel(); + camel.setEnabled(enabled); + camel.setProperties(properties); + return camel; + } +} diff --git a/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/traits/model/ContainerBuilder.java b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/traits/model/ContainerBuilder.java new file mode 100644 index 00000000000..c13bec0e0e7 --- /dev/null +++ b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/traits/model/ContainerBuilder.java @@ -0,0 +1,188 @@ +/* + * 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.kubernetes.traits.model; + +import java.util.List; + +public final class ContainerBuilder { + private Boolean allowPrivilegeEscalation; + private Boolean auto; + private List<String> capabilitiesAdd; + private List<String> capabilitiesDrop; + private Boolean enabled; + private Boolean expose; + private String image; + private Container.ImagePullPolicy imagePullPolicy; + private List<String> imagePullSecrets; + private boolean imagePush; + private String limitCPU; + private String limitMemory; + private String name; + private Long port; + private String portName; + private String requestCPU; + private String requestMemory; + private Boolean runAsNonRoot; + private Long runAsUser; + private Container.SeccompProfileType seccompProfileType; + private Long servicePort; + private String servicePortName; + + private ContainerBuilder() { + } + + public static ContainerBuilder container() { + return new ContainerBuilder(); + } + + public ContainerBuilder withAllowPrivilegeEscalation(Boolean allowPrivilegeEscalation) { + this.allowPrivilegeEscalation = allowPrivilegeEscalation; + return this; + } + + public ContainerBuilder withAuto(Boolean auto) { + this.auto = auto; + return this; + } + + public ContainerBuilder withCapabilitiesAdd(List<String> capabilitiesAdd) { + this.capabilitiesAdd = capabilitiesAdd; + return this; + } + + public ContainerBuilder withCapabilitiesDrop(List<String> capabilitiesDrop) { + this.capabilitiesDrop = capabilitiesDrop; + return this; + } + + public ContainerBuilder withEnabled(Boolean enabled) { + this.enabled = enabled; + return this; + } + + public ContainerBuilder withExpose(Boolean expose) { + this.expose = expose; + return this; + } + + public ContainerBuilder withImage(String image) { + this.image = image; + return this; + } + + public ContainerBuilder withImagePullPolicy(Container.ImagePullPolicy imagePullPolicy) { + this.imagePullPolicy = imagePullPolicy; + return this; + } + + public ContainerBuilder withImagePullSecrets(List<String> imagePullSecrets) { + this.imagePullSecrets = imagePullSecrets; + return this; + } + + public ContainerBuilder withImagePush(boolean imagePush) { + this.imagePush = imagePush; + return this; + } + + public ContainerBuilder withLimitCPU(String limitCPU) { + this.limitCPU = limitCPU; + return this; + } + + public ContainerBuilder withLimitMemory(String limitMemory) { + this.limitMemory = limitMemory; + return this; + } + + public ContainerBuilder withName(String name) { + this.name = name; + return this; + } + + public ContainerBuilder withPort(Long port) { + this.port = port; + return this; + } + + public ContainerBuilder withPortName(String portName) { + this.portName = portName; + return this; + } + + public ContainerBuilder withRequestCPU(String requestCPU) { + this.requestCPU = requestCPU; + return this; + } + + public ContainerBuilder withRequestMemory(String requestMemory) { + this.requestMemory = requestMemory; + return this; + } + + public ContainerBuilder withRunAsNonRoot(Boolean runAsNonRoot) { + this.runAsNonRoot = runAsNonRoot; + return this; + } + + public ContainerBuilder withRunAsUser(Long runAsUser) { + this.runAsUser = runAsUser; + return this; + } + + public ContainerBuilder withSeccompProfileType(Container.SeccompProfileType seccompProfileType) { + this.seccompProfileType = seccompProfileType; + return this; + } + + public ContainerBuilder withServicePort(Long servicePort) { + this.servicePort = servicePort; + return this; + } + + public ContainerBuilder withServicePortName(String servicePortName) { + this.servicePortName = servicePortName; + return this; + } + + public Container build() { + Container container = new Container(); + container.setAllowPrivilegeEscalation(allowPrivilegeEscalation); + container.setAuto(auto); + container.setCapabilitiesAdd(capabilitiesAdd); + container.setCapabilitiesDrop(capabilitiesDrop); + container.setEnabled(enabled); + container.setExpose(expose); + container.setImage(image); + container.setImagePullPolicy(imagePullPolicy); + container.setImagePullSecrets(imagePullSecrets); + container.setImagePush(imagePush); + container.setLimitCPU(limitCPU); + container.setLimitMemory(limitMemory); + container.setName(name); + container.setPort(port); + container.setPortName(portName); + container.setRequestCPU(requestCPU); + container.setRequestMemory(requestMemory); + container.setRunAsNonRoot(runAsNonRoot); + container.setRunAsUser(runAsUser); + container.setSeccompProfileType(seccompProfileType); + container.setServicePort(servicePort); + container.setServicePortName(servicePortName); + return container; + } +} diff --git a/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/traits/model/EnvironmentBuilder.java b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/traits/model/EnvironmentBuilder.java new file mode 100644 index 00000000000..bba35a99cbf --- /dev/null +++ b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/traits/model/EnvironmentBuilder.java @@ -0,0 +1,48 @@ +/* + * 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.kubernetes.traits.model; + +import java.util.List; + +public final class EnvironmentBuilder { + private Boolean enabled; + private List<String> vars; + + private EnvironmentBuilder() { + } + + public static EnvironmentBuilder environment() { + return new EnvironmentBuilder(); + } + + public EnvironmentBuilder withEnabled(Boolean enabled) { + this.enabled = enabled; + return this; + } + + public EnvironmentBuilder withVars(List<String> vars) { + this.vars = vars; + return this; + } + + public Environment build() { + Environment environment = new Environment(); + environment.setEnabled(enabled); + environment.setVars(vars); + return environment; + } +} diff --git a/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/traits/model/IngressBuilder.java b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/traits/model/IngressBuilder.java new file mode 100644 index 00000000000..1176ec06585 --- /dev/null +++ b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/traits/model/IngressBuilder.java @@ -0,0 +1,91 @@ +/* + * 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.kubernetes.traits.model; + +import java.util.List; +import java.util.Map; + +public final class IngressBuilder { + private Map<String, String> annotations; + private Boolean auto; + private Boolean enabled; + private String host; + private String path; + private Ingress.PathType pathType; + private List<String> tlsHosts; + private String tlsSecretName; + + private IngressBuilder() { + } + + public static IngressBuilder ingress() { + return new IngressBuilder(); + } + + public IngressBuilder withAnnotations(Map<String, String> annotations) { + this.annotations = annotations; + return this; + } + + public IngressBuilder withAuto(Boolean auto) { + this.auto = auto; + return this; + } + + public IngressBuilder withEnabled(Boolean enabled) { + this.enabled = enabled; + return this; + } + + public IngressBuilder withHost(String host) { + this.host = host; + return this; + } + + public IngressBuilder withPath(String path) { + this.path = path; + return this; + } + + public IngressBuilder withPathType(Ingress.PathType pathType) { + this.pathType = pathType; + return this; + } + + public IngressBuilder withTlsHosts(List<String> tlsHosts) { + this.tlsHosts = tlsHosts; + return this; + } + + public IngressBuilder withTlsSecretName(String tlsSecretName) { + this.tlsSecretName = tlsSecretName; + return this; + } + + public Ingress build() { + Ingress ingress = new Ingress(); + ingress.setAnnotations(annotations); + ingress.setAuto(auto); + ingress.setEnabled(enabled); + ingress.setHost(host); + ingress.setPath(path); + ingress.setPathType(pathType); + ingress.setTlsHosts(tlsHosts); + ingress.setTlsSecretName(tlsSecretName); + return ingress; + } +} diff --git a/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/traits/model/KnativeBuilder.java b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/traits/model/KnativeBuilder.java new file mode 100644 index 00000000000..9167cab166e --- /dev/null +++ b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/traits/model/KnativeBuilder.java @@ -0,0 +1,118 @@ +/* + * 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.kubernetes.traits.model; + +import java.util.List; + +public final class KnativeBuilder { + private Boolean auto; + private List<String> channelSinks; + private List<String> channelSources; + private String config; + private Boolean enabled; + private List<String> endpointSinks; + private List<String> endpointSources; + private List<String> eventSinks; + private List<String> eventSources; + private Boolean filterEventType; + private List<String> filters; + private Boolean sinkBinding; + + private KnativeBuilder() { + } + + public static KnativeBuilder knative() { + return new KnativeBuilder(); + } + + public KnativeBuilder withAuto(Boolean auto) { + this.auto = auto; + return this; + } + + public KnativeBuilder withChannelSinks(List<String> channelSinks) { + this.channelSinks = channelSinks; + return this; + } + + public KnativeBuilder withChannelSources(List<String> channelSources) { + this.channelSources = channelSources; + return this; + } + + public KnativeBuilder withConfig(String config) { + this.config = config; + return this; + } + + public KnativeBuilder withEnabled(Boolean enabled) { + this.enabled = enabled; + return this; + } + + public KnativeBuilder withEndpointSinks(List<String> endpointSinks) { + this.endpointSinks = endpointSinks; + return this; + } + + public KnativeBuilder withEndpointSources(List<String> endpointSources) { + this.endpointSources = endpointSources; + return this; + } + + public KnativeBuilder withEventSinks(List<String> eventSinks) { + this.eventSinks = eventSinks; + return this; + } + + public KnativeBuilder withEventSources(List<String> eventSources) { + this.eventSources = eventSources; + return this; + } + + public KnativeBuilder withFilterEventType(Boolean filterEventType) { + this.filterEventType = filterEventType; + return this; + } + + public KnativeBuilder withFilters(List<String> filters) { + this.filters = filters; + return this; + } + + public KnativeBuilder withSinkBinding(Boolean sinkBinding) { + this.sinkBinding = sinkBinding; + return this; + } + + public Knative build() { + Knative knative = new Knative(); + knative.setAuto(auto); + knative.setChannelSinks(channelSinks); + knative.setChannelSources(channelSources); + knative.setConfig(config); + knative.setEnabled(enabled); + knative.setEndpointSinks(endpointSinks); + knative.setEndpointSources(endpointSources); + knative.setEventSinks(eventSinks); + knative.setEventSources(eventSources); + knative.setFilterEventType(filterEventType); + knative.setFilters(filters); + knative.setSinkBinding(sinkBinding); + return knative; + } +} diff --git a/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/traits/model/KnativeServiceBuilder.java b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/traits/model/KnativeServiceBuilder.java new file mode 100644 index 00000000000..92cf6f504e3 --- /dev/null +++ b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/traits/model/KnativeServiceBuilder.java @@ -0,0 +1,111 @@ +/* + * 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.kubernetes.traits.model; + +import java.util.Map; + +public final class KnativeServiceBuilder { + private Map<String, String> annotations; + private Boolean auto; + private String autoscalingMetric; + private Long autoscalingTarget; + private KnativeService.Class _class; + private Boolean enabled; + private Long maxScale; + private Long minScale; + private String rolloutDuration; + private Long timeoutSeconds; + private KnativeService.Visibility visibility; + + private KnativeServiceBuilder() { + } + + public static KnativeServiceBuilder knativeService() { + return new KnativeServiceBuilder(); + } + + public KnativeServiceBuilder withAnnotations(Map<String, String> annotations) { + this.annotations = annotations; + return this; + } + + public KnativeServiceBuilder withAuto(Boolean auto) { + this.auto = auto; + return this; + } + + public KnativeServiceBuilder withAutoscalingMetric(String autoscalingMetric) { + this.autoscalingMetric = autoscalingMetric; + return this; + } + + public KnativeServiceBuilder withAutoscalingTarget(Long autoscalingTarget) { + this.autoscalingTarget = autoscalingTarget; + return this; + } + + public KnativeServiceBuilder with_class(KnativeService.Class _class) { + this._class = _class; + return this; + } + + public KnativeServiceBuilder withEnabled(Boolean enabled) { + this.enabled = enabled; + return this; + } + + public KnativeServiceBuilder withMaxScale(Long maxScale) { + this.maxScale = maxScale; + return this; + } + + public KnativeServiceBuilder withMinScale(Long minScale) { + this.minScale = minScale; + return this; + } + + public KnativeServiceBuilder withRolloutDuration(String rolloutDuration) { + this.rolloutDuration = rolloutDuration; + return this; + } + + public KnativeServiceBuilder withTimeoutSeconds(Long timeoutSeconds) { + this.timeoutSeconds = timeoutSeconds; + return this; + } + + public KnativeServiceBuilder withVisibility(KnativeService.Visibility visibility) { + this.visibility = visibility; + return this; + } + + public KnativeService build() { + KnativeService knativeService = new KnativeService(); + knativeService.setAnnotations(annotations); + knativeService.setAuto(auto); + knativeService.setAutoscalingMetric(autoscalingMetric); + knativeService.setAutoscalingTarget(autoscalingTarget); + knativeService.set_class(_class); + knativeService.setEnabled(enabled); + knativeService.setMaxScale(maxScale); + knativeService.setMinScale(minScale); + knativeService.setRolloutDuration(rolloutDuration); + knativeService.setTimeoutSeconds(timeoutSeconds); + knativeService.setVisibility(visibility); + return knativeService; + } +} diff --git a/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/traits/model/MountBuilder.java b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/traits/model/MountBuilder.java new file mode 100644 index 00000000000..8c58f7dd53f --- /dev/null +++ b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/traits/model/MountBuilder.java @@ -0,0 +1,83 @@ +/* + * 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.kubernetes.traits.model; + +import java.util.List; + +public final class MountBuilder { + private List<String> configs; + private List<String> emptyDirs; + private Boolean enabled; + private Boolean hotReload; + private List<String> resources; + private Boolean scanKameletsImplicitLabelSecrets; + private List<String> volumes; + + private MountBuilder() { + } + + public static MountBuilder mount() { + return new MountBuilder(); + } + + public MountBuilder withConfigs(List<String> configs) { + this.configs = configs; + return this; + } + + public MountBuilder withEmptyDirs(List<String> emptyDirs) { + this.emptyDirs = emptyDirs; + return this; + } + + public MountBuilder withEnabled(Boolean enabled) { + this.enabled = enabled; + return this; + } + + public MountBuilder withHotReload(Boolean hotReload) { + this.hotReload = hotReload; + return this; + } + + public MountBuilder withResources(List<String> resources) { + this.resources = resources; + return this; + } + + public MountBuilder withScanKameletsImplicitLabelSecrets(Boolean scanKameletsImplicitLabelSecrets) { + this.scanKameletsImplicitLabelSecrets = scanKameletsImplicitLabelSecrets; + return this; + } + + public MountBuilder withVolumes(List<String> volumes) { + this.volumes = volumes; + return this; + } + + public Mount build() { + Mount mount = new Mount(); + mount.setConfigs(configs); + mount.setEmptyDirs(emptyDirs); + mount.setEnabled(enabled); + mount.setHotReload(hotReload); + mount.setResources(resources); + mount.setScanKameletsImplicitLabelSecrets(scanKameletsImplicitLabelSecrets); + mount.setVolumes(volumes); + return mount; + } +} diff --git a/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/traits/model/OpenapiBuilder.java b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/traits/model/OpenapiBuilder.java new file mode 100644 index 00000000000..1463a89e9e7 --- /dev/null +++ b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/traits/model/OpenapiBuilder.java @@ -0,0 +1,48 @@ +/* + * 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.kubernetes.traits.model; + +import java.util.List; + +public final class OpenapiBuilder { + private List<String> configmaps; + private Boolean enabled; + + private OpenapiBuilder() { + } + + public static OpenapiBuilder openapi() { + return new OpenapiBuilder(); + } + + public OpenapiBuilder withConfigmaps(List<String> configmaps) { + this.configmaps = configmaps; + return this; + } + + public OpenapiBuilder withEnabled(Boolean enabled) { + this.enabled = enabled; + return this; + } + + public Openapi build() { + Openapi openapi = new Openapi(); + openapi.setConfigmaps(configmaps); + openapi.setEnabled(enabled); + return openapi; + } +} diff --git a/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/traits/model/RouteBuilder.java b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/traits/model/RouteBuilder.java new file mode 100644 index 00000000000..28d4ac06837 --- /dev/null +++ b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/traits/model/RouteBuilder.java @@ -0,0 +1,126 @@ +/* + * 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.kubernetes.traits.model; + +import java.util.Map; + +public final class RouteBuilder { + private Map<String, String> annotations; + private Boolean enabled; + private String host; + private String tlsCACertificate; + private String tlsCACertificateSecret; + private String tlsCertificate; + private String tlsCertificateSecret; + private String tlsDestinationCACertificate; + private String tlsDestinationCACertificateSecret; + private Route.TlsInsecureEdgeTerminationPolicy tlsInsecureEdgeTerminationPolicy; + private String tlsKey; + private String tlsKeySecret; + private Route.TlsTermination tlsTermination; + + private RouteBuilder() { + } + + public static RouteBuilder route() { + return new RouteBuilder(); + } + + public RouteBuilder withAnnotations(Map<String, String> annotations) { + this.annotations = annotations; + return this; + } + + public RouteBuilder withEnabled(Boolean enabled) { + this.enabled = enabled; + return this; + } + + public RouteBuilder withHost(String host) { + this.host = host; + return this; + } + + public RouteBuilder withTlsCACertificate(String tlsCACertificate) { + this.tlsCACertificate = tlsCACertificate; + return this; + } + + public RouteBuilder withTlsCACertificateSecret(String tlsCACertificateSecret) { + this.tlsCACertificateSecret = tlsCACertificateSecret; + return this; + } + + public RouteBuilder withTlsCertificate(String tlsCertificate) { + this.tlsCertificate = tlsCertificate; + return this; + } + + public RouteBuilder withTlsCertificateSecret(String tlsCertificateSecret) { + this.tlsCertificateSecret = tlsCertificateSecret; + return this; + } + + public RouteBuilder withTlsDestinationCACertificate(String tlsDestinationCACertificate) { + this.tlsDestinationCACertificate = tlsDestinationCACertificate; + return this; + } + + public RouteBuilder withTlsDestinationCACertificateSecret(String tlsDestinationCACertificateSecret) { + this.tlsDestinationCACertificateSecret = tlsDestinationCACertificateSecret; + return this; + } + + public RouteBuilder withTlsInsecureEdgeTerminationPolicy( + Route.TlsInsecureEdgeTerminationPolicy tlsInsecureEdgeTerminationPolicy) { + this.tlsInsecureEdgeTerminationPolicy = tlsInsecureEdgeTerminationPolicy; + return this; + } + + public RouteBuilder withTlsKey(String tlsKey) { + this.tlsKey = tlsKey; + return this; + } + + public RouteBuilder withTlsKeySecret(String tlsKeySecret) { + this.tlsKeySecret = tlsKeySecret; + return this; + } + + public RouteBuilder withTlsTermination(Route.TlsTermination tlsTermination) { + this.tlsTermination = tlsTermination; + return this; + } + + public Route build() { + Route route = new Route(); + route.setAnnotations(annotations); + route.setEnabled(enabled); + route.setHost(host); + route.setTlsCACertificate(tlsCACertificate); + route.setTlsCACertificateSecret(tlsCACertificateSecret); + route.setTlsCertificate(tlsCertificate); + route.setTlsCertificateSecret(tlsCertificateSecret); + route.setTlsDestinationCACertificate(tlsDestinationCACertificate); + route.setTlsDestinationCACertificateSecret(tlsDestinationCACertificateSecret); + route.setTlsInsecureEdgeTerminationPolicy(tlsInsecureEdgeTerminationPolicy); + route.setTlsKey(tlsKey); + route.setTlsKeySecret(tlsKeySecret); + route.setTlsTermination(tlsTermination); + return route; + } +} diff --git a/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/traits/model/ServiceBindingBuilder.java b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/traits/model/ServiceBindingBuilder.java new file mode 100644 index 00000000000..952d00e50ff --- /dev/null +++ b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/traits/model/ServiceBindingBuilder.java @@ -0,0 +1,48 @@ +/* + * 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.kubernetes.traits.model; + +import java.util.List; + +public final class ServiceBindingBuilder { + private Boolean enabled; + private List<String> services; + + private ServiceBindingBuilder() { + } + + public static ServiceBindingBuilder serviceBinding() { + return new ServiceBindingBuilder(); + } + + public ServiceBindingBuilder withEnabled(Boolean enabled) { + this.enabled = enabled; + return this; + } + + public ServiceBindingBuilder withServices(List<String> services) { + this.services = services; + return this; + } + + public ServiceBinding build() { + ServiceBinding serviceBinding = new ServiceBinding(); + serviceBinding.setEnabled(enabled); + serviceBinding.setServices(services); + return serviceBinding; + } +} diff --git a/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/traits/model/ServiceBuilder.java b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/traits/model/ServiceBuilder.java new file mode 100644 index 00000000000..90ab1e497a0 --- /dev/null +++ b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/traits/model/ServiceBuilder.java @@ -0,0 +1,53 @@ +/* + * 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.kubernetes.traits.model; + +public final class ServiceBuilder { + private Boolean auto; + private Boolean enabled; + private Service.Type type; + + private ServiceBuilder() { + } + + public static ServiceBuilder service() { + return new ServiceBuilder(); + } + + public ServiceBuilder withAuto(Boolean auto) { + this.auto = auto; + return this; + } + + public ServiceBuilder withEnabled(Boolean enabled) { + this.enabled = enabled; + return this; + } + + public ServiceBuilder withType(Service.Type type) { + this.type = type; + return this; + } + + public Service build() { + Service service = new Service(); + service.setAuto(auto); + service.setEnabled(enabled); + service.setType(type); + return service; + } +} diff --git a/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/traits/model/TraitsBuilder.java b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/traits/model/TraitsBuilder.java new file mode 100644 index 00000000000..b16bc006c33 --- /dev/null +++ b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/traits/model/TraitsBuilder.java @@ -0,0 +1,206 @@ +/* + * 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.kubernetes.traits.model; + +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.Map; + +public final class TraitsBuilder { + private Map<String, Addons> addons; + private CamelBuilder camel; + private ContainerBuilder container; + private EnvironmentBuilder environment; + private IngressBuilder ingress; + private KnativeBuilder knative; + private KnativeServiceBuilder knativeService; + private MountBuilder mount; + private OpenapiBuilder openapi; + private RouteBuilder route; + private ServiceBuilder service; + private ServiceBindingBuilder serviceBinding; + + private TraitsBuilder() { + } + + public static TraitsBuilder traits() { + return new TraitsBuilder(); + } + + public TraitsBuilder addToAddons(String key, Addons value) { + if (this.addons == null && key != null && value != null) { + this.addons = new LinkedHashMap<>(); + } + + if (key != null && value != null) { + this.addons.put(key, value); + } + + return this; + } + + public TraitsBuilder addToAddons(Map<String, Addons> map) { + if (this.addons == null && map != null) { + this.addons = new LinkedHashMap<>(); + } + + if (map != null) { + this.addons.putAll(map); + } + + return this; + } + + public TraitsBuilder removeFromAddons(String key) { + if (this.addons != null) { + if (key != null) { + this.addons.remove(key); + } + + } + return this; + } + + public TraitsBuilder removeFromAddons(Map<String, Addons> map) { + if (this.addons != null) { + if (map != null) { + Iterator<String> it = map.keySet().iterator(); + + while (it.hasNext()) { + Object key = it.next(); + if (this.addons != null) { + this.addons.remove(key); + } + } + } + + } + return this; + } + + public Map<String, Addons> getAddons() { + return this.addons; + } + + public <K, V> TraitsBuilder withAddons(Map<String, Addons> addons) { + if (addons == null) { + this.addons = null; + } else { + this.addons = new LinkedHashMap<>(addons); + } + + return this; + } + + public boolean hasAddons() { + return this.addons != null; + } + + public TraitsBuilder withCamel(CamelBuilder camel) { + this.camel = camel; + return this; + } + + public TraitsBuilder withContainer(ContainerBuilder container) { + this.container = container; + return this; + } + + public TraitsBuilder withEnvironment(EnvironmentBuilder environment) { + this.environment = environment; + return this; + } + + public TraitsBuilder withIngress(IngressBuilder ingress) { + this.ingress = ingress; + return this; + } + + public TraitsBuilder withKnative(KnativeBuilder knative) { + this.knative = knative; + return this; + } + + public TraitsBuilder withKnativeService(KnativeServiceBuilder knativeService) { + this.knativeService = knativeService; + return this; + } + + public TraitsBuilder withMount(MountBuilder mount) { + this.mount = mount; + return this; + } + + public TraitsBuilder withOpenapi(OpenapiBuilder openapi) { + this.openapi = openapi; + return this; + } + + public TraitsBuilder withRoute(RouteBuilder route) { + this.route = route; + return this; + } + + public TraitsBuilder withService(ServiceBuilder service) { + this.service = service; + return this; + } + + public TraitsBuilder withServiceBinding(ServiceBindingBuilder serviceBinding) { + this.serviceBinding = serviceBinding; + return this; + } + + public Traits build() { + Traits traits = new Traits(); + traits.setAddons(addons); + if (camel != null) { + traits.setCamel(camel.build()); + } + if (container != null) { + traits.setContainer(container.build()); + } + if (environment != null) { + traits.setEnvironment(environment.build()); + } + if (ingress != null) { + traits.setIngress(ingress.build()); + } + if (knative != null) { + traits.setKnative(knative.build()); + } + if (knativeService != null) { + traits.setKnativeService(knativeService.build()); + } + if (mount != null) { + traits.setMount(mount.build()); + } + if (openapi != null) { + traits.setOpenapi(openapi.build()); + } + if (route != null) { + traits.setRoute(route.build()); + } + if (service != null) { + traits.setService(service.build()); + } + if (serviceBinding != null) { + traits.setServiceBinding(serviceBinding.build()); + } + return traits; + } +}