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 a plainHttp option to v4.Chart #3282

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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 CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Unreleased

### Added

- Added a `plainHttp` option to the `v4.Chart` resource. (https://github.com/pulumi/pulumi-kubernetes/issues/3250)

## 4.18.2 (October 16, 2024)

### Fixed
Expand Down
4 changes: 4 additions & 0 deletions provider/cmd/pulumi-resource-kubernetes/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -91023,6 +91023,10 @@
"type": "string",
"description": "Namespace for the release."
},
"plainHttp": {
"type": "boolean",
"description": "Use insecure HTTP for the chart download instead of HTTPS."
},
"postRenderer": {
"$ref": "#/types/kubernetes:helm.sh/v4:PostRenderer",
"description": "Specification defining the post-renderer to use."
Expand Down
6 changes: 6 additions & 0 deletions provider/pkg/gen/overlays.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,12 @@ var helmV4ChartResource = pschema.ResourceSpec{
},
Description: "By default, the provider waits until all resources are in a ready state before marking the release as successful. Setting this to true will skip such await logic.",
},
"plainHttp": {
TypeSpec: pschema.TypeSpec{
Type: "boolean",
},
Description: "Use insecure HTTP for the chart download instead of HTTPS.",
},
"resourcePrefix": {
TypeSpec: pschema.TypeSpec{
Type: "string",
Expand Down
2 changes: 1 addition & 1 deletion provider/pkg/helm/tool.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ func (cmd *TemplateCommand) Execute(ctx context.Context) (*release.Release, erro
client.Replace = true // Skip the name check
client.ClientOnly = !cmd.Validate
client.IncludeCRDs = cmd.IncludeCRDs
client.PlainHTTP = cmd.PlainHTTP

return cmd.runInstall(ctx)
}
Expand Down Expand Up @@ -457,7 +458,6 @@ type cleanupF func() error

// downloadAsset downloads an asset to the local filesystem.
func downloadAsset(p getter.Providers, asset pulumi.AssetOrArchive) (string, cleanupF, error) {

a, isAsset := asset.(pulumi.Asset)
if !isAsset {
return "", nil, errors.New("expected an asset")
Expand Down
13 changes: 9 additions & 4 deletions provider/pkg/provider/helm/v4/chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ type ChartArgs struct {

ResourcePrefix pulumi.StringInput `pulumi:"resourcePrefix,optional"`
SkipAwait pulumi.BoolInput `pulumi:"skipAwait,optional"`
PlainHTTP pulumi.BoolInput `pulumi:"plainHttp,optional"`
}

type chartArgs struct {
Expand All @@ -79,14 +80,15 @@ type chartArgs struct {

ResourcePrefix *string
SkipAwait bool
PlainHTTP bool
}

func unwrapChartArgs(ctx context.Context, args *ChartArgs) (*chartArgs, internals.UnsafeAwaitOutputResult, error) {
result, err := internals.UnsafeAwaitOutput(ctx, pulumi.All(
args.Name, args.Namespace,
args.Chart, args.Version, args.Devel, args.RepositoryOpts, args.DependencyUpdate, args.Verify, args.Keyring,
args.Values, args.ValuesFiles, args.SkipCrds, args.PostRenderer,
args.ResourcePrefix, args.SkipAwait))
args.ResourcePrefix, args.SkipAwait, args.PlainHTTP))
if err != nil || !result.Known {
return nil, result, err
}
Expand Down Expand Up @@ -118,6 +120,7 @@ func unwrapChartArgs(ctx context.Context, args *ChartArgs) (*chartArgs, internal
r.ResourcePrefix = &v
}
r.SkipAwait, _ = pop().(bool)
r.PlainHTTP, _ = pop().(bool)

return r, result, nil
}
Expand Down Expand Up @@ -215,6 +218,7 @@ func (r *ChartProvider) Construct(ctx *pulumi.Context, typ, name string, inputs
cmd.DisableHooks = true
cmd.ReleaseName = chartArgs.Name
cmd.Namespace = chartArgs.Namespace
cmd.PlainHTTP = chartArgs.PlainHTTP

if chartArgs.PostRenderer != nil {
postrenderer, err := postrender.NewExec(chartArgs.PostRenderer.Command, chartArgs.PostRenderer.Args...)
Expand Down Expand Up @@ -262,7 +266,8 @@ func (r *ChartProvider) Construct(ctx *pulumi.Context, typ, name string, inputs
SkipAwait: chartArgs.SkipAwait,
ResourceOptions: []pulumi.ResourceOption{pulumi.Parent(comp)},
PreRegisterF: func(ctx *pulumi.Context, apiVersion, kind, resourceName string, obj *unstructured.Unstructured,
resourceOpts []pulumi.ResourceOption) (*unstructured.Unstructured, []pulumi.ResourceOption) {
resourceOpts []pulumi.ResourceOption,
) (*unstructured.Unstructured, []pulumi.ResourceOption) {
return preregister(ctx, comp, obj, resourceOpts)
},
}
Expand All @@ -276,8 +281,8 @@ func (r *ChartProvider) Construct(ctx *pulumi.Context, typ, name string, inputs
}

func preregister(ctx *pulumi.Context, comp *ChartState, obj *unstructured.Unstructured,
resourceOpts []pulumi.ResourceOption) (*unstructured.Unstructured, []pulumi.ResourceOption) {

resourceOpts []pulumi.ResourceOption,
) (*unstructured.Unstructured, []pulumi.ResourceOption) {
// Implement support for Helm resource policies.
// https://helm.sh/docs/howto/charts_tips_and_tricks/#tell-helm-not-to-uninstall-a-resource
policy, hasPolicy, err := unstructured.NestedString(obj.Object, "metadata", "annotations", helmkube.ResourcePolicyAnno)
Expand Down
19 changes: 19 additions & 0 deletions provider/pkg/provider/helm/v4/chart_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,25 @@ var _ = Describe("Construct", func() {
})
})

Describe("Plain HTTP set", func() {
BeforeEach(func() {
inputs["plainHttp"] = resource.NewBoolProperty(true)
})
It("should use plain HTTP", func(ctx context.Context) {
_, err := pulumiprovider.Construct(ctx, req, tc.EngineConn(), k.Construct)
Expect(err).ShouldNot(HaveOccurred())
Expect(executor.Action().PlainHTTP).To(Equal(true))
})
})

Describe("Plain HTTP unset", func() {
It("should not use plain HTTP by default", func(ctx context.Context) {
_, err := pulumiprovider.Construct(ctx, req, tc.EngineConn(), k.Construct)
Expect(err).ShouldNot(HaveOccurred())
Expect(executor.Action().PlainHTTP).To(Equal(false))
})
})

Describe("helm.sh/resource-policy: keep", func() {
BeforeEach(func() {
inputs["values"] = resource.NewObjectProperty(resource.NewPropertyMapFromMap(map[string]any{
Expand Down
6 changes: 6 additions & 0 deletions sdk/dotnet/Helm/V4/Chart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,12 @@ public class ChartArgs : global::Pulumi.ResourceArgs
[Input("namespace")]
public Input<string>? Namespace { get; set; }

/// <summary>
/// Use insecure HTTP for the chart download instead of HTTPS.
/// </summary>
[Input("plainHttp")]
public Input<bool>? PlainHttp { get; set; }

/// <summary>
/// Specification defining the post-renderer to use.
/// </summary>
Expand Down
4 changes: 4 additions & 0 deletions sdk/go/kubernetes/helm/v4/chart.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,21 @@ public Optional<Output<String>> namespace() {
return Optional.ofNullable(this.namespace);
}

/**
* Use insecure HTTP for the chart download instead of HTTPS.
*
*/
@Import(name="plainHttp")
private @Nullable Output<Boolean> plainHttp;

/**
* @return Use insecure HTTP for the chart download instead of HTTPS.
*
*/
public Optional<Output<Boolean>> plainHttp() {
return Optional.ofNullable(this.plainHttp);
}

/**
* Specification defining the post-renderer to use.
*
Expand Down Expand Up @@ -257,6 +272,7 @@ private ChartArgs(ChartArgs $) {
this.keyring = $.keyring;
this.name = $.name;
this.namespace = $.namespace;
this.plainHttp = $.plainHttp;
this.postRenderer = $.postRenderer;
this.repositoryOpts = $.repositoryOpts;
this.resourcePrefix = $.resourcePrefix;
Expand Down Expand Up @@ -412,6 +428,27 @@ public Builder namespace(String namespace) {
return namespace(Output.of(namespace));
}

/**
* @param plainHttp Use insecure HTTP for the chart download instead of HTTPS.
*
* @return builder
*
*/
public Builder plainHttp(@Nullable Output<Boolean> plainHttp) {
$.plainHttp = plainHttp;
return this;
}

/**
* @param plainHttp Use insecure HTTP for the chart download instead of HTTPS.
*
* @return builder
*
*/
public Builder plainHttp(Boolean plainHttp) {
return plainHttp(Output.of(plainHttp));
}

/**
* @param postRenderer Specification defining the post-renderer to use.
*
Expand Down
5 changes: 5 additions & 0 deletions sdk/nodejs/helm/v4/chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ export class Chart extends pulumi.ComponentResource {
resourceInputs["keyring"] = args ? args.keyring : undefined;
resourceInputs["name"] = args ? args.name : undefined;
resourceInputs["namespace"] = args ? args.namespace : undefined;
resourceInputs["plainHttp"] = args ? args.plainHttp : undefined;
resourceInputs["postRenderer"] = args ? args.postRenderer : undefined;
resourceInputs["repositoryOpts"] = args ? args.repositoryOpts : undefined;
resourceInputs["resourcePrefix"] = args ? args.resourcePrefix : undefined;
Expand Down Expand Up @@ -254,6 +255,10 @@ export interface ChartArgs {
* Namespace for the release.
*/
namespace?: pulumi.Input<string>;
/**
* Use insecure HTTP for the chart download instead of HTTPS.
*/
plainHttp?: pulumi.Input<boolean>;
/**
* Specification defining the post-renderer to use.
*/
Expand Down
20 changes: 20 additions & 0 deletions sdk/python/pulumi_kubernetes/helm/v4/Chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def __init__(__self__, *,
keyring: Optional[pulumi.Input[Union[pulumi.Asset, pulumi.Archive]]] = None,
name: Optional[pulumi.Input[str]] = None,
namespace: Optional[pulumi.Input[str]] = None,
plain_http: Optional[pulumi.Input[bool]] = None,
post_renderer: Optional[pulumi.Input['PostRendererArgs']] = None,
repository_opts: Optional[pulumi.Input['RepositoryOptsArgs']] = None,
resource_prefix: Optional[pulumi.Input[str]] = None,
Expand All @@ -43,6 +44,7 @@ def __init__(__self__, *,
:param pulumi.Input[Union[pulumi.Asset, pulumi.Archive]] keyring: Location of public keys used for verification. Used only if `verify` is true
:param pulumi.Input[str] name: Release name.
:param pulumi.Input[str] namespace: Namespace for the release.
:param pulumi.Input[bool] plain_http: Use insecure HTTP for the chart download instead of HTTPS.
:param pulumi.Input['PostRendererArgs'] post_renderer: Specification defining the post-renderer to use.
:param pulumi.Input['RepositoryOptsArgs'] repository_opts: Specification defining the Helm chart repository to use.
:param pulumi.Input[str] resource_prefix: An optional prefix for the auto-generated resource names. Example: A resource created with resourcePrefix="foo" would produce a resource named "foo:resourceName".
Expand All @@ -64,6 +66,8 @@ def __init__(__self__, *,
pulumi.set(__self__, "name", name)
if namespace is not None:
pulumi.set(__self__, "namespace", namespace)
if plain_http is not None:
pulumi.set(__self__, "plain_http", plain_http)
if post_renderer is not None:
pulumi.set(__self__, "post_renderer", post_renderer)
if repository_opts is not None:
Expand Down Expand Up @@ -155,6 +159,18 @@ def namespace(self) -> Optional[pulumi.Input[str]]:
def namespace(self, value: Optional[pulumi.Input[str]]):
pulumi.set(self, "namespace", value)

@property
@pulumi.getter(name="plainHttp")
def plain_http(self) -> Optional[pulumi.Input[bool]]:
"""
Use insecure HTTP for the chart download instead of HTTPS.
"""
return pulumi.get(self, "plain_http")

@plain_http.setter
def plain_http(self, value: Optional[pulumi.Input[bool]]):
pulumi.set(self, "plain_http", value)

@property
@pulumi.getter(name="postRenderer")
def post_renderer(self) -> Optional[pulumi.Input['PostRendererArgs']]:
Expand Down Expand Up @@ -275,6 +291,7 @@ def __init__(__self__,
keyring: Optional[pulumi.Input[Union[pulumi.Asset, pulumi.Archive]]] = None,
name: Optional[pulumi.Input[str]] = None,
namespace: Optional[pulumi.Input[str]] = None,
plain_http: Optional[pulumi.Input[bool]] = None,
post_renderer: Optional[pulumi.Input[Union['PostRendererArgs', 'PostRendererArgsDict']]] = None,
repository_opts: Optional[pulumi.Input[Union['RepositoryOptsArgs', 'RepositoryOptsArgsDict']]] = None,
resource_prefix: Optional[pulumi.Input[str]] = None,
Expand Down Expand Up @@ -458,6 +475,7 @@ def __init__(__self__,
:param pulumi.Input[Union[pulumi.Asset, pulumi.Archive]] keyring: Location of public keys used for verification. Used only if `verify` is true
:param pulumi.Input[str] name: Release name.
:param pulumi.Input[str] namespace: Namespace for the release.
:param pulumi.Input[bool] plain_http: Use insecure HTTP for the chart download instead of HTTPS.
:param pulumi.Input[Union['PostRendererArgs', 'PostRendererArgsDict']] post_renderer: Specification defining the post-renderer to use.
:param pulumi.Input[Union['RepositoryOptsArgs', 'RepositoryOptsArgsDict']] repository_opts: Specification defining the Helm chart repository to use.
:param pulumi.Input[str] resource_prefix: An optional prefix for the auto-generated resource names. Example: A resource created with resourcePrefix="foo" would produce a resource named "foo:resourceName".
Expand Down Expand Up @@ -660,6 +678,7 @@ def _internal_init(__self__,
keyring: Optional[pulumi.Input[Union[pulumi.Asset, pulumi.Archive]]] = None,
name: Optional[pulumi.Input[str]] = None,
namespace: Optional[pulumi.Input[str]] = None,
plain_http: Optional[pulumi.Input[bool]] = None,
post_renderer: Optional[pulumi.Input[Union['PostRendererArgs', 'PostRendererArgsDict']]] = None,
repository_opts: Optional[pulumi.Input[Union['RepositoryOptsArgs', 'RepositoryOptsArgsDict']]] = None,
resource_prefix: Optional[pulumi.Input[str]] = None,
Expand Down Expand Up @@ -688,6 +707,7 @@ def _internal_init(__self__,
__props__.__dict__["keyring"] = keyring
__props__.__dict__["name"] = name
__props__.__dict__["namespace"] = namespace
__props__.__dict__["plain_http"] = plain_http
__props__.__dict__["post_renderer"] = post_renderer
__props__.__dict__["repository_opts"] = repository_opts
__props__.__dict__["resource_prefix"] = resource_prefix
Expand Down
Loading