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 .NET tfgen #121

Merged
merged 5 commits into from
Dec 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## HEAD (Unreleased)

* Add Terraform resources to .NET SDK ([#121](https://github.com/pulumi/pulumi-docker/pull/121)).

## 1.0.0 (2019-12-06)
* Regenerate SDK against tf2pulumi 0.6.0
* Add ability to skip push on image build
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ TESTPARALLELISM := 4
build::
go install -ldflags "-X github.com/pulumi/pulumi-docker/pkg/version.Version=${VERSION}" ${PROJECT}/cmd/${TFGEN}
go install -ldflags "-X github.com/pulumi/pulumi-docker/pkg/version.Version=${VERSION}" ${PROJECT}/cmd/${PROVIDER}
for LANGUAGE in "nodejs" "python" "go" ; do \
for LANGUAGE in "nodejs" "python" "go" "dotnet" ; do \
$(TFGEN) $$LANGUAGE --overlays overlays/$$LANGUAGE/ --out ${PACKDIR}/$$LANGUAGE/ || exit 3 ; \
done
cd ${PACKDIR}/nodejs/ && \
Expand Down
15 changes: 15 additions & 0 deletions examples/examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,21 @@ func TestNginxPy(t *testing.T) {
integration.ProgramTest(t, &opts)
}

func TestNginxCs(t *testing.T) {
cwd, err := os.Getwd()
if !assert.NoError(t, err) {
t.FailNow()
}

opts := base.With(integration.ProgramTestOptions{
Dependencies: []string{
"Pulumi.Docker",
},
Dir: path.Join(cwd, "nginx-cs"),
})
integration.ProgramTest(t, &opts)
}

func TestDotNet(t *testing.T) {
cwd, err := os.Getwd()
if !assert.NoError(t, err) {
Expand Down
9 changes: 9 additions & 0 deletions examples/nginx-cs/NginxDocker.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
48 changes: 48 additions & 0 deletions examples/nginx-cs/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using System.Collections.Generic;
using System.Threading.Tasks;

using Pulumi;
using Pulumi.Docker;
using Pulumi.Docker.Inputs;

class Program
{
static Task<int> Main()
{
return Deployment.RunAsync(() =>
{
// Get a reference to the remote image "nginx:1.15.6". Without specifying the repository, the Docker provider will
// try to download it from the public Docker Hub.
var remoteImage = new RemoteImage("nginx-image", new RemoteImageArgs
{
Name = "nginx:1.15.6",
KeepLocally = true, // don't delete the image from the local cache when deleting this resource
});

// Launch a container using the nginx image we just downloaded.
var container = new Container("nginx", new ContainerArgs
{
Image = remoteImage.Name,
Ports =
{
new ContainerPortsArgs
{
Internal = 80,
// external: defaults to an open ephemeral port
// protocol: defaults to TCP
// ip: defaults to 0.0.0.0
},
},
});

var endpoints = container.Ports.Apply(ports => $"{ports![0].Ip}:{ports![0].External}");
return new Dictionary<string, object?>
{
// Since the container is auto-named, export the name.
{ "name", container.Name },
// Since the provider picked a random ephemeral port for this container, export the endpoint.
{ "endpoints", endpoints },
};
});
}
}
3 changes: 3 additions & 0 deletions examples/nginx-cs/Pulumi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name: nginx-cs
description: "Nginx Docker image"
runtime: dotnet
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/opencontainers/image-spec v1.0.1 // indirect
github.com/pkg/errors v0.8.1
github.com/pulumi/pulumi v1.6.2-0.20191205121639-7b3ec744f467
github.com/pulumi/pulumi-terraform-bridge v1.4.2
github.com/pulumi/pulumi-terraform-bridge v1.5.3-0.20191213094732-8f69405b5c5c
github.com/stretchr/testify v1.4.1-0.20191106224347-f1bd0923b832
github.com/terraform-providers/terraform-provider-docker v1.2.1-0.20191125182715-0de84e769ddc
github.com/vmihailenco/msgpack v4.0.1+incompatible // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -409,8 +409,8 @@ github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R
github.com/pulumi/pulumi v1.6.0/go.mod h1:gJBsD+SkjIhWRWPY+0ID9QM6sngLsMGQH8KiknlH0lU=
github.com/pulumi/pulumi v1.6.2-0.20191205121639-7b3ec744f467 h1:gaSct0YDP8ki2lCAc/3c5C3AVZPYykgvOiy+QzMgd04=
github.com/pulumi/pulumi v1.6.2-0.20191205121639-7b3ec744f467/go.mod h1:wWGvPIg2xvpYNJbIWjJsusLEBpApiR/Yp3FMhUMxp9I=
github.com/pulumi/pulumi-terraform-bridge v1.4.2 h1:S2iRH7ZHR2AY+XLt4i84is3fovBmNTxHB0FmdM6isQs=
github.com/pulumi/pulumi-terraform-bridge v1.4.2/go.mod h1:dSbi1sxIj9D4VYdX+HEWCUkPEsh4hAj6pKhXC4Z9FzE=
github.com/pulumi/pulumi-terraform-bridge v1.5.3-0.20191213094732-8f69405b5c5c h1:KQ5iIL+K4j3xhWQCRai+XlkxKIxQFdUHE/V44/1UpZs=
github.com/pulumi/pulumi-terraform-bridge v1.5.3-0.20191213094732-8f69405b5c5c/go.mod h1:dSbi1sxIj9D4VYdX+HEWCUkPEsh4hAj6pKhXC4Z9FzE=
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
github.com/reconquest/loreley v0.0.0-20160708080500-2ab6b7470a54/go.mod h1:1NF/j951kWm+ZnRXpOkBqweImgwhlzFVwTA4A0V7TEU=
github.com/rjeczalik/notify v0.9.2 h1:MiTWrPj55mNDHEiIX5YUSKefw/+lCQVoAFmD6oQm5w8=
Expand Down
21 changes: 20 additions & 1 deletion resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@ func Provider() tfbridge.ProviderInfo {
},
},
Resources: map[string]*tfbridge.ResourceInfo{
"docker_config": {Tok: dockerResource(dockerMod, "Config")},
"docker_config": {
Tok: dockerResource(dockerMod, "Config"),
CSharpName: "ServiceConfig",
},
"docker_container": {
Tok: dockerResource(dockerMod, "Container"),
DeleteBeforeReplace: true,
Expand Down Expand Up @@ -144,6 +147,22 @@ func Provider() tfbridge.ProviderInfo {
"pulumi": ">=1.0.0,<2.0.0",
},
},
CSharp: &tfbridge.CSharpInfo{
PackageReferences: map[string]string{
"Pulumi": "1.7.0-preview",
"Semver": "2.0.5",
"System.Collections.Immutable": "1.6.0",
},
Namespaces: map[string]string{
dockerPkg: "Docker",
},
Overlay: &tfbridge.OverlayInfo{
DestFiles: []string{
"Docker.cs",
"Image.cs",
},
},
},
}

// For all resources with name properties, we will add an auto-name property. Make sure to skip those that
Expand Down
51 changes: 51 additions & 0 deletions sdk/dotnet/Config/Config.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***

using System.Collections.Immutable;

namespace Pulumi.Docker
{
public static class Config
{
private static readonly Pulumi.Config __config = new Pulumi.Config("docker");

/// <summary>
/// PEM-encoded content of Docker host CA certificate
/// </summary>
public static string? CaMaterial { get; set; } = __config.Get("caMaterial") ?? Utilities.GetEnv("DOCKER_CA_MATERIAL");

/// <summary>
/// PEM-encoded content of Docker client certificate
/// </summary>
public static string? CertMaterial { get; set; } = __config.Get("certMaterial") ?? Utilities.GetEnv("DOCKER_CERT_MATERIAL");

/// <summary>
/// Path to directory with Docker TLS config
/// </summary>
public static string? CertPath { get; set; } = __config.Get("certPath") ?? Utilities.GetEnv("DOCKER_CERT_PATH");

/// <summary>
/// The Docker daemon address
/// </summary>
public static string? Host { get; set; } = __config.Get("host") ?? Utilities.GetEnv("DOCKER_HOST") ?? "unix:///var/run/docker.sock";

/// <summary>
/// PEM-encoded content of Docker client private key
/// </summary>
public static string? KeyMaterial { get; set; } = __config.Get("keyMaterial") ?? Utilities.GetEnv("DOCKER_KEY_MATERIAL");

public static ImmutableArray<ConfigTypes.RegistryAuth> RegistryAuth { get; set; } = __config.GetObject<ImmutableArray<ConfigTypes.RegistryAuth>>("registryAuth");

}
namespace ConfigTypes
{

public class RegistryAuth
{
public string Address { get; set; } = null!;
public string? ConfigFile { get; set; }
public string? Password { get; set; }
public string? Username { get; set; }
}
}
}
4 changes: 4 additions & 0 deletions sdk/dotnet/Config/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
> This provider is a derived work of the [Terraform Provider](https://github.com/terraform-providers/terraform-provider-docker)
> distributed under [MPL 2.0](https://www.mozilla.org/en-US/MPL/2.0/). If you encounter a bug or missing feature,
> first check the [`pulumi/pulumi-docker` repo](https://github.com/pulumi/pulumi-docker/issues); however, if that doesn't turn up anything,
> please consult the source [`terraform-providers/terraform-provider-docker` repo](https://github.com/terraform-providers/terraform-provider-docker/issues).
Loading