Skip to content

Commit 4d20e85

Browse files
committed
Update generation of schema & bridge metadata
1 parent 23bf6b9 commit 4d20e85

File tree

5 files changed

+236
-8
lines changed

5 files changed

+236
-8
lines changed
Lines changed: 210 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,210 @@
1+
{
2+
"auto-aliasing": {
3+
"resources": {
4+
"sentry_dashboard": {
5+
"current": "sentry:index/sentryDashboard:SentryDashboard",
6+
"fields": {
7+
"widget": {
8+
"maxItemsOne": false,
9+
"elem": {
10+
"fields": {
11+
"layout": {
12+
"maxItemsOne": true
13+
},
14+
"query": {
15+
"maxItemsOne": false,
16+
"elem": {
17+
"fields": {
18+
"aggregates": {
19+
"maxItemsOne": false
20+
},
21+
"columns": {
22+
"maxItemsOne": false
23+
},
24+
"field_aliases": {
25+
"maxItemsOne": false
26+
},
27+
"fields": {
28+
"maxItemsOne": false
29+
}
30+
}
31+
}
32+
}
33+
}
34+
}
35+
}
36+
}
37+
},
38+
"sentry_issue_alert": {
39+
"current": "sentry:index/sentryIssueAlert:SentryIssueAlert",
40+
"fields": {
41+
"actions": {
42+
"maxItemsOne": false
43+
},
44+
"conditions": {
45+
"maxItemsOne": false
46+
},
47+
"filters": {
48+
"maxItemsOne": false
49+
},
50+
"projects": {
51+
"maxItemsOne": false
52+
}
53+
}
54+
},
55+
"sentry_key": {
56+
"current": "sentry:index/sentryKey:SentryKey"
57+
},
58+
"sentry_metric_alert": {
59+
"current": "sentry:index/sentryMetricAlert:SentryMetricAlert",
60+
"fields": {
61+
"event_types": {
62+
"maxItemsOne": false
63+
},
64+
"trigger": {
65+
"maxItemsOne": false,
66+
"elem": {
67+
"fields": {
68+
"action": {
69+
"maxItemsOne": false
70+
}
71+
}
72+
}
73+
}
74+
}
75+
},
76+
"sentry_organization": {
77+
"current": "sentry:index/sentryOrganization:SentryOrganization"
78+
},
79+
"sentry_organization_code_mapping": {
80+
"current": "sentry:index/sentryOrganizationCodeMapping:SentryOrganizationCodeMapping"
81+
},
82+
"sentry_organization_member": {
83+
"current": "sentry:index/sentryOrganizationMember:SentryOrganizationMember",
84+
"fields": {
85+
"teams": {
86+
"maxItemsOne": false
87+
}
88+
}
89+
},
90+
"sentry_organization_repository_github": {
91+
"current": "sentry:index/sentryOrganizationRepositoryGithub:SentryOrganizationRepositoryGithub"
92+
},
93+
"sentry_plugin": {
94+
"current": "sentry:index/sentryPlugin:SentryPlugin"
95+
},
96+
"sentry_project": {
97+
"current": "sentry:index/sentryProject:SentryProject",
98+
"fields": {
99+
"features": {
100+
"maxItemsOne": false
101+
},
102+
"teams": {
103+
"maxItemsOne": false
104+
}
105+
}
106+
},
107+
"sentry_rule": {
108+
"current": "sentry:index/sentryRule:SentryRule",
109+
"fields": {
110+
"actions": {
111+
"maxItemsOne": false
112+
},
113+
"conditions": {
114+
"maxItemsOne": false
115+
},
116+
"filters": {
117+
"maxItemsOne": false
118+
},
119+
"projects": {
120+
"maxItemsOne": false
121+
}
122+
}
123+
},
124+
"sentry_team": {
125+
"current": "sentry:index/sentryTeam:SentryTeam"
126+
}
127+
},
128+
"datasources": {
129+
"sentry_dashboard": {
130+
"current": "sentry:index/getSentryDashboard:getSentryDashboard",
131+
"fields": {
132+
"widget": {
133+
"maxItemsOne": false,
134+
"elem": {
135+
"fields": {
136+
"layout": {
137+
"maxItemsOne": false
138+
},
139+
"query": {
140+
"maxItemsOne": false,
141+
"elem": {
142+
"fields": {
143+
"aggregates": {
144+
"maxItemsOne": false
145+
},
146+
"columns": {
147+
"maxItemsOne": false
148+
},
149+
"field_aliases": {
150+
"maxItemsOne": false
151+
},
152+
"fields": {
153+
"maxItemsOne": false
154+
}
155+
}
156+
}
157+
}
158+
}
159+
}
160+
}
161+
}
162+
},
163+
"sentry_issue_alert": {
164+
"current": "sentry:index/getSentryIssueAlert:getSentryIssueAlert",
165+
"fields": {
166+
"actions": {
167+
"maxItemsOne": false
168+
},
169+
"conditions": {
170+
"maxItemsOne": false
171+
},
172+
"filters": {
173+
"maxItemsOne": false
174+
}
175+
}
176+
},
177+
"sentry_key": {
178+
"current": "sentry:index/getSentryKey:getSentryKey"
179+
},
180+
"sentry_metric_alert": {
181+
"current": "sentry:index/getSentryMetricAlert:getSentryMetricAlert",
182+
"fields": {
183+
"event_types": {
184+
"maxItemsOne": false
185+
},
186+
"trigger": {
187+
"maxItemsOne": false,
188+
"elem": {
189+
"fields": {
190+
"action": {
191+
"maxItemsOne": false
192+
}
193+
}
194+
}
195+
}
196+
}
197+
},
198+
"sentry_organization": {
199+
"current": "sentry:index/getSentryOrganization:getSentryOrganization"
200+
},
201+
"sentry_organization_integration": {
202+
"current": "sentry:index/getSentryOrganizationIntegration:getSentryOrganizationIntegration"
203+
},
204+
"sentry_team": {
205+
"current": "sentry:index/getSentryTeam:getSentryTeam"
206+
}
207+
}
208+
},
209+
"auto-settings": {}
210+
}

