Skip to content

Commit 8c7a579

Browse files
authored
Remove extra schema information for dynamic providers (#2147)
1 parent 1994ac1 commit 8c7a579

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

dynamic/main.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222

2323
"github.com/blang/semver"
2424
"github.com/opentofu/opentofu/shim/run"
25+
"github.com/pulumi/pulumi/pkg/v3/codegen/schema"
2526
"github.com/pulumi/pulumi/sdk/v3/go/common/diag"
2627
"github.com/pulumi/pulumi/sdk/v3/go/common/diag/colors"
2728
"github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin"
@@ -44,6 +45,11 @@ func initialSetup() (tfbridge.ProviderInfo, pfbridge.ProviderMetadata, func() er
4445
Version: version.Version(),
4546
Description: "Use any Terraform provider with Pulumi",
4647
MetadataInfo: &tfbridge.MetadataInfo{Path: "", Data: tfbridge.ProviderMetadata(nil)},
48+
SchemaPostProcessor: func(spec *schema.PackageSpec) {
49+
spec.Attribution = ""
50+
spec.Provider = schema.ResourceSpec{}
51+
spec.Language = nil
52+
},
4753
}
4854

4955
var metadata pfbridge.ProviderMetadata
@@ -59,6 +65,11 @@ func initialSetup() (tfbridge.ProviderInfo, pfbridge.ProviderMetadata, func() er
5965
if err != nil {
6066
return nil, err
6167
}
68+
69+
if info.SchemaPostProcessor != nil {
70+
info.SchemaPostProcessor(&packageSchema.PackageSpec)
71+
}
72+
6273
return json.Marshal(packageSchema.PackageSpec)
6374
},
6475
XParamaterize: func(ctx context.Context, req plugin.ParameterizeRequest) (plugin.ParameterizeResponse, error) {

dynamic/provider_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,19 @@ func skipWindows(t *testing.T) {
376376
func TestSchemaGeneration(t *testing.T) {
377377
skipWindows(t)
378378

379+
t.Run("unparameterized", func(t *testing.T) {
380+
helper.Integration(t)
381+
ctx := context.Background()
382+
383+
schema, err := grpcTestServer(ctx, t).
384+
GetSchema(ctx, &pulumirpc.GetSchemaRequest{})
385+
386+
require.NoError(t, err)
387+
var fmtSchema bytes.Buffer
388+
require.NoError(t, json.Indent(&fmtSchema, []byte(schema.Schema), "", " "))
389+
autogold.ExpectFile(t, autogold.Raw(fmtSchema.String()))
390+
})
391+
379392
testSchema := func(name, version string) {
380393
t.Run(strings.Join([]string{name, version}, "-"), func(t *testing.T) {
381394
helper.Integration(t)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "terraform-provider",
3+
"displayName": "Any Terraform Provider",
4+
"version": "v0.0.0-dev",
5+
"description": "Use any Terraform provider with Pulumi",
6+
"meta": {
7+
"moduleFormat": "(.*)(?:/[^/]*)"
8+
},
9+
"config": {},
10+
"provider": {}
11+
}

0 commit comments

Comments
 (0)