-
Notifications
You must be signed in to change notification settings - Fork 1k
Kubernetes as a Composite config source #1873
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ryanjbaxter
merged 21 commits into
spring-cloud:3.1.x
from
arjavdongaonkar:composite-k8s
Feb 23, 2025
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
bd2b48a
initial commit, crearting factory
arjavdongaonkar a03f1c4
testing default
arjavdongaonkar 8bc4b44
remove checkstyle
arjavdongaonkar 4b117d1
for try
arjavdongaonkar e236897
for try
arjavdongaonkar 485a1ea
trying existing bean
arjavdongaonkar 886bccb
reverting pom.xml
arjavdongaonkar 3236523
ObjectProvider for missing bean
arjavdongaonkar c930c13
Update default order value in KubernetesConfigServerProperties
arjavdongaonkar c171236
code style fixes
arjavdongaonkar 2ecc524
code style fixes
arjavdongaonkar a212d18
code style fixes
arjavdongaonkar 123a540
code style
arjavdongaonkar 15d4497
test cases
arjavdongaonkar 4111c17
Composite Integration Tests where kubernetes is one of the type in th…
arjavdongaonkar 7667816
Composite Integration Tests where kubernetes is one of the type in th…
arjavdongaonkar a6a9011
Add KubernetesConfigServerProperties support to KubernetesEnvironment…
arjavdongaonkar 35a1004
mark old implementation as deprecated and revert test cases
arjavdongaonkar 2fe9852
test case for new constructor
arjavdongaonkar 9805c20
linting
arjavdongaonkar a53aae5
remove ObjectProvider
arjavdongaonkar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
40 changes: 40 additions & 0 deletions
40
...springframework/cloud/kubernetes/configserver/KubernetesEnvironmentRepositoryFactory.java
This file contains hidden or 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,40 @@ | ||
/* | ||
* Copyright 2013-2021 the original author or authors. | ||
* | ||
* Licensed 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 | ||
* | ||
* https://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.springframework.cloud.kubernetes.configserver; | ||
|
||
import org.springframework.cloud.config.server.environment.EnvironmentRepositoryFactory; | ||
|
||
/** | ||
* Factory class for creating instances of {@link KubernetesEnvironmentRepository}. | ||
* | ||
* @author Arjav Dongaonkar | ||
*/ | ||
public class KubernetesEnvironmentRepositoryFactory | ||
implements EnvironmentRepositoryFactory<KubernetesEnvironmentRepository, KubernetesConfigServerProperties> { | ||
|
||
private final KubernetesEnvironmentRepository kubernetesEnvironmentRepository; | ||
|
||
public KubernetesEnvironmentRepositoryFactory(KubernetesEnvironmentRepository kubernetesEnvironmentRepository) { | ||
this.kubernetesEnvironmentRepository = kubernetesEnvironmentRepository; | ||
} | ||
|
||
@Override | ||
public KubernetesEnvironmentRepository build(KubernetesConfigServerProperties environmentProperties) { | ||
return kubernetesEnvironmentRepository; | ||
} | ||
|
||
} |
53 changes: 53 additions & 0 deletions
53
...cloud/kubernetes/configserver/CompositeProfileWithGitAndKubernetesConfigSourcesTests.java
This file contains hidden or 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,53 @@ | ||
/* | ||
* Copyright 2013-2022 the original author or authors. | ||
* | ||
* Licensed 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 | ||
* | ||
* https://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.springframework.cloud.kubernetes.configserver; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.cloud.config.server.environment.JGitEnvironmentRepository; | ||
import org.springframework.context.ConfigurableApplicationContext; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
/** | ||
* @author Arjav Dongaonkar | ||
*/ | ||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, | ||
classes = { KubernetesConfigServerApplication.class }, | ||
properties = { "spring.main.cloud-platform=KUBERNETES", "spring.profiles.include=kubernetes", | ||
"spring.cloud.kubernetes.client.namespace=default", "spring.profiles.active=composite", | ||
"spring.cloud.config.server.composite[0].type=git", | ||
"spring.cloud.config.server.composite[0].uri=https://github.com/spring-cloud-samples/config-repo", | ||
"spring.cloud.config.server.composite[1].type=kubernetes", | ||
"spring.cloud.config.server.composite[1].config-map-namespace=default", | ||
"spring.cloud.config.server.composite[1].secrets-namespace=default" }) | ||
class CompositeProfileWithGitAndKubernetesConfigSourcesTests { | ||
|
||
@Autowired | ||
private ConfigurableApplicationContext context; | ||
|
||
@Test | ||
void runTest() { | ||
assertThat(context.getBeanNamesForType(KubernetesEnvironmentRepository.class)).hasSize(2); | ||
assertThat(context.getBeanNamesForType(KubernetesEnvironmentRepositoryFactory.class)).hasSize(1); | ||
assertThat(context.getBeanNamesForType(KubernetesPropertySourceSupplier.class)).isNotEmpty(); | ||
assertThat(context.getBeanNamesForType(JGitEnvironmentRepository.class)).hasSize(1); | ||
} | ||
|
||
} |
52 changes: 52 additions & 0 deletions
52
...oud/kubernetes/configserver/CompositeProfileWithMultipleKubernetesConfigSourcesTests.java
This file contains hidden or 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,52 @@ | ||
/* | ||
* Copyright 2013-2022 the original author or authors. | ||
* | ||
* Licensed 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 | ||
* | ||
* https://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.springframework.cloud.kubernetes.configserver; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.context.ConfigurableApplicationContext; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
/** | ||
* @author Arjav Dongaonkar | ||
*/ | ||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, | ||
classes = { KubernetesConfigServerApplication.class }, | ||
properties = { "spring.main.cloud-platform=KUBERNETES", "spring.profiles.include=kubernetes", | ||
"spring.cloud.kubernetes.client.namespace=default", "spring.profiles.active=composite", | ||
"spring.cloud.config.server.composite[0].type=kubernetes", | ||
"spring.cloud.config.server.composite[0].config-map-namespace=default", | ||
"spring.cloud.config.server.composite[0].secrets-namespace=default", | ||
"spring.cloud.config.server.composite[1].type=kubernetes", | ||
"spring.cloud.config.server.composite[1].config-map-namespace=another-namespace", | ||
"spring.cloud.config.server.composite[1].secrets-namespace=another-namespace" }) | ||
class CompositeProfileWithMultipleKubernetesConfigSourcesTests { | ||
|
||
@Autowired | ||
private ConfigurableApplicationContext context; | ||
|
||
@Test | ||
void runTest() { | ||
assertThat(context.getBeanNamesForType(KubernetesEnvironmentRepository.class)).hasSize(3); | ||
assertThat(context.getBeanNamesForType(KubernetesEnvironmentRepositoryFactory.class)).hasSize(1); | ||
assertThat(context.getBeanNamesForType(KubernetesPropertySourceSupplier.class)).isNotEmpty(); | ||
} | ||
|
||
} |
49 changes: 49 additions & 0 deletions
49
...rk/cloud/kubernetes/configserver/CompositeProfileWithOnlyKubernetesConfigSourceTests.java
This file contains hidden or 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,49 @@ | ||
/* | ||
* Copyright 2013-2022 the original author or authors. | ||
* | ||
* Licensed 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 | ||
* | ||
* https://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.springframework.cloud.kubernetes.configserver; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.context.ConfigurableApplicationContext; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
/** | ||
* @author Arjav Dongaonkar | ||
*/ | ||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, | ||
classes = { KubernetesConfigServerApplication.class }, | ||
properties = { "spring.main.cloud-platform=KUBERNETES", "spring.profiles.include=kubernetes", | ||
"spring.cloud.kubernetes.client.namespace=default", "spring.profiles.active=composite", | ||
"spring.cloud.config.server.composite[0].type=kubernetes", | ||
"spring.cloud.config.server.composite[0].config-map-namespace=default", | ||
"spring.cloud.config.server.composite[0].secrets-namespace=default" }) | ||
class CompositeProfileWithOnlyKubernetesConfigSourceTests { | ||
|
||
@Autowired | ||
private ConfigurableApplicationContext context; | ||
|
||
@Test | ||
void runTest() { | ||
assertThat(context.getBeanNamesForType(KubernetesEnvironmentRepository.class)).hasSize(2); | ||
assertThat(context.getBeanNamesForType(KubernetesEnvironmentRepositoryFactory.class)).hasSize(1); | ||
assertThat(context.getBeanNamesForType(KubernetesPropertySourceSupplier.class)).isNotEmpty(); | ||
} | ||
|
||
} |
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.