provider/cmd/pulumi-resource-sentry/generate.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
// +build ignore
15+
//go:build ignore
1616

1717
package main
1818

1919
import (
2020
"encoding/json"
21-
"fmt"
22-
"io/ioutil"
21+
"errors"
22+
"io/fs"
2323
"log"
2424
"os"
2525

@@ -32,7 +32,7 @@ func main() {
3232
log.Fatal("version not found")
3333
}
3434

35-
schemaContents, err := ioutil.ReadFile("./schema.json")
35+
schemaContents, err := os.ReadFile("./schema.json")
3636
if err != nil {
3737
log.Fatal(err)
3838
}
@@ -49,9 +49,13 @@ func main() {
4949
log.Fatalf("cannot reserialize schema: %v", err)
5050
}
5151

52-
err = ioutil.WriteFile("./schema.go", []byte(fmt.Sprintf(`package main
53-
var pulumiSchema = %#v
54-
`, versionedContents)), 0600)
52+
// Clean up schema.go as it may be present & gitignored and tolerate an error if the file isn't present.
53+
err = os.Remove("./schema.go")
54+
if err != nil && !errors.Is(err, fs.ErrNotExist) {
55+
log.Fatal(err)
56+
}
57+
58+
err = os.WriteFile("./schema-embed.json", versionedContents, 0600)
5559
if err != nil {
5660
log.Fatal(err)
5761
}

provider/cmd/pulumi-resource-sentry/main.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,17 @@
1717
package main
1818

1919
import (
20+
_ "embed"
21+
2022
"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge"
2123

2224
sentry "github.com/pulumiverse/pulumi-sentry/provider"
2325
"github.com/pulumiverse/pulumi-sentry/provider/pkg/version"
2426
)
2527

28+
//go:embed schema-embed.json
29+
var pulumiSchema []byte
30+
2631
func main() {
2732
// Modify the path to point to the new provider
2833
tfbridge.Main("sentry", version.Version, sentry.Provider(), pulumiSchema)

provider/cmd/pulumi-resource-sentry/schema-embed.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

provider/resources.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ import (
1818
"fmt"
1919
"path/filepath"
2020

21+
// Enable embedding of package metadata
22+
_ "embed"
23+
2124
"github.com/jianyuan/terraform-provider-sentry/sentry"
2225

2326
"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge"
@@ -50,6 +53,9 @@ func boolRef(b bool) *bool {
5053
return &b
5154
}
5255

56+
//go:embed cmd/pulumi-resource-sentry/bridge-metadata.json
57+
var metadata []byte
58+
5359
// Provider returns additional overlaid schema and metadata associated with the provider..
5460
func Provider() tfbridge.ProviderInfo {
5561
// Instantiate the Terraform provider
@@ -86,7 +92,8 @@ func Provider() tfbridge.ProviderInfo {
8692
Homepage: "https://github.com/pulumiverse",
8793
Repository: "https://github.com/pulumiverse/pulumi-sentry",
8894
// The GitHub Org for the provider - defaults to `terraform-providers`
89-
GitHubOrg: "jianyuan",
95+
GitHubOrg: "jianyuan",
96+
MetadataInfo: tfbridge.NewProviderMetadata(metadata),
9097
Config: map[string]*tfbridge.SchemaInfo{
9198
// Add any required configuration here, or remove the example below if
9299
// no additional points are required.
@@ -212,6 +219,7 @@ func Provider() tfbridge.ProviderInfo {
212219
}
213220

214221
prov.SetAutonaming(255, "-")
222+
prov.MustApplyAutoAliases()
215223

216224
return prov
217225
}

0 commit comments

Comments
 (0)