Skip to content

Commit

Permalink
Ensure that #170 doesn't regress
Browse files Browse the repository at this point in the history
Fixes #582

I have removed the diff replay test since it doesn't capture the issue anymore. I have
replaced this with an integration test since we need to ensure that "Check" behaves such
that diff doesn't present an issue.
  • Loading branch information
iwahbe committed Jun 12, 2024
1 parent 3c03f97 commit 456fcca
Show file tree
Hide file tree
Showing 8 changed files with 91 additions and 121 deletions.
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"
]
}
28 changes: 28 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,33 @@ 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, meta resource.PropertyMap,
) (resource.PropertyMap, error) {
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("Fixing up for https://github.com/hetznercloud/terraform-provider-hcloud/issues/650")
network[aliasIps] = resource.NewProperty([]resource.PropertyValue{})
}
}
return config, nil
},
},
},
JavaScript: &tfbridge.JavaScriptInfo{
// List any npm dependencies and their versions
Expand Down

0 comments on commit 456fcca

Please sign in to comment.