Skip to content

Commit fd2c9bc

Browse files
committed
Use AWS SDK client accessors instead of field names for skaff.
1 parent 4f8eb7d commit fd2c9bc

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

skaff/datasource/datasource.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ func dataSource{{ .DataSource }}Read(ctx context.Context, d *schema.ResourceData
165165

166166
// TIP: -- 1. Get a client connection to the relevant service
167167
{{- end }}
168-
conn := meta.(*conns.AWSClient).{{ .Service }}{{ if .AWSGoSDKV2 }}Client{{ else }}Conn{{ end }}
168+
conn := meta.(*conns.AWSClient).{{ .Service }}{{ if .AWSGoSDKV2 }}Client(){{ else }}Conn(){{ end }}
169169
{{ if .IncludeComments }}
170170
// TIP: -- 2. Get information about a resource from AWS using an API Get,
171171
// List, or Describe-type function, or, better yet, using a finder. Data

skaff/resource/resource.tmpl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ func resource{{ .Resource }}Create(ctx context.Context, d *schema.ResourceData,
217217

218218
// TIP: -- 1. Get a client connection to the relevant service
219219
{{- end }}
220-
conn := meta.(*conns.AWSClient).{{ .Service }}{{ if .AWSGoSDKV2 }}Client{{ else }}{{ if .AWSGoSDKV2 }}Client{{ else }}Conn{{ end }}{{ end }}
220+
conn := meta.(*conns.AWSClient).{{ .Service }}{{ if .AWSGoSDKV2 }}Client(){{ else }}Conn(){{ end }}
221221
{{ if .IncludeComments }}
222222
// TIP: -- 2. Populate a create input structure
223223
{{- end }}
@@ -309,7 +309,7 @@ func resource{{ .Resource }}Read(ctx context.Context, d *schema.ResourceData, me
309309

310310
// TIP: -- 1. Get a client connection to the relevant service
311311
{{- end }}
312-
conn := meta.(*conns.AWSClient).{{ .Service }}{{ if .AWSGoSDKV2 }}Client{{ else }}Conn{{ end }}
312+
conn := meta.(*conns.AWSClient).{{ .Service }}{{ if .AWSGoSDKV2 }}Client(){{ else }}Conn(){{ end }}
313313
{{ if .IncludeComments }}
314314
// TIP: -- 2. Get the resource from AWS using an API Get, List, or Describe-
315315
// type function, or, better yet, using a finder.
@@ -428,7 +428,7 @@ func resource{{ .Resource }}Update(ctx context.Context, d *schema.ResourceData,
428428

429429
// TIP: -- 1. Get a client connection to the relevant service
430430
{{- end }}
431-
conn := meta.(*conns.AWSClient).{{ .Service }}{{ if .AWSGoSDKV2 }}Client{{ else }}Conn{{ end }}
431+
conn := meta.(*conns.AWSClient).{{ .Service }}{{ if .AWSGoSDKV2 }}Client(){{ else }}Conn(){{ end }}
432432
{{ if .IncludeComments }}
433433
// TIP: -- 2. Populate a modify input structure and check for changes
434434
//
@@ -501,7 +501,7 @@ func resource{{ .Resource }}Delete(ctx context.Context, d *schema.ResourceData,
501501

502502
// TIP: -- 1. Get a client connection to the relevant service
503503
{{- end }}
504-
conn := meta.(*conns.AWSClient).{{ .Service }}{{ if .AWSGoSDKV2 }}Client{{ else }}Conn{{ end }}
504+
conn := meta.(*conns.AWSClient).{{ .Service }}{{ if .AWSGoSDKV2 }}Client(){{ else }}Conn(){{ end }}
505505
{{ if .IncludeComments }}
506506
// TIP: -- 2. Populate a delete input structure
507507
{{- end }}

skaff/resource/resourcetest.tmpl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ func TestAcc{{ .Service }}{{ .Resource }}_disappears(t *testing.T) {
253253
}
254254

255255
func testAccCheck{{ .Resource }}Destroy(s *terraform.State) error {
256-
conn := acctest.Provider.Meta().(*conns.AWSClient).{{ .Service }}{{ if .AWSGoSDKV2 }}Client{{ else }}Conn{{ end }}
256+
conn := acctest.Provider.Meta().(*conns.AWSClient).{{ .Service }}{{ if .AWSGoSDKV2 }}Client(){{ else }}Conn(){{ end }}
257257
ctx := context.Background()
258258

259259
for _, rs := range s.RootModule().Resources {
@@ -305,7 +305,7 @@ func testAccCheck{{ .Resource }}Exists(name string, {{ .ResourceLower }} *{{ .Se
305305
return create.Error(names.{{ .Service }}, create.ErrActionCheckingExistence, tf{{ .ServicePackage }}.ResName{{ .Resource }}, name, errors.New("not set"))
306306
}
307307

308-
conn := acctest.Provider.Meta().(*conns.AWSClient).{{ .Service }}{{ if .AWSGoSDKV2 }}Client{{ else }}Conn{{ end }}
308+
conn := acctest.Provider.Meta().(*conns.AWSClient).{{ .Service }}{{ if .AWSGoSDKV2 }}Client(){{ else }}Conn(){{ end }}
309309
ctx := context.Background()
310310

311311
{{- if .AWSGoSDKV2 }}
@@ -329,7 +329,7 @@ func testAccCheck{{ .Resource }}Exists(name string, {{ .ResourceLower }} *{{ .Se
329329
}
330330

331331
func testAccPreCheck(t *testing.T) {
332-
conn := acctest.Provider.Meta().(*conns.AWSClient).{{ .Service }}{{ if .AWSGoSDKV2 }}Client{{ else }}Conn{{ end }}
332+
conn := acctest.Provider.Meta().(*conns.AWSClient).{{ .Service }}{{ if .AWSGoSDKV2 }}Client(){{ else }}Conn(){{ end }}
333333
ctx := context.Background()
334334

335335
input := &{{ .ServicePackage }}.List{{ .Resource }}sInput{}

0 commit comments

Comments
 (0)