All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.kokuwa.maven.helm.InstallMojo Maven / Gradle / Ivy

The newest version!
package io.kokuwa.maven.helm;

import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;

import lombok.Setter;

/**
 * Mojo for executing "helm install".
 *
 * @author Tim IJntema
 * @see helm install
 * @since 5.10
 */
@Mojo(name = "install", defaultPhase = LifecyclePhase.DEPLOY, threadSafe = true)
@Setter
public class InstallMojo extends AbstractHandleMojo {

	/**
	 * Helm command to execute.
	 *
	 * @since 5.10
	 * @deprecated Will be removed in 7.x and set to "install".
	 */
	@Deprecated // java8 (since = "6.5.0", forRemoval = true)
	@Parameter(property = "action", defaultValue = "install")
	private String action;

	/**
	 * Set this to true to delete the installation on failure.
	 *
	 * @since 6.10.0
	 */
	@Parameter(property = "helm.install.atomic")
	private boolean installAtomic;

	/**
	 * Time in seconds to wait for any individual Kubernetes operation.
	 *
	 * @since 6.10.0
	 */
	@Parameter(property = "helm.install.timeout")
	private Integer installTimeout;

	/**
	 * Force resource updates through a replacement strategy.
	 *
	 * @since 6.10.1
	 */
	@Parameter(property = "helm.install.force")
	private boolean installForce;

	/**
	 * Use insecure HTTP connections for the chart download.
	 *
	 * @since 6.12.0
	 */
	@Parameter(property = "helm.install.plain-http")
	private Boolean installPlainHttp;

	/**
	 * Set this to true to skip invoking install goal.
	 *
	 * @since 5.10
	 */
	@Parameter(property = "helm.install.skip", defaultValue = "true")
	private boolean skipInstall;

	@Override
	public void execute() throws MojoExecutionException, MojoFailureException {

		if (skip || skipInstall) {
			getLog().info("Skip install");
			return;
		}

		for (Chart chart : getCharts()) {
			getLog().info("Perform install for chart " + chart.getReleaseName() + " " +
					(installAtomic ? " with atomic" : "") +
					(installTimeout != null ? installTimeout + "s" : "") +
					chart.getDirectory());
			helm()
					.arguments(action, chart.getReleaseName(), chart.getDirectory())
					.flag("atomic", installAtomic)
					.flag("force", installForce)
					.flag("plain-http", isPlainHttp(installPlainHttp))
					.flag("timeout", installTimeout != null ? installTimeout + "s" : null)
					.execute("Failed to deploy helm chart");
		}
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy