Skip to content

Commit

Permalink
Add parameter --output-dir and --generate-name for helm:template (
Browse files Browse the repository at this point in the history
  • Loading branch information
sschnabe authored Nov 8, 2022
1 parent 15771fc commit c292f1a
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,8 @@ Parameter | Type | User Property | Required | Description
`<kubeToken>` | string | helm.kubeToken | false | bearer token used for authentication
`<releaseName>` | string | helm.releaseName | false | Name of the release for upgrade goal
`<upgradeDryRun>` | boolean | helm.upgrade.dryRun | false | Run upgrade goal only in dry run mode
`<templateOutputDir>` | file | helm.template.output-dir | false | Writes the executed templates to files in output-dir instead of stdout.
`<templateGenerateName>` | boolean | helm.template.generate-name | false | Generate the name (and omit the NAME parameter).

## Packaging with the Helm Lifecycle

Expand Down
19 changes: 19 additions & 0 deletions src/main/java/io/kokuwa/maven/helm/TemplateMojo.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.kokuwa.maven.helm;

import java.io.File;
import java.nio.file.Path;

import org.apache.maven.plugin.MojoExecutionException;
Expand Down Expand Up @@ -32,6 +33,22 @@ public class TemplateMojo extends AbstractHelmWithValueOverrideMojo {
@Parameter(property = "action", defaultValue = "template")
private String action;

/**
* Writes the executed templates to files in output-dir instead of stdout.
*
* @since 6.6.1
*/
@Parameter(property = "helm.template.output-dir")
private File templateOutputDir;

/**
* Generate the name (and omit the NAME parameter).
*
* @since 6.6.1
*/
@Parameter(property = "helm.template.generate-name", defaultValue = "false")
private boolean templateGenerateName;

/**
* Additional arguments.
*
Expand Down Expand Up @@ -63,6 +80,8 @@ public void execute() throws MojoExecutionException, MojoFailureException {
helm()
.arguments(action, chartDirectory)
.arguments(getArguments())
.flag("output-dir", templateOutputDir)
.flag("generate-name", templateGenerateName)
.execute("There are test failures");
}
}
Expand Down
16 changes: 16 additions & 0 deletions src/test/java/io/kokuwa/maven/helm/TemplateMojoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,22 @@ void additionalArguments(TemplateMojo mojo) {
assertHelm(mojo, "template src/test/resources/simple --foo --bar");
}

@DisplayName("with --output-dir")
@Test
void outputDirectory(TemplateMojo mojo) {
mojo.setSkipTemplate(false);
mojo.setTemplateOutputDir(new File("."));
assertHelm(mojo, "template src/test/resources/simple --output-dir .");
}

@DisplayName("with --generate-name")
@Test
void genereateName(TemplateMojo mojo) {
mojo.setSkipTemplate(false);
mojo.setTemplateGenerateName(true);
assertHelm(mojo, "template src/test/resources/simple --generate-name");
}

@DisplayName("with dependencies")
@Test
void dependencies(TemplateMojo mojo) {
Expand Down

0 comments on commit c292f1a

Please sign in to comment.