Skip to content

Commit

Permalink
fix: ClusterConfiguration.getConfig should also set namespace in curr…
Browse files Browse the repository at this point in the history
…ent context

Related to failures in eclipse-jkube#3304

ClusterConfiguration `getConfig()` method converts ClusterConfiguration
to a KubernetesClient Config object. It should also set namespace in
current context while setting current context in Config.

Signed-off-by: Rohan Kumar <[email protected]>
  • Loading branch information
rohanKanojia authored Aug 6, 2024
1 parent fc7cc68 commit 0a4787e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ public Config getConfig() {
if (StringUtils.isNotBlank(this.currentContext)) {
configBuilder.withCurrentContext(new NamedContextBuilder()
.withName(this.currentContext)
.withNewContext()
.withNamespace(getNamespace())
.endContext()
.build());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ void should_load_configuration_from_properties() {
final Properties properties = new Properties();
properties.put("jkube.username", "user name");
properties.put("jkube.password", "the pa$$w*rd");
properties.put("jkube.namespace", "myns1");
properties.put("jkube.masterUrl", "https://example.com");
properties.put("jkube.corner-case", "corner");
properties.put("jkube.currentContext", "ctx1");
Expand All @@ -40,7 +41,9 @@ void should_load_configuration_from_properties() {
assertThat(config).isNotNull()
.hasFieldOrPropertyWithValue("username", "user name")
.hasFieldOrPropertyWithValue("password", "the pa$$w*rd")
.hasFieldOrPropertyWithValue("currentContext", new NamedContextBuilder().withName("ctx1").build())
.hasFieldOrPropertyWithValue("namespace", "myns1")
.hasFieldOrPropertyWithValue("currentContext.name", "ctx1")
.hasFieldOrPropertyWithValue("currentContext.context.namespace", "myns1")
.hasFieldOrPropertyWithValue("masterUrl", "https://example.com/");
}

Expand Down Expand Up @@ -130,7 +133,7 @@ void loadsConfigurationFromKubernetesConfig() {
.hasFieldOrPropertyWithValue("clientKeyData", "clientKeyData")
.hasFieldOrPropertyWithValue("clientKeyAlgo", "clientKeyAlgo")
.hasFieldOrPropertyWithValue("clientKeyPassphrase", "clientKeyPassphrase")
.hasFieldOrPropertyWithValue("currentContext", new NamedContextBuilder().withName("ctx1").build())
.hasFieldOrPropertyWithValue("currentContext", new NamedContextBuilder().withName("ctx1").withNewContext().withNamespace("namespace").endContext().build())
.hasFieldOrPropertyWithValue("trustStoreFile", "trustStoreFile")
.hasFieldOrPropertyWithValue("trustStorePassphrase", "trustStorePassphrase")
.hasFieldOrPropertyWithValue("keyStoreFile", "keyStoreFile")
Expand Down

0 comments on commit 0a4787e

Please sign in to comment.