Repository: camel Updated Branches: refs/heads/master 5bb5014e7 -> 0562ec4e6
CAMEL-11766 - camel-kubernetes adoc file missing Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/0562ec4e Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/0562ec4e Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/0562ec4e Branch: refs/heads/master Commit: 0562ec4e6bb4b57c3d8fa22bc59173557c37a60b Parents: 5bb5014 Author: Andrea Cosentino <anco...@gmail.com> Authored: Mon Sep 11 14:36:05 2017 +0200 Committer: Andrea Cosentino <anco...@gmail.com> Committed: Mon Sep 11 14:46:12 2017 +0200 ---------------------------------------------------------------------- .../kubernetes-service-accounts-component.adoc | 57 ++++++++ .../KubernetesServiceAccountsEndpoint.java | 4 +- ...rviceAccountsComponentAutoConfiguration.java | 132 +++++++++++++++++++ ...esServiceAccountsComponentConfiguration.java | 50 +++++++ .../main/resources/META-INF/spring.factories | 4 +- 5 files changed, 244 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/0562ec4e/components/camel-kubernetes/src/main/docs/kubernetes-service-accounts-component.adoc ---------------------------------------------------------------------- diff --git a/components/camel-kubernetes/src/main/docs/kubernetes-service-accounts-component.adoc b/components/camel-kubernetes/src/main/docs/kubernetes-service-accounts-component.adoc new file mode 100644 index 0000000..bcb26e8 --- /dev/null +++ b/components/camel-kubernetes/src/main/docs/kubernetes-service-accounts-component.adoc @@ -0,0 +1,57 @@ +## Kubernetes Service Account Component + +*Available as of Camel version 2.17* + +The *Kubernetes Service Account*Â component is one of link:kubernetes.html[Kubernetes Components] which +provides a producer to execute kubernetes Service Account operations. + + +### Component Options + +// component options: START +The Kubernetes Service Account component has no options. +// component options: END + + +### Endpoint Options +// endpoint options: START +The Kubernetes Service Account endpoint is configured using URI syntax: + + kubernetes-service-accounts:masterUrl + +with the following path and query parameters: + +#### Path Parameters (1 parameters): + +[width="100%",cols="2,5,^1,2",options="header"] +|======================================================================= +| Name | Description | Default | Type +| **masterUrl** | *Required* Kubernetes Master url | | String +|======================================================================= + +#### Query Parameters (19 parameters): + +[width="100%",cols="2,5,^1,2",options="header"] +|======================================================================= +| Name | Description | Default | Type +| **apiVersion** (producer) | The Kubernetes API Version to use | | String +| **dnsDomain** (producer) | The dns domain used for ServiceCall EIP | | String +| **kubernetesClient** (producer) | Default KubernetesClient to use if provided | | KubernetesClient +| **operation** (producer) | Producer operation to do on Kubernetes | | String +| **portName** (producer) | The port name used for ServiceCall EIP | | String +| **connectionTimeout** (advanced) | Connection timeout in milliseconds to use when making requests to the Kubernetes API server. | | Integer +| **synchronous** (advanced) | Sets whether synchronous processing should be strictly used or Camel is allowed to use asynchronous processing (if supported). | false | boolean +| **caCertData** (security) | The CA Cert Data | | String +| **caCertFile** (security) | The CA Cert File | | String +| **clientCertData** (security) | The Client Cert Data | | String +| **clientCertFile** (security) | The Client Cert File | | String +| **clientKeyAlgo** (security) | The Key Algorithm used by the client | | String +| **clientKeyData** (security) | The Client Key data | | String +| **clientKeyFile** (security) | The Client Key file | | String +| **clientKeyPassphrase** (security) | The Client Key Passphrase | | String +| **oauthToken** (security) | The Auth Token | | String +| **password** (security) | Password to connect to Kubernetes | | String +| **trustCerts** (security) | Define if the certs we used are trusted anyway or not | | Boolean +| **username** (security) | Username to connect to Kubernetes | | String +|======================================================================= +// endpoint options: END http://git-wip-us.apache.org/repos/asf/camel/blob/0562ec4e/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/service_accounts/KubernetesServiceAccountsEndpoint.java ---------------------------------------------------------------------- diff --git a/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/service_accounts/KubernetesServiceAccountsEndpoint.java b/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/service_accounts/KubernetesServiceAccountsEndpoint.java index cd5da73..52c7dcb 100644 --- a/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/service_accounts/KubernetesServiceAccountsEndpoint.java +++ b/components/camel-kubernetes/src/main/java/org/apache/camel/component/kubernetes/service_accounts/KubernetesServiceAccountsEndpoint.java @@ -28,8 +28,8 @@ import org.slf4j.LoggerFactory; /** * The Kubernetes Service Accounts component provides a producer to execute service account operations. */ -@UriEndpoint(firstVersion = "2.17.0", scheme = "kubernetes-service-account", title = "Kubernetes Servkce Account", - syntax = "kubernetes-service-account:masterUrl", producerOnly = true, label = "container,cloud,paas") +@UriEndpoint(firstVersion = "2.17.0", scheme = "kubernetes-service-accounts", title = "Kubernetes Service Account", + syntax = "kubernetes-service-accounts:masterUrl", producerOnly = true, label = "container,cloud,paas") public class KubernetesServiceAccountsEndpoint extends AbstractKubernetesEndpoint { private static final Logger LOG = LoggerFactory.getLogger(KubernetesServiceAccountsEndpoint.class); http://git-wip-us.apache.org/repos/asf/camel/blob/0562ec4e/platforms/spring-boot/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/service_accounts/springboot/KubernetesServiceAccountsComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/service_accounts/springboot/KubernetesServiceAccountsComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/service_accounts/springboot/KubernetesServiceAccountsComponentAutoConfiguration.java new file mode 100644 index 0000000..bd85bba --- /dev/null +++ b/platforms/spring-boot/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/service_accounts/springboot/KubernetesServiceAccountsComponentAutoConfiguration.java @@ -0,0 +1,132 @@ +/** + * 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.component.kubernetes.service_accounts.springboot; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.annotation.Generated; +import org.apache.camel.CamelContext; +import org.apache.camel.component.kubernetes.service_accounts.KubernetesServiceAccountsComponent; +import org.apache.camel.spi.ComponentCustomizer; +import org.apache.camel.spi.HasId; +import org.apache.camel.spring.boot.CamelAutoConfiguration; +import org.apache.camel.spring.boot.ComponentConfigurationProperties; +import org.apache.camel.spring.boot.util.CamelPropertiesHelper; +import org.apache.camel.spring.boot.util.ConditionalOnCamelContextAndAutoConfigurationBeans; +import org.apache.camel.spring.boot.util.GroupCondition; +import org.apache.camel.spring.boot.util.HierarchicalPropertiesEvaluator; +import org.apache.camel.util.IntrospectionSupport; +import org.apache.camel.util.ObjectHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Conditional; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Lazy; + +/** + * Generated by camel-package-maven-plugin - do not edit this file! + */ +@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") +@Configuration +@Conditional({ + ConditionalOnCamelContextAndAutoConfigurationBeans.class, + KubernetesServiceAccountsComponentAutoConfiguration.GroupConditions.class}) +@AutoConfigureAfter(CamelAutoConfiguration.class) +@EnableConfigurationProperties({ComponentConfigurationProperties.class, + KubernetesServiceAccountsComponentConfiguration.class}) +public class KubernetesServiceAccountsComponentAutoConfiguration { + + private static final Logger LOGGER = LoggerFactory + .getLogger(KubernetesServiceAccountsComponentAutoConfiguration.class); + @Autowired + private ApplicationContext applicationContext; + @Autowired + private CamelContext camelContext; + @Autowired + private KubernetesServiceAccountsComponentConfiguration configuration; + @Autowired(required = false) + private List<ComponentCustomizer<KubernetesServiceAccountsComponent>> customizers; + + static class GroupConditions extends GroupCondition { + public GroupConditions() { + super("camel.component", + "camel.component.kubernetes-service-accounts"); + } + } + + @Lazy + @Bean(name = "kubernetes-service-accounts-component") + @ConditionalOnMissingBean(KubernetesServiceAccountsComponent.class) + public KubernetesServiceAccountsComponent configureKubernetesServiceAccountsComponent() + throws Exception { + KubernetesServiceAccountsComponent component = new KubernetesServiceAccountsComponent(); + component.setCamelContext(camelContext); + Map<String, Object> parameters = new HashMap<>(); + IntrospectionSupport.getProperties(configuration, parameters, null, + false); + for (Map.Entry<String, Object> entry : parameters.entrySet()) { + Object value = entry.getValue(); + Class<?> paramClass = value.getClass(); + if (paramClass.getName().endsWith("NestedConfiguration")) { + Class nestedClass = null; + try { + nestedClass = (Class) paramClass.getDeclaredField( + "CAMEL_NESTED_CLASS").get(null); + HashMap<String, Object> nestedParameters = new HashMap<>(); + IntrospectionSupport.getProperties(value, nestedParameters, + null, false); + Object nestedProperty = nestedClass.newInstance(); + CamelPropertiesHelper.setCamelProperties(camelContext, + nestedProperty, nestedParameters, false); + entry.setValue(nestedProperty); + } catch (NoSuchFieldException e) { + } + } + } + CamelPropertiesHelper.setCamelProperties(camelContext, component, + parameters, false); + if (ObjectHelper.isNotEmpty(customizers)) { + for (ComponentCustomizer<KubernetesServiceAccountsComponent> customizer : customizers) { + boolean useCustomizer = (customizer instanceof HasId) + ? HierarchicalPropertiesEvaluator + .evaluate( + applicationContext.getEnvironment(), + "camel.component.customizer", + "camel.component.kubernetes-service-accounts.customizer", + ((HasId) customizer).getId()) + : HierarchicalPropertiesEvaluator + .evaluate(applicationContext.getEnvironment(), + "camel.component.customizer", + "camel.component.kubernetes-service-accounts.customizer"); + if (useCustomizer) { + LOGGER.debug("Configure component {}, with customizer {}", + component, customizer); + customizer.customize(component); + } + } + } + return component; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/0562ec4e/platforms/spring-boot/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/service_accounts/springboot/KubernetesServiceAccountsComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/service_accounts/springboot/KubernetesServiceAccountsComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/service_accounts/springboot/KubernetesServiceAccountsComponentConfiguration.java new file mode 100644 index 0000000..3ee66f0 --- /dev/null +++ b/platforms/spring-boot/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/service_accounts/springboot/KubernetesServiceAccountsComponentConfiguration.java @@ -0,0 +1,50 @@ +/** + * 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.component.kubernetes.service_accounts.springboot; + +import javax.annotation.Generated; +import org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon; +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * The Kubernetes Service Accounts component provides a producer to execute + * service account operations. + * + * Generated by camel-package-maven-plugin - do not edit this file! + */ +@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") +@ConfigurationProperties(prefix = "camel.component.kubernetes-service-accounts") +public class KubernetesServiceAccountsComponentConfiguration + extends + ComponentConfigurationPropertiesCommon { + + /** + * Whether the component should resolve property placeholders on itself when + * starting. Only properties which are of String type can use property + * placeholders. + */ + private Boolean resolvePropertyPlaceholders = true; + + public Boolean getResolvePropertyPlaceholders() { + return resolvePropertyPlaceholders; + } + + public void setResolvePropertyPlaceholders( + Boolean resolvePropertyPlaceholders) { + this.resolvePropertyPlaceholders = resolvePropertyPlaceholders; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/0562ec4e/platforms/spring-boot/components-starter/camel-kubernetes-starter/src/main/resources/META-INF/spring.factories ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-kubernetes-starter/src/main/resources/META-INF/spring.factories b/platforms/spring-boot/components-starter/camel-kubernetes-starter/src/main/resources/META-INF/spring.factories index 6c9d8d4..c132eab 100644 --- a/platforms/spring-boot/components-starter/camel-kubernetes-starter/src/main/resources/META-INF/spring.factories +++ b/platforms/spring-boot/components-starter/camel-kubernetes-starter/src/main/resources/META-INF/spring.factories @@ -29,7 +29,9 @@ org.apache.camel.component.kubernetes.persistent_volumes.springboot.KubernetesPe org.apache.camel.component.kubernetes.build_configs.springboot.KubernetesBuildConfigsComponentAutoConfiguration,\ org.apache.camel.component.kubernetes.config_maps.springboot.KubernetesConfigMapsComponentAutoConfiguration,\ org.apache.camel.component.kubernetes.persistent_volumes_claims.springboot.KubernetesPersistentVolumesClaimsComponentAutoConfiguration,\ -org.apache.camel.component.kubernetes.deployments.springboot.KubernetesDeploymentsComponentAutoConfiguration +org.apache.camel.component.kubernetes.deployments.springboot.KubernetesDeploymentsComponentAutoConfiguration,\ +org.apache.camel.component.kubernetes.service_accounts.springboot.KubernetesServiceAccountsComponentAutoConfiguration +