Skip to content

Commit

Permalink
Add token mapping strategy
Browse files Browse the repository at this point in the history
aq17 authored Mar 9, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents 4030d8e + 926ce22 commit 9942bee
Showing 3 changed files with 235 additions and 38 deletions.
24 changes: 12 additions & 12 deletions provider/go.mod
Original file line number Diff line number Diff line change
@@ -5,8 +5,8 @@ go 1.19
require (
github.com/F5Networks/terraform-provider-bigip v1.16.2
github.com/hashicorp/terraform-plugin-sdk v1.17.2
github.com/pulumi/pulumi-terraform-bridge/v3 v3.40.0
github.com/pulumi/pulumi/sdk/v3 v3.54.0
github.com/pulumi/pulumi-terraform-bridge/v3 v3.42.0
github.com/pulumi/pulumi/sdk/v3 v3.56.0
)

// Fixes build issues on windows: https://github.com/mattn/go-ieproxy/issues/45
@@ -91,7 +91,7 @@ require (
github.com/gedex/inflector v0.0.0-20170307190818-16278e9db813 // indirect
github.com/go-git/gcfg v1.5.0 // indirect
github.com/go-git/go-billy/v5 v5.4.1 // indirect
github.com/go-git/go-git/v5 v5.5.2 // indirect
github.com/go-git/go-git/v5 v5.6.0 // indirect
github.com/gofrs/uuid v4.4.0+incompatible // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt v3.2.1+incompatible // indirect
@@ -112,11 +112,11 @@ require (
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect
github.com/hashicorp/go-getter v1.6.2 // indirect
github.com/hashicorp/go-getter v1.7.0 // indirect
github.com/hashicorp/go-hclog v1.2.2 // indirect
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-plugin v1.4.5 // indirect
github.com/hashicorp/go-plugin v1.4.6 // indirect
github.com/hashicorp/go-retryablehttp v0.7.1 // indirect
github.com/hashicorp/go-rootcerts v1.0.2 // indirect
github.com/hashicorp/go-safetemp v1.0.0 // indirect
@@ -128,7 +128,7 @@ require (
github.com/hashicorp/go-version v1.6.0 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hashicorp/hcl/v2 v2.16.0 // indirect
github.com/hashicorp/hcl/v2 v2.16.1 // indirect
github.com/hashicorp/hil v0.0.0-20190212132231-97b3a9cdfa93 // indirect
github.com/hashicorp/logutils v1.0.0 // indirect
github.com/hashicorp/terraform-svchost v0.1.0 // indirect
@@ -170,16 +170,16 @@ require (
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/pgavlin/goldmark v1.1.33-0.20200616210433-b5eb04559386 // indirect
github.com/pierrec/lz4 v2.6.1+incompatible // indirect
github.com/pjbgf/sha1cd v0.2.3 // indirect
github.com/pjbgf/sha1cd v0.3.0 // indirect
github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 // indirect
github.com/pkg/errors v0.9.1 // indirect
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
github.com/pulumi/pulumi-java/pkg v0.7.1 // indirect
github.com/pulumi/pulumi-java/pkg v0.8.0 // indirect
github.com/pulumi/pulumi-yaml v1.0.4 // indirect
github.com/pulumi/pulumi/pkg/v3 v3.54.0 // indirect
github.com/pulumi/schema-tools v0.1.0 // indirect
github.com/pulumi/pulumi/pkg/v3 v3.56.0 // indirect
github.com/pulumi/schema-tools v0.1.2 // indirect
github.com/pulumi/terraform-diff-reader v0.0.0-20201211191010-ad4715e9285e // indirect
github.com/rivo/uniseg v0.4.3 // indirect
github.com/rogpeppe/go-internal v1.9.0 // indirect
@@ -196,7 +196,7 @@ require (
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/cobra v1.6.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/testify v1.8.1 // indirect
github.com/stretchr/testify v1.8.2 // indirect
github.com/texttheater/golang-levenshtein v1.0.1 // indirect
github.com/tweekmonster/luser v0.0.0-20161003172636-3fa38070dbd7 // indirect
github.com/uber/jaeger-client-go v2.30.0+incompatible // indirect
@@ -216,7 +216,7 @@ require (
gocloud.dev/secrets/hashivault v0.27.0 // indirect
golang.org/x/crypto v0.6.0 // indirect
golang.org/x/mod v0.8.0 // indirect
golang.org/x/net v0.6.0 // indirect
golang.org/x/net v0.7.0 // indirect
golang.org/x/oauth2 v0.5.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.5.0 // indirect
219 changes: 194 additions & 25 deletions provider/go.sum

Large diffs are not rendered by default.

30 changes: 29 additions & 1 deletion provider/resources.go
Original file line number Diff line number Diff line change
@@ -24,8 +24,10 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/pulumi/pulumi-f5bigip/provider/v3/pkg/version"
"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge"
"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge/x"
shimv1 "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim/sdk-v1"
"github.com/pulumi/pulumi/sdk/v3/go/common/tokens"
"github.com/pulumi/pulumi/sdk/v3/go/common/util/contract"
)

// all of the F5 BigIP token components used below.
@@ -71,7 +73,7 @@ func makeDataSource(mod string, res string) tokens.ModuleMember {

// Provider returns additional overlaid schema and metadata associated with the F5 BigIP package.
func Provider() tfbridge.ProviderInfo {
return tfbridge.ProviderInfo{
prov := tfbridge.ProviderInfo{
P: shimv1.NewProvider(bigip.Provider().(*schema.Provider)),
Name: "bigip",
Description: "A Pulumi package for creating and managing F5 BigIP resources.",
@@ -199,4 +201,30 @@ func Provider() tfbridge.ProviderInfo {
Namespaces: namespaceMap,
},
}

// The set of modules that x.TokensKnownModules is aware of.
mappedMods := map[string]string{
"cm": cmMod,
"ltm": ltmMod,
"net": netMod,
"sys": sysMod,
"ssk": sslMod,
"vcmp": vcmpMod,
}

mappedModKeys := make([]string, 0, len(mappedMods))
for k := range mappedMods {
mappedModKeys = append(mappedModKeys, k)
}

moduleNameMap := make(map[string]string, len(mappedMods))
for _, v := range mappedMods {
moduleNameMap[strings.ToLower(v)] = v
}

err := x.ComputeDefaults(&prov, x.TokensKnownModules("alicloud_", "", mappedModKeys,
x.MakeStandardToken(f5BigIPPkg)))
contract.AssertNoError(err)

return prov
}

0 comments on commit 9942bee

Please sign in to comment.