@@ -40,6 +40,66 @@ type (
4040 docTemplate string
4141)
4242
43+ type ResourceTemplateType struct {
44+ Type string
45+ Name string
46+ Description string
47+
48+ HasExample bool
49+ ExampleFile string
50+
51+ HasImport bool
52+ ImportFile string
53+
54+ HasImportIDConfig bool
55+ ImportIDConfigFile string
56+
57+ HasImportIdentityConfig bool
58+ ImportIdentityConfigFile string
59+ IdentitySchemaMarkdown string
60+
61+ ProviderName string
62+ ProviderShortName string
63+
64+ SchemaMarkdown string
65+
66+ RenderedProviderName string
67+ }
68+
69+ type ProviderTemplateType struct {
70+ Description string
71+
72+ HasExample bool
73+ ExampleFile string
74+
75+ ProviderName string
76+ ProviderShortName string
77+ SchemaMarkdown string
78+
79+ RenderedProviderName string
80+ }
81+
82+ type FunctionTemplateType struct {
83+ Type string
84+ Name string
85+ Description string
86+ Summary string
87+
88+ HasExample bool
89+ ExampleFile string
90+
91+ ProviderName string
92+ ProviderShortName string
93+
94+ FunctionSignatureMarkdown string
95+ FunctionArgumentsMarkdown string
96+
97+ HasVariadic bool
98+ FunctionVariadicArgumentMarkdown string
99+
100+ RenderedProviderName string
101+ }
102+
43103func newTemplate (providerDir , name , text string ) (* template.Template , error ) {
44104 tmpl := template .New (name )
45105 titleCaser := cases .Title (language .Und )
@@ -132,18 +192,7 @@ func (t providerTemplate) Render(providerDir, providerName, renderedProviderName
132192 return "" , nil
133193 }
134194
135- return renderStringTemplate (providerDir , "providerTemplate" , s , struct {
136- Description string
137-
138- HasExample bool
139- ExampleFile string
140-
141- ProviderName string
142- ProviderShortName string
143- SchemaMarkdown string
144-
145- RenderedProviderName string
146- }{
195+ return renderStringTemplate (providerDir , "providerTemplate" , s , ProviderTemplateType {
147196 Description : schema .Block .Description ,
148197
149198 HasExample : exampleFile != "" && fileExists (exampleFile ),
@@ -189,31 +238,7 @@ func (t resourceTemplate) Render(providerDir, name, providerName, renderedProvid
189238 return "" , fmt .Errorf ("unable to render: an identity import example (%q) was provided for a resource (%q) that does not support resource identity" , importIdentityConfigFile , name )
190239 }
191240
192- return renderStringTemplate (providerDir , "resourceTemplate" , s , struct {
193- Type string
194- Name string
195- Description string
196-
197- HasExample bool
198- ExampleFile string
199-
200- HasImport bool
201- ImportFile string
202-
203- HasImportIDConfig bool
204- ImportIDConfigFile string
205-
206- HasImportIdentityConfig bool
207- ImportIdentityConfigFile string
208- IdentitySchemaMarkdown string
209-
210- ProviderName string
211- ProviderShortName string
212-
213- SchemaMarkdown string
214-
215- RenderedProviderName string
216- }{
241+ return renderStringTemplate (providerDir , "resourceTemplate" , s , ResourceTemplateType {
217242 Type : typeName ,
218243 Name : name ,
219244 Description : schema .Block .Description ,
@@ -261,26 +286,7 @@ func (t functionTemplate) Render(providerDir, name, providerName, renderedProvid
261286 return "" , nil
262287 }
263288
264- return renderStringTemplate (providerDir , "resourceTemplate" , s , struct {
265- Type string
266- Name string
267- Description string
268- Summary string
269-
270- HasExample bool
271- ExampleFile string
272-
273- ProviderName string
274- ProviderShortName string
275-
276- FunctionSignatureMarkdown string
277- FunctionArgumentsMarkdown string
278-
279- HasVariadic bool
280- FunctionVariadicArgumentMarkdown string
281-
282- RenderedProviderName string
283- }{
289+ return renderStringTemplate (providerDir , "resourceTemplate" , s , FunctionTemplateType {
284290 Type : typeName ,
285291 Name : name ,
286292 Description : signature .Description ,
0 commit comments