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

add cluster path if exist

parent 6bff48cf
No related branches found
No related tags found
1 merge request!213Resolve "Support deployment of applications on remote clusters"
......@@ -16,6 +16,8 @@ public abstract class HelmCommand implements Command {
protected static final String HELM_VERSION_2 = "v2";
protected static final String HELM_VERSION_3 = "v3";
protected static final String KUBECONFIG = "--kubeconfig";
protected String command;
@Override
......
......@@ -46,11 +46,11 @@ public class HelmCommandExecutor {
this.enableTls = enableTls;
}
void executeHelmInstallCommand(String namespace, String releaseName, KubernetesTemplate template, Map<String, String> arguments) {
executeInstall(namespace, releaseName, template, arguments);
void executeHelmInstallCommand(String namespace, String releaseName, KubernetesTemplate template, Map<String, String> arguments, String kubeConfigPath) {
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 {
HelmInstallCommand command = HelmInstallCommand.commandWithRepo(
helmVersion,
......@@ -59,7 +59,8 @@ public class HelmCommandExecutor {
arguments,
constructChartNameWithRepo(template.getChart().getName()),
template.getChart().getVersion(),
enableTls
enableTls,
kubeConfigPath
);
commandExecutor.execute(command);
} catch (CommandExecutionException e) {
......
......@@ -25,7 +25,7 @@ public class HelmInstallCommand extends HelmCommand {
* @param enableTls flag indicating if tls option should be added
* @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);
if (chartName == null || chartName.isEmpty()) {
throw new IllegalArgumentException("Chart name can't be null or empty");
......@@ -35,6 +35,10 @@ public class HelmInstallCommand extends HelmCommand {
sb.append(SPACE).append(OPTION_VERSION).append(SPACE).append(chartVersion);
}
addTlsOptionIfRequired(helmVersion, enableTls, sb);
if(kubeConfigPath != null && !kubeConfigPath.isEmpty()) {
sb.append(SPACE).append(KUBECONFIG).append(SPACE).append(kubeConfigPath);
}
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