Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Converts AWS API calls to and provider CRUD calls to Context-aware versions #29005

Merged
merged 222 commits into from
Jan 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
222 commits
Select commit Hold shift + click to select a range
994a7e3
Moves `errs.AppendErrorf` and `errs.AppendWarningf` to `errs.sdkdiag`
gdavison Dec 14, 2022
9aea3dd
Adds support for generating only `Context`-aware tags functions
gdavison Dec 15, 2022
05e3377
Adds support for `Context`-aware functions without `WithContext` in g…
gdavison Dec 16, 2022
fd3fdb3
Fixes error return
gdavison Jan 4, 2023
7cca29f
Fixes error returns
gdavison Jan 4, 2023
621087d
Adds stub `Context` for sweepers and adds `Context` parameter to `swe…
gdavison Jan 5, 2023
11382cc
Adds support for `Context`-aware functions without `WithContext` in g…
gdavison Jan 5, 2023
73bc7e6
Removes direct callls to `schema.Resource.Delete()` from sweepers
gdavison Jan 6, 2023
048320e
Fixes bare error returns
gdavison Jan 6, 2023
bfefff1
Use default Go version and skip-dirs for golangci-lint. Pass both gol…
gdavison Jan 7, 2023
eac06ef
Adds stub `acctest.Context()`
gdavison Jan 13, 2023
a6c2876
Adds `context` calls to `accessanalyzer`
gdavison Jan 14, 2023
b1b494c
Adds `context` calls to `account`
gdavison Jan 14, 2023
c8e4a3f
Adds `context` calls to `acm`
gdavison Jan 14, 2023
ba821ce
Adds `context` calls to `acmpca`
gdavison Jan 14, 2023
5973e1b
Adds `context` calls to `amp`
gdavison Jan 14, 2023
7c79468
Adds `context` calls to `amplify`
gdavison Jan 14, 2023
4224236
Adds `context` calls to `apigateway`
gdavison Jan 14, 2023
3db5571
Adds `context` calls to `apigatewayv2`
gdavison Jan 14, 2023
8ea6799
Adds `context` calls to `appautoscaling`
gdavison Jan 14, 2023
6491065
Adds `context` calls to `appconfig`
gdavison Jan 14, 2023
159b300
Adds `context` calls to `appflow`
gdavison Jan 14, 2023
034bcb2
Adds `context` calls to `appintegrations`
gdavison Jan 14, 2023
f24ee75
Adds `context` calls to `applicationinsights`
gdavison Jan 14, 2023
002c872
Adds `context` calls to `appmesh`
gdavison Jan 14, 2023
1a1240d
Adds `context` calls to `apprunner`
gdavison Jan 14, 2023
40d0cc5
Adds `context` calls to `appstream`
gdavison Jan 14, 2023
4465f22
Adds `context` calls to `appsync`
gdavison Jan 14, 2023
7d148d1
Adds `context` calls to `athena`
gdavison Jan 14, 2023
0f23f0c
Removes `nosemgrep`
gdavison Jan 14, 2023
e0304be
Adds `context` calls to `auditmanager`
gdavison Jan 14, 2023
1cb72ae
Adds `AppendFromErr`
gdavison Jan 16, 2023
3bbb460
Makes generators runnable without deleting file first
gdavison Jan 16, 2023
94a46ea
Adds `context` calls to `autoscaling`
gdavison Jan 16, 2023
f483009
Adds `context` calls to `autoscalingplans`
gdavison Jan 16, 2023
d149f55
MIssed save
gdavison Jan 16, 2023
dcc496b
Adds `context` calls to `backup`
gdavison Jan 17, 2023
dcfbfd6
Adds `context` calls to `batch`
gdavison Jan 17, 2023
947b6e0
Adds `context` calls to `budgets`
gdavison Jan 17, 2023
d181de3
Adds check for corrrect naming for `testAccCheck...DestroyWithProvide…
gdavison Jan 17, 2023
6027aa7
Adds check for correct signature for check destroy functions
gdavison Jan 17, 2023
91d2e85
Adds `context` calls to `ce`
gdavison Jan 17, 2023
9558f98
Adds `context` calls to `chime`
gdavison Jan 17, 2023
f4b1b45
Adds `context` calls to `cloud9`
gdavison Jan 17, 2023
9a13802
Semgrep fix
gdavison Jan 17, 2023
4cf9578
Adds `context` calls to `cloudcontrol`
gdavison Jan 17, 2023
4499795
Adds `context` calls to `cloudformation`, `s3`, and `serverlessrepo` …
gdavison Jan 17, 2023
d64ab47
Adds `context` calls to `cloudfront`
gdavison Jan 17, 2023
4727420
Adds `context` calls to `cloudhsmv2`
gdavison Jan 17, 2023
c58b508
Adds `context` calls to `cloudsearch`
gdavison Jan 17, 2023
78add42
Adds `context` calls to `cloudtrail`
gdavison Jan 17, 2023
39e03ea
Adds `context` calls to `cloudwatch`
gdavison Jan 17, 2023
a6857e0
Adds `context` calls to `cognitoidp`
gdavison Jan 17, 2023
611c6d6
Adds `context` calls to `cognitoidentity`
gdavison Jan 17, 2023
6690b38
Adds `context` calls to `codeartifact`
gdavison Jan 17, 2023
1e273c9
Adds `context` calls to `codebuild`
gdavison Jan 17, 2023
cb7ec1b
Adds `context` calls to `codecommit`
gdavison Jan 17, 2023
1c23911
Adds `context` calls to `codepipeline`
gdavison Jan 17, 2023
9273699
Adds `context` calls to `codestarconnections`
gdavison Jan 17, 2023
a4c67c6
Adds `context` calls to `codestarnotifications`
gdavison Jan 17, 2023
36a3352
Adds `context` calls to `comprehend`
gdavison Jan 17, 2023
cb28b75
Adds `context` calls to `configservice`
gdavison Jan 17, 2023
9a77873
Adds `context` calls to `connect`
gdavison Jan 17, 2023
ac15f73
Adds `context` calls to `controltower`
gdavison Jan 17, 2023
46e7ed5
Adds `context` calls to `cur`
gdavison Jan 17, 2023
bb6406b
Adds some `focus-metavariable`s to Semgrep rules
gdavison Jan 17, 2023
3d1a345
Semgrep fixes
gdavison Jan 17, 2023
72cdd59
Adds `context` calls to `dataexchange`
gdavison Jan 17, 2023
28f189a
Adds `context` calls to `datapipeline`
gdavison Jan 17, 2023
bacf70f
Adds `context` calls to `datasync`
gdavison Jan 17, 2023
5729768
Adds `context` calls to `dax`
gdavison Jan 17, 2023
a229e64
Adds `context` calls to `deploy`
gdavison Jan 17, 2023
d5cd3a0
Adds `context` calls to `detective`
gdavison Jan 17, 2023
b960935
Adds `context` calls to `devicefarm`
gdavison Jan 17, 2023
5639d26
Adds `context` calls to `directconnect`
gdavison Jan 17, 2023
9fc3a4b
check destroy fixes
gdavison Jan 17, 2023
6d61f38
Adds `context` calls to `dlm`
gdavison Jan 17, 2023
2817c22
Adds `context` calls to `dms`
gdavison Jan 18, 2023
72cde70
Adds `context` calls to `docdb`
gdavison Jan 18, 2023
ffb4a59
Adds `context` calls to `ds`
gdavison Jan 18, 2023
24b54a2
Adds `context` calls to `dynamodb`
gdavison Jan 18, 2023
4f8aefc
Updates `tag_gen_test.go` to take context
gdavison Jan 18, 2023
7e31117
Adds `context` calls to `ec2`
gdavison Jan 18, 2023
f34caa7
Adds `context` calls to `ecr`
gdavison Jan 18, 2023
4d025ae
Adds `context` calls to `ecrpublic`
gdavison Jan 18, 2023
c0f8d32
Adds `context` calls to `ecs`
gdavison Jan 18, 2023
5c4bd4e
Adds `context` calls to `ecs`
gdavison Jan 18, 2023
e2ed935
Adds `context` calls to `efs`
gdavison Jan 18, 2023
2d91416
Adds `context` calls to `eks`
gdavison Jan 18, 2023
618a5da
Comment fixes
gdavison Jan 18, 2023
ef90bfd
Adds `context` calls to `elasticache`
gdavison Jan 18, 2023
8f9725f
Adds `context` calls to `elasticbeanstalk`
gdavison Jan 18, 2023
45f58c6
Adds `context` calls to `elasticsearch`
gdavison Jan 18, 2023
1d80818
Adds `context` calls to `elastictranscoder`
gdavison Jan 19, 2023
d030445
Adds `context` calls to `elb`
gdavison Jan 19, 2023
6a8af2f
Adds `context` calls to `elbv2`
gdavison Jan 19, 2023
aef93ef
Adds `context` calls to `emr`
gdavison Jan 19, 2023
7138465
Adds `context` calls to `emrcontainers`
gdavison Jan 19, 2023
5f603f0
Adds `context` calls to `emrserverless`
gdavison Jan 19, 2023
b99c3fa
Adds `context` calls to `events`
gdavison Jan 19, 2023
ee79f01
Adds `context` calls to `evidently`
gdavison Jan 19, 2023
3665332
Adds `context` calls to `firehose`
gdavison Jan 19, 2023
0b815f8
Makefile fixes
gdavison Jan 19, 2023
c2ba69c
Adds filtering for `semall` rule based on `PKG` envvar
gdavison Jan 19, 2023
9c8f547
Adds `context` calls to `fis`
gdavison Jan 19, 2023
306ff07
Adds `context` calls to `fms`
gdavison Jan 19, 2023
b486139
Docs fix
gdavison Jan 19, 2023
993ba3d
Adds `context` calls to `fsx`
gdavison Jan 19, 2023
c3ba677
Adds `context` calls to `gamelift`
gdavison Jan 19, 2023
ee8fc47
Adds `context` calls to `glacier`
gdavison Jan 19, 2023
a845b56
Adds `context` calls to `globalaccelerator`
gdavison Jan 19, 2023
975e23a
Adds `context` calls to `glue`
gdavison Jan 19, 2023
d92223f
Adds `context` calls to `grafana`
gdavison Jan 19, 2023
b0e8282
Replaces `schema.Noop` with `schema.NoopContext`
gdavison Jan 19, 2023
5e0f711
Fixes `gamelift` sweeper
gdavison Jan 19, 2023
690cf65
Adds `context` calls to `greengrass`
gdavison Jan 19, 2023
4f75a00
Adds `context` calls to `guardduty`
gdavison Jan 19, 2023
aae81ac
Adds `context` calls to `iam`
gdavison Jan 19, 2023
1202b48
Adds `context` calls to `identitystore`
gdavison Jan 19, 2023
84ad167
Adds `context` calls to `imagebuilder`
gdavison Jan 19, 2023
985ba4c
Adds `context` calls to `inspector`
gdavison Jan 19, 2023
7d5c2c6
Adds `context` calls to `inspector2`
gdavison Jan 19, 2023
e9e64b6
Adds `context` calls to `iot`
gdavison Jan 19, 2023
f5a1512
Adds `context` calls to `iotanalytics`
gdavison Jan 19, 2023
39c1893
Adds `context` calls to `iotevents`
gdavison Jan 19, 2023
3fe06a8
Adds `context` calls to `ivs`
gdavison Jan 19, 2023
1cef26b
Adds `context` calls to `ivschat`
gdavison Jan 19, 2023
39bb18c
Adds `context` calls to `kafka`
gdavison Jan 19, 2023
a12ba7c
Adds `context` calls to `kafkaconnect`
gdavison Jan 19, 2023
aad9439
Adds `context` calls to `kendra`
gdavison Jan 19, 2023
225fee8
Adds `context` calls to `keyspaces`
gdavison Jan 19, 2023
e80f803
Adds `context` calls to `kinesis`
gdavison Jan 19, 2023
ac04fb5
Adds `context` calls to `kinesisanalytics`
gdavison Jan 19, 2023
88085a1
Adds `context` calls to `kinesisanalyticsv2`
gdavison Jan 19, 2023
3b44a96
Adds `context` calls to `kinesisvideo`
gdavison Jan 19, 2023
7c7e44a
Adds `context` calls to `kms`
gdavison Jan 19, 2023
9b962a5
Fixes after rebase
gdavison Jan 19, 2023
753b906
Adds `context` calls to `lakeformation`
gdavison Jan 19, 2023
7016572
Adds `context` calls to `lambda`
gdavison Jan 19, 2023
2b71e11
Adds `context` calls to `lexmodels`
gdavison Jan 19, 2023
2f2beb6
Adds `context` calls to `licensemanager`
gdavison Jan 19, 2023
611e009
Adds `context` calls to `lightsail`
gdavison Jan 19, 2023
1c0b429
Adds `context` calls to `location`
gdavison Jan 19, 2023
d3f3dba
Adds `context` calls to `logs`
gdavison Jan 19, 2023
bc6e796
Adds `context` calls to `macie`
gdavison Jan 19, 2023
1d60797
Adds `context` calls to `macie2`
gdavison Jan 19, 2023
e38ddaa
Adds `context` calls to `mediaconnect`
gdavison Jan 19, 2023
54207c2
Adds `context` calls to `mediaconvert`
gdavison Jan 19, 2023
4b21560
Adds `context` calls to `medialive`
gdavison Jan 19, 2023
7216ea6
Adds `context` calls to `mediapackage`
gdavison Jan 19, 2023
a591fd4
Adds `context` calls to `mediastore`
gdavison Jan 19, 2023
6ecd096
Adds `context` calls to `memorydb`
gdavison Jan 19, 2023
7ac038a
Adds `context` calls to `mq`
gdavison Jan 19, 2023
e9edddc
Adds `context` calls to `mwaa`
gdavison Jan 19, 2023
18e5a0d
Adds `context` calls to `neptune`
gdavison Jan 19, 2023
73df00d
Adds `context` calls to `networkfirewall`
gdavison Jan 19, 2023
184126f
Adds `context` calls to `networkmanager`
gdavison Jan 19, 2023
1b58ec6
Adds `context` calls to `opensearch`
gdavison Jan 19, 2023
3ad6a90
Adds `context` calls to `opsworks`
gdavison Jan 19, 2023
90428e8
Adds `context` calls to `organizations`
gdavison Jan 19, 2023
1480afb
Adds `context` calls to `outposts`
gdavison Jan 19, 2023
4fa2937
Adds `context` calls to `pinpoint`
gdavison Jan 19, 2023
35274c4
Adds `context` calls to `pricing`
gdavison Jan 19, 2023
6af3bed
Adds `context` calls to `qldb`
gdavison Jan 19, 2023
9345eb4
Adds `context` calls to `quicksight`
gdavison Jan 19, 2023
b45fd15
Adds `context` calls to `ram`
gdavison Jan 19, 2023
17f0e88
Adds `context` calls to `rds`
gdavison Jan 19, 2023
925726e
Adds `context` calls to `redshift`
gdavison Jan 19, 2023
fa79b32
Adds `context` calls to `redshiftdata`
gdavison Jan 19, 2023
ea6d123
Adds `context` calls to `redshiftserverless`
gdavison Jan 19, 2023
3be644f
Adds `context` calls to `resourceexplorer2`
gdavison Jan 19, 2023
eae34e9
Adds `context` calls to `resourcegroups`
gdavison Jan 19, 2023
664b607
Adds `context` calls to `resourcegroupstaggingapi`
gdavison Jan 19, 2023
bdae971
Adds `context` calls to `rolesanywhere`
gdavison Jan 19, 2023
9d3d7ac
Adds `context` calls to `route53`
gdavison Jan 19, 2023
4636674
Adds `context` calls to `route53domains`
gdavison Jan 19, 2023
41c38e0
Adds `context` calls to `route53recoverycontrolconfig`
gdavison Jan 19, 2023
c1895f2
Adds `context` calls to `route53recoveryreadiness`
gdavison Jan 19, 2023
1b4e867
Adds `context` calls to `route53resolver`
gdavison Jan 19, 2023
f222553
Adds `context` calls to `rum`
gdavison Jan 19, 2023
c02a643
Adds `context` calls to `s3`
gdavison Jan 20, 2023
565095c
Adds `context` calls to `s3control`
gdavison Jan 20, 2023
309e8fa
Adds `context` calls to `s3outposts`
gdavison Jan 20, 2023
4bb0b5b
Adds `context` calls to `sagemaker`
gdavison Jan 20, 2023
2eb055b
Adds `context` calls to `scheduler`
gdavison Jan 20, 2023
589ff43
Adds `context` calls to `schemas`
gdavison Jan 20, 2023
2731a71
Adds `context` calls to `secretsmanager`
gdavison Jan 20, 2023
366ffae
Adds `context` calls to `securityhub`
gdavison Jan 20, 2023
7cc21ed
Adds `context` calls to `servicecatalog`
gdavison Jan 20, 2023
ea19143
Adds `context` calls to `servicediscovery`
gdavison Jan 20, 2023
a090153
Adds `context` calls to `servicequotas`
gdavison Jan 20, 2023
1dbd008
Adds `context` calls to `ses`
gdavison Jan 20, 2023
b75dd6c
Adds `context` calls to `sesv2`
gdavison Jan 20, 2023
f313c9c
Comment fixes
gdavison Jan 20, 2023
fbe446f
Adds `context` calls to `sfn`
gdavison Jan 20, 2023
6f5018c
Adds `context` calls to `shield`
gdavison Jan 20, 2023
abf1c7e
Adds `context` calls to `signer`
gdavison Jan 20, 2023
18eda6c
Adds `context` calls to `simpledb`
gdavison Jan 20, 2023
9007669
Adds `context` calls to `sns`
gdavison Jan 20, 2023
8bf2eb6
Adds `context` calls to `sqs`
gdavison Jan 20, 2023
31294d3
Adds `context` calls to `ssm`
gdavison Jan 20, 2023
1a3890b
Adds `context` calls to `ssoadmin`
gdavison Jan 20, 2023
2bd5a6c
Adds `context` calls to `storagegateway`
gdavison Jan 20, 2023
ac9559c
Adds `context` calls to `swf`
gdavison Jan 20, 2023
9deb577
Adds `context` calls to `synthetics`
gdavison Jan 20, 2023
54cf505
Adds `context` calls to `timestreamwrite`
gdavison Jan 20, 2023
eea22ce
Adds `context` calls to `transcribe`
gdavison Jan 20, 2023
fdb8f0e
Adds `context` calls to `transfer`
gdavison Jan 20, 2023
08ee4bf
Adds `context` calls to `waf`
gdavison Jan 20, 2023
124c0c9
Adds `context` calls to `wafregional`
gdavison Jan 20, 2023
af2f6b9
Adds `context` calls to `wafv2`
gdavison Jan 20, 2023
9d7d08a
Adds `context` calls to `worklink`
gdavison Jan 20, 2023
9056410
Adds `context` calls to `workspaces`
gdavison Jan 20, 2023
d7133d1
Adds `context` calls to `xray`
gdavison Jan 20, 2023
46e5d04
Documents new format for `testAccCheck...Destroy` and `testAccCheck..…
gdavison Jan 20, 2023
d9a97c5
Adds `Context` parameter to `acctest.PreCheckOrganizationsAccount`
gdavison Jan 20, 2023
d4c77c4
Adds `Context` parameter to `acctest.PreCheckOrganizationsEnabled`
gdavison Jan 20, 2023
3f5ddb3
Adds `Context` parameter to `PreCheckOrganizationManagementAccount`
gdavison Jan 20, 2023
e3c6743
Adds `Context` parameter to `acctest.CheckResourceDisappears` and `ac…
gdavison Jan 20, 2023
26f786e
updates `skaff` test templates
gdavison Jan 20, 2023
599dc56
Updates Semgrep rules for non-context calls and use of `context.TODO`
gdavison Jan 20, 2023
f5a7a59
Removes missed `context.Background()` from `internal/service`
gdavison Jan 20, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
2 changes: 0 additions & 2 deletions .ci/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,3 @@ linters:

