diff --git a/Makefile b/Makefile index 1eabcb694..d54e5c5ec 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ export PULUMI_DISABLE_AUTOMATIC_PLUGIN_ACQUISITION := true PROJECT_DIR := $(patsubst %/,%,$(dir $(abspath $(lastword $(MAKEFILE_LIST))))) install_plugins:: - pulumi plugin install converter terraform 1.0.19 + pulumi plugin install converter terraform 1.0.20 pulumi plugin install resource random 4.16.3 pulumi plugin install resource aws 6.22.2 pulumi plugin install resource archive 0.0.4 diff --git a/dynamic/go.mod b/dynamic/go.mod index 237bcd069..35b01dca2 100644 --- a/dynamic/go.mod +++ b/dynamic/go.mod @@ -189,7 +189,7 @@ require ( github.com/pgavlin/fx v0.1.6 // indirect github.com/pgavlin/goldmark v1.1.33-0.20200616210433-b5eb04559386 // indirect github.com/pjbgf/sha1cd v0.3.0 // indirect - github.com/pkg/errors v0.9.1 // indirect + github.com/pkg/errors v0.9.1 github.com/pkg/term v1.1.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/posener/complete v1.2.3 // indirect @@ -212,7 +212,7 @@ require ( github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect github.com/shopspring/decimal v1.3.1 // indirect github.com/skeema/knownhosts v1.2.2 // indirect - github.com/spf13/afero v1.9.5 // indirect + github.com/spf13/afero v1.9.5 github.com/spf13/cast v1.5.0 // indirect github.com/spf13/cobra v1.8.0 // indirect github.com/spf13/pflag v1.0.5 // indirect diff --git a/dynamic/info.go b/dynamic/info.go index 16720139b..d5b05fbca 100644 --- a/dynamic/info.go +++ b/dynamic/info.go @@ -33,18 +33,15 @@ import ( func providerInfo(ctx context.Context, p run.Provider, value parameterize.Value) (tfbridge.ProviderInfo, error) { provider := proto.New(ctx, p) - prov := tfbridge.ProviderInfo{ - P: provider, - Name: p.Name(), - Version: p.Version(), - Description: "A Pulumi provider dynamically bridged from " + p.Name() + ".", - Publisher: "Pulumi", + prov := tfbridge.ProviderInfo{ + P: provider, + Name: p.Name(), + Version: p.Version(), + Description: "A Pulumi provider dynamically bridged from " + p.Name() + ".", + Publisher: "Pulumi", ResourcePrefix: inferResourcePrefix(provider), - // To avoid bogging down schema generation speed, we skip all examples. - SkipExamples: func(tfbridge.SkipExamplesArgs) bool { return true }, - MetadataInfo: &tfbridge.MetadataInfo{ Path: "", Data: tfbridge.ProviderMetadata(nil), }, @@ -84,6 +81,24 @@ func providerInfo(ctx context.Context, p run.Provider, value parameterize.Value) } }, } + // Add presumed best-effort GitHub org to the provider info. + // We do not set the GitHubOrg field for a local dynamic provider. + if value.Remote != nil { + // https://github.com/opentofu/registry/issues/1337: + // Due to discrepancies in the registry protocol/implementation, + // we infer the Terraform provider's source code repository via the following assumptions: + // - The provider's source code is hosted at github.com + // - The provider's github org, for providers, is the namespace field of the registry name + // Example: + // + // opentofu.org/provider/hashicorp/random -> "hashicorp" is deduced to be the github org. + // Note that this will only work for the provider (not the module) protocol. + urlFields := strings.Split(value.Remote.URL, "/") + ghOrg := urlFields[len(urlFields)-2] + name := urlFields[len(urlFields)-1] + prov.GitHubOrg = ghOrg + prov.Repository = "https://github.com/" + ghOrg + "/terraform-provider-" + name + } if err := fixup.Default(&prov); err != nil { return prov, err diff --git a/dynamic/main.go b/dynamic/main.go index f9a148f02..0a97b970f 100644 --- a/dynamic/main.go +++ b/dynamic/main.go @@ -19,14 +19,17 @@ import ( "encoding/json" "fmt" "os" + "os/exec" "github.com/blang/semver" "github.com/opentofu/opentofu/shim/run" + "github.com/pkg/errors" "github.com/pulumi/pulumi/pkg/v3/codegen/schema" "github.com/pulumi/pulumi/sdk/v3/go/common/diag" "github.com/pulumi/pulumi/sdk/v3/go/common/diag/colors" "github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin" "github.com/pulumi/pulumi/sdk/v3/go/common/util/contract" + "github.com/spf13/afero" "github.com/pulumi/pulumi-terraform-bridge/dynamic/parameterize" "github.com/pulumi/pulumi-terraform-bridge/dynamic/version" @@ -63,15 +66,26 @@ func initialSetup() (info.Provider, pfbridge.ProviderMetadata, func() error) { } var metadata pfbridge.ProviderMetadata + var fullDocs bool metadata = pfbridge.ProviderMetadata{ XGetSchema: func(ctx context.Context, req plugin.GetSchemaRequest) ([]byte, error) { - packageSchema, err := tfgen.GenerateSchemaWithOptions(tfgen.GenerateSchemaOptions{ + // Create a custom generator for schema. Examples will only be generated if `fullDocs` is set. + g, err := tfgen.NewGenerator(tfgen.GeneratorOptions{ + Package: info.Name, + Version: info.Version, + Language: tfgen.Schema, ProviderInfo: info, - DiagnosticsSink: diag.DefaultSink(os.Stdout, os.Stderr, diag.FormatOptions{ + Root: afero.NewMemMapFs(), + Sink: diag.DefaultSink(os.Stdout, os.Stderr, diag.FormatOptions{ Color: colors.Always, }), - XInMemoryDocs: true, + XInMemoryDocs: !fullDocs, + SkipExamples: !fullDocs, }) + if err != nil { + return nil, errors.Wrapf(err, "failed to create generator") + } + packageSchema, err := g.Generate() if err != nil { return nil, err } @@ -148,6 +162,33 @@ func initialSetup() (info.Provider, pfbridge.ProviderMetadata, func() error) { return plugin.ParameterizeResponse{}, err } + switch args.Remote { + case nil: + // We're using local args. + if args.Local.UpstreamRepoPath != "" { + info.UpstreamRepoPath = args.Local.UpstreamRepoPath + fullDocs = true + } + default: + fullDocs = args.Remote.Docs + if fullDocs { + // Write the upstream files at this version to a temporary directory + tmpDir, err := os.MkdirTemp("", "upstreamRepoDir") + if err != nil { + return plugin.ParameterizeResponse{}, err + } + versionTag := "v" + info.Version + cmd := exec.Command( + "git", "clone", "--depth", "1", "-b", versionTag, info.Repository, tmpDir, + ) + err = cmd.Run() + if err != nil { + return plugin.ParameterizeResponse{}, err + } + info.UpstreamRepoPath = tmpDir + } + } + return plugin.ParameterizeResponse{ Name: p.Name(), Version: v, diff --git a/dynamic/parameterize/args.go b/dynamic/parameterize/args.go index 65873b13e..aa7352899 100644 --- a/dynamic/parameterize/args.go +++ b/dynamic/parameterize/args.go @@ -31,12 +31,19 @@ type RemoteArgs struct { Name string // Version is the (possibly empty) version constraint on the provider. Version string + // Docs indicates if full schema documentation should be generated. + Docs bool } // LocalArgs represents a local TF provider referenced by path. type LocalArgs struct { // Path is the path to the provider binary. It can be relative or absolute. Path string + // UpstreamRepoPath (if provided) is the local path to the dynamically bridged Terraform provider's repo. + // + // If set, full documentation will be generated for the provider. + // If not set, only documentation from the TF provider's schema will be used. + UpstreamRepoPath string } func ParseArgs(args []string) (Args, error) { @@ -44,7 +51,21 @@ func ParseArgs(args []string) (Args, error) { if len(args) >= 1 && (strings.HasPrefix(args[0], "./") || strings.HasPrefix(args[0], "/")) { if len(args) > 1 { - return Args{}, fmt.Errorf("path based providers are only parameterized by 1 argument: ") + docsArg := args[1] + upstreamRepoPath, found := strings.CutPrefix(docsArg, "upstreamRepoPath=") + if !found { + return Args{}, fmt.Errorf( + "path based providers are only parameterized by 2 arguments: " + + "[upstreamRepoPath=]", + ) + } + if upstreamRepoPath == "" { + return Args{}, fmt.Errorf( + "upstreamRepoPath must be set to a non-empty value: " + + "upstreamRepoPath=path/to/files", + ) + } + return Args{Local: &LocalArgs{Path: args[0], UpstreamRepoPath: upstreamRepoPath}}, nil } return Args{Local: &LocalArgs{Path: args[0]}}, nil } @@ -52,6 +73,26 @@ func ParseArgs(args []string) (Args, error) { // This is a registry based provider var remote RemoteArgs switch len(args) { + // The third argument, if any, is the full docs option for when we need to generate docs + case 3: + docsArg := args[2] + errMsg := "expected third parameterized argument to be 'fullDocs=' or be empty" + + fullDocs, found := strings.CutPrefix(docsArg, "fullDocs=") + if !found { + return Args{}, fmt.Errorf("%s", errMsg) + } + + switch fullDocs { + case "true": + remote.Docs = true + case "false": + // Do nothing + default: + return Args{}, fmt.Errorf("%s", errMsg) + } + + fallthrough // The second argument, if any is the version case 2: remote.Version = args[1] @@ -61,6 +102,6 @@ func ParseArgs(args []string) (Args, error) { remote.Name = args[0] return Args{Remote: &remote}, nil default: - return Args{}, fmt.Errorf("expected to be parameterized by 1-2 arguments: [version]") + return Args{}, fmt.Errorf("expected to be parameterized by 1-3 arguments: [version] [fullDocs=]") } } diff --git a/dynamic/parameterize/args_test.go b/dynamic/parameterize/args_test.go index c18bf108e..f3530e36b 100644 --- a/dynamic/parameterize/args_test.go +++ b/dynamic/parameterize/args_test.go @@ -35,6 +35,30 @@ func TestParseArgs(t *testing.T) { args: []string{"./my-provider"}, expect: Args{Local: &LocalArgs{Path: "./my-provider"}}, }, + { + name: "local too many args", + args: []string{"./my-provider", "nonsense"}, + errMsg: autogold.Expect( + "path based providers are only parameterized by 2 arguments: [upstreamRepoPath=]", + ), + }, + { + name: "local with docs location", + args: []string{"./my-provider", "upstreamRepoPath=./my-provider"}, + expect: Args{ + Local: &LocalArgs{ + Path: "./my-provider", + UpstreamRepoPath: "./my-provider", + }, + }, + }, + { + name: "local empty upstreamRepoPath", + args: []string{"./my-provider", "upstreamRepoPath="}, + errMsg: autogold.Expect( + "upstreamRepoPath must be set to a non-empty value: upstreamRepoPath=path/to/files", + ), + }, { name: "remote", args: []string{"my-registry.io/typ"}, @@ -51,12 +75,53 @@ func TestParseArgs(t *testing.T) { { name: "no args", args: []string{}, - errMsg: autogold.Expect("expected to be parameterized by 1-2 arguments: [version]"), + errMsg: autogold.Expect("expected to be parameterized by 1-3 arguments: [version] [fullDocs=]"), }, { name: "too many args", - args: []string{"arg1", "arg2", "arg3"}, - errMsg: autogold.Expect("expected to be parameterized by 1-2 arguments: [version]"), + args: []string{"arg1", "arg2", "arg3", "arg4"}, + errMsg: autogold.Expect("expected to be parameterized by 1-3 arguments: [version] [fullDocs=]"), + }, + { + name: "invalid third arg", + args: []string{"arg1", "arg2", "arg3"}, + errMsg: autogold.Expect( + "expected third parameterized argument to be 'fullDocs=' or be empty", + ), + }, + { + name: "empty third arg", + args: []string{"arg1", "arg2"}, + expect: Args{Remote: &RemoteArgs{ + Name: "arg1", + Version: "arg2", + Docs: false, + }}, + }, + { + name: "valid third arg true", + args: []string{"my-registry.io/typ", "1.2.3", "fullDocs=true"}, + expect: Args{Remote: &RemoteArgs{ + Name: "my-registry.io/typ", + Version: "1.2.3", + Docs: true, + }}, + }, + { + name: "valid third arg false", + args: []string{"my-registry.io/typ", "1.2.3", "fullDocs=false"}, + expect: Args{Remote: &RemoteArgs{ + Name: "my-registry.io/typ", + Version: "1.2.3", + Docs: false, + }}, + }, + { + name: "third arg invalid input", + args: []string{"my-registry.io/typ", "1.2.3", "fullDocs=invalid-input"}, + errMsg: autogold.Expect( + "expected third parameterized argument to be 'fullDocs=' or be empty", + ), }, } diff --git a/dynamic/provider_test.go b/dynamic/provider_test.go index 101cb59b4..41753566c 100644 --- a/dynamic/provider_test.go +++ b/dynamic/provider_test.go @@ -457,6 +457,49 @@ func TestSchemaGeneration(t *testing.T) { //nolint:paralleltest testSchema("databricks/databricks", "1.50.0") } +func TestSchemaGenerationFullDocs(t *testing.T) { //nolint:paralleltest + skipWindows(t) + type testCase struct { + name string + version string + fullDocs string + } + + tc := testCase{ + name: "hashicorp/random", + version: "3.6.3", + fullDocs: "fullDocs=true", + } + + t.Run(strings.Join([]string{tc.name, tc.version}, "-"), func(t *testing.T) { + helper.Integration(t) + ctx := context.Background() + + server := grpcTestServer(ctx, t) + + result, err := server.Parameterize(ctx, &pulumirpc.ParameterizeRequest{ + Parameters: &pulumirpc.ParameterizeRequest_Args{ + Args: &pulumirpc.ParameterizeRequest_ParametersArgs{ + Args: []string{tc.name, tc.version, tc.fullDocs}, + }, + }, + }) + require.NoError(t, err) + + assert.Equal(t, tc.version, result.Version) + + schema, err := server.GetSchema(ctx, &pulumirpc.GetSchemaRequest{ + SubpackageName: result.Name, + SubpackageVersion: result.Version, + }) + + require.NoError(t, err) + var fmtSchema bytes.Buffer + require.NoError(t, json.Indent(&fmtSchema, []byte(schema.Schema), "", " ")) + autogold.ExpectFile(t, autogold.Raw(fmtSchema.String())) + }) +} + func TestRandomCreate(t *testing.T) { t.Parallel() ctx := context.Background() diff --git a/dynamic/testdata/TestSchemaGeneration/Backblaze/b2-0.8.9.golden b/dynamic/testdata/TestSchemaGeneration/Backblaze/b2-0.8.9.golden index f1d362027..59a37ed4e 100644 --- a/dynamic/testdata/TestSchemaGeneration/Backblaze/b2-0.8.9.golden +++ b/dynamic/testdata/TestSchemaGeneration/Backblaze/b2-0.8.9.golden @@ -1,8 +1,8 @@ { "name": "b2", - "version": "0.8.9", "description": "A Pulumi provider dynamically bridged from b2.", - "attribution": "This Pulumi package is based on the [`b2` Terraform Provider](https://github.com/terraform-providers/terraform-provider-b2).", + "attribution": "This Pulumi package is based on the [`b2` Terraform Provider](https://github.com/backblaze/terraform-provider-b2).", + "repository": "https://github.com/backblaze/terraform-provider-b2", "publisher": "Pulumi", "meta": { "moduleFormat": "(.*)(?:/[^/]*)" @@ -28,14 +28,14 @@ }, "nodejs": { "packageDescription": "A Pulumi provider dynamically bridged from b2.", - "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).", + "readme": "\u003e This provider is a derived work of the [Terraform Provider](https://github.com/backblaze/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 please consult the source [`terraform-provider-b2` repo](https://github.com/backblaze/terraform-provider-b2/issues).", "compatibility": "tfbridge20", "disableUnionOutputTypes": true, "liftSingleValueMethodReturns": true, "respectSchemaVersion": true }, "python": { - "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).", + "readme": "\u003e This provider is a derived work of the [Terraform Provider](https://github.com/backblaze/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 please consult the source [`terraform-provider-b2` repo](https://github.com/backblaze/terraform-provider-b2/issues).", "compatibility": "tfbridge20", "respectSchemaVersion": true, "pyproject": { diff --git a/dynamic/testdata/TestSchemaGeneration/databricks/databricks-1.50.0.golden b/dynamic/testdata/TestSchemaGeneration/databricks/databricks-1.50.0.golden index 288af648a..ff3847eeb 100644 --- a/dynamic/testdata/TestSchemaGeneration/databricks/databricks-1.50.0.golden +++ b/dynamic/testdata/TestSchemaGeneration/databricks/databricks-1.50.0.golden @@ -1,8 +1,8 @@ { "name": "databricks", - "version": "1.50.0", "description": "A Pulumi provider dynamically bridged from databricks.", - "attribution": "This Pulumi package is based on the [`databricks` Terraform Provider](https://github.com/terraform-providers/terraform-provider-databricks).", + "attribution": "This Pulumi package is based on the [`databricks` Terraform Provider](https://github.com/databricks/terraform-provider-databricks).", + "repository": "https://github.com/databricks/terraform-provider-databricks", "publisher": "Pulumi", "meta": { "moduleFormat": "(.*)(?:/[^/]*)" @@ -28,14 +28,14 @@ }, "nodejs": { "packageDescription": "A Pulumi provider dynamically bridged from databricks.", - "readme": "\u003e This provider is a derived work of the [Terraform Provider](https://github.com/terraform-providers/terraform-provider-databricks)\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-databricks` repo](/issues); however, if that doesn't turn up anything,\n\u003e please consult the source [`terraform-provider-databricks` repo](https://github.com/terraform-providers/terraform-provider-databricks/issues).", + "readme": "\u003e This provider is a derived work of the [Terraform Provider](https://github.com/databricks/terraform-provider-databricks)\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 please consult the source [`terraform-provider-databricks` repo](https://github.com/databricks/terraform-provider-databricks/issues).", "compatibility": "tfbridge20", "disableUnionOutputTypes": true, "liftSingleValueMethodReturns": true, "respectSchemaVersion": true }, "python": { - "readme": "\u003e This provider is a derived work of the [Terraform Provider](https://github.com/terraform-providers/terraform-provider-databricks)\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-databricks` repo](/issues); however, if that doesn't turn up anything,\n\u003e please consult the source [`terraform-provider-databricks` repo](https://github.com/terraform-providers/terraform-provider-databricks/issues).", + "readme": "\u003e This provider is a derived work of the [Terraform Provider](https://github.com/databricks/terraform-provider-databricks)\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 please consult the source [`terraform-provider-databricks` repo](https://github.com/databricks/terraform-provider-databricks/issues).", "compatibility": "tfbridge20", "respectSchemaVersion": true, "pyproject": { diff --git a/dynamic/testdata/TestSchemaGeneration/hashicorp/random-3.3.0.golden b/dynamic/testdata/TestSchemaGeneration/hashicorp/random-3.3.0.golden index 35edcadaa..584322726 100644 --- a/dynamic/testdata/TestSchemaGeneration/hashicorp/random-3.3.0.golden +++ b/dynamic/testdata/TestSchemaGeneration/hashicorp/random-3.3.0.golden @@ -1,8 +1,8 @@ { "name": "random", - "version": "3.3.0", "description": "A Pulumi provider dynamically bridged from random.", - "attribution": "This Pulumi package is based on the [`random` Terraform Provider](https://github.com/terraform-providers/terraform-provider-random).", + "attribution": "This Pulumi package is based on the [`random` Terraform Provider](https://github.com/hashicorp/terraform-provider-random).", + "repository": "https://github.com/hashicorp/terraform-provider-random", "publisher": "Pulumi", "meta": { "moduleFormat": "(.*)(?:/[^/]*)" @@ -28,14 +28,14 @@ }, "nodejs": { "packageDescription": "A Pulumi provider dynamically bridged from random.", - "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).", + "readme": "\u003e This provider is a derived work of the [Terraform Provider](https://github.com/hashicorp/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 please consult the source [`terraform-provider-random` repo](https://github.com/hashicorp/terraform-provider-random/issues).", "compatibility": "tfbridge20", "disableUnionOutputTypes": true, "liftSingleValueMethodReturns": true, "respectSchemaVersion": true }, "python": { - "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).", + "readme": "\u003e This provider is a derived work of the [Terraform Provider](https://github.com/hashicorp/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 please consult the source [`terraform-provider-random` repo](https://github.com/hashicorp/terraform-provider-random/issues).", "compatibility": "tfbridge20", "respectSchemaVersion": true, "pyproject": { diff --git a/dynamic/testdata/TestSchemaGeneration/unparameterized.golden b/dynamic/testdata/TestSchemaGeneration/unparameterized.golden index 8809cef0f..45c104ce0 100644 --- a/dynamic/testdata/TestSchemaGeneration/unparameterized.golden +++ b/dynamic/testdata/TestSchemaGeneration/unparameterized.golden @@ -1,7 +1,6 @@ { "name": "terraform-provider", "displayName": "Any Terraform Provider", - "version": "v0.0.0-dev", "description": "Use any Terraform provider with Pulumi", "keywords": [ "category/utility" diff --git a/dynamic/testdata/TestSchemaGenerationFullDocs/hashicorp/random-3.6.3.golden b/dynamic/testdata/TestSchemaGenerationFullDocs/hashicorp/random-3.6.3.golden new file mode 100644 index 000000000..abaf942eb --- /dev/null +++ b/dynamic/testdata/TestSchemaGenerationFullDocs/hashicorp/random-3.6.3.golden @@ -0,0 +1,938 @@ +{ + "name": "random", + "description": "A Pulumi provider dynamically bridged from random.", + "attribution": "This Pulumi package is based on the [`random` Terraform Provider](https://github.com/hashicorp/terraform-provider-random).", + "repository": "https://github.com/hashicorp/terraform-provider-random", + "publisher": "Pulumi", + "meta": { + "moduleFormat": "(.*)(?:/[^/]*)" + }, + "language": { + "csharp": { + "compatibility": "tfbridge20", + "liftSingleValueMethodReturns": true, + "respectSchemaVersion": true + }, + "go": { + "importBasePath": "github.com/pulumi/pulumi-terraform-provider/sdks/go/random/v3/random", + "rootPackageName": "random", + "liftSingleValueMethodReturns": true, + "generateExtraInputTypes": true, + "respectSchemaVersion": true + }, + "java": { + "basePackage": "", + "buildFiles": "", + "gradleNexusPublishPluginVersion": "", + "gradleTest": "" + }, + "nodejs": { + "packageDescription": "A Pulumi provider dynamically bridged from random.", + "readme": "\u003e This provider is a derived work of the [Terraform Provider](https://github.com/hashicorp/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 please consult the source [`terraform-provider-random` repo](https://github.com/hashicorp/terraform-provider-random/issues).", + "compatibility": "tfbridge20", + "disableUnionOutputTypes": true, + "liftSingleValueMethodReturns": true, + "respectSchemaVersion": true + }, + "python": { + "readme": "\u003e This provider is a derived work of the [Terraform Provider](https://github.com/hashicorp/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 please consult the source [`terraform-provider-random` repo](https://github.com/hashicorp/terraform-provider-random/issues).", + "compatibility": "tfbridge20", + "respectSchemaVersion": true, + "pyproject": { + "enabled": true + } + } + }, + "config": {}, + "provider": { + "description": "The provider type for the random package. By default, resources use package-wide configuration\nsettings, however an explicit `Provider` instance may be created and passed during resource\nconstruction to achieve fine-grained programmatic control over provider settings. See the\n[documentation](https://www.pulumi.com/docs/reference/programming-model/#providers) for more information.\n" + }, + "resources": { + "random:index/bytes:Bytes": { + "description": "The resource `random.Bytes` generates random bytes that are intended to be used as a secret, or key. Use this in preference to `random.Id` when the output is considered sensitive, and should not be displayed in the CLI.\n\nThis resource *does* use a cryptographic random number generator.\n\n## Example Usage\n\n\u003c!--Start PulumiCodeChooser --\u003e\n```typescript\nimport * as pulumi from \"@pulumi/pulumi\";\nimport * as azurerm from \"@pulumi/azurerm\";\nimport * as random from \"@pulumi/random\";\n\nconst jwtSecretBytes = new random.Bytes(\"jwtSecretBytes\", {length: 64});\nconst jwtSecretazurerm_key_vault_secret = new azurerm.index.Azurerm_key_vault_secret(\"jwtSecretazurerm_key_vault_secret\", {\n keyVaultId: \"some-azure-key-vault-id\",\n name: \"JwtSecret\",\n value: jwtSecretBytes.base64,\n});\n```\n```python\nimport pulumi\nimport pulumi_azurerm as azurerm\nimport pulumi_random as random\n\njwt_secret_bytes = random.Bytes(\"jwtSecretBytes\", length=64)\njwt_secretazurerm_key_vault_secret = azurerm.index.Azurerm_key_vault_secret(\"jwtSecretazurerm_key_vault_secret\",\n key_vault_id=some-azure-key-vault-id,\n name=JwtSecret,\n value=jwt_secret_bytes.base64)\n```\n```csharp\nusing System.Collections.Generic;\nusing System.Linq;\nusing Pulumi;\nusing Azurerm = Pulumi.Azurerm;\nusing Random = Pulumi.Random;\n\nreturn await Deployment.RunAsync(() =\u003e \n{\n var jwtSecretBytes = new Random.Bytes(\"jwtSecretBytes\", new()\n {\n Length = 64,\n });\n\n var jwtSecretazurerm_key_vault_secret = new Azurerm.Index.Azurerm_key_vault_secret(\"jwtSecretazurerm_key_vault_secret\", new()\n {\n KeyVaultId = \"some-azure-key-vault-id\",\n Name = \"JwtSecret\",\n Value = jwtSecretBytes.Base64,\n });\n\n});\n```\n```go\npackage main\n\nimport (\n\t\"github.com/pulumi/pulumi-azurerm/sdk/go/azurerm\"\n\t\"github.com/pulumi/pulumi-terraform-provider/sdks/go/random/v3/random\"\n\t\"github.com/pulumi/pulumi/sdk/v3/go/pulumi\"\n)\n\nfunc main() {\n\tpulumi.Run(func(ctx *pulumi.Context) error {\n\t\tjwtSecretBytes, err := random.NewBytes(ctx, \"jwtSecretBytes\", \u0026random.BytesArgs{\n\t\t\tLength: pulumi.Float64(64),\n\t\t})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\t_, err = azurerm.NewAzurerm_key_vault_secret(ctx, \"jwtSecretazurerm_key_vault_secret\", \u0026azurerm.Azurerm_key_vault_secretArgs{\n\t\t\tKeyVaultId: \"some-azure-key-vault-id\",\n\t\t\tName: \"JwtSecret\",\n\t\t\tValue: jwtSecretBytes.Base64,\n\t\t})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\treturn nil\n\t})\n}\n```\n```java\npackage generated_program;\n\nimport com.pulumi.Context;\nimport com.pulumi.Pulumi;\nimport com.pulumi.core.Output;\nimport com.pulumi.random.Bytes;\nimport com.pulumi.random.BytesArgs;\nimport com.pulumi.azurerm.azurerm_key_vault_secret;\nimport com.pulumi.azurerm.Azurerm_key_vault_secretArgs;\nimport java.util.List;\nimport java.util.ArrayList;\nimport java.util.Map;\nimport java.io.File;\nimport java.nio.file.Files;\nimport java.nio.file.Paths;\n\npublic class App {\n public static void main(String[] args) {\n Pulumi.run(App::stack);\n }\n\n public static void stack(Context ctx) {\n var jwtSecretBytes = new Bytes(\"jwtSecretBytes\", BytesArgs.builder()\n .length(64)\n .build());\n\n var jwtSecretazurerm_key_vault_secret = new Azurerm_key_vault_secret(\"jwtSecretazurerm_key_vault_secret\", Azurerm_key_vault_secretArgs.builder()\n .keyVaultId(\"some-azure-key-vault-id\")\n .name(\"JwtSecret\")\n .value(jwtSecretBytes.base64())\n .build());\n\n }\n}\n```\n```yaml\nresources:\n jwtSecretBytes:\n type: random:Bytes\n properties:\n length: 64\n jwtSecretazurerm_key_vault_secret:\n type: azurerm:azurerm_key_vault_secret\n properties:\n keyVaultId: some-azure-key-vault-id\n name: JwtSecret\n value: ${jwtSecretBytes.base64}\n```\n\u003c!--End PulumiCodeChooser --\u003e\n\n## Import\n\nRandom bytes can be imported by specifying the value as base64 string.\n\n```sh\n$ pulumi import random:index/bytes:Bytes basic \"8/fu3q+2DcgSJ19i0jZ5Cw==\"\n```\n\n", + "properties": { + "base64": { + "type": "string", + "description": "The generated bytes presented in base64 string format.\n", + "secret": true + }, + "hex": { + "type": "string", + "description": "The generated bytes presented in lowercase hexadecimal string format. The length of the encoded string is exactly twice the `length` parameter.\n", + "secret": true + }, + "keepers": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.\n" + }, + "length": { + "type": "number", + "description": "The number of bytes requested. The minimum value for length is 1.\n" + } + }, + "required": [ + "base64", + "hex", + "length" + ], + "inputProperties": { + "keepers": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.\n" + }, + "length": { + "type": "number", + "description": "The number of bytes requested. The minimum value for length is 1.\n" + } + }, + "requiredInputs": [ + "length" + ], + "stateInputs": { + "description": "Input properties used for looking up and filtering Bytes resources.\n", + "properties": { + "base64": { + "type": "string", + "description": "The generated bytes presented in base64 string format.\n", + "secret": true + }, + "hex": { + "type": "string", + "description": "The generated bytes presented in lowercase hexadecimal string format. The length of the encoded string is exactly twice the `length` parameter.\n", + "secret": true + }, + "keepers": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.\n" + }, + "length": { + "type": "number", + "description": "The number of bytes requested. The minimum value for length is 1.\n" + } + }, + "type": "object" + } + }, + "random:index/id:Id": { + "description": "The resource `random.Id` generates random numbers that are intended to be\nused as unique identifiers for other resources. If the output is considered \nsensitive, and should not be displayed in the CLI, use `random.Bytes`\ninstead.\n\nThis resource *does* use a cryptographic random number generator in order\nto minimize the chance of collisions, making the results of this resource\nwhen a 16-byte identifier is requested of equivalent uniqueness to a\ntype-4 UUID.\n\nThis resource can be used in conjunction with resources that have\nthe `create_before_destroy` lifecycle flag set to avoid conflicts with\nunique names during the brief period where both the old and new resources\nexist concurrently.\n\n## Example Usage\n\n\u003c!--Start PulumiCodeChooser --\u003e\n```typescript\nimport * as pulumi from \"@pulumi/pulumi\";\nimport * as aws from \"@pulumi/aws\";\nimport * as random from \"@pulumi/random\";\n\n// The following example shows how to generate a unique name for an AWS EC2\n// instance that changes each time a new AMI id is selected.\nconst serverId = new random.Id(\"serverId\", {\n keepers: {\n ami_id: _var.ami_id,\n },\n byteLength: 8,\n});\nconst serverInstance = new aws.ec2.Instance(\"serverInstance\", {\n tags: {\n Name: pulumi.interpolate`web-server ${serverId.hex}`,\n },\n ami: serverId.keepers.apply(keepers =\u003e keepers?.amiId),\n});\n// ... (other aws_instance arguments) ...\n```\n```python\nimport pulumi\nimport pulumi_aws as aws\nimport pulumi_random as random\n\n# The following example shows how to generate a unique name for an AWS EC2\n# instance that changes each time a new AMI id is selected.\nserver_id = random.Id(\"serverId\",\n keepers={\n \"ami_id\": var[\"ami_id\"],\n },\n byte_length=8)\nserver_instance = aws.ec2.Instance(\"serverInstance\",\n tags={\n \"Name\": server_id.hex.apply(lambda hex: f\"web-server {hex}\"),\n },\n ami=server_id.keepers[\"amiId\"])\n# ... (other aws_instance arguments) ...\n```\n```csharp\nusing System.Collections.Generic;\nusing System.Linq;\nusing Pulumi;\nusing Aws = Pulumi.Aws;\nusing Random = Pulumi.Random;\n\nreturn await Deployment.RunAsync(() =\u003e \n{\n // The following example shows how to generate a unique name for an AWS EC2\n // instance that changes each time a new AMI id is selected.\n var serverId = new Random.Id(\"serverId\", new()\n {\n Keepers = \n {\n { \"ami_id\", @var.Ami_id },\n },\n ByteLength = 8,\n });\n\n var serverInstance = new Aws.Ec2.Instance(\"serverInstance\", new()\n {\n Tags = \n {\n { \"Name\", serverId.Hex.Apply(hex =\u003e $\"web-server {hex}\") },\n },\n Ami = serverId.Keepers.Apply(keepers =\u003e keepers?.AmiId),\n });\n\n // ... (other aws_instance arguments) ...\n});\n```\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2\"\n\t\"github.com/pulumi/pulumi-terraform-provider/sdks/go/random/v3/random\"\n\t\"github.com/pulumi/pulumi/sdk/v3/go/pulumi\"\n)\n\nfunc main() {\n\tpulumi.Run(func(ctx *pulumi.Context) error {\n\t\t// The following example shows how to generate a unique name for an AWS EC2\n\t\t// instance that changes each time a new AMI id is selected.\n\t\tserverId, err := random.NewId(ctx, \"serverId\", \u0026random.IdArgs{\n\t\t\tKeepers: pulumi.StringMap{\n\t\t\t\t\"ami_id\": pulumi.Any(_var.Ami_id),\n\t\t\t},\n\t\t\tByteLength: pulumi.Float64(8),\n\t\t})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\t_, err = ec2.NewInstance(ctx, \"serverInstance\", \u0026ec2.InstanceArgs{\n\t\t\tTags: pulumi.StringMap{\n\t\t\t\t\"Name\": serverId.Hex.ApplyT(func(hex string) (string, error) {\n\t\t\t\t\treturn fmt.Sprintf(\"web-server %v\", hex), nil\n\t\t\t\t}).(pulumi.StringOutput),\n\t\t\t},\n\t\t\tAmi: pulumi.String(serverId.Keepers.ApplyT(func(keepers map[string]string) (*string, error) {\n\t\t\t\treturn \u0026keepers.AmiId, nil\n\t\t\t}).(pulumi.StringPtrOutput)),\n\t\t})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\treturn nil\n\t})\n}\n```\n```java\npackage generated_program;\n\nimport com.pulumi.Context;\nimport com.pulumi.Pulumi;\nimport com.pulumi.core.Output;\nimport com.pulumi.random.Id;\nimport com.pulumi.random.IdArgs;\nimport com.pulumi.aws.ec2.Instance;\nimport com.pulumi.aws.ec2.InstanceArgs;\nimport java.util.List;\nimport java.util.ArrayList;\nimport java.util.Map;\nimport java.io.File;\nimport java.nio.file.Files;\nimport java.nio.file.Paths;\n\npublic class App {\n public static void main(String[] args) {\n Pulumi.run(App::stack);\n }\n\n public static void stack(Context ctx) {\n // The following example shows how to generate a unique name for an AWS EC2\n // instance that changes each time a new AMI id is selected.\n var serverId = new Id(\"serverId\", IdArgs.builder()\n .keepers(Map.of(\"ami_id\", var_.ami_id()))\n .byteLength(8)\n .build());\n\n var serverInstance = new Instance(\"serverInstance\", InstanceArgs.builder()\n .tags(Map.of(\"Name\", serverId.hex().applyValue(hex -\u003e String.format(\"web-server %s\", hex))))\n .ami(serverId.keepers().applyValue(keepers -\u003e keepers.amiId()))\n .build());\n\n // ... (other aws_instance arguments) ...\n }\n}\n```\n```yaml\nresources:\n # The following example shows how to generate a unique name for an AWS EC2\n # instance that changes each time a new AMI id is selected.\n serverId:\n type: random:Id\n properties:\n keepers:\n ami_id: ${var.ami_id}\n byteLength: 8\n serverInstance:\n type: aws:ec2:Instance\n properties:\n tags:\n Name: web-server ${serverId.hex}\n # Read the AMI id \"through\" the random_id resource to ensure that\n # # both will change together.\n ami: ${serverId.keepers.amiId}\n```\n\u003c!--End PulumiCodeChooser --\u003e\n\n## Import\n\nRandom IDs can be imported using the b64_url with an optional prefix. This\n\ncan be used to replace a config value with a value interpolated from the\n\nrandom provider without experiencing diffs.\n\nExample with no prefix:\n\n```sh\n$ pulumi import random:index/id:Id server p-9hUg\n```\n\nExample with prefix (prefix is separated by a ,):\n\n```sh\n$ pulumi import random:index/id:Id server my-prefix-,p-9hUg\n```\n\n", + "properties": { + "b64Std": { + "type": "string", + "description": "The generated id presented in base64 without additional transformations.\n" + }, + "b64Url": { + "type": "string", + "description": "The generated id presented in base64, using the URL-friendly character set: case-sensitive letters, digits and the characters `_` and `-`.\n" + }, + "byteLength": { + "type": "number", + "description": "The number of random bytes to produce. The minimum value is 1, which produces eight bits of randomness.\n" + }, + "dec": { + "type": "string", + "description": "The generated id presented in non-padded decimal digits.\n" + }, + "hex": { + "type": "string", + "description": "The generated id presented in padded hexadecimal digits. This result will always be twice as long as the requested byte length.\n" + }, + "keepers": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.\n" + }, + "prefix": { + "type": "string", + "description": "Arbitrary string to prefix the output value with. This string is supplied as-is, meaning it is not guaranteed to be URL-safe or base64 encoded.\n" + } + }, + "required": [ + "b64Std", + "b64Url", + "byteLength", + "dec", + "hex" + ], + "inputProperties": { + "byteLength": { + "type": "number", + "description": "The number of random bytes to produce. The minimum value is 1, which produces eight bits of randomness.\n" + }, + "keepers": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.\n" + }, + "prefix": { + "type": "string", + "description": "Arbitrary string to prefix the output value with. This string is supplied as-is, meaning it is not guaranteed to be URL-safe or base64 encoded.\n" + } + }, + "requiredInputs": [ + "byteLength" + ], + "stateInputs": { + "description": "Input properties used for looking up and filtering Id resources.\n", + "properties": { + "b64Std": { + "type": "string", + "description": "The generated id presented in base64 without additional transformations.\n" + }, + "b64Url": { + "type": "string", + "description": "The generated id presented in base64, using the URL-friendly character set: case-sensitive letters, digits and the characters `_` and `-`.\n" + }, + "byteLength": { + "type": "number", + "description": "The number of random bytes to produce. The minimum value is 1, which produces eight bits of randomness.\n" + }, + "dec": { + "type": "string", + "description": "The generated id presented in non-padded decimal digits.\n" + }, + "hex": { + "type": "string", + "description": "The generated id presented in padded hexadecimal digits. This result will always be twice as long as the requested byte length.\n" + }, + "keepers": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.\n" + }, + "prefix": { + "type": "string", + "description": "Arbitrary string to prefix the output value with. This string is supplied as-is, meaning it is not guaranteed to be URL-safe or base64 encoded.\n" + } + }, + "type": "object" + } + }, + "random:index/integer:Integer": { + "description": "The resource `random.Integer` generates random values from a given range, described by the `min` and `max` attributes of a given resource.\n\nThis resource can be used in conjunction with resources that have the `create_before_destroy` lifecycle flag set, to avoid conflicts with unique names during the brief period where both the old and new resources exist concurrently.\n\n## Example Usage\n\n\u003c!--Start PulumiCodeChooser --\u003e\n```typescript\nimport * as pulumi from \"@pulumi/pulumi\";\nimport * as aws from \"@pulumi/aws\";\nimport * as random from \"@pulumi/random\";\n\n// The following example shows how to generate a random priority\n// between 1 and 50000 for a aws_alb_listener_rule resource:\nconst priority = new random.Integer(\"priority\", {\n min: 1,\n max: 50000,\n keepers: {\n listener_arn: _var.listener_arn,\n },\n});\nconst main = new aws.alb.ListenerRule(\"main\", {\n listenerArn: priority.keepers.apply(keepers =\u003e keepers?.listenerArn),\n priority: priority.result,\n actions: [{\n type: \"forward\",\n targetGroupArn: _var.target_group_arn,\n }],\n});\n// ... (other aws_alb_listener_rule arguments) ...\n```\n```python\nimport pulumi\nimport pulumi_aws as aws\nimport pulumi_random as random\n\n# The following example shows how to generate a random priority\n# between 1 and 50000 for a aws_alb_listener_rule resource:\npriority = random.Integer(\"priority\",\n min=1,\n max=50000,\n keepers={\n \"listener_arn\": var[\"listener_arn\"],\n })\nmain = aws.alb.ListenerRule(\"main\",\n listener_arn=priority.keepers[\"listenerArn\"],\n priority=priority.result,\n actions=[{\n \"type\": \"forward\",\n \"target_group_arn\": var[\"target_group_arn\"],\n }])\n# ... (other aws_alb_listener_rule arguments) ...\n```\n```csharp\nusing System.Collections.Generic;\nusing System.Linq;\nusing Pulumi;\nusing Aws = Pulumi.Aws;\nusing Random = Pulumi.Random;\n\nreturn await Deployment.RunAsync(() =\u003e \n{\n // The following example shows how to generate a random priority\n // between 1 and 50000 for a aws_alb_listener_rule resource:\n var priority = new Random.Integer(\"priority\", new()\n {\n Min = 1,\n Max = 50000,\n Keepers = \n {\n { \"listener_arn\", @var.Listener_arn },\n },\n });\n\n var main = new Aws.Alb.ListenerRule(\"main\", new()\n {\n ListenerArn = priority.Keepers.Apply(keepers =\u003e keepers?.ListenerArn),\n Priority = priority.Result,\n Actions = new[]\n {\n new Aws.Alb.Inputs.ListenerRuleActionArgs\n {\n Type = \"forward\",\n TargetGroupArn = @var.Target_group_arn,\n },\n },\n });\n\n // ... (other aws_alb_listener_rule arguments) ...\n});\n```\n```go\npackage main\n\nimport (\n\t\"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/alb\"\n\t\"github.com/pulumi/pulumi-terraform-provider/sdks/go/random/v3/random\"\n\t\"github.com/pulumi/pulumi/sdk/v3/go/pulumi\"\n)\n\nfunc main() {\n\tpulumi.Run(func(ctx *pulumi.Context) error {\n\t\t// The following example shows how to generate a random priority\n\t\t// between 1 and 50000 for a aws_alb_listener_rule resource:\n\t\tpriority, err := random.NewInteger(ctx, \"priority\", \u0026random.IntegerArgs{\n\t\t\tMin: pulumi.Float64(1),\n\t\t\tMax: pulumi.Float64(50000),\n\t\t\tKeepers: pulumi.StringMap{\n\t\t\t\t\"listener_arn\": pulumi.Any(_var.Listener_arn),\n\t\t\t},\n\t\t})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\t_, err = alb.NewListenerRule(ctx, \"main\", \u0026alb.ListenerRuleArgs{\n\t\t\tListenerArn: pulumi.String(priority.Keepers.ApplyT(func(keepers map[string]string) (*string, error) {\n\t\t\t\treturn \u0026keepers.ListenerArn, nil\n\t\t\t}).(pulumi.StringPtrOutput)),\n\t\t\tPriority: priority.Result,\n\t\t\tActions: alb.ListenerRuleActionArray{\n\t\t\t\t\u0026alb.ListenerRuleActionArgs{\n\t\t\t\t\tType: pulumi.String(\"forward\"),\n\t\t\t\t\tTargetGroupArn: pulumi.Any(_var.Target_group_arn),\n\t\t\t\t},\n\t\t\t},\n\t\t})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\treturn nil\n\t})\n}\n```\n```java\npackage generated_program;\n\nimport com.pulumi.Context;\nimport com.pulumi.Pulumi;\nimport com.pulumi.core.Output;\nimport com.pulumi.random.Integer;\nimport com.pulumi.random.IntegerArgs;\nimport com.pulumi.aws.alb.ListenerRule;\nimport com.pulumi.aws.alb.ListenerRuleArgs;\nimport com.pulumi.aws.alb.inputs.ListenerRuleActionArgs;\nimport java.util.List;\nimport java.util.ArrayList;\nimport java.util.Map;\nimport java.io.File;\nimport java.nio.file.Files;\nimport java.nio.file.Paths;\n\npublic class App {\n public static void main(String[] args) {\n Pulumi.run(App::stack);\n }\n\n public static void stack(Context ctx) {\n // The following example shows how to generate a random priority\n // between 1 and 50000 for a aws_alb_listener_rule resource:\n var priority = new Integer(\"priority\", IntegerArgs.builder()\n .min(1)\n .max(50000)\n .keepers(Map.of(\"listener_arn\", var_.listener_arn()))\n .build());\n\n var main = new ListenerRule(\"main\", ListenerRuleArgs.builder()\n .listenerArn(priority.keepers().applyValue(keepers -\u003e keepers.listenerArn()))\n .priority(priority.result())\n .actions(ListenerRuleActionArgs.builder()\n .type(\"forward\")\n .targetGroupArn(var_.target_group_arn())\n .build())\n .build());\n\n // ... (other aws_alb_listener_rule arguments) ...\n }\n}\n```\n```yaml\nresources:\n # The following example shows how to generate a random priority\n # between 1 and 50000 for a aws_alb_listener_rule resource:\n priority:\n type: random:Integer\n properties:\n min: 1\n max: 50000\n keepers:\n listener_arn: ${var.listener_arn}\n main:\n type: aws:alb:ListenerRule\n properties:\n listenerArn: ${priority.keepers.listenerArn}\n priority: ${priority.result}\n actions:\n - type: forward\n targetGroupArn: ${var.target_group_arn}\n```\n\u003c!--End PulumiCodeChooser --\u003e\n\n## Import\n\nRandom integers can be imported using the result, min, and max, with an\n\noptional seed. This can be used to replace a config value with a value\n\ninterpolated from the random provider without experiencing diffs.\n\nExample (values are separated by a ,):\n\n```sh\n$ pulumi import random:index/integer:Integer priority 15390,1,50000\n```\n\n", + "properties": { + "keepers": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.\n" + }, + "max": { + "type": "number", + "description": "The maximum inclusive value of the range.\n" + }, + "min": { + "type": "number", + "description": "The minimum inclusive value of the range.\n" + }, + "result": { + "type": "number", + "description": "The random integer result.\n" + }, + "seed": { + "type": "string", + "description": "A custom seed to always produce the same value.\n" + } + }, + "required": [ + "max", + "min", + "result" + ], + "inputProperties": { + "keepers": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.\n" + }, + "max": { + "type": "number", + "description": "The maximum inclusive value of the range.\n" + }, + "min": { + "type": "number", + "description": "The minimum inclusive value of the range.\n" + }, + "seed": { + "type": "string", + "description": "A custom seed to always produce the same value.\n" + } + }, + "requiredInputs": [ + "max", + "min" + ], + "stateInputs": { + "description": "Input properties used for looking up and filtering Integer resources.\n", + "properties": { + "keepers": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.\n" + }, + "max": { + "type": "number", + "description": "The maximum inclusive value of the range.\n" + }, + "min": { + "type": "number", + "description": "The minimum inclusive value of the range.\n" + }, + "result": { + "type": "number", + "description": "The random integer result.\n" + }, + "seed": { + "type": "string", + "description": "A custom seed to always produce the same value.\n" + } + }, + "type": "object" + } + }, + "random:index/password:Password": { + "description": "## Example Usage\n\n\u003c!--Start PulumiCodeChooser --\u003e\n```typescript\nimport * as pulumi from \"@pulumi/pulumi\";\nimport * as aws from \"@pulumi/aws\";\nimport * as random from \"@pulumi/random\";\n\nconst password = new random.Password(\"password\", {\n length: 16,\n special: true,\n overrideSpecial: \"!#$%\u0026*()-_=+[]{}\u003c\u003e:?\",\n});\nconst example = new aws.rds.Instance(\"example\", {\n instanceClass: aws.rds.InstanceType.T3_Micro,\n allocatedStorage: 64,\n engine: \"mysql\",\n username: \"someone\",\n password: password.result,\n});\n```\n```python\nimport pulumi\nimport pulumi_aws as aws\nimport pulumi_random as random\n\npassword = random.Password(\"password\",\n length=16,\n special=True,\n override_special=\"!#$%\u0026*()-_=+[]{}\u003c\u003e:?\")\nexample = aws.rds.Instance(\"example\",\n instance_class=aws.rds.InstanceType.T3_MICRO,\n allocated_storage=64,\n engine=\"mysql\",\n username=\"someone\",\n password=password.result)\n```\n```csharp\nusing System.Collections.Generic;\nusing System.Linq;\nusing Pulumi;\nusing Aws = Pulumi.Aws;\nusing Random = Pulumi.Random;\n\nreturn await Deployment.RunAsync(() =\u003e \n{\n var password = new Random.Password(\"password\", new()\n {\n Length = 16,\n Special = true,\n OverrideSpecial = \"!#$%\u0026*()-_=+[]{}\u003c\u003e:?\",\n });\n\n var example = new Aws.Rds.Instance(\"example\", new()\n {\n InstanceClass = Aws.Rds.InstanceType.T3_Micro,\n AllocatedStorage = 64,\n Engine = \"mysql\",\n Username = \"someone\",\n Password = password.Result,\n });\n\n});\n```\n```go\npackage main\n\nimport (\n\t\"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/rds\"\n\t\"github.com/pulumi/pulumi-terraform-provider/sdks/go/random/v3/random\"\n\t\"github.com/pulumi/pulumi/sdk/v3/go/pulumi\"\n)\n\nfunc main() {\n\tpulumi.Run(func(ctx *pulumi.Context) error {\n\t\tpassword, err := random.NewPassword(ctx, \"password\", \u0026random.PasswordArgs{\n\t\t\tLength: pulumi.Float64(16),\n\t\t\tSpecial: pulumi.Bool(true),\n\t\t\tOverrideSpecial: pulumi.String(\"!#$%\u0026*()-_=+[]{}\u003c\u003e:?\"),\n\t\t})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\t_, err = rds.NewInstance(ctx, \"example\", \u0026rds.InstanceArgs{\n\t\t\tInstanceClass: pulumi.String(rds.InstanceType_T3_Micro),\n\t\t\tAllocatedStorage: pulumi.Int(64),\n\t\t\tEngine: pulumi.String(\"mysql\"),\n\t\t\tUsername: pulumi.String(\"someone\"),\n\t\t\tPassword: password.Result,\n\t\t})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\treturn nil\n\t})\n}\n```\n```java\npackage generated_program;\n\nimport com.pulumi.Context;\nimport com.pulumi.Pulumi;\nimport com.pulumi.core.Output;\nimport com.pulumi.random.Password;\nimport com.pulumi.random.PasswordArgs;\nimport com.pulumi.aws.rds.Instance;\nimport com.pulumi.aws.rds.InstanceArgs;\nimport java.util.List;\nimport java.util.ArrayList;\nimport java.util.Map;\nimport java.io.File;\nimport java.nio.file.Files;\nimport java.nio.file.Paths;\n\npublic class App {\n public static void main(String[] args) {\n Pulumi.run(App::stack);\n }\n\n public static void stack(Context ctx) {\n var password = new Password(\"password\", PasswordArgs.builder()\n .length(16)\n .special(true)\n .overrideSpecial(\"!#$%\u0026*()-_=+[]{}\u003c\u003e:?\")\n .build());\n\n var example = new Instance(\"example\", InstanceArgs.builder()\n .instanceClass(\"db.t3.micro\")\n .allocatedStorage(64)\n .engine(\"mysql\")\n .username(\"someone\")\n .password(password.result())\n .build());\n\n }\n}\n```\n```yaml\nresources:\n password:\n type: random:Password\n properties:\n length: 16\n special: true\n overrideSpecial: '!#$%\u0026*()-_=+[]{}\u003c\u003e:?'\n example:\n type: aws:rds:Instance\n properties:\n instanceClass: db.t3.micro\n allocatedStorage: 64\n engine: mysql\n username: someone\n password: ${password.result}\n```\n\u003c!--End PulumiCodeChooser --\u003e\n\n## Import\n\n### Avoiding Replacement\n\n```sh\n$ pulumi import random:index/password:Password If the resource were imported using `random_password.password securepassword`,\n```\n\nreplacement could be avoided by using:\n\n1. Attribute values that match the imported ID and defaults:\n\n terraform\n\n resource \"random_password\" \"password\" {\n\n length = 14\n\n lower = true\n\n }\n\n2. Attribute values that match the imported ID and omit the attributes with defaults:\n\n terraform\n\n resource \"random_password\" \"password\" {\n\n length = 14\n\n }\n\n3. `ignore_changes` specifying the attributes to ignore:\n\n terraform\n\n resource \"random_password\" \"password\" {\n\n length = 16\n\n lower = false\n\n lifecycle {\n\n ignore_changes = [\n\n length,\n\n lower,\n\n ]\n\n }\n\n }\n\n **NOTE** `ignore_changes` is only required until the resource is recreated after import,\n\n after which it will use the configuration values specified.\n\n", + "properties": { + "bcryptHash": { + "type": "string", + "description": "A bcrypt hash of the generated random string. **NOTE**: If the generated random string is greater than 72 bytes in length, `bcrypt_hash` will contain a hash of the first 72 bytes.\n", + "secret": true + }, + "keepers": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.\n" + }, + "length": { + "type": "number", + "description": "The length of the string desired. The minimum value for length is 1 and, length must also be \u003e= (`min_upper` + `min_lower` + `min_numeric` + `min_special`).\n" + }, + "lower": { + "type": "boolean", + "description": "Include lowercase alphabet characters in the result. Default value is `true`.\n" + }, + "minLower": { + "type": "number", + "description": "Minimum number of lowercase alphabet characters in the result. Default value is `0`.\n" + }, + "minNumeric": { + "type": "number", + "description": "Minimum number of numeric characters in the result. Default value is `0`.\n" + }, + "minSpecial": { + "type": "number", + "description": "Minimum number of special characters in the result. Default value is `0`.\n" + }, + "minUpper": { + "type": "number", + "description": "Minimum number of uppercase alphabet characters in the result. Default value is `0`.\n" + }, + "number": { + "type": "boolean", + "description": "Include numeric characters in the result. Default value is `true`. If `number`, `upper`, `lower`, and `special` are all configured, at least one of them must be set to `true`. **NOTE**: This is deprecated, use `numeric` instead.\n", + "deprecationMessage": "Deprecated" + }, + "numeric": { + "type": "boolean", + "description": "Include numeric characters in the result. Default value is `true`. If `numeric`, `upper`, `lower`, and `special` are all configured, at least one of them must be set to `true`.\n" + }, + "overrideSpecial": { + "type": "string", + "description": "Supply your own list of special characters to use for string generation. This overrides the default character list in the special argument. The `special` argument must still be set to true for any overwritten characters to be used in generation.\n" + }, + "result": { + "type": "string", + "description": "The generated random string.\n", + "secret": true + }, + "special": { + "type": "boolean", + "description": "Include special characters in the result. These are `!@#$%\u0026*()-_=+[]{}\u003c\u003e:?`. Default value is `true`.\n" + }, + "upper": { + "type": "boolean", + "description": "Include uppercase alphabet characters in the result. Default value is `true`.\n" + } + }, + "required": [ + "bcryptHash", + "length", + "lower", + "minLower", + "minNumeric", + "minSpecial", + "minUpper", + "number", + "numeric", + "result", + "special", + "upper" + ], + "inputProperties": { + "keepers": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.\n" + }, + "length": { + "type": "number", + "description": "The length of the string desired. The minimum value for length is 1 and, length must also be \u003e= (`min_upper` + `min_lower` + `min_numeric` + `min_special`).\n" + }, + "lower": { + "type": "boolean", + "description": "Include lowercase alphabet characters in the result. Default value is `true`.\n" + }, + "minLower": { + "type": "number", + "description": "Minimum number of lowercase alphabet characters in the result. Default value is `0`.\n" + }, + "minNumeric": { + "type": "number", + "description": "Minimum number of numeric characters in the result. Default value is `0`.\n" + }, + "minSpecial": { + "type": "number", + "description": "Minimum number of special characters in the result. Default value is `0`.\n" + }, + "minUpper": { + "type": "number", + "description": "Minimum number of uppercase alphabet characters in the result. Default value is `0`.\n" + }, + "number": { + "type": "boolean", + "description": "Include numeric characters in the result. Default value is `true`. If `number`, `upper`, `lower`, and `special` are all configured, at least one of them must be set to `true`. **NOTE**: This is deprecated, use `numeric` instead.\n", + "deprecationMessage": "Deprecated" + }, + "numeric": { + "type": "boolean", + "description": "Include numeric characters in the result. Default value is `true`. If `numeric`, `upper`, `lower`, and `special` are all configured, at least one of them must be set to `true`.\n" + }, + "overrideSpecial": { + "type": "string", + "description": "Supply your own list of special characters to use for string generation. This overrides the default character list in the special argument. The `special` argument must still be set to true for any overwritten characters to be used in generation.\n" + }, + "special": { + "type": "boolean", + "description": "Include special characters in the result. These are `!@#$%\u0026*()-_=+[]{}\u003c\u003e:?`. Default value is `true`.\n" + }, + "upper": { + "type": "boolean", + "description": "Include uppercase alphabet characters in the result. Default value is `true`.\n" + } + }, + "requiredInputs": [ + "length" + ], + "stateInputs": { + "description": "Input properties used for looking up and filtering Password resources.\n", + "properties": { + "bcryptHash": { + "type": "string", + "description": "A bcrypt hash of the generated random string. **NOTE**: If the generated random string is greater than 72 bytes in length, `bcrypt_hash` will contain a hash of the first 72 bytes.\n", + "secret": true + }, + "keepers": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.\n" + }, + "length": { + "type": "number", + "description": "The length of the string desired. The minimum value for length is 1 and, length must also be \u003e= (`min_upper` + `min_lower` + `min_numeric` + `min_special`).\n" + }, + "lower": { + "type": "boolean", + "description": "Include lowercase alphabet characters in the result. Default value is `true`.\n" + }, + "minLower": { + "type": "number", + "description": "Minimum number of lowercase alphabet characters in the result. Default value is `0`.\n" + }, + "minNumeric": { + "type": "number", + "description": "Minimum number of numeric characters in the result. Default value is `0`.\n" + }, + "minSpecial": { + "type": "number", + "description": "Minimum number of special characters in the result. Default value is `0`.\n" + }, + "minUpper": { + "type": "number", + "description": "Minimum number of uppercase alphabet characters in the result. Default value is `0`.\n" + }, + "number": { + "type": "boolean", + "description": "Include numeric characters in the result. Default value is `true`. If `number`, `upper`, `lower`, and `special` are all configured, at least one of them must be set to `true`. **NOTE**: This is deprecated, use `numeric` instead.\n", + "deprecationMessage": "Deprecated" + }, + "numeric": { + "type": "boolean", + "description": "Include numeric characters in the result. Default value is `true`. If `numeric`, `upper`, `lower`, and `special` are all configured, at least one of them must be set to `true`.\n" + }, + "overrideSpecial": { + "type": "string", + "description": "Supply your own list of special characters to use for string generation. This overrides the default character list in the special argument. The `special` argument must still be set to true for any overwritten characters to be used in generation.\n" + }, + "result": { + "type": "string", + "description": "The generated random string.\n", + "secret": true + }, + "special": { + "type": "boolean", + "description": "Include special characters in the result. These are `!@#$%\u0026*()-_=+[]{}\u003c\u003e:?`. Default value is `true`.\n" + }, + "upper": { + "type": "boolean", + "description": "Include uppercase alphabet characters in the result. Default value is `true`.\n" + } + }, + "type": "object" + } + }, + "random:index/pet:Pet": { + "description": "The resource `random.Pet` generates random pet names that are intended to be used as unique identifiers for other resources.\n\nThis resource can be used in conjunction with resources that have the `create_before_destroy` lifecycle flag set, to avoid conflicts with unique names during the brief period where both the old and new resources exist concurrently.\n\n## Example Usage\n\n\u003c!--Start PulumiCodeChooser --\u003e\n```typescript\nimport * as pulumi from \"@pulumi/pulumi\";\nimport * as aws from \"@pulumi/aws\";\nimport * as random from \"@pulumi/random\";\n\n// The following example shows how to generate a unique pet name\n// for an AWS EC2 instance that changes each time a new AMI id is\n// selected.\nconst serverPet = new random.Pet(\"serverPet\", {keepers: {\n ami_id: _var.ami_id,\n}});\nconst serverInstance = new aws.ec2.Instance(\"serverInstance\", {\n tags: {\n Name: pulumi.interpolate`web-server-${serverPet.id}`,\n },\n ami: serverPet.keepers.apply(keepers =\u003e keepers?.amiId),\n});\n// ... (other aws_instance arguments) ...\n```\n```python\nimport pulumi\nimport pulumi_aws as aws\nimport pulumi_random as random\n\n# The following example shows how to generate a unique pet name\n# for an AWS EC2 instance that changes each time a new AMI id is\n# selected.\nserver_pet = random.Pet(\"serverPet\", keepers={\n \"ami_id\": var[\"ami_id\"],\n})\nserver_instance = aws.ec2.Instance(\"serverInstance\",\n tags={\n \"Name\": server_pet.id.apply(lambda id: f\"web-server-{id}\"),\n },\n ami=server_pet.keepers[\"amiId\"])\n# ... (other aws_instance arguments) ...\n```\n```csharp\nusing System.Collections.Generic;\nusing System.Linq;\nusing Pulumi;\nusing Aws = Pulumi.Aws;\nusing Random = Pulumi.Random;\n\nreturn await Deployment.RunAsync(() =\u003e \n{\n // The following example shows how to generate a unique pet name\n // for an AWS EC2 instance that changes each time a new AMI id is\n // selected.\n var serverPet = new Random.Pet(\"serverPet\", new()\n {\n Keepers = \n {\n { \"ami_id\", @var.Ami_id },\n },\n });\n\n var serverInstance = new Aws.Ec2.Instance(\"serverInstance\", new()\n {\n Tags = \n {\n { \"Name\", serverPet.Id.Apply(id =\u003e $\"web-server-{id}\") },\n },\n Ami = serverPet.Keepers.Apply(keepers =\u003e keepers?.AmiId),\n });\n\n // ... (other aws_instance arguments) ...\n});\n```\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2\"\n\t\"github.com/pulumi/pulumi-terraform-provider/sdks/go/random/v3/random\"\n\t\"github.com/pulumi/pulumi/sdk/v3/go/pulumi\"\n)\n\nfunc main() {\n\tpulumi.Run(func(ctx *pulumi.Context) error {\n\t\t// The following example shows how to generate a unique pet name\n\t\t// for an AWS EC2 instance that changes each time a new AMI id is\n\t\t// selected.\n\t\tserverPet, err := random.NewPet(ctx, \"serverPet\", \u0026random.PetArgs{\n\t\t\tKeepers: pulumi.StringMap{\n\t\t\t\t\"ami_id\": pulumi.Any(_var.Ami_id),\n\t\t\t},\n\t\t})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\t_, err = ec2.NewInstance(ctx, \"serverInstance\", \u0026ec2.InstanceArgs{\n\t\t\tTags: pulumi.StringMap{\n\t\t\t\t\"Name\": serverPet.ID().ApplyT(func(id string) (string, error) {\n\t\t\t\t\treturn fmt.Sprintf(\"web-server-%v\", id), nil\n\t\t\t\t}).(pulumi.StringOutput),\n\t\t\t},\n\t\t\tAmi: pulumi.String(serverPet.Keepers.ApplyT(func(keepers map[string]string) (*string, error) {\n\t\t\t\treturn \u0026keepers.AmiId, nil\n\t\t\t}).(pulumi.StringPtrOutput)),\n\t\t})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\treturn nil\n\t})\n}\n```\n```java\npackage generated_program;\n\nimport com.pulumi.Context;\nimport com.pulumi.Pulumi;\nimport com.pulumi.core.Output;\nimport com.pulumi.random.Pet;\nimport com.pulumi.random.PetArgs;\nimport com.pulumi.aws.ec2.Instance;\nimport com.pulumi.aws.ec2.InstanceArgs;\nimport java.util.List;\nimport java.util.ArrayList;\nimport java.util.Map;\nimport java.io.File;\nimport java.nio.file.Files;\nimport java.nio.file.Paths;\n\npublic class App {\n public static void main(String[] args) {\n Pulumi.run(App::stack);\n }\n\n public static void stack(Context ctx) {\n // The following example shows how to generate a unique pet name\n // for an AWS EC2 instance that changes each time a new AMI id is\n // selected.\n var serverPet = new Pet(\"serverPet\", PetArgs.builder()\n .keepers(Map.of(\"ami_id\", var_.ami_id()))\n .build());\n\n var serverInstance = new Instance(\"serverInstance\", InstanceArgs.builder()\n .tags(Map.of(\"Name\", serverPet.id().applyValue(id -\u003e String.format(\"web-server-%s\", id))))\n .ami(serverPet.keepers().applyValue(keepers -\u003e keepers.amiId()))\n .build());\n\n // ... (other aws_instance arguments) ...\n }\n}\n```\n```yaml\nresources:\n # The following example shows how to generate a unique pet name\n # for an AWS EC2 instance that changes each time a new AMI id is\n # selected.\n serverPet:\n type: random:Pet\n properties:\n keepers:\n ami_id: ${var.ami_id}\n serverInstance:\n type: aws:ec2:Instance\n properties:\n tags:\n Name: web-server-${serverPet.id}\n # Read the AMI id \"through\" the random_pet resource to ensure that\n # # both will change together.\n ami: ${serverPet.keepers.amiId}\n```\n\u003c!--End PulumiCodeChooser --\u003e\n", + "properties": { + "keepers": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.\n" + }, + "length": { + "type": "number", + "description": "The length (in words) of the pet name. Defaults to 2\n" + }, + "prefix": { + "type": "string", + "description": "A string to prefix the name with.\n" + }, + "separator": { + "type": "string", + "description": "The character to separate words in the pet name. Defaults to \"-\"\n" + } + }, + "required": [ + "length", + "separator" + ], + "inputProperties": { + "keepers": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.\n" + }, + "length": { + "type": "number", + "description": "The length (in words) of the pet name. Defaults to 2\n" + }, + "prefix": { + "type": "string", + "description": "A string to prefix the name with.\n" + }, + "separator": { + "type": "string", + "description": "The character to separate words in the pet name. Defaults to \"-\"\n" + } + }, + "stateInputs": { + "description": "Input properties used for looking up and filtering Pet resources.\n", + "properties": { + "keepers": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.\n" + }, + "length": { + "type": "number", + "description": "The length (in words) of the pet name. Defaults to 2\n" + }, + "prefix": { + "type": "string", + "description": "A string to prefix the name with.\n" + }, + "separator": { + "type": "string", + "description": "The character to separate words in the pet name. Defaults to \"-\"\n" + } + }, + "type": "object" + } + }, + "random:index/shuffle:Shuffle": { + "description": "The resource `random.Shuffle` generates a random permutation of a list of strings given as an argument.\n\n## Example Usage\n\n\u003c!--Start PulumiCodeChooser --\u003e\n```typescript\nimport * as pulumi from \"@pulumi/pulumi\";\nimport * as aws from \"@pulumi/aws\";\nimport * as random from \"@pulumi/random\";\n\nconst az = new random.Shuffle(\"az\", {\n inputs: [\n \"us-west-1a\",\n \"us-west-1c\",\n \"us-west-1d\",\n \"us-west-1e\",\n ],\n resultCount: 2,\n});\nconst example = new aws.elb.LoadBalancer(\"example\", {availabilityZones: az.results});\n// ... and other aws_elb arguments ...\n```\n```python\nimport pulumi\nimport pulumi_aws as aws\nimport pulumi_random as random\n\naz = random.Shuffle(\"az\",\n inputs=[\n \"us-west-1a\",\n \"us-west-1c\",\n \"us-west-1d\",\n \"us-west-1e\",\n ],\n result_count=2)\nexample = aws.elb.LoadBalancer(\"example\", availability_zones=az.results)\n# ... and other aws_elb arguments ...\n```\n```csharp\nusing System.Collections.Generic;\nusing System.Linq;\nusing Pulumi;\nusing Aws = Pulumi.Aws;\nusing Random = Pulumi.Random;\n\nreturn await Deployment.RunAsync(() =\u003e \n{\n var az = new Random.Shuffle(\"az\", new()\n {\n Inputs = new[]\n {\n \"us-west-1a\",\n \"us-west-1c\",\n \"us-west-1d\",\n \"us-west-1e\",\n },\n ResultCount = 2,\n });\n\n var example = new Aws.Elb.LoadBalancer(\"example\", new()\n {\n AvailabilityZones = az.Results,\n });\n\n // ... and other aws_elb arguments ...\n});\n```\n```go\npackage main\n\nimport (\n\t\"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/elb\"\n\t\"github.com/pulumi/pulumi-terraform-provider/sdks/go/random/v3/random\"\n\t\"github.com/pulumi/pulumi/sdk/v3/go/pulumi\"\n)\n\nfunc main() {\n\tpulumi.Run(func(ctx *pulumi.Context) error {\n\t\taz, err := random.NewShuffle(ctx, \"az\", \u0026random.ShuffleArgs{\n\t\t\tInputs: pulumi.StringArray{\n\t\t\t\tpulumi.String(\"us-west-1a\"),\n\t\t\t\tpulumi.String(\"us-west-1c\"),\n\t\t\t\tpulumi.String(\"us-west-1d\"),\n\t\t\t\tpulumi.String(\"us-west-1e\"),\n\t\t\t},\n\t\t\tResultCount: pulumi.Float64(2),\n\t\t})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\t_, err = elb.NewLoadBalancer(ctx, \"example\", \u0026elb.LoadBalancerArgs{\n\t\t\tAvailabilityZones: az.Results,\n\t\t})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\treturn nil\n\t})\n}\n```\n```java\npackage generated_program;\n\nimport com.pulumi.Context;\nimport com.pulumi.Pulumi;\nimport com.pulumi.core.Output;\nimport com.pulumi.random.Shuffle;\nimport com.pulumi.random.ShuffleArgs;\nimport com.pulumi.aws.elb.LoadBalancer;\nimport com.pulumi.aws.elb.LoadBalancerArgs;\nimport java.util.List;\nimport java.util.ArrayList;\nimport java.util.Map;\nimport java.io.File;\nimport java.nio.file.Files;\nimport java.nio.file.Paths;\n\npublic class App {\n public static void main(String[] args) {\n Pulumi.run(App::stack);\n }\n\n public static void stack(Context ctx) {\n var az = new Shuffle(\"az\", ShuffleArgs.builder()\n .inputs( \n \"us-west-1a\",\n \"us-west-1c\",\n \"us-west-1d\",\n \"us-west-1e\")\n .resultCount(2)\n .build());\n\n var example = new LoadBalancer(\"example\", LoadBalancerArgs.builder()\n .availabilityZones(az.results())\n .build());\n\n // ... and other aws_elb arguments ...\n }\n}\n```\n```yaml\nresources:\n az:\n type: random:Shuffle\n properties:\n inputs:\n - us-west-1a\n - us-west-1c\n - us-west-1d\n - us-west-1e\n resultCount: 2\n example:\n type: aws:elb:LoadBalancer\n properties:\n # Place the ELB in any two of the given availability zones, selected\n # # at random.\n availabilityZones: ${az.results}\n```\n\u003c!--End PulumiCodeChooser --\u003e\n", + "properties": { + "inputs": { + "type": "array", + "items": { + "type": "string" + }, + "description": "The list of strings to shuffle.\n" + }, + "keepers": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.\n" + }, + "resultCount": { + "type": "number", + "description": "The number of results to return. Defaults to the number of items in the `input` list. If fewer items are requested, some elements will be excluded from the result. If more items are requested, items will be repeated in the result but not more frequently than the number of items in the input list.\n" + }, + "results": { + "type": "array", + "items": { + "type": "string" + }, + "description": "Random permutation of the list of strings given in `input`. The number of elements is determined by `result_count` if\nset, or the number of elements in `input`.\n" + }, + "seed": { + "type": "string", + "description": "Arbitrary string with which to seed the random number generator, in order to produce less-volatile permutations of the list.\n" + } + }, + "required": [ + "inputs", + "results" + ], + "inputProperties": { + "inputs": { + "type": "array", + "items": { + "type": "string" + }, + "description": "The list of strings to shuffle.\n" + }, + "keepers": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.\n" + }, + "resultCount": { + "type": "number", + "description": "The number of results to return. Defaults to the number of items in the `input` list. If fewer items are requested, some elements will be excluded from the result. If more items are requested, items will be repeated in the result but not more frequently than the number of items in the input list.\n" + }, + "seed": { + "type": "string", + "description": "Arbitrary string with which to seed the random number generator, in order to produce less-volatile permutations of the list.\n" + } + }, + "requiredInputs": [ + "inputs" + ], + "stateInputs": { + "description": "Input properties used for looking up and filtering Shuffle resources.\n", + "properties": { + "inputs": { + "type": "array", + "items": { + "type": "string" + }, + "description": "The list of strings to shuffle.\n" + }, + "keepers": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.\n" + }, + "resultCount": { + "type": "number", + "description": "The number of results to return. Defaults to the number of items in the `input` list. If fewer items are requested, some elements will be excluded from the result. If more items are requested, items will be repeated in the result but not more frequently than the number of items in the input list.\n" + }, + "results": { + "type": "array", + "items": { + "type": "string" + }, + "description": "Random permutation of the list of strings given in `input`. The number of elements is determined by `result_count` if\nset, or the number of elements in `input`.\n" + }, + "seed": { + "type": "string", + "description": "Arbitrary string with which to seed the random number generator, in order to produce less-volatile permutations of the list.\n" + } + }, + "type": "object" + } + }, + "random:index/string:String": { + "description": "The resource `random.String` generates a random permutation of alphanumeric characters and optionally special characters.\n\nThis resource *does* use a cryptographic random number generator.\n\nHistorically this resource's intended usage has been ambiguous as the original example used it in a password. For backwards compatibility it will continue to exist. For unique ids please use random_id, for sensitive random values please use random_password.\n\n## Example Usage\n\n\u003c!--Start PulumiCodeChooser --\u003e\n```typescript\nimport * as pulumi from \"@pulumi/pulumi\";\nimport * as random from \"@pulumi/random\";\n\nconst random = new random.String(\"random\", {\n length: 16,\n overrideSpecial: \"/@£$\",\n special: true,\n});\n```\n```python\nimport pulumi\nimport pulumi_random as random\n\nrandom = random.String(\"random\",\n length=16,\n override_special=\"/@£$\",\n special=True)\n```\n```csharp\nusing System.Collections.Generic;\nusing System.Linq;\nusing Pulumi;\nusing Random = Pulumi.Random;\n\nreturn await Deployment.RunAsync(() =\u003e \n{\n var random = new Random.String(\"random\", new()\n {\n Length = 16,\n OverrideSpecial = \"/@£$\",\n Special = true,\n });\n\n});\n```\n```go\npackage main\n\nimport (\n\t\"github.com/pulumi/pulumi-terraform-provider/sdks/go/random/v3/random\"\n\t\"github.com/pulumi/pulumi/sdk/v3/go/pulumi\"\n)\n\nfunc main() {\n\tpulumi.Run(func(ctx *pulumi.Context) error {\n\t\t_, err := random.NewString(ctx, \"random\", \u0026random.StringArgs{\n\t\t\tLength: pulumi.Float64(16),\n\t\t\tOverrideSpecial: pulumi.String(\"/@£$\"),\n\t\t\tSpecial: pulumi.Bool(true),\n\t\t})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\treturn nil\n\t})\n}\n```\n```java\npackage generated_program;\n\nimport com.pulumi.Context;\nimport com.pulumi.Pulumi;\nimport com.pulumi.core.Output;\nimport com.pulumi.random.String;\nimport com.pulumi.random.StringArgs;\nimport java.util.List;\nimport java.util.ArrayList;\nimport java.util.Map;\nimport java.io.File;\nimport java.nio.file.Files;\nimport java.nio.file.Paths;\n\npublic class App {\n public static void main(String[] args) {\n Pulumi.run(App::stack);\n }\n\n public static void stack(Context ctx) {\n var random = new String(\"random\", StringArgs.builder()\n .length(16)\n .overrideSpecial(\"/@£$\")\n .special(true)\n .build());\n\n }\n}\n```\n```yaml\nresources:\n random:\n type: random:String\n properties:\n length: 16\n overrideSpecial: /@£$\n special: true\n```\n\u003c!--End PulumiCodeChooser --\u003e\n\n## Import\n\n### Avoiding Replacement\n\n```sh\n$ pulumi import random:index/string:String If the resource were imported using `random_string.test test`,\n```\n\nreplacement can be avoided by using:\n\n1. Attribute values that match the imported ID and defaults:\n\n terraform\n\n resource \"random_string\" \"test\" {\n\n length = 4\n\n lower = true\n\n }\n\n2. Attribute values that match the imported ID and omit the attributes with defaults:\n\n terraform\n\n resource \"random_string\" \"test\" {\n\n length = 4\n\n }\n\n3. `ignore_changes` specifying the attributes to ignore:\n\n terraform\n\n resource \"random_string\" \"test\" {\n\n length = 16\n\n lower = false\n\n lifecycle {\n\n ignore_changes = [\n\n length,\n\n lower,\n\n ]\n\n }\n\n }\n\n **NOTE** `ignore_changes` is only required until the resource is recreated after import,\n\n after which it will use the configuration values specified.\n\n", + "properties": { + "keepers": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.\n" + }, + "length": { + "type": "number", + "description": "The length of the string desired. The minimum value for length is 1 and, length must also be \u003e= (`min_upper` + `min_lower` + `min_numeric` + `min_special`).\n" + }, + "lower": { + "type": "boolean", + "description": "Include lowercase alphabet characters in the result. Default value is `true`.\n" + }, + "minLower": { + "type": "number", + "description": "Minimum number of lowercase alphabet characters in the result. Default value is `0`.\n" + }, + "minNumeric": { + "type": "number", + "description": "Minimum number of numeric characters in the result. Default value is `0`.\n" + }, + "minSpecial": { + "type": "number", + "description": "Minimum number of special characters in the result. Default value is `0`.\n" + }, + "minUpper": { + "type": "number", + "description": "Minimum number of uppercase alphabet characters in the result. Default value is `0`.\n" + }, + "number": { + "type": "boolean", + "description": "Include numeric characters in the result. Default value is `true`. If `number`, `upper`, `lower`, and `special` are all configured, at least one of them must be set to `true`. **NOTE**: This is deprecated, use `numeric` instead.\n", + "deprecationMessage": "Deprecated" + }, + "numeric": { + "type": "boolean", + "description": "Include numeric characters in the result. Default value is `true`. If `numeric`, `upper`, `lower`, and `special` are all configured, at least one of them must be set to `true`.\n" + }, + "overrideSpecial": { + "type": "string", + "description": "Supply your own list of special characters to use for string generation. This overrides the default character list in the special argument. The `special` argument must still be set to true for any overwritten characters to be used in generation.\n" + }, + "result": { + "type": "string", + "description": "The generated random string.\n" + }, + "special": { + "type": "boolean", + "description": "Include special characters in the result. These are `!@#$%\u0026*()-_=+[]{}\u003c\u003e:?`. Default value is `true`.\n" + }, + "upper": { + "type": "boolean", + "description": "Include uppercase alphabet characters in the result. Default value is `true`.\n" + } + }, + "required": [ + "length", + "lower", + "minLower", + "minNumeric", + "minSpecial", + "minUpper", + "number", + "numeric", + "result", + "special", + "upper" + ], + "inputProperties": { + "keepers": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.\n" + }, + "length": { + "type": "number", + "description": "The length of the string desired. The minimum value for length is 1 and, length must also be \u003e= (`min_upper` + `min_lower` + `min_numeric` + `min_special`).\n" + }, + "lower": { + "type": "boolean", + "description": "Include lowercase alphabet characters in the result. Default value is `true`.\n" + }, + "minLower": { + "type": "number", + "description": "Minimum number of lowercase alphabet characters in the result. Default value is `0`.\n" + }, + "minNumeric": { + "type": "number", + "description": "Minimum number of numeric characters in the result. Default value is `0`.\n" + }, + "minSpecial": { + "type": "number", + "description": "Minimum number of special characters in the result. Default value is `0`.\n" + }, + "minUpper": { + "type": "number", + "description": "Minimum number of uppercase alphabet characters in the result. Default value is `0`.\n" + }, + "number": { + "type": "boolean", + "description": "Include numeric characters in the result. Default value is `true`. If `number`, `upper`, `lower`, and `special` are all configured, at least one of them must be set to `true`. **NOTE**: This is deprecated, use `numeric` instead.\n", + "deprecationMessage": "Deprecated" + }, + "numeric": { + "type": "boolean", + "description": "Include numeric characters in the result. Default value is `true`. If `numeric`, `upper`, `lower`, and `special` are all configured, at least one of them must be set to `true`.\n" + }, + "overrideSpecial": { + "type": "string", + "description": "Supply your own list of special characters to use for string generation. This overrides the default character list in the special argument. The `special` argument must still be set to true for any overwritten characters to be used in generation.\n" + }, + "special": { + "type": "boolean", + "description": "Include special characters in the result. These are `!@#$%\u0026*()-_=+[]{}\u003c\u003e:?`. Default value is `true`.\n" + }, + "upper": { + "type": "boolean", + "description": "Include uppercase alphabet characters in the result. Default value is `true`.\n" + } + }, + "requiredInputs": [ + "length" + ], + "stateInputs": { + "description": "Input properties used for looking up and filtering String resources.\n", + "properties": { + "keepers": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.\n" + }, + "length": { + "type": "number", + "description": "The length of the string desired. The minimum value for length is 1 and, length must also be \u003e= (`min_upper` + `min_lower` + `min_numeric` + `min_special`).\n" + }, + "lower": { + "type": "boolean", + "description": "Include lowercase alphabet characters in the result. Default value is `true`.\n" + }, + "minLower": { + "type": "number", + "description": "Minimum number of lowercase alphabet characters in the result. Default value is `0`.\n" + }, + "minNumeric": { + "type": "number", + "description": "Minimum number of numeric characters in the result. Default value is `0`.\n" + }, + "minSpecial": { + "type": "number", + "description": "Minimum number of special characters in the result. Default value is `0`.\n" + }, + "minUpper": { + "type": "number", + "description": "Minimum number of uppercase alphabet characters in the result. Default value is `0`.\n" + }, + "number": { + "type": "boolean", + "description": "Include numeric characters in the result. Default value is `true`. If `number`, `upper`, `lower`, and `special` are all configured, at least one of them must be set to `true`. **NOTE**: This is deprecated, use `numeric` instead.\n", + "deprecationMessage": "Deprecated" + }, + "numeric": { + "type": "boolean", + "description": "Include numeric characters in the result. Default value is `true`. If `numeric`, `upper`, `lower`, and `special` are all configured, at least one of them must be set to `true`.\n" + }, + "overrideSpecial": { + "type": "string", + "description": "Supply your own list of special characters to use for string generation. This overrides the default character list in the special argument. The `special` argument must still be set to true for any overwritten characters to be used in generation.\n" + }, + "result": { + "type": "string", + "description": "The generated random string.\n" + }, + "special": { + "type": "boolean", + "description": "Include special characters in the result. These are `!@#$%\u0026*()-_=+[]{}\u003c\u003e:?`. Default value is `true`.\n" + }, + "upper": { + "type": "boolean", + "description": "Include uppercase alphabet characters in the result. Default value is `true`.\n" + } + }, + "type": "object" + } + }, + "random:index/uuid:Uuid": { + "description": "## Example Usage\n\n\u003c!--Start PulumiCodeChooser --\u003e\n```typescript\nimport * as pulumi from \"@pulumi/pulumi\";\nimport * as azurerm from \"@pulumi/azurerm\";\nimport * as random from \"@pulumi/random\";\n\n// The following example shows how to generate a unique name for an Azure Resource Group.\nconst testUuid = new random.Uuid(\"testUuid\", {});\nconst testazurerm_resource_group = new azurerm.index.Azurerm_resource_group(\"testazurerm_resource_group\", {\n name: `${testUuid.result}-rg`,\n location: \"Central US\",\n});\n```\n```python\nimport pulumi\nimport pulumi_azurerm as azurerm\nimport pulumi_random as random\n\n# The following example shows how to generate a unique name for an Azure Resource Group.\ntest_uuid = random.Uuid(\"testUuid\")\ntestazurerm_resource_group = azurerm.index.Azurerm_resource_group(\"testazurerm_resource_group\",\n name=f{test_uuid.result}-rg,\n location=Central US)\n```\n```csharp\nusing System.Collections.Generic;\nusing System.Linq;\nusing Pulumi;\nusing Azurerm = Pulumi.Azurerm;\nusing Random = Pulumi.Random;\n\nreturn await Deployment.RunAsync(() =\u003e \n{\n // The following example shows how to generate a unique name for an Azure Resource Group.\n var testUuid = new Random.Uuid(\"testUuid\");\n\n var testazurerm_resource_group = new Azurerm.Index.Azurerm_resource_group(\"testazurerm_resource_group\", new()\n {\n Name = $\"{testUuid.Result}-rg\",\n Location = \"Central US\",\n });\n\n});\n```\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/pulumi/pulumi-azurerm/sdk/go/azurerm\"\n\t\"github.com/pulumi/pulumi-terraform-provider/sdks/go/random/v3/random\"\n\t\"github.com/pulumi/pulumi/sdk/v3/go/pulumi\"\n)\n\nfunc main() {\n\tpulumi.Run(func(ctx *pulumi.Context) error {\n\t\t// The following example shows how to generate a unique name for an Azure Resource Group.\n\t\ttestUuid, err := random.NewUuid(ctx, \"testUuid\", nil)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\t_, err = azurerm.NewAzurerm_resource_group(ctx, \"testazurerm_resource_group\", \u0026azurerm.Azurerm_resource_groupArgs{\n\t\t\tName: pulumi.Sprintf(\"%v-rg\", testUuid.Result),\n\t\t\tLocation: \"Central US\",\n\t\t})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\treturn nil\n\t})\n}\n```\n```java\npackage generated_program;\n\nimport com.pulumi.Context;\nimport com.pulumi.Pulumi;\nimport com.pulumi.core.Output;\nimport com.pulumi.random.Uuid;\nimport com.pulumi.azurerm.azurerm_resource_group;\nimport com.pulumi.azurerm.Azurerm_resource_groupArgs;\nimport java.util.List;\nimport java.util.ArrayList;\nimport java.util.Map;\nimport java.io.File;\nimport java.nio.file.Files;\nimport java.nio.file.Paths;\n\npublic class App {\n public static void main(String[] args) {\n Pulumi.run(App::stack);\n }\n\n public static void stack(Context ctx) {\n // The following example shows how to generate a unique name for an Azure Resource Group.\n var testUuid = new Uuid(\"testUuid\");\n\n var testazurerm_resource_group = new Azurerm_resource_group(\"testazurerm_resource_group\", Azurerm_resource_groupArgs.builder()\n .name(String.format(\"%s-rg\", testUuid.result()))\n .location(\"Central US\")\n .build());\n\n }\n}\n```\n```yaml\nresources:\n # The following example shows how to generate a unique name for an Azure Resource Group.\n testUuid:\n type: random:Uuid\n testazurerm_resource_group:\n type: azurerm:azurerm_resource_group\n properties:\n name: ${testUuid.result}-rg\n location: Central US\n```\n\u003c!--End PulumiCodeChooser --\u003e\n\n## Import\n\nRandom UUID's can be imported. This can be used to replace a config\n\nvalue with a value interpolated from the random provider without\n\nexperiencing diffs.\n\n```sh\n$ pulumi import random:index/uuid:Uuid main aabbccdd-eeff-0011-2233-445566778899\n```\n\n", + "properties": { + "keepers": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.\n" + }, + "result": { + "type": "string", + "description": "The generated uuid presented in string format.\n" + } + }, + "required": [ + "result" + ], + "inputProperties": { + "keepers": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.\n" + } + }, + "stateInputs": { + "description": "Input properties used for looking up and filtering Uuid resources.\n", + "properties": { + "keepers": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.\n" + }, + "result": { + "type": "string", + "description": "The generated uuid presented in string format.\n" + } + }, + "type": "object" + } + } + }, + "parameterization": { + "baseProvider": { + "name": "terraform-provider", + "version": "0.0.0-dev" + }, + "parameter": "eyJyZW1vdGUiOnsidXJsIjoicmVnaXN0cnkub3BlbnRvZnUub3JnL2hhc2hpY29ycC9yYW5kb20iLCJ2ZXJzaW9uIjoiMy42LjMifX0=" + } +} \ No newline at end of file diff --git a/go.mod b/go.mod index e9f28aeeb..e8d1b223f 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/pulumi/pulumi-terraform-bridge/v3 -go 1.22.0 +go 1.22.3 toolchain go1.23.2 diff --git a/internal/testprovider_sdkv2/cmd/pulumi-resource-tpsdkv2/schema.json b/internal/testprovider_sdkv2/cmd/pulumi-resource-tpsdkv2/schema.json index 40a76cabf..a2325fbc0 100644 --- a/internal/testprovider_sdkv2/cmd/pulumi-resource-tpsdkv2/schema.json +++ b/internal/testprovider_sdkv2/cmd/pulumi-resource-tpsdkv2/schema.json @@ -6,12 +6,12 @@ }, "language": { "nodejs": { - "readme": "\u003e This provider is a derived work of the [Terraform Provider](https://github.com/terraform-providers/terraform-provider-tpsdkv2)\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-tpsdkv2` repo](/issues); however, if that doesn't turn up anything,\n\u003e please consult the source [`terraform-provider-tpsdkv2` repo](https://github.com/terraform-providers/terraform-provider-tpsdkv2/issues).", + "readme": "\u003e This provider is a derived work of the [Terraform Provider](https://github.com/terraform-providers/terraform-provider-tpsdkv2)\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 please consult the source [`terraform-provider-tpsdkv2` repo](https://github.com/terraform-providers/terraform-provider-tpsdkv2/issues).", "compatibility": "tfbridge20", "disableUnionOutputTypes": true }, "python": { - "readme": "\u003e This provider is a derived work of the [Terraform Provider](https://github.com/terraform-providers/terraform-provider-tpsdkv2)\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-tpsdkv2` repo](/issues); however, if that doesn't turn up anything,\n\u003e please consult the source [`terraform-provider-tpsdkv2` repo](https://github.com/terraform-providers/terraform-provider-tpsdkv2/issues).", + "readme": "\u003e This provider is a derived work of the [Terraform Provider](https://github.com/terraform-providers/terraform-provider-tpsdkv2)\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 please consult the source [`terraform-provider-tpsdkv2` repo](https://github.com/terraform-providers/terraform-provider-tpsdkv2/issues).", "compatibility": "tfbridge20", "pyproject": {} } diff --git a/pkg/pf/tfgen/main.go b/pkg/pf/tfgen/main.go index 057b44aac..0f82f51aa 100644 --- a/pkg/pf/tfgen/main.go +++ b/pkg/pf/tfgen/main.go @@ -53,8 +53,9 @@ func Main(provider string, info sdkBridge.ProviderInfo) { if err := check.Provider(g.Sink(), info); err != nil { return err } + _, err = g.Generate() - return g.Generate() + return err }) } @@ -109,6 +110,7 @@ func MainWithMuxer(provider string, info sdkBridge.ProviderInfo) { return err } - return g.Generate() + _, err = g.Generate() + return err }) } diff --git a/pkg/tf2pulumi/convert/testdata/schemas/blocks.json b/pkg/tf2pulumi/convert/testdata/schemas/blocks.json index 12f40109f..7f7ebdb1b 100644 --- a/pkg/tf2pulumi/convert/testdata/schemas/blocks.json +++ b/pkg/tf2pulumi/convert/testdata/schemas/blocks.json @@ -1,17 +1,18 @@ { "name": "blocks", "attribution": "This Pulumi package is based on the [`blocks` Terraform Provider](https://github.com/terraform-providers/terraform-provider-blocks).", + "repository": "https://github.com/pulumi/pulumi-blocks", "meta": { "moduleFormat": "(.*)(?:/[^/]*)" }, "language": { "nodejs": { - "readme": "\u003e This provider is a derived work of the [Terraform Provider](https://github.com/terraform-providers/terraform-provider-blocks)\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-blocks` repo](/issues); however, if that doesn't turn up anything,\n\u003e please consult the source [`terraform-provider-blocks` repo](https://github.com/terraform-providers/terraform-provider-blocks/issues).", + "readme": "\u003e This provider is a derived work of the [Terraform Provider](https://github.com/terraform-providers/terraform-provider-blocks)\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-blocks` repo](https://github.com/pulumi/pulumi-blocks/issues); however, if that doesn't turn up anything,\n\u003e please consult the source [`terraform-provider-blocks` repo](https://github.com/terraform-providers/terraform-provider-blocks/issues).", "compatibility": "tfbridge20", "disableUnionOutputTypes": true }, "python": { - "readme": "\u003e This provider is a derived work of the [Terraform Provider](https://github.com/terraform-providers/terraform-provider-blocks)\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-blocks` repo](/issues); however, if that doesn't turn up anything,\n\u003e please consult the source [`terraform-provider-blocks` repo](https://github.com/terraform-providers/terraform-provider-blocks/issues).", + "readme": "\u003e This provider is a derived work of the [Terraform Provider](https://github.com/terraform-providers/terraform-provider-blocks)\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-blocks` repo](https://github.com/pulumi/pulumi-blocks/issues); however, if that doesn't turn up anything,\n\u003e please consult the source [`terraform-provider-blocks` repo](https://github.com/terraform-providers/terraform-provider-blocks/issues).", "compatibility": "tfbridge20", "pyproject": {} } diff --git a/pkg/tf2pulumi/convert/testdata/schemas/complex.json b/pkg/tf2pulumi/convert/testdata/schemas/complex.json index 7a1996854..5c5adaf33 100644 --- a/pkg/tf2pulumi/convert/testdata/schemas/complex.json +++ b/pkg/tf2pulumi/convert/testdata/schemas/complex.json @@ -1,17 +1,18 @@ { "name": "complex", "attribution": "This Pulumi package is based on the [`complex` Terraform Provider](https://github.com/terraform-providers/terraform-provider-complex).", + "repository": "https://github.com/pulumi/pulumi-complex", "meta": { "moduleFormat": "(.*)(?:/[^/]*)" }, "language": { "nodejs": { - "readme": "\u003e This provider is a derived work of the [Terraform Provider](https://github.com/terraform-providers/terraform-provider-complex)\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-complex` repo](/issues); however, if that doesn't turn up anything,\n\u003e please consult the source [`terraform-provider-complex` repo](https://github.com/terraform-providers/terraform-provider-complex/issues).", + "readme": "\u003e This provider is a derived work of the [Terraform Provider](https://github.com/terraform-providers/terraform-provider-complex)\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-complex` repo](https://github.com/pulumi/pulumi-complex/issues); however, if that doesn't turn up anything,\n\u003e please consult the source [`terraform-provider-complex` repo](https://github.com/terraform-providers/terraform-provider-complex/issues).", "compatibility": "tfbridge20", "disableUnionOutputTypes": true }, "python": { - "readme": "\u003e This provider is a derived work of the [Terraform Provider](https://github.com/terraform-providers/terraform-provider-complex)\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-complex` repo](/issues); however, if that doesn't turn up anything,\n\u003e please consult the source [`terraform-provider-complex` repo](https://github.com/terraform-providers/terraform-provider-complex/issues).", + "readme": "\u003e This provider is a derived work of the [Terraform Provider](https://github.com/terraform-providers/terraform-provider-complex)\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-complex` repo](https://github.com/pulumi/pulumi-complex/issues); however, if that doesn't turn up anything,\n\u003e please consult the source [`terraform-provider-complex` repo](https://github.com/terraform-providers/terraform-provider-complex/issues).", "compatibility": "tfbridge20", "pyproject": {} } diff --git a/pkg/tf2pulumi/convert/testdata/schemas/renames.json b/pkg/tf2pulumi/convert/testdata/schemas/renames.json index d600f0ae2..679fcd24b 100644 --- a/pkg/tf2pulumi/convert/testdata/schemas/renames.json +++ b/pkg/tf2pulumi/convert/testdata/schemas/renames.json @@ -1,17 +1,18 @@ { "name": "renames", "attribution": "This Pulumi package is based on the [`renames` Terraform Provider](https://github.com/terraform-providers/terraform-provider-renames).", + "repository": "https://github.com/pulumi/pulumi-renames", "meta": { "moduleFormat": "(.*)(?:/[^/]*)" }, "language": { "nodejs": { - "readme": "\u003e This provider is a derived work of the [Terraform Provider](https://github.com/terraform-providers/terraform-provider-renames)\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-renames` repo](/issues); however, if that doesn't turn up anything,\n\u003e please consult the source [`terraform-provider-renames` repo](https://github.com/terraform-providers/terraform-provider-renames/issues).", + "readme": "\u003e This provider is a derived work of the [Terraform Provider](https://github.com/terraform-providers/terraform-provider-renames)\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-renames` repo](https://github.com/pulumi/pulumi-renames/issues); however, if that doesn't turn up anything,\n\u003e please consult the source [`terraform-provider-renames` repo](https://github.com/terraform-providers/terraform-provider-renames/issues).", "compatibility": "tfbridge20", "disableUnionOutputTypes": true }, "python": { - "readme": "\u003e This provider is a derived work of the [Terraform Provider](https://github.com/terraform-providers/terraform-provider-renames)\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-renames` repo](/issues); however, if that doesn't turn up anything,\n\u003e please consult the source [`terraform-provider-renames` repo](https://github.com/terraform-providers/terraform-provider-renames/issues).", + "readme": "\u003e This provider is a derived work of the [Terraform Provider](https://github.com/terraform-providers/terraform-provider-renames)\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-renames` repo](https://github.com/pulumi/pulumi-renames/issues); however, if that doesn't turn up anything,\n\u003e please consult the source [`terraform-provider-renames` repo](https://github.com/terraform-providers/terraform-provider-renames/issues).", "compatibility": "tfbridge20", "pyproject": {} } diff --git a/pkg/tf2pulumi/convert/testdata/schemas/simple.json b/pkg/tf2pulumi/convert/testdata/schemas/simple.json index 1b3a13fde..bda221e9c 100644 --- a/pkg/tf2pulumi/convert/testdata/schemas/simple.json +++ b/pkg/tf2pulumi/convert/testdata/schemas/simple.json @@ -1,17 +1,18 @@ { "name": "simple", "attribution": "This Pulumi package is based on the [`simple` Terraform Provider](https://github.com/terraform-providers/terraform-provider-simple).", + "repository": "https://github.com/pulumi/pulumi-simple", "meta": { "moduleFormat": "(.*)(?:/[^/]*)" }, "language": { "nodejs": { - "readme": "\u003e This provider is a derived work of the [Terraform Provider](https://github.com/terraform-providers/terraform-provider-simple)\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-simple` repo](/issues); however, if that doesn't turn up anything,\n\u003e please consult the source [`terraform-provider-simple` repo](https://github.com/terraform-providers/terraform-provider-simple/issues).", + "readme": "\u003e This provider is a derived work of the [Terraform Provider](https://github.com/terraform-providers/terraform-provider-simple)\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-simple` repo](https://github.com/pulumi/pulumi-simple/issues); however, if that doesn't turn up anything,\n\u003e please consult the source [`terraform-provider-simple` repo](https://github.com/terraform-providers/terraform-provider-simple/issues).", "compatibility": "tfbridge20", "disableUnionOutputTypes": true }, "python": { - "readme": "\u003e This provider is a derived work of the [Terraform Provider](https://github.com/terraform-providers/terraform-provider-simple)\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-simple` repo](/issues); however, if that doesn't turn up anything,\n\u003e please consult the source [`terraform-provider-simple` repo](https://github.com/terraform-providers/terraform-provider-simple/issues).", + "readme": "\u003e This provider is a derived work of the [Terraform Provider](https://github.com/terraform-providers/terraform-provider-simple)\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-simple` repo](https://github.com/pulumi/pulumi-simple/issues); however, if that doesn't turn up anything,\n\u003e please consult the source [`terraform-provider-simple` repo](https://github.com/terraform-providers/terraform-provider-simple/issues).", "compatibility": "tfbridge20", "pyproject": {} } diff --git a/pkg/tfbridge/info/info.go b/pkg/tfbridge/info/info.go index bcc461bc0..26037c941 100644 --- a/pkg/tfbridge/info/info.go +++ b/pkg/tfbridge/info/info.go @@ -119,7 +119,7 @@ type Provider struct { // Rules that control file discovery and edits for any subset of docs in a provider. DocRules *DocRule - // An optional file path to the root of the upstream provider's git repo, for use in docs generation. + // An optional local file path to the root of the upstream provider's git repo, for use in docs generation. // // If UpstreamRepoPath is left blank, it is inferred to the location where Go downloaded the build // dependency of the provider. The following fields influence the inference decision: diff --git a/pkg/tfgen/convert_cli_test.go b/pkg/tfgen/convert_cli_test.go index d8a7bac60..21c134d52 100644 --- a/pkg/tfgen/convert_cli_test.go +++ b/pkg/tfgen/convert_cli_test.go @@ -183,7 +183,7 @@ output "someOutput" { }) assert.NoError(t, err) - err = g.Generate() + _, err = g.Generate() assert.NoError(t, err) d, err := os.ReadFile(filepath.Join(tempdir, "schema.json")) @@ -283,7 +283,7 @@ resource "azurerm_web_pubsub_custom_certificate" "test" { }) require.NoError(t, err) - err = g.Generate() + _, err = g.Generate() require.NoError(t, err) }) @@ -337,7 +337,7 @@ This is some intentionally broken HCL that should not convert. }) require.NoError(t, err) - err = g.Generate() + _, err = g.Generate() require.NoError(t, err) autogold.Expect("").Equal(t, stdout.String()) @@ -413,7 +413,7 @@ This is some intentionally broken HCL that should not convert. }) require.NoError(t, err) - err = g.Generate() + _, err = g.Generate() require.NoError(t, err) require.NotContains(t, stdout.String(), cliConverterErrUnexpectedHCLSnippet) diff --git a/pkg/tfgen/docs_test.go b/pkg/tfgen/docs_test.go index 604866657..2995ea9c3 100644 --- a/pkg/tfgen/docs_test.go +++ b/pkg/tfgen/docs_test.go @@ -2165,7 +2165,7 @@ throw new Exception("!"); }) assert.NoError(t, err) - err = g.Generate() + _, err = g.Generate() assert.NoError(t, err) f, err := inmem.Open("schema.json") diff --git a/pkg/tfgen/generate.go b/pkg/tfgen/generate.go index 2027b009a..09cf83bd2 100644 --- a/pkg/tfgen/generate.go +++ b/pkg/tfgen/generate.go @@ -828,7 +828,6 @@ type GeneratorOptions struct { // NewGenerator returns a code-generator for the given language runtime and package info. func NewGenerator(opts GeneratorOptions) (*Generator, error) { pkgName, version, lang, info, root := opts.Package, opts.Version, opts.Language, opts.ProviderInfo, opts.Root - pkg := tokens.NewPackageToken(tokens.PackageName(tokens.IntoQName(pkgName))) // Ensure the language is valid. @@ -926,10 +925,10 @@ type GenerateOptions struct { } // Generate creates Pulumi packages from the information it was initialized with. -func (g *Generator) Generate() error { +func (g *Generator) Generate() (*GenerateSchemaResult, error) { genSchemaResult, err := g.generateSchemaResult(context.Background()) if err != nil { - return err + return nil, err } // Now push the schema through the rest of the generator. @@ -953,7 +952,6 @@ func (g *Generator) generateSchemaResult(ctx context.Context) (*GenerateSchemaRe if err != nil { return nil, errors.Wrapf(err, "failed to create Pulumi schema") } - // Apply schema post-processing if defined in the provider. if g.info.SchemaPostProcessor != nil { g.info.SchemaPostProcessor(&pulumiPackageSpec) @@ -968,7 +966,7 @@ func (g *Generator) generateSchemaResult(ctx context.Context) (*GenerateSchemaRe // This is an unstable API. We have exposed it so other packages within // pulumi-terraform-bridge can consume it. We do not recommend other packages consume this // API. -func (g *Generator) UnstableGenerateFromSchema(genSchemaResult *GenerateSchemaResult) error { +func (g *Generator) UnstableGenerateFromSchema(genSchemaResult *GenerateSchemaResult) (*GenerateSchemaResult, error) { pulumiPackageSpec := genSchemaResult.PackageSpec schemaStats = schemaTools.CountStats(pulumiPackageSpec) @@ -976,20 +974,19 @@ func (g *Generator) UnstableGenerateFromSchema(genSchemaResult *GenerateSchemaRe var err error g.providerShim.schema, err = json.Marshal(pulumiPackageSpec) if err != nil { - return errors.Wrapf(err, "failed to marshal intermediate schema") + return nil, errors.Wrapf(err, "failed to marshal intermediate schema") } // Add any supplemental examples: err = addExtraHclExamplesToResources(g.info.ExtraResourceHclExamples, &pulumiPackageSpec) if err != nil { - return err + return nil, err } err = addExtraHclExamplesToFunctions(g.info.ExtraFunctionHclExamples, &pulumiPackageSpec) if err != nil { - return err + return nil, err } - // Convert examples. if !g.skipExamples { pulumiPackageSpec = g.convertExamplesInSchema(pulumiPackageSpec) @@ -1004,11 +1001,11 @@ func (g *Generator) UnstableGenerateFromSchema(genSchemaResult *GenerateSchemaRe source := NewGitRepoDocsSource(g) installationFile, err := source.getInstallation(nil) if err != nil { - return errors.Wrapf(err, "failed to obtain an index.md file for this provider") + return nil, errors.Wrapf(err, "failed to obtain an index.md file for this provider") } content, err := plainDocsParser(installationFile, g) if err != nil { - return errors.Wrapf(err, "failed to parse installation docs") + return nil, errors.Wrapf(err, "failed to parse installation docs") } files["_index.md"] = content case Schema: @@ -1017,7 +1014,7 @@ func (g *Generator) UnstableGenerateFromSchema(genSchemaResult *GenerateSchemaRe bytes, err := json.MarshalIndent(pulumiPackageSpec, "", " ") if err != nil { - return errors.Wrapf(err, "failed to marshal schema") + return nil, errors.Wrapf(err, "failed to marshal schema") } files = map[string][]byte{"schema.json": bytes} @@ -1030,7 +1027,7 @@ func (g *Generator) UnstableGenerateFromSchema(genSchemaResult *GenerateSchemaRe } case PCL: if g.skipExamples { - return fmt.Errorf("Cannot set skipExamples and get PCL") + return nil, fmt.Errorf("Cannot set skipExamples and get PCL") } files = map[string][]byte{} for path, code := range g.convertedCode { @@ -1040,13 +1037,13 @@ func (g *Generator) UnstableGenerateFromSchema(genSchemaResult *GenerateSchemaRe default: pulumiPackage, diags, err := pschema.BindSpec(pulumiPackageSpec, nil) if err != nil { - return errors.Wrapf(err, "failed to import Pulumi schema") + return nil, errors.Wrapf(err, "failed to import Pulumi schema") } if diags.HasErrors() { - return err + return nil, err } if files, err = g.language.emitSDK(pulumiPackage, g.info, g.root); err != nil { - return errors.Wrapf(err, "failed to generate package") + return nil, errors.Wrapf(err, "failed to generate package") } } @@ -1058,21 +1055,21 @@ func (g *Generator) UnstableGenerateFromSchema(genSchemaResult *GenerateSchemaRe } } if err := emitFile(g.root, f, contents); err != nil { - return errors.Wrapf(err, "emitting file %v", f) + return nil, errors.Wrapf(err, "emitting file %v", f) } } // Emit the Pulumi project information. if g.language != RegistryDocs { if err = g.emitProjectMetadata(g.pkg, g.language); err != nil { - return errors.Wrapf(err, "failed to create project file") + return nil, errors.Wrapf(err, "failed to create project file") } } // Close the plugin host. g.pluginHost.Close() - return nil + return &GenerateSchemaResult{PackageSpec: pulumiPackageSpec}, nil } // gatherPackage creates a package plus module structure for the entire set of members of this package. diff --git a/pkg/tfgen/generate_schema.go b/pkg/tfgen/generate_schema.go index cfcf52c1d..13f2a94fe 100644 --- a/pkg/tfgen/generate_schema.go +++ b/pkg/tfgen/generate_schema.go @@ -587,16 +587,27 @@ func nodeLanguageExtensions(providerInfo *tfbridge.ProviderInfo, readme string) func getDefaultReadme(pulumiPackageName tokens.Package, tfProviderShortName string, tfGitHubOrg string, pulumiProvLicense tfbridge.TFProviderLicense, pulumiProvLicenseURI string, githubHost string, - pulumiProvRepo string, + sourceRepo string, ) string { //nolint:lll standardDocReadme := `> This provider is a derived work of the [Terraform Provider](https://%[6]s/%[3]s/terraform-provider-%[2]s) > distributed under [%[4]s](%[5]s). If you encounter a bug or missing feature, > first check the [` + "`pulumi-%[1]s`" + ` repo](%[7]s/issues); however, if that doesn't turn up anything, > please consult the source [` + "`terraform-provider-%[2]s`" + ` repo](https://%[6]s/%[3]s/terraform-provider-%[2]s/issues).` + //nolint:lll + dynamicDocReadme := `> This provider is a derived work of the [Terraform Provider](https://%[6]s/%[3]s/terraform-provider-%[2]s) +> distributed under [%[4]s](%[5]s). If you encounter a bug or missing feature, +> please consult the source [` + "`terraform-provider-%[2]s`" + ` repo](https://%[6]s/%[3]s/terraform-provider-%[2]s/issues).` + + var returnReadme string + if strings.Contains(sourceRepo, "pulumi") { + returnReadme = standardDocReadme + } else { + returnReadme = dynamicDocReadme + } - return fmt.Sprintf(standardDocReadme, pulumiPackageName, tfProviderShortName, tfGitHubOrg, pulumiProvLicense, - pulumiProvLicenseURI, githubHost, pulumiProvRepo) + return fmt.Sprintf(returnReadme, pulumiPackageName, tfProviderShortName, tfGitHubOrg, pulumiProvLicense, + pulumiProvLicenseURI, githubHost, sourceRepo) } func (g *schemaGenerator) genDocComment(comment string) string { diff --git a/pkg/tfgen/generate_schema_test.go b/pkg/tfgen/generate_schema_test.go index 9ce5670fa..18b06938e 100644 --- a/pkg/tfgen/generate_schema_test.go +++ b/pkg/tfgen/generate_schema_test.go @@ -222,6 +222,7 @@ func TestTypeSharing(t *testing.T) { }, }), UpstreamRepoPath: tmpdir, + Repository: "https://github.com/pulumi/pulumi-testprov", Resources: map[string]*info.Resource{ "testprov_r1": { Tok: "testprov:index:R1", diff --git a/pkg/tfgen/generate_test.go b/pkg/tfgen/generate_test.go index 0595dd6e8..84c1bf278 100644 --- a/pkg/tfgen/generate_test.go +++ b/pkg/tfgen/generate_test.go @@ -136,6 +136,7 @@ func Test_GenerateTestDataSchemas(t *testing.T) { pkg := strings.Replace(info.Name(), filepath.Ext(info.Name()), "", -1) provInfo, err := providerInfoSource.GetProviderInfo("", "", pkg, "") require.NoError(t, err) + provInfo.Repository = "https://github.com/pulumi/pulumi-" + pkg schema, err := GenerateSchema(*provInfo, nilSink) require.NoError(t, err) diff --git a/pkg/tfgen/main.go b/pkg/tfgen/main.go index 1bd34a42a..4aa68e713 100644 --- a/pkg/tfgen/main.go +++ b/pkg/tfgen/main.go @@ -49,11 +49,7 @@ func Main(pkg string, version string, prov tfbridge.ProviderInfo) { } // Let's generate some code! - err = g.Generate() - if err != nil { - return err - } - + _, err = g.Generate() return err }) } diff --git a/pkg/tfgen/test_data/TestConvertViaPulumiCLI/schema.json b/pkg/tfgen/test_data/TestConvertViaPulumiCLI/schema.json index 90244c719..b224b949b 100644 --- a/pkg/tfgen/test_data/TestConvertViaPulumiCLI/schema.json +++ b/pkg/tfgen/test_data/TestConvertViaPulumiCLI/schema.json @@ -6,12 +6,12 @@ }, "language": { "nodejs": { - "readme": "\u003e This provider is a derived work of the [Terraform Provider](https://github.com/terraform-providers/terraform-provider-simple)\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-simple` repo](/issues); however, if that doesn't turn up anything,\n\u003e please consult the source [`terraform-provider-simple` repo](https://github.com/terraform-providers/terraform-provider-simple/issues).", + "readme": "\u003e This provider is a derived work of the [Terraform Provider](https://github.com/terraform-providers/terraform-provider-simple)\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 please consult the source [`terraform-provider-simple` repo](https://github.com/terraform-providers/terraform-provider-simple/issues).", "compatibility": "tfbridge20", "disableUnionOutputTypes": true }, "python": { - "readme": "\u003e This provider is a derived work of the [Terraform Provider](https://github.com/terraform-providers/terraform-provider-simple)\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-simple` repo](/issues); however, if that doesn't turn up anything,\n\u003e please consult the source [`terraform-provider-simple` repo](https://github.com/terraform-providers/terraform-provider-simple/issues).", + "readme": "\u003e This provider is a derived work of the [Terraform Provider](https://github.com/terraform-providers/terraform-provider-simple)\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 please consult the source [`terraform-provider-simple` repo](https://github.com/terraform-providers/terraform-provider-simple/issues).", "compatibility": "tfbridge20", "pyproject": {} } diff --git a/pkg/tfgen/testdata/TestTypeSharing.golden b/pkg/tfgen/testdata/TestTypeSharing.golden index a846f64e7..727ff09aa 100644 --- a/pkg/tfgen/testdata/TestTypeSharing.golden +++ b/pkg/tfgen/testdata/TestTypeSharing.golden @@ -1,17 +1,18 @@ { "name": "testprov", "attribution": "This Pulumi package is based on the [`testprov` Terraform Provider](https://github.com/terraform-providers/terraform-provider-testprov).", + "repository": "https://github.com/pulumi/pulumi-testprov", "meta": { "moduleFormat": "(.*)(?:/[^/]*)" }, "language": { "nodejs": { - "readme": "\u003e This provider is a derived work of the [Terraform Provider](https://github.com/terraform-providers/terraform-provider-testprov)\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-testprov` repo](/issues); however, if that doesn't turn up anything,\n\u003e please consult the source [`terraform-provider-testprov` repo](https://github.com/terraform-providers/terraform-provider-testprov/issues).", + "readme": "\u003e This provider is a derived work of the [Terraform Provider](https://github.com/terraform-providers/terraform-provider-testprov)\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-testprov` repo](https://github.com/pulumi/pulumi-testprov/issues); however, if that doesn't turn up anything,\n\u003e please consult the source [`terraform-provider-testprov` repo](https://github.com/terraform-providers/terraform-provider-testprov/issues).", "compatibility": "tfbridge20", "disableUnionOutputTypes": true }, "python": { - "readme": "\u003e This provider is a derived work of the [Terraform Provider](https://github.com/terraform-providers/terraform-provider-testprov)\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-testprov` repo](/issues); however, if that doesn't turn up anything,\n\u003e please consult the source [`terraform-provider-testprov` repo](https://github.com/terraform-providers/terraform-provider-testprov/issues).", + "readme": "\u003e This provider is a derived work of the [Terraform Provider](https://github.com/terraform-providers/terraform-provider-testprov)\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-testprov` repo](https://github.com/pulumi/pulumi-testprov/issues); however, if that doesn't turn up anything,\n\u003e please consult the source [`terraform-provider-testprov` repo](https://github.com/terraform-providers/terraform-provider-testprov/issues).", "compatibility": "tfbridge20", "pyproject": {} } diff --git a/testing/go.mod b/testing/go.mod index 4345426aa..d9490efc2 100644 --- a/testing/go.mod +++ b/testing/go.mod @@ -11,7 +11,6 @@ replace github.com/pulumi/pulumi-terraform-bridge/v3 => ../ require github.com/pulumi/pulumi-terraform-bridge/v3 v3.0.0-00010101000000-000000000000 require ( - github.com/kr/text v0.2.0 // indirect github.com/stretchr/testify v1.9.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect google.golang.org/protobuf v1.35.1 // indirect diff --git a/testing/go.sum b/testing/go.sum index a7c2cc6ea..4ab866ff5 100644 --- a/testing/go.sum +++ b/testing/go.sum @@ -1,4 +1,3 @@ -github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= @@ -6,9 +5,8 @@ github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= -github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pulumi/pulumi/sdk/v3 v3.142.0 h1:SmcVddGuvwAh3g3XUVQQ5gVRQUKH1yZ6iETpDNHIHlw=