Skip to content

Commit

Permalink
Merge pull request #2476 from Fabian-K/fix-2474
Browse files Browse the repository at this point in the history
  • Loading branch information
fusesource-ci authored Sep 16, 2020
2 parents f26412a + 9846bd0 commit 323be1c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#### Bugs
* Fix: #2442: Wrong resource kind in `ProjectRequestHandler` causes ClassCastException when handling Project resources.
* Fix #2467: OpenShiftClient cannot replace existing resource with API version =! v1
* Fix: #2474: Config.fromKubeconfig throws NullPointerException

#### Improvements
* Fix #2473: Removed unused ValidationMessages.properties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,8 @@ public static Config fromKubeconfig(String kubeconfigContents) throws IOExceptio
public static Config fromKubeconfig(String context, String kubeconfigContents, String kubeconfigPath) {
// we allow passing context along here, since downstream accepts it
Config config = new Config();
config.file = new File(kubeconfigPath);
if(kubeconfigPath != null)
config.file = new File(kubeconfigPath);
loadFromKubeconfig(config, context, kubeconfigContents);
return config;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,14 @@ void testWithKubeConfigAndSytemPropertiesAndBuilder() {
assertEquals("testns2", config.getNamespace());
}

@Test
void testFromKubeconfigContent() throws IOException {
File configFile = new File(TEST_KUBECONFIG_FILE);
final String configYAML = String.join("\n", Files.readAllLines(configFile.toPath()));
final Config config = Config.fromKubeconfig(configYAML);
assertEquals("https://172.28.128.4:8443", config.getMasterUrl());
}

@Test
void testWithNamespacePath() {
System.setProperty(Config.KUBERNETES_KUBECONFIG_FILE, "nokubeconfigfile");
Expand Down

0 comments on commit 323be1c

Please sign in to comment.