Skip to content
Open
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
14 changes: 14 additions & 0 deletions helm-java/src/main/java/com/marcnuri/helm/InstallCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public class InstallCommand extends HelmCommand<Release> {
private boolean disableOpenApiValidation;
private boolean dryRun;
private DryRun dryRunOption;
private boolean skipCrds;
private boolean wait;
private int timeout;
private final Map<String, String> values;
Expand Down Expand Up @@ -94,6 +95,7 @@ public Release call() {
toInt(disableOpenApiValidation),
toInt(dryRun),
dryRunOption == null ? null : dryRunOption.name().toLowerCase(Locale.ROOT),
toInt(skipCrds),
toInt(wait),
timeout,
urlEncode(values),
Expand Down Expand Up @@ -267,6 +269,18 @@ public InstallCommand withDryRunOption(DryRun dryRunOption) {
return this;
}

/**
* Skip CRDs during installation.
* <p>
* If set, no CRDs will be installed. By default, CRDs are installed if not already present.
*
* @return this {@link InstallCommand} instance.
*/
public InstallCommand skipCrds() {
this.skipCrds = true;
return this;
}

/**
* Waits until all Pods are in a ready state, PVCs are bound, Deployments have minimum
* (Desired minus maxUnavailable) Pods in ready state and Services have an IP address
Expand Down
14 changes: 14 additions & 0 deletions helm-java/src/main/java/com/marcnuri/helm/TemplateCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class TemplateCommand extends HelmCommand<String> {
private String chart;
private String namespace;
private boolean dependencyUpdate;
private boolean skipCrds;
private final Map<String, String> values;
private final List<Path> valuesFiles;
private Path certFile;
Expand Down Expand Up @@ -66,6 +67,7 @@ public String call() {
chart,
namespace,
toInt(dependencyUpdate),
toInt(skipCrds),
urlEncode(values),
toString(valuesFiles),
toString(certFile),
Expand Down Expand Up @@ -137,6 +139,18 @@ public TemplateCommand dependencyUpdate() {
return this;
}

/**
* Skip CRDs during template rendering.
* <p>
* If set, no CRDs will be included in the rendered templates.
*
* @return this {@link TemplateCommand} instance.
*/
public TemplateCommand skipCrds() {
this.skipCrds = true;
return this;
}

/**
* Set values for the chart.
*
Expand Down
14 changes: 14 additions & 0 deletions helm-java/src/main/java/com/marcnuri/helm/UpgradeCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public class UpgradeCommand extends HelmCommand<Release> {
private boolean disableOpenApiValidation;
private boolean dryRun;
private DryRun dryRunOption;
private boolean skipCrds;
private boolean wait;
private int timeout;
private final Map<String, String> values;
Expand Down Expand Up @@ -102,6 +103,7 @@ public Release call() {
toInt(disableOpenApiValidation),
toInt(dryRun),
dryRunOption == null ? null : dryRunOption.name().toLowerCase(Locale.ROOT),
toInt(skipCrds),
toInt(wait),
timeout,
urlEncode(values),
Expand Down Expand Up @@ -319,6 +321,18 @@ public UpgradeCommand withDryRunOption(DryRun dryRunOption) {
return this;
}

/**
* Skip CRDs during upgrade.
* <p>
* If set, no CRDs will be installed or upgraded. By default, CRDs are installed if not already present.
*
* @return this {@link UpgradeCommand} instance.
*/
public UpgradeCommand skipCrds() {
this.skipCrds = true;
return this;
}

/**
* Waits until all Pods are in a ready state, PVCs are bound, Deployments have minimum
* (Desired minus maxUnavailable) Pods in ready state and Services have an IP address
Expand Down
13 changes: 13 additions & 0 deletions helm-java/src/test/java/com/marcnuri/helm/HelmInstallTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,19 @@ void withDisableOpenApiValidation() {
.hasFieldOrPropertyWithValue("name", "test")
.hasFieldOrPropertyWithValue("status", "deployed");
}

@Test
void skipCrds() {
final Release result = helm.install()
.clientOnly()
.debug()
.withName("test-skip-crds")
.skipCrds()
.call();
assertThat(result)
.returns("test-skip-crds", Release::getName)
.returns("deployed", Release::getStatus);
}
}

@Nested
Expand Down
13 changes: 13 additions & 0 deletions helm-java/src/test/java/com/marcnuri/helm/HelmKubernetesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,19 @@ void withWaitAndCustomTimeout() {
"beginning wait for 3 resources with timeout of 5m30s"
);
}

@Test
void skipCrds() {
helm.install().withName("upgrade-skip-crds").withKubeConfig(kubeConfigFile).call();
final Release result = helm.upgrade()
.withKubeConfig(kubeConfigFile)
.withName("upgrade-skip-crds")
.skipCrds()
.call();
assertThat(result)
.returns("2", Release::getRevision)
.returns("deployed", Release::getStatus);
}
}

@Nested
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,15 @@ void withInvalidValuesAndDebug() {
.hasMessageContaining("# Source: local-chart-test")
.hasMessageContaining("name: release-name-local-chart-test");
}

@Test
void skipCrds() {
final String result = helm.template()
.skipCrds()
.call();
assertThat(result)
.contains("name: release-name-local-chart-test");
}
}

@Nested
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"disableOpenApiValidation",
"dryRun",
"dryRunOption",
"skipCRDs",
"wait",
"timeout",
"values",
Expand Down Expand Up @@ -71,6 +72,7 @@ public class InstallOptions extends Structure {
public int disableOpenApiValidation;
public int dryRun;
public String dryRunOption;
public int skipCRDs;
public int wait;
public int timeout;
public String values;
Expand Down Expand Up @@ -102,6 +104,7 @@ public InstallOptions(
int disableOpenApiValidation,
int dryRun,
String dryRunOption,
int skipCRDs,
int wait,
int timeout,
String values,
Expand Down Expand Up @@ -132,6 +135,7 @@ public InstallOptions(
this.disableOpenApiValidation = disableOpenApiValidation;
this.dryRun = dryRun;
this.dryRunOption = dryRunOption;
this.skipCRDs = skipCRDs;
this.wait = wait;
this.timeout = timeout;
this.values = values;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"chart",
"namespace",
"dependencyUpdate",
"skipCRDs",
"values",
"valuesFiles",
"certFile",
Expand All @@ -45,6 +46,7 @@ public class TemplateOptions extends Structure {
public String chart;
public String namespace;
public int dependencyUpdate;
public int skipCRDs;
public String values;
public String valuesFiles;
public String certFile;
Expand All @@ -62,6 +64,7 @@ public TemplateOptions(
String chart,
String namespace,
int dependencyUpdate,
int skipCRDs,
String values,
String valuesFiles,
String certFile,
Expand All @@ -78,6 +81,7 @@ public TemplateOptions(
this.chart = chart;
this.namespace = namespace;
this.dependencyUpdate = dependencyUpdate;
this.skipCRDs = skipCRDs;
this.values = values;
this.valuesFiles = valuesFiles;
this.certFile = certFile;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"disableOpenApiValidation",
"dryRun",
"dryRunOption",
"skipCRDs",
"wait",
"timeout",
"values",
Expand Down Expand Up @@ -78,6 +79,7 @@ public class UpgradeOptions extends Structure {
public int disableOpenApiValidation;
public int dryRun;
public String dryRunOption;
public int skipCRDs;
public int wait;
public int timeout;
public String values;
Expand Down Expand Up @@ -113,6 +115,7 @@ public UpgradeOptions(
int disableOpenApiValidation,
int dryRun,
String dryRunOption,
int skipCRDs,
int wait,
int timeout,
String values,
Expand Down Expand Up @@ -147,6 +150,7 @@ public UpgradeOptions(
this.disableOpenApiValidation = disableOpenApiValidation;
this.dryRun = dryRun;
this.dryRunOption = dryRunOption;
this.skipCRDs = skipCRDs;
this.wait = wait;
this.timeout = timeout;
this.values = values;
Expand Down
2 changes: 2 additions & 0 deletions native/internal/helm/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ type InstallOptions struct {
DisableOpenApiValidation bool
DryRun bool
DryRunOption string
SkipCRDs bool
Wait bool
Timeout time.Duration
Values string
Expand Down Expand Up @@ -130,6 +131,7 @@ func install(options *InstallOptions) (*release.Release, *installOutputs, error)
client.Devel = options.Devel
client.DryRun = options.DryRun
client.DryRunOption = dryRunOption(options.DryRunOption)
client.SkipCRDs = options.SkipCRDs
client.Wait = options.Wait
client.Timeout = options.Timeout
client.ClientOnly = options.ClientOnly
Expand Down
2 changes: 2 additions & 0 deletions native/internal/helm/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type TemplateOptions struct {
Chart string
Namespace string
DependencyUpdate bool
SkipCRDs bool
Values string
ValuesFiles string
Debug bool
Expand All @@ -51,6 +52,7 @@ func Template(options *TemplateOptions) (string, error) {
Chart: options.Chart,
Namespace: options.Namespace,
DependencyUpdate: options.DependencyUpdate,
SkipCRDs: options.SkipCRDs,
Values: options.Values,
ValuesFiles: options.ValuesFiles,
Debug: options.Debug,
Expand Down
3 changes: 3 additions & 0 deletions native/internal/helm/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ type UpgradeOptions struct {
DisableOpenApiValidation bool
DryRun bool
DryRunOption string
SkipCRDs bool
Wait bool
Timeout time.Duration
Values string
Expand Down Expand Up @@ -102,6 +103,7 @@ func Upgrade(options *UpgradeOptions) (string, error) {
DisableOpenApiValidation: options.DisableOpenApiValidation,
DryRun: options.DryRun,
DryRunOption: options.DryRunOption,
SkipCRDs: options.SkipCRDs,
Wait: options.Wait,
Timeout: options.Timeout,
Values: options.Values,
Expand Down Expand Up @@ -133,6 +135,7 @@ func Upgrade(options *UpgradeOptions) (string, error) {
client.DisableOpenAPIValidation = options.DisableOpenApiValidation
client.DryRun = options.DryRun
client.DryRunOption = dryRunOption(options.DryRunOption)
client.SkipCRDs = options.SkipCRDs
client.Wait = options.Wait
client.Timeout = options.Timeout
client.CertFile = options.CertFile
Expand Down
6 changes: 6 additions & 0 deletions native/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ struct InstallOptions {
int disableOpenApiValidation;
int dryRun;
char* dryRunOption;
int skipCRDs;
int wait;
int timeout;
char* values;
Expand Down Expand Up @@ -169,6 +170,7 @@ struct TemplateOptions {
char* chart;
char* namespace;
int dependencyUpdate;
int skipCRDs;
char* values;
char* valuesFiles;
char* certFile;
Expand Down Expand Up @@ -222,6 +224,7 @@ struct UpgradeOptions {
int disableOpenApiValidation;
int dryRun;
char* dryRunOption;
int skipCRDs;
int wait;
int timeout;
char* values;
Expand Down Expand Up @@ -353,6 +356,7 @@ func Install(options *C.struct_InstallOptions) C.Result {
DisableOpenApiValidation: options.disableOpenApiValidation == 1,
DryRun: options.dryRun == 1,
DryRunOption: C.GoString(options.dryRunOption),
SkipCRDs: options.skipCRDs == 1,
Wait: options.wait == 1,
Timeout: timeout,
Values: C.GoString(options.values),
Expand Down Expand Up @@ -607,6 +611,7 @@ func Template(options *C.struct_TemplateOptions) C.Result {
Chart: C.GoString(options.chart),
Namespace: C.GoString(options.namespace),
DependencyUpdate: options.dependencyUpdate == 1,
SkipCRDs: options.skipCRDs == 1,
Values: C.GoString(options.values),
ValuesFiles: C.GoString(options.valuesFiles),
CertOptions: helm.CertOptions{
Expand Down Expand Up @@ -689,6 +694,7 @@ func Upgrade(options *C.struct_UpgradeOptions) C.Result {
DisableOpenApiValidation: options.disableOpenApiValidation == 1,
DryRun: options.dryRun == 1,
DryRunOption: C.GoString(options.dryRunOption),
SkipCRDs: options.skipCRDs == 1,
Wait: options.wait == 1,
Timeout: timeout,
Values: C.GoString(options.values),
Expand Down