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

Update tfpf to v0.21 #15

Merged
merged 1 commit into from
Dec 14, 2023
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
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
# limitations under the License.

# Terraform provider version
PROVIDER_VERSION=1.5.0
PROVIDER_VERSION=1.6.0

# Pulumi bridged provider version (this package)
VERSION=1.5.4
VERSION=1.6.0

default: build

Expand All @@ -42,7 +42,8 @@ sdk.nodejs:
-e 's/$${PROVIDER_VERSION}/${PROVIDER_VERSION}/g' package.json.tpl > package.json
rm sdk/package.json sdk/tsconfig.json
sed -i -e 's/.\/package.json/..\/package.json/' sdk/utilities.ts
sed -i -e 's/$${VERSION}/'v${VERSION}/ sdk/scripts/install-pulumi-plugin.js
mkdir -p sdk/scripts
sed -e 's/$${VERSION}/'v${VERSION}/ install-pulumi-plugin.js > sdk/scripts/install-pulumi-plugin.js

# builds the pulumi terraform bridge
bridge: schema
Expand Down Expand Up @@ -70,4 +71,4 @@ tagcheck: versioncheck
git tag --points-at HEAD | grep -q v${VERSION} || (echo tag does not match specified version && false)

check: licenser
[ -z "`git status -uno --porcelain`" ] || (git status && echo 'Check failed. This could be a failed check or dirty git state.'; exit 1)
[ -z "`git status -uno --porcelain`" ] || (git status && echo 'Check failed. This could be a failed check or dirty git state.'; exit 1)
171 changes: 88 additions & 83 deletions go.mod

Large diffs are not rendered by default.

385 changes: 219 additions & 166 deletions go.sum

Large diffs are not rendered by default.

40 changes: 40 additions & 0 deletions install-pulumi-plugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright 2023 Tetrate
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

"use strict";
var childProcess = require("child_process");

var args = process.argv.slice(2);

if (args.indexOf("v1.5.4") !== -1) {
process.exit(0);
}

var res = childProcess.spawnSync("pulumi", ["plugin", "install"].concat(args), {
stdio: ["ignore", "inherit", "inherit"]
});

if (res.error && res.error.code === "ENOENT") {
console.error("\nThere was an error installing the resource provider plugin. " +
"It looks like `pulumi` is not installed on your system. " +
"Please visit https://pulumi.com/ to install the Pulumi CLI.\n" +
"You may try manually installing the plugin by running " +
"`pulumi plugin install " + args.join(" ") + "`");
} else if (res.error || res.status !== 0) {
console.error("\nThere was an error installing the resource provider plugin. " +
"You may try to manually installing the plugin by running " +
"`pulumi plugin install " + args.join(" ") + "`");
}

process.exit(0);
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "@tetratelabs/pulumi-checkmate",
"version": "1.5.4",
"description": ". Based on terraform-provider-checkmate: version v1.5.0",
"main": "index.js",
"types": "index.d.ts",
"version": "1.6.0",
"description": ". Based on terraform-provider-checkmate: version v1.6.0",
"main": "ts_bin/index.js",
"types": "ts_bin/index.d.ts",
"scripts": {
"build": "tsc",
"prepare": "npm run build",
"install": "node sdk/scripts/install-pulumi-plugin.js resource checkmate 1.5.4 --server github://api.github.com/tetratelabs"
"install": "node sdk/scripts/install-pulumi-plugin.js resource checkmate 1.6.0 --server github://api.github.com/tetratelabs"
},
"dependencies": {
"@pulumi/pulumi": "^3.0.0"
Expand Down
70 changes: 36 additions & 34 deletions provider/cmd/pulumi-resource-checkmate/bridge-metadata.json
Original file line number Diff line number Diff line change
@@ -1,37 +1,39 @@
{
"resources": {
"checkmate:index/httpHealth:HttpHealth": "checkmate_http_health",
"checkmate:index/localCommand:LocalCommand": "checkmate_local_command",
"checkmate:index/tcpEcho:TcpEcho": "checkmate_tcp_echo"
},
"renamedProperties": {
"checkmate:index/LocalCommandCreateFile:LocalCommandCreateFile": {
"createDirectory": "create_directory",
"useWorkingDir": "use_working_dir"
},
"checkmate:index/httpHealth:HttpHealth": {
"caBundle": "ca_bundle",
"consecutiveSuccesses": "consecutive_successes",
"createAnywayOnCheckFailure": "create_anyway_on_check_failure",
"insecureTls": "insecure_tls",
"requestBody": "request_body",
"requestTimeout": "request_timeout",
"resultBody": "result_body",
"statusCode": "status_code"
},
"checkmate:index/localCommand:LocalCommand": {
"commandTimeout": "command_timeout",
"consecutiveSuccesses": "consecutive_successes",
"createAnywayOnCheckFailure": "create_anyway_on_check_failure",
"createFile": "create_file",
"workingDirectory": "working_directory"
},
"checkmate:index/tcpEcho:TcpEcho": {
"connectionTimeout": "connection_timeout",
"consecutiveSuccesses": "consecutive_successes",
"createAnywayOnCheckFailure": "create_anyway_on_check_failure",
"expectedMessage": "expected_message",
"singleAttemptTimeout": "single_attempt_timeout"
"renames": {
"resources": {
"checkmate:index/httpHealth:HttpHealth": "checkmate_http_health",
"checkmate:index/localCommand:LocalCommand": "checkmate_local_command",
"checkmate:index/tcpEcho:TcpEcho": "checkmate_tcp_echo"
},
"renamedProperties": {
"checkmate:index/LocalCommandCreateFile:LocalCommandCreateFile": {
"createDirectory": "create_directory",
"useWorkingDir": "use_working_dir"
},
"checkmate:index/httpHealth:HttpHealth": {
"caBundle": "ca_bundle",
"consecutiveSuccesses": "consecutive_successes",
"createAnywayOnCheckFailure": "create_anyway_on_check_failure",
"insecureTls": "insecure_tls",
"requestBody": "request_body",
"requestTimeout": "request_timeout",
"resultBody": "result_body",
"statusCode": "status_code"
},
"checkmate:index/localCommand:LocalCommand": {
"commandTimeout": "command_timeout",
"consecutiveSuccesses": "consecutive_successes",
"createAnywayOnCheckFailure": "create_anyway_on_check_failure",
"createFile": "create_file",
"workingDirectory": "working_directory"
},
"checkmate:index/tcpEcho:TcpEcho": {
"connectionTimeout": "connection_timeout",
"consecutiveSuccesses": "consecutive_successes",
"createAnywayOnCheckFailure": "create_anyway_on_check_failure",
"expectedMessage": "expected_message",
"singleAttemptTimeout": "single_attempt_timeout"
}
}
}
}
}
14 changes: 7 additions & 7 deletions provider/cmd/pulumi-resource-checkmate/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@
},
"language": {
"nodejs": {
"compatibility": "tfbridge20",
"packageName": "@tetratelabs/pulumi-checkmate",
"packageDescription": ". Based on terraform-provider-checkmate: version v1.6.0",
"readme": "\u003e This provider is a derived work of the [Terraform Provider](https://github.com/tetratelabs/terraform-provider-checkmate)\n\u003e distributed under [MPL 2.0](https://www.mozilla.org/en-US/MPL/2.0/). If you encounter a bug or missing feature,\n\u003e first check the [`pulumi-checkmate` repo](/issues); however, if that doesn't turn up anything,\n\u003e please consult the source [`terraform-provider-checkmate` repo](https://github.com/tetratelabs/terraform-provider-checkmate/issues).",
"dependencies": {
"@pulumi/pulumi": "^3.0.0"
},
"devDependencies": {
"@types/node": "^10.0.0"
},
"disableUnionOutputTypes": true,
"packageDescription": ". Based on terraform-provider-checkmate: version v1.5.0",
"packageName": "@tetratelabs/pulumi-checkmate",
"readme": "\u003e This provider is a derived work of the [Terraform Provider](https://github.com/tetratelabs/terraform-provider-checkmate)\n\u003e distributed under [MPL 2.0](https://www.mozilla.org/en-US/MPL/2.0/). If you encounter a bug or missing feature,\n\u003e first check the [`pulumi-checkmate` repo](/issues); however, if that doesn't turn up anything,\n\u003e please consult the source [`terraform-provider-checkmate` repo](https://github.com/tetratelabs/terraform-provider-checkmate/issues).",
"typescriptVersion": ""
"compatibility": "tfbridge20",
"disableUnionOutputTypes": true
},
"python": {
"readme": "\u003e This provider is a derived work of the [Terraform Provider](https://github.com/tetratelabs/terraform-provider-checkmate)\n\u003e distributed under [MPL 2.0](https://www.mozilla.org/en-US/MPL/2.0/). If you encounter a bug or missing feature,\n\u003e first check the [`pulumi-checkmate` repo](/issues); however, if that doesn't turn up anything,\n\u003e please consult the source [`terraform-provider-checkmate` repo](https://github.com/tetratelabs/terraform-provider-checkmate/issues).",
"compatibility": "tfbridge20",
"readme": "\u003e This provider is a derived work of the [Terraform Provider](https://github.com/tetratelabs/terraform-provider-checkmate)\n\u003e distributed under [MPL 2.0](https://www.mozilla.org/en-US/MPL/2.0/). If you encounter a bug or missing feature,\n\u003e first check the [`pulumi-checkmate` repo](/issues); however, if that doesn't turn up anything,\n\u003e please consult the source [`terraform-provider-checkmate` repo](https://github.com/tetratelabs/terraform-provider-checkmate/issues)."
"pyproject": {}
}
},
"config": {},
Expand Down
14 changes: 6 additions & 8 deletions provider/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,13 @@ func checkResourceTok(mod string, res string) tokens.Type {
return checkType(mod+"/"+fn, res)
}

func Provider() tfpfbridge.ProviderInfo {
info := tfbridge.ProviderInfo{
func Provider() tfbridge.ProviderInfo {
return tfbridge.ProviderInfo{
P: tfpfbridge.ShimProvider(provider.NewProvider()),
Name: "checkmate",
GitHubOrg: "tetratelabs",
TFProviderVersion: "1.5.0",
Version: "1.5.4",
TFProviderVersion: "1.6.0",
Version: "1.6.0",
Resources: map[string]*tfbridge.ResourceInfo{
"checkmate_http_health": {Tok: checkResourceTok(checkMod, "HttpHealth")},
"checkmate_local_command": {Tok: checkResourceTok(checkMod, "LocalCommand")},
Expand All @@ -66,9 +67,6 @@ func Provider() tfpfbridge.ProviderInfo {
"@types/node": "^10.0.0", // so we can access strongly typed node definitions.
},
},
}
return tfpfbridge.ProviderInfo{
ProviderInfo: info,
NewProvider: getProvider,
MetadataInfo: tfbridge.NewProviderMetadata([]byte{}),
}
}
2 changes: 1 addition & 1 deletion sdk/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class Provider extends pulumi.ProviderResource {
if (obj === undefined || obj === null) {
return false;
}
return obj['__pulumiType'] === Provider.__pulumiType;
return obj['__pulumiType'] === "pulumi:providers:" + Provider.__pulumiType;
}


Expand Down
29 changes: 29 additions & 0 deletions sdk/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
// *** Do not edit by hand unless you're certain you know what you are doing! ***


import * as runtime from "@pulumi/pulumi/runtime";
import * as pulumi from "@pulumi/pulumi";

export function getEnv(...vars: string[]): string | undefined {
for (const v of vars) {
const value = process.env[v];
Expand Down Expand Up @@ -78,3 +81,29 @@ export function lazyLoad(exports: any, props: string[], loadModule: any) {
});
}
}

export async function callAsync<T>(
tok: string,
props: pulumi.Inputs,
res?: pulumi.Resource,
opts?: {property?: string},
): Promise<T> {
const o: any = runtime.call<T>(tok, props, res);
const value = await o.promise(true /*withUnknowns*/);
const isKnown = await o.isKnown;
const isSecret = await o.isSecret;
const problem: string|undefined =
!isKnown ? "an unknown value"
: isSecret ? "a secret value"
: undefined;
// Ingoring o.resources silently. They are typically non-empty, r.f() calls include r as a dependency.
if (problem) {
throw new Error(`Plain resource method "${tok}" incorrectly returned ${problem}. ` +
"This is an error in the provider, please report this to the provider developer.");
}
// Extract a single property if requested.
if (opts && opts.property) {
return value[opts.property];
}
return value;
}