Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add C# usage examples for Helm, YAML, and Kustomize #1213

Merged
merged 3 commits into from
Jul 23, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- Add Python usage examples for Helm, Kustomize, and YAML resources. (https://github.com/pulumi/pulumi-kubernetes/pull/1209)
- Add v3 Helm package for Go SDK. (https://github.com/pulumi/pulumi-kubernetes/pull/1211)
- Add Go usage examples for Helm, Kustomize, and YAML resources. (https://github.com/pulumi/pulumi-kubernetes/pull/1212)
- Add C# usage examples for Helm, Kustomize, and YAML resources. (https://github.com/pulumi/pulumi-kubernetes/pull/1213)

## 2.4.0 (July 7, 2020)

Expand Down
2 changes: 2 additions & 0 deletions provider/cmd/pulumi-gen-kubernetes/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,8 @@ func writeDotnetClient(pkg *schema.Package, outdir, templateDir string) {
"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")),
"Kustomize/Directory.cs": mustLoadFile(filepath.Join(templateDir, "kustomize", "Directory.cs")),
"Kustomize/Invokes.cs": mustLoadFile(filepath.Join(templateDir, "kustomize", "Invokes.cs")),
"Yaml/ConfigFile.cs": mustLoadFile(filepath.Join(templateDir, "yaml", "ConfigFile.cs")),
"Yaml/ConfigGroup.cs": mustLoadFile(filepath.Join(templateDir, "yaml", "ConfigGroup.cs")),
"Yaml/Invokes.cs": mustLoadFile(filepath.Join(templateDir, "yaml", "Invokes.cs")),
Expand Down
91 changes: 0 additions & 91 deletions provider/pkg/gen/dotnet-templates/Kustomize/Directory.cs

This file was deleted.

187 changes: 187 additions & 0 deletions provider/pkg/gen/dotnet-templates/helm/v2/Chart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,193 @@ namespace Pulumi.Kubernetes.Helm.V2
/// 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, dynamic>
lblackstone marked this conversation as resolved.
Show resolved Hide resolved
/// {
/// ["controller"] = new Dictionary<string, dynamic>
/// {
/// ["metrics"] = new Dictionary<string, dynamic>
/// {
/// ["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")
lblackstone marked this conversation as resolved.
Show resolved Hide resolved
/// {
/// 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 = new List<Input<Alias>> { new Alias { Name = "oldName" } };
lblackstone marked this conversation as resolved.
Show resolved Hide resolved
/// }
///
/// 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;
/// }
/// }
/// }
/// ```
/// </summary>
public sealed class Chart : ChartBase
{
Expand Down
Loading