-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CAMEL-21167 - Camel-Spring-Boot: Kubernetes Secrets Trigger context r… (
#1209) * CAMEL-21167 - Camel-Spring-Boot: Kubernetes Secrets Trigger context reloading on update support Signed-off-by: Andrea Cosentino <[email protected]> * CAMEL-21167 - Camel-Spring-Boot: Kubernetes Secrets Trigger context reloading on update support Signed-off-by: Andrea Cosentino <[email protected]> --------- Signed-off-by: Andrea Cosentino <[email protected]>
- Loading branch information
Showing
5 changed files
with
154 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
...ot/src/main/java/org/apache/camel/spring/boot/vault/KubernetesVaultAutoConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* 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.spring.boot.vault; | ||
|
||
import org.apache.camel.spring.boot.CamelAutoConfiguration; | ||
import org.apache.camel.vault.KubernetesVaultConfiguration; | ||
import org.springframework.boot.autoconfigure.AutoConfigureAfter; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; | ||
import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration(proxyBeanMethods = false) | ||
@ConditionalOnBean(CamelAutoConfiguration.class) | ||
@EnableConfigurationProperties(KubernetesVaultConfigurationProperties.class) | ||
@AutoConfigureAfter(CamelAutoConfiguration.class) | ||
public class KubernetesVaultAutoConfiguration { | ||
|
||
@Bean | ||
public KubernetesVaultConfiguration kubernetesVaultConfiguration(KubernetesVaultConfigurationProperties config) { | ||
KubernetesVaultConfiguration answer = new KubernetesVaultConfiguration(); | ||
answer.setRefreshEnabled(config.isRefreshEnabled()); | ||
answer.setSecrets(config.getSecrets()); | ||
return answer; | ||
} | ||
|
||
} |
51 changes: 51 additions & 0 deletions
51
.../main/java/org/apache/camel/spring/boot/vault/KubernetesVaultConfigurationProperties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* 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.spring.boot.vault; | ||
|
||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
|
||
@ConfigurationProperties(prefix = "camel.vault.kubernetes") | ||
public class KubernetesVaultConfigurationProperties { | ||
|
||
/** | ||
* Define if we want to refresh the secrets on update | ||
*/ | ||
private boolean refreshEnabled; | ||
|
||
/** | ||
* Define the secrets to look at | ||
*/ | ||
private String secrets; | ||
|
||
|
||
|
||
public boolean isRefreshEnabled() { | ||
return refreshEnabled; | ||
} | ||
|
||
public void setRefreshEnabled(boolean refreshEnabled) { | ||
this.refreshEnabled = refreshEnabled; | ||
} | ||
|
||
public String getSecrets() { | ||
return secrets; | ||
} | ||
|
||
public void setSecrets(String secrets) { | ||
this.secrets = secrets; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...ot/src/test/java/org/apache/camel/spring/boot/vault/KubernetesVaultConfigurationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* 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.spring.boot.vault; | ||
|
||
import org.apache.camel.CamelContext; | ||
import org.apache.camel.test.spring.junit5.CamelSpringBootTest; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.test.annotation.DirtiesContext; | ||
|
||
@DirtiesContext | ||
@CamelSpringBootTest | ||
@EnableAutoConfiguration | ||
@SpringBootTest(classes = { KubernetesVaultConfigurationTest.class }, properties = { | ||
"camel.vault.kubernetes.refreshEnabled=true", "camel.vault.kubernetes.secrets=supersecret" }) | ||
public class KubernetesVaultConfigurationTest { | ||
|
||
@Autowired | ||
private CamelContext camelContext; | ||
|
||
@Test | ||
public void testKubernetesVault() throws Exception { | ||
Assertions.assertEquals(true, camelContext.getVaultConfiguration().kubernetes().isRefreshEnabled()); | ||
Assertions.assertEquals("supersecret", camelContext.getVaultConfiguration().kubernetes().getSecrets()); | ||
} | ||
} |