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

Ensure that #170 doesn't regress #533

Closed
wants to merge 1 commit into from
Closed
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
10 changes: 10 additions & 0 deletions examples/examples_nodejs_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright 2016-2020, Pulumi Corporation. All rights reserved.
//go:build nodejs || all
// +build nodejs all

package examples
Expand All @@ -19,6 +20,15 @@ func TestNetworkTs(t *testing.T) {
integration.ProgramTest(t, &test)
}

func TestServerTs(t *testing.T) {
test := getJSBaseOptions(t).
With(integration.ProgramTestOptions{
Dir: path.Join(getCwd(t), "server", "ts"),
})

integration.ProgramTest(t, &test)
}

func getJSBaseOptions(t *testing.T) integration.ProgramTestOptions {
base := getBaseOptions(t)
baseJS := base.With(integration.ProgramTestOptions{
Expand Down
121 changes: 0 additions & 121 deletions examples/regress_170_test.go

This file was deleted.

2 changes: 2 additions & 0 deletions examples/server/ts/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/bin/
/node_modules/
3 changes: 3 additions & 0 deletions examples/server/ts/Pulumi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name: server-ts
runtime: nodejs
description: A minimal TypeScript Pulumi program
18 changes: 18 additions & 0 deletions examples/server/ts/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import * as hcloud from "@pulumi/hcloud";

const network = new hcloud.Network("network", {
ipRange: "10.0.1.0/24",
});

const subnet = new hcloud.NetworkSubnet("subnet", {
networkId: network.id.apply(Number),
ipRange: "10.0.1.0/24",
networkZone: "eu-central",
type: "cloud",
});

new hcloud.Server("server", {
serverType: "cx11",
image: "ubuntu-22.04",
networks: [{ networkId: network.id.apply(Number) }],
}, {dependsOn: subnet});
12 changes: 12 additions & 0 deletions examples/server/ts/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "server-ts",
"devDependencies": {
"@types/node": "^10.0.0"
},
"dependencies": {
"@pulumi/pulumi": "^3.0.0"
},
"peerDependencies": {
"@pulumi/hcloud": "dev"
}
}
18 changes: 18 additions & 0 deletions examples/server/ts/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"compilerOptions": {
"strict": true,
"outDir": "bin",
"target": "es2016",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"experimentalDecorators": true,
"pretty": true,
"noFallthroughCasesInSwitch": true,
"noImplicitReturns": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.ts"
]
}
29 changes: 29 additions & 0 deletions provider/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge"
tks "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge/tokens"
shimv2 "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim/sdk-v2"
"github.com/pulumi/pulumi/sdk/v3/go/common/resource"

"github.com/pulumi/pulumi-hcloud/provider/pkg/version"
)
Expand Down Expand Up @@ -65,6 +66,34 @@ func Provider() tfbridge.ProviderInfo {
},
},
},
"hcloud_server": {
// Work around
// https://github.com/hetznercloud/terraform-provider-hcloud/issues/650
// by applying the fix described in
// https://github.com/hetznercloud/terraform-provider-hcloud/issues/650#issuecomment-1497160625.
PreCheckCallback: func(
ctx context.Context, config resource.PropertyMap, _ resource.PropertyMap,
) (resource.PropertyMap, error) {
const debug = "Fixing up for https://github.com/hetznercloud/terraform-provider-hcloud/issues/650"
networksProp, ok := config["networks"]
if !ok || !networksProp.IsArray() {
return config, nil
}
networks := networksProp.ArrayValue()
for _, networkProp := range networks {
if !networkProp.IsObject() {
continue
}
const aliasIps = "aliasIps"
network := networkProp.ObjectValue()
if _, ok := network[aliasIps]; !ok {
tfbridge.GetLogger(ctx).Debug(debug)
network[aliasIps] = resource.NewProperty([]resource.PropertyValue{})
}
}
return config, nil
},
},
},
JavaScript: &tfbridge.JavaScriptInfo{
// List any npm dependencies and their versions
Expand Down
Loading