Skip to content

Commit

Permalink
feat: fix bridge stuff (#443)
Browse files Browse the repository at this point in the history
  • Loading branch information
dirien authored Nov 27, 2024
1 parent b7b605e commit a9d03f0
Show file tree
Hide file tree
Showing 10 changed files with 81 additions and 113 deletions.
4 changes: 2 additions & 2 deletions examples/vultr-go/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ go 1.21

require (
github.com/dirien/pulumi-vultr/sdk/v2 v2.21.0
github.com/pulumi/pulumi/sdk/v3 v3.120.0
github.com/pulumi/pulumi/sdk/v3 v3.142.0
)

replace github.com/dirien/pulumi-vultr/sdk/v2 => ../../sdk

require (
dario.cat/mergo v1.0.0 // indirect
github.com/BurntSushi/toml v1.2.1 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/ProtonMail/go-crypto v1.0.0 // indirect
github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da // indirect
Expand Down Expand Up @@ -69,7 +70,6 @@ require (
github.com/spf13/cobra v1.7.0 // indirect
github.com/spf13/pflag v1.0.5 // 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
github.com/uber/jaeger-lib v2.4.1+incompatible // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
Expand Down
8 changes: 4 additions & 4 deletions examples/vultr-go/go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk=
dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
github.com/BurntSushi/toml v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=
github.com/BurntSushi/toml v1.2.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/HdrHistogram/hdrhistogram-go v1.1.2 h1:5IcZpTvzydCQeHzK4Ef/D5rrSqwxob0t8PQPMybUNFM=
github.com/HdrHistogram/hdrhistogram-go v1.1.2/go.mod h1:yDgFjdqOqDEKOvasDdhWNXYg9BVp4O+o5f6V/ehm6Oo=
github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY=
Expand Down Expand Up @@ -148,8 +150,8 @@ github.com/pulumi/appdash v0.0.0-20231130102222-75f619a67231 h1:vkHw5I/plNdTr435
github.com/pulumi/appdash v0.0.0-20231130102222-75f619a67231/go.mod h1:murToZ2N9hNJzewjHBgfFdXhZKjY3z5cYC1VXk+lbFE=
github.com/pulumi/esc v0.9.1 h1:HH5eEv8sgyxSpY5a8yePyqFXzA8cvBvapfH8457+mIs=
github.com/pulumi/esc v0.9.1/go.mod h1:oEJ6bOsjYlQUpjf70GiX+CXn3VBmpwFDxUTlmtUN84c=
github.com/pulumi/pulumi/sdk/v3 v3.120.0 h1:KYtMkCmcSg4U+w41/Q0l3llKEodbfdyq6J0VMoEoVmY=
github.com/pulumi/pulumi/sdk/v3 v3.120.0/go.mod h1:/mQJPO+HehhoSJ9O3C6eUKAGeAr+4KSrbDhLsXHKldc=
github.com/pulumi/pulumi/sdk/v3 v3.142.0 h1:SmcVddGuvwAh3g3XUVQQ5gVRQUKH1yZ6iETpDNHIHlw=
github.com/pulumi/pulumi/sdk/v3 v3.142.0/go.mod h1:PvKsX88co8XuwuPdzolMvew5lZV+4JmZfkeSjj7A6dI=
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis=
Expand Down Expand Up @@ -181,8 +183,6 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/texttheater/golang-levenshtein v1.0.1 h1:+cRNoVrfiwufQPhoMzB6N0Yf/Mqajr6t1lOv8GyGE2U=
github.com/texttheater/golang-levenshtein v1.0.1/go.mod h1:PYAKrbF5sAiq9wd+H82hs7gNaen0CplQ9uvm6+enD/8=
github.com/tweekmonster/luser v0.0.0-20161003172636-3fa38070dbd7 h1:X9dsIWPuuEJlPX//UmRKophhOKCGXc46RVIGuttks68=
github.com/tweekmonster/luser v0.0.0-20161003172636-3fa38070dbd7/go.mod h1:UxoP3EypF8JfGEjAII8jx1q8rQyDnX8qdTCs/UQBVIE=
github.com/uber/jaeger-client-go v2.30.0+incompatible h1:D6wyKGCecFaSRUpo8lCVbaOOb6ThwMmTEbhRwtKR97o=
github.com/uber/jaeger-client-go v2.30.0+incompatible/go.mod h1:WVhlPFC8FDjOFMMWRy2pZqQJSXxYSwNYOkTr/Z6d3Kk=
github.com/uber/jaeger-lib v2.4.1+incompatible h1:td4jdvLcExb4cBISKIpHuGoVXh+dVKhn2Um6rjCsSsg=
Expand Down
6 changes: 3 additions & 3 deletions provider/cmd/pulumi-resource-vultr/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@
package main

import (
"context"
_ "embed"

vultr "github.com/dirien/pulumi-vultr/provider/v2"
pfbridge "github.com/pulumi/pulumi-terraform-bridge/pf/tfbridge"
"github.com/dirien/pulumi-vultr/provider/v2/pkg/version"
"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge"
)

//go:embed schema-embed.json
var pulumiSchema []byte

func main() {
// Modify the path to point to the new provider
pfbridge.MainWithMuxer(context.Background(), "vultr", vultr.Provider(), pulumiSchema)
tfbridge.Main("vultr", version.Version, vultr.Provider(), pulumiSchema)
}
116 changes: 58 additions & 58 deletions provider/cmd/pulumi-resource-vultr/schema.json

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions provider/cmd/pulumi-tfgen-vultr/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ package main

import (
vultr "github.com/dirien/pulumi-vultr/provider/v2"
"github.com/pulumi/pulumi-terraform-bridge/pf/tfgen"
"github.com/dirien/pulumi-vultr/provider/v2/pkg/version"
"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen"
)

func main() {
// Modify the path to point to the new provider
tfgen.MainWithMuxer("vultr", vultr.Provider())
tfgen.Main("vultr", version.Version, vultr.Provider())
}
5 changes: 3 additions & 2 deletions provider/go.mod
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
module github.com/dirien/pulumi-vultr/provider/v2

go 1.21.12
toolchain go1.22.5
go 1.22

toolchain go1.23.3

replace github.com/hashicorp/terraform-plugin-sdk/v2 => github.com/pulumi/terraform-plugin-sdk/v2 v2.0.0-20240520223432-0c0bf0d65f10

Expand Down
9 changes: 2 additions & 7 deletions provider/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@
package vultr

import (
"context"
_ "embed"
"fmt"

"path/filepath"

"github.com/dirien/pulumi-vultr/provider/v2/pkg/version"
pfbridge "github.com/pulumi/pulumi-terraform-bridge/pf/tfbridge"
"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge"
tfbridgetokens "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge/tokens"
shimv2 "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim/sdk-v2"
Expand All @@ -44,13 +42,10 @@ var metadata []byte
// Provider returns additional overlaid schema and metadata associated with the provider..
func Provider() tfbridge.ProviderInfo {
// Instantiate the Terraform provider
p := pfbridge.MuxShimWithPF(context.Background(),
shimv2.NewProvider(shim.NewProvider()),
shim.Framework()(),
)

// Create a Pulumi provider mapping
prov := tfbridge.ProviderInfo{
P: p,
P: shimv2.NewProvider(shim.NewProvider()),
Name: "vultr",
// DisplayName is a way to be able to change the casing of the provider
// name when being displayed on the Pulumi registry
Expand Down
33 changes: 0 additions & 33 deletions provider/shim/shim.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
package shim

import (
"context"
"github.com/hashicorp/terraform-plugin-framework/datasource"
prov "github.com/hashicorp/terraform-plugin-framework/provider"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/vultr/terraform-provider-vultr/vultr"
)
Expand All @@ -13,32 +9,3 @@ func NewProvider() *schema.Provider {
p := vultr.Provider()
return p
}

var _ prov.Provider = &VultrProvider{}

type VultrProvider struct{}

func (a VultrProvider) Metadata(ctx context.Context, request prov.MetadataRequest, response *prov.MetadataResponse) {
}

func (a VultrProvider) Schema(ctx context.Context, request prov.SchemaRequest, response *prov.SchemaResponse) {

}

func (a VultrProvider) Configure(ctx context.Context, request prov.ConfigureRequest, response *prov.ConfigureResponse) {

}

func (a VultrProvider) DataSources(ctx context.Context) []func() datasource.DataSource {
return []func() datasource.DataSource{}
}

func (a VultrProvider) Resources(ctx context.Context) []func() resource.Resource {
return []func() resource.Resource{}
}

func Framework() func() prov.Provider {
return func() prov.Provider {
return &VultrProvider{}
}
}
6 changes: 4 additions & 2 deletions sdk/go.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
module github.com/dirien/pulumi-vultr/sdk/v2

go 1.20
go 1.21

toolchain go1.23.3

require (
github.com/blang/semver v3.5.1+incompatible
github.com/pulumi/pulumi/sdk/v3 v3.125.0
github.com/pulumi/pulumi/sdk/v3 v3.142.0
)

require (
Expand Down
2 changes: 2 additions & 0 deletions sdk/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ github.com/pulumi/esc v0.9.1 h1:HH5eEv8sgyxSpY5a8yePyqFXzA8cvBvapfH8457+mIs=
github.com/pulumi/esc v0.9.1/go.mod h1:oEJ6bOsjYlQUpjf70GiX+CXn3VBmpwFDxUTlmtUN84c=
github.com/pulumi/pulumi/sdk/v3 v3.125.0 h1:hou7x/qf9G3878g4+DmBU+IEMJz66w+ZhwJONymjANE=
github.com/pulumi/pulumi/sdk/v3 v3.125.0/go.mod h1:p1U24en3zt51agx+WlNboSOV8eLlPWYAkxMzVEXKbnY=
github.com/pulumi/pulumi/sdk/v3 v3.142.0 h1:SmcVddGuvwAh3g3XUVQQ5gVRQUKH1yZ6iETpDNHIHlw=
github.com/pulumi/pulumi/sdk/v3 v3.142.0/go.mod h1:PvKsX88co8XuwuPdzolMvew5lZV+4JmZfkeSjj7A6dI=
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis=
Expand Down

0 comments on commit a9d03f0

Please sign in to comment.