11package quicksight
22
33import (
4- "fmt"
5-
6- "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge"
74 "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge/info"
85 "github.com/pulumi/pulumi/sdk/v3/go/common/tokens"
6+ "github.com/pulumi/pulumi/sdk/v3/go/common/util/contract"
97)
108
119const (
@@ -17,7 +15,6 @@ func ConfigureQuicksight(
1715 awsResource func (mod string , name string ) tokens.Type ,
1816 awsDataSource func (mod string , name string ) tokens.ModuleMember ,
1917) {
20- st := & state {defined : map [tokens.Type ]struct {}{}}
2118 quickSightResources := map [string ]* info.Resource {
2219 "aws_quicksight_account_subscription" : {Tok : awsResource (quicksightMod , "AccountSubscription" )},
2320 "aws_quicksight_data_set" : {Tok : awsResource (quicksightMod , "DataSet" )},
@@ -26,9 +23,9 @@ func ConfigureQuicksight(
2623 "aws_quicksight_group_membership" : {Tok : awsResource (quicksightMod , "GroupMembership" )},
2724 "aws_quicksight_data_source" : {Tok : awsResource (quicksightMod , "DataSource" )},
2825 "aws_quicksight_folder" : {Tok : awsResource (quicksightMod , "Folder" )},
29- "aws_quicksight_template" : resourceTemplate ( st , awsResource (quicksightMod , "Template" )) ,
30- "aws_quicksight_analysis" : resourceAnalysis ( st , awsResource (quicksightMod , "Analysis" )) ,
31- "aws_quicksight_dashboard" : resourceDashboard ( st , awsResource (quicksightMod , "Dashboard" )) ,
26+ "aws_quicksight_template" : { Tok : awsResource (quicksightMod , "Template" )} ,
27+ "aws_quicksight_analysis" : { Tok : awsResource (quicksightMod , "Analysis" )} ,
28+ "aws_quicksight_dashboard" : { Tok : awsResource (quicksightMod , "Dashboard" )} ,
3229 }
3330
3431 for k , v := range quickSightResources {
@@ -44,117 +41,9 @@ func ConfigureQuicksight(
4441 for k , v := range quickSightDataSources {
4542 providerInfo .DataSources [k ] = v
4643 }
47- }
4844
49- func resourceAnalysis (st * state , token tokens.Type ) * info.Resource {
50- columnConfigs := & info.Schema {
51- Elem : & info.Schema {
52- Fields : map [string ]* info.Schema {
53- "format_configuration" : formatConfigurationSchema (st ),
54- },
55- },
56- }
57- return & info.Resource {
58- Tok : token ,
59- Fields : map [string ]* info.Schema {
60- "definition" : {
61- Elem : & info.Schema {
62- Fields : map [string ]* info.Schema {
63- "analysis_defaults" : analysisDefaultSchema (st ),
64- "column_configurations" : columnConfigs ,
65- "sheets" : {
66- Elem : & info.Schema {
67- Fields : map [string ]* info.Schema {
68- "visuals" : visualsSchema (st ),
69- },
70- },
71- },
72- },
73- },
74- },
75- },
76- }
77- }
78-
79- func resourceDashboard (st * state , token tokens.Type ) * info.Resource {
80- columnConfigs := & info.Schema {
81- Elem : & info.Schema {
82- Fields : map [string ]* info.Schema {
83- "format_configuration" : formatConfigurationSchema (st ),
84- },
85- },
86- }
87- return & info.Resource {
88- Tok : token ,
89- Fields : map [string ]* info.Schema {
90- "definition" : {
91- Elem : & info.Schema {
92- Fields : map [string ]* info.Schema {
93- "analysis_defaults" : analysisDefaultSchema (st ),
94- "column_configurations" : columnConfigs ,
95- "sheets" : {
96- Elem : & info.Schema {
97- Fields : map [string ]* info.Schema {
98- "visuals" : visualsSchema (st ),
99- },
100- },
101- },
102- },
103- },
104- },
105- },
106- }
107- }
45+ st , err := readSharedTypesFile ("provider/pkg/quicksight/shared-types-rewrites.json" )
46+ contract .AssertNoErrorf (err , "failed to read shared-types-rewrites.json" )
10847
109- func resourceTemplate (st * state , token tokens.Type ) * info.Resource {
110- columnConfigs := & info.Schema {
111- Elem : & info.Schema {
112- Fields : map [string ]* info.Schema {
113- "format_configuration" : formatConfigurationSchema (st ),
114- },
115- },
116- }
117- return & info.Resource {
118- Tok : token ,
119- Fields : map [string ]* info.Schema {
120- "definition" : {
121- Elem : & info.Schema {
122- Fields : map [string ]* info.Schema {
123- "analysis_defaults" : analysisDefaultSchema (st ),
124- "column_configurations" : columnConfigs ,
125- "sheets" : {
126- Elem : & info.Schema {
127- Fields : map [string ]* info.Schema {
128- "visuals" : visualsSchema (st ),
129- },
130- },
131- },
132- },
133- },
134- },
135- },
136- }
137- }
138-
139- type state struct {
140- defined map [tokens.Type ]struct {}
141- }
142-
143- func (st * state ) define (name string , schema * info.Schema ) * info.Schema {
144- tok := tokens .Type (fmt .Sprintf ("aws:quicksight/%s:%s" , name , name ))
145- copy := * schema
146- if schema .Elem == nil {
147- copy .Elem = & info.Schema {}
148- } else {
149- elem := * schema .Elem
150- copy .Elem = & elem
151- }
152- if _ , ok := st .defined [tok ]; ! ok {
153- st .defined [tok ] = struct {}{}
154- copy .Elem .TypeName = tfbridge .Ref (name )
155- return & copy
156- }
157- copy .Elem .Type = tok
158- copy .Elem .OmitType = true
159- return & copy
48+ shareTypes (st , providerInfo )
16049}
0 commit comments