run:
timeout: 10m
skip-dirs:
- .ci/providerlint/vendor
2 changes: 0 additions & 2 deletions .ci/.golangci2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,5 +106,3 @@ linters-settings:

run:
timeout: 75m
skip-dirs:
- .ci/providerlint/vendor
2 changes: 2 additions & 0 deletions .ci/.semgrep-caps-aws-ec2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ rules:
metavariable: $NAME
patterns:
- pattern-regex: "(?i)AWS"
- focus-metavariable: $NAME
severity: WARNING

- id: aws-in-const-name
languages:
- go
Expand Down
11 changes: 1 addition & 10 deletions .ci/.semgrep.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ rules:
- metavariable-regex:
metavariable: "$FUNCNAME"
regex: "^TestAcc[^_]+_([a-zA-Z]+[dD]isappears|[^_]+_disappears)$"
- focus-metavariable: $FUNCNAME
severity: WARNING

- id: aws-sdk-go-multiple-service-imports
Expand Down Expand Up @@ -869,16 +870,6 @@ rules:
- pattern: "[]string{..., string($X), ...}"
severity: WARNING

- id: avoid-context-TODO-in-tests
languages: [go]
message: Prefer using context.Background() instead of context.TODO()
paths:
include:
- "internal/**/*_test.go"
patterns:
- pattern: context.TODO
severity: ERROR

