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

Make CRD rendering conditional for Helm v3 #1572

Merged
merged 11 commits into from
May 13, 2021
Merged
Show file tree
Hide file tree
Changes from 10 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 .github/workflows/run-acceptance-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ env:
PULUMI_LOCAL_NUGET: ${{ github.workspace }}/nuget
PR_COMMIT_SHA: ${{ github.event.client_payload.pull_request.head.sha }}
VERSION_PREFIX: 3.0.0
PULUMI_GO_DEP_ROOT: ${{ github.workspace }}/..

jobs:
comment-notification:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
## HEAD (Unreleased)
- Allow opting out of CRD rendering for Helm v3 by specifying `SkipCRDRendering` argument to Helm charts. (https://github.com/pulumi/pulumi-kubernetes/pull/1572)

## 3.1.2 (May 12, 2021)

Expand Down
5 changes: 5 additions & 0 deletions provider/pkg/gen/dotnet-templates/helm/ChartBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,11 @@ public InputList<string> ApiVersions
/// </summary>
public Input<bool>? IncludeTestHookResources { get; set; }

// <summary>
// By default, CRDs are rendered along with Helm chart templates. Setting this to true will skip CRD rendering.
// </summary>
public Input<bool>? SkipCRDRendering {get; set; }

/// <summary>
/// The optional namespace to install chart resources into.
/// </summary>
Expand Down
25 changes: 14 additions & 11 deletions provider/pkg/gen/dotnet-templates/helm/Unwraps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ internal class BaseChartArgsUnwrap
{
public ImmutableArray<string> ApiVersions { get; set; }
public bool? IncludeTestHookResources { get; set; }
public bool? SkipCRDRendering { get; set; }
public string? Namespace { get; set; }
public ImmutableDictionary<string, object> Values { get; set; } = null!;
public List<TransformationAction> Transformations { get; set; } = null!;
Expand Down Expand Up @@ -68,29 +69,31 @@ internal static class Extensions
public static Output<Union<ChartArgsUnwrap, LocalChartArgsUnwrap>> Unwrap(this Union<ChartArgs, LocalChartArgs> options)
{
return options.Match(
v => Output.Tuple(v.ApiVersions, v.IncludeTestHookResources.ToNullable(), v.Namespace.ToNullable(), v.Values, v.Repo.ToNullable(), v.Chart, v.Version.ToNullable(), v.FetchOptions.Unwrap()).Apply(vs =>
v => Output.Tuple(v.ApiVersions, v.Namespace.ToNullable(), v.Values, v.Repo.ToNullable(), v.Chart, v.Version.ToNullable(), v.FetchOptions.Unwrap(), new InputList<bool?> { v.IncludeTestHookResources.ToNullable(), v.SkipCRDRendering.ToNullable() }).Apply(vs =>
Union<ChartArgsUnwrap, LocalChartArgsUnwrap>.FromT0(
new ChartArgsUnwrap
{
ApiVersions = vs.Item1,
IncludeTestHookResources = vs.Item2,
Namespace = vs.Item3,
Values = vs.Item4,
Namespace = vs.Item2,
Values = vs.Item3,
Transformations = v.Transformations,
ResourcePrefix = v.ResourcePrefix,
Repo = vs.Item5,
Chart = vs.Item6,
Version = vs.Item7,
FetchOptions = vs.Item8
Repo = vs.Item4,
Chart = vs.Item5,
Version = vs.Item6,
FetchOptions = vs.Item7,
IncludeTestHookResources = vs.Item8[0],
SkipCRDRendering = vs.Item8[1]
})),
v => Output.Tuple(v.ApiVersions, v.IncludeTestHookResources.ToNullable(), v.Namespace.ToNullable(), v.Values).Apply(vs =>
v => Output.Tuple(v.ApiVersions, v.IncludeTestHookResources.ToNullable(), v.SkipCRDRendering.ToNullable(), v.Namespace.ToNullable(), v.Values).Apply(vs =>
Union<ChartArgsUnwrap, LocalChartArgsUnwrap>.FromT1(
new LocalChartArgsUnwrap
{
ApiVersions = vs.Item1,
IncludeTestHookResources = vs.Item2,
Namespace = vs.Item3,
Values = vs.Item4,
SkipCRDRendering = vs.Item3,
Namespace = vs.Item4,
Values = vs.Item5,
Transformations = v.Transformations,
ResourcePrefix = v.ResourcePrefix,
Path = v.Path
Expand Down
4 changes: 4 additions & 0 deletions provider/pkg/gen/dotnet-templates/helm/v3/Chart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ private static string GetName(Union<ChartArgs, LocalChartArgs> config, string re
{
ApiVersions = cfgBase.ApiVersions,
IncludeTestHookResources = cfgBase.IncludeTestHookResources,
SkipCRDRendering = cfgBase.SkipCRDRendering,
Namespace = cfgBase.Namespace,
Values = cfgBase.Values,
ReleaseName = releaseName,
Expand Down Expand Up @@ -347,6 +348,7 @@ private static string GetName(Union<ChartArgs, LocalChartArgs> config, string re
{
ApiVersions = cfgBase.ApiVersions,
IncludeTestHookResources = cfgBase.IncludeTestHookResources,
SkipCRDRendering = cfgBase.SkipCRDRendering,
Namespace = cfgBase.Namespace,
Values = cfgBase.Values,
ReleaseName = releaseName,
Expand Down Expand Up @@ -376,6 +378,8 @@ internal class JsonOpts
public ImmutableArray<string> ApiVersions { get; set; }
[JsonPropertyName("include_test_hook_resources")]
public bool? IncludeTestHookResources { get; set; }
[JsonPropertyName("skip_crd_rendering")]
public bool? SkipCRDRendering { get; set; }
[JsonPropertyName("namespace")]
public string? Namespace { get; set; }
[JsonPropertyName("values")]
Expand Down
3 changes: 3 additions & 0 deletions provider/pkg/gen/go-templates/helm/v3/pulumiTypes.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ type ChartArgs struct {
// By default, Helm resources with the `test`, `test-success`, and `test-failure` hooks are not installed. Set
// this flag to true to include these resources.
IncludeTestHookResources pulumi.BoolInput
// By default CRDs are also rendered along side templates. Set this to skip CRDs.
SkipCRDRendering pulumi.BoolInput
// The optional namespace to install chart resources into.
Namespace pulumi.StringInput
// Overrides for chart values.
Expand Down Expand Up @@ -153,6 +155,7 @@ type ChartArgs struct {
type chartArgs struct {
APIVersions []string `json:"api_versions,omitempty" pulumi:"apiVersions"`
IncludeTestHookResources bool `json:"include_test_hook_resources,omitempty" pulumi:"includeTestHookResources"`
SkipCRDRendering bool `json:"skip_crd_rendering,omitempty" pulumi:"skipCRDRendering"`
Namespace string `json:"namespace,omitempty" pulumi:"namespace"`
Values map[string]interface{} `json:"values,omitempty" pulumi:"values"`
Transformations []yaml.Transformation `json:"-" pulumi:"transformations"`
Expand Down
8 changes: 8 additions & 0 deletions provider/pkg/gen/nodejs-templates/helm/v3/helm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,10 @@ export class Chart extends yaml.CollectionComponentResource {
obj["include_test_hook_resources"] = value;
break;
}
case "skipCRDRendering": {
obj["skip_crd_rendering"] = value;
break;
}
case "releaseName": {
obj["release_name"] = value;
break;
Expand Down Expand Up @@ -241,6 +245,10 @@ interface BaseChartOpts {
* this flag to true to include these resources.
*/
includeTestHookResources?: boolean;
/**
* By default, CRDs are rendered along with Helm chart templates. Setting this to true will skip CRD rendering.
*/
skipCRDRendering?: boolean;
/**
* The optional namespace to install chart resources into.
*/
Expand Down
25 changes: 20 additions & 5 deletions provider/pkg/gen/python-templates/helm/v3/helm.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,13 +388,19 @@ class BaseChartOpts:
this flag to true to include these resources.
"""

skip_crd_rendering: Optional[pulumi.Input[bool]]
"""
By default, CRDs are rendered along with Helm chart templates. Setting this to true will skip CRD rendering.
"""

def __init__(self,
namespace: Optional[pulumi.Input[str]] = None,
values: Optional[pulumi.Inputs] = None,
transformations: Optional[Sequence[Callable[[Any, pulumi.ResourceOptions], None]]] = None,
resource_prefix: Optional[str] = None,
api_versions: Optional[Sequence[pulumi.Input[str]]] = None,
include_test_hook_resources: Optional[pulumi.Input[bool]] = None):
include_test_hook_resources: Optional[pulumi.Input[bool]] = None,
skip_crd_rendering: Optional[pulumi.Input[bool]] = None):
"""
:param Optional[pulumi.Input[str]] namespace: Optional namespace to install chart resources into.
:param Optional[pulumi.Inputs] values: Optional overrides for chart values.
Expand All @@ -408,9 +414,12 @@ def __init__(self,
:param Optional[pulumi.Input[bool]] include_test_hook_resources: By default, Helm resources with the 'test',
'test-success', and 'test-failure' hooks are not installed. Set this flag to true to include these
resources.
:param Optional[pulumi.Input[bool]] skip_crd_rendering: By default, CRDs are rendered along with Helm chart
templates. Setting this to true will skip CRD rendering.
"""
self.namespace = namespace
self.include_test_hook_resources = include_test_hook_resources
self.skip_crd_rendering = skip_crd_rendering
self.values = values
self.transformations = transformations
self.resource_prefix = resource_prefix
Expand Down Expand Up @@ -459,7 +468,8 @@ def __init__(self,
version: Optional[pulumi.Input[str]] = None,
fetch_opts: Optional[pulumi.Input[FetchOpts]] = None,
api_versions: Optional[Sequence[pulumi.Input[str]]] = None,
include_test_hook_resources: Optional[pulumi.Input[bool]] = None):
include_test_hook_resources: Optional[pulumi.Input[bool]] = None,
skip_crd_install: Optional[pulumi.Input[bool]] = None):
"""
:param pulumi.Input[str] chart: The name of the chart to deploy. If `repo` is provided, this chart name
will be prefixed by the repo name.
Expand All @@ -483,9 +493,11 @@ def __init__(self,
:param Optional[pulumi.Input[bool]] include_test_hook_resources: By default, Helm resources with the 'test',
'test-success', and 'test-failure' hooks are not installed. Set this flag to true to include these
resources.
:param Optional[pulumi.Input[bool]] skip_crd_rendering: By default, CRDs are rendered along with Helm chart
templates. Setting this to true will skip CRD rendering.
"""
super(ChartOpts, self).__init__(namespace, values, transformations, resource_prefix, api_versions,
include_test_hook_resources)
include_test_hook_resources, skip_crd_install)
self.chart = chart
self.repo = repo
self.version = version
Expand All @@ -509,7 +521,8 @@ def __init__(self,
transformations: Optional[Sequence[Callable[[Any, pulumi.ResourceOptions], None]]] = None,
resource_prefix: Optional[str] = None,
api_versions: Optional[Sequence[pulumi.Input[str]]] = None,
include_test_hook_resources: Optional[pulumi.Input[bool]] = None):
include_test_hook_resources: Optional[pulumi.Input[bool]] = None,
skip_crd_rendering: Optional[pulumi.Input[bool]] = None):
"""
:param pulumi.Input[str] path: The path to the chart directory which contains the
`Chart.yaml` file.
Expand All @@ -525,10 +538,12 @@ def __init__(self,
:param Optional[pulumi.Input[bool]] include_test_hook_resources: By default, Helm resources with the 'test',
'test-success', and 'test-failure' hooks are not installed. Set this flag to true to include these
resources.
:param Optional[pulumi.Input[bool]] skip_crd_rendering: By default, CRDs are rendered along with Helm chart
templates. Setting this to true will skip CRD rendering.
"""

super(LocalChartOpts, self).__init__(namespace, values, transformations, resource_prefix, api_versions,
include_test_hook_resources)
include_test_hook_resources, skip_crd_rendering)
self.path = path


Expand Down
3 changes: 2 additions & 1 deletion provider/pkg/provider/invoke_helm_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ type HelmChartOpts struct {
APIVersions []string `json:"api_versions,omitempty"`
Chart string `json:"chart,omitempty"`
IncludeTestHookResources bool `json:"include_test_hook_resources,omitempty"`
SkipCRDRendering bool `json:"skip_crd_rendering,omitempty"`
Namespace string `json:"namespace,omitempty"`
Path string `json:"path,omitempty"`
ReleaseName string `json:"release_name,omitempty"`
Expand Down Expand Up @@ -211,7 +212,7 @@ func (c *chart) template() (string, error) {
installAction.APIVersions = c.opts.APIVersions
installAction.ClientOnly = true
installAction.DryRun = true
installAction.IncludeCRDs = true // TODO: handle this conditionally?
installAction.IncludeCRDs = !c.opts.SkipCRDRendering
installAction.Namespace = c.opts.Namespace
installAction.NameTemplate = c.opts.ReleaseName
installAction.ReleaseName = c.opts.ReleaseName
Expand Down
5 changes: 5 additions & 0 deletions sdk/dotnet/Helm/ChartBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,11 @@ public InputList<string> ApiVersions
/// </summary>
public Input<bool>? IncludeTestHookResources { get; set; }

// <summary>
// By default, CRDs are rendered along with Helm chart templates. Setting this to true will skip CRD rendering.
// </summary>
public Input<bool>? SkipCRDRendering {get; set; }

/// <summary>
/// The optional namespace to install chart resources into.
/// </summary>
Expand Down
25 changes: 14 additions & 11 deletions sdk/dotnet/Helm/Unwraps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ internal class BaseChartArgsUnwrap
{
public ImmutableArray<string> ApiVersions { get; set; }
public bool? IncludeTestHookResources { get; set; }
public bool? SkipCRDRendering { get; set; }
public string? Namespace { get; set; }
public ImmutableDictionary<string, object> Values { get; set; } = null!;
public List<TransformationAction> Transformations { get; set; } = null!;
Expand Down Expand Up @@ -68,29 +69,31 @@ internal static class Extensions
public static Output<Union<ChartArgsUnwrap, LocalChartArgsUnwrap>> Unwrap(this Union<ChartArgs, LocalChartArgs> options)
{
return options.Match(
v => Output.Tuple(v.ApiVersions, v.IncludeTestHookResources.ToNullable(), v.Namespace.ToNullable(), v.Values, v.Repo.ToNullable(), v.Chart, v.Version.ToNullable(), v.FetchOptions.Unwrap()).Apply(vs =>
v => Output.Tuple(v.ApiVersions, v.Namespace.ToNullable(), v.Values, v.Repo.ToNullable(), v.Chart, v.Version.ToNullable(), v.FetchOptions.Unwrap(), new InputList<bool?> { v.IncludeTestHookResources.ToNullable(), v.SkipCRDRendering.ToNullable() }).Apply(vs =>
Union<ChartArgsUnwrap, LocalChartArgsUnwrap>.FromT0(
new ChartArgsUnwrap
{
ApiVersions = vs.Item1,
IncludeTestHookResources = vs.Item2,
Namespace = vs.Item3,
Values = vs.Item4,
Namespace = vs.Item2,
Values = vs.Item3,
Transformations = v.Transformations,
ResourcePrefix = v.ResourcePrefix,
Repo = vs.Item5,
Chart = vs.Item6,
Version = vs.Item7,
FetchOptions = vs.Item8
Repo = vs.Item4,
Chart = vs.Item5,
Version = vs.Item6,
FetchOptions = vs.Item7,
IncludeTestHookResources = vs.Item8[0],
SkipCRDRendering = vs.Item8[1]
})),
v => Output.Tuple(v.ApiVersions, v.IncludeTestHookResources.ToNullable(), v.Namespace.ToNullable(), v.Values).Apply(vs =>
v => Output.Tuple(v.ApiVersions, v.IncludeTestHookResources.ToNullable(), v.SkipCRDRendering.ToNullable(), v.Namespace.ToNullable(), v.Values).Apply(vs =>
Union<ChartArgsUnwrap, LocalChartArgsUnwrap>.FromT1(
new LocalChartArgsUnwrap
{
ApiVersions = vs.Item1,
IncludeTestHookResources = vs.Item2,
Namespace = vs.Item3,
Values = vs.Item4,
SkipCRDRendering = vs.Item3,
Namespace = vs.Item4,
Values = vs.Item5,
Transformations = v.Transformations,
ResourcePrefix = v.ResourcePrefix,
Path = v.Path
Expand Down
4 changes: 4 additions & 0 deletions sdk/dotnet/Helm/V3/Chart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ private static string GetName(Union<ChartArgs, LocalChartArgs> config, string re
{
ApiVersions = cfgBase.ApiVersions,
IncludeTestHookResources = cfgBase.IncludeTestHookResources,
SkipCRDRendering = cfgBase.SkipCRDRendering,
Namespace = cfgBase.Namespace,
Values = cfgBase.Values,
ReleaseName = releaseName,
Expand Down Expand Up @@ -347,6 +348,7 @@ private static string GetName(Union<ChartArgs, LocalChartArgs> config, string re
{
ApiVersions = cfgBase.ApiVersions,
IncludeTestHookResources = cfgBase.IncludeTestHookResources,
SkipCRDRendering = cfgBase.SkipCRDRendering,
Namespace = cfgBase.Namespace,
Values = cfgBase.Values,
ReleaseName = releaseName,
Expand Down Expand Up @@ -376,6 +378,8 @@ internal class JsonOpts
public ImmutableArray<string> ApiVersions { get; set; }
[JsonPropertyName("include_test_hook_resources")]
public bool? IncludeTestHookResources { get; set; }
[JsonPropertyName("skip_crd_rendering")]
public bool? SkipCRDRendering { get; set; }
[JsonPropertyName("namespace")]
public string? Namespace { get; set; }
[JsonPropertyName("values")]
Expand Down
3 changes: 3 additions & 0 deletions sdk/go/kubernetes/helm/v3/pulumiTypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ type ChartArgs struct {
// By default, Helm resources with the `test`, `test-success`, and `test-failure` hooks are not installed. Set
// this flag to true to include these resources.
IncludeTestHookResources pulumi.BoolInput
// By default CRDs are also rendered along side templates. Set this to skip CRDs.
SkipCRDRendering pulumi.BoolInput
// The optional namespace to install chart resources into.
Namespace pulumi.StringInput
// Overrides for chart values.
Expand Down Expand Up @@ -153,6 +155,7 @@ type ChartArgs struct {
type chartArgs struct {
APIVersions []string `json:"api_versions,omitempty" pulumi:"apiVersions"`
IncludeTestHookResources bool `json:"include_test_hook_resources,omitempty" pulumi:"includeTestHookResources"`
SkipCRDRendering bool `json:"skip_crd_rendering,omitempty" pulumi:"skipCRDRendering"`
Namespace string `json:"namespace,omitempty" pulumi:"namespace"`
Values map[string]interface{} `json:"values,omitempty" pulumi:"values"`
Transformations []yaml.Transformation `json:"-" pulumi:"transformations"`
Expand Down
Loading