Skip to content

Commit

Permalink
Convert to patches in preparation for #409 (#454)
Browse files Browse the repository at this point in the history
* Convert to patches in preparation for #409

This moves us to a standard upgrade mechanism (instead of a replace) so normal updates
work. We will use patches to support a shim system when we act on #409.

* Cleanup the provider
  • Loading branch information
iwahbe authored Jul 16, 2024
1 parent 6c0d632 commit 672695e
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 194 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "upstream"]
path = upstream
url = https://github.com/dnsimple/terraform-provider-dnsimple.git
130 changes: 0 additions & 130 deletions CHANGELOG_OLD.md

This file was deleted.

2 changes: 2 additions & 0 deletions patches/noop.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
The only issue with upstream is that they use an invalid module name, so we just need to
vendor, not apply any changes.
5 changes: 3 additions & 2 deletions provider/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ go 1.21
require (
github.com/pulumi/pulumi-terraform-bridge/v3 v3.86.0
github.com/pulumi/pulumi/sdk/v3 v3.121.0
github.com/terraform-providers/terraform-provider-dnsimple v0.15.0
github.com/terraform-providers/terraform-provider-dnsimple v0.0.0
)

replace github.com/terraform-providers/terraform-provider-dnsimple => ../upstream

require (
cloud.google.com/go v0.112.1 // indirect
cloud.google.com/go/compute v1.25.0 // indirect
Expand Down Expand Up @@ -241,5 +243,4 @@ require (
replace (
github.com/hashicorp/terraform-plugin-sdk/v2 => github.com/pulumi/terraform-plugin-sdk/v2 v2.0.0-20240520223432-0c0bf0d65f10
github.com/hashicorp/terraform-plugin-test => github.com/hashicorp/terraform-plugin-test v1.3.0
github.com/terraform-providers/terraform-provider-dnsimple => github.com/dnsimple/terraform-provider-dnsimple v0.15.0
)
2 changes: 0 additions & 2 deletions provider/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1340,8 +1340,6 @@ github.com/djherbis/times v1.5.0 h1:79myA211VwPhFTqUk8xehWrsEO+zcIZj0zT8mXPVARU=
github.com/djherbis/times v1.5.0/go.mod h1:5q7FDLvbNg1L/KaBmPcWlVR9NmoKo3+ucqUA3ijQhA0=
github.com/dnsimple/dnsimple-go v1.0.0 h1:x9UalQ0tHR68+sQxJYJmq746LdJou4OLTK+cZLR2Z9I=
github.com/dnsimple/dnsimple-go v1.0.0/go.mod h1:oaAtPP8bIROK3QXUdc8rMlTN7SyvCBAogw2I31WVNnU=
github.com/dnsimple/terraform-provider-dnsimple v0.15.0 h1:Weavs4ibgJM9ie6XggIOLfqKkaGrwmPRZ2HzSiSa4ns=
github.com/dnsimple/terraform-provider-dnsimple v0.15.0/go.mod h1:+L+pEgFgx0+xPiAmrHS03G1owIz8SUqLCEH7kBI+wUw=
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
Expand Down
88 changes: 28 additions & 60 deletions provider/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ package dnsimple

import (
"fmt"
"path/filepath"
"unicode"
"path"

// embed is used to store bridge-metadata.json in the compiled binary
_ "embed"
Expand All @@ -40,61 +39,37 @@ const (
mainMod = "index"
)

// makeMember manufactures a type token for the package and the given module and type.
func makeMember(mod string, mem string) tokens.ModuleMember {
return tokens.ModuleMember(mainPkg + ":" + mod + ":" + mem)
}

// makeType manufactures a type token for the package and the given module and type.
func makeType(mod string, typ string) tokens.Type {
return tokens.Type(makeMember(mod, typ))
func makeType(mod tokens.ModuleName, typ tokens.TypeName) tokens.Type {
return tokens.NewTypeToken(tokens.NewModuleToken(mainPkg, mod), typ)
}

// makeResource manufactures a standard resource token given a module and resource name. It
// automatically uses the main package and names the file by simply lower casing the resource's
// first character.
func makeResource(mod string, res string) tokens.Type {
fn := string(unicode.ToLower(rune(res[0]))) + res[1:]
return makeType(mod+"/"+fn, res)
}
//go:embed cmd/pulumi-resource-dnsimple/bridge-metadata.json
var metadata []byte

// Provider returns additional overlaid schema and metadata associated with the provider..
// Provider returns additional overlaid schema and metadata associated with the provider.
func Provider() tfbridge.ProviderInfo {
dnsimpleProv := dnsimple.Provider()
p := shimv2.NewProvider(dnsimpleProv)

prov := tfbridge.ProviderInfo{
P: p,
Name: "dnsimple",
Description: "A Pulumi package for creating and managing dnsimple cloud resources.",
Keywords: []string{"pulumi", "dnsimple"},
License: "Apache-2.0",
Homepage: "https://pulumi.io",
Repository: "https://github.com/pulumi/pulumi-dnsimple",
Config: map[string]*tfbridge.SchemaInfo{},
GitHubOrg: "terraform-providers",
P: shimv2.NewProvider(dnsimple.Provider()),
Name: "dnsimple",
Description: "A Pulumi package for creating and managing dnsimple cloud resources.",
Keywords: []string{"pulumi", "dnsimple"},
License: "Apache-2.0",
Homepage: "https://pulumi.io",
Repository: "https://github.com/pulumi/pulumi-dnsimple",
GitHubOrg: "terraform-providers",
MetadataInfo: tfbridge.NewProviderMetadata(metadata),
Resources: map[string]*tfbridge.ResourceInfo{
"dnsimple_record": {
Tok: makeResource(mainMod, "Record"),
Fields: map[string]*tfbridge.SchemaInfo{
"name": {
Type: "string",
},
"type": {
Type: makeType(mainMod, "RecordType"),
},
},
Docs: &tfbridge.DocInfo{
Markdown: []byte(" "),
"name": {Type: "string"},
"type": {Type: makeType(mainMod, "RecordType")},
},
Docs: &tfbridge.DocInfo{AllowMissing: true},
DeprecationMessage: "This resource is deprecated.\nIt will be removed in the next major version.",
},
"dnsimple_domain": {Tok: makeResource(mainMod, "Domain")},
"dnsimple_email_forward": {Tok: makeResource(mainMod, "EmailForward")},
"dnsimple_lets_encrypt_certificate": {Tok: makeResource(mainMod, "LetsEncryptCertificate")},
"dnsimple_zone_record": {Tok: makeResource(mainMod, "ZoneRecord")},
},
DataSources: map[string]*tfbridge.DataSourceInfo{},
UpstreamRepoPath: "./upstream",
JavaScript: &tfbridge.JavaScriptInfo{
Dependencies: map[string]string{
"@pulumi/pulumi": "^3.0.0",
Expand All @@ -110,19 +85,15 @@ func Provider() tfbridge.ProviderInfo {
},
RespectSchemaVersion: true,
},
Python: (func() *tfbridge.PythonInfo {
i := &tfbridge.PythonInfo{
RespectSchemaVersion: true,
Requires: map[string]string{
"pulumi": ">=3.0.0,<4.0.0",
},
}
i.PyProject.Enabled = true
return i
})(),

Python: &tfbridge.PythonInfo{
RespectSchemaVersion: true,
Requires: map[string]string{
"pulumi": ">=3.0.0,<4.0.0",
},
PyProject: struct{ Enabled bool }{true},
},
Golang: &tfbridge.GolangInfo{
ImportBasePath: filepath.Join(
ImportBasePath: path.Join(
fmt.Sprintf("github.com/pulumi/pulumi-%[1]s/sdk/", mainPkg),
tfbridge.GetModuleMajorVersion(version.Version),
"go",
Expand All @@ -139,7 +110,7 @@ func Provider() tfbridge.ProviderInfo {
Namespaces: map[string]string{
mainPkg: "DNSimple",
},
}, MetadataInfo: tfbridge.NewProviderMetadata(metadata),
},
}

prov.MustComputeTokens(tfbridgetokens.SingleModule("dnsimple_", mainMod,
Expand All @@ -148,6 +119,3 @@ func Provider() tfbridge.ProviderInfo {

return prov
}

//go:embed cmd/pulumi-resource-dnsimple/bridge-metadata.json
var metadata []byte
1 change: 1 addition & 0 deletions upstream
Submodule upstream added at f392de

0 comments on commit 672695e

Please sign in to comment.