- id: avoid-context-CRUD-handlers
languages: [go]
message: Prefer using WithoutTimeout CRUD handlers instead of Context variants
Expand Down
28 changes: 28 additions & 0 deletions .ci/semgrep/acctest/naming/naming.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,31 @@ rules:
regex: "^testAcc((?!Check)[a-zA-Z]+Destroy$|(Check)?Destroy)"
# regex: "^testAccCheckDestroy"
severity: WARNING

- id: destroy-check-with-provider
languages: [go]
message: The check destroy with provider function should match the pattern "testAccCheck<Resource>DestroyWithProvider".
paths:
include:
- "internal/**/*_test.go"
patterns:
- pattern: func $FUNCNAME(...) { ... }
- metavariable-regex:
metavariable: "$FUNCNAME"
regex: '^testAccCheck[a-zA-Z]+Destroy(?!With)Provider'
severity: WARNING

- id: destroy-check-signature
languages: [go]
message: The check destroy function should have the correct signature
paths:
include:
- "internal/**/*_test.go"
patterns:
- pattern: func $FUNCNAME(...) { ... }
- metavariable-regex:
metavariable: "$FUNCNAME"
regex: "^testAccCheck[a-zA-Z]+Destroy(?!WithProvider)"
- pattern-not: func $FUNCNAME(s *terraform.State) error { ... }
- pattern-not: func $FUNCNAME(...) resource.TestCheckFunc { ... }
severity: WARNING
75 changes: 75 additions & 0 deletions .ci/semgrep/migrate/context.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
rules:
- id: aws-api-context
languages: [go]
message: All AWS API calls should use the WithContext version
paths: &paths
include:
- internal/service/*
- internal/acctest/*
exclude:
# `pattern-not` not working
- internal/service/kafkaconnect
# WIP
- internal/acctest/acctest.go
patterns:
- pattern: |
$CONN.$API(...)
- metavariable-regex:
metavariable: $CONN
regex: ^(?!conns)\w*([cC]onn)
- metavariable-regex:
metavariable: $API
# This weird construction is to get around greedy matching
regex: ^(?!.*WithContext).*$
- pattern-not: |
$CONN.$APIV2(ctx, ...)
- pattern-not: connect.$API(...)
- pattern-not: tfconnect.$API(...)
- pattern-not: codestarconnections.$API(...)
- pattern-not: tfcodestarconnections.$API(...)
- pattern-not: tfdirectconnect.$API(...)
- pattern-not: kafkaconnect.$API(...)
- pattern-not: tfkafkaconnect.$API(...)
- pattern-not: conn.Handlers.$X(...)
- pattern-not: conn.Handlers.$X.$Y(...)
severity: ERROR
- id: aws-helpers-context
languages: [go]
message: All AWS helper functions should take a context.Context
paths: *paths
patterns:
- pattern: |
$INNER(conn, ...)
- pattern-not: $V2(conn, ...)
- metavariable-regex:
metavariable: $V2
regex: ^New\w+Paginator$
severity: ERROR
- id: retry-context
languages: [go]
message: Waiter and retry functions should use the Context version
paths: *paths
patterns:
- pattern-either:
- pattern: $X.WaitForState()
- pattern: resource.Retry()
- pattern: tfresource.RetryWhen(...)
- pattern: tfresource.RetryWhenAWSErrCodeEquals(...)
- pattern: tfresource.RetryWhenAWSErrMessageContains(...)
- pattern: tfresource.RetryUntilNotFound(...)
- pattern: tfresource.RetryWhenNotFound(...)
- pattern: tfresource.RetryWhenNewResourceNotFound(...)
- pattern: tfresource.WaitUntil(...)
severity: WARNING
- id: context-todo
languages: [go]
message: Should not use `context.TODO()`
paths: *paths
pattern: context.TODO()
severity: ERROR
- id: schema-noop
languages: [go]
message: Should use `schema.NoopContext` instead of `schema.Noop`
paths: *paths
pattern: schema.Noop
severity: ERROR
16 changes: 10 additions & 6 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,10 @@ gh-workflows-lint:

golangci-lint:
@echo "==> Checking source code with golangci-lint..."
@golangci-lint run --config .ci/.golangci.yml ./$(PKG_NAME)/...
@golangci-lint run --config .ci/.golangci2.yml ./$(PKG_NAME)/...
@golangci-lint run \
--config .ci/.golangci.yml \
--config .ci/.golangci2.yml \
./$(PKG_NAME)/...

providerlint:
@echo "==> Checking source code with providerlint..."
Expand All @@ -202,11 +204,11 @@ providerlint:
-XR005=false \
-XS001=false \
-XS002=false \
./$(PKG_NAME)/service/... ./$(PKG_NAME)/provider/...
./internal/service/... ./internal/provider/...

importlint:
@echo "==> Checking source code with importlint..."
@impi --local . --scheme stdThirdPartyLocal ./$(PKG_NAME)/...
@impi --local . --scheme stdThirdPartyLocal ./internal/...

tools:
cd .ci/providerlint && $(GO_VER) install .
Expand Down Expand Up @@ -263,6 +265,7 @@ semgrep:
semall:
@echo "==> Running Semgrep checks locally (must have semgrep installed)..."
@semgrep --error --metrics=off \
$(if $(filter-out $(origin PKG), undefined),--include $(PKG_NAME),) \
--config .ci/.semgrep.yml \
--config .ci/.semgrep-caps-aws-ec2.yml \
--config .ci/.semgrep-configs.yml \
Expand All @@ -271,11 +274,12 @@ semall:
--config .ci/.semgrep-service-name2.yml \
--config .ci/.semgrep-service-name3.yml \
--config .ci/semgrep/acctest/ \
--config .ci/semgrep/migrate/ \
--config 'r/dgryski.semgrep-go.badnilguard' \
--config 'r/dgryski.semgrep-go.errnilcheck' \
--config 'r/dgryski.semgrep-go.marshaljson' \
--config 'r/dgryski.semgrep-go.marshaljson' \
--config 'r/dgryski.semgrep-go.nilerr' \
--config 'r/dgryski.semgrep-go.oddifsequence' \
--config 'r/dgryski.semgrep-go.oddifsequence' \
--config 'r/dgryski.semgrep-go.oserrors'

skaff:
Expand Down
19 changes: 11 additions & 8 deletions docs/adding-a-tag-resource.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,20 @@ import (
)

func TestAcc{Service}Tag_basic(t *testing.T) {
ctx := acctest.Context(t)
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
resourceName := "aws_{service}_tag.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(t) },
ErrorCheck: acctest.ErrorCheck(t, {Service}.EndpointsID),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
CheckDestroy: testAccCheck{Service}TagDestroy,
CheckDestroy: testAccCheck{Service}TagDestroy(ctx),
Steps: []resource.TestStep{
{
Config: testAcc{Service}TagConfig(rName, "key1", "value1"),
Check: resource.ComposeTestCheckFunc(
testAccCheck{Service}TagExists(resourceName),
testAccCheck{Service}TagExists(ctx, resourceName),
resource.TestCheckResourceAttr(resourceName, "key", "key1"),
resource.TestCheckResourceAttr(resourceName, "value", "value1"),
),
Expand All @@ -47,20 +48,21 @@ func TestAcc{Service}Tag_basic(t *testing.T) {
}

func TestAcc{Service}Tag_disappears(t *testing.T) {
ctx := acctest.Context(t)
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
resourceName := "aws_{service}_tag.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(t) },
ErrorCheck: acctest.ErrorCheck(t, {Service}.EndpointsID),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
CheckDestroy: testAccCheck{Service}TagDestroy,
CheckDestroy: testAccCheck{Service}TagDestroy(ctx),
Steps: []resource.TestStep{
{
Config: testAcc{Service}TagConfig(rName, "key1", "value1"),
Check: resource.ComposeTestCheckFunc(
testAccCheck{Service}TagExists(resourceName),
acctest.CheckResourceDisappears(acctest.Provider, resourceAws{Service}Tag(), resourceName),
testAccCheck{Service}TagExists(ctx, resourceName),
acctest.CheckResourceDisappears(ctx, acctest.Provider, resourceAws{Service}Tag(), resourceName),
),
ExpectNonEmptyPlan: true,
},
Expand All @@ -69,19 +71,20 @@ func TestAcc{Service}Tag_disappears(t *testing.T) {
}

func TestAcc{Service}Tag_Value(t *testing.T) {
ctx := acctest.Context(t)
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
resourceName := "aws_{service}_tag.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(t) },
ErrorCheck: acctest.ErrorCheck(t, {Service}.EndpointsID),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
CheckDestroy: testAccCheck{Service}TagDestroy,
CheckDestroy: testAccCheck{Service}TagDestroy(ctx),
Steps: []resource.TestStep{
{
Config: testAcc{Service}TagConfig(rName, "key1", "value1"),
Check: resource.ComposeTestCheckFunc(
testAccCheck{Service}TagExists(resourceName),
testAccCheck{Service}TagExists(ctx, resourceName),
resource.TestCheckResourceAttr(resourceName, "key", "key1"),
resource.TestCheckResourceAttr(resourceName, "value", "value1"),
),
Expand All @@ -94,7 +97,7 @@ func TestAcc{Service}Tag_Value(t *testing.T) {
{
Config: testAcc{Service}TagConfig(rName, "key1", "value1updated"),
Check: resource.ComposeTestCheckFunc(
testAccCheck{Service}TagExists(resourceName),
testAccCheck{Service}TagExists(ctx, resourceName),
resource.TestCheckResourceAttr(resourceName, "key", "key1"),
resource.TestCheckResourceAttr(resourceName, "value", "value1updated"),
),
Expand Down
Loading