From fecef13da5c97b03c6737714868d787522f252a6 Mon Sep 17 00:00:00 2001 From: Levi Blackstone Date: Wed, 17 May 2023 12:12:00 -0600 Subject: [PATCH] Remove deprecated helm/v2 SDK (#2396) The helm/v2 SDK is deprecated, and is now being removed. The helm/v3 SDK provides equivalent support, but uses the helm client library rather than shelling out to the helm CLI. The v2:Chart and v3:Chart resources are already aliased, so users can update the SDK in code without a disruptive update. --- provider/cmd/pulumi-gen-kubernetes/main.go | 7 +- .../pulumi-resource-kubernetes/schema.json | 127 ---- .../pkg/gen/_go-templates/helm/v2/chart.go | 527 -------------- .../gen/_go-templates/helm/v2/pulumiTypes.go | 198 ----- .../pkg/gen/dotnet-templates/helm/v2/Chart.cs | 237 ------ .../pkg/gen/nodejs-templates/helm/v2/helm.ts | 483 ------------- provider/pkg/gen/overlays.go | 96 +-- .../pkg/gen/python-templates/helm/v2/helm.py | 677 ------------------ sdk/dotnet/Helm/V2/Chart.cs | 237 ------ sdk/go/kubernetes/helm/v2/chart.go | 527 -------------- sdk/go/kubernetes/helm/v2/pulumiTypes.go | 198 ----- sdk/nodejs/helm/index.ts | 2 - sdk/nodejs/helm/v2/helm.ts | 483 ------------- sdk/nodejs/helm/v2/index.ts | 5 - sdk/nodejs/tsconfig.json | 2 - sdk/python/pulumi_kubernetes/helm/__init__.py | 3 - .../pulumi_kubernetes/helm/v2/__init__.py | 8 - sdk/python/pulumi_kubernetes/helm/v2/helm.py | 677 ------------------ tests/sdk/dotnet/dotnet_test.go | 22 +- .../dotnet/helm-api-versions/step1/Program.cs | 2 +- .../dotnet/helm-api-versions/step2/Program.cs | 49 -- tests/sdk/dotnet/helm-local/step1/Program.cs | 2 +- tests/sdk/dotnet/helm-local/step2/Program.cs | 90 --- tests/sdk/dotnet/helm/step1/Program.cs | 2 +- tests/sdk/dotnet/helm/step2/Program.cs | 112 --- tests/sdk/go/go_test.go | 23 +- tests/sdk/go/helm-api-versions/step1/main.go | 2 +- tests/sdk/go/helm-api-versions/step2/main.go | 36 - tests/sdk/go/helm-local/step1/main.go | 2 +- tests/sdk/go/helm-local/step2/main.go | 38 - tests/sdk/go/helm/step1/main.go | 2 +- tests/sdk/go/helm/step2/main.go | 32 - tests/sdk/nodejs/examples/examples_test.go | 23 +- .../examples/helm-api-versions/step1/index.ts | 4 +- .../examples/helm-api-versions/step2/index.ts | 15 - .../nodejs/examples/helm-local/step1/index.ts | 4 +- .../nodejs/examples/helm-local/step2/index.ts | 56 -- tests/sdk/nodejs/examples/helm/step1/index.ts | 8 +- tests/sdk/nodejs/examples/helm/step2/index.ts | 65 -- .../sdk/python/get-old/step1/requirements.txt | 2 +- .../sdk/python/get-one-step/requirements.txt | 2 +- tests/sdk/python/get/step1/requirements.txt | 2 +- .../sdk/python/guestbook-old/requirements.txt | 2 +- tests/sdk/python/guestbook/requirements.txt | 2 +- .../helm-api-versions/step1/__main__.py | 2 +- .../helm-api-versions/step1/requirements.txt | 2 +- .../helm-api-versions/step2/__main__.py | 29 - tests/sdk/python/helm-local/step1/__main__.py | 2 +- tests/sdk/python/helm-local/step2/__main__.py | 26 - .../helm-release/step1/requirements.txt | 2 +- .../step1/requirements.txt | 2 +- tests/sdk/python/helm/step1/__main__.py | 2 +- tests/sdk/python/helm/step1/requirements.txt | 4 +- tests/sdk/python/helm/step2/__main__.py | 53 -- tests/sdk/python/kustomize/requirements.txt | 2 +- .../sdk/python/provider-old/requirements.txt | 2 +- tests/sdk/python/provider/requirements.txt | 2 +- tests/sdk/python/python_test.go | 22 - .../python/smoke-test-old/requirements.txt | 2 +- tests/sdk/python/smoke-test/requirements.txt | 2 +- tests/sdk/python/yaml-test/requirements.txt | 2 +- 61 files changed, 40 insertions(+), 5211 deletions(-) delete mode 100644 provider/pkg/gen/_go-templates/helm/v2/chart.go delete mode 100644 provider/pkg/gen/_go-templates/helm/v2/pulumiTypes.go delete mode 100644 provider/pkg/gen/dotnet-templates/helm/v2/Chart.cs delete mode 100644 provider/pkg/gen/nodejs-templates/helm/v2/helm.ts delete mode 100644 provider/pkg/gen/python-templates/helm/v2/helm.py delete mode 100644 sdk/dotnet/Helm/V2/Chart.cs delete mode 100644 sdk/go/kubernetes/helm/v2/chart.go delete mode 100644 sdk/go/kubernetes/helm/v2/pulumiTypes.go delete mode 100644 sdk/nodejs/helm/v2/helm.ts delete mode 100644 sdk/nodejs/helm/v2/index.ts delete mode 100644 sdk/python/pulumi_kubernetes/helm/v2/__init__.py delete mode 100644 sdk/python/pulumi_kubernetes/helm/v2/helm.py delete mode 100644 tests/sdk/dotnet/helm-api-versions/step2/Program.cs delete mode 100644 tests/sdk/dotnet/helm-local/step2/Program.cs delete mode 100644 tests/sdk/dotnet/helm/step2/Program.cs delete mode 100644 tests/sdk/go/helm-api-versions/step2/main.go delete mode 100644 tests/sdk/go/helm-local/step2/main.go delete mode 100644 tests/sdk/go/helm/step2/main.go delete mode 100644 tests/sdk/nodejs/examples/helm-api-versions/step2/index.ts delete mode 100644 tests/sdk/nodejs/examples/helm-local/step2/index.ts delete mode 100644 tests/sdk/nodejs/examples/helm/step2/index.ts delete mode 100644 tests/sdk/python/helm-api-versions/step2/__main__.py delete mode 100644 tests/sdk/python/helm-local/step2/__main__.py delete mode 100644 tests/sdk/python/helm/step2/__main__.py diff --git a/provider/cmd/pulumi-gen-kubernetes/main.go b/provider/cmd/pulumi-gen-kubernetes/main.go index b6a76f8893..655331c692 100644 --- a/provider/cmd/pulumi-gen-kubernetes/main.go +++ b/provider/cmd/pulumi-gen-kubernetes/main.go @@ -1,4 +1,4 @@ -// Copyright 2016-2021, Pulumi Corporation. +// Copyright 2016-2023, Pulumi Corporation. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -216,7 +216,6 @@ func writeNodeJSClient(pkg *schema.Package, outdir, templateDir string) { overlays := map[string][]byte{ "apiextensions/customResource.ts": mustLoadFile(filepath.Join(templateDir, "apiextensions", "customResource.ts")), "apiextensions/customResourcePatch.ts": mustLoadFile(filepath.Join(templateDir, "apiextensions", "customResourcePatch.ts")), - "helm/v2/helm.ts": mustLoadFile(filepath.Join(templateDir, "helm", "v2", "helm.ts")), "helm/v3/helm.ts": mustLoadFile(filepath.Join(templateDir, "helm", "v3", "helm.ts")), "kustomize/kustomize.ts": mustLoadFile(filepath.Join(templateDir, "kustomize", "kustomize.ts")), "yaml/yaml.ts": mustRenderTemplate(filepath.Join(templateDir, "yaml", "yaml.tmpl"), templateResources), @@ -264,7 +263,6 @@ func writePythonClient(pkg *schema.Package, outdir string, templateDir string) { overlays := map[string][]byte{ "apiextensions/CustomResource.py": mustLoadFile(filepath.Join(templateDir, "apiextensions", "CustomResource.py")), "apiextensions/CustomResourcePatch.py": mustLoadFile(filepath.Join(templateDir, "apiextensions", "CustomResourcePatch.py")), - "helm/v2/helm.py": mustLoadFile(filepath.Join(templateDir, "helm", "v2", "helm.py")), "helm/v3/helm.py": mustLoadFile(filepath.Join(templateDir, "helm", "v3", "helm.py")), "kustomize/kustomize.py": mustLoadFile(filepath.Join(templateDir, "kustomize", "kustomize.py")), "yaml/yaml.py": mustRenderTemplate(filepath.Join(templateDir, "yaml", "yaml.tmpl"), templateResources), @@ -307,7 +305,6 @@ func writeDotnetClient(pkg *schema.Package, outdir, templateDir string) { "ApiExtensions/CustomResourcePatch.cs": mustLoadFile(filepath.Join(templateDir, "apiextensions", "CustomResourcePatch.cs")), "Helm/ChartBase.cs": mustLoadFile(filepath.Join(templateDir, "helm", "ChartBase.cs")), "Helm/Unwraps.cs": mustLoadFile(filepath.Join(templateDir, "helm", "Unwraps.cs")), - "Helm/V2/Chart.cs": mustLoadFile(filepath.Join(templateDir, "helm", "v2", "Chart.cs")), "Helm/V3/Chart.cs": mustLoadFile(filepath.Join(templateDir, "helm", "v3", "Chart.cs")), "Helm/V3/Invokes.cs": mustLoadFile(filepath.Join(templateDir, "helm", "v3", "Invokes.cs")), "Kustomize/Directory.cs": mustLoadFile(filepath.Join(templateDir, "kustomize", "Directory.cs")), @@ -392,8 +389,6 @@ func writeGoClient(pkg *schema.Package, outdir string, templateDir string) { files["kubernetes/customPulumiTypes.go"] = mustLoadGoFile(filepath.Join(templateDir, "customPulumiTypes.go")) files["kubernetes/apiextensions/customResource.go"] = mustLoadGoFile(filepath.Join(templateDir, "apiextensions", "customResource.go")) files["kubernetes/apiextensions/customResourcePatch.go"] = mustLoadGoFile(filepath.Join(templateDir, "apiextensions", "customResourcePatch.go")) - files["kubernetes/helm/v2/chart.go"] = mustLoadGoFile(filepath.Join(templateDir, "helm", "v2", "chart.go")) - files["kubernetes/helm/v2/pulumiTypes.go"] = mustLoadGoFile(filepath.Join(templateDir, "helm", "v2", "pulumiTypes.go")) files["kubernetes/helm/v3/chart.go"] = mustLoadGoFile(filepath.Join(templateDir, "helm", "v3", "chart.go")) // Rename pulumiTypes.go to avoid conflict with schema generated Helm Release types. files["kubernetes/helm/v3/chartPulumiTypes.go"] = mustLoadGoFile(filepath.Join(templateDir, "helm", "v3", "pulumiTypes.go")) diff --git a/provider/cmd/pulumi-resource-kubernetes/schema.json b/provider/cmd/pulumi-resource-kubernetes/schema.json index 5f3e010605..0c301a4d9d 100644 --- a/provider/cmd/pulumi-resource-kubernetes/schema.json +++ b/provider/cmd/pulumi-resource-kubernetes/schema.json @@ -48705,73 +48705,6 @@ } } }, - "kubernetes:helm.sh/v2:FetchOpts": { - "description": "Additional options to customize the fetching of the Helm chart.", - "properties": { - "caFile": { - "type": "string", - "description": "Verify certificates of HTTPS-enabled servers using this CA bundle." - }, - "certFile": { - "type": "string", - "description": "Identify HTTPS client using this SSL certificate file." - }, - "destination": { - "type": "string", - "description": "Location to write the chart. If this and tardir are specified, tardir is appended to this (default \".\")." - }, - "devel": { - "type": "boolean", - "description": "Use development versions, too. Equivalent to version '>0.0.0-0'. If –version is set, this is ignored." - }, - "home": { - "type": "string", - "description": "Location of your Helm config. Overrides $HELM_HOME (default \"/Users/abc/.helm\")." - }, - "keyFile": { - "type": "string", - "description": "Identify HTTPS client using this SSL key file." - }, - "keyring": { - "type": "string", - "description": "Keyring containing public keys (default “/Users/abc/.gnupg/pubring.gpg”)." - }, - "password": { - "type": "string", - "description": "Chart repository password." - }, - "prov": { - "type": "string", - "description": "Fetch the provenance file, but don’t perform verification." - }, - "repo": { - "type": "string", - "description": "Chart repository url where to locate the requested chart." - }, - "untar": { - "type": "boolean", - "description": "If set to false, will leave the chart as a tarball after downloading." - }, - "untardir": { - "type": "string", - "description": "If untar is specified, this flag specifies the name of the directory into which the chart is expanded (default \".\")." - }, - "username": { - "type": "string", - "description": "Chart repository username." - }, - "verify": { - "type": "boolean", - "description": "Verify the package against its signature." - }, - "version": { - "type": "string", - "description": "Specific version of a chart. Without this, the latest version is fetched." - } - }, - "type": "object", - "isOverlay": true - }, "kubernetes:helm.sh/v3:FetchOpts": { "description": "Additional options to customize the fetching of the Helm chart.", "properties": { @@ -78475,66 +78408,6 @@ } ] }, - "kubernetes:helm.sh/v2:Chart": { - "description": "Chart is a component representing a collection of resources described by an arbitrary Helm Chart.\n\nThe Chart can be fetched from any source that is accessible to the `helm` command line. Values in the `values.yml` file can be overridden using `ChartOpts.values` (equivalent to `--set` or having multiple `values.yml` files). Objects can be transformed arbitrarily by supplying callbacks to `ChartOpts.transformations`.\n\n`Chart` does not use Tiller. The Chart specified is copied and expanded locally; the semantics are equivalent to running `helm template` and then using Pulumi to manage the resulting YAML manifests. Any values that would be retrieved in-cluster are assigned fake values, and none of Tiller's server-side validity testing is executed.\n\n**Note**: `helm/v2/Chart` has been deprecated and superceded by `helm/v3/Chart` and will be removed in a future release.\n\n{{% examples %}}\n## Example Usage\n{{% example %}}\n### Local Chart Directory\n\n```typescript\nimport * as k8s from \"@pulumi/kubernetes\";\n\nconst nginxIngress = new k8s.helm.v2.Chart(\"nginx-ingress\", {\n path: \"./nginx-ingress\",\n});\n```\n```python\nfrom pulumi_kubernetes.helm.v2 import Chart, LocalChartOpts\n\nnginx_ingress = Chart(\n \"nginx-ingress\",\n LocalChartOpts(\n path=\"./nginx-ingress\",\n ),\n)\n```\n```csharp\nusing System.Threading.Tasks;\nusing Pulumi;\nusing Pulumi.Kubernetes.Helm;\nusing Pulumi.Kubernetes.Helm.V2;\n\nclass HelmStack : Stack\n{\n public HelmStack()\n {\n var nginx = new Chart(\"nginx-ingress\", new LocalChartArgs\n {\n Path = \"./nginx-ingress\",\n });\n\n }\n}\n```\n```go\npackage main\n\nimport (\n\t\"github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/helm/v2\"\n\t\"github.com/pulumi/pulumi/sdk/v3/go/pulumi\"\n)\n\nfunc main() {\n\tpulumi.Run(func(ctx *pulumi.Context) error {\n\t\t_, err := helm.NewChart(ctx, \"nginx-ingress\", helm.ChartArgs{\n\t\t\tPath: pulumi.String(\"./nginx-ingress\"),\n\t\t})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\treturn nil\n\t})\n}\n```\n{{% /example %}}\n{{% example %}}\n### Remote Chart\n\n```typescript\nimport * as k8s from \"@pulumi/kubernetes\";\n\nconst nginxIngress = new k8s.helm.v2.Chart(\"nginx-ingress\", {\n chart: \"nginx-ingress\",\n version: \"1.24.4\",\n fetchOpts:{\n repo: \"https://charts.helm.sh/stable\",\n },\n});\n```\n```python\nfrom pulumi_kubernetes.helm.v2 import Chart, ChartOpts, FetchOpts\n\nnginx_ingress = Chart(\n \"nginx-ingress\",\n ChartOpts(\n chart=\"nginx-ingress\",\n version=\"1.24.4\",\n fetch_opts=FetchOpts(\n repo=\"https://charts.helm.sh/stable\",\n ),\n ),\n)\n```\n```csharp\nusing System.Threading.Tasks;\nusing Pulumi;\nusing Pulumi.Kubernetes.Helm;\nusing Pulumi.Kubernetes.Helm.V2;\n\nclass HelmStack : Stack\n{\n public HelmStack()\n {\n var nginx = new Chart(\"nginx-ingress\", new ChartArgs\n {\n Chart = \"nginx-ingress\",\n Version = \"1.24.4\",\n FetchOptions = new ChartFetchArgs\n {\n Repo = \"https://charts.helm.sh/stable\"\n }\n });\n\n }\n}\n```\n```go\npackage main\n\nimport (\n\t\"github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/helm/v2\"\n\t\"github.com/pulumi/pulumi/sdk/v3/go/pulumi\"\n)\n\nfunc main() {\n\tpulumi.Run(func(ctx *pulumi.Context) error {\n\t\t_, err := helm.Newchart(ctx, \"nginx-ingress\", helm.Chartargs{\n\t\t\tChart: pulumi.String(\"nginx-ingress\"),\n\t\t\tVersion: pulumi.String(\"1.24.4\"),\n\t\t\tFetchargs: helm.Fetchargs{\n\t\t\t\trepo: pulumi.String(\"https://charts.helm.sh/stable\"),\n\t\t\t},\n\t\t})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\treturn nil\n\t})\n}\n```\n\n{{% /example %}}\n{{% example %}}\n### Set Chart Values\n\n```typescript\nimport * as k8s from \"@pulumi/kubernetes\";\n\nconst nginxIngress = new k8s.helm.v2.Chart(\"nginx-ingress\", {\n chart: \"nginx-ingress\",\n version: \"1.24.4\",\n fetchOpts:{\n repo: \"https://charts.helm.sh/stable\",\n },\n values: {\n controller: {\n metrics: {\n enabled: true,\n }\n }\n },\n});\n```\n```python\nfrom pulumi_kubernetes.helm.v2 import Chart, ChartOpts, FetchOpts\n\nnginx_ingress = Chart(\n \"nginx-ingress\",\n ChartOpts(\n chart=\"nginx-ingress\",\n version=\"1.24.4\",\n fetch_opts=FetchOpts(\n repo=\"https://charts.helm.sh/stable\",\n ),\n values={\n \"controller\": {\n \"metrics\": {\n \"enabled\": True,\n },\n },\n },\n ),\n)\n```\n```csharp\nusing System.Collections.Generic;\nusing System.Threading.Tasks;\nusing Pulumi;\nusing Pulumi.Kubernetes.Helm;\nusing Pulumi.Kubernetes.Helm.V2;\n\nclass HelmStack : Stack\n{\n public HelmStack()\n {\n var values = new Dictionary\n {\n [\"controller\"] = new Dictionary\n {\n [\"metrics\"] = new Dictionary\n {\n [\"enabled\"] = true\n }\n },\n };\n\n var nginx = new Chart(\"nginx-ingress\", new ChartArgs\n {\n Chart = \"nginx-ingress\",\n Version = \"1.24.4\",\n FetchOptions = new ChartFetchArgs\n {\n Repo = \"https://charts.helm.sh/stable\"\n },\n Values = values,\n });\n\n }\n}\n```\n```go\npackage main\n\nimport (\n\t\"github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/helm/v2\"\n\t\"github.com/pulumi/pulumi/sdk/v3/go/pulumi\"\n)\n\nfunc main() {\n\tpulumi.Run(func(ctx *pulumi.Context) error {\n\t\t_, err := helm.NewChart(ctx, \"nginx-ingress\", helm.ChartArgs{\n\t\t\tChart: pulumi.String(\"nginx-ingress\"),\n\t\t\tVersion: pulumi.String(\"1.24.4\"),\n\t\t\tFetchArgs: helm.FetchArgs{\n\t\t\t\tRepo: pulumi.String(\"https://charts.helm.sh/stable\"),\n\t\t\t},\n\t\t\tValues: pulumi.Map{\n\t\t\t\t\"controller\": pulumi.Map{\n\t\t\t\t\t\"metrics\": pulumi.Map{\n\t\t\t\t\t\t\"enabled\": pulumi.Bool(true),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\treturn nil\n\t})\n}\n```\n{{% /example %}}\n{{% example %}}\n### Deploy Chart into Namespace\n\n```typescript\nimport * as k8s from \"@pulumi/kubernetes\";\n\nconst nginxIngress = new k8s.helm.v2.Chart(\"nginx-ingress\", {\n chart: \"nginx-ingress\",\n version: \"1.24.4\",\n namespace: \"test-namespace\",\n fetchOpts:{\n repo: \"https://charts.helm.sh/stable\",\n },\n});\n```\n```python\nfrom pulumi_kubernetes.helm.v2 import Chart, ChartOpts, FetchOpts\n\nnginx_ingress = Chart(\n \"nginx-ingress\",\n ChartOpts(\n chart=\"nginx-ingress\",\n version=\"1.24.4\",\n namespace=\"test-namespace\",\n fetch_opts=FetchOpts(\n repo=\"https://charts.helm.sh/stable\",\n ),\n ),\n)\n```\n```csharp\nusing System.Threading.Tasks;\nusing Pulumi;\nusing Pulumi.Kubernetes.Helm;\nusing Pulumi.Kubernetes.Helm.V2;\n\nclass HelmStack : Stack\n{\n public HelmStack()\n {\n var nginx = new Chart(\"nginx-ingress\", new ChartArgs\n {\n Chart = \"nginx-ingress\",\n Version = \"1.24.4\",\n Namespace = \"test-namespace\",\n FetchOptions = new ChartFetchArgs\n {\n Repo = \"https://charts.helm.sh/stable\"\n },\n });\n\n }\n}\n```\n```go\npackage main\n\nimport (\n\t\"github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/helm/v2\"\n\t\"github.com/pulumi/pulumi/sdk/v3/go/pulumi\"\n)\n\nfunc main() {\n\tpulumi.Run(func(ctx *pulumi.Context) error {\n\t\t_, err := helm.NewChart(ctx, \"nginx-ingress\", helm.ChartArgs{\n\t\t\tChart: pulumi.String(\"nginx-ingress\"),\n\t\t\tVersion: pulumi.String(\"1.24.4\"),\n\t\t\tNamespace: pulumi.String(\"test-namespace\"),\n\t\t\tFetchArgs: helm.FetchArgs{\n\t\t\t\tRepo: pulumi.String(\"https://charts.helm.sh/stable\"),\n\t\t\t},\n\t\t})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\treturn nil\n\t})\n}\n```\n{{% /example %}}\n{{% example %}}\n### Chart with Transformations\n\n```typescript\nimport * as k8s from \"@pulumi/kubernetes\";\n\nconst nginxIngress = new k8s.helm.v2.Chart(\"nginx-ingress\", {\n chart: \"nginx-ingress\",\n version: \"1.24.4\",\n fetchOpts:{\n repo: \"https://charts.helm.sh/stable\",\n },\n transformations: [\n // Make every service private to the cluster, i.e., turn all services into ClusterIP instead of LoadBalancer.\n (obj: any, opts: pulumi.CustomResourceOptions) => {\n if (obj.kind === \"Service\" && obj.apiVersion === \"v1\") {\n if (obj.spec && obj.spec.type && obj.spec.type === \"LoadBalancer\") {\n obj.spec.type = \"ClusterIP\";\n }\n }\n },\n\n // Set a resource alias for a previous name.\n (obj: any, opts: pulumi.CustomResourceOptions) => {\n if (obj.kind === \"Deployment\") {\n opts.aliases = [{ name: \"oldName\" }]\n }\n },\n\n // Omit a resource from the Chart by transforming the specified resource definition to an empty List.\n (obj: any, opts: pulumi.CustomResourceOptions) => {\n if (obj.kind === \"Pod\" && obj.metadata.name === \"test\") {\n obj.apiVersion = \"v1\"\n obj.kind = \"List\"\n }\n },\n ],\n});\n```\n```python\nfrom pulumi_kubernetes.helm.v2 import Chart, ChartOpts, FetchOpts\n\n# Make every service private to the cluster, i.e., turn all services into ClusterIP instead of LoadBalancer.\ndef make_service_private(obj, opts):\n if obj[\"kind\"] == \"Service\" and obj[\"apiVersion\"] == \"v1\":\n try:\n t = obj[\"spec\"][\"type\"]\n if t == \"LoadBalancer\":\n obj[\"spec\"][\"type\"] = \"ClusterIP\"\n except KeyError:\n pass\n\n\n# Set a resource alias for a previous name.\ndef alias(obj, opts):\n if obj[\"kind\"] == \"Deployment\":\n opts.aliases = [\"oldName\"]\n\n\n# Omit a resource from the Chart by transforming the specified resource definition to an empty List.\ndef omit_resource(obj, opts):\n if obj[\"kind\"] == \"Pod\" and obj[\"metadata\"][\"name\"] == \"test\":\n obj[\"apiVersion\"] = \"v1\"\n obj[\"kind\"] = \"List\"\n\n\nnginx_ingress = Chart(\n \"nginx-ingress\",\n ChartOpts(\n chart=\"nginx-ingress\",\n version=\"1.24.4\",\n fetch_opts=FetchOpts(\n repo=\"https://charts.helm.sh/stable\",\n ),\n transformations=[make_service_private, alias, omit_resource],\n ),\n)\n```\n```csharp\nusing System.Collections.Generic;\nusing System.Collections.Immutable;\nusing System.Threading.Tasks;\nusing Pulumi;\nusing Pulumi.Kubernetes.Helm;\nusing Pulumi.Kubernetes.Helm.V2;\n\nclass HelmStack : Stack\n{\n public HelmStack()\n {\n var nginx = new Chart(\"nginx-ingress\", new ChartArgs\n {\n Chart = \"nginx-ingress\",\n Version = \"1.24.4\",\n FetchOptions = new ChartFetchArgs\n {\n Repo = \"https://charts.helm.sh/stable\"\n },\n Transformations =\n {\n LoadBalancerToClusterIP,\n ResourceAlias,\n OmitTestPod,\n }\n\n });\n\n // Make every service private to the cluster, i.e., turn all services into ClusterIP instead of LoadBalancer.\n ImmutableDictionary LoadBalancerToClusterIP(ImmutableDictionary obj, CustomResourceOptions opts)\n {\n if ((string)obj[\"kind\"] == \"Service\" && (string)obj[\"apiVersion\"] == \"v1\")\n {\n var spec = (ImmutableDictionary)obj[\"spec\"];\n if (spec != null && (string)spec[\"type\"] == \"LoadBalancer\")\n {\n return obj.SetItem(\"spec\", spec.SetItem(\"type\", \"ClusterIP\"));\n }\n }\n\n return obj;\n }\n\n // Set a resource alias for a previous name.\n ImmutableDictionary ResourceAlias(ImmutableDictionary obj, CustomResourceOptions opts)\n {\n if ((string)obj[\"kind\"] == \"Deployment\")\n {\n opts.Aliases.Add(new Alias { Name = \"oldName\" });\n }\n\n return obj;\n }\n\n // Omit a resource from the Chart by transforming the specified resource definition to an empty List.\n ImmutableDictionary OmitTestPod(ImmutableDictionary obj, CustomResourceOptions opts)\n {\n var metadata = (ImmutableDictionary)obj[\"metadata\"];\n if ((string)obj[\"kind\"] == \"Pod\" && (string)metadata[\"name\"] == \"test\")\n {\n return new Dictionary\n {\n [\"apiVersion\"] = \"v1\",\n [\"kind\"] = \"List\",\n [\"items\"] = new Dictionary(),\n }.ToImmutableDictionary();\n }\n\n return obj;\n }\n }\n}\n```\n```go\npackage main\n\nimport (\n\t\"github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/helm/v2\"\n\t\"github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/yaml\"\n\t\"github.com/pulumi/pulumi/sdk/v3/go/pulumi\"\n)\n\nfunc main() {\n\tpulumi.Run(func(ctx *pulumi.Context) error {\n\t\t_, err := helm.NewChart(ctx, \"nginx-ingress\", helm.ChartArgs{\n\t\t\tChart: pulumi.String(\"nginx-ingress\"),\n\t\t\tVersion: pulumi.String(\"1.24.4\"),\n\t\t\tFetchArgs: helm.FetchArgs{\n\t\t\t\tRepo: pulumi.String(\"https://charts.helm.sh/stable\"),\n\t\t\t},\n\t\t\tTransformations: []yaml.Transformation{\n\t\t\t\t// Make every service private to the cluster, i.e., turn all services into ClusterIP\n\t\t\t\t// instead of LoadBalancer.\n\t\t\t\tfunc(state map[string]interface{}, opts ...pulumi.ResourceOption) {\n\t\t\t\t\tif state[\"kind\"] == \"Service\" {\n\t\t\t\t\t\tspec := state[\"spec\"].(map[string]interface{})\n\t\t\t\t\t\tspec[\"type\"] = \"ClusterIP\"\n\t\t\t\t\t}\n\t\t\t\t},\n\n\t\t\t\t// Set a resource alias for a previous name.\n\t\t\t\tfunc(state map[string]interface{}, opts ...pulumi.ResourceOption) {\n\t\t\t\t\tif state[\"kind\"] == \"Deployment\" {\n\t\t\t\t\t\taliases := pulumi.Aliases([]pulumi.Alias{\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tName: pulumi.String(\"oldName\"),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t})\n\t\t\t\t\t\topts = append(opts, aliases)\n\t\t\t\t\t}\n\t\t\t\t},\n\n\t\t\t\t// Omit a resource from the Chart by transforming the specified resource definition\n\t\t\t\t// to an empty List.\n\t\t\t\tfunc(state map[string]interface{}, opts ...pulumi.ResourceOption) {\n\t\t\t\t\tname := state[\"metadata\"].(map[string]interface{})[\"name\"]\n\t\t\t\t\tif state[\"kind\"] == \"Pod\" && name == \"test\" {\n\t\t\t\t\t\tstate[\"apiVersion\"] = \"core/v1\"\n\t\t\t\t\t\tstate[\"kind\"] = \"List\"\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t},\n\t\t})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\treturn nil\n\t})\n}\n```\n{{% /example %}}\n{{% /examples %}}\n", - "properties": { - "resources": { - "type": "string", - "description": "Resources created by the Chart." - }, - "urn": { - "type": "string", - "description": "The stable logical URN used to distinctly address a resource, both before and after deployments." - } - }, - "type": "object", - "isOverlay": true, - "inputProperties": { - "chart": { - "type": "string", - "description": "The name of the chart to deploy. If [repo] is provided, this chart name will be prefixed by the repo name. Example: repo: \"stable\", chart: \"nginx-ingress\" -> \"stable/nginx-ingress\" Example: chart: \"stable/nginx-ingress\" -> \"stable/nginx-ingress\"\n\nRequired if specifying `ChartOpts` for a remote chart." - }, - "fetchOpts": { - "$ref": "#/types/kubernetes:helm.sh/v2:FetchOpts", - "description": "Additional options to customize the fetching of the Helm chart." - }, - "namespace": { - "type": "string", - "description": "The optional namespace to install chart resources into." - }, - "path": { - "type": "string", - "description": "The path to the chart directory which contains the `Chart.yaml` file.\n\nRequired if specifying `LocalChartOpts`." - }, - "repo": { - "type": "string", - "description": "The repository name of the chart to deploy. Example: \"stable\".\n\nUsed only when specifying options for a remote chart." - }, - "resourcePrefix": { - "type": "string", - "description": "An optional prefix for the auto-generated resource names. Example: A resource created with resourcePrefix=\"foo\" would produce a resource named \"foo-resourceName\"." - }, - "transformations": { - "type": "array", - "items": { - "$ref": "pulumi.json#/Any" - }, - "description": "Optional array of transformations to apply to resources that will be created by this chart prior to creation. Allows customization of the chart behaviour without directly modifying the chart itself." - }, - "values": { - "type": "object", - "additionalProperties": { - "$ref": "pulumi.json#/Any" - }, - "description": "Overrides for chart values." - }, - "version": { - "type": "string", - "description": "The version of the chart to deploy. If not provided, the latest version will be deployed." - } - }, - "isComponent": true - }, "kubernetes:helm.sh/v3:Chart": { "description": "Chart is a component representing a collection of resources described by an arbitrary Helm Chart.\n\nThe Chart can be fetched from any source that is accessible to the `helm` command line. Values in the `values.yml` file can be overridden using `ChartOpts.values` (equivalent to `--set` or having multiple `values.yml` files). Objects can be transformed arbitrarily by supplying callbacks to `ChartOpts.transformations`.\n\n`Chart` does not use Tiller. The Chart specified is copied and expanded locally; the semantics are equivalent to running `helm template` and then using Pulumi to manage the resulting YAML manifests. Any values that would be retrieved in-cluster are assigned fake values, and none of Tiller's server-side validity testing is executed.\n\n{{% examples %}}\n## Example Usage\n{{% example %}}\n### Local Chart Directory\n\n```typescript\nimport * as k8s from \"@pulumi/kubernetes\";\n\nconst nginxIngress = new k8s.helm.v3.Chart(\"nginx-ingress\", {\n path: \"./nginx-ingress\",\n});\n```\n```python\nfrom pulumi_kubernetes.helm.v3 import Chart, LocalChartOpts\n\nnginx_ingress = Chart(\n \"nginx-ingress\",\n LocalChartOpts(\n path=\"./nginx-ingress\",\n ),\n)\n```\n```csharp\nusing System.Threading.Tasks;\nusing Pulumi;\nusing Pulumi.Kubernetes.Helm;\nusing Pulumi.Kubernetes.Helm.V3;\n\nclass HelmStack : Stack\n{\n public HelmStack()\n {\n var nginx = new Chart(\"nginx-ingress\", new LocalChartArgs\n {\n Path = \"./nginx-ingress\",\n });\n\n }\n}\n```\n```go\npackage main\n\nimport (\n\t\"github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/helm/v3\"\n\t\"github.com/pulumi/pulumi/sdk/v3/go/pulumi\"\n)\n\nfunc main() {\n\tpulumi.Run(func(ctx *pulumi.Context) error {\n\t\t_, err := helm.NewChart(ctx, \"nginx-ingress\", helm.ChartArgs{\n\t\t\tPath: pulumi.String(\"./nginx-ingress\"),\n\t\t})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\treturn nil\n\t})\n}\n```\n{{% /example %}}\n{{% example %}}\n### Remote Chart\n\n```typescript\nimport * as k8s from \"@pulumi/kubernetes\";\n\nconst nginxIngress = new k8s.helm.v3.Chart(\"nginx-ingress\", {\n chart: \"nginx-ingress\",\n version: \"1.24.4\",\n fetchOpts:{\n repo: \"https://charts.helm.sh/stable\",\n },\n});\n```\n```python\nfrom pulumi_kubernetes.helm.v3 import Chart, ChartOpts, FetchOpts\n\nnginx_ingress = Chart(\n \"nginx-ingress\",\n ChartOpts(\n chart=\"nginx-ingress\",\n version=\"1.24.4\",\n fetch_opts=FetchOpts(\n repo=\"https://charts.helm.sh/stable\",\n ),\n ),\n)\n```\n```csharp\nusing System.Threading.Tasks;\nusing Pulumi;\nusing Pulumi.Kubernetes.Helm;\nusing Pulumi.Kubernetes.Helm.V3;\n\nclass HelmStack : Stack\n{\n public HelmStack()\n {\n var nginx = new Chart(\"nginx-ingress\", new ChartArgs\n {\n Chart = \"nginx-ingress\",\n Version = \"1.24.4\",\n FetchOptions = new ChartFetchArgs\n {\n Repo = \"https://charts.helm.sh/stable\"\n }\n });\n\n }\n}\n```\n```go\npackage main\n\nimport (\n\t\"github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/helm/v3\"\n\t\"github.com/pulumi/pulumi/sdk/v3/go/pulumi\"\n)\n\nfunc main() {\n\tpulumi.Run(func(ctx *pulumi.Context) error {\n\t\t_, err := helm.NewChart(ctx, \"nginx-ingress\", helm.ChartArgs{\n\t\t\tChart: pulumi.String(\"nginx-ingress\"),\n\t\t\tVersion: pulumi.String(\"1.24.4\"),\n\t\t\tFetchargs: helm.FetchArgs{\n\t\t\t\tRepo: pulumi.String(\"https://charts.helm.sh/stable\"),\n\t\t\t},\n\t\t})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\treturn nil\n\t})\n}\n```\n\n{{% /example %}}\n{{% example %}}\n### Set Chart Values\n\n```typescript\nimport * as k8s from \"@pulumi/kubernetes\";\n\nconst nginxIngress = new k8s.helm.v3.Chart(\"nginx-ingress\", {\n chart: \"nginx-ingress\",\n version: \"1.24.4\",\n fetchOpts:{\n repo: \"https://charts.helm.sh/stable\",\n },\n values: {\n controller: {\n metrics: {\n enabled: true,\n }\n }\n },\n});\n```\n```python\nfrom pulumi_kubernetes.helm.v3 import Chart, ChartOpts, FetchOpts\n\nnginx_ingress = Chart(\n \"nginx-ingress\",\n ChartOpts(\n chart=\"nginx-ingress\",\n version=\"1.24.4\",\n fetch_opts=FetchOpts(\n repo=\"https://charts.helm.sh/stable\",\n ),\n values={\n \"controller\": {\n \"metrics\": {\n \"enabled\": True,\n },\n },\n },\n ),\n)\n```\n```csharp\nusing System.Collections.Generic;\nusing System.Threading.Tasks;\nusing Pulumi;\nusing Pulumi.Kubernetes.Helm;\nusing Pulumi.Kubernetes.Helm.V3;\n\nclass HelmStack : Stack\n{\n public HelmStack()\n {\n var values = new Dictionary\n {\n [\"controller\"] = new Dictionary\n {\n [\"metrics\"] = new Dictionary\n {\n [\"enabled\"] = true\n }\n },\n };\n\n var nginx = new Chart(\"nginx-ingress\", new ChartArgs\n {\n Chart = \"nginx-ingress\",\n Version = \"1.24.4\",\n FetchOptions = new ChartFetchArgs\n {\n Repo = \"https://charts.helm.sh/stable\"\n },\n Values = values,\n });\n\n }\n}\n```\n```go\npackage main\n\nimport (\n\t\"github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/helm/v3\"\n\t\"github.com/pulumi/pulumi/sdk/v3/go/pulumi\"\n)\n\nfunc main() {\n\tpulumi.Run(func(ctx *pulumi.Context) error {\n\t\t_, err := helm.NewChart(ctx, \"nginx-ingress\", helm.ChartArgs{\n\t\t\tChart: pulumi.String(\"nginx-ingress\"),\n\t\t\tVersion: pulumi.String(\"1.24.4\"),\n\t\t\tFetchArgs: helm.FetchArgs{\n\t\t\t\tRepo: pulumi.String(\"https://charts.helm.sh/stable\"),\n\t\t\t},\n\t\t\tValues: pulumi.Map{\n\t\t\t\t\"controller\": pulumi.Map{\n\t\t\t\t\t\"metrics\": pulumi.Map{\n\t\t\t\t\t\t\"enabled\": pulumi.Bool(true),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\treturn nil\n\t})\n}\n```\n{{% /example %}}\n{{% example %}}\n### Deploy Chart into Namespace\n\n```typescript\nimport * as k8s from \"@pulumi/kubernetes\";\n\nconst nginxIngress = new k8s.helm.v3.Chart(\"nginx-ingress\", {\n chart: \"nginx-ingress\",\n version: \"1.24.4\",\n namespace: \"test-namespace\",\n fetchOpts:{\n repo: \"https://charts.helm.sh/stable\",\n },\n});\n```\n```python\nfrom pulumi_kubernetes.helm.v3 import Chart, ChartOpts, FetchOpts\n\nnginx_ingress = Chart(\n \"nginx-ingress\",\n ChartOpts(\n chart=\"nginx-ingress\",\n version=\"1.24.4\",\n namespace=\"test-namespace\",\n fetch_opts=FetchOpts(\n repo=\"https://charts.helm.sh/stable\",\n ),\n ),\n)\n```\n```csharp\nusing System.Threading.Tasks;\nusing Pulumi;\nusing Pulumi.Kubernetes.Helm;\nusing Pulumi.Kubernetes.Helm.V3;\n\nclass HelmStack : Stack\n{\n public HelmStack()\n {\n var nginx = new Chart(\"nginx-ingress\", new ChartArgs\n {\n Chart = \"nginx-ingress\",\n Version = \"1.24.4\",\n Namespace = \"test-namespace\",\n FetchOptions = new ChartFetchArgs\n {\n Repo = \"https://charts.helm.sh/stable\"\n },\n });\n\n }\n}\n```\n```go\npackage main\n\nimport (\n\t\"github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/helm/v3\"\n\t\"github.com/pulumi/pulumi/sdk/v3/go/pulumi\"\n)\n\nfunc main() {\n\tpulumi.Run(func(ctx *pulumi.Context) error {\n\t\t_, err := helm.NewChart(ctx, \"nginx-ingress\", helm.ChartArgs{\n\t\t\tChart: pulumi.String(\"nginx-ingress\"),\n\t\t\tVersion: pulumi.String(\"1.24.4\"),\n\t\t\tNamespace: pulumi.String(\"test-namespace\"),\n\t\t\tFetchArgs: helm.FetchArgs{\n\t\t\t\tRepo: pulumi.String(\"https://charts.helm.sh/stable\"),\n\t\t\t},\n\t\t})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\treturn nil\n\t})\n}\n```\n{{% /example %}}\n{{% example %}}\n### Depend on a Chart resource\n\n```typescript\nimport * as k8s from \"@pulumi/kubernetes\";\n\nconst nginxIngress = new k8s.helm.v3.Chart(\"nginx-ingress\", {\n chart: \"nginx-ingress\",\n version: \"1.24.4\",\n namespace: \"test-namespace\",\n fetchOpts:{\n repo: \"https://charts.helm.sh/stable\",\n },\n});\n\n// Create a ConfigMap depending on the Chart. The ConfigMap will not be created until after all of the Chart\n// resources are ready. Note the use of the `ready` attribute; depending on the Chart resource directly will not work.\nnew k8s.core.v1.ConfigMap(\"foo\", {\n metadata: { namespace: namespaceName },\n data: {foo: \"bar\"}\n}, {dependsOn: nginxIngress.ready})\n```\n```python\nimport pulumi\nfrom pulumi_kubernetes.core.v1 import ConfigMap, ConfigMapInitArgs\nfrom pulumi_kubernetes.helm.v3 import Chart, ChartOpts, FetchOpts\n\nnginx_ingress = Chart(\n \"nginx-ingress\",\n ChartOpts(\n chart=\"nginx-ingress\",\n version=\"1.24.4\",\n namespace=\"test-namespace\",\n fetch_opts=FetchOpts(\n repo=\"https://charts.helm.sh/stable\",\n ),\n ),\n)\n\n# Create a ConfigMap depending on the Chart. The ConfigMap will not be created until after all of the Chart\n# resources are ready. Note the use of the `ready` attribute; depending on the Chart resource directly will not work.\nConfigMap(\"foo\", ConfigMapInitArgs(data={\"foo\": \"bar\"}), opts=pulumi.ResourceOptions(depends_on=nginx_ingress.ready))\n```\n```csharp\nusing System.Threading.Tasks;\nusing Pulumi;\nusing Pulumi.Kubernetes.Core.V1;\nusing Pulumi.Kubernetes.Helm;\nusing Pulumi.Kubernetes.Helm.V3;\n\nclass HelmStack : Stack\n{\n public HelmStack()\n {\n var nginx = new Chart(\"nginx-ingress\", new ChartArgs\n {\n Chart = \"nginx-ingress\",\n Version = \"1.24.4\",\n Namespace = \"test-namespace\",\n FetchOptions = new ChartFetchArgs\n {\n Repo = \"https://charts.helm.sh/stable\"\n },\n });\n \n // Create a ConfigMap depending on the Chart. The ConfigMap will not be created until after all of the Chart\n // resources are ready. Note the use of the `Ready()` method; depending on the Chart resource directly will \n // not work.\n new ConfigMap(\"foo\", new Pulumi.Kubernetes.Types.Inputs.Core.V1.ConfigMapArgs\n {\n Data = new InputMap\n {\n {\"foo\", \"bar\"}\n },\n }, new CustomResourceOptions\n {\n DependsOn = nginx.Ready(),\n });\n\n }\n}\n```\n```go\npackage main\n\nimport (\n\tcorev1 \"github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/core/v1\"\n\t\"github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/helm/v3\"\n\t\"github.com/pulumi/pulumi/sdk/v3/go/pulumi\"\n)\n\nfunc main() {\n\tpulumi.Run(func(ctx *pulumi.Context) error {\n\t\t_, err := helm.NewChart(ctx, \"nginx-ingress\", helm.ChartArgs{\n\t\t\tChart: pulumi.String(\"nginx-ingress\"),\n\t\t\tVersion: pulumi.String(\"1.24.4\"),\n\t\t\tNamespace: pulumi.String(\"test-namespace\"),\n\t\t\tFetchArgs: helm.FetchArgs{\n\t\t\t\tRepo: pulumi.String(\"https://charts.helm.sh/stable\"),\n\t\t\t},\n\t\t})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// Create a ConfigMap depending on the Chart. The ConfigMap will not be created until after all of the Chart\n\t\t// resources are ready. Note the use of the `Ready` attribute, which is used with `DependsOnInputs` rather than\n\t\t// `DependsOn`. Depending on the Chart resource directly, or using `DependsOn` will not work.\n\t\t_, err = corev1.NewConfigMap(ctx, \"cm\", &corev1.ConfigMapArgs{\n\t\t\tData: pulumi.StringMap{\n\t\t\t\t\"foo\": pulumi.String(\"bar\"),\n\t\t\t},\n\t\t}, pulumi.DependsOnInputs(chart.Ready))\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\treturn nil\n\t})\n}\n```\n{{% /example %}}\n{{% example %}}\n### Chart with Transformations\n\n```typescript\nimport * as k8s from \"@pulumi/kubernetes\";\n\nconst nginxIngress = new k8s.helm.v3.Chart(\"nginx-ingress\", {\n chart: \"nginx-ingress\",\n version: \"1.24.4\",\n fetchOpts:{\n repo: \"https://charts.helm.sh/stable\",\n },\n transformations: [\n // Make every service private to the cluster, i.e., turn all services into ClusterIP instead of LoadBalancer.\n (obj: any, opts: pulumi.CustomResourceOptions) => {\n if (obj.kind === \"Service\" && obj.apiVersion === \"v1\") {\n if (obj.spec && obj.spec.type && obj.spec.type === \"LoadBalancer\") {\n obj.spec.type = \"ClusterIP\";\n }\n }\n },\n\n // Set a resource alias for a previous name.\n (obj: any, opts: pulumi.CustomResourceOptions) => {\n if (obj.kind === \"Deployment\") {\n opts.aliases = [{ name: \"oldName\" }]\n }\n },\n\n // Omit a resource from the Chart by transforming the specified resource definition to an empty List.\n (obj: any, opts: pulumi.CustomResourceOptions) => {\n if (obj.kind === \"Pod\" && obj.metadata.name === \"test\") {\n obj.apiVersion = \"v1\"\n obj.kind = \"List\"\n }\n },\n ],\n});\n```\n```python\nfrom pulumi_kubernetes.helm.v3 import Chart, ChartOpts, FetchOpts\n\n# Make every service private to the cluster, i.e., turn all services into ClusterIP instead of LoadBalancer.\ndef make_service_private(obj, opts):\n if obj[\"kind\"] == \"Service\" and obj[\"apiVersion\"] == \"v1\":\n try:\n t = obj[\"spec\"][\"type\"]\n if t == \"LoadBalancer\":\n obj[\"spec\"][\"type\"] = \"ClusterIP\"\n except KeyError:\n pass\n\n\n# Set a resource alias for a previous name.\ndef alias(obj, opts):\n if obj[\"kind\"] == \"Deployment\":\n opts.aliases = [\"oldName\"]\n\n\n# Omit a resource from the Chart by transforming the specified resource definition to an empty List.\ndef omit_resource(obj, opts):\n if obj[\"kind\"] == \"Pod\" and obj[\"metadata\"][\"name\"] == \"test\":\n obj[\"apiVersion\"] = \"v1\"\n obj[\"kind\"] = \"List\"\n\n\nnginx_ingress = Chart(\n \"nginx-ingress\",\n ChartOpts(\n chart=\"nginx-ingress\",\n version=\"1.24.4\",\n fetch_opts=FetchOpts(\n repo=\"https://charts.helm.sh/stable\",\n ),\n transformations=[make_service_private, alias, omit_resource],\n ),\n)\n```\n```csharp\nusing System.Collections.Generic;\nusing System.Collections.Immutable;\nusing System.Threading.Tasks;\nusing Pulumi;\nusing Pulumi.Kubernetes.Helm;\nusing Pulumi.Kubernetes.Helm.V3;\n\nclass HelmStack : Stack\n{\n public HelmStack()\n {\n var nginx = new Chart(\"nginx-ingress\", new ChartArgs\n {\n Chart = \"nginx-ingress\",\n Version = \"1.24.4\",\n FetchOptions = new ChartFetchArgs\n {\n Repo = \"https://charts.helm.sh/stable\"\n },\n Transformations =\n {\n LoadBalancerToClusterIP,\n ResourceAlias,\n OmitTestPod,\n }\n\n });\n\n // Make every service private to the cluster, i.e., turn all services into ClusterIP instead of LoadBalancer.\n ImmutableDictionary LoadBalancerToClusterIP(ImmutableDictionary obj, CustomResourceOptions opts)\n {\n if ((string)obj[\"kind\"] == \"Service\" && (string)obj[\"apiVersion\"] == \"v1\")\n {\n var spec = (ImmutableDictionary)obj[\"spec\"];\n if (spec != null && (string)spec[\"type\"] == \"LoadBalancer\")\n {\n return obj.SetItem(\"spec\", spec.SetItem(\"type\", \"ClusterIP\"));\n }\n }\n\n return obj;\n }\n\n // Set a resource alias for a previous name.\n ImmutableDictionary ResourceAlias(ImmutableDictionary obj, CustomResourceOptions opts)\n {\n if ((string)obj[\"kind\"] == \"Deployment\")\n {\n opts.Aliases.Add(new Alias { Name = \"oldName\" });\n }\n\n return obj;\n }\n\n // Omit a resource from the Chart by transforming the specified resource definition to an empty List.\n ImmutableDictionary OmitTestPod(ImmutableDictionary obj, CustomResourceOptions opts)\n {\n var metadata = (ImmutableDictionary)obj[\"metadata\"];\n if ((string)obj[\"kind\"] == \"Pod\" && (string)metadata[\"name\"] == \"test\")\n {\n return new Dictionary\n {\n [\"apiVersion\"] = \"v1\",\n [\"kind\"] = \"List\",\n [\"items\"] = new Dictionary(),\n }.ToImmutableDictionary();\n }\n\n return obj;\n }\n }\n}\n```\n```go\npackage main\n\nimport (\n\t\"github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/helm/v3\"\n\t\"github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/yaml\"\n\t\"github.com/pulumi/pulumi/sdk/v3/go/pulumi\"\n)\n\nfunc main() {\n\tpulumi.Run(func(ctx *pulumi.Context) error {\n\t\t_, err := helm.NewChart(ctx, \"nginx-ingress\", helm.ChartArgs{\n\t\t\tChart: pulumi.String(\"nginx-ingress\"),\n\t\t\tVersion: pulumi.String(\"1.24.4\"),\n\t\t\tFetchArgs: helm.FetchArgs{\n\t\t\t\tRepo: pulumi.String(\"https://charts.helm.sh/stable\"),\n\t\t\t},\n\t\t\tTransformations: []yaml.Transformation{\n\t\t\t\t// Make every service private to the cluster, i.e., turn all services into ClusterIP\n\t\t\t\t// instead of LoadBalancer.\n\t\t\t\tfunc(state map[string]interface{}, opts ...pulumi.ResourceOption) {\n\t\t\t\t\tif state[\"kind\"] == \"Service\" {\n\t\t\t\t\t\tspec := state[\"spec\"].(map[string]interface{})\n\t\t\t\t\t\tspec[\"type\"] = \"ClusterIP\"\n\t\t\t\t\t}\n\t\t\t\t},\n\n\t\t\t\t// Set a resource alias for a previous name.\n\t\t\t\tfunc(state map[string]interface{}, opts ...pulumi.ResourceOption) {\n\t\t\t\t\tif state[\"kind\"] == \"Deployment\" {\n\t\t\t\t\t\taliases := pulumi.Aliases([]pulumi.Alias{\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tName: pulumi.String(\"oldName\"),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t})\n\t\t\t\t\t\topts = append(opts, aliases)\n\t\t\t\t\t}\n\t\t\t\t},\n\n\t\t\t\t// Omit a resource from the Chart by transforming the specified resource definition\n\t\t\t\t// to an empty List.\n\t\t\t\tfunc(state map[string]interface{}, opts ...pulumi.ResourceOption) {\n\t\t\t\t\tname := state[\"metadata\"].(map[string]interface{})[\"name\"]\n\t\t\t\t\tif state[\"kind\"] == \"Pod\" && name == \"test\" {\n\t\t\t\t\t\tstate[\"apiVersion\"] = \"core/v1\"\n\t\t\t\t\t\tstate[\"kind\"] = \"List\"\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t},\n\t\t})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\treturn nil\n\t})\n}\n```\n{{% /example %}}\n{{% /examples %}}\n", "properties": { diff --git a/provider/pkg/gen/_go-templates/helm/v2/chart.go b/provider/pkg/gen/_go-templates/helm/v2/chart.go deleted file mode 100644 index fb4ad57d2e..0000000000 --- a/provider/pkg/gen/_go-templates/helm/v2/chart.go +++ /dev/null @@ -1,527 +0,0 @@ -// Copyright 2016-2021, Pulumi Corporation. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// *** WARNING: this file was generated by pulumigen. *** -// *** Do not edit by hand unless you're certain you know what you are doing! *** - -package helm - -import ( - "bytes" - "encoding/json" - "fmt" - "io/ioutil" - "os" - "os/exec" - "path/filepath" - "regexp" - "sort" - "strings" - - "github.com/pkg/errors" - "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/yaml" - "github.com/pulumi/pulumi/sdk/v3/go/pulumi" -) - -// Chart is a component representing a collection of resources described by an arbitrary Helm -// Chart. The Chart can be fetched from any source that is accessible to the `helm` command -// line. Values in the `values.yml` file can be overridden using `ChartOpts.values` (equivalent -// to `--set` or having multiple `values.yml` files). Objects can be transformed arbitrarily by -// supplying callbacks to `ChartOpts.transformations`. -// -// `Chart` does not use Tiller. The Chart specified is copied and expanded locally; the semantics -// are equivalent to running `helm template` and then using Pulumi to manage the resulting YAML -// manifests. Any values that would be retrieved in-cluster are assigned fake values, and -// none of Tiller's server-side validity testing is executed. -// -// ## Example Usage -// ### Local Chart Directory -// -// ```go -// package main -// -// import ( -// -// "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/helm/v3" -// "github.com/pulumi/pulumi/sdk/v3/go/pulumi" -// -// ) -// -// func main() { -// pulumi.Run(func(ctx *pulumi.Context) error { -// _, err := helm.NewChart(ctx, "nginx-ingress", helm.ChartArgs{ -// Path: pulumi.String("./nginx-ingress"), -// }) -// if err != nil { -// return err -// } -// -// return nil -// }) -// } -// -// ``` -// ### Remote Chart -// -// ```go -// package main -// -// import ( -// -// "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/helm/v3" -// "github.com/pulumi/pulumi/sdk/v3/go/pulumi" -// -// ) -// -// func main() { -// pulumi.Run(func(ctx *pulumi.Context) error { -// _, err := helm.NewChart(ctx, "nginx-ingress", helm.ChartArgs{ -// Chart: pulumi.String("nginx-ingress"), -// Version: pulumi.String("1.24.4"), -// FetchArgs: helm.FetchArgs{ -// Repo: pulumi.String("https://charts.helm.sh/stable"), -// }, -// }) -// if err != nil { -// return err -// } -// -// return nil -// }) -// } -// -// ``` -// ### Set Chart values -// -// ```go -// package main -// -// import ( -// -// "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/helm/v3" -// "github.com/pulumi/pulumi/sdk/v3/go/pulumi" -// -// ) -// -// func main() { -// pulumi.Run(func(ctx *pulumi.Context) error { -// _, err := helm.NewChart(ctx, "nginx-ingress", helm.ChartArgs{ -// Chart: pulumi.String("nginx-ingress"), -// Version: pulumi.String("1.24.4"), -// FetchArgs: helm.FetchArgs{ -// Repo: pulumi.String("https://charts.helm.sh/stable"), -// }, -// Values: pulumi.Map{ -// "controller": pulumi.Map{ -// "metrics": pulumi.Map{ -// "enabled": pulumi.Bool(true), -// }, -// }, -// }, -// }) -// if err != nil { -// return err -// } -// -// return nil -// }) -// } -// -// ``` -// ### Deploy Chart into Namespace -// -// ```go -// package main -// -// import ( -// -// "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/helm/v3" -// "github.com/pulumi/pulumi/sdk/v3/go/pulumi" -// -// ) -// -// func main() { -// pulumi.Run(func(ctx *pulumi.Context) error { -// _, err := helm.NewChart(ctx, "nginx-ingress", helm.ChartArgs{ -// Chart: pulumi.String("nginx-ingress"), -// Version: pulumi.String("1.24.4"), -// Namespace: pulumi.String("test-namespace"), -// FetchArgs: helm.FetchArgs{ -// Repo: pulumi.String("https://charts.helm.sh/stable"), -// }, -// }) -// if err != nil { -// return err -// } -// -// return nil -// }) -// } -// -// ``` -// ### Chart with Transformations -// -// ```go -// package main -// -// import ( -// -// "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/helm/v3" -// "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/yaml" -// "github.com/pulumi/pulumi/sdk/v3/go/pulumi" -// -// ) -// -// func main() { -// pulumi.Run(func(ctx *pulumi.Context) error { -// _, err := helm.NewChart(ctx, "nginx-ingress", helm.ChartArgs{ -// Chart: pulumi.String("nginx-ingress"), -// Version: pulumi.String("1.24.4"), -// FetchArgs: helm.FetchArgs{ -// Repo: pulumi.String("https://charts.helm.sh/stable"), -// }, -// Transformations: []yaml.Transformation{ -// // Make every service private to the cluster, i.e., turn all services into ClusterIP -// // instead of LoadBalancer. -// func(state map[string]interface{}, opts ...pulumi.ResourceOption) { -// if state["kind"] == "Service" { -// spec := state["spec"].(map[string]interface{}) -// spec["type"] = "ClusterIP" -// } -// }, -// -// // Set a resource alias for a previous name. -// func(state map[string]interface{}, opts ...pulumi.ResourceOption) { -// if state["kind"] == "Deployment" { -// aliases := pulumi.Aliases([]pulumi.Alias{ -// { -// Name: pulumi.String("oldName"), -// }, -// }) -// opts = append(opts, aliases) -// } -// }, -// -// // Omit a resource from the Chart by transforming the specified resource definition -// // to an empty List. -// func(state map[string]interface{}, opts ...pulumi.ResourceOption) { -// name := state["metadata"].(map[string]interface{})["name"] -// if state["kind"] == "Pod" && name == "test" { -// state["apiVersion"] = "core/v1" -// state["kind"] = "List" -// } -// }, -// }, -// }) -// if err != nil { -// return err -// } -// -// return nil -// }) -// } -// -// ``` -// Deprecated: helm/v2/Chart is deprecated by helm/v3/Chart and will be removed in a future release. -type Chart struct { - pulumi.ResourceState - - Ready pulumi.ResourceArrayOutput - Resources pulumi.Output -} - -// NewChart registers a new resource with the given unique name, arguments, and options. -// Deprecated: helm/v2/Chart is deprecated by helm/v3/Chart and will be removed in a future release. -func NewChart(ctx *pulumi.Context, - name string, args ChartArgs, opts ...pulumi.ResourceOption) (*Chart, error) { - - // Register the resulting resource state. - chart := &Chart{} - err := ctx.RegisterComponentResource("kubernetes:helm.sh/v2:Chart", name, chart, opts...) - if err != nil { - return nil, err - } - - // Honor the resource name prefix if specified. - if args.ResourcePrefix != "" { - name = args.ResourcePrefix + "-" + name - } - - resources := args.ToChartArgsOutput().ApplyT(func(args chartArgs) (map[string]pulumi.Resource, error) { - return parseChart(ctx, name, args, pulumi.Parent(chart)) - }) - chart.Resources = resources - - // Finally, register all of the resources found. - // Note: Go requires that we "pull" on our futures in order to get them scheduled for execution. Here, we use - // the engine's RegisterResourceOutputs to wait for the resolution of all resources that this Helm chart created. - err = ctx.RegisterResourceOutputs(chart, pulumi.Map{"resources": resources}) - if err != nil { - return nil, errors.Wrap(err, "registering child resources") - } - - chart.Ready = resources.ApplyT(func(x interface{}) []pulumi.Resource { - resources := x.(map[string]pulumi.Resource) - var outputs []pulumi.Resource - for _, r := range resources { - outputs = append(outputs, r) - } - return outputs - }).(pulumi.ResourceArrayOutput) - - return chart, nil -} - -func parseChart(ctx *pulumi.Context, name string, args chartArgs, opts ...pulumi.ResourceOption, -) (map[string]pulumi.Resource, error) { - - // Create temporary directory and file to hold chart data and override values. - chartDir, err := ioutil.TempDir("", "") - if err != nil { - return nil, errors.Wrap(err, "creating temp directory for chart") - } - defer os.RemoveAll(chartDir) - overrides, err := ioutil.TempFile("", "values.*.yaml") - if err != nil { - return nil, errors.Wrap(err, "creating temp file for chart values") - } - defer os.Remove(overrides.Name()) - - var chart string - if args.Path != "" { // Local Chart - chart = args.Path - } else { // Remote Chart - if strings.HasPrefix(args.Repo, "http") { - return nil, fmt.Errorf("`repo` specifies the name of the Helm chart repo. Use FetchArgs.Repo" + - "to specify a URL") - } - - chartToFetch := args.Chart - if len(args.Repo) > 0 { - chartToFetch = fmt.Sprintf("%s/%s", args.Repo, chartToFetch) - } - - // Fetch the Chart. - if len(args.FetchArgs.Destination) == 0 { - args.FetchArgs.Destination = chartDir - } - if len(args.FetchArgs.Version) == 0 { - args.FetchArgs.Version = args.Version - } - err = fetch(chartToFetch, args.FetchArgs) - if err != nil { - return nil, err - } - - // Get the path to the fetched Chart. - files, err := ioutil.ReadDir(chartDir) - if err != nil { - return nil, errors.Wrap(err, "failed to read chart directory") - } - if len(files) == 0 { - return nil, errors.New("chart directory was empty") - } - sort.Slice(files, func(i, j int) bool { - return files[i].Name() < files[j].Name() - }) - fetchedChartName := files[0].Name() - - chart = filepath.Join(chartDir, fetchedChartName) - } - - defaultVals := filepath.Join(chart, "values.yaml") - - helmArgs := []string{"template", chart, "--name-template", name, "--values", defaultVals} - // Write overrides file if Values set. - if args.Values != nil { - b, err := json.Marshal(args.Values) - if err != nil { - return nil, errors.Wrap(err, "failed to marshal overrides file") - } - _, err = overrides.Write(b) - if err != nil { - return nil, errors.Wrap(err, "failed to write overrides file") - } - helmArgs = append(helmArgs, "--values", overrides.Name()) - } - if len(args.Namespace) > 0 { - helmArgs = append(helmArgs, "--namespace", args.Namespace) - } - - for _, version := range args.APIVersions { - helmArgs = append(helmArgs, fmt.Sprintf("--api-versions=%s", version)) - } - - // Check for helm version - v3, err := isHelmV3() - - if err != nil { - return nil, err - } - - if v3 { - helmArgs = append(helmArgs, "--include-crds") - } - - helmCmd := exec.Command("helm", helmArgs...) - var stderr bytes.Buffer - helmCmd.Stderr = &stderr - yamlBytes, err := helmCmd.Output() - if err != nil { - return nil, errors.Wrap(err, fmt.Sprintf("failed to run helm template: %s", stderr.String())) - } - objs, err := yamlDecode(ctx, string(yamlBytes), args.Namespace) - if err != nil { - return nil, err - } - - resources, err := yaml.ParseYamlObjects(ctx, objs, args.Transformations, args.ResourcePrefix, opts...) - if err != nil { - return nil, err - } - return resources, nil -} - -// yamlDecode invokes the function to decode a single YAML file and decompose it into object structures. -func yamlDecode(ctx *pulumi.Context, text, namespace string) ([]map[string]interface{}, error) { - args := struct { - Text string `pulumi:"text"` - DefaultNamespace string `pulumi:"defaultNamespace"` - }{Text: text, DefaultNamespace: namespace} - var ret struct { - Result []map[string]interface{} `pulumi:"result"` - } - if err := ctx.Invoke("kubernetes:yaml:decode", &args, &ret); err != nil { - return nil, errors.Wrap(err, "failed to decode YAML") - } - return ret.Result, nil -} - -func isHelmV3() (bool, error) { - - /* - Helm v2 returns version like this: - Client: v2.16.7+g5f2584f - Helm v3 returns a version like this: - v3.1.2+gd878d4d - --include-crds is available in helm v3.1+ so check for a regex matching that version - */ - helmVerArgs := []string{"version", "--short"} - helmVerCmd := exec.Command("helm", helmVerArgs...) - - var stderr bytes.Buffer - helmVerCmd.Stderr = &stderr - - version, err := helmVerCmd.Output() - if err != nil { - return false, errors.Wrap(err, fmt.Sprintf("failed to check helm version: %s", stderr.String())) - } - - matched, err := regexp.MatchString(`^v3\.[1-9]`, string(version)) - if err != nil { - return false, errors.Wrap(err, fmt.Sprintf("failed to perform regex match: %s", stderr.String())) - } - - return matched, nil - -} - -func fetch(name string, args fetchArgs) error { - helmArgs := []string{"fetch", name} - - // Untar by default. - if args.Untar == nil || !*args.Untar { - helmArgs = append(helmArgs, "--untar") - } - - env := os.Environ() - // Helm v3 removed the `--home` flag, so we must use an env var instead. - if len(args.Home) > 0 { - found := false - for i, v := range env { - if strings.HasPrefix(v, "HELM_HOME=") { - env[i] = fmt.Sprintf("HELM_HOME=%s", args.Home) - found = true - break - } - } - if !found { - env = append(env, fmt.Sprintf("HELM_HOME=%s", args.Home)) - } - } - - if len(args.Version) > 0 { - helmArgs = append(helmArgs, "--version", args.Version) - } - if len(args.CAFile) > 0 { - helmArgs = append(helmArgs, "--ca-file", args.CAFile) - } - if len(args.CertFile) > 0 { - helmArgs = append(helmArgs, "--cert-file", args.CertFile) - } - if len(args.KeyFile) > 0 { - helmArgs = append(helmArgs, "--key-file", args.KeyFile) - } - if len(args.Destination) > 0 { - helmArgs = append(helmArgs, "--destination", args.Destination) - } - if len(args.Keyring) > 0 { - helmArgs = append(helmArgs, "--keyring", args.Keyring) - } - if len(args.Password) > 0 { - helmArgs = append(helmArgs, "--password", args.Password) - } - if len(args.Repo) > 0 { - helmArgs = append(helmArgs, "--repo", args.Repo) - } - if len(args.UntarDir) > 0 { - helmArgs = append(helmArgs, "--untardir", args.UntarDir) - } - if len(args.Username) > 0 { - helmArgs = append(helmArgs, "--username", args.Username) - } - if args.Devel != nil && *args.Devel { - helmArgs = append(helmArgs, "--devel") - } - if args.Prov != nil && *args.Prov { - helmArgs = append(helmArgs, "--prov") - } - if args.Verify != nil && *args.Verify { - helmArgs = append(helmArgs, "--verify") - } - - helmCmd := exec.Command("helm", helmArgs...) - var stderr bytes.Buffer - helmCmd.Stderr = &stderr - err := helmCmd.Run() - if err != nil { - return errors.Wrap(err, fmt.Sprintf("failed to fetch Helm chart: %s", stderr.String())) - } - - return nil -} - -// GetResource returns a resource defined by a built-in Kubernetes group/version/kind, name and namespace. -// For example, GetResource("v1/Pod", "foo", "") would return a Pod called "foo" from the "default" namespace. -func (c *Chart) GetResource(gvk, name, namespace string) pulumi.AnyOutput { - id := name - if len(namespace) > 0 && namespace != "default" { - id = fmt.Sprintf("%s/%s", namespace, name) - } - key := fmt.Sprintf("%s::%s", gvk, id) - return c.Resources.ApplyT(func(x interface{}) interface{} { - resources := x.(map[string]pulumi.Resource) - return resources[key] - }).(pulumi.AnyOutput) -} diff --git a/provider/pkg/gen/_go-templates/helm/v2/pulumiTypes.go b/provider/pkg/gen/_go-templates/helm/v2/pulumiTypes.go deleted file mode 100644 index c8094ce96b..0000000000 --- a/provider/pkg/gen/_go-templates/helm/v2/pulumiTypes.go +++ /dev/null @@ -1,198 +0,0 @@ -// Copyright 2016-2020, Pulumi Corporation. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// *** WARNING: this file was generated by pulumigen. *** -// *** Do not edit by hand unless you're certain you know what you are doing! *** - -package helm - -import ( - "context" - "reflect" - - "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/yaml" - "github.com/pulumi/pulumi/sdk/v3/go/pulumi" -) - -// FetchArgs specifies arguments for fetching the Helm chart. -type FetchArgs struct { - // Specific version of a chart. If unset, the latest version is fetched. - Version pulumi.StringInput - // Verify certificates of HTTPS-enabled servers using this CA bundle. - CAFile pulumi.StringInput - // Identify HTTPS client using this SSL certificate file. - CertFile pulumi.StringInput - // Identify HTTPS client using this SSL key file. - KeyFile pulumi.StringInput - // Location to write the chart. If Destination and UntarDir are specified, UntarDir is - // appended to Destination (default "."). - Destination pulumi.StringInput - // Keyring containing public keys (default "~/.gnupg/pubring.gpg"). - Keyring pulumi.StringInput - // Chart repository password. - Password pulumi.StringInput - // Chart repository URL for the requested chart. - Repo pulumi.StringInput - // Location to expand the chart. (default "."). - UntarDir pulumi.StringInput - // Chart repository username. - Username pulumi.StringInput - // Location of your Helm config. Overrides $HELM_HOME (default "~/.helm"). - Home pulumi.StringInput - // Use development versions, too. Equivalent to version '>0.0.0-0'. If Version is set, - // Devel is ignored. - Devel pulumi.BoolPtrInput - // Fetch the provenance file, but don't perform verification. - Prov pulumi.BoolPtrInput - // If false, leave the chart as a tarball after downloading. - Untar pulumi.BoolPtrInput - // Verify the package against its signature. - Verify pulumi.BoolPtrInput -} - -// fetchArgs is a copy of FetchArgs but without using TInput in types. -type fetchArgs struct { - Version string `pulumi:"version"` - CAFile string `pulumi:"caFile"` - CertFile string `pulumi:"certFile"` - KeyFile string `pulumi:"keyFile"` - Destination string `pulumi:"destination"` - Keyring string `pulumi:"keyring"` - Password string `pulumi:"password"` - Repo string `pulumi:"repo"` - UntarDir string `pulumi:"untarDir"` - Username string `pulumi:"username"` - Home string `pulumi:"home"` - Devel *bool `pulumi:"devel"` - Prov *bool `pulumi:"prov"` - Untar *bool `pulumi:"untar"` - Verify *bool `pulumi:"verify"` -} - -type FetchArgsInput interface { - pulumi.Input - - ToFetchArgsOutput() FetchArgsOutput - ToFetchArgsOutputWithContext(context.Context) FetchArgsOutput -} - -func (FetchArgs) ElementType() reflect.Type { - return reflect.TypeOf((*fetchArgs)(nil)).Elem() -} - -func (i FetchArgs) ToFetchArgsOutput() FetchArgsOutput { - return i.ToFetchArgsOutputWithContext(context.Background()) -} - -func (i FetchArgs) ToFetchArgsOutputWithContext(ctx context.Context) FetchArgsOutput { - return pulumi.ToOutputWithContext(ctx, i).(FetchArgsOutput) -} - -type FetchArgsOutput struct{ *pulumi.OutputState } - -func (FetchArgsOutput) ElementType() reflect.Type { - return reflect.TypeOf((*fetchArgs)(nil)).Elem() -} - -func (o FetchArgsOutput) ToFetchArgsOutput() FetchArgsOutput { - return o -} - -func (o FetchArgsOutput) ToFetchArgsOutputWithContext(ctx context.Context) FetchArgsOutput { - return o -} - -// ChartArgs specifies arguments for constructing a Chart resource. -type ChartArgs struct { - // The optional Kubernetes API versions used for Capabilities.APIVersions. - APIVersions pulumi.StringArrayInput - // The optional namespace to install chart resources into. - Namespace pulumi.StringInput - // Overrides for chart values. - Values pulumi.MapInput - // Transformations is an optional list of transformations to apply to Kubernetes resource definitions - // before registering with the engine. - Transformations []yaml.Transformation - // ResourcePrefix is an optional prefix for the auto-generated resource names. For example, a resource named `bar` - // created with resource prefix of `"foo"` would produce a resource named `"foo-bar"`. - ResourcePrefix string - - // (Remote chart) The repository name of the chart to deploy. Example: "stable". - Repo pulumi.StringInput - // (Remote chart) The name of the chart to deploy. If Repo is specified, this chart name will be prefixed - // by the repo name. - // Example: Repo: "stable", Chart: "nginx-ingress" -> "stable/nginx-ingress" - // Example: Chart: "stable/nginx-ingress" -> "stable/nginx-ingress" - Chart pulumi.StringInput - // (Remote chart) The version of the chart to deploy. If not provided, the latest version will be deployed. - Version pulumi.StringInput - // (Remote chart) Additional options to customize the fetching of the Helm chart. - FetchArgs FetchArgsInput - - // (Local chart) The path to the chart directory which contains the `Chart.yaml` file. - // If Path is set, any remote chart args (Repo, Chart, Version, FetchArgs) will be ignored. - Path pulumi.StringInput -} - -// chartArgs is a copy of ChartArgs but without using TInput in types. -type chartArgs struct { - APIVersions []string `pulumi:"apiVersions"` - Namespace string `pulumi:"namespace"` - Values map[string]interface{} `pulumi:"values"` - Transformations []yaml.Transformation `pulumi:"transformations"` - ResourcePrefix string `pulumi:"resourcePrefix"` - Repo string `pulumi:"repo"` - Chart string `pulumi:"chart"` - Version string `pulumi:"version"` - FetchArgs fetchArgs `pulumi:"fetchArgs"` - Path string `pulumi:"path"` -} - -type ChartArgsInput interface { - pulumi.Input - - ToChartArgsOutput() ChartArgsOutput - ToChartArgsOutputWithContext(context.Context) ChartArgsOutput -} - -func (ChartArgs) ElementType() reflect.Type { - return reflect.TypeOf((*chartArgs)(nil)).Elem() -} - -func (i ChartArgs) ToChartArgsOutput() ChartArgsOutput { - return i.ToChartArgsOutputWithContext(context.Background()) -} - -func (i ChartArgs) ToChartArgsOutputWithContext(ctx context.Context) ChartArgsOutput { - return pulumi.ToOutputWithContext(ctx, i).(ChartArgsOutput) -} - -type ChartArgsOutput struct{ *pulumi.OutputState } - -func (ChartArgsOutput) ElementType() reflect.Type { - return reflect.TypeOf((*chartArgs)(nil)).Elem() -} - -func (o ChartArgsOutput) ToChartArgsOutput() ChartArgsOutput { - return o -} - -func (o ChartArgsOutput) ToChartArgsOutputWithContext(ctx context.Context) ChartArgsOutput { - return o -} - -func init() { - pulumi.RegisterOutputType(FetchArgsOutput{}) - pulumi.RegisterOutputType(ChartArgsOutput{}) -} diff --git a/provider/pkg/gen/dotnet-templates/helm/v2/Chart.cs b/provider/pkg/gen/dotnet-templates/helm/v2/Chart.cs deleted file mode 100644 index 3605a619dd..0000000000 --- a/provider/pkg/gen/dotnet-templates/helm/v2/Chart.cs +++ /dev/null @@ -1,237 +0,0 @@ -// Copyright 2016-2020, Pulumi Corporation. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// *** WARNING: this file was generated by pulumigen. *** -// *** Do not edit by hand unless you're certain you know what you are doing! *** - -using System; - -namespace Pulumi.Kubernetes.Helm.V2 -{ - /// - /// Chart is a component representing a collection of resources described by an arbitrary Helm - /// Chart. The Chart can be fetched from any source that is accessible to the `helm` command - /// line. Values in the `values.yml` file can be overridden using - /// (equivalent to `--set` or having multiple - /// `values.yml` files). Objects can be transformed arbitrarily by supplying callbacks to - /// . - /// - /// does not use Tiller. The Chart specified is copied and expanded locally; - /// the semantics are equivalent to running `helm template` and then using Pulumi to manage the - /// resulting YAML manifests. Any values that would be retrieved in-cluster are assigned fake - /// values, and none of Tiller's server-side validity testing is executed. - /// - /// ## Example Usage - /// ### Local Chart Directory - /// - /// ```csharp - /// using System.Threading.Tasks; - /// using Pulumi; - /// using Pulumi.Kubernetes.Helm; - /// using Pulumi.Kubernetes.Helm.V2; - /// - /// class HelmStack : Stack - /// { - /// public HelmStack() - /// { - /// var nginx = new Chart("nginx-ingress", new LocalChartArgs - /// { - /// Path = "./nginx-ingress", - /// }); - /// - /// } - /// } - /// ``` - /// ### Remote Chart - /// - /// ```csharp - /// using System.Threading.Tasks; - /// using Pulumi; - /// using Pulumi.Kubernetes.Helm; - /// using Pulumi.Kubernetes.Helm.V2; - /// - /// class HelmStack : Stack - /// { - /// public HelmStack() - /// { - /// var nginx = new Chart("nginx-ingress", new ChartArgs - /// { - /// Chart = "nginx-ingress", - /// Version = "1.24.4", - /// FetchOptions = new ChartFetchArgs - /// { - /// Repo = "https://kubernetes-charts.storage.googleapis.com/" - /// } - /// }); - /// - /// } - /// } - /// ``` - /// ### Set Chart Values - /// - /// ```csharp - /// using System.Collections.Generic; - /// using System.Threading.Tasks; - /// using Pulumi; - /// using Pulumi.Kubernetes.Helm; - /// using Pulumi.Kubernetes.Helm.V2; - /// - /// class HelmStack : Stack - /// { - /// public HelmStack() - /// { - /// var values = new Dictionary<string, object> - /// { - /// ["controller"] = new Dictionary<string, object> - /// { - /// ["metrics"] = new Dictionary<string, object> - /// { - /// ["enabled"] = true - /// } - /// }, - /// }; - /// - /// var nginx = new Chart("nginx-ingress", new ChartArgs - /// { - /// Chart = "nginx-ingress", - /// Version = "1.24.4", - /// FetchOptions = new ChartFetchArgs - /// { - /// Repo = "https://kubernetes-charts.storage.googleapis.com/" - /// }, - /// Values = values, - /// }); - /// - /// } - /// } - /// ``` - /// ### Deploy Chart into Namespace - /// - /// ```csharp - /// using System.Threading.Tasks; - /// using Pulumi; - /// using Pulumi.Kubernetes.Helm; - /// using Pulumi.Kubernetes.Helm.V2; - /// - /// class HelmStack : Stack - /// { - /// public HelmStack() - /// { - /// var nginx = new Chart("nginx-ingress", new ChartArgs - /// { - /// Chart = "nginx-ingress", - /// Version = "1.24.4", - /// Namespace = "test-namespace", - /// FetchOptions = new ChartFetchArgs - /// { - /// Repo = "https://kubernetes-charts.storage.googleapis.com/" - /// }, - /// }); - /// - /// } - /// } - /// ``` - /// ### Chart with Transformations - /// - /// ```csharp - /// using System.Collections.Generic; - /// using System.Collections.Immutable; - /// using System.Threading.Tasks; - /// using Pulumi; - /// using Pulumi.Kubernetes.Helm; - /// using Pulumi.Kubernetes.Helm.V2; - /// - /// class HelmStack : Stack - /// { - /// public HelmStack() - /// { - /// var nginx = new Chart("nginx-ingress", new ChartArgs - /// { - /// Chart = "nginx-ingress", - /// Version = "1.24.4", - /// FetchOptions = new ChartFetchArgs - /// { - /// Repo = "https://kubernetes-charts.storage.googleapis.com/" - /// }, - /// Transformations = - /// { - /// LoadBalancerToClusterIP, - /// ResourceAlias, - /// OmitTestPod, - /// } - /// - /// }); - /// - /// // Make every service private to the cluster, i.e., turn all services into ClusterIP instead of LoadBalancer. - /// ImmutableDictionary<string, object> LoadBalancerToClusterIP(ImmutableDictionary<string, object> obj, CustomResourceOptions opts) - /// { - /// if ((string)obj["kind"] == "Service" && (string)obj["apiVersion"] == "v1") - /// { - /// var spec = (ImmutableDictionary<string, object>)obj["spec"]; - /// if (spec != null && (string)spec["type"] == "LoadBalancer") - /// { - /// return obj.SetItem("spec", spec.SetItem("type", "ClusterIP")); - /// } - /// } - /// - /// return obj; - /// } - /// - /// // Set a resource alias for a previous name. - /// ImmutableDictionary<string, object> ResourceAlias(ImmutableDictionary<string, object> obj, CustomResourceOptions opts) - /// { - /// if ((string)obj["kind"] == "Deployment") - /// { - /// opts.Aliases.Add(new Alias { Name = "oldName" }); - /// } - /// - /// return obj; - /// } - /// - /// // Omit a resource from the Chart by transforming the specified resource definition to an empty List. - /// ImmutableDictionary<string, object> OmitTestPod(ImmutableDictionary<string, object> obj, CustomResourceOptions opts) - /// { - /// var metadata = (ImmutableDictionary<string, object>)obj["metadata"]; - /// if ((string)obj["kind"] == "Pod" && (string)metadata["name"] == "test") - /// { - /// return new Dictionary<string, object> - /// { - /// ["apiVersion"] = "v1", - /// ["kind"] = "List", - /// ["items"] = new Dictionary<string, object>(), - /// }.ToImmutableDictionary(); - /// } - /// - /// return obj; - /// } - /// } - /// } - /// ``` - /// - [Obsolete(@"helm/v2/Chart is deprecated by helm/v3/Chart and will be removed in a future release.")] - public sealed class Chart : ChartBase - { - /// - /// Create a Chart resource with the given unique name, arguments, and options. - /// - /// - /// The unique name of the resource - /// The arguments used to populate this resource's properties - /// A bag of options that control this resource's behavior - public Chart(string releaseName, Union args, ComponentResourceOptions? options = null) - : base(releaseName, args, options) - { - } - } -} diff --git a/provider/pkg/gen/nodejs-templates/helm/v2/helm.ts b/provider/pkg/gen/nodejs-templates/helm/v2/helm.ts deleted file mode 100644 index d59b66ecad..0000000000 --- a/provider/pkg/gen/nodejs-templates/helm/v2/helm.ts +++ /dev/null @@ -1,483 +0,0 @@ -// Copyright 2016-2020, Pulumi Corporation. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// *** WARNING: this file was generated by the pulumigen. *** -// *** Do not edit by hand unless you're certain you know what you are doing! *** - -import * as pulumi from "@pulumi/pulumi"; -import { execSync } from "child_process"; -import * as fs from "fs"; -import * as nodepath from "path"; -import * as shell from "shell-quote"; -import * as tmp from "tmp"; -import * as path from "../../path"; -import { getVersion } from "../../utilities"; -import * as yaml from "../../yaml/index"; - -/** - * Chart is a component representing a collection of resources described by an arbitrary Helm - * Chart. The Chart can be fetched from any source that is accessible to the `helm` command - * line. Values in the `values.yml` file can be overridden using `ChartOpts.values` (equivalent - * to `--set` or having multiple `values.yml` files). Objects can be transformed arbitrarily by - * supplying callbacks to `ChartOpts.transformations`. - * - * `Chart` does not use Tiller. The Chart specified is copied and expanded locally; the semantics - * are equivalent to running `helm template` and then using Pulumi to manage the resulting YAML - * manifests. Any values that would be retrieved in-cluster are assigned fake values, and - * none of Tiller's server-side validity testing is executed. - * - * ## Example Usage - * ### Local Chart Directory - * - * ```typescript - * import * as k8s from "@pulumi/kubernetes"; - * - * const nginxIngress = new k8s.helm.v2.Chart("nginx-ingress", { - * path: "./nginx-ingress", - * }); - * ``` - * ### Remote Chart - * - * ```typescript - * import * as k8s from "@pulumi/kubernetes"; - * - * const nginxIngress = new k8s.helm.v2.Chart("nginx-ingress", { - * chart: "nginx-ingress", - * version: "1.24.4", - * fetchOpts:{ - * repo: "https://charts.helm.sh/stable", - * }, - * }); - * ``` - * ### Set Chart values - * - * ```typescript - * import * as k8s from "@pulumi/kubernetes"; - * - * const nginxIngress = new k8s.helm.v2.Chart("nginx-ingress", { - * chart: "nginx-ingress", - * version: "1.24.4", - * fetchOpts:{ - * repo: "https://charts.helm.sh/stable", - * }, - * values: { - * controller: { - * metrics: { - * enabled: true, - * } - * } - * }, - * }); - * ``` - * ### Deploy Chart into Namespace - * - * ```typescript - * import * as k8s from "@pulumi/kubernetes"; - * - * const nginxIngress = new k8s.helm.v2.Chart("nginx-ingress", { - * chart: "nginx-ingress", - * version: "1.24.4", - * namespace: "test-namespace", - * fetchOpts:{ - * repo: "https://charts.helm.sh/stable", - * }, - * }); - * ``` - * ### Chart with Transformations - * - * ```typescript - * import * as k8s from "@pulumi/kubernetes"; - * - * const nginxIngress = new k8s.helm.v2.Chart("nginx-ingress", { - * chart: "nginx-ingress", - * version: "1.24.4", - * fetchOpts:{ - * repo: "https://charts.helm.sh/stable", - * }, - * transformations: [ - * // Make every service private to the cluster, i.e., turn all services into ClusterIP instead of LoadBalancer. - * (obj: any, opts: pulumi.CustomResourceOptions) => { - * if (obj.kind === "Service" && obj.apiVersion === "v1") { - * if (obj.spec && obj.spec.type && obj.spec.type === "LoadBalancer") { - * obj.spec.type = "ClusterIP"; - * } - * } - * }, - * - * // Set a resource alias for a previous name. - * (obj: any, opts: pulumi.CustomResourceOptions) => { - * if (obj.kind === "Deployment") { - * opts.aliases = [{ name: "oldName" }] - * }, - * - * // Omit a resource from the Chart by transforming the specified resource definition to an empty List. - * (obj: any, opts: pulumi.CustomResourceOptions) => { - * if (obj.kind === "Pod" && obj.metadata.name === "test") { - * obj.apiVersion = "v1" - * obj.kind = "List" - * }, - * ], - * }); - * ``` - * - * @deprecated helm/v2/Chart is deprecated by helm/v3/Chart and will be removed in a future release. - */ -export class Chart extends yaml.CollectionComponentResource { - /** @internal */ - public static readonly __pulumiType = 'kubernetes:helm.sh/v2:Chart'; - - /** - * Create an instance of the specified Helm chart. - * @param releaseName Name of the Chart (e.g., nginx-ingress). - * @param config Configuration options for the Chart. - * @param opts A bag of options that control this resource's behavior. - */ - constructor( - releaseName: string, - config: ChartOpts | LocalChartOpts, - opts?: pulumi.ComponentResourceOptions - ) { - if (config.resourcePrefix !== undefined) { - releaseName = `${config.resourcePrefix}-${releaseName}` - } - super("kubernetes:helm.sh/v2:Chart", releaseName, config, opts); - - const allConfig = pulumi.output(config); - const configDeps = Array.from(>(allConfig).resources()); - - (allConfig).isKnown.then((isKnown: boolean) => { - if (!isKnown) { - // Note that this can only happen during a preview. - pulumi.log.info("[Can't preview] all chart values must be known ahead of time to generate an accurate preview.", this); - } - }); - - this.resources = allConfig.apply(cfg => { - // Create temporary directories and files to hold chart data and override values. - const overrides = tmp.fileSync({ postfix: ".yaml" }); - const chartDir = tmp.dirSync({ unsafeCleanup: true }); - - try { - let chart: string; - let defaultValues: string; - let cmd: string; - if (isChartOpts(cfg)) { - // Fetch chart. - if (cfg.repo && cfg.repo.includes("http")) { - pulumi.log.error( - "`repo` specifies the name of the Helm chart repo. Use `fetchOpts.repo` to specify a URL.", this); - } - const chartToFetch = cfg.repo ? `${cfg.repo}/${cfg.chart}` : cfg.chart; - const fetchOpts = Object.assign({}, cfg.fetchOpts, { - destination: chartDir.name, - version: cfg.version - }); - fetch(chartToFetch, fetchOpts); - const fetchedChartName = fs.readdirSync(chartDir.name).sort()[0]; - chart = path.quotePath(nodepath.join(chartDir.name, fetchedChartName)); - defaultValues = path.quotePath( - nodepath.join(chartDir.name, fetchedChartName, "values.yaml") - ); - } else { - chart = cfg.path; - defaultValues = path.quotePath(nodepath.join(chart, "values.yaml")); - } - - // Write overrides file. - const data = JSON.stringify(cfg.values || {}, undefined, " "); - fs.writeFileSync(overrides.name, data); - - // Does not require Tiller. From the `helm template` documentation: - // - // > Render chart templates locally and display the output. - // > - // > This does not require Tiller. However, any values that would normally be - // > looked up or retrieved in-cluster will be faked locally. Additionally, none - // > of the server-side testing of chart validity (e.g. whether an API is supported) - // > is done. - const release = shell.quote([releaseName]); - const values = path.quotePath(overrides.name); - const apiVersionsArgs = cfg.apiVersions - ? cfg.apiVersions - .map(v => `--api-versions=${v}`) - .join(" ") - : ""; - const namespaceArg = cfg.namespace - ? `--namespace ${shell.quote([cfg.namespace])}` - : ""; - - // Check the helm version - v2 or v3 - let helmVerCmd = `helm version --short || true`; - var helmVer; - try { - helmVer = execSync( - helmVerCmd, - { - stdio: ['pipe', 'pipe', 'ignore'], // Suppress tiller version error - }, - ).toString(); - } catch (e: any) { - helmVer = e.stdout.toString(); - } - - cmd = `helm template ${chart} --name-template ${release} --values ${defaultValues} --values ${values} ${apiVersionsArgs} ${namespaceArg}`; - // Helm v2 returns version like this: - // Client: v2.16.7+g5f2584f - // Helm v3 returns a version like this: - // v3.1.2+gd878d4d - // --include-crds is available in helm v3.1+ so check for a regex matching that version - if (RegExp('^v3\.[1-9]').test(helmVer)) { - cmd += ` --include-crds` - } - - const yamlStream = execSync( - cmd, - { - env: {...process.env}, - maxBuffer: 512 * 1024 * 1024 // 512 MB - }, - ).toString(); - return this.parseTemplate( - yamlStream, cfg.transformations, cfg.resourcePrefix, configDeps, cfg.namespace); - } catch (e: any) { - // Shed stack trace, only emit the error. - throw new pulumi.RunError(e.toString()); - } finally { - // Clean up temporary files and directories. - chartDir.removeCallback(); - overrides.removeCallback(); - } - - // Without this block, the TS compiler adds `| undefined` even though execution won't get here. - return pulumi.output<{[key: string]: pulumi.CustomResource}>({}); - }); - - this.ready = this.resources.apply(m => Object.values(m)); - } - - parseTemplate( - text: string, - transformations: ((o: any, opts: pulumi.CustomResourceOptions) => void)[] | undefined, - resourcePrefix: string | undefined, - dependsOn: pulumi.Resource[], - defaultNamespace: string | undefined, - ): pulumi.Output<{ [key: string]: pulumi.CustomResource }> { - // Rather than using the default provider for the following invoke call, use the version specified - // in package.json. - let invokeOpts: pulumi.InvokeOptions = { async: true, version: getVersion() }; - - const promise = pulumi.runtime.invoke("kubernetes:yaml:decode", {text, defaultNamespace}, invokeOpts); - return pulumi.output(promise).apply<{[key: string]: pulumi.CustomResource}>(p => yaml.parse( - { - resourcePrefix: resourcePrefix, - objs: p.result, - transformations: transformations || [], - }, - { parent: this, dependsOn: dependsOn } - )); - } -} - -interface BaseChartOpts { - /** - * The optional kubernetes api versions used for Capabilities.APIVersions. - */ - apiVersions?: pulumi.Input[]>; - /** - * The optional namespace to install chart resources into. - */ - namespace?: pulumi.Input; - /** - * Overrides for chart values. - */ - values?: pulumi.Inputs; - /** - * A set of transformations to apply to Kubernetes resource definitions before registering - * with engine. - */ - transformations?: ((o: any, opts: pulumi.CustomResourceOptions) => void)[]; - /** - * An optional prefix for the auto-generated resource names. - * Example: A resource created with resourcePrefix="foo" would produce a resource named "foo-resourceName". - */ - resourcePrefix?: string -} - -/** - * The set of arguments for constructing a Chart resource from a remote source. - */ -export interface ChartOpts extends BaseChartOpts { - /** - * The repository name of the chart to deploy. - * Example: "stable" - */ - repo?: pulumi.Input; - - /** - * The name of the chart to deploy. If [repo] is provided, this chart name will be prefixed by the repo name. - * Example: repo: "stable", chart: "nginx-ingress" -> "stable/nginx-ingress" - * Example: chart: "stable/nginx-ingress" -> "stable/nginx-ingress" - */ - chart: pulumi.Input; - - /** - * The version of the chart to deploy. If not provided, the latest version will be deployed. - */ - version?: pulumi.Input; - - /** - * Additional options to customize the fetching of the Helm chart. - */ - fetchOpts?: pulumi.Input; -} - -function isChartOpts(o: any): o is ChartOpts { - return "chart" in o; -} - -/** - * The set of arguments for constructing a Chart resource from a local source. - */ -export interface LocalChartOpts extends BaseChartOpts { - /** - * The path to the chart directory which contains the `Chart.yaml` file. - */ - path: string; -} - -function isLocalChartOpts(o: any): o is LocalChartOpts { - return "path" in o; -} - -/** - * Additional options to customize the fetching of the Helm chart. - */ -export interface FetchOpts { - /** Specific version of a chart. Without this, the latest version is fetched. */ - version?: pulumi.Input; - - /** Verify certificates of HTTPS-enabled servers using this CA bundle. */ - caFile?: pulumi.Input; - - /** Identify HTTPS client using this SSL certificate file. */ - certFile?: pulumi.Input; - - /** Identify HTTPS client using this SSL key file. */ - keyFile?: pulumi.Input; - - /** - * Location to write the chart. If this and tardir are specified, tardir is appended to this - * (default "."). - */ - destination?: pulumi.Input; - - /** Keyring containing public keys (default "/Users/alex/.gnupg/pubring.gpg"). */ - keyring?: pulumi.Input; - - /** Chart repository password. */ - password?: pulumi.Input; - - /** Chart repository url where to locate the requested chart. */ - repo?: pulumi.Input; - - /** - * If untar is specified, this flag specifies the name of the directory into which the chart is - * expanded (default "."). - */ - untardir?: pulumi.Input; - - /** Chart repository username. */ - username?: pulumi.Input; - - /** Location of your Helm config. Overrides $HELM_HOME (default "/Users/alex/.helm"). */ - home?: pulumi.Input; - - /** - * Use development versions, too. Equivalent to version '>0.0.0-0'. If --version is set, this is - * ignored. - */ - devel?: pulumi.Input; - - /** Fetch the provenance file, but don't perform verification. */ - prov?: pulumi.Input; - - /** If set to false, will leave the chart as a tarball after downloading. */ - untar?: pulumi.Input; - - /** Verify the package against its signature. */ - verify?: pulumi.Input; -} - -interface ResolvedFetchOpts { - version?: string; - caFile?: string; - certFile?: string; - keyFile?: string; - destination?: string; - keyring?: string; - password?: string; - repo?: string; - untardir?: string; - username?: string; - home?: string; - devel?: boolean; - prov?: boolean; - untar?: boolean; - verify?: boolean; -} - -/** - * Retrieve a package from a package repository, and download it locally. - * - * This is useful for fetching packages to inspect, modify, or repackage. It can also be used to - * perform cryptographic verification of a chart without installing the chart. - * - * There are options for unpacking the chart after download. This will create a directory for the - * chart and uncompress into that directory. - * - * If the `verify` option is specified, the requested chart MUST have a provenance file, and MUST - * pass the verification process. Failure in any part of this will result in an error, and the chart - * will not be saved locally. - * - * @ignore - */ -export function fetch(chart: string, opts?: ResolvedFetchOpts) { - const flags: string[] = []; - const env: { [key: string]: string | undefined } = {...process.env}; - if (opts !== undefined) { - // Untar by default. - if(opts.untar !== false) { flags.push(`--untar`); } - - // Helm v3 removed the `--home` flag, so we must use an env var instead. - if (opts.home) { env['HELM_HOME'] = path.quotePath(opts.home) } - - // For arguments that are not paths to files, it is sufficient to use shell.quote to quote the arguments. - // However, for arguments that are actual paths to files we use path.quotePath (note that path here is - // not the node path builtin module). This ensures proper escaping of paths on Windows. - if (opts.version !== undefined) { flags.push(`--version ${shell.quote([opts.version])}`); } - if (opts.caFile !== undefined) { flags.push(`--ca-file ${path.quotePath(opts.caFile)}`); } - if (opts.certFile !== undefined) { flags.push(`--cert-file ${path.quotePath(opts.certFile)}`); } - if (opts.keyFile !== undefined) { flags.push(`--key-file ${path.quotePath(opts.keyFile)}`); } - if (opts.destination !== undefined) { flags.push(`--destination ${path.quotePath(opts.destination)}`); } - if (opts.keyring !== undefined) { flags.push(`--keyring ${path.quotePath(opts.keyring)}`); } - if (opts.password !== undefined) { flags.push(`--password ${shell.quote([opts.password])}`); } - if (opts.repo !== undefined) { flags.push(`--repo ${path.quotePath(opts.repo)}`); } - if (opts.untardir !== undefined) { flags.push(`--untardir ${path.quotePath(opts.untardir)}`); } - if (opts.username !== undefined) { flags.push(`--username ${shell.quote([opts.username])}`); } - if (opts.devel === true) { flags.push(`--devel`); } - if (opts.prov === true) { flags.push(`--prov`); } - if (opts.verify === true) { flags.push(`--verify`); } - } - execSync(`helm fetch ${shell.quote([chart])} ${flags.join(" ")}`, { env }); -} diff --git a/provider/pkg/gen/overlays.go b/provider/pkg/gen/overlays.go index 073877e147..8edbf9e2f0 100644 --- a/provider/pkg/gen/overlays.go +++ b/provider/pkg/gen/overlays.go @@ -1,4 +1,4 @@ -// Copyright 2016-2021, Pulumi Corporation. +// Copyright 2016-2023, Pulumi Corporation. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -48,94 +48,6 @@ var serviceSpecType = pschema.ComplexTypeSpec{ }, } -//go:embed examples/overlays/chartV2.md -var helmV2ChartMD string - -var helmV2ChartResource = pschema.ResourceSpec{ - IsComponent: true, - ObjectTypeSpec: pschema.ObjectTypeSpec{ - IsOverlay: true, - Description: helmV2ChartMD, - Properties: map[string]pschema.PropertySpec{ - "resources": { - TypeSpec: pschema.TypeSpec{ - Type: "string", - }, - Description: "Resources created by the Chart.", - }, - "urn": { - TypeSpec: pschema.TypeSpec{ - Type: "string", - }, - Description: "The stable logical URN used to distinctly address a resource, both before and after deployments.", - }, - }, - Type: "object", - }, - InputProperties: map[string]pschema.PropertySpec{ - "chart": { - TypeSpec: pschema.TypeSpec{ - Type: "string", - }, - Description: "The name of the chart to deploy. If [repo] is provided, this chart name will be prefixed by the repo name. Example: repo: \"stable\", chart: \"nginx-ingress\" -> \"stable/nginx-ingress\" Example: chart: \"stable/nginx-ingress\" -> \"stable/nginx-ingress\"\n\nRequired if specifying `ChartOpts` for a remote chart.", - }, - "fetchOpts": { - TypeSpec: pschema.TypeSpec{ - Ref: "#/types/kubernetes:helm.sh/v2:FetchOpts", - }, - Description: "Additional options to customize the fetching of the Helm chart.", - }, - "path": { - TypeSpec: pschema.TypeSpec{ - Type: "string", - }, - Description: "The path to the chart directory which contains the `Chart.yaml` file.\n\nRequired if specifying `LocalChartOpts`.", - }, - "namespace": { - TypeSpec: pschema.TypeSpec{ - Type: "string", - }, - Description: "The optional namespace to install chart resources into.", - }, - "repo": { - TypeSpec: pschema.TypeSpec{ - Type: "string", - }, - Description: "The repository name of the chart to deploy. Example: \"stable\".\n\nUsed only when specifying options for a remote chart.", - }, - "resourcePrefix": { - TypeSpec: pschema.TypeSpec{ - Type: "string", - }, - Description: "An optional prefix for the auto-generated resource names. Example: A resource created with resourcePrefix=\"foo\" would produce a resource named \"foo-resourceName\".", - }, - "transformations": { - TypeSpec: pschema.TypeSpec{ - Type: "array", - Items: &pschema.TypeSpec{ - Ref: "pulumi.json#/Any", - }, - }, - Description: "Optional array of transformations to apply to resources that will be created by this chart prior to creation. Allows customization of the chart behaviour without directly modifying the chart itself.", - }, - "values": { - TypeSpec: pschema.TypeSpec{ - Type: "object", - AdditionalProperties: &pschema.TypeSpec{ - Ref: "pulumi.json#/Any", - }, - }, - Description: "Overrides for chart values.", - }, - "version": { - TypeSpec: pschema.TypeSpec{ - Type: "string", - }, - Description: "The version of the chart to deploy. If not provided, the latest version will be deployed.", - }, - }, -} - //go:embed examples/overlays/chartV3.md var helmV3ChartMD string @@ -224,7 +136,7 @@ var helmV3ChartResource = pschema.ResourceSpec{ }, } -var helmV2FetchOpts = pschema.ComplexTypeSpec{ +var helmV3FetchOpts = pschema.ComplexTypeSpec{ ObjectTypeSpec: pschema.ObjectTypeSpec{ IsOverlay: true, Description: "Additional options to customize the fetching of the Helm chart.", @@ -1373,8 +1285,7 @@ var apiextentionsCustomResourcePatch = pschema.ResourceSpec{ func init() { typeOverlays["kubernetes:core/v1:ServiceSpec"] = serviceSpec typeOverlays["kubernetes:core/v1:ServiceSpecType"] = serviceSpecType - typeOverlays["kubernetes:helm.sh/v2:FetchOpts"] = helmV2FetchOpts - typeOverlays["kubernetes:helm.sh/v3:FetchOpts"] = helmV2FetchOpts // v2 fetch opts are identical to v3 + typeOverlays["kubernetes:helm.sh/v3:FetchOpts"] = helmV3FetchOpts typeOverlays["kubernetes:helm.sh/v3:RepositoryOpts"] = helmV3RepoOpts typeOverlays["kubernetes:helm.sh/v3:ReleaseStatus"] = helmV3ReleaseStatus typeOverlays["kubernetes:index:KubeClientSettings"] = kubeClientSettings @@ -1382,7 +1293,6 @@ func init() { resourceOverlays["kubernetes:apiextensions.k8s.io:CustomResource"] = apiextentionsCustomResource resourceOverlays["kubernetes:apiextensions.k8s.io:CustomResourcePatch"] = apiextentionsCustomResourcePatch - resourceOverlays["kubernetes:helm.sh/v2:Chart"] = helmV2ChartResource resourceOverlays["kubernetes:helm.sh/v3:Chart"] = helmV3ChartResource resourceOverlays["kubernetes:helm.sh/v3:Release"] = helmV3ReleaseResource resourceOverlays["kubernetes:kustomize:Directory"] = kustomizeDirectoryResource diff --git a/provider/pkg/gen/python-templates/helm/v2/helm.py b/provider/pkg/gen/python-templates/helm/v2/helm.py deleted file mode 100644 index b59da3b5e7..0000000000 --- a/provider/pkg/gen/python-templates/helm/v2/helm.py +++ /dev/null @@ -1,677 +0,0 @@ -# Copyright 2016-2021, Pulumi Corporation. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# *** WARNING: this file was generated by the Pulumi Kubernetes codegen tool. *** -# *** Do not edit by hand unless you're certain you know what you are doing! *** - -import json -import os.path -import re -import shutil -import subprocess -from tempfile import mkdtemp, mkstemp -from typing import Any, Callable, Optional, Sequence, TextIO, Tuple, Union -from warnings import warn - -import pulumi.runtime -from pulumi_kubernetes.yaml.yaml import _parse_yaml_document - -from ... import _utilities - -warn(f'helm/v2/Chart is deprecated by helm/v3/Chart and will be removed in a future release.', - DeprecationWarning, stacklevel=2) - - -class Chart(pulumi.ComponentResource): - resources: pulumi.Output[dict] - """ - Kubernetes resources contained in this Chart. - """ - ready: pulumi.Output[Sequence[pulumi.Output[pulumi.Resource]]] - - def __init__(self, - release_name: str, - config: Union['ChartOpts', 'LocalChartOpts'], - opts: Optional[pulumi.ResourceOptions] = None): - """ - Chart is a component representing a collection of resources described by an arbitrary Helm - Chart. The Chart can be fetched from any source that is accessible to the `helm` command - line. Values in the `values.yml` file can be overridden using `ChartOpts.values` (equivalent - to `--set` or having multiple `values.yml` files). Objects can be transformed arbitrarily by - supplying callbacks to `ChartOpts.transformations`. - - Chart does not use Tiller. The Chart specified is copied and expanded locally; the semantics - are equivalent to running `helm template` and then using Pulumi to manage the resulting YAML - manifests. Any values that would be retrieved in-cluster are assigned fake values, and - none of Tiller's server-side validity testing is executed. - - ## Example Usage - ### Local Chart Directory - - ```python - from pulumi_kubernetes.helm.v3 import Chart, LocalChartOpts - - nginx_ingress = Chart( - "nginx-ingress", - LocalChartOpts( - path="./nginx-ingress", - ), - ) - ``` - ### Remote Chart - - ```python - from pulumi_kubernetes.helm.v3 import Chart, ChartOpts, FetchOpts - - nginx_ingress = Chart( - "nginx-ingress", - ChartOpts( - chart="nginx-ingress", - version="1.24.4", - fetch_opts=FetchOpts( - repo="https://charts.helm.sh/stable", - ), - ), - ) - ``` - ### Set Chart Values - - ```python - from pulumi_kubernetes.helm.v3 import Chart, ChartOpts, FetchOpts - - nginx_ingress = Chart( - "nginx-ingress", - ChartOpts( - chart="nginx-ingress", - version="1.24.4", - fetch_opts=FetchOpts( - repo="https://charts.helm.sh/stable", - ), - values={ - "controller": { - "metrics": { - "enabled": True, - }, - }, - }, - ), - ) - ``` - ### Deploy Chart into Namespace - - ```python - from pulumi_kubernetes.helm.v3 import Chart, ChartOpts, FetchOpts - - nginx_ingress = Chart( - "nginx-ingress", - ChartOpts( - chart="nginx-ingress", - version="1.24.4", - namespace="test-namespace", - fetch_opts=FetchOpts( - repo="https://charts.helm.sh/stable", - ), - ), - ) - ``` - ### Chart with Transformations - - ```python - from pulumi_kubernetes.helm.v3 import Chart, ChartOpts, FetchOpts - - # Make every service private to the cluster, i.e., turn all services into ClusterIP instead of LoadBalancer. - def make_service_private(obj, opts): - if obj["kind"] == "Service" and obj["apiVersion"] == "v1": - try: - t = obj["spec"]["type"] - if t == "LoadBalancer": - obj["spec"]["type"] = "ClusterIP" - except KeyError: - pass - - - # Set a resource alias for a previous name. - def alias(obj, opts): - if obj["kind"] == "Deployment": - opts.aliases = ["oldName"] - - - # Omit a resource from the Chart by transforming the specified resource definition to an empty List. - def omit_resource(obj, opts): - if obj["kind"] == "Pod" and obj["metadata"]["name"] == "test": - obj["apiVersion"] = "v1" - obj["kind"] = "List" - - - nginx_ingress = Chart( - "nginx-ingress", - ChartOpts( - chart="nginx-ingress", - version="1.24.4", - fetch_opts=FetchOpts( - repo="https://charts.helm.sh/stable", - ), - transformations=[make_service_private, alias, omit_resource], - ), - ) - ``` - - :param str release_name: Name of the Chart (e.g., nginx-ingress). - :param Union[ChartOpts, LocalChartOpts] config: Configuration options for the Chart. - :param Optional[pulumi.ResourceOptions] opts: A bag of options that control this - resource's behavior. - """ - if not release_name: - raise TypeError('Missing release name argument') - if not isinstance(release_name, str): - raise TypeError('Expected release name to be a string') - if config and not isinstance(config, ChartOpts) and not isinstance(config, LocalChartOpts): - raise TypeError('Expected config to be a ChartOpts or LocalChartOpts instance') - if opts and not isinstance(opts, pulumi.ResourceOptions): - raise TypeError('Expected resource options to be a ResourceOptions instance') - - __props__ = dict() - - if config.resource_prefix: - release_name = f"{config.resource_prefix}-{release_name}" - - super(Chart, self).__init__( - "kubernetes:helm.sh/v2:Chart", - release_name, - __props__, - opts) - - all_config = pulumi.Output.from_input((release_name, config, pulumi.ResourceOptions(parent=self))) - - # Note: Unlike NodeJS, Python requires that we "pull" on our futures in order to get them scheduled for - # execution. In order to do this, we leverage the engine's RegisterResourceOutputs to wait for the - # resolution of all resources that this Helm chart created. - self.resources = all_config.apply(_parse_chart) - self.register_outputs({"resources": self.resources}) - self.ready = self.resources.apply(lambda x: list(x.values())) - - def get_resource(self, - group_version_kind: str, - name: str, - namespace: Optional[str] = None) -> pulumi.Output[pulumi.CustomResource]: - """ - get_resource returns a resource defined by a built-in Kubernetes group/version/kind and - name. For example: `get_resource("apps/v1/Deployment", "nginx")` - - :param str group_version_kind: Group/Version/Kind of the resource, e.g., `apps/v1/Deployment` - :param str name: Name of the resource to retrieve - :param Optional[str] namespace: Optional namespace of the resource to retrieve - """ - - # `id` will either be `${name}` or `${namespace}/${name}`. - id = pulumi.Output.from_input(name) - if namespace is not None: - id = pulumi.Output.concat(namespace, '/', name) - - resource_id = id.apply(lambda x: f'{group_version_kind}:{x}') - return resource_id.apply(lambda x: self.resources[x]) - - -class FetchOpts: - """ - FetchOpts is a bag of configuration options to customize the fetching of the Helm chart. - """ - - version: Optional[pulumi.Input[str]] - """ - Specific version of a chart. If unset, the latest version is fetched. - """ - - ca_file: Optional[pulumi.Input[str]] - """ - Verify certificates of HTTPS-enabled servers using this CA bundle. - """ - - cert_file: Optional[pulumi.Input[str]] - """ - Identify HTTPS client using this SSL certificate file. - """ - - key_file: Optional[pulumi.Input[str]] - """ - Identify HTTPS client using this SSL key file. - """ - - destination: Optional[pulumi.Input[str]] - """ - Location to write the chart. If this and [tardir] are specified, tardir is appended - to this (default "."). - """ - - keyring: Optional[pulumi.Input[str]] - """ - Keyring containing public keys (default "/Users/alex/.gnupg/pubring.gpg"). - """ - - password: Optional[pulumi.Input[str]] - """ - Chart repository password. - """ - - repo: Optional[pulumi.Input[str]] - """ - Chart repository url where to locate the requested chart. - """ - - untar_dir: Optional[pulumi.Input[str]] - """ - If [untar] is specified, this flag specifies the name of the directory into which - the chart is expanded (default "."). - """ - - username: Optional[pulumi.Input[str]] - """ - Chart repository username. - """ - - home: Optional[pulumi.Input[str]] - """ - Location of your Helm config. Overrides $HELM_HOME (default "/Users/alex/.helm"). - """ - - devel: Optional[pulumi.Input[bool]] - """ - Use development versions, too. Equivalent to version '>0.0.0-0'. If [version] is set, - this is ignored. - """ - - prov: Optional[pulumi.Input[bool]] - """ - Fetch the provenance file, but don't perform verification. - """ - - untar: Optional[pulumi.Input[bool]] - """ - If set to false, will leave the chart as a tarball after downloading. - """ - - verify: Optional[pulumi.Input[bool]] - """ - Verify the package against its signature. - """ - - def __init__(self, - version: Optional[pulumi.Input[str]] = None, - ca_file: Optional[pulumi.Input[str]] = None, - cert_file: Optional[pulumi.Input[str]] = None, - key_file: Optional[pulumi.Input[str]] = None, - destination: Optional[pulumi.Input[str]] = None, - keyring: Optional[pulumi.Input[str]] = None, - password: Optional[pulumi.Input[str]] = None, - repo: Optional[pulumi.Input[str]] = None, - untar_dir: Optional[pulumi.Input[str]] = None, - username: Optional[pulumi.Input[str]] = None, - home: Optional[pulumi.Input[str]] = None, - devel: Optional[pulumi.Input[bool]] = None, - prov: Optional[pulumi.Input[bool]] = None, - untar: Optional[pulumi.Input[bool]] = None, - verify: Optional[pulumi.Input[bool]] = None): - """ - :param Optional[pulumi.Input[str]] version: Specific version of a chart. If unset, - the latest version is fetched. - :param Optional[pulumi.Input[str]] ca_file: Verify certificates of HTTPS-enabled - servers using this CA bundle. - :param Optional[pulumi.Input[str]] cert_file: Identify HTTPS client using this SSL - certificate file. - :param Optional[pulumi.Input[str]] key_file: Identify HTTPS client using this SSL - key file. - :param Optional[pulumi.Input[str]] destination: Location to write the chart. - If this and [tardir] are specified, tardir is appended to this (default "."). - :param Optional[pulumi.Input[str]] keyring: Keyring containing public keys - (default "/Users//.gnupg/pubring.gpg"). - :param Optional[pulumi.Input[str]] password: Chart repository password. - :param Optional[pulumi.Input[str]] repo: Chart repository url where to locate - the requested chart. - :param Optional[pulumi.Input[str]] untar_dir: If [untar] is specified, this flag - specifies the name of the directory into which the chart is - expanded (default "."). - :param Optional[pulumi.Input[str]] username: Chart repository username. - :param Optional[pulumi.Input[str]] home: Location of your Helm config. Overrides - $HELM_HOME (default "/Users//.helm"). - :param Optional[pulumi.Input[bool]] devel: Use development versions, too. - Equivalent to version '>0.0.0-0'. If [version] is set, this is ignored. - :param Optional[pulumi.Input[bool]] prov: Fetch the provenance file, but don't - perform verification. - :param Optional[pulumi.Input[bool]] untar: If set to false, will leave the - chart as a tarball after downloading. - :param Optional[pulumi.Input[bool]] verify: Verify the package against its signature. - """ - self.version = version - self.ca_file = ca_file - self.cert_file = cert_file - self.key_file = key_file - self.destination = destination - self.keyring = keyring - self.password = password - self.repo = repo - self.untar_dir = untar_dir - self.username = username - self.home = home - self.devel = devel - self.prov = prov - self.untar = untar - self.verify = verify - - -class BaseChartOpts: - """ - BaseChartOpts is a bag of common configuration options for a Helm chart. - """ - - namespace: Optional[pulumi.Input[str]] - """ - Optional namespace to install chart resources into. - """ - - values: Optional[pulumi.Inputs] - """ - Optional overrides for chart values. - """ - - transformations: Optional[Sequence[Callable[[Any, pulumi.ResourceOptions], None]]] - """ - Optional list of transformations to apply to resources that will be created by this chart prior to - creation. Allows customization of the chart behaviour without directly modifying the chart itself. - """ - - resource_prefix: Optional[str] - """ - Optional prefix for the auto-generated resource names. - Example: A resource created with resource_prefix="foo" would produce a resource named "foo-resourceName". - """ - - api_versions: Optional[Sequence[pulumi.Input[str]]] - """ - Optional kubernetes api versions used for Capabilities.APIVersions. - """ - - 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): - """ - :param Optional[pulumi.Input[str]] namespace: Optional namespace to install chart resources into. - :param Optional[pulumi.Inputs] values: Optional overrides for chart values. - :param Optional[Sequence[Callable[[Any, pulumi.ResourceOptions], None]]] transformations: Optional list - of transformations to apply to resources that will be created by this chart prior to creation. - Allows customization of the chart behaviour without directly modifying the chart itself. - :param Optional[str] resource_prefix: An optional prefix for the auto-generated resource names. - Example: A resource created with resource_prefix="foo" would produce a resource named "foo-resourceName". - :param Optional[Sequence[pulumi.Input[str]]] api_versions: Optional kubernetes api versions used for - Capabilities.APIVersions. - """ - self.namespace = namespace - self.values = values - self.transformations = transformations - self.resource_prefix = resource_prefix - self.api_versions = api_versions - - -class ChartOpts(BaseChartOpts): - """ - ChartOpts is a bag of configuration options for a remote Helm chart. - """ - - chart: pulumi.Input[str] - """ - The name of the chart to deploy. If `repo` is provided, this chart name will be prefixed by the repo name. - Example: repo: "stable", chart: "nginx-ingress" -> "stable/nginx-ingress" - Example: chart: "stable/nginx-ingress" -> "stable/nginx-ingress" - """ - - repo: Optional[pulumi.Input[str]] - """ - The repository name of the chart to deploy. - Example: "stable" - """ - - version: Optional[pulumi.Input[str]] - """ - The version of the chart to deploy. If not provided, the latest version will be deployed. - """ - - fetch_opts: Optional[pulumi.Input[FetchOpts]] - """ - Additional options to customize the fetching of the Helm chart. - """ - - def __init__(self, - chart: pulumi.Input[str], - 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, - repo: Optional[pulumi.Input[str]] = None, - version: Optional[pulumi.Input[str]] = None, - fetch_opts: Optional[pulumi.Input[FetchOpts]] = None, - api_versions: Optional[Sequence[pulumi.Input[str]]] = 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. - Example: repo: "stable", chart: "nginx-ingress" -> "stable/nginx-ingress" - Example: chart: "stable/nginx-ingress" -> "stable/nginx-ingress" - :param Optional[pulumi.Input[str]] namespace: Optional namespace to install chart resources into. - :param Optional[pulumi.Inputs] values: Optional overrides for chart values. - :param Optional[Sequence[Callable[[Any, pulumi.ResourceOptions], None]]] transformations: Optional list of - transformations to apply to resources that will be created by this chart prior to creation. - Allows customization of the chart behaviour without directly modifying the chart itself. - :param Optional[str] resource_prefix: An optional prefix for the auto-generated resource names. - Example: A resource created with resource_prefix="foo" would produce a resource named "foo-resourceName". - :param Optional[pulumi.Input[str]] repo: The repository name of the chart to deploy. - Example: "stable" - :param Optional[pulumi.Input[str]] version: The version of the chart to deploy. If not provided, - the latest version will be deployed. - :param Optional[pulumi.Input[FetchOpts]] fetch_opts: Additional options to customize the - fetching of the Helm chart. - :param Optional[Sequence[pulumi.Input[str]]] api_versions: Optional kubernetes api versions used for - Capabilities.APIVersions. - """ - super(ChartOpts, self).__init__(namespace, values, transformations, resource_prefix, api_versions) - self.chart = chart - self.repo = repo - self.version = version - self.fetch_opts = fetch_opts - - -class LocalChartOpts(BaseChartOpts): - """ - LocalChartOpts is a bag of configuration options for a local Helm chart. - """ - - path: pulumi.Input[str] - """ - The path to the chart directory which contains the `Chart.yaml` file. - """ - - def __init__(self, - path: pulumi.Input[str], - 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): - """ - :param pulumi.Input[str] path: The path to the chart directory which contains the - `Chart.yaml` file. - :param Optional[pulumi.Input[str]] namespace: Optional namespace to install chart resources into. - :param Optional[pulumi.Inputs] values: Optional overrides for chart values. - :param Optional[Sequence[Callable[[Any, pulumi.ResourceOptions], None]]] transformations: Optional list of - transformations to apply to resources that will be created by this chart prior to creation. - Allows customization of the chart behaviour without directly modifying the chart itself. - :param Optional[str] resource_prefix: An optional prefix for the auto-generated resource names. - Example: A resource created with resource_prefix="foo" would produce a resource named "foo-resourceName". - :param Optional[Sequence[pulumi.Input[str]]] api_versions: Optional kubernetes api versions used for - Capabilities.APIVersions. - """ - - super(LocalChartOpts, self).__init__(namespace, values, transformations, resource_prefix, api_versions) - self.path = path - - -def _run_helm_cmd(all_config: Tuple[Sequence[Union[str, bytes]], Any]) -> str: - cmd, _ = all_config - - output = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True, check=True) - yaml_str: str = output.stdout - return yaml_str - - -def _is_helm_v3() -> bool: - cmd: Sequence[str] = ['helm', 'version', '--short'] - - """ - Helm v2 returns version like this: - Client: v2.16.7+g5f2584f - Helm v3 returns a version like this: - v3.1.2+gd878d4d - --include-crds is available in helm v3.1+ so check for a regex matching that version - """ - output = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, universal_newlines=True, check=True) - version: str = output.stdout - regexp = re.compile(r'^v3\.[1-9]') - return bool(regexp.search(version)) - - -def _write_override_file(all_config: Tuple[TextIO, str]) -> None: - file, data = all_config - - file.write(data) - file.flush() - - -def _cleanup_temp_dir(all_config: Tuple[TextIO, Union[bytes, str], Any]) -> None: - file, chart_dir, _ = all_config - - file.close() - shutil.rmtree(chart_dir) - - -def _parse_chart(all_config: Tuple[str, Union[ChartOpts, LocalChartOpts], pulumi.ResourceOptions]) -> pulumi.Output: - release_name, config, opts = all_config - - # Create temporary directory and file to hold chart data and override values. - # Note: We're intentionally using the lower-level APIs here because the async Outputs are being handled in - # a different scope, which was causing the temporary files/directory to be deleted before they were referenced - # in the Output handlers. We manually clean these up once we're done with another async handler that depends - # on the result of the operations. - overrides, overrides_filename = mkstemp() - chart_dir = mkdtemp() - - if isinstance(config, ChartOpts): - if config.repo and 'http' in config.repo: - raise ValueError('`repo` specifies the name of the Helm chart repo.' - 'Use `fetch_opts.repo` to specify a URL.') - chart_to_fetch = f'{config.repo}/{config.chart}' if config.repo else config.chart - - # Configure fetch options. - fetch_opts_dict = {} - if config.fetch_opts is not None: - fetch_opts_dict = {k: v for k, v in vars(config.fetch_opts).items() if v is not None} - fetch_opts_dict["destination"] = chart_dir - if config.version is not None: - fetch_opts_dict["version"] = config.version - fetch_opts = FetchOpts(**fetch_opts_dict) - - # Fetch the chart. - _fetch(chart_to_fetch, fetch_opts) - # Sort the directories into alphabetical order, and choose the first - fetched_chart_name = sorted(os.listdir(chart_dir), key=str.lower)[0] - chart = os.path.join(chart_dir, fetched_chart_name) - else: - chart = config.path - - default_values = os.path.join(chart, 'values.yaml') - - # Write overrides file. - vals = config.values if config.values is not None else {} - data = pulumi.Output.from_input(vals).apply(lambda x: json.dumps(x)) - file = open(overrides, 'w') - pulumi.Output.all(file, data).apply(_write_override_file) - - apiversions_arg = [f'--api-versions={version}' for version in config.api_versions] if config.api_versions else [] - namespace_arg = ['--namespace', config.namespace] if config.namespace else [] - crd_arg = ['--include-crds'] if _is_helm_v3() else [] - - # Use 'helm template' to create a combined YAML manifest. - cmd = ['helm', 'template', chart, '--name-template', release_name, - '--values', default_values, '--values', overrides_filename] - cmd.extend(apiversions_arg) - cmd.extend(namespace_arg) - cmd.extend(crd_arg) - - chart_resources = pulumi.Output.all(cmd, data).apply(_run_helm_cmd) - - # Rather than using the default provider for the following invoke call, use the version specified - # in package.json. - invoke_opts = pulumi.InvokeOptions(version=_utilities.get_version()) - - objects = chart_resources.apply( - lambda text: pulumi.runtime.invoke('kubernetes:yaml:decode', { - 'text': text, 'defaultNamespace': config.namespace}, invoke_opts).value['result']) - - # Parse the manifest and create the specified resources. - resources = objects.apply( - lambda objects: _parse_yaml_document(objects, opts, config.transformations)) - - pulumi.Output.all(file, chart_dir, resources).apply(_cleanup_temp_dir) - return resources - - -def _fetch(chart: str, opts: FetchOpts) -> None: - cmd: Sequence[str] = ['helm', 'fetch', chart] - - # Untar by default. - if opts.untar is not False: - cmd.append('--untar') - - env = os.environ - # Helm v3 removed the `--home` flag, so we must use an env var instead. - if opts.home: - env['HELM_HOME'] = opts.home - - if opts.version: - cmd.extend(['--version', opts.version]) - if opts.ca_file: - cmd.extend(['--ca-file', opts.ca_file]) - if opts.cert_file: - cmd.extend(['--cert-file', opts.cert_file]) - if opts.key_file: - cmd.extend(['--key-file', opts.key_file]) - if opts.destination: - cmd.extend(['--destination', opts.destination]) - if opts.keyring: - cmd.extend(['--keyring', opts.keyring]) - if opts.password: - cmd.extend(['--password', opts.password]) - if opts.repo: - cmd.extend(['--repo', opts.repo]) - if opts.untar_dir: - cmd.extend(['--untardir', opts.untar_dir]) - if opts.username: - cmd.extend(['--username', opts.username]) - if opts.devel: - cmd.append('--devel') - if opts.prov: - cmd.append('--prov') - if opts.verify: - cmd.append('--verify') - - subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True, check=True, env=env) diff --git a/sdk/dotnet/Helm/V2/Chart.cs b/sdk/dotnet/Helm/V2/Chart.cs deleted file mode 100644 index 3605a619dd..0000000000 --- a/sdk/dotnet/Helm/V2/Chart.cs +++ /dev/null @@ -1,237 +0,0 @@ -// Copyright 2016-2020, Pulumi Corporation. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// *** WARNING: this file was generated by pulumigen. *** -// *** Do not edit by hand unless you're certain you know what you are doing! *** - -using System; - -namespace Pulumi.Kubernetes.Helm.V2 -{ - /// - /// Chart is a component representing a collection of resources described by an arbitrary Helm - /// Chart. The Chart can be fetched from any source that is accessible to the `helm` command - /// line. Values in the `values.yml` file can be overridden using - /// (equivalent to `--set` or having multiple - /// `values.yml` files). Objects can be transformed arbitrarily by supplying callbacks to - /// . - /// - /// does not use Tiller. The Chart specified is copied and expanded locally; - /// the semantics are equivalent to running `helm template` and then using Pulumi to manage the - /// resulting YAML manifests. Any values that would be retrieved in-cluster are assigned fake - /// values, and none of Tiller's server-side validity testing is executed. - /// - /// ## Example Usage - /// ### Local Chart Directory - /// - /// ```csharp - /// using System.Threading.Tasks; - /// using Pulumi; - /// using Pulumi.Kubernetes.Helm; - /// using Pulumi.Kubernetes.Helm.V2; - /// - /// class HelmStack : Stack - /// { - /// public HelmStack() - /// { - /// var nginx = new Chart("nginx-ingress", new LocalChartArgs - /// { - /// Path = "./nginx-ingress", - /// }); - /// - /// } - /// } - /// ``` - /// ### Remote Chart - /// - /// ```csharp - /// using System.Threading.Tasks; - /// using Pulumi; - /// using Pulumi.Kubernetes.Helm; - /// using Pulumi.Kubernetes.Helm.V2; - /// - /// class HelmStack : Stack - /// { - /// public HelmStack() - /// { - /// var nginx = new Chart("nginx-ingress", new ChartArgs - /// { - /// Chart = "nginx-ingress", - /// Version = "1.24.4", - /// FetchOptions = new ChartFetchArgs - /// { - /// Repo = "https://kubernetes-charts.storage.googleapis.com/" - /// } - /// }); - /// - /// } - /// } - /// ``` - /// ### Set Chart Values - /// - /// ```csharp - /// using System.Collections.Generic; - /// using System.Threading.Tasks; - /// using Pulumi; - /// using Pulumi.Kubernetes.Helm; - /// using Pulumi.Kubernetes.Helm.V2; - /// - /// class HelmStack : Stack - /// { - /// public HelmStack() - /// { - /// var values = new Dictionary<string, object> - /// { - /// ["controller"] = new Dictionary<string, object> - /// { - /// ["metrics"] = new Dictionary<string, object> - /// { - /// ["enabled"] = true - /// } - /// }, - /// }; - /// - /// var nginx = new Chart("nginx-ingress", new ChartArgs - /// { - /// Chart = "nginx-ingress", - /// Version = "1.24.4", - /// FetchOptions = new ChartFetchArgs - /// { - /// Repo = "https://kubernetes-charts.storage.googleapis.com/" - /// }, - /// Values = values, - /// }); - /// - /// } - /// } - /// ``` - /// ### Deploy Chart into Namespace - /// - /// ```csharp - /// using System.Threading.Tasks; - /// using Pulumi; - /// using Pulumi.Kubernetes.Helm; - /// using Pulumi.Kubernetes.Helm.V2; - /// - /// class HelmStack : Stack - /// { - /// public HelmStack() - /// { - /// var nginx = new Chart("nginx-ingress", new ChartArgs - /// { - /// Chart = "nginx-ingress", - /// Version = "1.24.4", - /// Namespace = "test-namespace", - /// FetchOptions = new ChartFetchArgs - /// { - /// Repo = "https://kubernetes-charts.storage.googleapis.com/" - /// }, - /// }); - /// - /// } - /// } - /// ``` - /// ### Chart with Transformations - /// - /// ```csharp - /// using System.Collections.Generic; - /// using System.Collections.Immutable; - /// using System.Threading.Tasks; - /// using Pulumi; - /// using Pulumi.Kubernetes.Helm; - /// using Pulumi.Kubernetes.Helm.V2; - /// - /// class HelmStack : Stack - /// { - /// public HelmStack() - /// { - /// var nginx = new Chart("nginx-ingress", new ChartArgs - /// { - /// Chart = "nginx-ingress", - /// Version = "1.24.4", - /// FetchOptions = new ChartFetchArgs - /// { - /// Repo = "https://kubernetes-charts.storage.googleapis.com/" - /// }, - /// Transformations = - /// { - /// LoadBalancerToClusterIP, - /// ResourceAlias, - /// OmitTestPod, - /// } - /// - /// }); - /// - /// // Make every service private to the cluster, i.e., turn all services into ClusterIP instead of LoadBalancer. - /// ImmutableDictionary<string, object> LoadBalancerToClusterIP(ImmutableDictionary<string, object> obj, CustomResourceOptions opts) - /// { - /// if ((string)obj["kind"] == "Service" && (string)obj["apiVersion"] == "v1") - /// { - /// var spec = (ImmutableDictionary<string, object>)obj["spec"]; - /// if (spec != null && (string)spec["type"] == "LoadBalancer") - /// { - /// return obj.SetItem("spec", spec.SetItem("type", "ClusterIP")); - /// } - /// } - /// - /// return obj; - /// } - /// - /// // Set a resource alias for a previous name. - /// ImmutableDictionary<string, object> ResourceAlias(ImmutableDictionary<string, object> obj, CustomResourceOptions opts) - /// { - /// if ((string)obj["kind"] == "Deployment") - /// { - /// opts.Aliases.Add(new Alias { Name = "oldName" }); - /// } - /// - /// return obj; - /// } - /// - /// // Omit a resource from the Chart by transforming the specified resource definition to an empty List. - /// ImmutableDictionary<string, object> OmitTestPod(ImmutableDictionary<string, object> obj, CustomResourceOptions opts) - /// { - /// var metadata = (ImmutableDictionary<string, object>)obj["metadata"]; - /// if ((string)obj["kind"] == "Pod" && (string)metadata["name"] == "test") - /// { - /// return new Dictionary<string, object> - /// { - /// ["apiVersion"] = "v1", - /// ["kind"] = "List", - /// ["items"] = new Dictionary<string, object>(), - /// }.ToImmutableDictionary(); - /// } - /// - /// return obj; - /// } - /// } - /// } - /// ``` - /// - [Obsolete(@"helm/v2/Chart is deprecated by helm/v3/Chart and will be removed in a future release.")] - public sealed class Chart : ChartBase - { - /// - /// Create a Chart resource with the given unique name, arguments, and options. - /// - /// - /// The unique name of the resource - /// The arguments used to populate this resource's properties - /// A bag of options that control this resource's behavior - public Chart(string releaseName, Union args, ComponentResourceOptions? options = null) - : base(releaseName, args, options) - { - } - } -} diff --git a/sdk/go/kubernetes/helm/v2/chart.go b/sdk/go/kubernetes/helm/v2/chart.go deleted file mode 100644 index fb4ad57d2e..0000000000 --- a/sdk/go/kubernetes/helm/v2/chart.go +++ /dev/null @@ -1,527 +0,0 @@ -// Copyright 2016-2021, Pulumi Corporation. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// *** WARNING: this file was generated by pulumigen. *** -// *** Do not edit by hand unless you're certain you know what you are doing! *** - -package helm - -import ( - "bytes" - "encoding/json" - "fmt" - "io/ioutil" - "os" - "os/exec" - "path/filepath" - "regexp" - "sort" - "strings" - - "github.com/pkg/errors" - "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/yaml" - "github.com/pulumi/pulumi/sdk/v3/go/pulumi" -) - -// Chart is a component representing a collection of resources described by an arbitrary Helm -// Chart. The Chart can be fetched from any source that is accessible to the `helm` command -// line. Values in the `values.yml` file can be overridden using `ChartOpts.values` (equivalent -// to `--set` or having multiple `values.yml` files). Objects can be transformed arbitrarily by -// supplying callbacks to `ChartOpts.transformations`. -// -// `Chart` does not use Tiller. The Chart specified is copied and expanded locally; the semantics -// are equivalent to running `helm template` and then using Pulumi to manage the resulting YAML -// manifests. Any values that would be retrieved in-cluster are assigned fake values, and -// none of Tiller's server-side validity testing is executed. -// -// ## Example Usage -// ### Local Chart Directory -// -// ```go -// package main -// -// import ( -// -// "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/helm/v3" -// "github.com/pulumi/pulumi/sdk/v3/go/pulumi" -// -// ) -// -// func main() { -// pulumi.Run(func(ctx *pulumi.Context) error { -// _, err := helm.NewChart(ctx, "nginx-ingress", helm.ChartArgs{ -// Path: pulumi.String("./nginx-ingress"), -// }) -// if err != nil { -// return err -// } -// -// return nil -// }) -// } -// -// ``` -// ### Remote Chart -// -// ```go -// package main -// -// import ( -// -// "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/helm/v3" -// "github.com/pulumi/pulumi/sdk/v3/go/pulumi" -// -// ) -// -// func main() { -// pulumi.Run(func(ctx *pulumi.Context) error { -// _, err := helm.NewChart(ctx, "nginx-ingress", helm.ChartArgs{ -// Chart: pulumi.String("nginx-ingress"), -// Version: pulumi.String("1.24.4"), -// FetchArgs: helm.FetchArgs{ -// Repo: pulumi.String("https://charts.helm.sh/stable"), -// }, -// }) -// if err != nil { -// return err -// } -// -// return nil -// }) -// } -// -// ``` -// ### Set Chart values -// -// ```go -// package main -// -// import ( -// -// "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/helm/v3" -// "github.com/pulumi/pulumi/sdk/v3/go/pulumi" -// -// ) -// -// func main() { -// pulumi.Run(func(ctx *pulumi.Context) error { -// _, err := helm.NewChart(ctx, "nginx-ingress", helm.ChartArgs{ -// Chart: pulumi.String("nginx-ingress"), -// Version: pulumi.String("1.24.4"), -// FetchArgs: helm.FetchArgs{ -// Repo: pulumi.String("https://charts.helm.sh/stable"), -// }, -// Values: pulumi.Map{ -// "controller": pulumi.Map{ -// "metrics": pulumi.Map{ -// "enabled": pulumi.Bool(true), -// }, -// }, -// }, -// }) -// if err != nil { -// return err -// } -// -// return nil -// }) -// } -// -// ``` -// ### Deploy Chart into Namespace -// -// ```go -// package main -// -// import ( -// -// "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/helm/v3" -// "github.com/pulumi/pulumi/sdk/v3/go/pulumi" -// -// ) -// -// func main() { -// pulumi.Run(func(ctx *pulumi.Context) error { -// _, err := helm.NewChart(ctx, "nginx-ingress", helm.ChartArgs{ -// Chart: pulumi.String("nginx-ingress"), -// Version: pulumi.String("1.24.4"), -// Namespace: pulumi.String("test-namespace"), -// FetchArgs: helm.FetchArgs{ -// Repo: pulumi.String("https://charts.helm.sh/stable"), -// }, -// }) -// if err != nil { -// return err -// } -// -// return nil -// }) -// } -// -// ``` -// ### Chart with Transformations -// -// ```go -// package main -// -// import ( -// -// "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/helm/v3" -// "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/yaml" -// "github.com/pulumi/pulumi/sdk/v3/go/pulumi" -// -// ) -// -// func main() { -// pulumi.Run(func(ctx *pulumi.Context) error { -// _, err := helm.NewChart(ctx, "nginx-ingress", helm.ChartArgs{ -// Chart: pulumi.String("nginx-ingress"), -// Version: pulumi.String("1.24.4"), -// FetchArgs: helm.FetchArgs{ -// Repo: pulumi.String("https://charts.helm.sh/stable"), -// }, -// Transformations: []yaml.Transformation{ -// // Make every service private to the cluster, i.e., turn all services into ClusterIP -// // instead of LoadBalancer. -// func(state map[string]interface{}, opts ...pulumi.ResourceOption) { -// if state["kind"] == "Service" { -// spec := state["spec"].(map[string]interface{}) -// spec["type"] = "ClusterIP" -// } -// }, -// -// // Set a resource alias for a previous name. -// func(state map[string]interface{}, opts ...pulumi.ResourceOption) { -// if state["kind"] == "Deployment" { -// aliases := pulumi.Aliases([]pulumi.Alias{ -// { -// Name: pulumi.String("oldName"), -// }, -// }) -// opts = append(opts, aliases) -// } -// }, -// -// // Omit a resource from the Chart by transforming the specified resource definition -// // to an empty List. -// func(state map[string]interface{}, opts ...pulumi.ResourceOption) { -// name := state["metadata"].(map[string]interface{})["name"] -// if state["kind"] == "Pod" && name == "test" { -// state["apiVersion"] = "core/v1" -// state["kind"] = "List" -// } -// }, -// }, -// }) -// if err != nil { -// return err -// } -// -// return nil -// }) -// } -// -// ``` -// Deprecated: helm/v2/Chart is deprecated by helm/v3/Chart and will be removed in a future release. -type Chart struct { - pulumi.ResourceState - - Ready pulumi.ResourceArrayOutput - Resources pulumi.Output -} - -// NewChart registers a new resource with the given unique name, arguments, and options. -// Deprecated: helm/v2/Chart is deprecated by helm/v3/Chart and will be removed in a future release. -func NewChart(ctx *pulumi.Context, - name string, args ChartArgs, opts ...pulumi.ResourceOption) (*Chart, error) { - - // Register the resulting resource state. - chart := &Chart{} - err := ctx.RegisterComponentResource("kubernetes:helm.sh/v2:Chart", name, chart, opts...) - if err != nil { - return nil, err - } - - // Honor the resource name prefix if specified. - if args.ResourcePrefix != "" { - name = args.ResourcePrefix + "-" + name - } - - resources := args.ToChartArgsOutput().ApplyT(func(args chartArgs) (map[string]pulumi.Resource, error) { - return parseChart(ctx, name, args, pulumi.Parent(chart)) - }) - chart.Resources = resources - - // Finally, register all of the resources found. - // Note: Go requires that we "pull" on our futures in order to get them scheduled for execution. Here, we use - // the engine's RegisterResourceOutputs to wait for the resolution of all resources that this Helm chart created. - err = ctx.RegisterResourceOutputs(chart, pulumi.Map{"resources": resources}) - if err != nil { - return nil, errors.Wrap(err, "registering child resources") - } - - chart.Ready = resources.ApplyT(func(x interface{}) []pulumi.Resource { - resources := x.(map[string]pulumi.Resource) - var outputs []pulumi.Resource - for _, r := range resources { - outputs = append(outputs, r) - } - return outputs - }).(pulumi.ResourceArrayOutput) - - return chart, nil -} - -func parseChart(ctx *pulumi.Context, name string, args chartArgs, opts ...pulumi.ResourceOption, -) (map[string]pulumi.Resource, error) { - - // Create temporary directory and file to hold chart data and override values. - chartDir, err := ioutil.TempDir("", "") - if err != nil { - return nil, errors.Wrap(err, "creating temp directory for chart") - } - defer os.RemoveAll(chartDir) - overrides, err := ioutil.TempFile("", "values.*.yaml") - if err != nil { - return nil, errors.Wrap(err, "creating temp file for chart values") - } - defer os.Remove(overrides.Name()) - - var chart string - if args.Path != "" { // Local Chart - chart = args.Path - } else { // Remote Chart - if strings.HasPrefix(args.Repo, "http") { - return nil, fmt.Errorf("`repo` specifies the name of the Helm chart repo. Use FetchArgs.Repo" + - "to specify a URL") - } - - chartToFetch := args.Chart - if len(args.Repo) > 0 { - chartToFetch = fmt.Sprintf("%s/%s", args.Repo, chartToFetch) - } - - // Fetch the Chart. - if len(args.FetchArgs.Destination) == 0 { - args.FetchArgs.Destination = chartDir - } - if len(args.FetchArgs.Version) == 0 { - args.FetchArgs.Version = args.Version - } - err = fetch(chartToFetch, args.FetchArgs) - if err != nil { - return nil, err - } - - // Get the path to the fetched Chart. - files, err := ioutil.ReadDir(chartDir) - if err != nil { - return nil, errors.Wrap(err, "failed to read chart directory") - } - if len(files) == 0 { - return nil, errors.New("chart directory was empty") - } - sort.Slice(files, func(i, j int) bool { - return files[i].Name() < files[j].Name() - }) - fetchedChartName := files[0].Name() - - chart = filepath.Join(chartDir, fetchedChartName) - } - - defaultVals := filepath.Join(chart, "values.yaml") - - helmArgs := []string{"template", chart, "--name-template", name, "--values", defaultVals} - // Write overrides file if Values set. - if args.Values != nil { - b, err := json.Marshal(args.Values) - if err != nil { - return nil, errors.Wrap(err, "failed to marshal overrides file") - } - _, err = overrides.Write(b) - if err != nil { - return nil, errors.Wrap(err, "failed to write overrides file") - } - helmArgs = append(helmArgs, "--values", overrides.Name()) - } - if len(args.Namespace) > 0 { - helmArgs = append(helmArgs, "--namespace", args.Namespace) - } - - for _, version := range args.APIVersions { - helmArgs = append(helmArgs, fmt.Sprintf("--api-versions=%s", version)) - } - - // Check for helm version - v3, err := isHelmV3() - - if err != nil { - return nil, err - } - - if v3 { - helmArgs = append(helmArgs, "--include-crds") - } - - helmCmd := exec.Command("helm", helmArgs...) - var stderr bytes.Buffer - helmCmd.Stderr = &stderr - yamlBytes, err := helmCmd.Output() - if err != nil { - return nil, errors.Wrap(err, fmt.Sprintf("failed to run helm template: %s", stderr.String())) - } - objs, err := yamlDecode(ctx, string(yamlBytes), args.Namespace) - if err != nil { - return nil, err - } - - resources, err := yaml.ParseYamlObjects(ctx, objs, args.Transformations, args.ResourcePrefix, opts...) - if err != nil { - return nil, err - } - return resources, nil -} - -// yamlDecode invokes the function to decode a single YAML file and decompose it into object structures. -func yamlDecode(ctx *pulumi.Context, text, namespace string) ([]map[string]interface{}, error) { - args := struct { - Text string `pulumi:"text"` - DefaultNamespace string `pulumi:"defaultNamespace"` - }{Text: text, DefaultNamespace: namespace} - var ret struct { - Result []map[string]interface{} `pulumi:"result"` - } - if err := ctx.Invoke("kubernetes:yaml:decode", &args, &ret); err != nil { - return nil, errors.Wrap(err, "failed to decode YAML") - } - return ret.Result, nil -} - -func isHelmV3() (bool, error) { - - /* - Helm v2 returns version like this: - Client: v2.16.7+g5f2584f - Helm v3 returns a version like this: - v3.1.2+gd878d4d - --include-crds is available in helm v3.1+ so check for a regex matching that version - */ - helmVerArgs := []string{"version", "--short"} - helmVerCmd := exec.Command("helm", helmVerArgs...) - - var stderr bytes.Buffer - helmVerCmd.Stderr = &stderr - - version, err := helmVerCmd.Output() - if err != nil { - return false, errors.Wrap(err, fmt.Sprintf("failed to check helm version: %s", stderr.String())) - } - - matched, err := regexp.MatchString(`^v3\.[1-9]`, string(version)) - if err != nil { - return false, errors.Wrap(err, fmt.Sprintf("failed to perform regex match: %s", stderr.String())) - } - - return matched, nil - -} - -func fetch(name string, args fetchArgs) error { - helmArgs := []string{"fetch", name} - - // Untar by default. - if args.Untar == nil || !*args.Untar { - helmArgs = append(helmArgs, "--untar") - } - - env := os.Environ() - // Helm v3 removed the `--home` flag, so we must use an env var instead. - if len(args.Home) > 0 { - found := false - for i, v := range env { - if strings.HasPrefix(v, "HELM_HOME=") { - env[i] = fmt.Sprintf("HELM_HOME=%s", args.Home) - found = true - break - } - } - if !found { - env = append(env, fmt.Sprintf("HELM_HOME=%s", args.Home)) - } - } - - if len(args.Version) > 0 { - helmArgs = append(helmArgs, "--version", args.Version) - } - if len(args.CAFile) > 0 { - helmArgs = append(helmArgs, "--ca-file", args.CAFile) - } - if len(args.CertFile) > 0 { - helmArgs = append(helmArgs, "--cert-file", args.CertFile) - } - if len(args.KeyFile) > 0 { - helmArgs = append(helmArgs, "--key-file", args.KeyFile) - } - if len(args.Destination) > 0 { - helmArgs = append(helmArgs, "--destination", args.Destination) - } - if len(args.Keyring) > 0 { - helmArgs = append(helmArgs, "--keyring", args.Keyring) - } - if len(args.Password) > 0 { - helmArgs = append(helmArgs, "--password", args.Password) - } - if len(args.Repo) > 0 { - helmArgs = append(helmArgs, "--repo", args.Repo) - } - if len(args.UntarDir) > 0 { - helmArgs = append(helmArgs, "--untardir", args.UntarDir) - } - if len(args.Username) > 0 { - helmArgs = append(helmArgs, "--username", args.Username) - } - if args.Devel != nil && *args.Devel { - helmArgs = append(helmArgs, "--devel") - } - if args.Prov != nil && *args.Prov { - helmArgs = append(helmArgs, "--prov") - } - if args.Verify != nil && *args.Verify { - helmArgs = append(helmArgs, "--verify") - } - - helmCmd := exec.Command("helm", helmArgs...) - var stderr bytes.Buffer - helmCmd.Stderr = &stderr - err := helmCmd.Run() - if err != nil { - return errors.Wrap(err, fmt.Sprintf("failed to fetch Helm chart: %s", stderr.String())) - } - - return nil -} - -// GetResource returns a resource defined by a built-in Kubernetes group/version/kind, name and namespace. -// For example, GetResource("v1/Pod", "foo", "") would return a Pod called "foo" from the "default" namespace. -func (c *Chart) GetResource(gvk, name, namespace string) pulumi.AnyOutput { - id := name - if len(namespace) > 0 && namespace != "default" { - id = fmt.Sprintf("%s/%s", namespace, name) - } - key := fmt.Sprintf("%s::%s", gvk, id) - return c.Resources.ApplyT(func(x interface{}) interface{} { - resources := x.(map[string]pulumi.Resource) - return resources[key] - }).(pulumi.AnyOutput) -} diff --git a/sdk/go/kubernetes/helm/v2/pulumiTypes.go b/sdk/go/kubernetes/helm/v2/pulumiTypes.go deleted file mode 100644 index c8094ce96b..0000000000 --- a/sdk/go/kubernetes/helm/v2/pulumiTypes.go +++ /dev/null @@ -1,198 +0,0 @@ -// Copyright 2016-2020, Pulumi Corporation. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// *** WARNING: this file was generated by pulumigen. *** -// *** Do not edit by hand unless you're certain you know what you are doing! *** - -package helm - -import ( - "context" - "reflect" - - "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/yaml" - "github.com/pulumi/pulumi/sdk/v3/go/pulumi" -) - -// FetchArgs specifies arguments for fetching the Helm chart. -type FetchArgs struct { - // Specific version of a chart. If unset, the latest version is fetched. - Version pulumi.StringInput - // Verify certificates of HTTPS-enabled servers using this CA bundle. - CAFile pulumi.StringInput - // Identify HTTPS client using this SSL certificate file. - CertFile pulumi.StringInput - // Identify HTTPS client using this SSL key file. - KeyFile pulumi.StringInput - // Location to write the chart. If Destination and UntarDir are specified, UntarDir is - // appended to Destination (default "."). - Destination pulumi.StringInput - // Keyring containing public keys (default "~/.gnupg/pubring.gpg"). - Keyring pulumi.StringInput - // Chart repository password. - Password pulumi.StringInput - // Chart repository URL for the requested chart. - Repo pulumi.StringInput - // Location to expand the chart. (default "."). - UntarDir pulumi.StringInput - // Chart repository username. - Username pulumi.StringInput - // Location of your Helm config. Overrides $HELM_HOME (default "~/.helm"). - Home pulumi.StringInput - // Use development versions, too. Equivalent to version '>0.0.0-0'. If Version is set, - // Devel is ignored. - Devel pulumi.BoolPtrInput - // Fetch the provenance file, but don't perform verification. - Prov pulumi.BoolPtrInput - // If false, leave the chart as a tarball after downloading. - Untar pulumi.BoolPtrInput - // Verify the package against its signature. - Verify pulumi.BoolPtrInput -} - -// fetchArgs is a copy of FetchArgs but without using TInput in types. -type fetchArgs struct { - Version string `pulumi:"version"` - CAFile string `pulumi:"caFile"` - CertFile string `pulumi:"certFile"` - KeyFile string `pulumi:"keyFile"` - Destination string `pulumi:"destination"` - Keyring string `pulumi:"keyring"` - Password string `pulumi:"password"` - Repo string `pulumi:"repo"` - UntarDir string `pulumi:"untarDir"` - Username string `pulumi:"username"` - Home string `pulumi:"home"` - Devel *bool `pulumi:"devel"` - Prov *bool `pulumi:"prov"` - Untar *bool `pulumi:"untar"` - Verify *bool `pulumi:"verify"` -} - -type FetchArgsInput interface { - pulumi.Input - - ToFetchArgsOutput() FetchArgsOutput - ToFetchArgsOutputWithContext(context.Context) FetchArgsOutput -} - -func (FetchArgs) ElementType() reflect.Type { - return reflect.TypeOf((*fetchArgs)(nil)).Elem() -} - -func (i FetchArgs) ToFetchArgsOutput() FetchArgsOutput { - return i.ToFetchArgsOutputWithContext(context.Background()) -} - -func (i FetchArgs) ToFetchArgsOutputWithContext(ctx context.Context) FetchArgsOutput { - return pulumi.ToOutputWithContext(ctx, i).(FetchArgsOutput) -} - -type FetchArgsOutput struct{ *pulumi.OutputState } - -func (FetchArgsOutput) ElementType() reflect.Type { - return reflect.TypeOf((*fetchArgs)(nil)).Elem() -} - -func (o FetchArgsOutput) ToFetchArgsOutput() FetchArgsOutput { - return o -} - -func (o FetchArgsOutput) ToFetchArgsOutputWithContext(ctx context.Context) FetchArgsOutput { - return o -} - -// ChartArgs specifies arguments for constructing a Chart resource. -type ChartArgs struct { - // The optional Kubernetes API versions used for Capabilities.APIVersions. - APIVersions pulumi.StringArrayInput - // The optional namespace to install chart resources into. - Namespace pulumi.StringInput - // Overrides for chart values. - Values pulumi.MapInput - // Transformations is an optional list of transformations to apply to Kubernetes resource definitions - // before registering with the engine. - Transformations []yaml.Transformation - // ResourcePrefix is an optional prefix for the auto-generated resource names. For example, a resource named `bar` - // created with resource prefix of `"foo"` would produce a resource named `"foo-bar"`. - ResourcePrefix string - - // (Remote chart) The repository name of the chart to deploy. Example: "stable". - Repo pulumi.StringInput - // (Remote chart) The name of the chart to deploy. If Repo is specified, this chart name will be prefixed - // by the repo name. - // Example: Repo: "stable", Chart: "nginx-ingress" -> "stable/nginx-ingress" - // Example: Chart: "stable/nginx-ingress" -> "stable/nginx-ingress" - Chart pulumi.StringInput - // (Remote chart) The version of the chart to deploy. If not provided, the latest version will be deployed. - Version pulumi.StringInput - // (Remote chart) Additional options to customize the fetching of the Helm chart. - FetchArgs FetchArgsInput - - // (Local chart) The path to the chart directory which contains the `Chart.yaml` file. - // If Path is set, any remote chart args (Repo, Chart, Version, FetchArgs) will be ignored. - Path pulumi.StringInput -} - -// chartArgs is a copy of ChartArgs but without using TInput in types. -type chartArgs struct { - APIVersions []string `pulumi:"apiVersions"` - Namespace string `pulumi:"namespace"` - Values map[string]interface{} `pulumi:"values"` - Transformations []yaml.Transformation `pulumi:"transformations"` - ResourcePrefix string `pulumi:"resourcePrefix"` - Repo string `pulumi:"repo"` - Chart string `pulumi:"chart"` - Version string `pulumi:"version"` - FetchArgs fetchArgs `pulumi:"fetchArgs"` - Path string `pulumi:"path"` -} - -type ChartArgsInput interface { - pulumi.Input - - ToChartArgsOutput() ChartArgsOutput - ToChartArgsOutputWithContext(context.Context) ChartArgsOutput -} - -func (ChartArgs) ElementType() reflect.Type { - return reflect.TypeOf((*chartArgs)(nil)).Elem() -} - -func (i ChartArgs) ToChartArgsOutput() ChartArgsOutput { - return i.ToChartArgsOutputWithContext(context.Background()) -} - -func (i ChartArgs) ToChartArgsOutputWithContext(ctx context.Context) ChartArgsOutput { - return pulumi.ToOutputWithContext(ctx, i).(ChartArgsOutput) -} - -type ChartArgsOutput struct{ *pulumi.OutputState } - -func (ChartArgsOutput) ElementType() reflect.Type { - return reflect.TypeOf((*chartArgs)(nil)).Elem() -} - -func (o ChartArgsOutput) ToChartArgsOutput() ChartArgsOutput { - return o -} - -func (o ChartArgsOutput) ToChartArgsOutputWithContext(ctx context.Context) ChartArgsOutput { - return o -} - -func init() { - pulumi.RegisterOutputType(FetchArgsOutput{}) - pulumi.RegisterOutputType(ChartArgsOutput{}) -} diff --git a/sdk/nodejs/helm/index.ts b/sdk/nodejs/helm/index.ts index 04e0d923b5..9fa93a9b6f 100644 --- a/sdk/nodejs/helm/index.ts +++ b/sdk/nodejs/helm/index.ts @@ -4,10 +4,8 @@ import * as utilities from "../utilities"; // Export sub-modules: -import * as v2 from "./v2"; import * as v3 from "./v3"; export { - v2, v3, }; diff --git a/sdk/nodejs/helm/v2/helm.ts b/sdk/nodejs/helm/v2/helm.ts deleted file mode 100644 index d59b66ecad..0000000000 --- a/sdk/nodejs/helm/v2/helm.ts +++ /dev/null @@ -1,483 +0,0 @@ -// Copyright 2016-2020, Pulumi Corporation. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// *** WARNING: this file was generated by the pulumigen. *** -// *** Do not edit by hand unless you're certain you know what you are doing! *** - -import * as pulumi from "@pulumi/pulumi"; -import { execSync } from "child_process"; -import * as fs from "fs"; -import * as nodepath from "path"; -import * as shell from "shell-quote"; -import * as tmp from "tmp"; -import * as path from "../../path"; -import { getVersion } from "../../utilities"; -import * as yaml from "../../yaml/index"; - -/** - * Chart is a component representing a collection of resources described by an arbitrary Helm - * Chart. The Chart can be fetched from any source that is accessible to the `helm` command - * line. Values in the `values.yml` file can be overridden using `ChartOpts.values` (equivalent - * to `--set` or having multiple `values.yml` files). Objects can be transformed arbitrarily by - * supplying callbacks to `ChartOpts.transformations`. - * - * `Chart` does not use Tiller. The Chart specified is copied and expanded locally; the semantics - * are equivalent to running `helm template` and then using Pulumi to manage the resulting YAML - * manifests. Any values that would be retrieved in-cluster are assigned fake values, and - * none of Tiller's server-side validity testing is executed. - * - * ## Example Usage - * ### Local Chart Directory - * - * ```typescript - * import * as k8s from "@pulumi/kubernetes"; - * - * const nginxIngress = new k8s.helm.v2.Chart("nginx-ingress", { - * path: "./nginx-ingress", - * }); - * ``` - * ### Remote Chart - * - * ```typescript - * import * as k8s from "@pulumi/kubernetes"; - * - * const nginxIngress = new k8s.helm.v2.Chart("nginx-ingress", { - * chart: "nginx-ingress", - * version: "1.24.4", - * fetchOpts:{ - * repo: "https://charts.helm.sh/stable", - * }, - * }); - * ``` - * ### Set Chart values - * - * ```typescript - * import * as k8s from "@pulumi/kubernetes"; - * - * const nginxIngress = new k8s.helm.v2.Chart("nginx-ingress", { - * chart: "nginx-ingress", - * version: "1.24.4", - * fetchOpts:{ - * repo: "https://charts.helm.sh/stable", - * }, - * values: { - * controller: { - * metrics: { - * enabled: true, - * } - * } - * }, - * }); - * ``` - * ### Deploy Chart into Namespace - * - * ```typescript - * import * as k8s from "@pulumi/kubernetes"; - * - * const nginxIngress = new k8s.helm.v2.Chart("nginx-ingress", { - * chart: "nginx-ingress", - * version: "1.24.4", - * namespace: "test-namespace", - * fetchOpts:{ - * repo: "https://charts.helm.sh/stable", - * }, - * }); - * ``` - * ### Chart with Transformations - * - * ```typescript - * import * as k8s from "@pulumi/kubernetes"; - * - * const nginxIngress = new k8s.helm.v2.Chart("nginx-ingress", { - * chart: "nginx-ingress", - * version: "1.24.4", - * fetchOpts:{ - * repo: "https://charts.helm.sh/stable", - * }, - * transformations: [ - * // Make every service private to the cluster, i.e., turn all services into ClusterIP instead of LoadBalancer. - * (obj: any, opts: pulumi.CustomResourceOptions) => { - * if (obj.kind === "Service" && obj.apiVersion === "v1") { - * if (obj.spec && obj.spec.type && obj.spec.type === "LoadBalancer") { - * obj.spec.type = "ClusterIP"; - * } - * } - * }, - * - * // Set a resource alias for a previous name. - * (obj: any, opts: pulumi.CustomResourceOptions) => { - * if (obj.kind === "Deployment") { - * opts.aliases = [{ name: "oldName" }] - * }, - * - * // Omit a resource from the Chart by transforming the specified resource definition to an empty List. - * (obj: any, opts: pulumi.CustomResourceOptions) => { - * if (obj.kind === "Pod" && obj.metadata.name === "test") { - * obj.apiVersion = "v1" - * obj.kind = "List" - * }, - * ], - * }); - * ``` - * - * @deprecated helm/v2/Chart is deprecated by helm/v3/Chart and will be removed in a future release. - */ -export class Chart extends yaml.CollectionComponentResource { - /** @internal */ - public static readonly __pulumiType = 'kubernetes:helm.sh/v2:Chart'; - - /** - * Create an instance of the specified Helm chart. - * @param releaseName Name of the Chart (e.g., nginx-ingress). - * @param config Configuration options for the Chart. - * @param opts A bag of options that control this resource's behavior. - */ - constructor( - releaseName: string, - config: ChartOpts | LocalChartOpts, - opts?: pulumi.ComponentResourceOptions - ) { - if (config.resourcePrefix !== undefined) { - releaseName = `${config.resourcePrefix}-${releaseName}` - } - super("kubernetes:helm.sh/v2:Chart", releaseName, config, opts); - - const allConfig = pulumi.output(config); - const configDeps = Array.from(>(allConfig).resources()); - - (allConfig).isKnown.then((isKnown: boolean) => { - if (!isKnown) { - // Note that this can only happen during a preview. - pulumi.log.info("[Can't preview] all chart values must be known ahead of time to generate an accurate preview.", this); - } - }); - - this.resources = allConfig.apply(cfg => { - // Create temporary directories and files to hold chart data and override values. - const overrides = tmp.fileSync({ postfix: ".yaml" }); - const chartDir = tmp.dirSync({ unsafeCleanup: true }); - - try { - let chart: string; - let defaultValues: string; - let cmd: string; - if (isChartOpts(cfg)) { - // Fetch chart. - if (cfg.repo && cfg.repo.includes("http")) { - pulumi.log.error( - "`repo` specifies the name of the Helm chart repo. Use `fetchOpts.repo` to specify a URL.", this); - } - const chartToFetch = cfg.repo ? `${cfg.repo}/${cfg.chart}` : cfg.chart; - const fetchOpts = Object.assign({}, cfg.fetchOpts, { - destination: chartDir.name, - version: cfg.version - }); - fetch(chartToFetch, fetchOpts); - const fetchedChartName = fs.readdirSync(chartDir.name).sort()[0]; - chart = path.quotePath(nodepath.join(chartDir.name, fetchedChartName)); - defaultValues = path.quotePath( - nodepath.join(chartDir.name, fetchedChartName, "values.yaml") - ); - } else { - chart = cfg.path; - defaultValues = path.quotePath(nodepath.join(chart, "values.yaml")); - } - - // Write overrides file. - const data = JSON.stringify(cfg.values || {}, undefined, " "); - fs.writeFileSync(overrides.name, data); - - // Does not require Tiller. From the `helm template` documentation: - // - // > Render chart templates locally and display the output. - // > - // > This does not require Tiller. However, any values that would normally be - // > looked up or retrieved in-cluster will be faked locally. Additionally, none - // > of the server-side testing of chart validity (e.g. whether an API is supported) - // > is done. - const release = shell.quote([releaseName]); - const values = path.quotePath(overrides.name); - const apiVersionsArgs = cfg.apiVersions - ? cfg.apiVersions - .map(v => `--api-versions=${v}`) - .join(" ") - : ""; - const namespaceArg = cfg.namespace - ? `--namespace ${shell.quote([cfg.namespace])}` - : ""; - - // Check the helm version - v2 or v3 - let helmVerCmd = `helm version --short || true`; - var helmVer; - try { - helmVer = execSync( - helmVerCmd, - { - stdio: ['pipe', 'pipe', 'ignore'], // Suppress tiller version error - }, - ).toString(); - } catch (e: any) { - helmVer = e.stdout.toString(); - } - - cmd = `helm template ${chart} --name-template ${release} --values ${defaultValues} --values ${values} ${apiVersionsArgs} ${namespaceArg}`; - // Helm v2 returns version like this: - // Client: v2.16.7+g5f2584f - // Helm v3 returns a version like this: - // v3.1.2+gd878d4d - // --include-crds is available in helm v3.1+ so check for a regex matching that version - if (RegExp('^v3\.[1-9]').test(helmVer)) { - cmd += ` --include-crds` - } - - const yamlStream = execSync( - cmd, - { - env: {...process.env}, - maxBuffer: 512 * 1024 * 1024 // 512 MB - }, - ).toString(); - return this.parseTemplate( - yamlStream, cfg.transformations, cfg.resourcePrefix, configDeps, cfg.namespace); - } catch (e: any) { - // Shed stack trace, only emit the error. - throw new pulumi.RunError(e.toString()); - } finally { - // Clean up temporary files and directories. - chartDir.removeCallback(); - overrides.removeCallback(); - } - - // Without this block, the TS compiler adds `| undefined` even though execution won't get here. - return pulumi.output<{[key: string]: pulumi.CustomResource}>({}); - }); - - this.ready = this.resources.apply(m => Object.values(m)); - } - - parseTemplate( - text: string, - transformations: ((o: any, opts: pulumi.CustomResourceOptions) => void)[] | undefined, - resourcePrefix: string | undefined, - dependsOn: pulumi.Resource[], - defaultNamespace: string | undefined, - ): pulumi.Output<{ [key: string]: pulumi.CustomResource }> { - // Rather than using the default provider for the following invoke call, use the version specified - // in package.json. - let invokeOpts: pulumi.InvokeOptions = { async: true, version: getVersion() }; - - const promise = pulumi.runtime.invoke("kubernetes:yaml:decode", {text, defaultNamespace}, invokeOpts); - return pulumi.output(promise).apply<{[key: string]: pulumi.CustomResource}>(p => yaml.parse( - { - resourcePrefix: resourcePrefix, - objs: p.result, - transformations: transformations || [], - }, - { parent: this, dependsOn: dependsOn } - )); - } -} - -interface BaseChartOpts { - /** - * The optional kubernetes api versions used for Capabilities.APIVersions. - */ - apiVersions?: pulumi.Input[]>; - /** - * The optional namespace to install chart resources into. - */ - namespace?: pulumi.Input; - /** - * Overrides for chart values. - */ - values?: pulumi.Inputs; - /** - * A set of transformations to apply to Kubernetes resource definitions before registering - * with engine. - */ - transformations?: ((o: any, opts: pulumi.CustomResourceOptions) => void)[]; - /** - * An optional prefix for the auto-generated resource names. - * Example: A resource created with resourcePrefix="foo" would produce a resource named "foo-resourceName". - */ - resourcePrefix?: string -} - -/** - * The set of arguments for constructing a Chart resource from a remote source. - */ -export interface ChartOpts extends BaseChartOpts { - /** - * The repository name of the chart to deploy. - * Example: "stable" - */ - repo?: pulumi.Input; - - /** - * The name of the chart to deploy. If [repo] is provided, this chart name will be prefixed by the repo name. - * Example: repo: "stable", chart: "nginx-ingress" -> "stable/nginx-ingress" - * Example: chart: "stable/nginx-ingress" -> "stable/nginx-ingress" - */ - chart: pulumi.Input; - - /** - * The version of the chart to deploy. If not provided, the latest version will be deployed. - */ - version?: pulumi.Input; - - /** - * Additional options to customize the fetching of the Helm chart. - */ - fetchOpts?: pulumi.Input; -} - -function isChartOpts(o: any): o is ChartOpts { - return "chart" in o; -} - -/** - * The set of arguments for constructing a Chart resource from a local source. - */ -export interface LocalChartOpts extends BaseChartOpts { - /** - * The path to the chart directory which contains the `Chart.yaml` file. - */ - path: string; -} - -function isLocalChartOpts(o: any): o is LocalChartOpts { - return "path" in o; -} - -/** - * Additional options to customize the fetching of the Helm chart. - */ -export interface FetchOpts { - /** Specific version of a chart. Without this, the latest version is fetched. */ - version?: pulumi.Input; - - /** Verify certificates of HTTPS-enabled servers using this CA bundle. */ - caFile?: pulumi.Input; - - /** Identify HTTPS client using this SSL certificate file. */ - certFile?: pulumi.Input; - - /** Identify HTTPS client using this SSL key file. */ - keyFile?: pulumi.Input; - - /** - * Location to write the chart. If this and tardir are specified, tardir is appended to this - * (default "."). - */ - destination?: pulumi.Input; - - /** Keyring containing public keys (default "/Users/alex/.gnupg/pubring.gpg"). */ - keyring?: pulumi.Input; - - /** Chart repository password. */ - password?: pulumi.Input; - - /** Chart repository url where to locate the requested chart. */ - repo?: pulumi.Input; - - /** - * If untar is specified, this flag specifies the name of the directory into which the chart is - * expanded (default "."). - */ - untardir?: pulumi.Input; - - /** Chart repository username. */ - username?: pulumi.Input; - - /** Location of your Helm config. Overrides $HELM_HOME (default "/Users/alex/.helm"). */ - home?: pulumi.Input; - - /** - * Use development versions, too. Equivalent to version '>0.0.0-0'. If --version is set, this is - * ignored. - */ - devel?: pulumi.Input; - - /** Fetch the provenance file, but don't perform verification. */ - prov?: pulumi.Input; - - /** If set to false, will leave the chart as a tarball after downloading. */ - untar?: pulumi.Input; - - /** Verify the package against its signature. */ - verify?: pulumi.Input; -} - -interface ResolvedFetchOpts { - version?: string; - caFile?: string; - certFile?: string; - keyFile?: string; - destination?: string; - keyring?: string; - password?: string; - repo?: string; - untardir?: string; - username?: string; - home?: string; - devel?: boolean; - prov?: boolean; - untar?: boolean; - verify?: boolean; -} - -/** - * Retrieve a package from a package repository, and download it locally. - * - * This is useful for fetching packages to inspect, modify, or repackage. It can also be used to - * perform cryptographic verification of a chart without installing the chart. - * - * There are options for unpacking the chart after download. This will create a directory for the - * chart and uncompress into that directory. - * - * If the `verify` option is specified, the requested chart MUST have a provenance file, and MUST - * pass the verification process. Failure in any part of this will result in an error, and the chart - * will not be saved locally. - * - * @ignore - */ -export function fetch(chart: string, opts?: ResolvedFetchOpts) { - const flags: string[] = []; - const env: { [key: string]: string | undefined } = {...process.env}; - if (opts !== undefined) { - // Untar by default. - if(opts.untar !== false) { flags.push(`--untar`); } - - // Helm v3 removed the `--home` flag, so we must use an env var instead. - if (opts.home) { env['HELM_HOME'] = path.quotePath(opts.home) } - - // For arguments that are not paths to files, it is sufficient to use shell.quote to quote the arguments. - // However, for arguments that are actual paths to files we use path.quotePath (note that path here is - // not the node path builtin module). This ensures proper escaping of paths on Windows. - if (opts.version !== undefined) { flags.push(`--version ${shell.quote([opts.version])}`); } - if (opts.caFile !== undefined) { flags.push(`--ca-file ${path.quotePath(opts.caFile)}`); } - if (opts.certFile !== undefined) { flags.push(`--cert-file ${path.quotePath(opts.certFile)}`); } - if (opts.keyFile !== undefined) { flags.push(`--key-file ${path.quotePath(opts.keyFile)}`); } - if (opts.destination !== undefined) { flags.push(`--destination ${path.quotePath(opts.destination)}`); } - if (opts.keyring !== undefined) { flags.push(`--keyring ${path.quotePath(opts.keyring)}`); } - if (opts.password !== undefined) { flags.push(`--password ${shell.quote([opts.password])}`); } - if (opts.repo !== undefined) { flags.push(`--repo ${path.quotePath(opts.repo)}`); } - if (opts.untardir !== undefined) { flags.push(`--untardir ${path.quotePath(opts.untardir)}`); } - if (opts.username !== undefined) { flags.push(`--username ${shell.quote([opts.username])}`); } - if (opts.devel === true) { flags.push(`--devel`); } - if (opts.prov === true) { flags.push(`--prov`); } - if (opts.verify === true) { flags.push(`--verify`); } - } - execSync(`helm fetch ${shell.quote([chart])} ${flags.join(" ")}`, { env }); -} diff --git a/sdk/nodejs/helm/v2/index.ts b/sdk/nodejs/helm/v2/index.ts deleted file mode 100644 index aa46d17133..0000000000 --- a/sdk/nodejs/helm/v2/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -// *** WARNING: this file was generated by pulumigen. *** -// *** Do not edit by hand unless you're certain you know what you are doing! *** - -// Export members: -export * from "./helm"; diff --git a/sdk/nodejs/tsconfig.json b/sdk/nodejs/tsconfig.json index 6440e1fd0d..deda54c2be 100644 --- a/sdk/nodejs/tsconfig.json +++ b/sdk/nodejs/tsconfig.json @@ -275,8 +275,6 @@ "flowcontrol/v1beta3/priorityLevelConfigurationList.ts", "flowcontrol/v1beta3/priorityLevelConfigurationPatch.ts", "helm/index.ts", - "helm/v2/helm.ts", - "helm/v2/index.ts", "helm/v3/helm.ts", "helm/v3/index.ts", "helm/v3/release.ts", diff --git a/sdk/python/pulumi_kubernetes/helm/__init__.py b/sdk/python/pulumi_kubernetes/helm/__init__.py index f7a4c7a3b0..6c932218a1 100644 --- a/sdk/python/pulumi_kubernetes/helm/__init__.py +++ b/sdk/python/pulumi_kubernetes/helm/__init__.py @@ -7,11 +7,8 @@ # Make subpackages available: if typing.TYPE_CHECKING: - import pulumi_kubernetes.helm.v2 as __v2 - v2 = __v2 import pulumi_kubernetes.helm.v3 as __v3 v3 = __v3 else: - v2 = _utilities.lazy_import('pulumi_kubernetes.helm.v2') v3 = _utilities.lazy_import('pulumi_kubernetes.helm.v3') diff --git a/sdk/python/pulumi_kubernetes/helm/v2/__init__.py b/sdk/python/pulumi_kubernetes/helm/v2/__init__.py deleted file mode 100644 index 9a804ee9a7..0000000000 --- a/sdk/python/pulumi_kubernetes/helm/v2/__init__.py +++ /dev/null @@ -1,8 +0,0 @@ -# coding=utf-8 -# *** WARNING: this file was generated by pulumigen. *** -# *** Do not edit by hand unless you're certain you know what you are doing! *** - -from ... import _utilities -import typing -# Export this package's modules as members: -from .helm import * diff --git a/sdk/python/pulumi_kubernetes/helm/v2/helm.py b/sdk/python/pulumi_kubernetes/helm/v2/helm.py deleted file mode 100644 index b59da3b5e7..0000000000 --- a/sdk/python/pulumi_kubernetes/helm/v2/helm.py +++ /dev/null @@ -1,677 +0,0 @@ -# Copyright 2016-2021, Pulumi Corporation. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# *** WARNING: this file was generated by the Pulumi Kubernetes codegen tool. *** -# *** Do not edit by hand unless you're certain you know what you are doing! *** - -import json -import os.path -import re -import shutil -import subprocess -from tempfile import mkdtemp, mkstemp -from typing import Any, Callable, Optional, Sequence, TextIO, Tuple, Union -from warnings import warn - -import pulumi.runtime -from pulumi_kubernetes.yaml.yaml import _parse_yaml_document - -from ... import _utilities - -warn(f'helm/v2/Chart is deprecated by helm/v3/Chart and will be removed in a future release.', - DeprecationWarning, stacklevel=2) - - -class Chart(pulumi.ComponentResource): - resources: pulumi.Output[dict] - """ - Kubernetes resources contained in this Chart. - """ - ready: pulumi.Output[Sequence[pulumi.Output[pulumi.Resource]]] - - def __init__(self, - release_name: str, - config: Union['ChartOpts', 'LocalChartOpts'], - opts: Optional[pulumi.ResourceOptions] = None): - """ - Chart is a component representing a collection of resources described by an arbitrary Helm - Chart. The Chart can be fetched from any source that is accessible to the `helm` command - line. Values in the `values.yml` file can be overridden using `ChartOpts.values` (equivalent - to `--set` or having multiple `values.yml` files). Objects can be transformed arbitrarily by - supplying callbacks to `ChartOpts.transformations`. - - Chart does not use Tiller. The Chart specified is copied and expanded locally; the semantics - are equivalent to running `helm template` and then using Pulumi to manage the resulting YAML - manifests. Any values that would be retrieved in-cluster are assigned fake values, and - none of Tiller's server-side validity testing is executed. - - ## Example Usage - ### Local Chart Directory - - ```python - from pulumi_kubernetes.helm.v3 import Chart, LocalChartOpts - - nginx_ingress = Chart( - "nginx-ingress", - LocalChartOpts( - path="./nginx-ingress", - ), - ) - ``` - ### Remote Chart - - ```python - from pulumi_kubernetes.helm.v3 import Chart, ChartOpts, FetchOpts - - nginx_ingress = Chart( - "nginx-ingress", - ChartOpts( - chart="nginx-ingress", - version="1.24.4", - fetch_opts=FetchOpts( - repo="https://charts.helm.sh/stable", - ), - ), - ) - ``` - ### Set Chart Values - - ```python - from pulumi_kubernetes.helm.v3 import Chart, ChartOpts, FetchOpts - - nginx_ingress = Chart( - "nginx-ingress", - ChartOpts( - chart="nginx-ingress", - version="1.24.4", - fetch_opts=FetchOpts( - repo="https://charts.helm.sh/stable", - ), - values={ - "controller": { - "metrics": { - "enabled": True, - }, - }, - }, - ), - ) - ``` - ### Deploy Chart into Namespace - - ```python - from pulumi_kubernetes.helm.v3 import Chart, ChartOpts, FetchOpts - - nginx_ingress = Chart( - "nginx-ingress", - ChartOpts( - chart="nginx-ingress", - version="1.24.4", - namespace="test-namespace", - fetch_opts=FetchOpts( - repo="https://charts.helm.sh/stable", - ), - ), - ) - ``` - ### Chart with Transformations - - ```python - from pulumi_kubernetes.helm.v3 import Chart, ChartOpts, FetchOpts - - # Make every service private to the cluster, i.e., turn all services into ClusterIP instead of LoadBalancer. - def make_service_private(obj, opts): - if obj["kind"] == "Service" and obj["apiVersion"] == "v1": - try: - t = obj["spec"]["type"] - if t == "LoadBalancer": - obj["spec"]["type"] = "ClusterIP" - except KeyError: - pass - - - # Set a resource alias for a previous name. - def alias(obj, opts): - if obj["kind"] == "Deployment": - opts.aliases = ["oldName"] - - - # Omit a resource from the Chart by transforming the specified resource definition to an empty List. - def omit_resource(obj, opts): - if obj["kind"] == "Pod" and obj["metadata"]["name"] == "test": - obj["apiVersion"] = "v1" - obj["kind"] = "List" - - - nginx_ingress = Chart( - "nginx-ingress", - ChartOpts( - chart="nginx-ingress", - version="1.24.4", - fetch_opts=FetchOpts( - repo="https://charts.helm.sh/stable", - ), - transformations=[make_service_private, alias, omit_resource], - ), - ) - ``` - - :param str release_name: Name of the Chart (e.g., nginx-ingress). - :param Union[ChartOpts, LocalChartOpts] config: Configuration options for the Chart. - :param Optional[pulumi.ResourceOptions] opts: A bag of options that control this - resource's behavior. - """ - if not release_name: - raise TypeError('Missing release name argument') - if not isinstance(release_name, str): - raise TypeError('Expected release name to be a string') - if config and not isinstance(config, ChartOpts) and not isinstance(config, LocalChartOpts): - raise TypeError('Expected config to be a ChartOpts or LocalChartOpts instance') - if opts and not isinstance(opts, pulumi.ResourceOptions): - raise TypeError('Expected resource options to be a ResourceOptions instance') - - __props__ = dict() - - if config.resource_prefix: - release_name = f"{config.resource_prefix}-{release_name}" - - super(Chart, self).__init__( - "kubernetes:helm.sh/v2:Chart", - release_name, - __props__, - opts) - - all_config = pulumi.Output.from_input((release_name, config, pulumi.ResourceOptions(parent=self))) - - # Note: Unlike NodeJS, Python requires that we "pull" on our futures in order to get them scheduled for - # execution. In order to do this, we leverage the engine's RegisterResourceOutputs to wait for the - # resolution of all resources that this Helm chart created. - self.resources = all_config.apply(_parse_chart) - self.register_outputs({"resources": self.resources}) - self.ready = self.resources.apply(lambda x: list(x.values())) - - def get_resource(self, - group_version_kind: str, - name: str, - namespace: Optional[str] = None) -> pulumi.Output[pulumi.CustomResource]: - """ - get_resource returns a resource defined by a built-in Kubernetes group/version/kind and - name. For example: `get_resource("apps/v1/Deployment", "nginx")` - - :param str group_version_kind: Group/Version/Kind of the resource, e.g., `apps/v1/Deployment` - :param str name: Name of the resource to retrieve - :param Optional[str] namespace: Optional namespace of the resource to retrieve - """ - - # `id` will either be `${name}` or `${namespace}/${name}`. - id = pulumi.Output.from_input(name) - if namespace is not None: - id = pulumi.Output.concat(namespace, '/', name) - - resource_id = id.apply(lambda x: f'{group_version_kind}:{x}') - return resource_id.apply(lambda x: self.resources[x]) - - -class FetchOpts: - """ - FetchOpts is a bag of configuration options to customize the fetching of the Helm chart. - """ - - version: Optional[pulumi.Input[str]] - """ - Specific version of a chart. If unset, the latest version is fetched. - """ - - ca_file: Optional[pulumi.Input[str]] - """ - Verify certificates of HTTPS-enabled servers using this CA bundle. - """ - - cert_file: Optional[pulumi.Input[str]] - """ - Identify HTTPS client using this SSL certificate file. - """ - - key_file: Optional[pulumi.Input[str]] - """ - Identify HTTPS client using this SSL key file. - """ - - destination: Optional[pulumi.Input[str]] - """ - Location to write the chart. If this and [tardir] are specified, tardir is appended - to this (default "."). - """ - - keyring: Optional[pulumi.Input[str]] - """ - Keyring containing public keys (default "/Users/alex/.gnupg/pubring.gpg"). - """ - - password: Optional[pulumi.Input[str]] - """ - Chart repository password. - """ - - repo: Optional[pulumi.Input[str]] - """ - Chart repository url where to locate the requested chart. - """ - - untar_dir: Optional[pulumi.Input[str]] - """ - If [untar] is specified, this flag specifies the name of the directory into which - the chart is expanded (default "."). - """ - - username: Optional[pulumi.Input[str]] - """ - Chart repository username. - """ - - home: Optional[pulumi.Input[str]] - """ - Location of your Helm config. Overrides $HELM_HOME (default "/Users/alex/.helm"). - """ - - devel: Optional[pulumi.Input[bool]] - """ - Use development versions, too. Equivalent to version '>0.0.0-0'. If [version] is set, - this is ignored. - """ - - prov: Optional[pulumi.Input[bool]] - """ - Fetch the provenance file, but don't perform verification. - """ - - untar: Optional[pulumi.Input[bool]] - """ - If set to false, will leave the chart as a tarball after downloading. - """ - - verify: Optional[pulumi.Input[bool]] - """ - Verify the package against its signature. - """ - - def __init__(self, - version: Optional[pulumi.Input[str]] = None, - ca_file: Optional[pulumi.Input[str]] = None, - cert_file: Optional[pulumi.Input[str]] = None, - key_file: Optional[pulumi.Input[str]] = None, - destination: Optional[pulumi.Input[str]] = None, - keyring: Optional[pulumi.Input[str]] = None, - password: Optional[pulumi.Input[str]] = None, - repo: Optional[pulumi.Input[str]] = None, - untar_dir: Optional[pulumi.Input[str]] = None, - username: Optional[pulumi.Input[str]] = None, - home: Optional[pulumi.Input[str]] = None, - devel: Optional[pulumi.Input[bool]] = None, - prov: Optional[pulumi.Input[bool]] = None, - untar: Optional[pulumi.Input[bool]] = None, - verify: Optional[pulumi.Input[bool]] = None): - """ - :param Optional[pulumi.Input[str]] version: Specific version of a chart. If unset, - the latest version is fetched. - :param Optional[pulumi.Input[str]] ca_file: Verify certificates of HTTPS-enabled - servers using this CA bundle. - :param Optional[pulumi.Input[str]] cert_file: Identify HTTPS client using this SSL - certificate file. - :param Optional[pulumi.Input[str]] key_file: Identify HTTPS client using this SSL - key file. - :param Optional[pulumi.Input[str]] destination: Location to write the chart. - If this and [tardir] are specified, tardir is appended to this (default "."). - :param Optional[pulumi.Input[str]] keyring: Keyring containing public keys - (default "/Users//.gnupg/pubring.gpg"). - :param Optional[pulumi.Input[str]] password: Chart repository password. - :param Optional[pulumi.Input[str]] repo: Chart repository url where to locate - the requested chart. - :param Optional[pulumi.Input[str]] untar_dir: If [untar] is specified, this flag - specifies the name of the directory into which the chart is - expanded (default "."). - :param Optional[pulumi.Input[str]] username: Chart repository username. - :param Optional[pulumi.Input[str]] home: Location of your Helm config. Overrides - $HELM_HOME (default "/Users//.helm"). - :param Optional[pulumi.Input[bool]] devel: Use development versions, too. - Equivalent to version '>0.0.0-0'. If [version] is set, this is ignored. - :param Optional[pulumi.Input[bool]] prov: Fetch the provenance file, but don't - perform verification. - :param Optional[pulumi.Input[bool]] untar: If set to false, will leave the - chart as a tarball after downloading. - :param Optional[pulumi.Input[bool]] verify: Verify the package against its signature. - """ - self.version = version - self.ca_file = ca_file - self.cert_file = cert_file - self.key_file = key_file - self.destination = destination - self.keyring = keyring - self.password = password - self.repo = repo - self.untar_dir = untar_dir - self.username = username - self.home = home - self.devel = devel - self.prov = prov - self.untar = untar - self.verify = verify - - -class BaseChartOpts: - """ - BaseChartOpts is a bag of common configuration options for a Helm chart. - """ - - namespace: Optional[pulumi.Input[str]] - """ - Optional namespace to install chart resources into. - """ - - values: Optional[pulumi.Inputs] - """ - Optional overrides for chart values. - """ - - transformations: Optional[Sequence[Callable[[Any, pulumi.ResourceOptions], None]]] - """ - Optional list of transformations to apply to resources that will be created by this chart prior to - creation. Allows customization of the chart behaviour without directly modifying the chart itself. - """ - - resource_prefix: Optional[str] - """ - Optional prefix for the auto-generated resource names. - Example: A resource created with resource_prefix="foo" would produce a resource named "foo-resourceName". - """ - - api_versions: Optional[Sequence[pulumi.Input[str]]] - """ - Optional kubernetes api versions used for Capabilities.APIVersions. - """ - - 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): - """ - :param Optional[pulumi.Input[str]] namespace: Optional namespace to install chart resources into. - :param Optional[pulumi.Inputs] values: Optional overrides for chart values. - :param Optional[Sequence[Callable[[Any, pulumi.ResourceOptions], None]]] transformations: Optional list - of transformations to apply to resources that will be created by this chart prior to creation. - Allows customization of the chart behaviour without directly modifying the chart itself. - :param Optional[str] resource_prefix: An optional prefix for the auto-generated resource names. - Example: A resource created with resource_prefix="foo" would produce a resource named "foo-resourceName". - :param Optional[Sequence[pulumi.Input[str]]] api_versions: Optional kubernetes api versions used for - Capabilities.APIVersions. - """ - self.namespace = namespace - self.values = values - self.transformations = transformations - self.resource_prefix = resource_prefix - self.api_versions = api_versions - - -class ChartOpts(BaseChartOpts): - """ - ChartOpts is a bag of configuration options for a remote Helm chart. - """ - - chart: pulumi.Input[str] - """ - The name of the chart to deploy. If `repo` is provided, this chart name will be prefixed by the repo name. - Example: repo: "stable", chart: "nginx-ingress" -> "stable/nginx-ingress" - Example: chart: "stable/nginx-ingress" -> "stable/nginx-ingress" - """ - - repo: Optional[pulumi.Input[str]] - """ - The repository name of the chart to deploy. - Example: "stable" - """ - - version: Optional[pulumi.Input[str]] - """ - The version of the chart to deploy. If not provided, the latest version will be deployed. - """ - - fetch_opts: Optional[pulumi.Input[FetchOpts]] - """ - Additional options to customize the fetching of the Helm chart. - """ - - def __init__(self, - chart: pulumi.Input[str], - 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, - repo: Optional[pulumi.Input[str]] = None, - version: Optional[pulumi.Input[str]] = None, - fetch_opts: Optional[pulumi.Input[FetchOpts]] = None, - api_versions: Optional[Sequence[pulumi.Input[str]]] = 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. - Example: repo: "stable", chart: "nginx-ingress" -> "stable/nginx-ingress" - Example: chart: "stable/nginx-ingress" -> "stable/nginx-ingress" - :param Optional[pulumi.Input[str]] namespace: Optional namespace to install chart resources into. - :param Optional[pulumi.Inputs] values: Optional overrides for chart values. - :param Optional[Sequence[Callable[[Any, pulumi.ResourceOptions], None]]] transformations: Optional list of - transformations to apply to resources that will be created by this chart prior to creation. - Allows customization of the chart behaviour without directly modifying the chart itself. - :param Optional[str] resource_prefix: An optional prefix for the auto-generated resource names. - Example: A resource created with resource_prefix="foo" would produce a resource named "foo-resourceName". - :param Optional[pulumi.Input[str]] repo: The repository name of the chart to deploy. - Example: "stable" - :param Optional[pulumi.Input[str]] version: The version of the chart to deploy. If not provided, - the latest version will be deployed. - :param Optional[pulumi.Input[FetchOpts]] fetch_opts: Additional options to customize the - fetching of the Helm chart. - :param Optional[Sequence[pulumi.Input[str]]] api_versions: Optional kubernetes api versions used for - Capabilities.APIVersions. - """ - super(ChartOpts, self).__init__(namespace, values, transformations, resource_prefix, api_versions) - self.chart = chart - self.repo = repo - self.version = version - self.fetch_opts = fetch_opts - - -class LocalChartOpts(BaseChartOpts): - """ - LocalChartOpts is a bag of configuration options for a local Helm chart. - """ - - path: pulumi.Input[str] - """ - The path to the chart directory which contains the `Chart.yaml` file. - """ - - def __init__(self, - path: pulumi.Input[str], - 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): - """ - :param pulumi.Input[str] path: The path to the chart directory which contains the - `Chart.yaml` file. - :param Optional[pulumi.Input[str]] namespace: Optional namespace to install chart resources into. - :param Optional[pulumi.Inputs] values: Optional overrides for chart values. - :param Optional[Sequence[Callable[[Any, pulumi.ResourceOptions], None]]] transformations: Optional list of - transformations to apply to resources that will be created by this chart prior to creation. - Allows customization of the chart behaviour without directly modifying the chart itself. - :param Optional[str] resource_prefix: An optional prefix for the auto-generated resource names. - Example: A resource created with resource_prefix="foo" would produce a resource named "foo-resourceName". - :param Optional[Sequence[pulumi.Input[str]]] api_versions: Optional kubernetes api versions used for - Capabilities.APIVersions. - """ - - super(LocalChartOpts, self).__init__(namespace, values, transformations, resource_prefix, api_versions) - self.path = path - - -def _run_helm_cmd(all_config: Tuple[Sequence[Union[str, bytes]], Any]) -> str: - cmd, _ = all_config - - output = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True, check=True) - yaml_str: str = output.stdout - return yaml_str - - -def _is_helm_v3() -> bool: - cmd: Sequence[str] = ['helm', 'version', '--short'] - - """ - Helm v2 returns version like this: - Client: v2.16.7+g5f2584f - Helm v3 returns a version like this: - v3.1.2+gd878d4d - --include-crds is available in helm v3.1+ so check for a regex matching that version - """ - output = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, universal_newlines=True, check=True) - version: str = output.stdout - regexp = re.compile(r'^v3\.[1-9]') - return bool(regexp.search(version)) - - -def _write_override_file(all_config: Tuple[TextIO, str]) -> None: - file, data = all_config - - file.write(data) - file.flush() - - -def _cleanup_temp_dir(all_config: Tuple[TextIO, Union[bytes, str], Any]) -> None: - file, chart_dir, _ = all_config - - file.close() - shutil.rmtree(chart_dir) - - -def _parse_chart(all_config: Tuple[str, Union[ChartOpts, LocalChartOpts], pulumi.ResourceOptions]) -> pulumi.Output: - release_name, config, opts = all_config - - # Create temporary directory and file to hold chart data and override values. - # Note: We're intentionally using the lower-level APIs here because the async Outputs are being handled in - # a different scope, which was causing the temporary files/directory to be deleted before they were referenced - # in the Output handlers. We manually clean these up once we're done with another async handler that depends - # on the result of the operations. - overrides, overrides_filename = mkstemp() - chart_dir = mkdtemp() - - if isinstance(config, ChartOpts): - if config.repo and 'http' in config.repo: - raise ValueError('`repo` specifies the name of the Helm chart repo.' - 'Use `fetch_opts.repo` to specify a URL.') - chart_to_fetch = f'{config.repo}/{config.chart}' if config.repo else config.chart - - # Configure fetch options. - fetch_opts_dict = {} - if config.fetch_opts is not None: - fetch_opts_dict = {k: v for k, v in vars(config.fetch_opts).items() if v is not None} - fetch_opts_dict["destination"] = chart_dir - if config.version is not None: - fetch_opts_dict["version"] = config.version - fetch_opts = FetchOpts(**fetch_opts_dict) - - # Fetch the chart. - _fetch(chart_to_fetch, fetch_opts) - # Sort the directories into alphabetical order, and choose the first - fetched_chart_name = sorted(os.listdir(chart_dir), key=str.lower)[0] - chart = os.path.join(chart_dir, fetched_chart_name) - else: - chart = config.path - - default_values = os.path.join(chart, 'values.yaml') - - # Write overrides file. - vals = config.values if config.values is not None else {} - data = pulumi.Output.from_input(vals).apply(lambda x: json.dumps(x)) - file = open(overrides, 'w') - pulumi.Output.all(file, data).apply(_write_override_file) - - apiversions_arg = [f'--api-versions={version}' for version in config.api_versions] if config.api_versions else [] - namespace_arg = ['--namespace', config.namespace] if config.namespace else [] - crd_arg = ['--include-crds'] if _is_helm_v3() else [] - - # Use 'helm template' to create a combined YAML manifest. - cmd = ['helm', 'template', chart, '--name-template', release_name, - '--values', default_values, '--values', overrides_filename] - cmd.extend(apiversions_arg) - cmd.extend(namespace_arg) - cmd.extend(crd_arg) - - chart_resources = pulumi.Output.all(cmd, data).apply(_run_helm_cmd) - - # Rather than using the default provider for the following invoke call, use the version specified - # in package.json. - invoke_opts = pulumi.InvokeOptions(version=_utilities.get_version()) - - objects = chart_resources.apply( - lambda text: pulumi.runtime.invoke('kubernetes:yaml:decode', { - 'text': text, 'defaultNamespace': config.namespace}, invoke_opts).value['result']) - - # Parse the manifest and create the specified resources. - resources = objects.apply( - lambda objects: _parse_yaml_document(objects, opts, config.transformations)) - - pulumi.Output.all(file, chart_dir, resources).apply(_cleanup_temp_dir) - return resources - - -def _fetch(chart: str, opts: FetchOpts) -> None: - cmd: Sequence[str] = ['helm', 'fetch', chart] - - # Untar by default. - if opts.untar is not False: - cmd.append('--untar') - - env = os.environ - # Helm v3 removed the `--home` flag, so we must use an env var instead. - if opts.home: - env['HELM_HOME'] = opts.home - - if opts.version: - cmd.extend(['--version', opts.version]) - if opts.ca_file: - cmd.extend(['--ca-file', opts.ca_file]) - if opts.cert_file: - cmd.extend(['--cert-file', opts.cert_file]) - if opts.key_file: - cmd.extend(['--key-file', opts.key_file]) - if opts.destination: - cmd.extend(['--destination', opts.destination]) - if opts.keyring: - cmd.extend(['--keyring', opts.keyring]) - if opts.password: - cmd.extend(['--password', opts.password]) - if opts.repo: - cmd.extend(['--repo', opts.repo]) - if opts.untar_dir: - cmd.extend(['--untardir', opts.untar_dir]) - if opts.username: - cmd.extend(['--username', opts.username]) - if opts.devel: - cmd.append('--devel') - if opts.prov: - cmd.append('--prov') - if opts.verify: - cmd.append('--verify') - - subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True, check=True, env=env) diff --git a/tests/sdk/dotnet/dotnet_test.go b/tests/sdk/dotnet/dotnet_test.go index 09e753f2b9..b4be8a16cf 100644 --- a/tests/sdk/dotnet/dotnet_test.go +++ b/tests/sdk/dotnet/dotnet_test.go @@ -1,4 +1,4 @@ -// Copyright 2016-2022, Pulumi Corporation. +// Copyright 2016-2023, Pulumi Corporation. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -90,12 +90,6 @@ func TestDotnet_YamlLocal(t *testing.T) { Path: true, }, }, - ExtraRuntimeValidation: func( - t *testing.T, stackInfo integration.RuntimeValidationStackInfo, - ) { - assert.NotNil(t, stackInfo.Deployment) - assert.Equal(t, 7, len(stackInfo.Deployment.Resources)) - }, }) integration.ProgramTest(t, &test) } @@ -118,13 +112,6 @@ func TestDotnet_Helm(t *testing.T) { } } }, - EditDirs: []integration.EditDir{ - { - Dir: filepath.Join("helm", "step2"), - Additive: true, - ExpectNoChanges: true, - }, - }, }) integration.ProgramTest(t, &test) } @@ -190,13 +177,6 @@ func TestDotnet_HelmApiVersions(t *testing.T) { assert.NotNil(t, stackInfo.Deployment) assert.Equal(t, 7, len(stackInfo.Deployment.Resources)) }, - EditDirs: []integration.EditDir{ - { - Dir: filepath.Join("helm-api-versions", "step2"), - Additive: true, - ExpectNoChanges: true, - }, - }, }) integration.ProgramTest(t, &test) } diff --git a/tests/sdk/dotnet/helm-api-versions/step1/Program.cs b/tests/sdk/dotnet/helm-api-versions/step1/Program.cs index 68d39ba7a5..4d534aeda4 100644 --- a/tests/sdk/dotnet/helm-api-versions/step1/Program.cs +++ b/tests/sdk/dotnet/helm-api-versions/step1/Program.cs @@ -8,7 +8,7 @@ using Pulumi.Kubernetes; using Pulumi.Kubernetes.Core.V1; using Pulumi.Kubernetes.Helm; -using Pulumi.Kubernetes.Helm.V2; +using Pulumi.Kubernetes.Helm.V3; using Pulumi.Kubernetes.Types.Inputs.Core.V1; using Pulumi.Kubernetes.Yaml; using Pulumi.Serialization; diff --git a/tests/sdk/dotnet/helm-api-versions/step2/Program.cs b/tests/sdk/dotnet/helm-api-versions/step2/Program.cs deleted file mode 100644 index 4d534aeda4..0000000000 --- a/tests/sdk/dotnet/helm-api-versions/step2/Program.cs +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2016-2022, Pulumi Corporation. All rights reserved. - -using System; -using System.Collections.Generic; -using System.Collections.Immutable; -using System.Threading.Tasks; -using Pulumi; -using Pulumi.Kubernetes; -using Pulumi.Kubernetes.Core.V1; -using Pulumi.Kubernetes.Helm; -using Pulumi.Kubernetes.Helm.V3; -using Pulumi.Kubernetes.Types.Inputs.Core.V1; -using Pulumi.Kubernetes.Yaml; -using Pulumi.Serialization; - -class HelmStack : Stack -{ - public HelmStack() - { - var provider = new Provider("k8s"); - var namespaceTest = new Namespace("test", null, new CustomResourceOptions{Provider = provider}); - var namespaceName = namespaceTest.Metadata.Apply(n => n.Name); - - new Chart("api-versions", new LocalChartArgs - { - ApiVersions = { "foo", "bar" }, - Namespace = namespaceName, - Path = "helm-api-versions" - }, new ComponentResourceOptions - { - Provider = provider, - }); - - new Chart("single-api-version", new LocalChartArgs - { - ApiVersions = { "foo" }, - Namespace = namespaceName, - Path = "helm-single-api-version" - }, new ComponentResourceOptions - { - Provider = provider, - }); - } -} - -class Program -{ - static Task Main(string[] args) => Deployment.RunAsync(); -} diff --git a/tests/sdk/dotnet/helm-local/step1/Program.cs b/tests/sdk/dotnet/helm-local/step1/Program.cs index e859ad4d20..eeaaa039c4 100644 --- a/tests/sdk/dotnet/helm-local/step1/Program.cs +++ b/tests/sdk/dotnet/helm-local/step1/Program.cs @@ -6,7 +6,7 @@ using Pulumi; using Pulumi.Kubernetes.Core.V1; using Pulumi.Kubernetes.Helm; -using Pulumi.Kubernetes.Helm.V2; +using Pulumi.Kubernetes.Helm.V3; class HelmStack : Stack { diff --git a/tests/sdk/dotnet/helm-local/step2/Program.cs b/tests/sdk/dotnet/helm-local/step2/Program.cs deleted file mode 100644 index eeaaa039c4..0000000000 --- a/tests/sdk/dotnet/helm-local/step2/Program.cs +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright 2016-2021, Pulumi Corporation. All rights reserved. - -using System.Collections.Generic; -using System.Collections.Immutable; -using System.Threading.Tasks; -using Pulumi; -using Pulumi.Kubernetes.Core.V1; -using Pulumi.Kubernetes.Helm; -using Pulumi.Kubernetes.Helm.V3; - -class HelmStack : Stack -{ - public HelmStack() - { - var namespaceTest = new Namespace("test"); - var namespaceName = namespaceTest.Metadata.Apply(n => n.Name); - - var nginx = CreateChart(namespaceName); - new ConfigMap("foo", new Pulumi.Kubernetes.Types.Inputs.Core.V1.ConfigMapArgs - { - Data = new InputMap - { - {"foo", "bar"} - }, - }, new CustomResourceOptions - { - DependsOn = nginx.Ready(), - }); - - // Deploy a duplicate chart with a different resource prefix to verify that multiple instances of the Chart - // can be managed in the same stack. - CreateChart(namespaceName, "dup"); - } - - private static Chart CreateChart(Output namespaceName, string? resourcePrefix = null) - { - var values = new Dictionary - { - ["service"] = new Dictionary - { - ["type"] = "ClusterIP" - }, - }; - return new Chart("nginx", new LocalChartArgs - { - Path = "nginx", - Namespace = namespaceName, - ResourcePrefix = resourcePrefix, - Values = values, - Transformations = - { - LoadBalancerToClusterIP, - StatusToSecret - } - }); - - // Make every service private to the cluster, i.e., turn all services into ClusterIP instead of - // LoadBalancer. - ImmutableDictionary LoadBalancerToClusterIP(ImmutableDictionary obj, CustomResourceOptions opts) - { - if ((string)obj["kind"] == "Service" && (string)obj["apiVersion"] == "v1") - { - var spec = (ImmutableDictionary)obj["spec"]; - if (spec != null && (string)spec["type"] == "LoadBalancer") - { - return obj.SetItem("spec", spec.SetItem("type", "ClusterIP")); - } - } - - return obj; - } - - // Make every service private to the cluster, i.e., turn all services into ClusterIP instead of - // LoadBalancer. - ImmutableDictionary StatusToSecret(ImmutableDictionary obj, CustomResourceOptions opts) - { - if ((string)obj["kind"] == "Service" && (string)obj["apiVersion"] == "v1") - { - opts.AdditionalSecretOutputs = new List { "status" }; - } - - return obj; - } - } -} - -class Program -{ - static Task Main(string[] args) => Deployment.RunAsync(); -} diff --git a/tests/sdk/dotnet/helm/step1/Program.cs b/tests/sdk/dotnet/helm/step1/Program.cs index 35c70326e9..a47be3bd0c 100644 --- a/tests/sdk/dotnet/helm/step1/Program.cs +++ b/tests/sdk/dotnet/helm/step1/Program.cs @@ -7,7 +7,7 @@ using Pulumi; using Pulumi.Kubernetes.Core.V1; using Pulumi.Kubernetes.Helm; -using Pulumi.Kubernetes.Helm.V2; +using Pulumi.Kubernetes.Helm.V3; using Pulumi.Kubernetes.Types.Inputs.Core.V1; using Pulumi.Kubernetes.Yaml; diff --git a/tests/sdk/dotnet/helm/step2/Program.cs b/tests/sdk/dotnet/helm/step2/Program.cs deleted file mode 100644 index a47be3bd0c..0000000000 --- a/tests/sdk/dotnet/helm/step2/Program.cs +++ /dev/null @@ -1,112 +0,0 @@ -// Copyright 2016-2020, Pulumi Corporation. All rights reserved. - -using System; -using System.Collections.Generic; -using System.Collections.Immutable; -using System.Threading.Tasks; -using Pulumi; -using Pulumi.Kubernetes.Core.V1; -using Pulumi.Kubernetes.Helm; -using Pulumi.Kubernetes.Helm.V3; -using Pulumi.Kubernetes.Types.Inputs.Core.V1; -using Pulumi.Kubernetes.Yaml; - -class HelmStack : Stack -{ - public HelmStack() - { - var namespaceTest = new Namespace("test"); - var namespaceName = namespaceTest.Metadata.Apply(n => n.Name); - - var values = new Dictionary - { - ["service"] = new Dictionary - { - ["type"] = "ClusterIP" - }, - }; - var nginx = new Chart("nginx", new ChartArgs - { - Chart = "nginx", - Version = "6.0.4", - Namespace = namespaceName, - Values = values, - FetchOptions = new ChartFetchArgs - { - Repo = "https://raw.githubusercontent.com/bitnami/charts/eb5f9a9513d987b519f0ecd732e7031241c50328/bitnami", - }, - Transformations = - { - LoadBalancerToClusterIP, - StatusToSecret - } - }); - - // Export the (cluster-private) IP address of the Guestbook frontend. - var frontendServiceSpec = namespaceName.Apply(nsName => - nginx.GetResource("nginx", nsName).Apply(s => s.Spec)); - this.FrontendServiceIP = frontendServiceSpec.Apply(p => p.ClusterIP); - - // Test a variety of other inputs on a chart that creates no resources. - var empty1 = new Chart("empty1", new ChartArgs - { - Chart = "https://charts.helm.sh/incubator/packages/raw-0.1.0.tgz" - }); - - var empty2 = new Chart("empty2", new ChartArgs - { - Chart = "raw", - Version = "0.1.0", - FetchOptions = new ChartFetchArgs - { - Home = Environment.GetEnvironmentVariable("HOME"), - Repo = "https://charts.helm.sh/incubator", - } - }); - - var empty3 = new Chart("empty3", new ChartArgs - { - Chart = "raw", - FetchOptions = new ChartFetchArgs - { - Repo = "https://charts.helm.sh/incubator" - } - }); - - // Make every service private to the cluster, i.e., turn all services into ClusterIP instead of - // LoadBalancer. - ImmutableDictionary LoadBalancerToClusterIP(ImmutableDictionary obj, CustomResourceOptions opts) - { - if ((string)obj["kind"] == "Service" && (string)obj["apiVersion"] == "v1") - { - var spec = (ImmutableDictionary)obj["spec"]; - if (spec != null && (string)spec["type"] == "LoadBalancer") - { - return obj.SetItem("spec", spec.SetItem("type", "ClusterIP")); - } - } - - return obj; - } - - // Make every service private to the cluster, i.e., turn all services into ClusterIP instead of - // LoadBalancer. - ImmutableDictionary StatusToSecret(ImmutableDictionary obj, CustomResourceOptions opts) - { - if ((string)obj["kind"] == "Service" && (string)obj["apiVersion"] == "v1") - { - opts.AdditionalSecretOutputs = new List { "status" }; - } - - return obj; - } - } - - [Output] - public Output FrontendServiceIP { get; set; } -} - -class Program -{ - static Task Main(string[] args) => Deployment.RunAsync(); -} diff --git a/tests/sdk/go/go_test.go b/tests/sdk/go/go_test.go index 98517570ba..fa27caab3e 100644 --- a/tests/sdk/go/go_test.go +++ b/tests/sdk/go/go_test.go @@ -1,4 +1,4 @@ -// Copyright 2016-2022, Pulumi Corporation. +// Copyright 2016-2023, Pulumi Corporation. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -106,13 +106,6 @@ func TestGo(t *testing.T) { } } }, - EditDirs: []integration.EditDir{ - { - Dir: filepath.Join(cwd, "helm-local", "step2"), - Additive: true, - ExpectNoChanges: true, - }, - }, }) integration.ProgramTest(t, &options) }) @@ -159,13 +152,6 @@ func TestGo(t *testing.T) { options := baseOptions.With(integration.ProgramTestOptions{ Dir: filepath.Join(cwd, "helm", "step1"), Quick: true, - EditDirs: []integration.EditDir{ - { - Dir: filepath.Join("helm", "step2"), - Additive: true, - ExpectNoChanges: true, - }, - }, }) integration.ProgramTest(t, &options) }) @@ -252,13 +238,6 @@ func TestGo(t *testing.T) { options := baseOptions.With(integration.ProgramTestOptions{ Dir: filepath.Join(cwd, "helm-api-versions", "step1"), Quick: true, - EditDirs: []integration.EditDir{ - { - Dir: filepath.Join("helm-api-versions", "step2"), - Additive: true, - ExpectNoChanges: true, - }, - }, }) integration.ProgramTest(t, &options) }) diff --git a/tests/sdk/go/helm-api-versions/step1/main.go b/tests/sdk/go/helm-api-versions/step1/main.go index ceb5054453..36ed3b2e70 100644 --- a/tests/sdk/go/helm-api-versions/step1/main.go +++ b/tests/sdk/go/helm-api-versions/step1/main.go @@ -2,7 +2,7 @@ package main import ( corev1 "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/core/v1" - "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/helm/v2" + "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/helm/v3" "github.com/pulumi/pulumi/sdk/v3/go/pulumi" ) diff --git a/tests/sdk/go/helm-api-versions/step2/main.go b/tests/sdk/go/helm-api-versions/step2/main.go deleted file mode 100644 index 36ed3b2e70..0000000000 --- a/tests/sdk/go/helm-api-versions/step2/main.go +++ /dev/null @@ -1,36 +0,0 @@ -package main - -import ( - corev1 "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/core/v1" - "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/helm/v3" - "github.com/pulumi/pulumi/sdk/v3/go/pulumi" -) - -func main() { - pulumi.Run(func(ctx *pulumi.Context) error { - namespace, err := corev1.NewNamespace(ctx, "test", nil) - if err != nil { - return err - } - - _, err = helm.NewChart(ctx, "api-versions", helm.ChartArgs{ - APIVersions: pulumi.StringArray{pulumi.String("foo"), pulumi.String("bar")}, - Namespace: namespace.Metadata.Name().Elem(), - Path: pulumi.String("helm-api-versions"), - }) - if err != nil { - return err - } - - _, err = helm.NewChart(ctx, "single-api-version", helm.ChartArgs{ - APIVersions: pulumi.StringArray{pulumi.String("foo")}, - Namespace: namespace.Metadata.Name().Elem(), - Path: pulumi.String("helm-single-api-version"), - }) - if err != nil { - return err - } - - return nil - }) -} diff --git a/tests/sdk/go/helm-local/step1/main.go b/tests/sdk/go/helm-local/step1/main.go index 58b6b3732e..cd26349125 100644 --- a/tests/sdk/go/helm-local/step1/main.go +++ b/tests/sdk/go/helm-local/step1/main.go @@ -2,7 +2,7 @@ package main import ( corev1 "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/core/v1" - "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/helm/v2" + "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/helm/v3" "github.com/pulumi/pulumi/sdk/v3/go/pulumi" ) diff --git a/tests/sdk/go/helm-local/step2/main.go b/tests/sdk/go/helm-local/step2/main.go deleted file mode 100644 index cd26349125..0000000000 --- a/tests/sdk/go/helm-local/step2/main.go +++ /dev/null @@ -1,38 +0,0 @@ -package main - -import ( - corev1 "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/core/v1" - "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/helm/v3" - "github.com/pulumi/pulumi/sdk/v3/go/pulumi" -) - -func main() { - pulumi.Run(func(ctx *pulumi.Context) error { - chart, err := helm.NewChart(ctx, "test", helm.ChartArgs{ - Path: pulumi.String("nginx"), - Values: pulumi.Map{"service": pulumi.StringMap{"type": pulumi.String("ClusterIP")}}, - ResourcePrefix: "prefix", - }) - if err != nil { - return err - } - - svc := chart.GetResource("v1/Service", "prefix-prefix-test-nginx", ""). - ApplyT(func(r any) (any, error) { - svc := r.(*corev1.Service) - return svc.Spec.ClusterIP(), nil - }) - ctx.Export("svc_ip", svc) - - _, err = corev1.NewConfigMap(ctx, "cm", &corev1.ConfigMapArgs{ - Data: pulumi.StringMap{ - "foo": pulumi.String("bar"), - }, - }, pulumi.DependsOnInputs(chart.Ready)) - if err != nil { - return err - } - - return nil - }) -} diff --git a/tests/sdk/go/helm/step1/main.go b/tests/sdk/go/helm/step1/main.go index 96d5f2b957..83bc2930b4 100644 --- a/tests/sdk/go/helm/step1/main.go +++ b/tests/sdk/go/helm/step1/main.go @@ -2,7 +2,7 @@ package main import ( corev1 "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/core/v1" - "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/helm/v2" + "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/helm/v3" "github.com/pulumi/pulumi/sdk/v3/go/pulumi" ) diff --git a/tests/sdk/go/helm/step2/main.go b/tests/sdk/go/helm/step2/main.go deleted file mode 100644 index 83bc2930b4..0000000000 --- a/tests/sdk/go/helm/step2/main.go +++ /dev/null @@ -1,32 +0,0 @@ -package main - -import ( - corev1 "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/core/v1" - "github.com/pulumi/pulumi-kubernetes/sdk/v3/go/kubernetes/helm/v3" - "github.com/pulumi/pulumi/sdk/v3/go/pulumi" -) - -func main() { - pulumi.Run(func(ctx *pulumi.Context) error { - chart, err := helm.NewChart(ctx, "test", helm.ChartArgs{ - Chart: pulumi.String("nginx"), - Version: pulumi.String("6.0.4"), - FetchArgs: &helm.FetchArgs{ - Repo: pulumi.String("https://raw.githubusercontent.com/bitnami/charts/eb5f9a9513d987b519f0ecd732e7031241c50328/bitnami"), - }, - Values: pulumi.Map{"service": pulumi.StringMap{"type": pulumi.String("ClusterIP")}}, - }) - if err != nil { - return err - } - - svc := chart.GetResource("v1/Service", "test-nginx", ""). - ApplyT(func(r any) (any, error) { - svc := r.(*corev1.Service) - return svc.Spec.ClusterIP(), nil - }) - ctx.Export("svc_ip", svc) - - return nil - }) -} diff --git a/tests/sdk/nodejs/examples/examples_test.go b/tests/sdk/nodejs/examples/examples_test.go index 122264466e..7cd541bf96 100644 --- a/tests/sdk/nodejs/examples/examples_test.go +++ b/tests/sdk/nodejs/examples/examples_test.go @@ -1,4 +1,4 @@ -// Copyright 2016-2021, Pulumi Corporation. +// Copyright 2016-2023, Pulumi Corporation. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -182,13 +182,6 @@ func TestAccHelm(t *testing.T) { } } }, - EditDirs: []integration.EditDir{ - { - Dir: filepath.Join(getCwd(t), "helm", "step2"), - Additive: true, - ExpectNoChanges: true, - }, - }, }) integration.ProgramTest(t, &test) @@ -220,13 +213,6 @@ func TestAccHelmApiVersions(t *testing.T) { assert.NotNil(t, stackInfo.Deployment) assert.Equal(t, 7, len(stackInfo.Deployment.Resources)) }, - EditDirs: []integration.EditDir{ - { - Dir: filepath.Join(getCwd(t), "helm-api-versions", "step2"), - Additive: true, - ExpectNoChanges: true, - }, - }, }) integration.ProgramTest(t, &test) @@ -297,13 +283,6 @@ func TestAccHelmLocal(t *testing.T) { } } }, - EditDirs: []integration.EditDir{ - { - Dir: filepath.Join(getCwd(t), "helm-local", "step2"), - Additive: true, - ExpectNoChanges: true, - }, - }, }) integration.ProgramTest(t, &test) diff --git a/tests/sdk/nodejs/examples/helm-api-versions/step1/index.ts b/tests/sdk/nodejs/examples/helm-api-versions/step1/index.ts index 37eb0cd50d..81bb44cc63 100644 --- a/tests/sdk/nodejs/examples/helm-api-versions/step1/index.ts +++ b/tests/sdk/nodejs/examples/helm-api-versions/step1/index.ts @@ -2,13 +2,13 @@ import * as k8s from "@pulumi/kubernetes"; const namespace = new k8s.core.v1.Namespace("test"); -new k8s.helm.v2.Chart("api-versions", { +new k8s.helm.v3.Chart("api-versions", { apiVersions: ["foo", "bar"], namespace: namespace.metadata.name, path: "helm-api-versions", }); -new k8s.helm.v2.Chart("single-api-version", { +new k8s.helm.v3.Chart("single-api-version", { apiVersions: ["foo"], namespace: namespace.metadata.name, path: "helm-single-api-version", diff --git a/tests/sdk/nodejs/examples/helm-api-versions/step2/index.ts b/tests/sdk/nodejs/examples/helm-api-versions/step2/index.ts deleted file mode 100644 index 81bb44cc63..0000000000 --- a/tests/sdk/nodejs/examples/helm-api-versions/step2/index.ts +++ /dev/null @@ -1,15 +0,0 @@ -import * as k8s from "@pulumi/kubernetes"; - -const namespace = new k8s.core.v1.Namespace("test"); - -new k8s.helm.v3.Chart("api-versions", { - apiVersions: ["foo", "bar"], - namespace: namespace.metadata.name, - path: "helm-api-versions", -}); - -new k8s.helm.v3.Chart("single-api-version", { - apiVersions: ["foo"], - namespace: namespace.metadata.name, - path: "helm-single-api-version", -}); diff --git a/tests/sdk/nodejs/examples/helm-local/step1/index.ts b/tests/sdk/nodejs/examples/helm-local/step1/index.ts index 91ecd4293f..5a64a98be8 100644 --- a/tests/sdk/nodejs/examples/helm-local/step1/index.ts +++ b/tests/sdk/nodejs/examples/helm-local/step1/index.ts @@ -18,8 +18,8 @@ import * as pulumi from "@pulumi/pulumi"; const namespace = new k8s.core.v1.Namespace("test"); const namespaceName = namespace.metadata.name; -function chart(resourcePrefix?: string): k8s.helm.v2.Chart { - return new k8s.helm.v2.Chart("nginx", { +function chart(resourcePrefix?: string): k8s.helm.v3.Chart { + return new k8s.helm.v3.Chart("nginx", { path: "nginx", namespace: namespaceName, resourcePrefix: resourcePrefix, diff --git a/tests/sdk/nodejs/examples/helm-local/step2/index.ts b/tests/sdk/nodejs/examples/helm-local/step2/index.ts deleted file mode 100644 index 5a64a98be8..0000000000 --- a/tests/sdk/nodejs/examples/helm-local/step2/index.ts +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2016-2020, Pulumi Corporation. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import * as k8s from "@pulumi/kubernetes"; -import * as pulumi from "@pulumi/pulumi"; - -const namespace = new k8s.core.v1.Namespace("test"); -const namespaceName = namespace.metadata.name; - -function chart(resourcePrefix?: string): k8s.helm.v3.Chart { - return new k8s.helm.v3.Chart("nginx", { - path: "nginx", - namespace: namespaceName, - resourcePrefix: resourcePrefix, - values: { - service: { type: "ClusterIP" } - }, - transformations: [ - (obj: any, opts: pulumi.CustomResourceOptions) => { - if (obj.kind == "Service" && obj.apiVersion == "v1") { - opts.additionalSecretOutputs = ["status"]; - } - } - ] - }); -} - -// Create the first instance of the Chart. -const nginx = chart(); - -// Create a ConfigMap depending on the Chart. The ConfigMap should not be created until after all of the Chart -// resources are ready. -new k8s.core.v1.ConfigMap("foo", { - metadata: { namespace: namespaceName }, - data: {foo: "bar"} -}, {dependsOn: nginx.ready}) - -// Export the (cluster-private) IP address of the Guestbook frontend. -const frontendServiceSpec = pulumi.all([namespaceName, nginx]).apply(([nsName, nginx]) => - nginx.getResourceProperty("v1/Service", nsName, "nginx", "spec")); -export const frontendServiceIP = frontendServiceSpec.clusterIP; - -// Deploy a duplicate chart with a different resource prefix to verify that multiple instances of the Chart -// can be managed in the same stack. -chart("dup"); diff --git a/tests/sdk/nodejs/examples/helm/step1/index.ts b/tests/sdk/nodejs/examples/helm/step1/index.ts index f86d344919..17d717f916 100644 --- a/tests/sdk/nodejs/examples/helm/step1/index.ts +++ b/tests/sdk/nodejs/examples/helm/step1/index.ts @@ -19,7 +19,7 @@ import * as pulumi from "@pulumi/pulumi"; const namespace = new k8s.core.v1.Namespace("test"); const namespaceName = namespace.metadata.name; -const nginx = new k8s.helm.v2.Chart("test", { +const nginx = new k8s.helm.v3.Chart("test", { chart: "nginx", version: "6.0.4", namespace: namespaceName, @@ -45,11 +45,11 @@ const frontendServiceSpec = pulumi.all([namespaceName, nginx]).apply(([nsName, n export const frontendServiceIP = frontendServiceSpec.clusterIP; // Test a variety of other inputs on a chart that creates no resources. -const empty1 = new k8s.helm.v2.Chart("empty1", { +const empty1 = new k8s.helm.v3.Chart("empty1", { chart: "https://charts.helm.sh/incubator/packages/raw-0.1.0.tgz", }); -const empty2 = new k8s.helm.v2.Chart("empty2", { +const empty2 = new k8s.helm.v3.Chart("empty2", { chart: "raw", version: "0.1.0", fetchOpts: { @@ -57,7 +57,7 @@ const empty2 = new k8s.helm.v2.Chart("empty2", { }, }); -const empty3 = new k8s.helm.v2.Chart("empty3", { +const empty3 = new k8s.helm.v3.Chart("empty3", { chart: "raw", fetchOpts: { repo: "https://charts.helm.sh/incubator", diff --git a/tests/sdk/nodejs/examples/helm/step2/index.ts b/tests/sdk/nodejs/examples/helm/step2/index.ts deleted file mode 100644 index 17d717f916..0000000000 --- a/tests/sdk/nodejs/examples/helm/step2/index.ts +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2016-2019, Pulumi Corporation. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import * as k8s from "@pulumi/kubernetes"; -import * as os from "os"; -import * as pulumi from "@pulumi/pulumi"; - -const namespace = new k8s.core.v1.Namespace("test"); -const namespaceName = namespace.metadata.name; - -const nginx = new k8s.helm.v3.Chart("test", { - chart: "nginx", - version: "6.0.4", - namespace: namespaceName, - fetchOpts: { - home: os.homedir(), - repo: "https://raw.githubusercontent.com/bitnami/charts/eb5f9a9513d987b519f0ecd732e7031241c50328/bitnami", - }, - values: { - service: { type: "ClusterIP" } - }, - transformations: [ - (obj: any, opts: pulumi.CustomResourceOptions) => { - if (obj.kind == "Service" && obj.apiVersion == "v1") { - opts.additionalSecretOutputs = ["status"]; - } - } - ] -}); - -// Export the (cluster-private) IP address of the Guestbook frontend. -const frontendServiceSpec = pulumi.all([namespaceName, nginx]).apply(([nsName, nginx]) => - nginx.getResourceProperty("v1/Service", nsName, "test-nginx", "spec")); -export const frontendServiceIP = frontendServiceSpec.clusterIP; - -// Test a variety of other inputs on a chart that creates no resources. -const empty1 = new k8s.helm.v3.Chart("empty1", { - chart: "https://charts.helm.sh/incubator/packages/raw-0.1.0.tgz", -}); - -const empty2 = new k8s.helm.v3.Chart("empty2", { - chart: "raw", - version: "0.1.0", - fetchOpts: { - repo: "https://charts.helm.sh/incubator", - }, -}); - -const empty3 = new k8s.helm.v3.Chart("empty3", { - chart: "raw", - fetchOpts: { - repo: "https://charts.helm.sh/incubator", - }, -}); diff --git a/tests/sdk/python/get-old/step1/requirements.txt b/tests/sdk/python/get-old/step1/requirements.txt index 875bbd5ee3..bc4e43087b 100644 --- a/tests/sdk/python/get-old/step1/requirements.txt +++ b/tests/sdk/python/get-old/step1/requirements.txt @@ -1 +1 @@ -pulumi>=2.0.0,<3.0.0 +pulumi>=3.0.0,<4.0.0 diff --git a/tests/sdk/python/get-one-step/requirements.txt b/tests/sdk/python/get-one-step/requirements.txt index 875bbd5ee3..bc4e43087b 100644 --- a/tests/sdk/python/get-one-step/requirements.txt +++ b/tests/sdk/python/get-one-step/requirements.txt @@ -1 +1 @@ -pulumi>=2.0.0,<3.0.0 +pulumi>=3.0.0,<4.0.0 diff --git a/tests/sdk/python/get/step1/requirements.txt b/tests/sdk/python/get/step1/requirements.txt index 875bbd5ee3..bc4e43087b 100644 --- a/tests/sdk/python/get/step1/requirements.txt +++ b/tests/sdk/python/get/step1/requirements.txt @@ -1 +1 @@ -pulumi>=2.0.0,<3.0.0 +pulumi>=3.0.0,<4.0.0 diff --git a/tests/sdk/python/guestbook-old/requirements.txt b/tests/sdk/python/guestbook-old/requirements.txt index 875bbd5ee3..bc4e43087b 100644 --- a/tests/sdk/python/guestbook-old/requirements.txt +++ b/tests/sdk/python/guestbook-old/requirements.txt @@ -1 +1 @@ -pulumi>=2.0.0,<3.0.0 +pulumi>=3.0.0,<4.0.0 diff --git a/tests/sdk/python/guestbook/requirements.txt b/tests/sdk/python/guestbook/requirements.txt index 875bbd5ee3..bc4e43087b 100644 --- a/tests/sdk/python/guestbook/requirements.txt +++ b/tests/sdk/python/guestbook/requirements.txt @@ -1 +1 @@ -pulumi>=2.0.0,<3.0.0 +pulumi>=3.0.0,<4.0.0 diff --git a/tests/sdk/python/helm-api-versions/step1/__main__.py b/tests/sdk/python/helm-api-versions/step1/__main__.py index cef665d149..572bf9efc0 100644 --- a/tests/sdk/python/helm-api-versions/step1/__main__.py +++ b/tests/sdk/python/helm-api-versions/step1/__main__.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. from pulumi_kubernetes.core.v1 import Namespace -from pulumi_kubernetes.helm.v2 import Chart, LocalChartOpts +from pulumi_kubernetes.helm.v3 import Chart, LocalChartOpts namespace = Namespace("test") diff --git a/tests/sdk/python/helm-api-versions/step1/requirements.txt b/tests/sdk/python/helm-api-versions/step1/requirements.txt index 875bbd5ee3..bc4e43087b 100644 --- a/tests/sdk/python/helm-api-versions/step1/requirements.txt +++ b/tests/sdk/python/helm-api-versions/step1/requirements.txt @@ -1 +1 @@ -pulumi>=2.0.0,<3.0.0 +pulumi>=3.0.0,<4.0.0 diff --git a/tests/sdk/python/helm-api-versions/step2/__main__.py b/tests/sdk/python/helm-api-versions/step2/__main__.py deleted file mode 100644 index 572bf9efc0..0000000000 --- a/tests/sdk/python/helm-api-versions/step2/__main__.py +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright 2016-2020, Pulumi Corporation. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -from pulumi_kubernetes.core.v1 import Namespace -from pulumi_kubernetes.helm.v3 import Chart, LocalChartOpts - -namespace = Namespace("test") - -Chart("api-versions", LocalChartOpts( - api_versions=["foo", "bar"], - namespace=namespace.metadata["name"], - path="helm-api-versions", -)) - -Chart("single-api-version", LocalChartOpts( - api_versions=["foo"], - namespace=namespace.metadata["name"], - path="helm-single-api-version", -)) diff --git a/tests/sdk/python/helm-local/step1/__main__.py b/tests/sdk/python/helm-local/step1/__main__.py index a14ea1f6bf..d9f8128e60 100644 --- a/tests/sdk/python/helm-local/step1/__main__.py +++ b/tests/sdk/python/helm-local/step1/__main__.py @@ -14,7 +14,7 @@ import pulumi from pulumi_kubernetes.core.v1 import ConfigMap, ConfigMapInitArgs -from pulumi_kubernetes.helm.v2 import Chart, LocalChartOpts +from pulumi_kubernetes.helm.v3 import Chart, LocalChartOpts values = {"service": {"type": "ClusterIP"}} diff --git a/tests/sdk/python/helm-local/step2/__main__.py b/tests/sdk/python/helm-local/step2/__main__.py deleted file mode 100644 index d9f8128e60..0000000000 --- a/tests/sdk/python/helm-local/step2/__main__.py +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright 2016-2021, Pulumi Corporation. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import pulumi -from pulumi_kubernetes.core.v1 import ConfigMap, ConfigMapInitArgs -from pulumi_kubernetes.helm.v3 import Chart, LocalChartOpts - -values = {"service": {"type": "ClusterIP"}} - -chart = Chart("nginx", LocalChartOpts(path="nginx", values=values)) -foo = ConfigMap("foo", ConfigMapInitArgs(data={"foo": "bar"}), opts=pulumi.ResourceOptions(depends_on=chart.ready)) - -# Deploy a duplicate chart with a different resource prefix to verify that multiple instances of the Chart -# can be managed in the same stack. -Chart("nginx", LocalChartOpts(path="nginx", resource_prefix="dup", values=values)) diff --git a/tests/sdk/python/helm-release/step1/requirements.txt b/tests/sdk/python/helm-release/step1/requirements.txt index 15faefbb5c..77e5cee933 100644 --- a/tests/sdk/python/helm-release/step1/requirements.txt +++ b/tests/sdk/python/helm-release/step1/requirements.txt @@ -1,2 +1,2 @@ pulumi>=3.0.0,<4.0.0 -pulumi_random>=3.0.0 +pulumi_random>=4.0.0,<5.0.0 diff --git a/tests/sdk/python/helm-skip-crd-rendering/step1/requirements.txt b/tests/sdk/python/helm-skip-crd-rendering/step1/requirements.txt index 875bbd5ee3..bc4e43087b 100644 --- a/tests/sdk/python/helm-skip-crd-rendering/step1/requirements.txt +++ b/tests/sdk/python/helm-skip-crd-rendering/step1/requirements.txt @@ -1 +1 @@ -pulumi>=2.0.0,<3.0.0 +pulumi>=3.0.0,<4.0.0 diff --git a/tests/sdk/python/helm/step1/__main__.py b/tests/sdk/python/helm/step1/__main__.py index 40afcdcd79..286c30d309 100644 --- a/tests/sdk/python/helm/step1/__main__.py +++ b/tests/sdk/python/helm/step1/__main__.py @@ -14,7 +14,7 @@ from os.path import expanduser from pulumi_kubernetes.core.v1 import Namespace -from pulumi_kubernetes.helm.v2 import Chart, ChartOpts, FetchOpts +from pulumi_kubernetes.helm.v3 import Chart, ChartOpts, FetchOpts from pulumi_random import RandomString namespace = Namespace("test") diff --git a/tests/sdk/python/helm/step1/requirements.txt b/tests/sdk/python/helm/step1/requirements.txt index 2a48504026..77e5cee933 100644 --- a/tests/sdk/python/helm/step1/requirements.txt +++ b/tests/sdk/python/helm/step1/requirements.txt @@ -1,2 +1,2 @@ -pulumi>=2.0.0,<3.0.0 -pulumi_random>=2.1.1 +pulumi>=3.0.0,<4.0.0 +pulumi_random>=4.0.0,<5.0.0 diff --git a/tests/sdk/python/helm/step2/__main__.py b/tests/sdk/python/helm/step2/__main__.py deleted file mode 100644 index 286c30d309..0000000000 --- a/tests/sdk/python/helm/step2/__main__.py +++ /dev/null @@ -1,53 +0,0 @@ -# Copyright 2016-2019, Pulumi Corporation. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -from os.path import expanduser - -from pulumi_kubernetes.core.v1 import Namespace -from pulumi_kubernetes.helm.v3 import Chart, ChartOpts, FetchOpts -from pulumi_random import RandomString - -namespace = Namespace("test") - -rs = RandomString("random-string", length=8).result - -values = {"service": {"type": "ClusterIP"}, "random-string": rs} - -Chart( - "remote-chart", - ChartOpts( - chart="nginx", - fetch_opts=FetchOpts( - home=expanduser("~"), - repo="https://raw.githubusercontent.com/bitnami/charts/eb5f9a9513d987b519f0ecd732e7031241c50328/bitnami" - ), - namespace=namespace.metadata["name"], - values={"service": {"type": "ClusterIP"}}, - version="6.0.4", - )) - -# Deploy a duplicate chart with a different resource prefix to verify that multiple instances of the Chart -# can be managed in the same stack. -Chart( - "remote-chart", - ChartOpts( - chart="nginx", - resource_prefix="dup", - fetch_opts=FetchOpts( - home=expanduser("~"), - repo="https://raw.githubusercontent.com/bitnami/charts/eb5f9a9513d987b519f0ecd732e7031241c50328/bitnami" - ), - namespace=namespace.metadata["name"], - values={"service": {"type": "ClusterIP"}}, - version="6.0.4", - )) diff --git a/tests/sdk/python/kustomize/requirements.txt b/tests/sdk/python/kustomize/requirements.txt index 875bbd5ee3..bc4e43087b 100644 --- a/tests/sdk/python/kustomize/requirements.txt +++ b/tests/sdk/python/kustomize/requirements.txt @@ -1 +1 @@ -pulumi>=2.0.0,<3.0.0 +pulumi>=3.0.0,<4.0.0 diff --git a/tests/sdk/python/provider-old/requirements.txt b/tests/sdk/python/provider-old/requirements.txt index 875bbd5ee3..bc4e43087b 100644 --- a/tests/sdk/python/provider-old/requirements.txt +++ b/tests/sdk/python/provider-old/requirements.txt @@ -1 +1 @@ -pulumi>=2.0.0,<3.0.0 +pulumi>=3.0.0,<4.0.0 diff --git a/tests/sdk/python/provider/requirements.txt b/tests/sdk/python/provider/requirements.txt index 875bbd5ee3..bc4e43087b 100644 --- a/tests/sdk/python/provider/requirements.txt +++ b/tests/sdk/python/provider/requirements.txt @@ -1 +1 @@ -pulumi>=2.0.0,<3.0.0 +pulumi>=3.0.0,<4.0.0 diff --git a/tests/sdk/python/python_test.go b/tests/sdk/python/python_test.go index 306c8e4da7..d633c84121 100644 --- a/tests/sdk/python/python_test.go +++ b/tests/sdk/python/python_test.go @@ -346,20 +346,12 @@ func TestProvider(t *testing.T) { } func TestHelm(t *testing.T) { - t.Skip("Temp skipping") cwd, err := os.Getwd() if !assert.NoError(t, err) { t.FailNow() } options := baseOptions.With(integration.ProgramTestOptions{ Dir: filepath.Join(cwd, "helm", "step1"), - EditDirs: []integration.EditDir{ - { - Dir: filepath.Join(cwd, "helm", "step2"), - Additive: true, - ExpectNoChanges: true, - }, - }, }) integration.ProgramTest(t, &options) } @@ -417,13 +409,6 @@ func TestHelmLocal(t *testing.T) { } } }, - EditDirs: []integration.EditDir{ - { - Dir: filepath.Join(cwd, "helm-local", "step2"), - Additive: true, - ExpectNoChanges: true, - }, - }, }) integration.ProgramTest(t, &options) } @@ -435,13 +420,6 @@ func TestHelmApiVersions(t *testing.T) { } options := baseOptions.With(integration.ProgramTestOptions{ Dir: filepath.Join(cwd, "helm-api-versions", "step1"), - EditDirs: []integration.EditDir{ - { - Dir: filepath.Join(cwd, "helm-api-versions", "step2"), - Additive: true, - ExpectNoChanges: true, - }, - }, }) integration.ProgramTest(t, &options) } diff --git a/tests/sdk/python/smoke-test-old/requirements.txt b/tests/sdk/python/smoke-test-old/requirements.txt index 875bbd5ee3..bc4e43087b 100644 --- a/tests/sdk/python/smoke-test-old/requirements.txt +++ b/tests/sdk/python/smoke-test-old/requirements.txt @@ -1 +1 @@ -pulumi>=2.0.0,<3.0.0 +pulumi>=3.0.0,<4.0.0 diff --git a/tests/sdk/python/smoke-test/requirements.txt b/tests/sdk/python/smoke-test/requirements.txt index 875bbd5ee3..bc4e43087b 100644 --- a/tests/sdk/python/smoke-test/requirements.txt +++ b/tests/sdk/python/smoke-test/requirements.txt @@ -1 +1 @@ -pulumi>=2.0.0,<3.0.0 +pulumi>=3.0.0,<4.0.0 diff --git a/tests/sdk/python/yaml-test/requirements.txt b/tests/sdk/python/yaml-test/requirements.txt index 875bbd5ee3..bc4e43087b 100644 --- a/tests/sdk/python/yaml-test/requirements.txt +++ b/tests/sdk/python/yaml-test/requirements.txt @@ -1 +1 @@ -pulumi>=2.0.0,<3.0.0 +pulumi>=3.0.0,<4.0.0