Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add flags for --ignore-not-found for uninstall, fix #351 #352

Merged
merged 1 commit into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ Parameter | Type | User Property | Required | Description
`<uninstallNoHooks>` | boolean | helm.uninstall.no-hooks | false | Prevent hooks from running during uninstallation.
`<uninstallCascade>` | boolean | helm.uninstall.cascade | false | Must be "background", "orphan", or "foreground". Selects the deletion cascading strategy for the dependents. Defaults to background. (default "background" from helm)
`<uninstallKeepHistory>` | boolean | helm.uninstall.keep-history | false | Remove all associated resources and mark the release as deleted, but retain the release history.
`<uninstallIgnoreNotFound>` | boolean | helm.uninstall.ignore-not-found | false | Treat "release not found" as a successful uninstall.
`<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).
`<templatePlainHttp>` | boolean | helm.template.plain-http | false | Use insecure HTTP connections for the chart download.
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/io/kokuwa/maven/helm/UninstallMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ public class UninstallMojo extends AbstractHelmWithValueOverrideMojo {
@Parameter(property = "helm.uninstall.no-hooks", defaultValue = "false")
private boolean uninstallNoHooks;

/**
* Treat "release not found" as a successful uninstall.
*
* @since 6.14.0
*/
@Parameter(property = "helm.uninstall.ignore-not-found ", defaultValue = "false")
private boolean uninstallIgnoreNotFound;

/**
* Remove all associated resources and mark the release as deleted, but retain the release history.
*
Expand Down Expand Up @@ -86,6 +94,7 @@ public void execute() throws MojoExecutionException {
.flag("cascade", uninstallCascade)
.flag("no-hooks", uninstallNoHooks)
.flag("keep-history", uninstallKeepHistory)
.flag("ignore-not-found", uninstallIgnoreNotFound)
.execute("Failed to deploy helm chart");
}
}
Expand Down
8 changes: 8 additions & 0 deletions src/test/java/io/kokuwa/maven/helm/UninstallMojoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ void noHooks(UninstallMojo mojo) {
assertHelm(mojo, "uninstall simple --no-hooks");
}

@DisplayName("with flag ignore-not-found")
@Test
void ignoreNotFound(UninstallMojo mojo) {
mojo.setSkipUninstall(false);
mojo.setUninstallIgnoreNotFound(true);
assertHelm(mojo, "uninstall simple --ignore-not-found");
}

@DisplayName("with flags cascade background")
@Test
void cascade(UninstallMojo mojo) {
Expand Down