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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ Release result = installCommand
.withNamespace("namespace")
// Optionally create the namespace if not present
.createNamespace()
// Optionally, specify the kubernetes version
.withKubeVersion("1.21.0")
// Optionally, if set, the installation process deletes the installation on failure
.atomic()
// Optionally specify a custom description for the release
Expand Down Expand Up @@ -592,6 +594,8 @@ String result = templateCommand
.withVersion("^1.0.0")
// Optionally specify the Kubernetes namespace for the release
.withNamespace("namespace")
// Optionally, specify the kubernetes version
.withKubeVersion("1.21.0")
// Optionally update dependencies if they are missing before installing the chart
.dependencyUpdate()
// Optionally set values for the chart
Expand Down
13 changes: 13 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 @@ -42,6 +42,7 @@ public class InstallCommand extends HelmCommand<Release> {
private String version;
private String chart;
private String namespace;
private String kubeVersion;
private boolean atomic;
private boolean createNamespace;
private String description;
Expand Down Expand Up @@ -86,6 +87,7 @@ public Release call() {
version,
chart,
namespace,
kubeVersion,
toInt(atomic),
toInt(createNamespace),
description,
Expand Down Expand Up @@ -181,6 +183,17 @@ public InstallCommand withNamespace(String namespace) {
return this;
}

/**
* Kubernetes version for this request.
*
* @param kubeVersion the Kubernetes version for this request.
* @return this {@link InstallCommand} instance.
*/
public InstallCommand withKubeVersion(String kubeVersion) {
this.kubeVersion = kubeVersion;
return this;
}

/**
* Create the release namespace if not present.
*
Expand Down
13 changes: 13 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 @@ -35,6 +35,7 @@ public class TemplateCommand extends HelmCommand<String> {
private String version;
private String chart;
private String namespace;
private String kubeVersion;
private boolean dependencyUpdate;
private final Map<String, String> values;
private final List<Path> valuesFiles;
Expand Down Expand Up @@ -65,6 +66,7 @@ public String call() {
version,
chart,
namespace,
kubeVersion,
toInt(dependencyUpdate),
urlEncode(values),
toString(valuesFiles),
Expand Down Expand Up @@ -127,6 +129,17 @@ public TemplateCommand withNamespace(String namespace) {
return this;
}

/**
* Kubernetes version for this request.
*
* @param kubeVersion the Kubernetes version for this request.
* @return this {@link TemplateCommand} instance.
*/
public TemplateCommand withKubeVersion(String kubeVersion) {
this.kubeVersion = kubeVersion;
return this;
}

/**
* Update dependencies if they are missing before rendering the chart.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"version",
"chart",
"namespace",
"kubeVersion",
"atomic",
"createNamespace",
"description",
Expand Down Expand Up @@ -63,6 +64,7 @@ public class InstallOptions extends Structure {
public String version;
public String chart;
public String namespace;
public String kubeVersion;
public int atomic;
public int createNamespace;
public String description;
Expand Down Expand Up @@ -94,6 +96,7 @@ public InstallOptions(
String version,
String chart,
String namespace,
String kubeVersion,
int atomic,
int createNamespace,
String description,
Expand Down Expand Up @@ -124,6 +127,7 @@ public InstallOptions(
this.version = version;
this.chart = chart;
this.namespace = namespace;
this.kubeVersion = kubeVersion;
this.atomic = atomic;
this.createNamespace = createNamespace;
this.description = description;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"version",
"chart",
"namespace",
"kubeVersion",
"dependencyUpdate",
"values",
"valuesFiles",
Expand All @@ -44,6 +45,7 @@ public class TemplateOptions extends Structure {
public String version;
public String chart;
public String namespace;
public String kubeVersion;
public int dependencyUpdate;
public String values;
public String valuesFiles;
Expand All @@ -61,6 +63,7 @@ public TemplateOptions(
String version,
String chart,
String namespace,
String kubeVersion,
int dependencyUpdate,
String values,
String valuesFiles,
Expand All @@ -77,6 +80,7 @@ public TemplateOptions(
this.version = version;
this.chart = chart;
this.namespace = namespace;
this.kubeVersion = kubeVersion;
this.dependencyUpdate = dependencyUpdate;
this.values = values;
this.valuesFiles = valuesFiles;
Expand Down
5 changes: 5 additions & 0 deletions native/internal/helm/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"helm.sh/helm/v3/pkg/action"
"helm.sh/helm/v3/pkg/chart"
"helm.sh/helm/v3/pkg/chart/loader"
"helm.sh/helm/v3/pkg/chartutil"
"helm.sh/helm/v3/pkg/cli"
"helm.sh/helm/v3/pkg/cli/values"
"helm.sh/helm/v3/pkg/getter"
Expand All @@ -45,6 +46,7 @@ type InstallOptions struct {
Version string
Chart string
Namespace string
KubeVersion string
Atomic bool
CreateNamespace bool
Description string
Expand Down Expand Up @@ -120,6 +122,9 @@ func install(options *InstallOptions) (*release.Release, *installOutputs, error)
}
client.ReleaseName = name
client.Namespace = options.Namespace
if options.KubeVersion != "" {
client.KubeVersion, err = chartutil.ParseKubeVersion(options.KubeVersion)
}
client.Atomic = options.Atomic
client.CreateNamespace = options.CreateNamespace
client.Description = options.Description
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 @@ -28,6 +28,7 @@ type TemplateOptions struct {
Version string
Chart string
Namespace string
KubeVersion string
DependencyUpdate bool
Values string
ValuesFiles string
Expand All @@ -50,6 +51,7 @@ func Template(options *TemplateOptions) (string, error) {
Version: options.Version,
Chart: options.Chart,
Namespace: options.Namespace,
KubeVersion: options.KubeVersion,
DependencyUpdate: options.DependencyUpdate,
Values: options.Values,
ValuesFiles: options.ValuesFiles,
Expand Down
4 changes: 4 additions & 0 deletions native/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ struct InstallOptions {
char* version;
char* chart;
char* namespace;
char* kubeVersion;
int atomic;
int createNamespace;
char* description;
Expand Down Expand Up @@ -168,6 +169,7 @@ struct TemplateOptions {
char* version;
char* chart;
char* namespace;
char* kubeVersion;
int dependencyUpdate;
char* values;
char* valuesFiles;
Expand Down Expand Up @@ -345,6 +347,7 @@ func Install(options *C.struct_InstallOptions) C.Result {
Version: C.GoString(options.version),
Chart: C.GoString(options.chart),
Namespace: C.GoString(options.namespace),
KubeVersion: C.GoString(options.kubeVersion),
Atomic: options.atomic == 1,
CreateNamespace: options.createNamespace == 1,
Description: C.GoString(options.description),
Expand Down Expand Up @@ -606,6 +609,7 @@ func Template(options *C.struct_TemplateOptions) C.Result {
Version: C.GoString(options.version),
Chart: C.GoString(options.chart),
Namespace: C.GoString(options.namespace),
KubeVersion: C.GoString(options.kubeVersion),
DependencyUpdate: options.dependencyUpdate == 1,
Values: C.GoString(options.values),
ValuesFiles: C.GoString(options.valuesFiles),
Expand Down