Skip to content
Snippets Groups Projects
Commit dfecad1d authored by kbeyro's avatar kbeyro
Browse files

add cluster path if exist

parent 6bff48cf
Branches
Tags 0.3
1 merge request!213Resolve "Support deployment of applications on remote clusters"
...@@ -16,6 +16,8 @@ public abstract class HelmCommand implements Command { ...@@ -16,6 +16,8 @@ public abstract class HelmCommand implements Command {
protected static final String HELM_VERSION_2 = "v2"; protected static final String HELM_VERSION_2 = "v2";
protected static final String HELM_VERSION_3 = "v3"; protected static final String HELM_VERSION_3 = "v3";
protected static final String KUBECONFIG = "--kubeconfig";
protected String command; protected String command;
@Override @Override
......
...@@ -46,11 +46,11 @@ public class HelmCommandExecutor { ...@@ -46,11 +46,11 @@ public class HelmCommandExecutor {
this.enableTls = enableTls; this.enableTls = enableTls;
} }
void executeHelmInstallCommand(String namespace, String releaseName, KubernetesTemplate template, Map<String, String> arguments) { void executeHelmInstallCommand(String namespace, String releaseName, KubernetesTemplate template, Map<String, String> arguments, String kubeConfigPath) {
executeInstall(namespace, releaseName, template, arguments); executeInstall(namespace, releaseName, template, arguments, kubeConfigPath);
} }
private void executeInstall(String namespace, String releaseName, KubernetesTemplate template, Map<String, String> arguments) { private void executeInstall(String namespace, String releaseName, KubernetesTemplate template, Map<String, String> arguments, String kubeConfigPath) {
try { try {
HelmInstallCommand command = HelmInstallCommand.commandWithRepo( HelmInstallCommand command = HelmInstallCommand.commandWithRepo(
helmVersion, helmVersion,
...@@ -59,7 +59,8 @@ public class HelmCommandExecutor { ...@@ -59,7 +59,8 @@ public class HelmCommandExecutor {
arguments, arguments,
constructChartNameWithRepo(template.getChart().getName()), constructChartNameWithRepo(template.getChart().getName()),
template.getChart().getVersion(), template.getChart().getVersion(),
enableTls enableTls,
kubeConfigPath
); );
commandExecutor.execute(command); commandExecutor.execute(command);
} catch (CommandExecutionException e) { } catch (CommandExecutionException e) {
......
...@@ -25,7 +25,7 @@ public class HelmInstallCommand extends HelmCommand { ...@@ -25,7 +25,7 @@ public class HelmInstallCommand extends HelmCommand {
* @param enableTls flag indicating if tls option should be added * @param enableTls flag indicating if tls option should be added
* @return complete command object * @return complete command object
*/ */
public static HelmInstallCommand commandWithRepo(String helmVersion, String namespace, String releaseName, Map<String, String> values, String chartName, String chartVersion, boolean enableTls) { public static HelmInstallCommand commandWithRepo(String helmVersion, String namespace, String releaseName, Map<String, String> values, String chartName, String chartVersion, boolean enableTls, String kubeConfigPath) {
StringBuilder sb = buildBaseInstallCommand(helmVersion, namespace, releaseName, values); StringBuilder sb = buildBaseInstallCommand(helmVersion, namespace, releaseName, values);
if (chartName == null || chartName.isEmpty()) { if (chartName == null || chartName.isEmpty()) {
throw new IllegalArgumentException("Chart name can't be null or empty"); throw new IllegalArgumentException("Chart name can't be null or empty");
...@@ -35,6 +35,10 @@ public class HelmInstallCommand extends HelmCommand { ...@@ -35,6 +35,10 @@ public class HelmInstallCommand extends HelmCommand {
sb.append(SPACE).append(OPTION_VERSION).append(SPACE).append(chartVersion); sb.append(SPACE).append(OPTION_VERSION).append(SPACE).append(chartVersion);
} }
addTlsOptionIfRequired(helmVersion, enableTls, sb); addTlsOptionIfRequired(helmVersion, enableTls, sb);
if(kubeConfigPath != null && !kubeConfigPath.isEmpty()) {
sb.append(SPACE).append(KUBECONFIG).append(SPACE).append(kubeConfigPath);
}
return new HelmInstallCommand(sb.toString()); return new HelmInstallCommand(sb.toString());
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment