Skip to content

Commit 3a3da3f

Browse files
committed
Make the generated schema useful by including versions
1 parent c9ce9b5 commit 3a3da3f

File tree

6 files changed

+88
-11
lines changed

6 files changed

+88
-11
lines changed

dynamic/info.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"context"
1919
"fmt"
2020
"path"
21+
"strings"
2122

2223
"github.com/opentofu/opentofu/shim/run"
2324
"github.com/pulumi/pulumi/pkg/v3/codegen/schema"
@@ -35,6 +36,7 @@ func providerInfo(ctx context.Context, p run.Provider, value parameterize.Value)
3536
Name: p.Name(),
3637
Version: p.Version(),
3738
Description: "A Pulumi provider dynamically bridged from " + p.Name() + ".",
39+
Publisher: "Pulumi",
3840

3941
// To avoid bogging down schema generation speed, we skip all examples.
4042
SkipExamples: func(tfbridge.SkipExamplesArgs) bool { return true },
@@ -43,6 +45,19 @@ func providerInfo(ctx context.Context, p run.Provider, value parameterize.Value)
4345
Path: "", Data: tfbridge.ProviderMetadata(nil),
4446
},
4547

48+
Python: &tfbridge.PythonInfo{
49+
PyProject: struct{ Enabled bool }{true},
50+
RespectSchemaVersion: true,
51+
},
52+
JavaScript: &tfbridge.JavaScriptInfo{
53+
LiftSingleValueMethodReturns: true,
54+
RespectSchemaVersion: true,
55+
},
56+
CSharp: &tfbridge.CSharpInfo{
57+
LiftSingleValueMethodReturns: true,
58+
RespectSchemaVersion: true,
59+
},
60+
Java: &tfbridge.JavaInfo{ /* Java does not have a RespectSchemaVersion flag */ },
4661
Golang: &tfbridge.GolangInfo{
4762
ImportBasePath: path.Join(
4863
fmt.Sprintf("github.com/pulumi/pulumi-%[1]s/sdk/", p.Name()),
@@ -59,7 +74,7 @@ func providerInfo(ctx context.Context, p run.Provider, value parameterize.Value)
5974
spec.Parameterization = &schema.ParameterizationSpec{
6075
BaseProvider: schema.BaseProviderSpec{
6176
Name: baseProviderName,
62-
Version: version.Version(),
77+
Version: strings.TrimPrefix(version.Version(), "v"),
6378
},
6479
Parameter: value.Marshal(),
6580
}

dynamic/main.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,16 @@ func initialSetup() (tfbridge.ProviderInfo, pfbridge.ProviderMetadata, func() er
8989
case *plugin.ParameterizeValue:
9090
value, err := parameterize.ParseValue(params.Value)
9191
if err != nil {
92-
return plugin.ParameterizeResponse{}, err
92+
tfbridge.GetLogger(ctx).Error(fmt.Sprintf(
93+
"%[1]s is unable to parse the parameter value "+
94+
"embedded in the generated SDK.\nThis is always a bug in "+
95+
"%[1]s and should be reported. \n"+
96+
"The value passed was %[2]q.",
97+
baseProviderName, string(params.Value),
98+
))
99+
return plugin.ParameterizeResponse{}, fmt.Errorf(
100+
"failed to parse parameterized value: %w", err,
101+
)
93102
}
94103
args = value.IntoArgs()
95104
case *plugin.ParameterizeArgs:

dynamic/testdata/TestSchemaGeneration/Azure/alz-0.11.1.golden

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,43 @@
33
"version": "0.11.1",
44
"description": "A Pulumi provider dynamically bridged from alz.",
55
"attribution": "This Pulumi package is based on the [`alz` Terraform Provider](https://github.com/terraform-providers/terraform-provider-alz).",
6+
"publisher": "Pulumi",
67
"meta": {
78
"moduleFormat": "(.*)(?:/[^/]*)"
89
},
910
"language": {
11+
"csharp": {
12+
"compatibility": "tfbridge20",
13+
"liftSingleValueMethodReturns": true,
14+
"respectSchemaVersion": true
15+
},
1016
"go": {
1117
"importBasePath": "github.com/pulumi/pulumi-alz/sdk/go/alz",
1218
"liftSingleValueMethodReturns": true,
1319
"generateExtraInputTypes": true,
1420
"respectSchemaVersion": true
1521
},
22+
"java": {
23+
"basePackage": "",
24+
"buildFiles": "",
25+
"gradleNexusPublishPluginVersion": "",
26+
"gradleTest": ""
27+
},
1628
"nodejs": {
1729
"packageDescription": "A Pulumi provider dynamically bridged from alz.",
1830
"readme": "\u003e This provider is a derived work of the [Terraform Provider](https://github.com/terraform-providers/terraform-provider-alz)\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-alz` repo](/issues); however, if that doesn't turn up anything,\n\u003e please consult the source [`terraform-provider-alz` repo](https://github.com/terraform-providers/terraform-provider-alz/issues).",
1931
"compatibility": "tfbridge20",
20-
"disableUnionOutputTypes": true
32+
"disableUnionOutputTypes": true,
33+
"liftSingleValueMethodReturns": true,
34+
"respectSchemaVersion": true
2135
},
2236
"python": {
2337
"readme": "\u003e This provider is a derived work of the [Terraform Provider](https://github.com/terraform-providers/terraform-provider-alz)\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-alz` repo](/issues); however, if that doesn't turn up anything,\n\u003e please consult the source [`terraform-provider-alz` repo](https://github.com/terraform-providers/terraform-provider-alz/issues).",
2438
"compatibility": "tfbridge20",
25-
"pyproject": {}
39+
"respectSchemaVersion": true,
40+
"pyproject": {
41+
"enabled": true
42+
}
2643
}
2744
},
2845
"config": {
@@ -747,7 +764,7 @@
747764
"parameterization": {
748765
"baseProvider": {
749766
"name": "terraform-provider",
750-
"version": "v0.0.0-dev"
767+
"version": "0.0.0-dev"
751768
},
752769
"parameter": "eyJyZW1vdGUiOnsidXJsIjoicmVnaXN0cnkub3BlbnRvZnUub3JnL2F6dXJlL2FseiIsInZlcnNpb24iOiIwLjExLjEifX0="
753770
}

dynamic/testdata/TestSchemaGeneration/Backblaze/b2-0.8.9.golden

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,43 @@
33
"version": "0.8.9",
44
"description": "A Pulumi provider dynamically bridged from b2.",
55
"attribution": "This Pulumi package is based on the [`b2` Terraform Provider](https://github.com/terraform-providers/terraform-provider-b2).",
6+
"publisher": "Pulumi",
67
"meta": {
78
"moduleFormat": "(.*)(?:/[^/]*)"
89
},
910
"language": {
11+
"csharp": {
12+
"compatibility": "tfbridge20",
13+
"liftSingleValueMethodReturns": true,
14+
"respectSchemaVersion": true
15+
},
1016
"go": {
1117
"importBasePath": "github.com/pulumi/pulumi-b2/sdk/go/b2",
1218
"liftSingleValueMethodReturns": true,
1319
"generateExtraInputTypes": true,
1420
"respectSchemaVersion": true
1521
},
22+
"java": {
23+
"basePackage": "",
24+
"buildFiles": "",
25+
"gradleNexusPublishPluginVersion": "",
26+
"gradleTest": ""
27+
},
1628
"nodejs": {
1729
"packageDescription": "A Pulumi provider dynamically bridged from b2.",
1830
"readme": "\u003e This provider is a derived work of the [Terraform Provider](https://github.com/terraform-providers/terraform-provider-b2)\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-b2` repo](/issues); however, if that doesn't turn up anything,\n\u003e please consult the source [`terraform-provider-b2` repo](https://github.com/terraform-providers/terraform-provider-b2/issues).",
1931
"compatibility": "tfbridge20",
20-
"disableUnionOutputTypes": true
32+
"disableUnionOutputTypes": true,
33+
"liftSingleValueMethodReturns": true,
34+
"respectSchemaVersion": true
2135
},
2236
"python": {
2337
"readme": "\u003e This provider is a derived work of the [Terraform Provider](https://github.com/terraform-providers/terraform-provider-b2)\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-b2` repo](/issues); however, if that doesn't turn up anything,\n\u003e please consult the source [`terraform-provider-b2` repo](https://github.com/terraform-providers/terraform-provider-b2/issues).",
2438
"compatibility": "tfbridge20",
25-
"pyproject": {}
39+
"respectSchemaVersion": true,
40+
"pyproject": {
41+
"enabled": true
42+
}
2643
}
2744
},
2845
"config": {
@@ -1399,7 +1416,7 @@
13991416
"parameterization": {
14001417
"baseProvider": {
14011418
"name": "terraform-provider",
1402-
"version": "v0.0.0-dev"
1419+
"version": "0.0.0-dev"
14031420
},
14041421
"parameter": "eyJyZW1vdGUiOnsidXJsIjoicmVnaXN0cnkub3BlbnRvZnUub3JnL2JhY2tibGF6ZS9iMiIsInZlcnNpb24iOiIwLjguOSJ9fQ=="
14051422
}

dynamic/testdata/TestSchemaGeneration/hashicorp/random-3.3.0.golden

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,43 @@
33
"version": "3.3.0",
44
"description": "A Pulumi provider dynamically bridged from random.",
55
"attribution": "This Pulumi package is based on the [`random` Terraform Provider](https://github.com/terraform-providers/terraform-provider-random).",
6+
"publisher": "Pulumi",
67
"meta": {
78
"moduleFormat": "(.*)(?:/[^/]*)"
89
},
910
"language": {
11+
"csharp": {
12+
"compatibility": "tfbridge20",
13+
"liftSingleValueMethodReturns": true,
14+
"respectSchemaVersion": true
15+
},
1016
"go": {
1117
"importBasePath": "github.com/pulumi/pulumi-random/sdk/go/random",
1218
"liftSingleValueMethodReturns": true,
1319
"generateExtraInputTypes": true,
1420
"respectSchemaVersion": true
1521
},
22+
"java": {
23+
"basePackage": "",
24+
"buildFiles": "",
25+
"gradleNexusPublishPluginVersion": "",
26+
"gradleTest": ""
27+
},
1628
"nodejs": {
1729
"packageDescription": "A Pulumi provider dynamically bridged from random.",
1830
"readme": "\u003e This provider is a derived work of the [Terraform Provider](https://github.com/terraform-providers/terraform-provider-random)\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-random` repo](/issues); however, if that doesn't turn up anything,\n\u003e please consult the source [`terraform-provider-random` repo](https://github.com/terraform-providers/terraform-provider-random/issues).",
1931
"compatibility": "tfbridge20",
20-
"disableUnionOutputTypes": true
32+
"disableUnionOutputTypes": true,
33+
"liftSingleValueMethodReturns": true,
34+
"respectSchemaVersion": true
2135
},
2236
"python": {
2337
"readme": "\u003e This provider is a derived work of the [Terraform Provider](https://github.com/terraform-providers/terraform-provider-random)\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-random` repo](/issues); however, if that doesn't turn up anything,\n\u003e please consult the source [`terraform-provider-random` repo](https://github.com/terraform-providers/terraform-provider-random/issues).",
2438
"compatibility": "tfbridge20",
25-
"pyproject": {}
39+
"respectSchemaVersion": true,
40+
"pyproject": {
41+
"enabled": true
42+
}
2643
}
2744
},
2845
"config": {},
@@ -811,7 +828,7 @@
811828
"parameterization": {
812829
"baseProvider": {
813830
"name": "terraform-provider",
814-
"version": "v0.0.0-dev"
831+
"version": "0.0.0-dev"
815832
},
816833
"parameter": "eyJyZW1vdGUiOnsidXJsIjoicmVnaXN0cnkub3BlbnRvZnUub3JnL2hhc2hpY29ycC9yYW5kb20iLCJ2ZXJzaW9uIjoiMy4zLjAifX0="
817834
}

pf/tfbridge/provider.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ func XParameterizeResetProvider(ctx context.Context, info tfbridge.ProviderInfo,
203203
func (p *provider) ParameterizeWithContext(
204204
ctx context.Context, req plugin.ParameterizeRequest,
205205
) (plugin.ParameterizeResponse, error) {
206+
ctx = p.initLogging(ctx, p.logSink, "")
206207
if p.parameterize == nil {
207208
return (&plugin.UnimplementedProvider{}).Parameterize(ctx, req)
208209
}
@@ -222,6 +223,7 @@ func (p *provider) ParameterizeWithContext(
222223

223224
// GetSchema returns the schema for the provider.
224225
func (p *provider) GetSchemaWithContext(ctx context.Context, req plugin.GetSchemaRequest) ([]byte, error) {
226+
ctx = p.initLogging(ctx, p.logSink, "")
225227
return p.pulumiSchema(ctx, req)
226228
}
227229

0 commit comments

Comments
 (0)