Skip to content

Commit

Permalink
Kubernetes provider (#897)
Browse files Browse the repository at this point in the history
Add a provider resource to the .NET SDK
  • Loading branch information
mikhailshilkov authored and Luke Hoban committed Nov 27, 2019
1 parent 2fe9d0f commit b6bcc41
Show file tree
Hide file tree
Showing 5 changed files with 166 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
**/bin/
**/obj/
**/node_modules/
**/.vs
.pulumi
Pulumi.*.yaml
/pkg/gen/openapi-specs
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
- v1.15.x
- v1.14.x

### Improvements

- Add `Provider` for .NET. (https://github.com/pulumi/pulumi-kubernetes/pull/897)

## 1.3.2 (November 26, 2019)

### Supported Kubernetes versions
Expand Down
5 changes: 5 additions & 0 deletions cmd/pulumi-gen-kubernetes/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,11 @@ func writeDotnetClient(data map[string]interface{}, outdir, templateDir string)
panic(err)
}

err = CopyFile(filepath.Join(templateDir, "Provider.cs"), filepath.Join(outdir, "Provider.cs"))
if err != nil {
panic(err)
}

err = CopyFile(filepath.Join(templateDir, "logo.png"), filepath.Join(outdir, "logo.png"))
if err != nil {
panic(err)
Expand Down
78 changes: 78 additions & 0 deletions pkg/gen/dotnet-templates/Provider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
using Pulumi.Serialization;

namespace Pulumi.Kubernetes
{
/// <summary>
/// The provider type for the kubernetes package.
/// </summary>
public class Provider : ProviderResource
{
/// <summary>
/// Create a Provider resource with the given unique name, arguments, and options.
/// </summary>
///
/// <param name="name">The unique name of the resource.</param>
/// <param name="args">The arguments used to populate this resource's properties.</param>
/// <param name="options">A bag of options that control this resource's behavior.</param>
public Provider(string name, ProviderArgs? args = null, ResourceOptions? options = null)
: base("kubernetes", name, args ?? ResourceArgs.Empty, MakeResourceOptions(options, ""))
{
}

private static ResourceOptions MakeResourceOptions(ResourceOptions? options, Input<string>? id)
{
var defaultOptions = new ResourceOptions
{
Version = Utilities.Version,
};
var merged = ResourceOptions.Merge(defaultOptions, options);
// Override the ID if one was specified for consistency with other language SDKs.
merged.Id = id ?? merged.Id;
return merged;
}
}

/// <summary>
/// The set of arguments for constructing a Provider.
/// </summary>
public sealed class ProviderArgs : ResourceArgs
{
/// <summary>
/// If present, the name of the kubeconfig cluster to use.
/// </summary>
[Input("cluster")]
public Input<string>? Cluster { get; set; }

/// <summary>
/// If present, the name of the kubeconfig context to use.
/// </summary>
[Input("context")]
public Input<string>? Context { get; set; }

/// <summary>
/// The contents of a kubeconfig file. If this is set, this config will be used instead of $KUBECONFIG.
/// </summary>
[Input("kubeconfig")]
public Input<string>? KubeConfig { get; set; }

/// <summary>
/// If present, the default namespace to use. This flag is ignored for cluster-scoped resources.
/// Note: if .metadata.namespace is set on a resource, that value takes precedence over the provider default.
/// </summary>
[Input("namespace")]
public Input<string>? Namespace { get; set; }

/// <summary>
/// BETA FEATURE - If present and set to true, enable server-side diff calculations.
/// This feature is in developer preview, and is disabled by default.
/// </summary>
[Input("enableDryRun")]
public Input<bool>? EnableDryRun { get; set; }

/// <summary>
/// If present and set to true, suppress apiVersion deprecation warnings from the CLI.
/// </summary>
[Input("suppressDeprecationWarnings")]
public Input<bool>? SuppressDeprecationWarnings { get; set; }
}
}
78 changes: 78 additions & 0 deletions sdk/dotnet/Provider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
using Pulumi.Serialization;

namespace Pulumi.Kubernetes
{
/// <summary>
/// The provider type for the kubernetes package.
/// </summary>
public class Provider : ProviderResource
{
/// <summary>
/// Create a Provider resource with the given unique name, arguments, and options.
/// </summary>
///
/// <param name="name">The unique name of the resource.</param>
/// <param name="args">The arguments used to populate this resource's properties.</param>
/// <param name="options">A bag of options that control this resource's behavior.</param>
public Provider(string name, ProviderArgs? args = null, ResourceOptions? options = null)
: base("kubernetes", name, args ?? ResourceArgs.Empty, MakeResourceOptions(options, ""))
{
}

private static ResourceOptions MakeResourceOptions(ResourceOptions? options, Input<string>? id)
{
var defaultOptions = new ResourceOptions
{
Version = Utilities.Version,
};
var merged = ResourceOptions.Merge(defaultOptions, options);
// Override the ID if one was specified for consistency with other language SDKs.
merged.Id = id ?? merged.Id;
return merged;
}
}

/// <summary>
/// The set of arguments for constructing a Provider.
/// </summary>
public sealed class ProviderArgs : ResourceArgs
{
/// <summary>
/// If present, the name of the kubeconfig cluster to use.
/// </summary>
[Input("cluster")]
public Input<string>? Cluster { get; set; }

/// <summary>
/// If present, the name of the kubeconfig context to use.
/// </summary>
[Input("context")]
public Input<string>? Context { get; set; }

/// <summary>
/// The contents of a kubeconfig file. If this is set, this config will be used instead of $KUBECONFIG.
/// </summary>
[Input("kubeconfig")]
public Input<string>? KubeConfig { get; set; }

/// <summary>
/// If present, the default namespace to use. This flag is ignored for cluster-scoped resources.
/// Note: if .metadata.namespace is set on a resource, that value takes precedence over the provider default.
/// </summary>
[Input("namespace")]
public Input<string>? Namespace { get; set; }

/// <summary>
/// BETA FEATURE - If present and set to true, enable server-side diff calculations.
/// This feature is in developer preview, and is disabled by default.
/// </summary>
[Input("enableDryRun")]
public Input<bool>? EnableDryRun { get; set; }

/// <summary>
/// If present and set to true, suppress apiVersion deprecation warnings from the CLI.
/// </summary>
[Input("suppressDeprecationWarnings")]
public Input<bool>? SuppressDeprecationWarnings { get; set; }
}
}

0 comments on commit b6bcc41

Please sign in to comment.