Skip to content

Commit 156a638

Browse files
authored
all: Run Go 1.19 fmt (#1025)
To prevent issues with the latest `golangci-lint` in CI.
1 parent 2f7133b commit 156a638

File tree

10 files changed

+151
-156
lines changed

10 files changed

+151
-156
lines changed

diag/helpers.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import "fmt"
66
// as the most common use case in Go will be handling a single error
77
// returned from a function.
88
//
9-
// if err != nil {
10-
// return diag.FromErr(err)
11-
// }
9+
// if err != nil {
10+
// return diag.FromErr(err)
11+
// }
1212
func FromErr(err error) Diagnostics {
1313
if err == nil {
1414
return nil
@@ -26,9 +26,9 @@ func FromErr(err error) Diagnostics {
2626
// values. This returns a single error in a Diagnostics as errors typically
2727
// do not occur in multiples as warnings may.
2828
//
29-
// if unexpectedCondition {
30-
// return diag.Errorf("unexpected: %s", someValue)
31-
// }
29+
// if unexpectedCondition {
30+
// return diag.Errorf("unexpected: %s", someValue)
31+
// }
3232
func Errorf(format string, a ...interface{}) Diagnostics {
3333
return Diagnostics{
3434
Diagnostic{

helper/customdiff/compose.go

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -18,32 +18,31 @@ import (
1818
//
1919
// For example:
2020
//
21-
// &schema.Resource{
22-
// // ...
23-
// CustomizeDiff: customdiff.All(
24-
// customdiff.ValidateChange("size", func (old, new, meta interface{}) error {
25-
// // If we are increasing "size" then the new value must be
26-
// // a multiple of the old value.
27-
// if new.(int) <= old.(int) {
28-
// return nil
29-
// }
30-
// if (new.(int) % old.(int)) != 0 {
31-
// return fmt.Errorf("new size value must be an integer multiple of old value %d", old.(int))
32-
// }
33-
// return nil
34-
// }),
35-
// customdiff.ForceNewIfChange("size", func (old, new, meta interface{}) bool {
36-
// // "size" can only increase in-place, so we must create a new resource
37-
// // if it is decreased.
38-
// return new.(int) < old.(int)
39-
// }),
40-
// customdiff.ComputedIf("version_id", func (d *schema.ResourceDiff, meta interface{}) bool {
41-
// // Any change to "content" causes a new "version_id" to be allocated.
42-
// return d.HasChange("content")
43-
// }),
44-
// ),
45-
// }
46-
//
21+
// &schema.Resource{
22+
// // ...
23+
// CustomizeDiff: customdiff.All(
24+
// customdiff.ValidateChange("size", func (old, new, meta interface{}) error {
25+
// // If we are increasing "size" then the new value must be
26+
// // a multiple of the old value.
27+
// if new.(int) <= old.(int) {
28+
// return nil
29+
// }
30+
// if (new.(int) % old.(int)) != 0 {
31+
// return fmt.Errorf("new size value must be an integer multiple of old value %d", old.(int))
32+
// }
33+
// return nil
34+
// }),
35+
// customdiff.ForceNewIfChange("size", func (old, new, meta interface{}) bool {
36+
// // "size" can only increase in-place, so we must create a new resource
37+
// // if it is decreased.
38+
// return new.(int) < old.(int)
39+
// }),
40+
// customdiff.ComputedIf("version_id", func (d *schema.ResourceDiff, meta interface{}) bool {
41+
// // Any change to "content" causes a new "version_id" to be allocated.
42+
// return d.HasChange("content")
43+
// }),
44+
// ),
45+
// }
4746
func All(funcs ...schema.CustomizeDiffFunc) schema.CustomizeDiffFunc {
4847
return func(ctx context.Context, d *schema.ResourceDiff, meta interface{}) error {
4948
var err error

helper/resource/testcase_validate.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,9 @@ func (c TestCase) hasProviders(_ context.Context) bool {
3636

3737
// validate ensures the TestCase is valid based on the following criteria:
3838
//
39-
// - No overlapping ExternalProviders and Providers entries
40-
// - No overlapping ExternalProviders and ProviderFactories entries
41-
// - TestStep validations performed by the (TestStep).validate() method.
42-
//
39+
// - No overlapping ExternalProviders and Providers entries
40+
// - No overlapping ExternalProviders and ProviderFactories entries
41+
// - TestStep validations performed by the (TestStep).validate() method.
4342
func (c TestCase) validate(ctx context.Context) error {
4443
logging.HelperResourceTrace(ctx, "Validating TestCase")
4544

helper/resource/testing.go

Lines changed: 70 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,10 @@ func AddTestSweepers(name string, s *Sweeper) {
100100
//
101101
// Sweeper flags added to the "go test" command:
102102
//
103-
// -sweep: Comma-separated list of locations/regions to run available sweepers.
104-
// -sweep-allow-failues: Enable to allow other sweepers to run after failures.
105-
// -sweep-run: Comma-separated list of resource type sweepers to run. Defaults
106-
// to all sweepers.
103+
// -sweep: Comma-separated list of locations/regions to run available sweepers.
104+
// -sweep-allow-failues: Enable to allow other sweepers to run after failures.
105+
// -sweep-run: Comma-separated list of resource type sweepers to run. Defaults
106+
// to all sweepers.
107107
//
108108
// Refer to the Env prefixed constants for environment variables that further
109109
// control testing functionality.
@@ -665,16 +665,16 @@ func ParallelTest(t testing.T, c TestCase) {
665665
// This function will automatically find or install Terraform CLI into a
666666
// temporary directory, based on the following behavior:
667667
//
668-
// - If the TF_ACC_TERRAFORM_PATH environment variable is set, that
669-
// Terraform CLI binary is used if found and executable. If not found or
670-
// executable, an error will be returned unless the
671-
// TF_ACC_TERRAFORM_VERSION environment variable is also set.
672-
// - If the TF_ACC_TERRAFORM_VERSION environment variable is set, install
673-
// and use that Terraform CLI version.
674-
// - If both the TF_ACC_TERRAFORM_PATH and TF_ACC_TERRAFORM_VERSION
675-
// environment variables are unset, perform a lookup for the Terraform
676-
// CLI binary based on the operating system PATH. If not found, the
677-
// latest available Terraform CLI binary is installed.
668+
// - If the TF_ACC_TERRAFORM_PATH environment variable is set, that
669+
// Terraform CLI binary is used if found and executable. If not found or
670+
// executable, an error will be returned unless the
671+
// TF_ACC_TERRAFORM_VERSION environment variable is also set.
672+
// - If the TF_ACC_TERRAFORM_VERSION environment variable is set, install
673+
// and use that Terraform CLI version.
674+
// - If both the TF_ACC_TERRAFORM_PATH and TF_ACC_TERRAFORM_VERSION
675+
// environment variables are unset, perform a lookup for the Terraform
676+
// CLI binary based on the operating system PATH. If not found, the
677+
// latest available Terraform CLI binary is installed.
678678
//
679679
// Refer to the Env prefixed constants for additional details about these
680680
// environment variables, and others, that control testing functionality.
@@ -821,35 +821,35 @@ func ComposeAggregateTestCheckFunc(fs ...TestCheckFunc) TestCheckFunc {
821821
// Use this as a last resort when a more specific TestCheckFunc cannot be
822822
// implemented, such as:
823823
//
824-
// - TestCheckResourceAttr: Equality checking of non-TypeSet state value.
825-
// - TestCheckResourceAttrPair: Equality checking of non-TypeSet state
826-
// value, based on another state value.
827-
// - TestCheckTypeSet*: Equality checking of TypeSet state values.
828-
// - TestMatchResourceAttr: Regular expression checking of non-TypeSet
829-
// state value.
830-
// - TestMatchTypeSet*: Regular expression checking on TypeSet state values.
824+
// - TestCheckResourceAttr: Equality checking of non-TypeSet state value.
825+
// - TestCheckResourceAttrPair: Equality checking of non-TypeSet state
826+
// value, based on another state value.
827+
// - TestCheckTypeSet*: Equality checking of TypeSet state values.
828+
// - TestMatchResourceAttr: Regular expression checking of non-TypeSet
829+
// state value.
830+
// - TestMatchTypeSet*: Regular expression checking on TypeSet state values.
831831
//
832832
// For managed resources, the name parameter is combination of the resource
833833
// type, a period (.), and the name label. The name for the below example
834834
// configuration would be "myprovider_thing.example".
835835
//
836-
// resource "myprovider_thing" "example" { ... }
836+
// resource "myprovider_thing" "example" { ... }
837837
//
838838
// For data sources, the name parameter is a combination of the keyword "data",
839839
// a period (.), the data source type, a period (.), and the name label. The
840840
// name for the below example configuration would be
841841
// "data.myprovider_thing.example".
842842
//
843-
// data "myprovider_thing" "example" { ... }
843+
// data "myprovider_thing" "example" { ... }
844844
//
845845
// The key parameter is an attribute path in Terraform CLI 0.11 and earlier
846846
// "flatmap" syntax. Keys start with the attribute name of a top-level
847847
// attribute. Use the following special key syntax to inspect underlying
848848
// values of a list or map attribute:
849849
//
850-
// - .{NUMBER}: List value at index, e.g. .0 to inspect the first element
851-
// - .{KEY}: Map value at key, e.g. .example to inspect the example key
852-
// value
850+
// - .{NUMBER}: List value at index, e.g. .0 to inspect the first element
851+
// - .{KEY}: Map value at key, e.g. .example to inspect the example key
852+
// value
853853
//
854854
// While it is possible to check nested attributes under list and map
855855
// attributes using the special key syntax, checking a list, map, or set
@@ -918,34 +918,34 @@ func testCheckResourceAttrSet(is *terraform.InstanceState, name string, key stri
918918
// type, a period (.), and the name label. The name for the below example
919919
// configuration would be "myprovider_thing.example".
920920
//
921-
// resource "myprovider_thing" "example" { ... }
921+
// resource "myprovider_thing" "example" { ... }
922922
//
923923
// For data sources, the name parameter is a combination of the keyword "data",
924924
// a period (.), the data source type, a period (.), and the name label. The
925925
// name for the below example configuration would be
926926
// "data.myprovider_thing.example".
927927
//
928-
// data "myprovider_thing" "example" { ... }
928+
// data "myprovider_thing" "example" { ... }
929929
//
930930
// The key parameter is an attribute path in Terraform CLI 0.11 and earlier
931931
// "flatmap" syntax. Keys start with the attribute name of a top-level
932932
// attribute. Use the following special key syntax to inspect list, map, and
933933
// set attributes:
934934
//
935-
// - .{NUMBER}: List value at index, e.g. .0 to inspect the first element.
936-
// Use the TestCheckTypeSet* and TestMatchTypeSet* functions instead
937-
// for sets.
938-
// - .{KEY}: Map value at key, e.g. .example to inspect the example key
939-
// value.
940-
// - .#: Number of elements in list or set.
941-
// - .%: Number of elements in map.
935+
// - .{NUMBER}: List value at index, e.g. .0 to inspect the first element.
936+
// Use the TestCheckTypeSet* and TestMatchTypeSet* functions instead
937+
// for sets.
938+
// - .{KEY}: Map value at key, e.g. .example to inspect the example key
939+
// value.
940+
// - .#: Number of elements in list or set.
941+
// - .%: Number of elements in map.
942942
//
943943
// The value parameter is the stringified data to check at the given key. Use
944944
// the following attribute type rules to set the value:
945945
//
946-
// - Boolean: "false" or "true".
947-
// - Float/Integer: Stringified number, such as "1.2" or "123".
948-
// - String: No conversion necessary.
946+
// - Boolean: "false" or "true".
947+
// - Float/Integer: Stringified number, such as "1.2" or "123".
948+
// - String: No conversion necessary.
949949
func TestCheckResourceAttr(name, key, value string) TestCheckFunc {
950950
return checkIfIndexesIntoTypeSet(key, func(s *terraform.State) error {
951951
is, err := primaryInstanceState(s, name)
@@ -1032,27 +1032,27 @@ type CheckResourceAttrWithFunc func(value string) error
10321032
// type, a period (.), and the name label. The name for the below example
10331033
// configuration would be "myprovider_thing.example".
10341034
//
1035-
// resource "myprovider_thing" "example" { ... }
1035+
// resource "myprovider_thing" "example" { ... }
10361036
//
10371037
// For data sources, the name parameter is a combination of the keyword "data",
10381038
// a period (.), the data source type, a period (.), and the name label. The
10391039
// name for the below example configuration would be
10401040
// "data.myprovider_thing.example".
10411041
//
1042-
// data "myprovider_thing" "example" { ... }
1042+
// data "myprovider_thing" "example" { ... }
10431043
//
10441044
// The key parameter is an attribute path in Terraform CLI 0.11 and earlier
10451045
// "flatmap" syntax. Keys start with the attribute name of a top-level
10461046
// attribute. Use the following special key syntax to inspect list, map, and
10471047
// set attributes:
10481048
//
1049-
// - .{NUMBER}: List value at index, e.g. .0 to inspect the first element.
1050-
// Use the TestCheckTypeSet* and TestMatchTypeSet* functions instead
1051-
// for sets.
1052-
// - .{KEY}: Map value at key, e.g. .example to inspect the example key
1053-
// value.
1054-
// - .#: Number of elements in list or set.
1055-
// - .%: Number of elements in map.
1049+
// - .{NUMBER}: List value at index, e.g. .0 to inspect the first element.
1050+
// Use the TestCheckTypeSet* and TestMatchTypeSet* functions instead
1051+
// for sets.
1052+
// - .{KEY}: Map value at key, e.g. .example to inspect the example key
1053+
// value.
1054+
// - .#: Number of elements in list or set.
1055+
// - .%: Number of elements in map.
10561056
//
10571057
// The checkValueFunc parameter is a CheckResourceAttrWithFunc,
10581058
// and it's provided with the attribute value to apply a custom checking logic,
@@ -1088,23 +1088,23 @@ func TestCheckResourceAttrWith(name, key string, checkValueFunc CheckResourceAtt
10881088
// type, a period (.), and the name label. The name for the below example
10891089
// configuration would be "myprovider_thing.example".
10901090
//
1091-
// resource "myprovider_thing" "example" { ... }
1091+
// resource "myprovider_thing" "example" { ... }
10921092
//
10931093
// For data sources, the name parameter is a combination of the keyword "data",
10941094
// a period (.), the data source type, a period (.), and the name label. The
10951095
// name for the below example configuration would be
10961096
// "data.myprovider_thing.example".
10971097
//
1098-
// data "myprovider_thing" "example" { ... }
1098+
// data "myprovider_thing" "example" { ... }
10991099
//
11001100
// The key parameter is an attribute path in Terraform CLI 0.11 and earlier
11011101
// "flatmap" syntax. Keys start with the attribute name of a top-level
11021102
// attribute. Use the following special key syntax to inspect underlying
11031103
// values of a list or map attribute:
11041104
//
1105-
// - .{NUMBER}: List value at index, e.g. .0 to inspect the first element.
1106-
// - .{KEY}: Map value at key, e.g. .example to inspect the example key
1107-
// value.
1105+
// - .{NUMBER}: List value at index, e.g. .0 to inspect the first element.
1106+
// - .{KEY}: Map value at key, e.g. .example to inspect the example key
1107+
// value.
11081108
//
11091109
// While it is possible to check nested attributes under list and map
11101110
// attributes using the special key syntax, checking a list, map, or set
@@ -1180,27 +1180,27 @@ func testCheckNoResourceAttr(is *terraform.InstanceState, name string, key strin
11801180
// type, a period (.), and the name label. The name for the below example
11811181
// configuration would be "myprovider_thing.example".
11821182
//
1183-
// resource "myprovider_thing" "example" { ... }
1183+
// resource "myprovider_thing" "example" { ... }
11841184
//
11851185
// For data sources, the name parameter is a combination of the keyword "data",
11861186
// a period (.), the data source type, a period (.), and the name label. The
11871187
// name for the below example configuration would be
11881188
// "data.myprovider_thing.example".
11891189
//
1190-
// data "myprovider_thing" "example" { ... }
1190+
// data "myprovider_thing" "example" { ... }
11911191
//
11921192
// The key parameter is an attribute path in Terraform CLI 0.11 and earlier
11931193
// "flatmap" syntax. Keys start with the attribute name of a top-level
11941194
// attribute. Use the following special key syntax to inspect list, map, and
11951195
// set attributes:
11961196
//
1197-
// - .{NUMBER}: List value at index, e.g. .0 to inspect the first element.
1198-
// Use the TestCheckTypeSet* and TestMatchTypeSet* functions instead
1199-
// for sets.
1200-
// - .{KEY}: Map value at key, e.g. .example to inspect the example key
1201-
// value.
1202-
// - .#: Number of elements in list or set.
1203-
// - .%: Number of elements in map.
1197+
// - .{NUMBER}: List value at index, e.g. .0 to inspect the first element.
1198+
// Use the TestCheckTypeSet* and TestMatchTypeSet* functions instead
1199+
// for sets.
1200+
// - .{KEY}: Map value at key, e.g. .example to inspect the example key
1201+
// value.
1202+
// - .#: Number of elements in list or set.
1203+
// - .%: Number of elements in map.
12041204
//
12051205
// The value parameter is a compiled regular expression. A typical pattern is
12061206
// using the regexp.MustCompile() function, which will automatically ensure the
@@ -1273,14 +1273,14 @@ func TestCheckModuleResourceAttrPtr(mp []string, name string, key string, value
12731273
// type, a period (.), and the name label. The name for the below example
12741274
// configuration would be "myprovider_thing.example".
12751275
//
1276-
// resource "myprovider_thing" "example" { ... }
1276+
// resource "myprovider_thing" "example" { ... }
12771277
//
12781278
// For data sources, the name parameter is a combination of the keyword "data",
12791279
// a period (.), the data source type, a period (.), and the name label. The
12801280
// name for the below example configuration would be
12811281
// "data.myprovider_thing.example".
12821282
//
1283-
// data "myprovider_thing" "example" { ... }
1283+
// data "myprovider_thing" "example" { ... }
12841284
//
12851285
// The first and second names may use any combination of managed resources
12861286
// and/or data sources.
@@ -1290,13 +1290,13 @@ func TestCheckModuleResourceAttrPtr(mp []string, name string, key string, value
12901290
// attribute. Use the following special key syntax to inspect list, map, and
12911291
// set attributes:
12921292
//
1293-
// - .{NUMBER}: List value at index, e.g. .0 to inspect the first element.
1294-
// Use the TestCheckTypeSet* and TestMatchTypeSet* functions instead
1295-
// for sets.
1296-
// - .{KEY}: Map value at key, e.g. .example to inspect the example key
1297-
// value.
1298-
// - .#: Number of elements in list or set.
1299-
// - .%: Number of elements in map.
1293+
// - .{NUMBER}: List value at index, e.g. .0 to inspect the first element.
1294+
// Use the TestCheckTypeSet* and TestMatchTypeSet* functions instead
1295+
// for sets.
1296+
// - .{KEY}: Map value at key, e.g. .example to inspect the example key
1297+
// value.
1298+
// - .#: Number of elements in list or set.
1299+
// - .%: Number of elements in map.
13001300
func TestCheckResourceAttrPair(nameFirst, keyFirst, nameSecond, keySecond string) TestCheckFunc {
13011301
return checkIfIndexesIntoTypeSetPair(keyFirst, keySecond, func(s *terraform.State) error {
13021302
isFirst, err := primaryInstanceState(s, nameFirst)

0 commit comments

Comments
 (0)