Skip to content

Commit

Permalink
Helm Release: Make RepositoryOpts optional
Browse files Browse the repository at this point in the history
- Fix Check method to handle unset RepositoryOpts
  • Loading branch information
lblackstone committed Nov 19, 2021
1 parent d25bd4c commit 4466c03
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 49 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## HEAD (Unreleased)

- Remove unused helm ReleaseType type (https://github.com/pulumi/pulumi-kubernetes/pull/1805)
- Helm Release: Make RepositoryOpts optional (https://github.com/pulumi/pulumi-kubernetes/pull/1806)

## 3.10.0 (November 12, 2021)

Expand Down
5 changes: 1 addition & 4 deletions provider/cmd/pulumi-resource-kubernetes/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -39700,14 +39700,12 @@
"type": "object",
"required": [
"chart",
"repositoryOpts",
"status"
],
"language": {
"nodejs": {
"requiredOutputs": [
"name",
"repositoryOpts",
"chart",
"version",
"devel",
Expand Down Expand Up @@ -39896,8 +39894,7 @@
}
},
"requiredInputs": [
"chart",
"repositoryOpts"
"chart"
]
},
"kubernetes:kustomize:Directory": {
Expand Down
3 changes: 0 additions & 3 deletions provider/pkg/gen/overlays.go
Original file line number Diff line number Diff line change
Expand Up @@ -766,14 +766,12 @@ var helmV3ReleaseResource = pschema.ResourceSpec{
Type: "object",
Required: []string{
"chart",
"repositoryOpts",
"status",
},
Language: map[string]pschema.RawMessage{
"nodejs": rawMessage(map[string][]string{
"requiredOutputs": {
"name",
"repositoryOpts",
"chart",
"version",
"devel",
Expand Down Expand Up @@ -1033,7 +1031,6 @@ var helmV3ReleaseResource = pschema.ResourceSpec{
},
RequiredInputs: []string{
"chart",
"repositoryOpts",
},
}

Expand Down
28 changes: 16 additions & 12 deletions provider/pkg/provider/helm_release.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ type Release struct {
// Re-use the given name, even if that name is already used. This is unsafe in production
Replace bool `json:"replace,omitempty"`
// Specification defining the Helm chart repository to use.
RepositoryOpts RepositoryOpts `json:"repositoryOpts,omitempty"`
RepositoryOpts *RepositoryOpts `json:"repositoryOpts,omitempty"`
// When upgrading, reset the values to the ones built into the chart
ResetValues bool `json:"resetValues,omitempty"`
// When upgrading, reuse the last release's values and merge in any overrides. If 'reset_values' is specified, this is ignored
Expand Down Expand Up @@ -985,7 +985,17 @@ func computeResourceNames(r *Release) (map[string][]string, error) {
helmHome := os.Getenv("HELM_HOME")

helmChartOpts := HelmChartOpts{
HelmFetchOpts: HelmFetchOpts{
APIVersions: nil,
IncludeTestHookResources: true,
SkipCRDRendering: r.SkipCrds,
Namespace: r.Namespace,
ReleaseName: r.Name,
Values: r.Values,
Version: r.Version,
}
if r.RepositoryOpts != nil {
helmChartOpts.Chart = r.Chart
helmChartOpts.HelmFetchOpts = HelmFetchOpts{
CAFile: r.RepositoryOpts.CAFile,
CertFile: r.RepositoryOpts.CertFile,
Devel: r.Devel,
Expand All @@ -996,17 +1006,11 @@ func computeResourceNames(r *Release) (map[string][]string, error) {
Repo: r.RepositoryOpts.Repo,
Username: r.RepositoryOpts.Password,
Version: r.Version,
},
APIVersions: nil,
Chart: r.Chart,
IncludeTestHookResources: true,
SkipCRDRendering: r.SkipCrds,
Namespace: r.Namespace,
Path: "",
ReleaseName: r.Name,
Values: r.Values,
Version: r.Version,
}
} else {
helmChartOpts.Path = r.Chart
}

templ, err := helmTemplate(helmChartOpts)
if err != nil {
return nil, err
Expand Down
4 changes: 2 additions & 2 deletions sdk/dotnet/Helm/V3/Release.cs
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,8 @@ public InputMap<object> Manifest
/// <summary>
/// Specification defining the Helm chart repository to use.
/// </summary>
[Input("repositoryOpts", required: true)]
public Input<Pulumi.Kubernetes.Types.Inputs.Helm.V3.RepositoryOptsArgs> RepositoryOpts { get; set; } = null!;
[Input("repositoryOpts")]
public Input<Pulumi.Kubernetes.Types.Inputs.Helm.V3.RepositoryOptsArgs>? RepositoryOpts { get; set; }

/// <summary>
/// When upgrading, reset the values to the ones built into the chart.
Expand Down
9 changes: 3 additions & 6 deletions sdk/go/kubernetes/helm/v3/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ type Release struct {
// Re-use the given name, even if that name is already used. This is unsafe in production
Replace pulumi.BoolPtrOutput `pulumi:"replace"`
// Specification defining the Helm chart repository to use.
RepositoryOpts RepositoryOptsOutput `pulumi:"repositoryOpts"`
RepositoryOpts RepositoryOptsPtrOutput `pulumi:"repositoryOpts"`
// When upgrading, reset the values to the ones built into the chart.
ResetValues pulumi.BoolPtrOutput `pulumi:"resetValues"`
// Names of resources created by the release grouped by "kind/version".
Expand Down Expand Up @@ -97,9 +97,6 @@ func NewRelease(ctx *pulumi.Context,
if args.Chart == nil {
return nil, errors.New("invalid value for required argument 'Chart'")
}
if args.RepositoryOpts == nil {
return nil, errors.New("invalid value for required argument 'RepositoryOpts'")
}
args.Compat = pulumi.StringPtr("true")
var resource Release
err := ctx.RegisterResource("kubernetes:helm.sh/v3:Release", name, args, &resource, opts...)
Expand Down Expand Up @@ -177,7 +174,7 @@ type releaseArgs struct {
// Re-use the given name, even if that name is already used. This is unsafe in production
Replace *bool `pulumi:"replace"`
// Specification defining the Helm chart repository to use.
RepositoryOpts RepositoryOpts `pulumi:"repositoryOpts"`
RepositoryOpts *RepositoryOpts `pulumi:"repositoryOpts"`
// When upgrading, reset the values to the ones built into the chart.
ResetValues *bool `pulumi:"resetValues"`
// Names of resources created by the release grouped by "kind/version".
Expand Down Expand Up @@ -248,7 +245,7 @@ type ReleaseArgs struct {
// Re-use the given name, even if that name is already used. This is unsafe in production
Replace pulumi.BoolPtrInput
// Specification defining the Helm chart repository to use.
RepositoryOpts RepositoryOptsInput
RepositoryOpts RepositoryOptsPtrInput
// When upgrading, reset the values to the ones built into the chart.
ResetValues pulumi.BoolPtrInput
// Names of resources created by the release grouped by "kind/version".
Expand Down
5 changes: 1 addition & 4 deletions sdk/nodejs/helm/v3/release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,6 @@ export class Release extends pulumi.CustomResource {
if ((!args || args.chart === undefined) && !opts.urn) {
throw new Error("Missing required property 'chart'");
}
if ((!args || args.repositoryOpts === undefined) && !opts.urn) {
throw new Error("Missing required property 'repositoryOpts'");
}
inputs["atomic"] = args ? args.atomic : undefined;
inputs["chart"] = args ? args.chart : undefined;
inputs["cleanupOnFail"] = args ? args.cleanupOnFail : undefined;
Expand Down Expand Up @@ -361,7 +358,7 @@ export interface ReleaseArgs {
/**
* Specification defining the Helm chart repository to use.
*/
repositoryOpts: pulumi.Input<inputs.helm.v3.RepositoryOpts>;
repositoryOpts?: pulumi.Input<inputs.helm.v3.RepositoryOpts>;
/**
* When upgrading, reset the values to the ones built into the chart.
*/
Expand Down
35 changes: 17 additions & 18 deletions sdk/python/pulumi_kubernetes/helm/v3/Release.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
class ReleaseArgs:
def __init__(__self__, *,
chart: pulumi.Input[str],
repository_opts: pulumi.Input['RepositoryOptsArgs'],
atomic: Optional[pulumi.Input[bool]] = None,
cleanup_on_fail: Optional[pulumi.Input[bool]] = None,
compat: Optional[pulumi.Input[str]] = None,
Expand All @@ -38,6 +37,7 @@ def __init__(__self__, *,
recreate_pods: Optional[pulumi.Input[bool]] = None,
render_subchart_notes: Optional[pulumi.Input[bool]] = None,
replace: Optional[pulumi.Input[bool]] = None,
repository_opts: Optional[pulumi.Input['RepositoryOptsArgs']] = None,
reset_values: Optional[pulumi.Input[bool]] = None,
resource_names: Optional[pulumi.Input[Mapping[str, pulumi.Input[Sequence[pulumi.Input[str]]]]]] = None,
reuse_values: Optional[pulumi.Input[bool]] = None,
Expand All @@ -52,7 +52,6 @@ def __init__(__self__, *,
"""
The set of arguments for constructing a Release resource.
:param pulumi.Input[str] chart: Chart name to be installed. A path may be used.
:param pulumi.Input['RepositoryOptsArgs'] repository_opts: Specification defining the Helm chart repository to use.
:param pulumi.Input[bool] atomic: If set, installation process purges chart on fail. `skipAwait` will be disabled automatically if atomic is used.
:param pulumi.Input[bool] cleanup_on_fail: Allow deletion of new resources created in this upgrade when upgrade fails.
:param pulumi.Input[bool] create_namespace: Create the namespace if it does not exist.
Expand All @@ -73,6 +72,7 @@ def __init__(__self__, *,
:param pulumi.Input[bool] recreate_pods: Perform pods restart during upgrade/rollback.
:param pulumi.Input[bool] render_subchart_notes: If set, render subchart notes along with the parent.
:param pulumi.Input[bool] replace: Re-use the given name, even if that name is already used. This is unsafe in production
:param pulumi.Input['RepositoryOptsArgs'] repository_opts: Specification defining the Helm chart repository to use.
:param pulumi.Input[bool] reset_values: When upgrading, reset the values to the ones built into the chart.
:param pulumi.Input[Mapping[str, pulumi.Input[Sequence[pulumi.Input[str]]]]] resource_names: Names of resources created by the release grouped by "kind/version".
:param pulumi.Input[bool] reuse_values: When upgrading, reuse the last release's values and merge in any overrides. If 'resetValues' is specified, this is ignored
Expand All @@ -86,7 +86,6 @@ def __init__(__self__, *,
:param pulumi.Input[bool] wait_for_jobs: Will wait until all Jobs have been completed before marking the release as successful. This is ignored if `skipAwait` is enabled.
"""
pulumi.set(__self__, "chart", chart)
pulumi.set(__self__, "repository_opts", repository_opts)
if atomic is not None:
pulumi.set(__self__, "atomic", atomic)
if cleanup_on_fail is not None:
Expand Down Expand Up @@ -129,6 +128,8 @@ def __init__(__self__, *,
pulumi.set(__self__, "render_subchart_notes", render_subchart_notes)
if replace is not None:
pulumi.set(__self__, "replace", replace)
if repository_opts is not None:
pulumi.set(__self__, "repository_opts", repository_opts)
if reset_values is not None:
pulumi.set(__self__, "reset_values", reset_values)
if resource_names is not None:
Expand Down Expand Up @@ -164,18 +165,6 @@ def chart(self) -> pulumi.Input[str]:
def chart(self, value: pulumi.Input[str]):
pulumi.set(self, "chart", value)

@property
@pulumi.getter(name="repositoryOpts")
def repository_opts(self) -> pulumi.Input['RepositoryOptsArgs']:
"""
Specification defining the Helm chart repository to use.
"""
return pulumi.get(self, "repository_opts")

@repository_opts.setter
def repository_opts(self, value: pulumi.Input['RepositoryOptsArgs']):
pulumi.set(self, "repository_opts", value)

@property
@pulumi.getter
def atomic(self) -> Optional[pulumi.Input[bool]]:
Expand Down Expand Up @@ -425,6 +414,18 @@ def replace(self) -> Optional[pulumi.Input[bool]]:
def replace(self, value: Optional[pulumi.Input[bool]]):
pulumi.set(self, "replace", value)

@property
@pulumi.getter(name="repositoryOpts")
def repository_opts(self) -> Optional[pulumi.Input['RepositoryOptsArgs']]:
"""
Specification defining the Helm chart repository to use.
"""
return pulumi.get(self, "repository_opts")

@repository_opts.setter
def repository_opts(self, value: Optional[pulumi.Input['RepositoryOptsArgs']]):
pulumi.set(self, "repository_opts", value)

@property
@pulumi.getter(name="resetValues")
def reset_values(self) -> Optional[pulumi.Input[bool]]:
Expand Down Expand Up @@ -735,8 +736,6 @@ def _internal_init(__self__,
__props__.__dict__["recreate_pods"] = recreate_pods
__props__.__dict__["render_subchart_notes"] = render_subchart_notes
__props__.__dict__["replace"] = replace
if repository_opts is None and not opts.urn:
raise TypeError("Missing required property 'repository_opts'")
__props__.__dict__["repository_opts"] = repository_opts
__props__.__dict__["reset_values"] = reset_values
__props__.__dict__["resource_names"] = resource_names
Expand Down Expand Up @@ -978,7 +977,7 @@ def replace(self) -> pulumi.Output[Optional[bool]]:

@property
@pulumi.getter(name="repositoryOpts")
def repository_opts(self) -> pulumi.Output['outputs.RepositoryOpts']:
def repository_opts(self) -> pulumi.Output[Optional['outputs.RepositoryOpts']]:
"""
Specification defining the Helm chart repository to use.
"""
Expand Down

0 comments on commit 4466c03

Please sign in to comment.