Skip to content

Commit

Permalink
kubectlbuildwrapper: simplify, set context in common path
Browse files Browse the repository at this point in the history
  • Loading branch information
colemickens committed Mar 17, 2018
1 parent 0db5e2b commit 26ee3e2
Showing 1 changed file with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ public void setUp(Context context, Run<?, ?> build, FilePath workspace, Launcher

FilePath configFile = workspace.createTempFile(".kube", "config");
Set<String> tempFiles = newHashSet(configFile.getRemote());

context.env("KUBECONFIG", configFile.getRemote());
context.setDisposer(new CleanupDisposer(tempFiles));

String tlsConfig;
if (caCertificate != null && !caCertificate.isEmpty()) {
Expand Down Expand Up @@ -127,9 +130,6 @@ public void setUp(Context context, Run<?, ?> build, FilePath workspace, Launcher
String kubeconfigContents = reader.lines().collect(Collectors.joining("\n"));
configFile.write(kubeconfigContents, null);
reader.close();

context.setDisposer(new CleanupDisposer(tempFiles));
context.env("KUBECONFIG", configFile.getRemote());
return;
}

Expand Down Expand Up @@ -188,10 +188,6 @@ public void setUp(Context context, Run<?, ?> build, FilePath workspace, Launcher
.cmdAsSingleString("kubectl config --kubeconfig=\"" + configFile.getRemote() + "\" use-context k8s")
.join();
if (status != 0) throw new IOException("Failed to run kubectl config "+status);

context.setDisposer(new CleanupDisposer(tempFiles));

context.env("KUBECONFIG", configFile.getRemote());
}

/**
Expand Down

0 comments on commit 26ee3e2

Please sign in to comment.