From ec259ef50600f7b327b4591861aacacd5db27880 Mon Sep 17 00:00:00 2001 From: Paul Tyng Date: Tue, 10 Mar 2020 15:44:38 -0400 Subject: [PATCH] gofmt -s --- helper/resource/testing_new.go | 4 +- helper/resource/testing_test.go | 172 ++-- helper/schema/core_schema_test.go | 2 +- helper/schema/field_reader.go | 2 +- helper/schema/field_reader_config_test.go | 16 +- helper/schema/field_reader_diff_test.go | 114 +-- helper/schema/field_reader_map_test.go | 4 +- helper/schema/field_reader_multi_test.go | 30 +- helper/schema/field_reader_test.go | 68 +- helper/schema/field_writer_map.go | 4 +- helper/schema/field_writer_map_test.go | 38 +- helper/schema/provider.go | 4 +- helper/schema/provider_test.go | 46 +- helper/schema/resource.go | 2 +- helper/schema/resource_data.go | 2 +- helper/schema/resource_data_test.go | 324 +++---- helper/schema/resource_diff_test.go | 214 ++--- helper/schema/resource_test.go | 108 +-- helper/schema/schema.go | 6 +- helper/schema/schema_test.go | 894 +++++++++--------- helper/schema/serialize_test.go | 52 +- helper/schema/shims_test.go | 434 ++++----- .../configs/configschema/decoder_spec_test.go | 8 +- .../configs/configschema/implied_type_test.go | 14 +- .../configschema/internal_validate_test.go | 52 +- internal/configs/hcl2shim/paths_test.go | 18 +- internal/helper/plugin/grpc_provider_test.go | 16 +- internal/helper/plugin/unknown_test.go | 4 +- internal/plugin/convert/schema_test.go | 28 +- scripts/gofmtcheck.sh | 2 +- terraform/diff.go | 16 +- terraform/diff_test.go | 160 ++-- terraform/resource_test.go | 4 +- terraform/state.go | 10 +- terraform/state_test.go | 162 ++-- 35 files changed, 1517 insertions(+), 1517 deletions(-) diff --git a/helper/resource/testing_new.go b/helper/resource/testing_new.go index f16ead31452..a94ef6c6234 100644 --- a/helper/resource/testing_new.go +++ b/helper/resource/testing_new.go @@ -148,12 +148,12 @@ func testIDRefresh(c TestCase, t *testing.T, wd *tftest.WorkingDir, step TestSte expected := r.Primary.Attributes // Remove fields we're ignoring for _, v := range c.IDRefreshIgnore { - for k, _ := range actual { + for k := range actual { if strings.HasPrefix(k, v) { delete(actual, k) } } - for k, _ := range expected { + for k := range expected { if strings.HasPrefix(k, v) { delete(expected, k) } diff --git a/helper/resource/testing_test.go b/helper/resource/testing_test.go index 1e3eef2c395..eacc6ae52d2 100644 --- a/helper/resource/testing_test.go +++ b/helper/resource/testing_test.go @@ -50,7 +50,7 @@ func TestTest_factoryError(t *testing.T) { "test": factory, }, Steps: []TestStep{ - TestStep{ + { ExpectError: regexp.MustCompile("resource factory error"), }, }, @@ -198,7 +198,7 @@ func TestTest_Main(t *testing.T) { { Name: "basic passing", Sweepers: map[string]*Sweeper{ - "aws_dummy": &Sweeper{ + "aws_dummy": { Name: "aws_dummy", F: mockSweeperFunc, }, @@ -233,7 +233,7 @@ func TestFilterSweepers(t *testing.T) { { Name: "normal", Sweepers: map[string]*Sweeper{ - "aws_dummy": &Sweeper{ + "aws_dummy": { Name: "aws_dummy", F: mockSweeperFunc, }, @@ -243,16 +243,16 @@ func TestFilterSweepers(t *testing.T) { { Name: "with dep", Sweepers: map[string]*Sweeper{ - "aws_dummy": &Sweeper{ + "aws_dummy": { Name: "aws_dummy", F: mockSweeperFunc, }, - "aws_top": &Sweeper{ + "aws_top": { Name: "aws_top", Dependencies: []string{"aws_sub"}, F: mockSweeperFunc, }, - "aws_sub": &Sweeper{ + "aws_sub": { Name: "aws_sub", F: mockSweeperFunc, }, @@ -262,16 +262,16 @@ func TestFilterSweepers(t *testing.T) { { Name: "with filter", Sweepers: map[string]*Sweeper{ - "aws_dummy": &Sweeper{ + "aws_dummy": { Name: "aws_dummy", F: mockSweeperFunc, }, - "aws_top": &Sweeper{ + "aws_top": { Name: "aws_top", Dependencies: []string{"aws_sub"}, F: mockSweeperFunc, }, - "aws_sub": &Sweeper{ + "aws_sub": { Name: "aws_sub", F: mockSweeperFunc, }, @@ -282,16 +282,16 @@ func TestFilterSweepers(t *testing.T) { { Name: "with two filters", Sweepers: map[string]*Sweeper{ - "aws_dummy": &Sweeper{ + "aws_dummy": { Name: "aws_dummy", F: mockSweeperFunc, }, - "aws_top": &Sweeper{ + "aws_top": { Name: "aws_top", Dependencies: []string{"aws_sub"}, F: mockSweeperFunc, }, - "aws_sub": &Sweeper{ + "aws_sub": { Name: "aws_sub", F: mockSweeperFunc, }, @@ -302,16 +302,16 @@ func TestFilterSweepers(t *testing.T) { { Name: "with dep and filter", Sweepers: map[string]*Sweeper{ - "aws_dummy": &Sweeper{ + "aws_dummy": { Name: "aws_dummy", F: mockSweeperFunc, }, - "aws_top": &Sweeper{ + "aws_top": { Name: "aws_top", Dependencies: []string{"aws_sub"}, F: mockSweeperFunc, }, - "aws_sub": &Sweeper{ + "aws_sub": { Name: "aws_sub", F: mockSweeperFunc, }, @@ -322,16 +322,16 @@ func TestFilterSweepers(t *testing.T) { { Name: "with non-matching filter", Sweepers: map[string]*Sweeper{ - "aws_dummy": &Sweeper{ + "aws_dummy": { Name: "aws_dummy", F: mockSweeperFunc, }, - "aws_top": &Sweeper{ + "aws_top": { Name: "aws_top", Dependencies: []string{"aws_sub"}, F: mockSweeperFunc, }, - "aws_sub": &Sweeper{ + "aws_sub": { Name: "aws_sub", F: mockSweeperFunc, }, @@ -341,21 +341,21 @@ func TestFilterSweepers(t *testing.T) { { Name: "with nested depenencies and top level filter", Sweepers: map[string]*Sweeper{ - "not_matching": &Sweeper{ + "not_matching": { Name: "not_matching", F: mockSweeperFunc, }, - "matching_level1": &Sweeper{ + "matching_level1": { Name: "matching_level1", Dependencies: []string{"matching_level2"}, F: mockSweeperFunc, }, - "matching_level2": &Sweeper{ + "matching_level2": { Name: "matching_level2", Dependencies: []string{"matching_level3"}, F: mockSweeperFunc, }, - "matching_level3": &Sweeper{ + "matching_level3": { Name: "matching_level3", F: mockSweeperFunc, }, @@ -366,21 +366,21 @@ func TestFilterSweepers(t *testing.T) { { Name: "with nested depenencies and middle level filter", Sweepers: map[string]*Sweeper{ - "not_matching": &Sweeper{ + "not_matching": { Name: "not_matching", F: mockSweeperFunc, }, - "matching_level1": &Sweeper{ + "matching_level1": { Name: "matching_level1", Dependencies: []string{"matching_level2"}, F: mockSweeperFunc, }, - "matching_level2": &Sweeper{ + "matching_level2": { Name: "matching_level2", Dependencies: []string{"matching_level3"}, F: mockSweeperFunc, }, - "matching_level3": &Sweeper{ + "matching_level3": { Name: "matching_level3", F: mockSweeperFunc, }, @@ -391,21 +391,21 @@ func TestFilterSweepers(t *testing.T) { { Name: "with nested depenencies and bottom level filter", Sweepers: map[string]*Sweeper{ - "not_matching": &Sweeper{ + "not_matching": { Name: "not_matching", F: mockSweeperFunc, }, - "matching_level1": &Sweeper{ + "matching_level1": { Name: "matching_level1", Dependencies: []string{"matching_level2"}, F: mockSweeperFunc, }, - "matching_level2": &Sweeper{ + "matching_level2": { Name: "matching_level2", Dependencies: []string{"matching_level3"}, F: mockSweeperFunc, }, - "matching_level3": &Sweeper{ + "matching_level3": { Name: "matching_level3", F: mockSweeperFunc, }, @@ -423,7 +423,7 @@ func TestFilterSweepers(t *testing.T) { actualSweepers := filterSweepers(tc.Filter, tc.Sweepers) var keys []string - for k, _ := range actualSweepers { + for k := range actualSweepers { keys = append(keys, k) } @@ -446,11 +446,11 @@ func TestFilterSweeperWithDependencies(t *testing.T) { { Name: "no dependencies", Sweepers: map[string]*Sweeper{ - "matching_level1": &Sweeper{ + "matching_level1": { Name: "matching_level1", F: mockSweeperFunc, }, - "non_matching": &Sweeper{ + "non_matching": { Name: "non_matching", F: mockSweeperFunc, }, @@ -461,12 +461,12 @@ func TestFilterSweeperWithDependencies(t *testing.T) { { Name: "one level one dependency", Sweepers: map[string]*Sweeper{ - "matching_level1": &Sweeper{ + "matching_level1": { Name: "matching_level1", Dependencies: []string{"matching_level2"}, F: mockSweeperFunc, }, - "matching_level2": &Sweeper{ + "matching_level2": { Name: "matching_level2", F: mockSweeperFunc, }, @@ -477,16 +477,16 @@ func TestFilterSweeperWithDependencies(t *testing.T) { { Name: "one level multiple dependencies", Sweepers: map[string]*Sweeper{ - "matching_level1": &Sweeper{ + "matching_level1": { Name: "matching_level1", Dependencies: []string{"matching_level2a", "matching_level2b"}, F: mockSweeperFunc, }, - "matching_level2a": &Sweeper{ + "matching_level2a": { Name: "matching_level2a", F: mockSweeperFunc, }, - "matching_level2b": &Sweeper{ + "matching_level2b": { Name: "matching_level2b", F: mockSweeperFunc, }, @@ -497,17 +497,17 @@ func TestFilterSweeperWithDependencies(t *testing.T) { { Name: "multiple level one dependency", Sweepers: map[string]*Sweeper{ - "matching_level1": &Sweeper{ + "matching_level1": { Name: "matching_level1", Dependencies: []string{"matching_level2"}, F: mockSweeperFunc, }, - "matching_level2": &Sweeper{ + "matching_level2": { Name: "matching_level2", Dependencies: []string{"matching_level3"}, F: mockSweeperFunc, }, - "matching_level3": &Sweeper{ + "matching_level3": { Name: "matching_level3", F: mockSweeperFunc, }, @@ -518,34 +518,34 @@ func TestFilterSweeperWithDependencies(t *testing.T) { { Name: "multiple level multiple dependencies", Sweepers: map[string]*Sweeper{ - "matching_level1": &Sweeper{ + "matching_level1": { Name: "matching_level1", Dependencies: []string{"matching_level2a", "matching_level2b"}, F: mockSweeperFunc, }, - "matching_level2a": &Sweeper{ + "matching_level2a": { Name: "matching_level2a", Dependencies: []string{"matching_level3a", "matching_level3b"}, F: mockSweeperFunc, }, - "matching_level2b": &Sweeper{ + "matching_level2b": { Name: "matching_level2b", Dependencies: []string{"matching_level3c", "matching_level3d"}, F: mockSweeperFunc, }, - "matching_level3a": &Sweeper{ + "matching_level3a": { Name: "matching_level3a", F: mockSweeperFunc, }, - "matching_level3b": &Sweeper{ + "matching_level3b": { Name: "matching_level3b", F: mockSweeperFunc, }, - "matching_level3c": &Sweeper{ + "matching_level3c": { Name: "matching_level3c", F: mockSweeperFunc, }, - "matching_level3d": &Sweeper{ + "matching_level3d": { Name: "matching_level3d", F: mockSweeperFunc, }, @@ -556,17 +556,17 @@ func TestFilterSweeperWithDependencies(t *testing.T) { { Name: "no parents one level", Sweepers: map[string]*Sweeper{ - "matching_level1": &Sweeper{ + "matching_level1": { Name: "matching_level1", Dependencies: []string{"matching_level2"}, F: mockSweeperFunc, }, - "matching_level2": &Sweeper{ + "matching_level2": { Name: "matching_level2", Dependencies: []string{"matching_level3"}, F: mockSweeperFunc, }, - "matching_level3": &Sweeper{ + "matching_level3": { Name: "matching_level3", F: mockSweeperFunc, }, @@ -577,17 +577,17 @@ func TestFilterSweeperWithDependencies(t *testing.T) { { Name: "no parents multiple level", Sweepers: map[string]*Sweeper{ - "matching_level1": &Sweeper{ + "matching_level1": { Name: "matching_level1", Dependencies: []string{"matching_level2"}, F: mockSweeperFunc, }, - "matching_level2": &Sweeper{ + "matching_level2": { Name: "matching_level2", Dependencies: []string{"matching_level3"}, F: mockSweeperFunc, }, - "matching_level3": &Sweeper{ + "matching_level3": { Name: "matching_level3", F: mockSweeperFunc, }, @@ -598,16 +598,16 @@ func TestFilterSweeperWithDependencies(t *testing.T) { { Name: "one level missing dependency", Sweepers: map[string]*Sweeper{ - "matching_level1": &Sweeper{ + "matching_level1": { Name: "matching_level1", Dependencies: []string{"matching_level2a", "matching_level2c"}, F: mockSweeperFunc, }, - "matching_level2a": &Sweeper{ + "matching_level2a": { Name: "matching_level2a", F: mockSweeperFunc, }, - "matching_level2b": &Sweeper{ + "matching_level2b": { Name: "matching_level2b", F: mockSweeperFunc, }, @@ -618,34 +618,34 @@ func TestFilterSweeperWithDependencies(t *testing.T) { { Name: "multiple level missing dependencies", Sweepers: map[string]*Sweeper{ - "matching_level1": &Sweeper{ + "matching_level1": { Name: "matching_level1", Dependencies: []string{"matching_level2a", "matching_level2b", "matching_level2c"}, F: mockSweeperFunc, }, - "matching_level2a": &Sweeper{ + "matching_level2a": { Name: "matching_level2a", Dependencies: []string{"matching_level3a", "matching_level3e"}, F: mockSweeperFunc, }, - "matching_level2b": &Sweeper{ + "matching_level2b": { Name: "matching_level2b", Dependencies: []string{"matching_level3c", "matching_level3f"}, F: mockSweeperFunc, }, - "matching_level3a": &Sweeper{ + "matching_level3a": { Name: "matching_level3a", F: mockSweeperFunc, }, - "matching_level3b": &Sweeper{ + "matching_level3b": { Name: "matching_level3b", F: mockSweeperFunc, }, - "matching_level3c": &Sweeper{ + "matching_level3c": { Name: "matching_level3c", F: mockSweeperFunc, }, - "matching_level3d": &Sweeper{ + "matching_level3d": { Name: "matching_level3d", F: mockSweeperFunc, }, @@ -663,7 +663,7 @@ func TestFilterSweeperWithDependencies(t *testing.T) { actualSweepers := filterSweeperWithDependencies(tc.StartingSweeper, tc.Sweepers) var keys []string - for k, _ := range actualSweepers { + for k := range actualSweepers { keys = append(keys, k) } @@ -688,7 +688,7 @@ func TestRunSweepers(t *testing.T) { { Name: "single", Sweepers: map[string]*Sweeper{ - "aws_dummy": &Sweeper{ + "aws_dummy": { Name: "aws_dummy", F: mockSweeperFunc, }, @@ -698,11 +698,11 @@ func TestRunSweepers(t *testing.T) { { Name: "multiple", Sweepers: map[string]*Sweeper{ - "aws_one": &Sweeper{ + "aws_one": { Name: "aws_one", F: mockSweeperFunc, }, - "aws_two": &Sweeper{ + "aws_two": { Name: "aws_two", F: mockSweeperFunc, }, @@ -712,16 +712,16 @@ func TestRunSweepers(t *testing.T) { { Name: "multiple with dep", Sweepers: map[string]*Sweeper{ - "aws_dummy": &Sweeper{ + "aws_dummy": { Name: "aws_dummy", F: mockSweeperFunc, }, - "aws_top": &Sweeper{ + "aws_top": { Name: "aws_top", Dependencies: []string{"aws_sub"}, F: mockSweeperFunc, }, - "aws_sub": &Sweeper{ + "aws_sub": { Name: "aws_sub", F: mockSweeperFunc, }, @@ -731,12 +731,12 @@ func TestRunSweepers(t *testing.T) { { Name: "failing dep", Sweepers: map[string]*Sweeper{ - "aws_top": &Sweeper{ + "aws_top": { Name: "aws_top", Dependencies: []string{"aws_sub"}, F: mockSweeperFunc, }, - "aws_sub": &Sweeper{ + "aws_sub": { Name: "aws_sub", F: mockFailingSweeperFunc, }, @@ -747,12 +747,12 @@ func TestRunSweepers(t *testing.T) { { Name: "failing dep allow failures", Sweepers: map[string]*Sweeper{ - "aws_top": &Sweeper{ + "aws_top": { Name: "aws_top", Dependencies: []string{"aws_sub"}, F: mockSweeperFunc, }, - "aws_sub": &Sweeper{ + "aws_sub": { Name: "aws_sub", F: mockFailingSweeperFunc, }, @@ -764,12 +764,12 @@ func TestRunSweepers(t *testing.T) { { Name: "failing top", Sweepers: map[string]*Sweeper{ - "aws_top": &Sweeper{ + "aws_top": { Name: "aws_top", Dependencies: []string{"aws_sub"}, F: mockFailingSweeperFunc, }, - "aws_sub": &Sweeper{ + "aws_sub": { Name: "aws_sub", F: mockSweeperFunc, }, @@ -780,12 +780,12 @@ func TestRunSweepers(t *testing.T) { { Name: "failing top allow failures", Sweepers: map[string]*Sweeper{ - "aws_top": &Sweeper{ + "aws_top": { Name: "aws_top", Dependencies: []string{"aws_sub"}, F: mockFailingSweeperFunc, }, - "aws_sub": &Sweeper{ + "aws_sub": { Name: "aws_sub", F: mockSweeperFunc, }, @@ -797,12 +797,12 @@ func TestRunSweepers(t *testing.T) { { Name: "failing top and dep", Sweepers: map[string]*Sweeper{ - "aws_top": &Sweeper{ + "aws_top": { Name: "aws_top", Dependencies: []string{"aws_sub"}, F: mockFailingSweeperFunc, }, - "aws_sub": &Sweeper{ + "aws_sub": { Name: "aws_sub", F: mockFailingSweeperFunc, }, @@ -813,12 +813,12 @@ func TestRunSweepers(t *testing.T) { { Name: "failing top and dep allow failues", Sweepers: map[string]*Sweeper{ - "aws_top": &Sweeper{ + "aws_top": { Name: "aws_top", Dependencies: []string{"aws_sub"}, F: mockFailingSweeperFunc, }, - "aws_sub": &Sweeper{ + "aws_sub": { Name: "aws_sub", F: mockFailingSweeperFunc, }, @@ -847,7 +847,7 @@ func TestRunSweepers(t *testing.T) { // get list of tests ran from sweeperRunList keys var keys []string - for k, _ := range sweeperRunList["test"] { + for k := range sweeperRunList["test"] { keys = append(keys, k) } @@ -873,7 +873,7 @@ func TestCheckResourceAttr_empty(t *testing.T) { s.AddModuleState(&terraform.ModuleState{ Path: []string{"root"}, Resources: map[string]*terraform.ResourceState{ - "test_resource": &terraform.ResourceState{ + "test_resource": { Primary: &terraform.InstanceState{ Attributes: map[string]string{ "empty_list.#": "0", @@ -904,7 +904,7 @@ func TestCheckNoResourceAttr_empty(t *testing.T) { s.AddModuleState(&terraform.ModuleState{ Path: []string{"root"}, Resources: map[string]*terraform.ResourceState{ - "test_resource": &terraform.ResourceState{ + "test_resource": { Primary: &terraform.InstanceState{ Attributes: map[string]string{ "empty_list.#": "0", diff --git a/helper/schema/core_schema_test.go b/helper/schema/core_schema_test.go index a03f8331ec7..737141bb83b 100644 --- a/helper/schema/core_schema_test.go +++ b/helper/schema/core_schema_test.go @@ -341,7 +341,7 @@ func TestSchemaMapCoreConfigSchema(t *testing.T) { testResource(&configschema.Block{ Attributes: map[string]*configschema.Attribute{}, BlockTypes: map[string]*configschema.NestedBlock{ - "foo": &configschema.NestedBlock{ + "foo": { Nesting: configschema.NestingList, Block: configschema.Block{ Attributes: map[string]*configschema.Attribute{ diff --git a/helper/schema/field_reader.go b/helper/schema/field_reader.go index 2a66a068fb6..622e9b13eb2 100644 --- a/helper/schema/field_reader.go +++ b/helper/schema/field_reader.go @@ -205,7 +205,7 @@ func readListField( // Go through each count, and get the item value out of it result := make([]interface{}, countResult.Value.(int)) - for i, _ := range result { + for i := range result { is := strconv.FormatInt(int64(i), 10) addrPadded[len(addrPadded)-1] = is rawResult, err := r.ReadField(addrPadded) diff --git a/helper/schema/field_reader_config_test.go b/helper/schema/field_reader_config_test.go index e3739187baa..69ef5cde9be 100644 --- a/helper/schema/field_reader_config_test.go +++ b/helper/schema/field_reader_config_test.go @@ -69,7 +69,7 @@ func TestConfigFieldReader(t *testing.T) { // This contains custom table tests for our ConfigFieldReader func TestConfigFieldReader_custom(t *testing.T) { schema := map[string]*Schema{ - "bool": &Schema{ + "bool": { Type: TypeBool, }, } @@ -128,11 +128,11 @@ func TestConfigFieldReader_custom(t *testing.T) { func TestConfigFieldReader_DefaultHandling(t *testing.T) { schema := map[string]*Schema{ - "strWithDefault": &Schema{ + "strWithDefault": { Type: TypeString, Default: "ImADefault", }, - "strWithDefaultFunc": &Schema{ + "strWithDefaultFunc": { Type: TypeString, DefaultFunc: func() (interface{}, error) { return "FuncDefault", nil @@ -213,16 +213,16 @@ func TestConfigFieldReader_DefaultHandling(t *testing.T) { func TestConfigFieldReader_ComputedMap(t *testing.T) { schema := map[string]*Schema{ - "map": &Schema{ + "map": { Type: TypeMap, Computed: true, }, - "listmap": &Schema{ + "listmap": { Type: TypeMap, Computed: true, Elem: TypeList, }, - "maplist": &Schema{ + "maplist": { Type: TypeList, Computed: true, Elem: TypeMap, @@ -390,7 +390,7 @@ func TestConfigFieldReader_ComputedMap(t *testing.T) { func TestConfigFieldReader_ComputedSet(t *testing.T) { schema := map[string]*Schema{ - "strSet": &Schema{ + "strSet": { Type: TypeSet, Elem: &Schema{Type: TypeString}, Set: HashString, @@ -464,7 +464,7 @@ func TestConfigFieldReader_computedComplexSet(t *testing.T) { } schema := map[string]*Schema{ - "set": &Schema{ + "set": { Type: TypeSet, Elem: &Resource{ Schema: map[string]*Schema{ diff --git a/helper/schema/field_reader_diff_test.go b/helper/schema/field_reader_diff_test.go index 2101a7747c7..5af63bb62b1 100644 --- a/helper/schema/field_reader_diff_test.go +++ b/helper/schema/field_reader_diff_test.go @@ -18,15 +18,15 @@ func TestDiffFieldReader_NestedSetUpdate(t *testing.T) { } schema := map[string]*Schema{ - "list_of_sets_1": &Schema{ + "list_of_sets_1": { Type: TypeList, Elem: &Resource{ Schema: map[string]*Schema{ - "nested_set": &Schema{ + "nested_set": { Type: TypeSet, Elem: &Resource{ Schema: map[string]*Schema{ - "val": &Schema{ + "val": { Type: TypeInt, }, }, @@ -36,15 +36,15 @@ func TestDiffFieldReader_NestedSetUpdate(t *testing.T) { }, }, }, - "list_of_sets_2": &Schema{ + "list_of_sets_2": { Type: TypeList, Elem: &Resource{ Schema: map[string]*Schema{ - "nested_set": &Schema{ + "nested_set": { Type: TypeSet, Elem: &Resource{ Schema: map[string]*Schema{ - "val": &Schema{ + "val": { Type: TypeInt, }, }, @@ -60,12 +60,12 @@ func TestDiffFieldReader_NestedSetUpdate(t *testing.T) { Schema: schema, Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "list_of_sets_1.0.nested_set.1.val": &terraform.ResourceAttrDiff{ + "list_of_sets_1.0.nested_set.1.val": { Old: "1", New: "0", NewRemoved: true, }, - "list_of_sets_1.0.nested_set.2.val": &terraform.ResourceAttrDiff{ + "list_of_sets_1.0.nested_set.2.val": { New: "2", }, }, @@ -112,7 +112,7 @@ func TestDiffFieldReader_NestedSetUpdate(t *testing.T) { // https://github.com/hashicorp/terraform-plugin-sdk/issues/914 func TestDiffFieldReader_MapHandling(t *testing.T) { schema := map[string]*Schema{ - "tags": &Schema{ + "tags": { Type: TypeMap, }, } @@ -120,11 +120,11 @@ func TestDiffFieldReader_MapHandling(t *testing.T) { Schema: schema, Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "tags.%": &terraform.ResourceAttrDiff{ + "tags.%": { Old: "1", New: "2", }, - "tags.baz": &terraform.ResourceAttrDiff{ + "tags.baz": { Old: "", New: "qux", }, @@ -156,28 +156,28 @@ func TestDiffFieldReader_MapHandling(t *testing.T) { func TestDiffFieldReader_extra(t *testing.T) { schema := map[string]*Schema{ - "stringComputed": &Schema{Type: TypeString}, + "stringComputed": {Type: TypeString}, - "listMap": &Schema{ + "listMap": { Type: TypeList, Elem: &Schema{ Type: TypeMap, }, }, - "mapRemove": &Schema{Type: TypeMap}, + "mapRemove": {Type: TypeMap}, - "setChange": &Schema{ + "setChange": { Type: TypeSet, Optional: true, Elem: &Resource{ Schema: map[string]*Schema{ - "index": &Schema{ + "index": { Type: TypeInt, Required: true, }, - "value": &Schema{ + "value": { Type: TypeString, Required: true, }, @@ -189,17 +189,17 @@ func TestDiffFieldReader_extra(t *testing.T) { }, }, - "setEmpty": &Schema{ + "setEmpty": { Type: TypeSet, Optional: true, Elem: &Resource{ Schema: map[string]*Schema{ - "index": &Schema{ + "index": { Type: TypeInt, Required: true, }, - "value": &Schema{ + "value": { Type: TypeString, Required: true, }, @@ -216,26 +216,26 @@ func TestDiffFieldReader_extra(t *testing.T) { Schema: schema, Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "stringComputed": &terraform.ResourceAttrDiff{ + "stringComputed": { Old: "foo", New: "bar", NewComputed: true, }, - "listMap.0.bar": &terraform.ResourceAttrDiff{ + "listMap.0.bar": { NewRemoved: true, }, - "mapRemove.bar": &terraform.ResourceAttrDiff{ + "mapRemove.bar": { NewRemoved: true, }, - "setChange.10.value": &terraform.ResourceAttrDiff{ + "setChange.10.value": { Old: "50", New: "80", }, - "setEmpty.#": &terraform.ResourceAttrDiff{ + "setEmpty.#": { Old: "2", New: "0", }, @@ -354,156 +354,156 @@ func TestDiffFieldReader(t *testing.T) { Schema: s, Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "bool": &terraform.ResourceAttrDiff{ + "bool": { Old: "", New: "true", }, - "int": &terraform.ResourceAttrDiff{ + "int": { Old: "", New: "42", }, - "float": &terraform.ResourceAttrDiff{ + "float": { Old: "", New: "3.1415", }, - "string": &terraform.ResourceAttrDiff{ + "string": { Old: "", New: "string", }, - "stringComputed": &terraform.ResourceAttrDiff{ + "stringComputed": { Old: "foo", New: "bar", NewComputed: true, }, - "list.#": &terraform.ResourceAttrDiff{ + "list.#": { Old: "0", New: "2", }, - "list.0": &terraform.ResourceAttrDiff{ + "list.0": { Old: "", New: "foo", }, - "list.1": &terraform.ResourceAttrDiff{ + "list.1": { Old: "", New: "bar", }, - "listInt.#": &terraform.ResourceAttrDiff{ + "listInt.#": { Old: "0", New: "2", }, - "listInt.0": &terraform.ResourceAttrDiff{ + "listInt.0": { Old: "", New: "21", }, - "listInt.1": &terraform.ResourceAttrDiff{ + "listInt.1": { Old: "", New: "42", }, - "map.foo": &terraform.ResourceAttrDiff{ + "map.foo": { Old: "", New: "bar", }, - "map.bar": &terraform.ResourceAttrDiff{ + "map.bar": { Old: "", New: "baz", }, - "mapInt.%": &terraform.ResourceAttrDiff{ + "mapInt.%": { Old: "", New: "2", }, - "mapInt.one": &terraform.ResourceAttrDiff{ + "mapInt.one": { Old: "", New: "1", }, - "mapInt.two": &terraform.ResourceAttrDiff{ + "mapInt.two": { Old: "", New: "2", }, - "mapIntNestedSchema.%": &terraform.ResourceAttrDiff{ + "mapIntNestedSchema.%": { Old: "", New: "2", }, - "mapIntNestedSchema.one": &terraform.ResourceAttrDiff{ + "mapIntNestedSchema.one": { Old: "", New: "1", }, - "mapIntNestedSchema.two": &terraform.ResourceAttrDiff{ + "mapIntNestedSchema.two": { Old: "", New: "2", }, - "mapFloat.%": &terraform.ResourceAttrDiff{ + "mapFloat.%": { Old: "", New: "1", }, - "mapFloat.oneDotTwo": &terraform.ResourceAttrDiff{ + "mapFloat.oneDotTwo": { Old: "", New: "1.2", }, - "mapBool.%": &terraform.ResourceAttrDiff{ + "mapBool.%": { Old: "", New: "2", }, - "mapBool.True": &terraform.ResourceAttrDiff{ + "mapBool.True": { Old: "", New: "true", }, - "mapBool.False": &terraform.ResourceAttrDiff{ + "mapBool.False": { Old: "", New: "false", }, - "set.#": &terraform.ResourceAttrDiff{ + "set.#": { Old: "0", New: "2", }, - "set.10": &terraform.ResourceAttrDiff{ + "set.10": { Old: "", New: "10", }, - "set.50": &terraform.ResourceAttrDiff{ + "set.50": { Old: "", New: "50", }, - "setDeep.#": &terraform.ResourceAttrDiff{ + "setDeep.#": { Old: "0", New: "2", }, - "setDeep.10.index": &terraform.ResourceAttrDiff{ + "setDeep.10.index": { Old: "", New: "10", }, - "setDeep.10.value": &terraform.ResourceAttrDiff{ + "setDeep.10.value": { Old: "", New: "foo", }, - "setDeep.50.index": &terraform.ResourceAttrDiff{ + "setDeep.50.index": { Old: "", New: "50", }, - "setDeep.50.value": &terraform.ResourceAttrDiff{ + "setDeep.50.value": { Old: "", New: "bar", }, diff --git a/helper/schema/field_reader_map_test.go b/helper/schema/field_reader_map_test.go index 2723674a326..a0fff5cb689 100644 --- a/helper/schema/field_reader_map_test.go +++ b/helper/schema/field_reader_map_test.go @@ -64,8 +64,8 @@ func TestMapFieldReader(t *testing.T) { func TestMapFieldReader_extra(t *testing.T) { r := &MapFieldReader{ Schema: map[string]*Schema{ - "mapDel": &Schema{Type: TypeMap}, - "mapEmpty": &Schema{Type: TypeMap}, + "mapDel": {Type: TypeMap}, + "mapEmpty": {Type: TypeMap}, }, Map: BasicMapReader(map[string]string{ diff --git a/helper/schema/field_reader_multi_test.go b/helper/schema/field_reader_multi_test.go index bde5dc1f949..a4239c3affe 100644 --- a/helper/schema/field_reader_multi_test.go +++ b/helper/schema/field_reader_multi_test.go @@ -21,7 +21,7 @@ func TestMultiLevelFieldReaderReadFieldExact(t *testing.T) { Readers: []FieldReader{ &MapFieldReader{ Schema: map[string]*Schema{ - "foo": &Schema{Type: TypeString}, + "foo": {Type: TypeString}, }, Map: BasicMapReader(map[string]string{ "foo": "bar", @@ -29,7 +29,7 @@ func TestMultiLevelFieldReaderReadFieldExact(t *testing.T) { }, &MapFieldReader{ Schema: map[string]*Schema{ - "foo": &Schema{Type: TypeString}, + "foo": {Type: TypeString}, }, Map: BasicMapReader(map[string]string{ "foo": "baz", @@ -37,7 +37,7 @@ func TestMultiLevelFieldReaderReadFieldExact(t *testing.T) { }, &MapFieldReader{ Schema: map[string]*Schema{ - "foo": &Schema{Type: TypeString}, + "foo": {Type: TypeString}, }, Map: BasicMapReader(map[string]string{}), }, @@ -88,12 +88,12 @@ func TestMultiLevelFieldReaderReadFieldMerge(t *testing.T) { Readers: []FieldReader{ &DiffFieldReader{ Schema: map[string]*Schema{ - "availability_zone": &Schema{Type: TypeString}, + "availability_zone": {Type: TypeString}, }, Source: &MapFieldReader{ Schema: map[string]*Schema{ - "availability_zone": &Schema{Type: TypeString}, + "availability_zone": {Type: TypeString}, }, Map: BasicMapReader(map[string]string{ "availability_zone": "foo", @@ -102,7 +102,7 @@ func TestMultiLevelFieldReaderReadFieldMerge(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "availability_zone": &terraform.ResourceAttrDiff{ + "availability_zone": { Old: "foo", New: "bar", RequiresNew: true, @@ -124,7 +124,7 @@ func TestMultiLevelFieldReaderReadFieldMerge(t *testing.T) { Readers: []FieldReader{ &MapFieldReader{ Schema: map[string]*Schema{ - "availability_zone": &Schema{Type: TypeString}, + "availability_zone": {Type: TypeString}, }, Map: BasicMapReader(map[string]string{ @@ -134,12 +134,12 @@ func TestMultiLevelFieldReaderReadFieldMerge(t *testing.T) { &DiffFieldReader{ Schema: map[string]*Schema{ - "availability_zone": &Schema{Type: TypeString}, + "availability_zone": {Type: TypeString}, }, Source: &MapFieldReader{ Schema: map[string]*Schema{ - "availability_zone": &Schema{Type: TypeString}, + "availability_zone": {Type: TypeString}, }, Map: BasicMapReader(map[string]string{ @@ -149,7 +149,7 @@ func TestMultiLevelFieldReaderReadFieldMerge(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "availability_zone": &terraform.ResourceAttrDiff{ + "availability_zone": { Old: "foo", New: "bar", NewComputed: true, @@ -172,7 +172,7 @@ func TestMultiLevelFieldReaderReadFieldMerge(t *testing.T) { Readers: []FieldReader{ &DiffFieldReader{ Schema: map[string]*Schema{ - "config_vars": &Schema{ + "config_vars": { Type: TypeList, Elem: &Schema{Type: TypeMap}, }, @@ -180,7 +180,7 @@ func TestMultiLevelFieldReaderReadFieldMerge(t *testing.T) { Source: &MapFieldReader{ Schema: map[string]*Schema{ - "config_vars": &Schema{ + "config_vars": { Type: TypeList, Elem: &Schema{Type: TypeMap}, }, @@ -196,7 +196,7 @@ func TestMultiLevelFieldReaderReadFieldMerge(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "config_vars.0.bar": &terraform.ResourceAttrDiff{ + "config_vars.0.bar": { NewRemoved: true, }, }, @@ -223,7 +223,7 @@ func TestMultiLevelFieldReaderReadFieldMerge(t *testing.T) { Readers: []FieldReader{ &MapFieldReader{ Schema: map[string]*Schema{ - "foo": &Schema{Type: TypeString}, + "foo": {Type: TypeString}, }, Map: BasicMapReader(map[string]string{ "foo": "bar", @@ -231,7 +231,7 @@ func TestMultiLevelFieldReaderReadFieldMerge(t *testing.T) { }, &MapFieldReader{ Schema: map[string]*Schema{ - "foo": &Schema{Type: TypeString}, + "foo": {Type: TypeString}, }, Map: BasicMapReader(map[string]string{}), }, diff --git a/helper/schema/field_reader_test.go b/helper/schema/field_reader_test.go index 2c62eb0a8a2..cbaf0fd1276 100644 --- a/helper/schema/field_reader_test.go +++ b/helper/schema/field_reader_test.go @@ -14,7 +14,7 @@ func TestAddrToSchema(t *testing.T) { "full object": { []string{}, map[string]*Schema{ - "list": &Schema{ + "list": { Type: TypeList, Elem: &Schema{Type: TypeInt}, }, @@ -25,7 +25,7 @@ func TestAddrToSchema(t *testing.T) { "list": { []string{"list"}, map[string]*Schema{ - "list": &Schema{ + "list": { Type: TypeList, Elem: &Schema{Type: TypeInt}, }, @@ -36,7 +36,7 @@ func TestAddrToSchema(t *testing.T) { "list.#": { []string{"list", "#"}, map[string]*Schema{ - "list": &Schema{ + "list": { Type: TypeList, Elem: &Schema{Type: TypeInt}, }, @@ -47,7 +47,7 @@ func TestAddrToSchema(t *testing.T) { "list.0": { []string{"list", "0"}, map[string]*Schema{ - "list": &Schema{ + "list": { Type: TypeList, Elem: &Schema{Type: TypeInt}, }, @@ -58,11 +58,11 @@ func TestAddrToSchema(t *testing.T) { "list.0 with resource": { []string{"list", "0"}, map[string]*Schema{ - "list": &Schema{ + "list": { Type: TypeList, Elem: &Resource{ Schema: map[string]*Schema{ - "field": &Schema{Type: TypeString}, + "field": {Type: TypeString}, }, }, }, @@ -73,11 +73,11 @@ func TestAddrToSchema(t *testing.T) { "list.0.field": { []string{"list", "0", "field"}, map[string]*Schema{ - "list": &Schema{ + "list": { Type: TypeList, Elem: &Resource{ Schema: map[string]*Schema{ - "field": &Schema{Type: TypeString}, + "field": {Type: TypeString}, }, }, }, @@ -88,7 +88,7 @@ func TestAddrToSchema(t *testing.T) { "set": { []string{"set"}, map[string]*Schema{ - "set": &Schema{ + "set": { Type: TypeSet, Elem: &Schema{Type: TypeInt}, Set: func(a interface{}) int { @@ -102,7 +102,7 @@ func TestAddrToSchema(t *testing.T) { "set.#": { []string{"set", "#"}, map[string]*Schema{ - "set": &Schema{ + "set": { Type: TypeSet, Elem: &Schema{Type: TypeInt}, Set: func(a interface{}) int { @@ -116,7 +116,7 @@ func TestAddrToSchema(t *testing.T) { "set.0": { []string{"set", "0"}, map[string]*Schema{ - "set": &Schema{ + "set": { Type: TypeSet, Elem: &Schema{Type: TypeInt}, Set: func(a interface{}) int { @@ -130,11 +130,11 @@ func TestAddrToSchema(t *testing.T) { "set.0 with resource": { []string{"set", "0"}, map[string]*Schema{ - "set": &Schema{ + "set": { Type: TypeSet, Elem: &Resource{ Schema: map[string]*Schema{ - "field": &Schema{Type: TypeString}, + "field": {Type: TypeString}, }, }, }, @@ -145,7 +145,7 @@ func TestAddrToSchema(t *testing.T) { "mapElem": { []string{"map", "foo"}, map[string]*Schema{ - "map": &Schema{Type: TypeMap}, + "map": {Type: TypeMap}, }, []ValueType{TypeMap, TypeString}, }, @@ -153,12 +153,12 @@ func TestAddrToSchema(t *testing.T) { "setDeep": { []string{"set", "50", "index"}, map[string]*Schema{ - "set": &Schema{ + "set": { Type: TypeSet, Elem: &Resource{ Schema: map[string]*Schema{ - "index": &Schema{Type: TypeInt}, - "value": &Schema{Type: TypeString}, + "index": {Type: TypeInt}, + "value": {Type: TypeString}, }, }, Set: func(a interface{}) int { @@ -188,21 +188,21 @@ func TestAddrToSchema(t *testing.T) { func testFieldReader(t *testing.T, f func(map[string]*Schema) FieldReader) { schema := map[string]*Schema{ // Primitives - "bool": &Schema{Type: TypeBool}, - "float": &Schema{Type: TypeFloat}, - "int": &Schema{Type: TypeInt}, - "string": &Schema{Type: TypeString}, + "bool": {Type: TypeBool}, + "float": {Type: TypeFloat}, + "int": {Type: TypeInt}, + "string": {Type: TypeString}, // Lists - "list": &Schema{ + "list": { Type: TypeList, Elem: &Schema{Type: TypeString}, }, - "listInt": &Schema{ + "listInt": { Type: TypeList, Elem: &Schema{Type: TypeInt}, }, - "listMap": &Schema{ + "listMap": { Type: TypeList, Elem: &Schema{ Type: TypeMap, @@ -210,48 +210,48 @@ func testFieldReader(t *testing.T, f func(map[string]*Schema) FieldReader) { }, // Maps - "map": &Schema{Type: TypeMap}, - "mapInt": &Schema{ + "map": {Type: TypeMap}, + "mapInt": { Type: TypeMap, Elem: TypeInt, }, // This is used to verify that the type of a Map can be specified using the // same syntax as for lists (as a nested *Schema passed to Elem) - "mapIntNestedSchema": &Schema{ + "mapIntNestedSchema": { Type: TypeMap, Elem: &Schema{Type: TypeInt}, }, - "mapFloat": &Schema{ + "mapFloat": { Type: TypeMap, Elem: TypeFloat, }, - "mapBool": &Schema{ + "mapBool": { Type: TypeMap, Elem: TypeBool, }, // Sets - "set": &Schema{ + "set": { Type: TypeSet, Elem: &Schema{Type: TypeInt}, Set: func(a interface{}) int { return a.(int) }, }, - "setDeep": &Schema{ + "setDeep": { Type: TypeSet, Elem: &Resource{ Schema: map[string]*Schema{ - "index": &Schema{Type: TypeInt}, - "value": &Schema{Type: TypeString}, + "index": {Type: TypeInt}, + "value": {Type: TypeString}, }, }, Set: func(a interface{}) int { return a.(map[string]interface{})["index"].(int) }, }, - "setEmpty": &Schema{ + "setEmpty": { Type: TypeSet, Elem: &Schema{Type: TypeInt}, Set: func(a interface{}) int { diff --git a/helper/schema/field_writer_map.go b/helper/schema/field_writer_map.go index c09358b1bb4..85d05be4c3b 100644 --- a/helper/schema/field_writer_map.go +++ b/helper/schema/field_writer_map.go @@ -146,7 +146,7 @@ func (w *MapFieldWriter) setList( } } if err != nil { - for i, _ := range vs { + for i := range vs { is := strconv.FormatInt(int64(i), 10) setElement(is, nil) } @@ -227,7 +227,7 @@ func (w *MapFieldWriter) setObject( } } if err != nil { - for k1, _ := range v { + for k1 := range v { w.set(append(addrCopy, k1), nil) } } diff --git a/helper/schema/field_writer_map_test.go b/helper/schema/field_writer_map_test.go index d1a7932aadc..4480b41fc1b 100644 --- a/helper/schema/field_writer_map_test.go +++ b/helper/schema/field_writer_map_test.go @@ -11,44 +11,44 @@ func TestMapFieldWriter_impl(t *testing.T) { func TestMapFieldWriter(t *testing.T) { schema := map[string]*Schema{ - "bool": &Schema{Type: TypeBool}, - "int": &Schema{Type: TypeInt}, - "string": &Schema{Type: TypeString}, - "list": &Schema{ + "bool": {Type: TypeBool}, + "int": {Type: TypeInt}, + "string": {Type: TypeString}, + "list": { Type: TypeList, Elem: &Schema{Type: TypeString}, }, - "listInt": &Schema{ + "listInt": { Type: TypeList, Elem: &Schema{Type: TypeInt}, }, - "listResource": &Schema{ + "listResource": { Type: TypeList, Optional: true, Computed: true, Elem: &Resource{ Schema: map[string]*Schema{ - "value": &Schema{ + "value": { Type: TypeInt, Optional: true, }, }, }, }, - "map": &Schema{Type: TypeMap}, - "set": &Schema{ + "map": {Type: TypeMap}, + "set": { Type: TypeSet, Elem: &Schema{Type: TypeInt}, Set: func(a interface{}) int { return a.(int) }, }, - "setDeep": &Schema{ + "setDeep": { Type: TypeSet, Elem: &Resource{ Schema: map[string]*Schema{ - "index": &Schema{Type: TypeInt}, - "value": &Schema{Type: TypeString}, + "index": {Type: TypeInt}, + "value": {Type: TypeString}, }, }, Set: func(a interface{}) int { @@ -273,12 +273,12 @@ func TestMapFieldWriter(t *testing.T) { func TestMapFieldWriterCleanSet(t *testing.T) { schema := map[string]*Schema{ - "setDeep": &Schema{ + "setDeep": { Type: TypeSet, Elem: &Resource{ Schema: map[string]*Schema{ - "index": &Schema{Type: TypeInt}, - "value": &Schema{Type: TypeString}, + "index": {Type: TypeInt}, + "value": {Type: TypeString}, }, }, Set: func(a interface{}) int { @@ -371,12 +371,12 @@ func TestMapFieldWriterCleanSet(t *testing.T) { func TestMapFieldWriterCleanList(t *testing.T) { schema := map[string]*Schema{ - "listDeep": &Schema{ + "listDeep": { Type: TypeList, Elem: &Resource{ Schema: map[string]*Schema{ - "thing1": &Schema{Type: TypeString}, - "thing2": &Schema{Type: TypeString}, + "thing1": {Type: TypeString}, + "thing2": {Type: TypeString}, }, }, }, @@ -490,7 +490,7 @@ func TestMapFieldWriterCleanList(t *testing.T) { func TestMapFieldWriterCleanMap(t *testing.T) { schema := map[string]*Schema{ - "map": &Schema{ + "map": { Type: TypeMap, }, } diff --git a/helper/schema/provider.go b/helper/schema/provider.go index b58c103b124..ee0da4b04c3 100644 --- a/helper/schema/provider.go +++ b/helper/schema/provider.go @@ -96,7 +96,7 @@ func (p *Provider) InternalValidate() error { } // Provider-specific checks - for k, _ := range sm { + for k := range sm { if isReservedProviderFieldName(k) { return fmt.Errorf("%s is a reserved field name for a provider", k) } @@ -375,7 +375,7 @@ func (p *Provider) ValidateDataSource( // provider implements. func (p *Provider) DataSources() []terraform.DataSource { keys := make([]string, 0, len(p.DataSourcesMap)) - for k, _ := range p.DataSourcesMap { + for k := range p.DataSourcesMap { keys = append(keys, k) } sort.Strings(keys) diff --git a/helper/schema/provider_test.go b/helper/schema/provider_test.go index b732836144f..e09c6cbae09 100644 --- a/helper/schema/provider_test.go +++ b/helper/schema/provider_test.go @@ -26,7 +26,7 @@ func TestProviderGetSchema(t *testing.T) { }, }, ResourcesMap: map[string]*Resource{ - "foo": &Resource{ + "foo": { Schema: map[string]*Schema{ "bar": { Type: TypeString, @@ -36,7 +36,7 @@ func TestProviderGetSchema(t *testing.T) { }, }, DataSourcesMap: map[string]*Resource{ - "baz": &Resource{ + "baz": { Schema: map[string]*Schema{ "bur": { Type: TypeString, @@ -50,7 +50,7 @@ func TestProviderGetSchema(t *testing.T) { want := &terraform.ProviderSchema{ Provider: &configschema.Block{ Attributes: map[string]*configschema.Attribute{ - "bar": &configschema.Attribute{ + "bar": { Type: cty.String, Required: true, }, @@ -60,7 +60,7 @@ func TestProviderGetSchema(t *testing.T) { ResourceTypes: map[string]*configschema.Block{ "foo": testResource(&configschema.Block{ Attributes: map[string]*configschema.Attribute{ - "bar": &configschema.Attribute{ + "bar": { Type: cty.String, Required: true, }, @@ -71,7 +71,7 @@ func TestProviderGetSchema(t *testing.T) { DataSources: map[string]*configschema.Block{ "baz": testResource(&configschema.Block{ Attributes: map[string]*configschema.Attribute{ - "bur": &configschema.Attribute{ + "bur": { Type: cty.String, Required: true, }, @@ -108,7 +108,7 @@ func TestProviderConfigure(t *testing.T) { { P: &Provider{ Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeInt, Optional: true, }, @@ -131,7 +131,7 @@ func TestProviderConfigure(t *testing.T) { { P: &Provider{ Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeInt, Optional: true, }, @@ -154,7 +154,7 @@ func TestProviderConfigure(t *testing.T) { { P: &Provider{ Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeInt, Optional: true, }, @@ -202,8 +202,8 @@ func TestProviderResources(t *testing.T) { }, }, Result: []terraform.ResourceType{ - terraform.ResourceType{Name: "bar", SchemaAvailable: true}, - terraform.ResourceType{Name: "foo", SchemaAvailable: true}, + {Name: "bar", SchemaAvailable: true}, + {Name: "foo", SchemaAvailable: true}, }, }, @@ -211,14 +211,14 @@ func TestProviderResources(t *testing.T) { P: &Provider{ ResourcesMap: map[string]*Resource{ "foo": nil, - "bar": &Resource{Importer: &ResourceImporter{}}, + "bar": {Importer: &ResourceImporter{}}, "baz": nil, }, }, Result: []terraform.ResourceType{ - terraform.ResourceType{Name: "bar", Importable: true, SchemaAvailable: true}, - terraform.ResourceType{Name: "baz", SchemaAvailable: true}, - terraform.ResourceType{Name: "foo", SchemaAvailable: true}, + {Name: "bar", Importable: true, SchemaAvailable: true}, + {Name: "baz", SchemaAvailable: true}, + {Name: "foo", SchemaAvailable: true}, }, }, } @@ -249,8 +249,8 @@ func TestProviderDataSources(t *testing.T) { }, }, Result: []terraform.DataSource{ - terraform.DataSource{Name: "bar", SchemaAvailable: true}, - terraform.DataSource{Name: "foo", SchemaAvailable: true}, + {Name: "bar", SchemaAvailable: true}, + {Name: "foo", SchemaAvailable: true}, }, }, } @@ -272,7 +272,7 @@ func TestProviderValidate(t *testing.T) { { P: &Provider{ Schema: map[string]*Schema{ - "foo": &Schema{}, + "foo": {}, }, }, Config: nil, @@ -292,7 +292,7 @@ func TestProviderValidate(t *testing.T) { func TestProviderDiff_legacyTimeoutType(t *testing.T) { p := &Provider{ ResourcesMap: map[string]*Resource{ - "blah": &Resource{ + "blah": { Schema: map[string]*Schema{ "foo": { Type: TypeInt, @@ -329,7 +329,7 @@ func TestProviderDiff_legacyTimeoutType(t *testing.T) { func TestProviderDiff_timeoutInvalidValue(t *testing.T) { p := &Provider{ ResourcesMap: map[string]*Resource{ - "blah": &Resource{ + "blah": { Schema: map[string]*Schema{ "foo": { Type: TypeInt, @@ -384,7 +384,7 @@ func TestProviderValidateResource(t *testing.T) { { P: &Provider{ ResourcesMap: map[string]*Resource{ - "foo": &Resource{}, + "foo": {}, }, }, Type: "foo", @@ -405,7 +405,7 @@ func TestProviderValidateResource(t *testing.T) { func TestProviderImportState_default(t *testing.T) { p := &Provider{ ResourcesMap: map[string]*Resource{ - "foo": &Resource{ + "foo": { Importer: &ResourceImporter{}, }, }, @@ -435,7 +435,7 @@ func TestProviderImportState_setsId(t *testing.T) { p := &Provider{ ResourcesMap: map[string]*Resource{ - "foo": &Resource{ + "foo": { Importer: &ResourceImporter{ State: stateFunc, }, @@ -465,7 +465,7 @@ func TestProviderImportState_setsType(t *testing.T) { p := &Provider{ ResourcesMap: map[string]*Resource{ - "foo": &Resource{ + "foo": { Importer: &ResourceImporter{ State: stateFunc, }, diff --git a/helper/schema/resource.go b/helper/schema/resource.go index c502a8b6a53..20391f9e247 100644 --- a/helper/schema/resource.go +++ b/helper/schema/resource.go @@ -787,7 +787,7 @@ func (r *Resource) InternalValidate(topSchemaMap schemaMap, writable bool) error // Data source if r.isTopLevel() && !writable { tsm = schemaMap(r.Schema) - for k, _ := range tsm { + for k := range tsm { if isReservedDataSourceFieldName(k) { return fmt.Errorf("%s is a reserved field name", k) } diff --git a/helper/schema/resource_data.go b/helper/schema/resource_data.go index 7b706064b6f..e830160591c 100644 --- a/helper/schema/resource_data.go +++ b/helper/schema/resource_data.go @@ -272,7 +272,7 @@ func (d *ResourceData) State() *terraform.InstanceState { // integrity check of fields existing in the schema, allowing dynamic // keys to be created. hasDynamicAttributes := false - for k, _ := range d.schema { + for k := range d.schema { if k == "__has_dynamic_attributes" { hasDynamicAttributes = true log.Printf("[INFO] Resource %s has dynamic attributes", result.ID) diff --git a/helper/schema/resource_data_test.go b/helper/schema/resource_data_test.go index 5908bfe1b00..dae276b823a 100644 --- a/helper/schema/resource_data_test.go +++ b/helper/schema/resource_data_test.go @@ -22,7 +22,7 @@ func TestResourceDataGet(t *testing.T) { // #0 { Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Optional: true, Computed: true, @@ -34,7 +34,7 @@ func TestResourceDataGet(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "availability_zone": &terraform.ResourceAttrDiff{ + "availability_zone": { Old: "foo", New: "bar", NewComputed: true, @@ -49,7 +49,7 @@ func TestResourceDataGet(t *testing.T) { // #1 { Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Optional: true, Computed: true, @@ -61,7 +61,7 @@ func TestResourceDataGet(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "availability_zone": &terraform.ResourceAttrDiff{ + "availability_zone": { Old: "", New: "foo", RequiresNew: true, @@ -77,7 +77,7 @@ func TestResourceDataGet(t *testing.T) { // #2 { Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Optional: true, Computed: true, @@ -89,7 +89,7 @@ func TestResourceDataGet(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "availability_zone": &terraform.ResourceAttrDiff{ + "availability_zone": { Old: "", New: "foo!", NewExtra: "foo", @@ -104,7 +104,7 @@ func TestResourceDataGet(t *testing.T) { // #3 { Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Optional: true, Computed: true, @@ -128,7 +128,7 @@ func TestResourceDataGet(t *testing.T) { // #4 { Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Optional: true, Computed: true, @@ -144,7 +144,7 @@ func TestResourceDataGet(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "availability_zone": &terraform.ResourceAttrDiff{ + "availability_zone": { Old: "foo", New: "bar", NewComputed: true, @@ -159,7 +159,7 @@ func TestResourceDataGet(t *testing.T) { // #5 { Schema: map[string]*Schema{ - "port": &Schema{ + "port": { Type: TypeInt, Optional: true, Computed: true, @@ -183,7 +183,7 @@ func TestResourceDataGet(t *testing.T) { // #6 { Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeList, Required: true, Elem: &Schema{Type: TypeInt}, @@ -207,7 +207,7 @@ func TestResourceDataGet(t *testing.T) { // #7 { Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeList, Required: true, Elem: &Schema{Type: TypeInt}, @@ -231,7 +231,7 @@ func TestResourceDataGet(t *testing.T) { // #8 { Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeList, Required: true, Elem: &Schema{Type: TypeInt}, @@ -248,7 +248,7 @@ func TestResourceDataGet(t *testing.T) { // #9 { Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeList, Required: true, Elem: &Schema{Type: TypeInt}, @@ -272,12 +272,12 @@ func TestResourceDataGet(t *testing.T) { // #10 { Schema: map[string]*Schema{ - "ingress": &Schema{ + "ingress": { Type: TypeList, Required: true, Elem: &Resource{ Schema: map[string]*Schema{ - "from": &Schema{ + "from": { Type: TypeInt, Required: true, }, @@ -290,11 +290,11 @@ func TestResourceDataGet(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "ingress.#": &terraform.ResourceAttrDiff{ + "ingress.#": { Old: "", New: "1", }, - "ingress.0.from": &terraform.ResourceAttrDiff{ + "ingress.0.from": { Old: "", New: "8080", }, @@ -311,12 +311,12 @@ func TestResourceDataGet(t *testing.T) { // #11 { Schema: map[string]*Schema{ - "ingress": &Schema{ + "ingress": { Type: TypeList, Required: true, Elem: &Resource{ Schema: map[string]*Schema{ - "from": &Schema{ + "from": { Type: TypeInt, Required: true, }, @@ -329,11 +329,11 @@ func TestResourceDataGet(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "ingress.#": &terraform.ResourceAttrDiff{ + "ingress.#": { Old: "", New: "1", }, - "ingress.0.from": &terraform.ResourceAttrDiff{ + "ingress.0.from": { Old: "", New: "8080", }, @@ -352,7 +352,7 @@ func TestResourceDataGet(t *testing.T) { // #12 Computed get { Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Computed: true, }, @@ -372,7 +372,7 @@ func TestResourceDataGet(t *testing.T) { // #13 Full object { Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Optional: true, Computed: true, @@ -384,7 +384,7 @@ func TestResourceDataGet(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "availability_zone": &terraform.ResourceAttrDiff{ + "availability_zone": { Old: "", New: "foo", RequiresNew: true, @@ -402,7 +402,7 @@ func TestResourceDataGet(t *testing.T) { // #14 List of maps { Schema: map[string]*Schema{ - "config_vars": &Schema{ + "config_vars": { Type: TypeList, Optional: true, Computed: true, @@ -416,15 +416,15 @@ func TestResourceDataGet(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "config_vars.#": &terraform.ResourceAttrDiff{ + "config_vars.#": { Old: "0", New: "2", }, - "config_vars.0.foo": &terraform.ResourceAttrDiff{ + "config_vars.0.foo": { Old: "", New: "bar", }, - "config_vars.1.bar": &terraform.ResourceAttrDiff{ + "config_vars.1.bar": { Old: "", New: "baz", }, @@ -446,7 +446,7 @@ func TestResourceDataGet(t *testing.T) { // #15 List of maps in state { Schema: map[string]*Schema{ - "config_vars": &Schema{ + "config_vars": { Type: TypeList, Optional: true, Computed: true, @@ -481,7 +481,7 @@ func TestResourceDataGet(t *testing.T) { // #16 List of maps with removal in diff { Schema: map[string]*Schema{ - "config_vars": &Schema{ + "config_vars": { Type: TypeList, Optional: true, Computed: true, @@ -500,11 +500,11 @@ func TestResourceDataGet(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "config_vars.#": &terraform.ResourceAttrDiff{ + "config_vars.#": { Old: "1", New: "0", }, - "config_vars.0.FOO": &terraform.ResourceAttrDiff{ + "config_vars.0.FOO": { Old: "bar", NewRemoved: true, }, @@ -519,7 +519,7 @@ func TestResourceDataGet(t *testing.T) { // #17 Sets { Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeSet, Optional: true, Computed: true, @@ -547,17 +547,17 @@ func TestResourceDataGet(t *testing.T) { // #18 { Schema: map[string]*Schema{ - "data": &Schema{ + "data": { Type: TypeSet, Optional: true, Elem: &Resource{ Schema: map[string]*Schema{ - "index": &Schema{ + "index": { Type: TypeInt, Required: true, }, - "value": &Schema{ + "value": { Type: TypeString, Required: true, }, @@ -580,7 +580,7 @@ func TestResourceDataGet(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "data.10.value": &terraform.ResourceAttrDiff{ + "data.10.value": { Old: "50", New: "80", }, @@ -600,7 +600,7 @@ func TestResourceDataGet(t *testing.T) { // #19 Empty Set { Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeSet, Optional: true, Computed: true, @@ -623,7 +623,7 @@ func TestResourceDataGet(t *testing.T) { // #20 Float zero { Schema: map[string]*Schema{ - "ratio": &Schema{ + "ratio": { Type: TypeFloat, Optional: true, Computed: true, @@ -642,7 +642,7 @@ func TestResourceDataGet(t *testing.T) { // #21 Float given { Schema: map[string]*Schema{ - "ratio": &Schema{ + "ratio": { Type: TypeFloat, Optional: true, Computed: true, @@ -665,7 +665,7 @@ func TestResourceDataGet(t *testing.T) { // #22 Float diff { Schema: map[string]*Schema{ - "ratio": &Schema{ + "ratio": { Type: TypeFloat, Optional: true, Computed: true, @@ -680,7 +680,7 @@ func TestResourceDataGet(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "ratio": &terraform.ResourceAttrDiff{ + "ratio": { Old: "-0.5", New: "33.0", }, @@ -695,7 +695,7 @@ func TestResourceDataGet(t *testing.T) { // #23 Sets with removed elements { Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeSet, Optional: true, Computed: true, @@ -715,15 +715,15 @@ func TestResourceDataGet(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "ports.#": &terraform.ResourceAttrDiff{ + "ports.#": { Old: "2", New: "1", }, - "ports.80": &terraform.ResourceAttrDiff{ + "ports.80": { Old: "80", New: "80", }, - "ports.8080": &terraform.ResourceAttrDiff{ + "ports.8080": { Old: "8080", New: "0", NewRemoved: true, @@ -765,7 +765,7 @@ func TestResourceDataGetChange(t *testing.T) { }{ { Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Optional: true, Computed: true, @@ -777,7 +777,7 @@ func TestResourceDataGetChange(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "availability_zone": &terraform.ResourceAttrDiff{ + "availability_zone": { Old: "", New: "foo", RequiresNew: true, @@ -793,7 +793,7 @@ func TestResourceDataGetChange(t *testing.T) { { Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Optional: true, Computed: true, @@ -809,7 +809,7 @@ func TestResourceDataGetChange(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "availability_zone": &terraform.ResourceAttrDiff{ + "availability_zone": { Old: "", New: "foo", RequiresNew: true, @@ -854,7 +854,7 @@ func TestResourceDataGetOk(t *testing.T) { */ { Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Optional: true, Computed: true, @@ -866,7 +866,7 @@ func TestResourceDataGetOk(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "availability_zone": &terraform.ResourceAttrDiff{ + "availability_zone": { Old: "", New: "", }, @@ -880,7 +880,7 @@ func TestResourceDataGetOk(t *testing.T) { { Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Optional: true, Computed: true, @@ -892,7 +892,7 @@ func TestResourceDataGetOk(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "availability_zone": &terraform.ResourceAttrDiff{ + "availability_zone": { Old: "", New: "", NewComputed: true, @@ -907,7 +907,7 @@ func TestResourceDataGetOk(t *testing.T) { { Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Optional: true, Computed: true, @@ -930,7 +930,7 @@ func TestResourceDataGetOk(t *testing.T) { { Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeList, Optional: true, Elem: &Schema{Type: TypeInt}, @@ -952,7 +952,7 @@ func TestResourceDataGetOk(t *testing.T) { { Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeMap, Optional: true, }, @@ -973,7 +973,7 @@ func TestResourceDataGetOk(t *testing.T) { { Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeSet, Optional: true, Elem: &Schema{Type: TypeInt}, @@ -992,7 +992,7 @@ func TestResourceDataGetOk(t *testing.T) { { Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeSet, Optional: true, Elem: &Schema{Type: TypeInt}, @@ -1011,7 +1011,7 @@ func TestResourceDataGetOk(t *testing.T) { { Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeSet, Optional: true, Elem: &Schema{Type: TypeInt}, @@ -1023,7 +1023,7 @@ func TestResourceDataGetOk(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "ports.#": &terraform.ResourceAttrDiff{ + "ports.#": { Old: "0", New: "0", }, @@ -1040,7 +1040,7 @@ func TestResourceDataGetOk(t *testing.T) { // indistinguishable from unset config. { Schema: map[string]*Schema{ - "from_port": &Schema{ + "from_port": { Type: TypeInt, Optional: true, }, @@ -1050,7 +1050,7 @@ func TestResourceDataGetOk(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "from_port": &terraform.ResourceAttrDiff{ + "from_port": { Old: "", New: "0", }, @@ -1437,10 +1437,10 @@ func TestResourceDataHasChanges(t *testing.T) { // neither has change { Schema: map[string]*Schema{ - "a": &Schema{ + "a": { Type: TypeString, }, - "b": &Schema{ + "b": { Type: TypeString, }, }, @@ -1454,11 +1454,11 @@ func TestResourceDataHasChanges(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "a": &terraform.ResourceAttrDiff{ + "a": { Old: "", New: "foo", }, - "b": &terraform.ResourceAttrDiff{ + "b": { Old: "", New: "foo", }, @@ -1472,10 +1472,10 @@ func TestResourceDataHasChanges(t *testing.T) { // one key has change { Schema: map[string]*Schema{ - "a": &Schema{ + "a": { Type: TypeString, }, - "b": &Schema{ + "b": { Type: TypeString, }, }, @@ -1489,11 +1489,11 @@ func TestResourceDataHasChanges(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "a": &terraform.ResourceAttrDiff{ + "a": { Old: "", New: "bar", }, - "b": &terraform.ResourceAttrDiff{ + "b": { Old: "", New: "foo", }, @@ -1529,7 +1529,7 @@ func TestResourceDataHasChange(t *testing.T) { }{ { Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Optional: true, Computed: true, @@ -1541,7 +1541,7 @@ func TestResourceDataHasChange(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "availability_zone": &terraform.ResourceAttrDiff{ + "availability_zone": { Old: "", New: "foo", RequiresNew: true, @@ -1556,7 +1556,7 @@ func TestResourceDataHasChange(t *testing.T) { { Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Optional: true, Computed: true, @@ -1572,7 +1572,7 @@ func TestResourceDataHasChange(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "availability_zone": &terraform.ResourceAttrDiff{ + "availability_zone": { Old: "", New: "foo", RequiresNew: true, @@ -1587,7 +1587,7 @@ func TestResourceDataHasChange(t *testing.T) { { Schema: map[string]*Schema{ - "tags": &Schema{ + "tags": { Type: TypeMap, Optional: true, Computed: true, @@ -1598,7 +1598,7 @@ func TestResourceDataHasChange(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "tags.Name": &terraform.ResourceAttrDiff{ + "tags.Name": { Old: "foo", New: "foo", }, @@ -1612,7 +1612,7 @@ func TestResourceDataHasChange(t *testing.T) { { Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeSet, Optional: true, Elem: &Schema{Type: TypeInt}, @@ -1629,7 +1629,7 @@ func TestResourceDataHasChange(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "ports.#": &terraform.ResourceAttrDiff{ + "ports.#": { Old: "1", New: "0", }, @@ -1644,7 +1644,7 @@ func TestResourceDataHasChange(t *testing.T) { // https://github.com/hashicorp/terraform/issues/927 { Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeSet, Optional: true, Elem: &Schema{Type: TypeInt}, @@ -1661,7 +1661,7 @@ func TestResourceDataHasChange(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "tags.foo": &terraform.ResourceAttrDiff{ + "tags.foo": { Old: "", New: "bar", }, @@ -1707,7 +1707,7 @@ func TestResourceDataSet(t *testing.T) { // #0: Basic good { Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Optional: true, Computed: true, @@ -1729,7 +1729,7 @@ func TestResourceDataSet(t *testing.T) { // #1: Basic int { Schema: map[string]*Schema{ - "port": &Schema{ + "port": { Type: TypeInt, Optional: true, Computed: true, @@ -1751,7 +1751,7 @@ func TestResourceDataSet(t *testing.T) { // #2: Basic bool { Schema: map[string]*Schema{ - "vpc": &Schema{ + "vpc": { Type: TypeBool, Optional: true, }, @@ -1771,7 +1771,7 @@ func TestResourceDataSet(t *testing.T) { // #3 { Schema: map[string]*Schema{ - "vpc": &Schema{ + "vpc": { Type: TypeBool, Optional: true, }, @@ -1791,7 +1791,7 @@ func TestResourceDataSet(t *testing.T) { // #4: Invalid type { Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Optional: true, Computed: true, @@ -1814,7 +1814,7 @@ func TestResourceDataSet(t *testing.T) { // #5: List of primitives, set list { Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeList, Computed: true, Elem: &Schema{Type: TypeInt}, @@ -1835,7 +1835,7 @@ func TestResourceDataSet(t *testing.T) { // #6: List of primitives, set list with error { Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeList, Computed: true, Elem: &Schema{Type: TypeInt}, @@ -1857,7 +1857,7 @@ func TestResourceDataSet(t *testing.T) { // #7: Set a list of maps { Schema: map[string]*Schema{ - "config_vars": &Schema{ + "config_vars": { Type: TypeList, Optional: true, Computed: true, @@ -1896,7 +1896,7 @@ func TestResourceDataSet(t *testing.T) { // #8: Set, with list { Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeSet, Optional: true, Computed: true, @@ -1926,7 +1926,7 @@ func TestResourceDataSet(t *testing.T) { // #9: Set, with Set { Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeSet, Optional: true, Computed: true, @@ -1961,7 +1961,7 @@ func TestResourceDataSet(t *testing.T) { // #10: Set single item { Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeSet, Optional: true, Computed: true, @@ -1991,15 +1991,15 @@ func TestResourceDataSet(t *testing.T) { // #11: Set with nested set { Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeSet, Elem: &Resource{ Schema: map[string]*Schema{ - "port": &Schema{ + "port": { Type: TypeInt, }, - "set": &Schema{ + "set": { Type: TypeSet, Elem: &Schema{Type: TypeInt}, Set: func(a interface{}) int { @@ -2059,7 +2059,7 @@ func TestResourceDataSet(t *testing.T) { // #12: List of floats, set list { Schema: map[string]*Schema{ - "ratios": &Schema{ + "ratios": { Type: TypeList, Computed: true, Elem: &Schema{Type: TypeFloat}, @@ -2080,7 +2080,7 @@ func TestResourceDataSet(t *testing.T) { // #12: Set of floats, set list { Schema: map[string]*Schema{ - "ratios": &Schema{ + "ratios": { Type: TypeSet, Computed: true, Elem: &Schema{Type: TypeFloat}, @@ -2104,7 +2104,7 @@ func TestResourceDataSet(t *testing.T) { // #13: Basic pointer { Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Optional: true, Computed: true, @@ -2126,7 +2126,7 @@ func TestResourceDataSet(t *testing.T) { // #14: Basic nil value { Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Optional: true, Computed: true, @@ -2148,7 +2148,7 @@ func TestResourceDataSet(t *testing.T) { // #15: Basic nil pointer { Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Optional: true, Computed: true, @@ -2170,11 +2170,11 @@ func TestResourceDataSet(t *testing.T) { // #16: Set in a list { Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeList, Elem: &Resource{ Schema: map[string]*Schema{ - "set": &Schema{ + "set": { Type: TypeSet, Elem: &Schema{Type: TypeInt}, Set: func(a interface{}) int { @@ -2272,7 +2272,7 @@ func TestResourceDataState_schema(t *testing.T) { // #0 Basic primitive in diff { Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Optional: true, Computed: true, @@ -2284,7 +2284,7 @@ func TestResourceDataState_schema(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "availability_zone": &terraform.ResourceAttrDiff{ + "availability_zone": { Old: "", New: "foo", RequiresNew: true, @@ -2302,7 +2302,7 @@ func TestResourceDataState_schema(t *testing.T) { // #1 Basic primitive set override { Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Optional: true, Computed: true, @@ -2314,7 +2314,7 @@ func TestResourceDataState_schema(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "availability_zone": &terraform.ResourceAttrDiff{ + "availability_zone": { Old: "", New: "foo", RequiresNew: true, @@ -2336,7 +2336,7 @@ func TestResourceDataState_schema(t *testing.T) { // #2 { Schema: map[string]*Schema{ - "vpc": &Schema{ + "vpc": { Type: TypeBool, Optional: true, }, @@ -2360,7 +2360,7 @@ func TestResourceDataState_schema(t *testing.T) { // #3 Basic primitive with StateFunc set { Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Optional: true, Computed: true, @@ -2372,7 +2372,7 @@ func TestResourceDataState_schema(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "availability_zone": &terraform.ResourceAttrDiff{ + "availability_zone": { Old: "", New: "foo", NewExtra: "foo!", @@ -2390,7 +2390,7 @@ func TestResourceDataState_schema(t *testing.T) { // #4 List { Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeList, Required: true, Elem: &Schema{Type: TypeInt}, @@ -2406,11 +2406,11 @@ func TestResourceDataState_schema(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "ports.#": &terraform.ResourceAttrDiff{ + "ports.#": { Old: "1", New: "2", }, - "ports.1": &terraform.ResourceAttrDiff{ + "ports.1": { Old: "", New: "100", }, @@ -2429,12 +2429,12 @@ func TestResourceDataState_schema(t *testing.T) { // #5 List of resources { Schema: map[string]*Schema{ - "ingress": &Schema{ + "ingress": { Type: TypeList, Required: true, Elem: &Resource{ Schema: map[string]*Schema{ - "from": &Schema{ + "from": { Type: TypeInt, Required: true, }, @@ -2452,15 +2452,15 @@ func TestResourceDataState_schema(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "ingress.#": &terraform.ResourceAttrDiff{ + "ingress.#": { Old: "1", New: "2", }, - "ingress.0.from": &terraform.ResourceAttrDiff{ + "ingress.0.from": { Old: "80", New: "150", }, - "ingress.1.from": &terraform.ResourceAttrDiff{ + "ingress.1.from": { Old: "", New: "100", }, @@ -2479,7 +2479,7 @@ func TestResourceDataState_schema(t *testing.T) { // #6 List of maps { Schema: map[string]*Schema{ - "config_vars": &Schema{ + "config_vars": { Type: TypeList, Optional: true, Computed: true, @@ -2502,7 +2502,7 @@ func TestResourceDataState_schema(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "config_vars.0.bar": &terraform.ResourceAttrDiff{ + "config_vars.0.bar": { NewRemoved: true, }, }, @@ -2510,10 +2510,10 @@ func TestResourceDataState_schema(t *testing.T) { Set: map[string]interface{}{ "config_vars": []map[string]interface{}{ - map[string]interface{}{ + { "foo": "bar", }, - map[string]interface{}{ + { "baz": "bang", }, }, @@ -2533,7 +2533,7 @@ func TestResourceDataState_schema(t *testing.T) { // #7 List of maps with removal in diff { Schema: map[string]*Schema{ - "config_vars": &Schema{ + "config_vars": { Type: TypeList, Optional: true, Computed: true, @@ -2552,11 +2552,11 @@ func TestResourceDataState_schema(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "config_vars.#": &terraform.ResourceAttrDiff{ + "config_vars.#": { Old: "1", New: "0", }, - "config_vars.0.FOO": &terraform.ResourceAttrDiff{ + "config_vars.0.FOO": { Old: "bar", NewRemoved: true, }, @@ -2573,7 +2573,7 @@ func TestResourceDataState_schema(t *testing.T) { // #8 Basic state with other keys { Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Optional: true, Computed: true, @@ -2590,7 +2590,7 @@ func TestResourceDataState_schema(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "availability_zone": &terraform.ResourceAttrDiff{ + "availability_zone": { Old: "", New: "foo", RequiresNew: true, @@ -2610,7 +2610,7 @@ func TestResourceDataState_schema(t *testing.T) { // #9 Sets { Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeSet, Optional: true, Computed: true, @@ -2645,7 +2645,7 @@ func TestResourceDataState_schema(t *testing.T) { // #10 { Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeSet, Optional: true, Computed: true, @@ -2676,22 +2676,22 @@ func TestResourceDataState_schema(t *testing.T) { // #11 { Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeSet, Optional: true, Computed: true, Elem: &Resource{ Schema: map[string]*Schema{ - "order": &Schema{ + "order": { Type: TypeInt, }, - "a": &Schema{ + "a": { Type: TypeList, Elem: &Schema{Type: TypeInt}, }, - "b": &Schema{ + "b": { Type: TypeList, Elem: &Schema{Type: TypeInt}, }, @@ -2747,7 +2747,7 @@ func TestResourceDataState_schema(t *testing.T) { // #12 Maps { Schema: map[string]*Schema{ - "tags": &Schema{ + "tags": { Type: TypeMap, Optional: true, Computed: true, @@ -2758,7 +2758,7 @@ func TestResourceDataState_schema(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "tags.Name": &terraform.ResourceAttrDiff{ + "tags.Name": { Old: "", New: "foo", }, @@ -2776,7 +2776,7 @@ func TestResourceDataState_schema(t *testing.T) { // #13 empty computed map { Schema: map[string]*Schema{ - "tags": &Schema{ + "tags": { Type: TypeMap, Optional: true, Computed: true, @@ -2787,7 +2787,7 @@ func TestResourceDataState_schema(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "tags.Name": &terraform.ResourceAttrDiff{ + "tags.Name": { Old: "", New: "foo", }, @@ -2808,7 +2808,7 @@ func TestResourceDataState_schema(t *testing.T) { // #14 { Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeString, Optional: true, Computed: true, @@ -2819,7 +2819,7 @@ func TestResourceDataState_schema(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "foo": &terraform.ResourceAttrDiff{ + "foo": { NewComputed: true, }, }, @@ -2833,7 +2833,7 @@ func TestResourceDataState_schema(t *testing.T) { // #15 { Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeString, Optional: true, Computed: true, @@ -2844,7 +2844,7 @@ func TestResourceDataState_schema(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "foo": &terraform.ResourceAttrDiff{ + "foo": { NewComputed: true, }, }, @@ -2864,14 +2864,14 @@ func TestResourceDataState_schema(t *testing.T) { // #16 Set of maps { Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeSet, Optional: true, Computed: true, Elem: &Resource{ Schema: map[string]*Schema{ - "index": &Schema{Type: TypeInt}, - "uuids": &Schema{Type: TypeMap}, + "index": {Type: TypeInt}, + "uuids": {Type: TypeMap}, }, }, Set: func(a interface{}) int { @@ -2885,7 +2885,7 @@ func TestResourceDataState_schema(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "ports.10.uuids.#": &terraform.ResourceAttrDiff{ + "ports.10.uuids.#": { NewComputed: true, }, }, @@ -2915,7 +2915,7 @@ func TestResourceDataState_schema(t *testing.T) { // #17 { Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeSet, Optional: true, Computed: true, @@ -2937,7 +2937,7 @@ func TestResourceDataState_schema(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "ports.#": &terraform.ResourceAttrDiff{ + "ports.#": { Old: "3", New: "0", }, @@ -2954,7 +2954,7 @@ func TestResourceDataState_schema(t *testing.T) { // #18 { Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeSet, Optional: true, Computed: true, @@ -2983,7 +2983,7 @@ func TestResourceDataState_schema(t *testing.T) { // #19 { Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeList, Optional: true, Computed: true, @@ -3009,14 +3009,14 @@ func TestResourceDataState_schema(t *testing.T) { // #20 Set lists { Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeList, Optional: true, Computed: true, Elem: &Resource{ Schema: map[string]*Schema{ - "index": &Schema{Type: TypeInt}, - "uuids": &Schema{Type: TypeMap}, + "index": {Type: TypeInt}, + "uuids": {Type: TypeMap}, }, }, }, @@ -3026,7 +3026,7 @@ func TestResourceDataState_schema(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "ports.#": &terraform.ResourceAttrDiff{ + "ports.#": { NewComputed: true, }, }, @@ -3097,7 +3097,7 @@ func TestResourceData_nonStringValuesInMap(t *testing.T) { }{ { Schema: map[string]*Schema{ - "boolMap": &Schema{ + "boolMap": { Type: TypeMap, Elem: TypeBool, Optional: true, @@ -3105,11 +3105,11 @@ func TestResourceData_nonStringValuesInMap(t *testing.T) { }, Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "boolMap.%": &terraform.ResourceAttrDiff{ + "boolMap.%": { Old: "", New: "1", }, - "boolMap.boolField": &terraform.ResourceAttrDiff{ + "boolMap.boolField": { Old: "", New: "true", }, @@ -3121,7 +3121,7 @@ func TestResourceData_nonStringValuesInMap(t *testing.T) { }, { Schema: map[string]*Schema{ - "intMap": &Schema{ + "intMap": { Type: TypeMap, Elem: TypeInt, Optional: true, @@ -3129,11 +3129,11 @@ func TestResourceData_nonStringValuesInMap(t *testing.T) { }, Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "intMap.%": &terraform.ResourceAttrDiff{ + "intMap.%": { Old: "", New: "1", }, - "intMap.intField": &terraform.ResourceAttrDiff{ + "intMap.intField": { Old: "", New: "8", }, @@ -3145,7 +3145,7 @@ func TestResourceData_nonStringValuesInMap(t *testing.T) { }, { Schema: map[string]*Schema{ - "floatMap": &Schema{ + "floatMap": { Type: TypeMap, Elem: TypeFloat, Optional: true, @@ -3153,11 +3153,11 @@ func TestResourceData_nonStringValuesInMap(t *testing.T) { }, Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "floatMap.%": &terraform.ResourceAttrDiff{ + "floatMap.%": { Old: "", New: "1", }, - "floatMap.floatField": &terraform.ResourceAttrDiff{ + "floatMap.floatField": { Old: "", New: "8.22", }, diff --git a/helper/schema/resource_diff_test.go b/helper/schema/resource_diff_test.go index 9f65334516e..5a0b0e0a6bc 100644 --- a/helper/schema/resource_diff_test.go +++ b/helper/schema/resource_diff_test.go @@ -40,10 +40,10 @@ type resourceDiffTestCase struct { // testDiffCases produces a list of test cases for use with SetNew and SetDiff. func testDiffCases(t *testing.T, oldPrefix string, oldOffset int, computed bool) []resourceDiffTestCase { return []resourceDiffTestCase{ - resourceDiffTestCase{ + { Name: "basic primitive diff", Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeString, Optional: true, Computed: true, @@ -59,7 +59,7 @@ func testDiffCases(t *testing.T, oldPrefix string, oldOffset int, computed bool) }), Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "foo": &terraform.ResourceAttrDiff{ + "foo": { Old: "bar", New: "baz", }, @@ -69,7 +69,7 @@ func testDiffCases(t *testing.T, oldPrefix string, oldOffset int, computed bool) NewValue: "qux", Expected: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "foo": &terraform.ResourceAttrDiff{ + "foo": { Old: "bar", New: func() string { if computed { @@ -82,10 +82,10 @@ func testDiffCases(t *testing.T, oldPrefix string, oldOffset int, computed bool) }, }, }, - resourceDiffTestCase{ + { Name: "basic set diff", Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeSet, Optional: true, Computed: true, @@ -104,12 +104,12 @@ func testDiffCases(t *testing.T, oldPrefix string, oldOffset int, computed bool) }), Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "foo.1996459178": &terraform.ResourceAttrDiff{ + "foo.1996459178": { Old: "bar", New: "", NewRemoved: true, }, - "foo.2015626392": &terraform.ResourceAttrDiff{ + "foo.2015626392": { Old: "", New: "baz", }, @@ -141,10 +141,10 @@ func testDiffCases(t *testing.T, oldPrefix string, oldOffset int, computed bool) }(), }, }, - resourceDiffTestCase{ + { Name: "basic list diff", Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeList, Optional: true, Computed: true, @@ -162,7 +162,7 @@ func testDiffCases(t *testing.T, oldPrefix string, oldOffset int, computed bool) }), Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "foo.0": &terraform.ResourceAttrDiff{ + "foo.0": { Old: "bar", New: "baz", }, @@ -189,10 +189,10 @@ func testDiffCases(t *testing.T, oldPrefix string, oldOffset int, computed bool) }(), }, }, - resourceDiffTestCase{ + { Name: "basic map diff", Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeMap, Optional: true, Computed: true, @@ -209,7 +209,7 @@ func testDiffCases(t *testing.T, oldPrefix string, oldOffset int, computed bool) }), Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "foo.bar": &terraform.ResourceAttrDiff{ + "foo.bar": { Old: "baz", New: "qux", }, @@ -241,14 +241,14 @@ func testDiffCases(t *testing.T, oldPrefix string, oldOffset int, computed bool) }(), }, }, - resourceDiffTestCase{ + { Name: "additional diff with primitive", Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeString, Optional: true, }, - "one": &Schema{ + "one": { Type: TypeString, Optional: true, Computed: true, @@ -265,7 +265,7 @@ func testDiffCases(t *testing.T, oldPrefix string, oldOffset int, computed bool) }), Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "foo": &terraform.ResourceAttrDiff{ + "foo": { Old: "bar", New: "baz", }, @@ -275,11 +275,11 @@ func testDiffCases(t *testing.T, oldPrefix string, oldOffset int, computed bool) NewValue: "four", Expected: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "foo": &terraform.ResourceAttrDiff{ + "foo": { Old: "bar", New: "baz", }, - "one": &terraform.ResourceAttrDiff{ + "one": { Old: "two", New: func() string { if computed { @@ -292,14 +292,14 @@ func testDiffCases(t *testing.T, oldPrefix string, oldOffset int, computed bool) }, }, }, - resourceDiffTestCase{ + { Name: "additional diff with primitive computed only", Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeString, Optional: true, }, - "one": &Schema{ + "one": { Type: TypeString, Computed: true, }, @@ -315,7 +315,7 @@ func testDiffCases(t *testing.T, oldPrefix string, oldOffset int, computed bool) }), Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "foo": &terraform.ResourceAttrDiff{ + "foo": { Old: "bar", New: "baz", }, @@ -325,11 +325,11 @@ func testDiffCases(t *testing.T, oldPrefix string, oldOffset int, computed bool) NewValue: "three", Expected: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "foo": &terraform.ResourceAttrDiff{ + "foo": { Old: "bar", New: "baz", }, - "one": &terraform.ResourceAttrDiff{ + "one": { Old: "two", New: func() string { if computed { @@ -342,21 +342,21 @@ func testDiffCases(t *testing.T, oldPrefix string, oldOffset int, computed bool) }, }, }, - resourceDiffTestCase{ + { Name: "complex-ish set diff", Schema: map[string]*Schema{ - "top": &Schema{ + "top": { Type: TypeSet, Optional: true, Computed: true, Elem: &Resource{ Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeInt, Optional: true, Computed: true, }, - "bar": &Schema{ + "bar": { Type: TypeInt, Optional: true, Computed: true, @@ -389,19 +389,19 @@ func testDiffCases(t *testing.T, oldPrefix string, oldOffset int, computed bool) }), Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "top.4.foo": &terraform.ResourceAttrDiff{ + "top.4.foo": { Old: "", New: "1", }, - "top.4.bar": &terraform.ResourceAttrDiff{ + "top.4.bar": { Old: "", New: "3", }, - "top.24.foo": &terraform.ResourceAttrDiff{ + "top.24.foo": { Old: "", New: "12", }, - "top.24.bar": &terraform.ResourceAttrDiff{ + "top.24.bar": { Old: "", New: "12", }, @@ -465,10 +465,10 @@ func testDiffCases(t *testing.T, oldPrefix string, oldOffset int, computed bool) }(), }, }, - resourceDiffTestCase{ + { Name: "primitive, no diff, no refresh", Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeString, Computed: true, }, @@ -484,7 +484,7 @@ func testDiffCases(t *testing.T, oldPrefix string, oldOffset int, computed bool) NewValue: "baz", Expected: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "foo": &terraform.ResourceAttrDiff{ + "foo": { Old: "bar", New: func() string { if computed { @@ -497,10 +497,10 @@ func testDiffCases(t *testing.T, oldPrefix string, oldOffset int, computed bool) }, }, }, - resourceDiffTestCase{ + { Name: "non-computed key, should error", Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeString, Required: true, }, @@ -515,7 +515,7 @@ func testDiffCases(t *testing.T, oldPrefix string, oldOffset int, computed bool) }), Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "foo": &terraform.ResourceAttrDiff{ + "foo": { Old: "bar", New: "baz", }, @@ -525,10 +525,10 @@ func testDiffCases(t *testing.T, oldPrefix string, oldOffset int, computed bool) NewValue: "qux", ExpectedError: true, }, - resourceDiffTestCase{ + { Name: "bad key, should error", Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeString, Required: true, }, @@ -543,7 +543,7 @@ func testDiffCases(t *testing.T, oldPrefix string, oldOffset int, computed bool) }), Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "foo": &terraform.ResourceAttrDiff{ + "foo": { Old: "bar", New: "baz", }, @@ -553,7 +553,7 @@ func testDiffCases(t *testing.T, oldPrefix string, oldOffset int, computed bool) NewValue: "qux", ExpectedError: true, }, - resourceDiffTestCase{ + { // NOTE: This case is technically impossible in the current // implementation, because optional+computed values never show up in the // diff, and we actually clear existing diffs when SetNew or @@ -561,7 +561,7 @@ func testDiffCases(t *testing.T, oldPrefix string, oldOffset int, computed bool) // these behaviors change that we don't introduce regressions. Name: "NewRemoved in diff for Optional and Computed, should be fully overridden", Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeString, Optional: true, Computed: true, @@ -575,7 +575,7 @@ func testDiffCases(t *testing.T, oldPrefix string, oldOffset int, computed bool) Config: testConfig(t, map[string]interface{}{}), Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "foo": &terraform.ResourceAttrDiff{ + "foo": { Old: "bar", New: "", NewRemoved: true, @@ -586,7 +586,7 @@ func testDiffCases(t *testing.T, oldPrefix string, oldOffset int, computed bool) NewValue: "qux", Expected: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "foo": &terraform.ResourceAttrDiff{ + "foo": { Old: "bar", New: func() string { if computed { @@ -599,10 +599,10 @@ func testDiffCases(t *testing.T, oldPrefix string, oldOffset int, computed bool) }, }, }, - resourceDiffTestCase{ + { Name: "NewComputed should always propagate", Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeString, Computed: true, }, @@ -621,7 +621,7 @@ func testDiffCases(t *testing.T, oldPrefix string, oldOffset int, computed bool) Attributes: func() map[string]*terraform.ResourceAttrDiff { if computed { return map[string]*terraform.ResourceAttrDiff{ - "foo": &terraform.ResourceAttrDiff{ + "foo": { NewComputed: computed, }, } @@ -689,10 +689,10 @@ func TestSetNewComputed(t *testing.T) { func TestForceNew(t *testing.T) { cases := []resourceDiffTestCase{ - resourceDiffTestCase{ + { Name: "basic primitive diff", Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeString, Optional: true, Computed: true, @@ -708,7 +708,7 @@ func TestForceNew(t *testing.T) { }), Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "foo": &terraform.ResourceAttrDiff{ + "foo": { Old: "bar", New: "baz", }, @@ -717,7 +717,7 @@ func TestForceNew(t *testing.T) { Key: "foo", Expected: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "foo": &terraform.ResourceAttrDiff{ + "foo": { Old: "bar", New: "baz", RequiresNew: true, @@ -725,10 +725,10 @@ func TestForceNew(t *testing.T) { }, }, }, - resourceDiffTestCase{ + { Name: "no change, should error", Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeString, Optional: true, Computed: true, @@ -744,10 +744,10 @@ func TestForceNew(t *testing.T) { }), ExpectedError: true, }, - resourceDiffTestCase{ + { Name: "basic primitive, non-computed key", Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeString, Required: true, }, @@ -762,7 +762,7 @@ func TestForceNew(t *testing.T) { }), Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "foo": &terraform.ResourceAttrDiff{ + "foo": { Old: "bar", New: "baz", }, @@ -771,7 +771,7 @@ func TestForceNew(t *testing.T) { Key: "foo", Expected: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "foo": &terraform.ResourceAttrDiff{ + "foo": { Old: "bar", New: "baz", RequiresNew: true, @@ -779,10 +779,10 @@ func TestForceNew(t *testing.T) { }, }, }, - resourceDiffTestCase{ + { Name: "nested field", Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeList, Required: true, MaxItems: 1, @@ -817,11 +817,11 @@ func TestForceNew(t *testing.T) { }), Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "foo.0.bar": &terraform.ResourceAttrDiff{ + "foo.0.bar": { Old: "abc", New: "abcdefg", }, - "foo.0.baz": &terraform.ResourceAttrDiff{ + "foo.0.baz": { Old: "xyz", New: "changed", }, @@ -830,11 +830,11 @@ func TestForceNew(t *testing.T) { Key: "foo.0.baz", Expected: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "foo.0.bar": &terraform.ResourceAttrDiff{ + "foo.0.bar": { Old: "abc", New: "abcdefg", }, - "foo.0.baz": &terraform.ResourceAttrDiff{ + "foo.0.baz": { Old: "xyz", New: "changed", RequiresNew: true, @@ -842,10 +842,10 @@ func TestForceNew(t *testing.T) { }, }, }, - resourceDiffTestCase{ + { Name: "preserve NewRemoved on existing diff", Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeString, Optional: true, }, @@ -858,7 +858,7 @@ func TestForceNew(t *testing.T) { Config: testConfig(t, map[string]interface{}{}), Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "foo": &terraform.ResourceAttrDiff{ + "foo": { Old: "bar", New: "", NewRemoved: true, @@ -868,7 +868,7 @@ func TestForceNew(t *testing.T) { Key: "foo", Expected: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "foo": &terraform.ResourceAttrDiff{ + "foo": { Old: "bar", New: "", RequiresNew: true, @@ -877,10 +877,10 @@ func TestForceNew(t *testing.T) { }, }, }, - resourceDiffTestCase{ + { Name: "nested field, preserve original diff without zero values", Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeList, Required: true, MaxItems: 1, @@ -913,7 +913,7 @@ func TestForceNew(t *testing.T) { }), Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "foo.0.bar": &terraform.ResourceAttrDiff{ + "foo.0.bar": { Old: "abc", New: "abcdefg", }, @@ -922,7 +922,7 @@ func TestForceNew(t *testing.T) { Key: "foo.0.bar", Expected: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "foo.0.bar": &terraform.ResourceAttrDiff{ + "foo.0.bar": { Old: "abc", New: "abcdefg", RequiresNew: true, @@ -958,10 +958,10 @@ func TestForceNew(t *testing.T) { func TestClear(t *testing.T) { cases := []resourceDiffTestCase{ - resourceDiffTestCase{ + { Name: "basic primitive diff", Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeString, Optional: true, Computed: true, @@ -977,7 +977,7 @@ func TestClear(t *testing.T) { }), Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "foo": &terraform.ResourceAttrDiff{ + "foo": { Old: "bar", New: "baz", }, @@ -986,10 +986,10 @@ func TestClear(t *testing.T) { Key: "foo", Expected: &terraform.InstanceDiff{Attributes: map[string]*terraform.ResourceAttrDiff{}}, }, - resourceDiffTestCase{ + { Name: "non-computed key, should error", Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeString, Required: true, }, @@ -1004,7 +1004,7 @@ func TestClear(t *testing.T) { }), Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "foo": &terraform.ResourceAttrDiff{ + "foo": { Old: "bar", New: "baz", }, @@ -1013,15 +1013,15 @@ func TestClear(t *testing.T) { Key: "foo", ExpectedError: true, }, - resourceDiffTestCase{ + { Name: "multi-value, one removed", Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeString, Optional: true, Computed: true, }, - "one": &Schema{ + "one": { Type: TypeString, Optional: true, Computed: true, @@ -1039,11 +1039,11 @@ func TestClear(t *testing.T) { }), Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "foo": &terraform.ResourceAttrDiff{ + "foo": { Old: "bar", New: "baz", }, - "one": &terraform.ResourceAttrDiff{ + "one": { Old: "two", New: "three", }, @@ -1052,28 +1052,28 @@ func TestClear(t *testing.T) { Key: "one", Expected: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "foo": &terraform.ResourceAttrDiff{ + "foo": { Old: "bar", New: "baz", }, }, }, }, - resourceDiffTestCase{ + { Name: "basic sub-block diff", Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeList, Optional: true, Computed: true, Elem: &Resource{ Schema: map[string]*Schema{ - "bar": &Schema{ + "bar": { Type: TypeString, Optional: true, Computed: true, }, - "baz": &Schema{ + "baz": { Type: TypeString, Optional: true, Computed: true, @@ -1098,7 +1098,7 @@ func TestClear(t *testing.T) { }), Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "foo.0.bar": &terraform.ResourceAttrDiff{ + "foo.0.bar": { Old: "bar1", New: "bar2", }, @@ -1107,21 +1107,21 @@ func TestClear(t *testing.T) { Key: "foo.0.bar", Expected: &terraform.InstanceDiff{Attributes: map[string]*terraform.ResourceAttrDiff{}}, }, - resourceDiffTestCase{ + { Name: "sub-block diff only partial clear", Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeList, Optional: true, Computed: true, Elem: &Resource{ Schema: map[string]*Schema{ - "bar": &Schema{ + "bar": { Type: TypeString, Optional: true, Computed: true, }, - "baz": &Schema{ + "baz": { Type: TypeString, Optional: true, Computed: true, @@ -1146,11 +1146,11 @@ func TestClear(t *testing.T) { }), Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "foo.0.bar": &terraform.ResourceAttrDiff{ + "foo.0.bar": { Old: "bar1", New: "bar2", }, - "foo.0.baz": &terraform.ResourceAttrDiff{ + "foo.0.baz": { Old: "baz1", New: "baz2", }, @@ -1158,7 +1158,7 @@ func TestClear(t *testing.T) { }, Key: "foo.0.bar", Expected: &terraform.InstanceDiff{Attributes: map[string]*terraform.ResourceAttrDiff{ - "foo.0.baz": &terraform.ResourceAttrDiff{ + "foo.0.baz": { Old: "baz1", New: "baz2", }, @@ -1192,10 +1192,10 @@ func TestClear(t *testing.T) { func TestGetChangedKeysPrefix(t *testing.T) { cases := []resourceDiffTestCase{ - resourceDiffTestCase{ + { Name: "basic primitive diff", Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeString, Optional: true, Computed: true, @@ -1211,7 +1211,7 @@ func TestGetChangedKeysPrefix(t *testing.T) { }), Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "foo": &terraform.ResourceAttrDiff{ + "foo": { Old: "bar", New: "baz", }, @@ -1222,14 +1222,14 @@ func TestGetChangedKeysPrefix(t *testing.T) { "foo", }, }, - resourceDiffTestCase{ + { Name: "nested field filtering", Schema: map[string]*Schema{ - "testfield": &Schema{ + "testfield": { Type: TypeString, Required: true, }, - "foo": &Schema{ + "foo": { Type: TypeList, Required: true, MaxItems: 1, @@ -1266,15 +1266,15 @@ func TestGetChangedKeysPrefix(t *testing.T) { }), Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "testfield": &terraform.ResourceAttrDiff{ + "testfield": { Old: "blablah", New: "modified", }, - "foo.0.bar": &terraform.ResourceAttrDiff{ + "foo.0.bar": { Old: "abc", New: "abcdefg", }, - "foo.0.baz": &terraform.ResourceAttrDiff{ + "foo.0.baz": { Old: "xyz", New: "changed", }, diff --git a/helper/schema/resource_test.go b/helper/schema/resource_test.go index a5862b3ed42..77b51f8c098 100644 --- a/helper/schema/resource_test.go +++ b/helper/schema/resource_test.go @@ -21,7 +21,7 @@ func TestResourceApply_create(t *testing.T) { r := &Resource{ SchemaVersion: 2, Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeInt, Optional: true, }, @@ -39,7 +39,7 @@ func TestResourceApply_create(t *testing.T) { d := &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "foo": &terraform.ResourceAttrDiff{ + "foo": { New: "42", }, }, @@ -74,7 +74,7 @@ func TestResourceApply_Timeout_state(t *testing.T) { r := &Resource{ SchemaVersion: 2, Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeInt, Optional: true, }, @@ -97,7 +97,7 @@ func TestResourceApply_Timeout_state(t *testing.T) { d := &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "foo": &terraform.ResourceAttrDiff{ + "foo": { New: "42", }, }, @@ -151,7 +151,7 @@ func TestResourceApply_Timeout_destroy(t *testing.T) { r := &Resource{ Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeInt, Optional: true, }, @@ -200,7 +200,7 @@ func TestResourceApply_Timeout_destroy(t *testing.T) { func TestResourceDiff_Timeout_diff(t *testing.T) { r := &Resource{ Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeInt, Optional: true, }, @@ -234,7 +234,7 @@ func TestResourceDiff_Timeout_diff(t *testing.T) { expected := &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "foo": &terraform.ResourceAttrDiff{ + "foo": { New: "42", }, }, @@ -258,7 +258,7 @@ func TestResourceDiff_Timeout_diff(t *testing.T) { func TestResourceDiff_CustomizeFunc(t *testing.T) { r := &Resource{ Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeInt, Optional: true, }, @@ -293,7 +293,7 @@ func TestResourceDiff_CustomizeFunc(t *testing.T) { func TestResourceApply_destroy(t *testing.T) { r := &Resource{ Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeInt, Optional: true, }, @@ -331,12 +331,12 @@ func TestResourceApply_destroy(t *testing.T) { func TestResourceApply_destroyCreate(t *testing.T) { r := &Resource{ Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeInt, Optional: true, }, - "tags": &Schema{ + "tags": { Type: TypeMap, Optional: true, Computed: true, @@ -364,11 +364,11 @@ func TestResourceApply_destroyCreate(t *testing.T) { d := &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "foo": &terraform.ResourceAttrDiff{ + "foo": { New: "42", RequiresNew: true, }, - "tags.Name": &terraform.ResourceAttrDiff{ + "tags.Name": { Old: "foo", New: "foo", RequiresNew: true, @@ -403,7 +403,7 @@ func TestResourceApply_destroyCreate(t *testing.T) { func TestResourceApply_destroyPartial(t *testing.T) { r := &Resource{ Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeInt, Optional: true, }, @@ -451,7 +451,7 @@ func TestResourceApply_destroyPartial(t *testing.T) { func TestResourceApply_update(t *testing.T) { r := &Resource{ Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeInt, Optional: true, }, @@ -472,7 +472,7 @@ func TestResourceApply_update(t *testing.T) { d := &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "foo": &terraform.ResourceAttrDiff{ + "foo": { New: "13", }, }, @@ -499,7 +499,7 @@ func TestResourceApply_update(t *testing.T) { func TestResourceApply_updateNoCallback(t *testing.T) { r := &Resource{ Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeInt, Optional: true, }, @@ -517,7 +517,7 @@ func TestResourceApply_updateNoCallback(t *testing.T) { d := &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "foo": &terraform.ResourceAttrDiff{ + "foo": { New: "13", }, }, @@ -543,7 +543,7 @@ func TestResourceApply_updateNoCallback(t *testing.T) { func TestResourceApply_isNewResource(t *testing.T) { r := &Resource{ Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeString, Optional: true, }, @@ -566,7 +566,7 @@ func TestResourceApply_isNewResource(t *testing.T) { d := &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "foo": &terraform.ResourceAttrDiff{ + "foo": { New: "bla-blah", }, }, @@ -637,7 +637,7 @@ func TestResourceInternalValidate(t *testing.T) { 1: { &Resource{ Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeInt, Optional: true, Required: true, @@ -653,7 +653,7 @@ func TestResourceInternalValidate(t *testing.T) { &Resource{ Create: Noop, Schema: map[string]*Schema{ - "boo": &Schema{ + "boo": { Type: TypeInt, Optional: true, }, @@ -669,7 +669,7 @@ func TestResourceInternalValidate(t *testing.T) { Create: Noop, Update: Noop, Schema: map[string]*Schema{ - "goo": &Schema{ + "goo": { Type: TypeInt, Optional: true, ForceNew: true, @@ -684,7 +684,7 @@ func TestResourceInternalValidate(t *testing.T) { 4: { &Resource{ Schema: map[string]*Schema{ - "goo": &Schema{ + "goo": { Type: TypeInt, Optional: true, }, @@ -699,7 +699,7 @@ func TestResourceInternalValidate(t *testing.T) { &Resource{ Create: Noop, Schema: map[string]*Schema{ - "goo": &Schema{ + "goo": { Type: TypeInt, Optional: true, }, @@ -716,7 +716,7 @@ func TestResourceInternalValidate(t *testing.T) { Update: Noop, Delete: Noop, Schema: map[string]*Schema{ - "goo": &Schema{ + "goo": { Type: TypeInt, Optional: true, }, @@ -733,7 +733,7 @@ func TestResourceInternalValidate(t *testing.T) { Read: Noop, Update: Noop, Schema: map[string]*Schema{ - "goo": &Schema{ + "goo": { Type: TypeInt, Optional: true, }, @@ -767,7 +767,7 @@ func TestResourceInternalValidate(t *testing.T) { Update: Noop, Delete: Noop, Schema: map[string]*Schema{ - "parent_list": &Schema{ + "parent_list": { Type: TypeString, Optional: true, Elem: &Resource{ @@ -792,7 +792,7 @@ func TestResourceInternalValidate(t *testing.T) { Update: Noop, Delete: Noop, Schema: map[string]*Schema{ - "alias": &Schema{ + "alias": { Type: TypeString, Optional: true, }, @@ -806,7 +806,7 @@ func TestResourceInternalValidate(t *testing.T) { &Resource{ Read: Noop, Schema: map[string]*Schema{ - "id": &Schema{ + "id": { Type: TypeString, Optional: true, }, @@ -823,7 +823,7 @@ func TestResourceInternalValidate(t *testing.T) { Update: Noop, Delete: Noop, Schema: map[string]*Schema{ - "id": &Schema{ + "id": { Type: TypeString, Optional: true, Deprecated: "Use x_id instead", @@ -838,7 +838,7 @@ func TestResourceInternalValidate(t *testing.T) { &Resource{ Read: Noop, Schema: map[string]*Schema{ - "goo": &Schema{ + "goo": { Type: TypeInt, Optional: true, }, @@ -852,7 +852,7 @@ func TestResourceInternalValidate(t *testing.T) { &Resource{ Read: Noop, Schema: map[string]*Schema{ - "goo": &Schema{ + "goo": { Type: TypeInt, Optional: true, }, @@ -870,7 +870,7 @@ func TestResourceInternalValidate(t *testing.T) { Update: Noop, Delete: Noop, Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeString, Required: true, }, @@ -887,7 +887,7 @@ func TestResourceInternalValidate(t *testing.T) { Update: Noop, Delete: Noop, Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeString, Required: true, }, @@ -904,7 +904,7 @@ func TestResourceInternalValidate(t *testing.T) { UpdateContext: NoopContext, Delete: Noop, Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeString, Required: true, }, @@ -921,7 +921,7 @@ func TestResourceInternalValidate(t *testing.T) { Delete: Noop, DeleteContext: NoopContext, Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeString, Required: true, }, @@ -939,7 +939,7 @@ func TestResourceInternalValidate(t *testing.T) { Exists: func(*ResourceData, interface{}) (bool, error) { return false, nil }, ExistsContext: func(context.Context, *ResourceData, interface{}) (bool, error) { return false, nil }, Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeString, Required: true, }, @@ -971,7 +971,7 @@ func TestResourceRefresh(t *testing.T) { r := &Resource{ SchemaVersion: 2, Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeInt, Optional: true, }, @@ -1017,7 +1017,7 @@ func TestResourceRefresh(t *testing.T) { func TestResourceRefresh_blankId(t *testing.T) { r := &Resource{ Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeInt, Optional: true, }, @@ -1046,7 +1046,7 @@ func TestResourceRefresh_blankId(t *testing.T) { func TestResourceRefresh_delete(t *testing.T) { r := &Resource{ Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeInt, Optional: true, }, @@ -1078,7 +1078,7 @@ func TestResourceRefresh_delete(t *testing.T) { func TestResourceRefresh_existsError(t *testing.T) { r := &Resource{ Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeInt, Optional: true, }, @@ -1112,7 +1112,7 @@ func TestResourceRefresh_existsError(t *testing.T) { func TestResourceRefresh_noExists(t *testing.T) { r := &Resource{ Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeInt, Optional: true, }, @@ -1148,7 +1148,7 @@ func TestResourceRefresh_needsMigration(t *testing.T) { r := &Resource{ SchemaVersion: 2, Schema: map[string]*Schema{ - "newfoo": &Schema{ + "newfoo": { Type: TypeInt, Optional: true, }, @@ -1220,7 +1220,7 @@ func TestResourceRefresh_noMigrationNeeded(t *testing.T) { r := &Resource{ SchemaVersion: 2, Schema: map[string]*Schema{ - "newfoo": &Schema{ + "newfoo": { Type: TypeInt, Optional: true, }, @@ -1275,7 +1275,7 @@ func TestResourceRefresh_stateSchemaVersionUnset(t *testing.T) { // Version 1 > Version 0 SchemaVersion: 1, Schema: map[string]*Schema{ - "newfoo": &Schema{ + "newfoo": { Type: TypeInt, Optional: true, }, @@ -1326,7 +1326,7 @@ func TestResourceRefresh_migrateStateErr(t *testing.T) { r := &Resource{ SchemaVersion: 2, Schema: map[string]*Schema{ - "newfoo": &Schema{ + "newfoo": { Type: TypeInt, Optional: true, }, @@ -1362,7 +1362,7 @@ func TestResourceData(t *testing.T) { r := &Resource{ SchemaVersion: 2, Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeInt, Optional: true, }, @@ -1400,7 +1400,7 @@ func TestResourceData_blank(t *testing.T) { r := &Resource{ SchemaVersion: 2, Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeInt, Optional: true, }, @@ -1434,7 +1434,7 @@ func TestResourceData_timeouts(t *testing.T) { r := &Resource{ SchemaVersion: 2, Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeInt, Optional: true, }, @@ -1459,7 +1459,7 @@ func TestResource_UpgradeState(t *testing.T) { r := &Resource{ SchemaVersion: 2, Schema: map[string]*Schema{ - "newfoo": &Schema{ + "newfoo": { Type: TypeInt, Optional: true, }, @@ -1528,7 +1528,7 @@ func TestResource_ValidateUpgradeState(t *testing.T) { r := &Resource{ SchemaVersion: 3, Schema: map[string]*Schema{ - "newfoo": &Schema{ + "newfoo": { Type: TypeInt, Optional: true, }, @@ -1775,7 +1775,7 @@ func TestResource_migrateAndUpgrade(t *testing.T) { func TestResource_ContextTimeout(t *testing.T) { r := &Resource{ Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeInt, Optional: true, }, @@ -1796,7 +1796,7 @@ func TestResource_ContextTimeout(t *testing.T) { d := &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "foo": &terraform.ResourceAttrDiff{ + "foo": { New: "42", }, }, diff --git a/helper/schema/schema.go b/helper/schema/schema.go index c726551f1af..b4081003207 100644 --- a/helper/schema/schema.go +++ b/helper/schema/schema.go @@ -1546,7 +1546,7 @@ func (m schemaMap) validateList( // Now build the []interface{} raws := make([]interface{}, rawV.Len()) - for i, _ := range raws { + for i := range raws { raws[i] = rawV.Index(i).Interface() } @@ -1632,7 +1632,7 @@ func (m schemaMap) validateMap( // It is a slice, verify that all the elements are maps raws := make([]interface{}, rawV.Len()) - for i, _ := range raws { + for i := range raws { raws[i] = rawV.Index(i).Interface() } @@ -1756,7 +1756,7 @@ func (m schemaMap) validateObject( // Detect any extra/unknown keys and report those as errors. if m, ok := raw.(map[string]interface{}); ok { - for subk, _ := range m { + for subk := range m { if _, ok := schema[subk]; !ok { if subk == TimeoutsConfigKey { continue diff --git a/helper/schema/schema_test.go b/helper/schema/schema_test.go index 9d4e01e7a02..1f9f773ec40 100644 --- a/helper/schema/schema_test.go +++ b/helper/schema/schema_test.go @@ -138,7 +138,7 @@ func TestSchemaMap_Diff(t *testing.T) { }{ { Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Optional: true, Computed: true, @@ -154,7 +154,7 @@ func TestSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "availability_zone": &terraform.ResourceAttrDiff{ + "availability_zone": { Old: "", New: "foo", RequiresNew: true, @@ -167,7 +167,7 @@ func TestSchemaMap_Diff(t *testing.T) { { Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Optional: true, Computed: true, @@ -181,7 +181,7 @@ func TestSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "availability_zone": &terraform.ResourceAttrDiff{ + "availability_zone": { Old: "", NewComputed: true, RequiresNew: true, @@ -194,7 +194,7 @@ func TestSchemaMap_Diff(t *testing.T) { { Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Optional: true, Computed: true, @@ -216,7 +216,7 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "Computed, but set in config", Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Optional: true, Computed: true, @@ -235,7 +235,7 @@ func TestSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "availability_zone": &terraform.ResourceAttrDiff{ + "availability_zone": { Old: "foo", New: "bar", }, @@ -248,7 +248,7 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "Default", Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Optional: true, Default: "foo", @@ -261,7 +261,7 @@ func TestSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "availability_zone": &terraform.ResourceAttrDiff{ + "availability_zone": { Old: "", New: "foo", }, @@ -274,7 +274,7 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "DefaultFunc, value", Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Optional: true, DefaultFunc: func() (interface{}, error) { @@ -289,7 +289,7 @@ func TestSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "availability_zone": &terraform.ResourceAttrDiff{ + "availability_zone": { Old: "", New: "foo", }, @@ -302,7 +302,7 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "DefaultFunc, configuration set", Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Optional: true, DefaultFunc: func() (interface{}, error) { @@ -319,7 +319,7 @@ func TestSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "availability_zone": &terraform.ResourceAttrDiff{ + "availability_zone": { Old: "", New: "bar", }, @@ -332,7 +332,7 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "String with StateFunc", Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Optional: true, Computed: true, @@ -350,7 +350,7 @@ func TestSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "availability_zone": &terraform.ResourceAttrDiff{ + "availability_zone": { Old: "", New: "foo!", NewExtra: "foo", @@ -364,7 +364,7 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "StateFunc not called with nil value", Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Optional: true, Computed: true, @@ -381,7 +381,7 @@ func TestSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "availability_zone": &terraform.ResourceAttrDiff{ + "availability_zone": { Old: "", New: "", NewComputed: true, @@ -395,7 +395,7 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "Variable computed", Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Optional: true, }, @@ -409,7 +409,7 @@ func TestSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "availability_zone": &terraform.ResourceAttrDiff{ + "availability_zone": { Old: "", New: hcl2shim.UnknownVariableValue, NewComputed: true, @@ -423,7 +423,7 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "Int decode", Schema: map[string]*Schema{ - "port": &Schema{ + "port": { Type: TypeInt, Optional: true, Computed: true, @@ -439,7 +439,7 @@ func TestSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "port": &terraform.ResourceAttrDiff{ + "port": { Old: "", New: "27", RequiresNew: true, @@ -453,7 +453,7 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "bool decode", Schema: map[string]*Schema{ - "port": &Schema{ + "port": { Type: TypeBool, Optional: true, Computed: true, @@ -469,7 +469,7 @@ func TestSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "port": &terraform.ResourceAttrDiff{ + "port": { Old: "", New: "false", RequiresNew: true, @@ -483,7 +483,7 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "Bool", Schema: map[string]*Schema{ - "delete": &Schema{ + "delete": { Type: TypeBool, Optional: true, Default: false, @@ -506,7 +506,7 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "List decode", Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeList, Required: true, Elem: &Schema{Type: TypeInt}, @@ -521,19 +521,19 @@ func TestSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "ports.#": &terraform.ResourceAttrDiff{ + "ports.#": { Old: "0", New: "3", }, - "ports.0": &terraform.ResourceAttrDiff{ + "ports.0": { Old: "", New: "1", }, - "ports.1": &terraform.ResourceAttrDiff{ + "ports.1": { Old: "", New: "2", }, - "ports.2": &terraform.ResourceAttrDiff{ + "ports.2": { Old: "", New: "5", }, @@ -545,7 +545,7 @@ func TestSchemaMap_Diff(t *testing.T) { { Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeList, Required: true, Elem: &Schema{Type: TypeInt}, @@ -560,19 +560,19 @@ func TestSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "ports.#": &terraform.ResourceAttrDiff{ + "ports.#": { Old: "0", New: "3", }, - "ports.0": &terraform.ResourceAttrDiff{ + "ports.0": { Old: "", New: "1", }, - "ports.1": &terraform.ResourceAttrDiff{ + "ports.1": { Old: "", New: "2", }, - "ports.2": &terraform.ResourceAttrDiff{ + "ports.2": { Old: "", New: "5", }, @@ -584,7 +584,7 @@ func TestSchemaMap_Diff(t *testing.T) { { Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeList, Required: true, Elem: &Schema{Type: TypeInt}, @@ -599,7 +599,7 @@ func TestSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "ports.#": &terraform.ResourceAttrDiff{ + "ports.#": { Old: "0", New: "", NewComputed: true, @@ -612,7 +612,7 @@ func TestSchemaMap_Diff(t *testing.T) { { Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeList, Required: true, Elem: &Schema{Type: TypeInt}, @@ -640,7 +640,7 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "", Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeList, Required: true, Elem: &Schema{Type: TypeInt}, @@ -661,11 +661,11 @@ func TestSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "ports.#": &terraform.ResourceAttrDiff{ + "ports.#": { Old: "2", New: "3", }, - "ports.2": &terraform.ResourceAttrDiff{ + "ports.2": { Old: "", New: "5", }, @@ -678,7 +678,7 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "", Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeList, Required: true, Elem: &Schema{Type: TypeInt}, @@ -694,22 +694,22 @@ func TestSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "ports.#": &terraform.ResourceAttrDiff{ + "ports.#": { Old: "0", New: "3", RequiresNew: true, }, - "ports.0": &terraform.ResourceAttrDiff{ + "ports.0": { Old: "", New: "1", RequiresNew: true, }, - "ports.1": &terraform.ResourceAttrDiff{ + "ports.1": { Old: "", New: "2", RequiresNew: true, }, - "ports.2": &terraform.ResourceAttrDiff{ + "ports.2": { Old: "", New: "5", RequiresNew: true, @@ -723,7 +723,7 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "", Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeList, Optional: true, Computed: true, @@ -737,7 +737,7 @@ func TestSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "ports.#": &terraform.ResourceAttrDiff{ + "ports.#": { Old: "", NewComputed: true, }, @@ -750,7 +750,7 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "List with computed set", Schema: map[string]*Schema{ - "config": &Schema{ + "config": { Type: TypeList, Optional: true, ForceNew: true, @@ -785,18 +785,18 @@ func TestSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "config.#": &terraform.ResourceAttrDiff{ + "config.#": { Old: "0", New: "1", RequiresNew: true, }, - "config.0.name": &terraform.ResourceAttrDiff{ + "config.0.name": { Old: "", New: "hello", }, - "config.0.rules.#": &terraform.ResourceAttrDiff{ + "config.0.rules.#": { Old: "", NewComputed: true, }, @@ -809,7 +809,7 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "Set", Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeSet, Required: true, Elem: &Schema{Type: TypeInt}, @@ -827,19 +827,19 @@ func TestSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "ports.#": &terraform.ResourceAttrDiff{ + "ports.#": { Old: "0", New: "3", }, - "ports.1": &terraform.ResourceAttrDiff{ + "ports.1": { Old: "", New: "1", }, - "ports.2": &terraform.ResourceAttrDiff{ + "ports.2": { Old: "", New: "2", }, - "ports.5": &terraform.ResourceAttrDiff{ + "ports.5": { Old: "", New: "5", }, @@ -852,7 +852,7 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "Set", Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeSet, Computed: true, Required: true, @@ -879,7 +879,7 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "Set", Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeSet, Optional: true, Computed: true, @@ -896,7 +896,7 @@ func TestSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "ports.#": &terraform.ResourceAttrDiff{ + "ports.#": { Old: "", NewComputed: true, }, @@ -909,7 +909,7 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "Set", Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeSet, Required: true, Elem: &Schema{Type: TypeInt}, @@ -927,19 +927,19 @@ func TestSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "ports.#": &terraform.ResourceAttrDiff{ + "ports.#": { Old: "0", New: "3", }, - "ports.1": &terraform.ResourceAttrDiff{ + "ports.1": { Old: "", New: "1", }, - "ports.2": &terraform.ResourceAttrDiff{ + "ports.2": { Old: "", New: "2", }, - "ports.5": &terraform.ResourceAttrDiff{ + "ports.5": { Old: "", New: "5", }, @@ -952,7 +952,7 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "Set", Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeSet, Required: true, Elem: &Schema{Type: TypeInt}, @@ -970,7 +970,7 @@ func TestSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "ports.#": &terraform.ResourceAttrDiff{ + "ports.#": { Old: "", New: "", NewComputed: true, @@ -984,7 +984,7 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "Set", Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeSet, Required: true, Elem: &Schema{Type: TypeInt}, @@ -1008,19 +1008,19 @@ func TestSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "ports.#": &terraform.ResourceAttrDiff{ + "ports.#": { Old: "2", New: "3", }, - "ports.1": &terraform.ResourceAttrDiff{ + "ports.1": { Old: "1", New: "1", }, - "ports.2": &terraform.ResourceAttrDiff{ + "ports.2": { Old: "2", New: "2", }, - "ports.5": &terraform.ResourceAttrDiff{ + "ports.5": { Old: "", New: "5", }, @@ -1033,7 +1033,7 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "Set", Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeSet, Required: true, Elem: &Schema{Type: TypeInt}, @@ -1055,16 +1055,16 @@ func TestSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "ports.#": &terraform.ResourceAttrDiff{ + "ports.#": { Old: "2", New: "0", }, - "ports.1": &terraform.ResourceAttrDiff{ + "ports.1": { Old: "1", New: "0", NewRemoved: true, }, - "ports.2": &terraform.ResourceAttrDiff{ + "ports.2": { Old: "2", New: "0", NewRemoved: true, @@ -1078,7 +1078,7 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "Set", Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeSet, Optional: true, Computed: true, @@ -1107,12 +1107,12 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "Set", Schema: map[string]*Schema{ - "ingress": &Schema{ + "ingress": { Type: TypeSet, Required: true, Elem: &Resource{ Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeList, Optional: true, Elem: &Schema{Type: TypeInt}, @@ -1160,12 +1160,12 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "List of structure decode", Schema: map[string]*Schema{ - "ingress": &Schema{ + "ingress": { Type: TypeList, Required: true, Elem: &Resource{ Schema: map[string]*Schema{ - "from": &Schema{ + "from": { Type: TypeInt, Required: true, }, @@ -1186,11 +1186,11 @@ func TestSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "ingress.#": &terraform.ResourceAttrDiff{ + "ingress.#": { Old: "0", New: "1", }, - "ingress.0.from": &terraform.ResourceAttrDiff{ + "ingress.0.from": { Old: "", New: "8080", }, @@ -1203,13 +1203,13 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "ComputedWhen", Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Computed: true, ComputedWhen: []string{"port"}, }, - "port": &Schema{ + "port": { Type: TypeInt, Optional: true, }, @@ -1234,13 +1234,13 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "", Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Computed: true, ComputedWhen: []string{"port"}, }, - "port": &Schema{ + "port": { Type: TypeInt, Optional: true, }, @@ -1258,7 +1258,7 @@ func TestSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "availability_zone": &terraform.ResourceAttrDiff{ + "availability_zone": { NewComputed: true, }, }, @@ -1313,7 +1313,7 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "Maps", Schema: map[string]*Schema{ - "config_vars": &Schema{ + "config_vars": { Type: TypeMap, }, }, @@ -1330,12 +1330,12 @@ func TestSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "config_vars.%": &terraform.ResourceAttrDiff{ + "config_vars.%": { Old: "0", New: "1", }, - "config_vars.bar": &terraform.ResourceAttrDiff{ + "config_vars.bar": { Old: "", New: "baz", }, @@ -1348,7 +1348,7 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "Maps", Schema: map[string]*Schema{ - "config_vars": &Schema{ + "config_vars": { Type: TypeMap, }, }, @@ -1369,11 +1369,11 @@ func TestSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "config_vars.foo": &terraform.ResourceAttrDiff{ + "config_vars.foo": { Old: "bar", NewRemoved: true, }, - "config_vars.bar": &terraform.ResourceAttrDiff{ + "config_vars.bar": { Old: "", New: "baz", }, @@ -1386,7 +1386,7 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "Maps", Schema: map[string]*Schema{ - "vars": &Schema{ + "vars": { Type: TypeMap, Optional: true, Computed: true, @@ -1409,12 +1409,12 @@ func TestSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "vars.foo": &terraform.ResourceAttrDiff{ + "vars.foo": { Old: "bar", New: "", NewRemoved: true, }, - "vars.bar": &terraform.ResourceAttrDiff{ + "vars.bar": { Old: "", New: "baz", }, @@ -1427,7 +1427,7 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "Maps", Schema: map[string]*Schema{ - "vars": &Schema{ + "vars": { Type: TypeMap, Computed: true, }, @@ -1449,7 +1449,7 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "Maps", Schema: map[string]*Schema{ - "config_vars": &Schema{ + "config_vars": { Type: TypeList, Elem: &Schema{Type: TypeMap}, }, @@ -1472,11 +1472,11 @@ func TestSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "config_vars.0.foo": &terraform.ResourceAttrDiff{ + "config_vars.0.foo": { Old: "bar", NewRemoved: true, }, - "config_vars.0.bar": &terraform.ResourceAttrDiff{ + "config_vars.0.bar": { Old: "", New: "baz", }, @@ -1489,7 +1489,7 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "Maps", Schema: map[string]*Schema{ - "config_vars": &Schema{ + "config_vars": { Type: TypeList, Elem: &Schema{Type: TypeMap}, }, @@ -1507,19 +1507,19 @@ func TestSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "config_vars.#": &terraform.ResourceAttrDiff{ + "config_vars.#": { Old: "1", New: "0", }, - "config_vars.0.%": &terraform.ResourceAttrDiff{ + "config_vars.0.%": { Old: "2", New: "0", }, - "config_vars.0.foo": &terraform.ResourceAttrDiff{ + "config_vars.0.foo": { Old: "bar", NewRemoved: true, }, - "config_vars.0.bar": &terraform.ResourceAttrDiff{ + "config_vars.0.bar": { Old: "baz", NewRemoved: true, }, @@ -1532,13 +1532,13 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "ForceNews", Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Optional: true, ForceNew: true, }, - "address": &Schema{ + "address": { Type: TypeString, Optional: true, Computed: true, @@ -1558,13 +1558,13 @@ func TestSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "availability_zone": &terraform.ResourceAttrDiff{ + "availability_zone": { Old: "bar", New: "foo", RequiresNew: true, }, - "address": &terraform.ResourceAttrDiff{ + "address": { Old: "foo", New: "", NewComputed: true, @@ -1578,13 +1578,13 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "Set", Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Optional: true, ForceNew: true, }, - "ports": &Schema{ + "ports": { Type: TypeSet, Optional: true, Computed: true, @@ -1609,13 +1609,13 @@ func TestSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "availability_zone": &terraform.ResourceAttrDiff{ + "availability_zone": { Old: "bar", New: "foo", RequiresNew: true, }, - "ports.#": &terraform.ResourceAttrDiff{ + "ports.#": { Old: "1", New: "", NewComputed: true, @@ -1629,7 +1629,7 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "Set", Schema: map[string]*Schema{ - "instances": &Schema{ + "instances": { Type: TypeSet, Elem: &Schema{Type: TypeString}, Optional: true, @@ -1652,7 +1652,7 @@ func TestSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "instances.#": &terraform.ResourceAttrDiff{ + "instances.#": { NewComputed: true, }, }, @@ -1664,17 +1664,17 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "Set", Schema: map[string]*Schema{ - "route": &Schema{ + "route": { Type: TypeSet, Optional: true, Elem: &Resource{ Schema: map[string]*Schema{ - "index": &Schema{ + "index": { Type: TypeInt, Required: true, }, - "gateway": &Schema{ + "gateway": { Type: TypeString, Optional: true, }, @@ -1700,15 +1700,15 @@ func TestSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "route.#": &terraform.ResourceAttrDiff{ + "route.#": { Old: "0", New: "1", }, - "route.~1.index": &terraform.ResourceAttrDiff{ + "route.~1.index": { Old: "", New: "1", }, - "route.~1.gateway": &terraform.ResourceAttrDiff{ + "route.~1.gateway": { Old: "", New: hcl2shim.UnknownVariableValue, NewComputed: true, @@ -1722,17 +1722,17 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "Set", Schema: map[string]*Schema{ - "route": &Schema{ + "route": { Type: TypeSet, Optional: true, Elem: &Resource{ Schema: map[string]*Schema{ - "index": &Schema{ + "index": { Type: TypeInt, Required: true, }, - "gateway": &Schema{ + "gateway": { Type: TypeSet, Optional: true, Elem: &Schema{Type: TypeInt}, @@ -1764,15 +1764,15 @@ func TestSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "route.#": &terraform.ResourceAttrDiff{ + "route.#": { Old: "0", New: "1", }, - "route.~1.index": &terraform.ResourceAttrDiff{ + "route.~1.index": { Old: "", New: "1", }, - "route.~1.gateway.#": &terraform.ResourceAttrDiff{ + "route.~1.gateway.#": { NewComputed: true, }, }, @@ -1784,7 +1784,7 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "Computed maps", Schema: map[string]*Schema{ - "vars": &Schema{ + "vars": { Type: TypeMap, Computed: true, }, @@ -1796,7 +1796,7 @@ func TestSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "vars.%": &terraform.ResourceAttrDiff{ + "vars.%": { Old: "", NewComputed: true, }, @@ -1809,7 +1809,7 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "Computed maps", Schema: map[string]*Schema{ - "vars": &Schema{ + "vars": { Type: TypeMap, Computed: true, }, @@ -1829,7 +1829,7 @@ func TestSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "vars.%": &terraform.ResourceAttrDiff{ + "vars.%": { Old: "", NewComputed: true, }, @@ -1855,7 +1855,7 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "Float", Schema: map[string]*Schema{ - "some_threshold": &Schema{ + "some_threshold": { Type: TypeFloat, }, }, @@ -1872,7 +1872,7 @@ func TestSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "some_threshold": &terraform.ResourceAttrDiff{ + "some_threshold": { Old: "567.8", New: "12.34", }, @@ -1885,17 +1885,17 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "https://github.com/hashicorp/terraform-plugin-sdk/issues/824", Schema: map[string]*Schema{ - "block_device": &Schema{ + "block_device": { Type: TypeSet, Optional: true, Computed: true, Elem: &Resource{ Schema: map[string]*Schema{ - "device_name": &Schema{ + "device_name": { Type: TypeString, Required: true, }, - "delete_on_termination": &Schema{ + "delete_on_termination": { Type: TypeBool, Optional: true, Default: true, @@ -1939,7 +1939,7 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "Zero value in state shouldn't result in diff", Schema: map[string]*Schema{ - "port": &Schema{ + "port": { Type: TypeBool, Optional: true, ForceNew: true, @@ -1962,17 +1962,17 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "Same as prev, but for sets", Schema: map[string]*Schema{ - "route": &Schema{ + "route": { Type: TypeSet, Optional: true, Elem: &Resource{ Schema: map[string]*Schema{ - "index": &Schema{ + "index": { Type: TypeInt, Required: true, }, - "gateway": &Schema{ + "gateway": { Type: TypeSet, Optional: true, Elem: &Schema{Type: TypeInt}, @@ -2005,7 +2005,7 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "A set computed element shouldn't cause a diff", Schema: map[string]*Schema{ - "active": &Schema{ + "active": { Type: TypeBool, Computed: true, ForceNew: true, @@ -2028,7 +2028,7 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "An empty set should show up in the diff", Schema: map[string]*Schema{ - "instances": &Schema{ + "instances": { Type: TypeSet, Elem: &Schema{Type: TypeString}, Optional: true, @@ -2050,12 +2050,12 @@ func TestSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "instances.#": &terraform.ResourceAttrDiff{ + "instances.#": { Old: "1", New: "0", RequiresNew: true, }, - "instances.3": &terraform.ResourceAttrDiff{ + "instances.3": { Old: "foo", New: "", NewRemoved: true, @@ -2070,7 +2070,7 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "Map with empty value", Schema: map[string]*Schema{ - "vars": &Schema{ + "vars": { Type: TypeMap, }, }, @@ -2085,11 +2085,11 @@ func TestSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "vars.%": &terraform.ResourceAttrDiff{ + "vars.%": { Old: "0", New: "1", }, - "vars.foo": &terraform.ResourceAttrDiff{ + "vars.foo": { Old: "", New: "", }, @@ -2102,7 +2102,7 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "Unset bool, not in state", Schema: map[string]*Schema{ - "force": &Schema{ + "force": { Type: TypeBool, Optional: true, ForceNew: true, @@ -2121,7 +2121,7 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "Unset set, not in state", Schema: map[string]*Schema{ - "metadata_keys": &Schema{ + "metadata_keys": { Type: TypeSet, Optional: true, ForceNew: true, @@ -2142,7 +2142,7 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "Unset list in state, should not show up computed", Schema: map[string]*Schema{ - "metadata_keys": &Schema{ + "metadata_keys": { Type: TypeList, Optional: true, Computed: true, @@ -2167,7 +2167,7 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "Set element computed element", Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeSet, Required: true, Elem: &Schema{Type: TypeInt}, @@ -2185,7 +2185,7 @@ func TestSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "ports.#": &terraform.ResourceAttrDiff{ + "ports.#": { Old: "", New: "", NewComputed: true, @@ -2199,7 +2199,7 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "Computed map without config that's known to be empty does not generate diff", Schema: map[string]*Schema{ - "tags": &Schema{ + "tags": { Type: TypeMap, Computed: true, }, @@ -2221,17 +2221,17 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "Set with hyphen keys", Schema: map[string]*Schema{ - "route": &Schema{ + "route": { Type: TypeSet, Optional: true, Elem: &Resource{ Schema: map[string]*Schema{ - "index": &Schema{ + "index": { Type: TypeInt, Required: true, }, - "gateway-name": &Schema{ + "gateway-name": { Type: TypeString, Optional: true, }, @@ -2257,15 +2257,15 @@ func TestSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "route.#": &terraform.ResourceAttrDiff{ + "route.#": { Old: "0", New: "1", }, - "route.1.index": &terraform.ResourceAttrDiff{ + "route.1.index": { Old: "", New: "1", }, - "route.1.gateway-name": &terraform.ResourceAttrDiff{ + "route.1.gateway-name": { Old: "", New: "hello", }, @@ -2278,13 +2278,13 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: ": StateFunc in nested set (#1759)", Schema: map[string]*Schema{ - "service_account": &Schema{ + "service_account": { Type: TypeList, Optional: true, ForceNew: true, Elem: &Resource{ Schema: map[string]*Schema{ - "scopes": &Schema{ + "scopes": { Type: TypeSet, Required: true, ForceNew: true, @@ -2319,17 +2319,17 @@ func TestSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "service_account.#": &terraform.ResourceAttrDiff{ + "service_account.#": { Old: "0", New: "1", RequiresNew: true, }, - "service_account.0.scopes.#": &terraform.ResourceAttrDiff{ + "service_account.0.scopes.#": { Old: "0", New: "1", RequiresNew: true, }, - "service_account.0.scopes.123": &terraform.ResourceAttrDiff{ + "service_account.0.scopes.123": { Old: "", New: "123!", NewExtra: "123", @@ -2344,7 +2344,7 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "Removing set elements", Schema: map[string]*Schema{ - "instances": &Schema{ + "instances": { Type: TypeSet, Elem: &Schema{Type: TypeString}, Optional: true, @@ -2369,21 +2369,21 @@ func TestSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "instances.#": &terraform.ResourceAttrDiff{ + "instances.#": { Old: "2", New: "2", }, - "instances.2": &terraform.ResourceAttrDiff{ + "instances.2": { Old: "22", New: "", NewRemoved: true, RequiresNew: true, }, - "instances.3": &terraform.ResourceAttrDiff{ + "instances.3": { Old: "333", New: "333", }, - "instances.4": &terraform.ResourceAttrDiff{ + "instances.4": { Old: "", New: "4444", RequiresNew: true, @@ -2397,15 +2397,15 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "Bools can be set with 0/1 in config, still get true/false", Schema: map[string]*Schema{ - "one": &Schema{ + "one": { Type: TypeBool, Optional: true, }, - "two": &Schema{ + "two": { Type: TypeBool, Optional: true, }, - "three": &Schema{ + "three": { Type: TypeBool, Optional: true, }, @@ -2426,15 +2426,15 @@ func TestSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "one": &terraform.ResourceAttrDiff{ + "one": { Old: "false", New: "true", }, - "two": &terraform.ResourceAttrDiff{ + "two": { Old: "true", New: "false", }, - "three": &terraform.ResourceAttrDiff{ + "three": { Old: "true", New: "false", NewRemoved: true, @@ -2469,7 +2469,7 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "Set ForceNew only marks the changing element as ForceNew", Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeSet, Required: true, ForceNew: true, @@ -2495,24 +2495,24 @@ func TestSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "ports.#": &terraform.ResourceAttrDiff{ + "ports.#": { Old: "3", New: "3", }, - "ports.1": &terraform.ResourceAttrDiff{ + "ports.1": { Old: "1", New: "1", }, - "ports.2": &terraform.ResourceAttrDiff{ + "ports.2": { Old: "2", New: "2", }, - "ports.5": &terraform.ResourceAttrDiff{ + "ports.5": { Old: "", New: "5", RequiresNew: true, }, - "ports.4": &terraform.ResourceAttrDiff{ + "ports.4": { Old: "4", New: "0", NewRemoved: true, @@ -2525,7 +2525,7 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "removed optional items should trigger ForceNew", Schema: map[string]*Schema{ - "description": &Schema{ + "description": { Type: TypeString, ForceNew: true, Optional: true, @@ -2542,7 +2542,7 @@ func TestSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "description": &terraform.ResourceAttrDiff{ + "description": { Old: "foo", New: "", RequiresNew: true, @@ -2558,7 +2558,7 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "computed value for boolean field", Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeBool, ForceNew: true, Computed: true, @@ -2574,7 +2574,7 @@ func TestSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "foo": &terraform.ResourceAttrDiff{ + "foo": { Old: "", New: "false", NewComputed: true, @@ -2589,7 +2589,7 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "Set ForceNew marks count as ForceNew if computed", Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeSet, Required: true, ForceNew: true, @@ -2615,7 +2615,7 @@ func TestSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "ports.#": &terraform.ResourceAttrDiff{ + "ports.#": { Old: "3", New: "", NewComputed: true, @@ -2628,7 +2628,7 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "List with computed schema and ForceNew", Schema: map[string]*Schema{ - "config": &Schema{ + "config": { Type: TypeList, Optional: true, ForceNew: true, @@ -2652,7 +2652,7 @@ func TestSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "config.#": &terraform.ResourceAttrDiff{ + "config.#": { Old: "2", New: "", RequiresNew: true, @@ -2667,7 +2667,7 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "overridden diff with a CustomizeDiff function, ForceNew not in schema", Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Optional: true, Computed: true, @@ -2692,7 +2692,7 @@ func TestSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "availability_zone": &terraform.ResourceAttrDiff{ + "availability_zone": { Old: "", New: "bar", RequiresNew: true, @@ -2710,7 +2710,7 @@ func TestSchemaMap_Diff(t *testing.T) { // intended diff still shows up. Name: "overridden removed attribute diff with a CustomizeDiff function, ForceNew not in schema", Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Optional: true, Computed: true, @@ -2733,7 +2733,7 @@ func TestSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "availability_zone": &terraform.ResourceAttrDiff{ + "availability_zone": { Old: "", New: "bar", RequiresNew: true, @@ -2748,7 +2748,7 @@ func TestSchemaMap_Diff(t *testing.T) { Name: "overridden diff with a CustomizeDiff function, ForceNew in schema", Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Optional: true, Computed: true, @@ -2771,7 +2771,7 @@ func TestSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "availability_zone": &terraform.ResourceAttrDiff{ + "availability_zone": { Old: "", New: "bar", RequiresNew: true, @@ -2785,11 +2785,11 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "required field with computed diff added with CustomizeDiff function", Schema: map[string]*Schema{ - "ami_id": &Schema{ + "ami_id": { Type: TypeString, Required: true, }, - "instance_id": &Schema{ + "instance_id": { Type: TypeString, Computed: true, }, @@ -2810,11 +2810,11 @@ func TestSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "ami_id": &terraform.ResourceAttrDiff{ + "ami_id": { Old: "", New: "foo", }, - "instance_id": &terraform.ResourceAttrDiff{ + "instance_id": { Old: "", New: "bar", }, @@ -2827,7 +2827,7 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "Set ForceNew only marks the changing element as ForceNew - CustomizeDiffFunc edition", Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeSet, Optional: true, Computed: true, @@ -2863,24 +2863,24 @@ func TestSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "ports.#": &terraform.ResourceAttrDiff{ + "ports.#": { Old: "3", New: "3", }, - "ports.1": &terraform.ResourceAttrDiff{ + "ports.1": { Old: "1", New: "1", }, - "ports.2": &terraform.ResourceAttrDiff{ + "ports.2": { Old: "2", New: "2", }, - "ports.5": &terraform.ResourceAttrDiff{ + "ports.5": { Old: "", New: "5", RequiresNew: true, }, - "ports.4": &terraform.ResourceAttrDiff{ + "ports.4": { Old: "4", New: "0", NewRemoved: true, @@ -2918,12 +2918,12 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "NewComputed based on a conditional with CustomizeDiffFunc", Schema: map[string]*Schema{ - "etag": &Schema{ + "etag": { Type: TypeString, Optional: true, Computed: true, }, - "version_id": &Schema{ + "version_id": { Type: TypeString, Computed: true, }, @@ -2949,11 +2949,11 @@ func TestSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "etag": &terraform.ResourceAttrDiff{ + "etag": { Old: "foo", New: "bar", }, - "version_id": &terraform.ResourceAttrDiff{ + "version_id": { Old: "1", New: "", NewComputed: true, @@ -2967,7 +2967,7 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "NewComputed should always propagate with CustomizeDiff", Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeString, Computed: true, }, @@ -2989,7 +2989,7 @@ func TestSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "foo": &terraform.ResourceAttrDiff{ + "foo": { NewComputed: true, }, }, @@ -3001,7 +3001,7 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "vetoing a diff", Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeString, Optional: true, Computed: true, @@ -3032,7 +3032,7 @@ func TestSchemaMap_Diff(t *testing.T) { { Name: "optional, computed, empty string", Schema: map[string]*Schema{ - "attr": &Schema{ + "attr": { Type: TypeString, Optional: true, Computed: true, @@ -3126,7 +3126,7 @@ func TestSchemaMap_InternalValidate(t *testing.T) { "Both optional and required": { map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeInt, Optional: true, Required: true, @@ -3137,7 +3137,7 @@ func TestSchemaMap_InternalValidate(t *testing.T) { "No optional and no required": { map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeInt, }, }, @@ -3146,7 +3146,7 @@ func TestSchemaMap_InternalValidate(t *testing.T) { "Missing Type": { map[string]*Schema{ - "foo": &Schema{ + "foo": { Required: true, }, }, @@ -3155,7 +3155,7 @@ func TestSchemaMap_InternalValidate(t *testing.T) { "Required but computed": { map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeInt, Required: true, Computed: true, @@ -3166,7 +3166,7 @@ func TestSchemaMap_InternalValidate(t *testing.T) { "Looks good": { map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeString, Required: true, }, @@ -3176,7 +3176,7 @@ func TestSchemaMap_InternalValidate(t *testing.T) { "Computed but has default": { map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeInt, Optional: true, Computed: true, @@ -3188,7 +3188,7 @@ func TestSchemaMap_InternalValidate(t *testing.T) { "Required but has default": { map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeInt, Optional: true, Required: true, @@ -3200,7 +3200,7 @@ func TestSchemaMap_InternalValidate(t *testing.T) { "List element not set": { map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeList, }, }, @@ -3209,7 +3209,7 @@ func TestSchemaMap_InternalValidate(t *testing.T) { "List default": { map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeList, Elem: &Schema{Type: TypeInt}, Default: "foo", @@ -3220,7 +3220,7 @@ func TestSchemaMap_InternalValidate(t *testing.T) { "List element computed": { map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeList, Optional: true, Elem: &Schema{ @@ -3234,7 +3234,7 @@ func TestSchemaMap_InternalValidate(t *testing.T) { "List element with Set set": { map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeList, Elem: &Schema{Type: TypeInt}, Set: func(interface{}) int { return 0 }, @@ -3246,7 +3246,7 @@ func TestSchemaMap_InternalValidate(t *testing.T) { "Set element with no Set set": { map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeSet, Elem: &Schema{Type: TypeInt}, Optional: true, @@ -3257,7 +3257,7 @@ func TestSchemaMap_InternalValidate(t *testing.T) { "Required but computedWhen": { map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeInt, Required: true, ComputedWhen: []string{"foo"}, @@ -3268,11 +3268,11 @@ func TestSchemaMap_InternalValidate(t *testing.T) { "Conflicting attributes cannot be required": { map[string]*Schema{ - "blacklist": &Schema{ + "blacklist": { Type: TypeBool, Required: true, }, - "whitelist": &Schema{ + "whitelist": { Type: TypeBool, Optional: true, ConflictsWith: []string{"blacklist"}, @@ -3283,7 +3283,7 @@ func TestSchemaMap_InternalValidate(t *testing.T) { "Attribute with conflicts cannot be required": { map[string]*Schema{ - "whitelist": &Schema{ + "whitelist": { Type: TypeBool, Required: true, ConflictsWith: []string{"blacklist"}, @@ -3294,11 +3294,11 @@ func TestSchemaMap_InternalValidate(t *testing.T) { "ConflictsWith cannot be used w/ ComputedWhen": { map[string]*Schema{ - "blacklist": &Schema{ + "blacklist": { Type: TypeBool, ComputedWhen: []string{"foor"}, }, - "whitelist": &Schema{ + "whitelist": { Type: TypeBool, Required: true, ConflictsWith: []string{"blacklist"}, @@ -3309,7 +3309,7 @@ func TestSchemaMap_InternalValidate(t *testing.T) { "Sub-resource invalid": { map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeList, Optional: true, Elem: &Resource{ @@ -3324,12 +3324,12 @@ func TestSchemaMap_InternalValidate(t *testing.T) { "Sub-resource valid": { map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeList, Optional: true, Elem: &Resource{ Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeInt, Optional: true, }, @@ -3342,7 +3342,7 @@ func TestSchemaMap_InternalValidate(t *testing.T) { "ValidateFunc on non-primitive": { map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeSet, Required: true, ValidateFunc: func(v interface{}, k string) (ws []string, es []error) { @@ -3355,7 +3355,7 @@ func TestSchemaMap_InternalValidate(t *testing.T) { "Computed-only with AtLeastOneOf": { map[string]*Schema{ - "string_one": &Schema{ + "string_one": { Type: TypeString, Computed: true, AtLeastOneOf: []string{ @@ -3363,7 +3363,7 @@ func TestSchemaMap_InternalValidate(t *testing.T) { "string_two", }, }, - "string_two": &Schema{ + "string_two": { Type: TypeString, Computed: true, AtLeastOneOf: []string{ @@ -3377,14 +3377,14 @@ func TestSchemaMap_InternalValidate(t *testing.T) { "Computed-only with ConflictsWith": { map[string]*Schema{ - "string_one": &Schema{ + "string_one": { Type: TypeString, Computed: true, ConflictsWith: []string{ "string_two", }, }, - "string_two": &Schema{ + "string_two": { Type: TypeString, Computed: true, ConflictsWith: []string{ @@ -3397,7 +3397,7 @@ func TestSchemaMap_InternalValidate(t *testing.T) { "Computed-only with Default": { map[string]*Schema{ - "string": &Schema{ + "string": { Type: TypeString, Computed: true, Default: "test", @@ -3408,7 +3408,7 @@ func TestSchemaMap_InternalValidate(t *testing.T) { "Computed-only with DefaultFunc": { map[string]*Schema{ - "string": &Schema{ + "string": { Type: TypeString, Computed: true, DefaultFunc: func() (interface{}, error) { return nil, nil }, @@ -3419,7 +3419,7 @@ func TestSchemaMap_InternalValidate(t *testing.T) { "Computed-only with DiffSuppressFunc": { map[string]*Schema{ - "string": &Schema{ + "string": { Type: TypeString, Computed: true, DiffSuppressFunc: func(k, old, new string, d *ResourceData) bool { return false }, @@ -3430,7 +3430,7 @@ func TestSchemaMap_InternalValidate(t *testing.T) { "Computed-only with ExactlyOneOf": { map[string]*Schema{ - "string_one": &Schema{ + "string_one": { Type: TypeString, Computed: true, ExactlyOneOf: []string{ @@ -3438,7 +3438,7 @@ func TestSchemaMap_InternalValidate(t *testing.T) { "string_two", }, }, - "string_two": &Schema{ + "string_two": { Type: TypeString, Computed: true, ExactlyOneOf: []string{ @@ -3452,7 +3452,7 @@ func TestSchemaMap_InternalValidate(t *testing.T) { "Computed-only with InputDefault": { map[string]*Schema{ - "string": &Schema{ + "string": { Type: TypeString, Computed: true, InputDefault: "test", @@ -3463,7 +3463,7 @@ func TestSchemaMap_InternalValidate(t *testing.T) { "Computed-only with MaxItems": { map[string]*Schema{ - "string": &Schema{ + "string": { Type: TypeList, Elem: &Schema{Type: TypeString}, Computed: true, @@ -3475,7 +3475,7 @@ func TestSchemaMap_InternalValidate(t *testing.T) { "Computed-only with MinItems": { map[string]*Schema{ - "string": &Schema{ + "string": { Type: TypeList, Elem: &Schema{Type: TypeString}, Computed: true, @@ -3487,7 +3487,7 @@ func TestSchemaMap_InternalValidate(t *testing.T) { "Computed-only with StateFunc": { map[string]*Schema{ - "string": &Schema{ + "string": { Type: TypeString, Computed: true, StateFunc: func(v interface{}) string { return "" }, @@ -3498,7 +3498,7 @@ func TestSchemaMap_InternalValidate(t *testing.T) { "Computed-only with ValidateFunc": { map[string]*Schema{ - "string": &Schema{ + "string": { Type: TypeString, Computed: true, ValidateFunc: func(v interface{}, k string) ([]string, []error) { return nil, nil }, @@ -3509,7 +3509,7 @@ func TestSchemaMap_InternalValidate(t *testing.T) { "invalid field name format #1": { map[string]*Schema{ - "with space": &Schema{ + "with space": { Type: TypeString, Optional: true, }, @@ -3519,7 +3519,7 @@ func TestSchemaMap_InternalValidate(t *testing.T) { "invalid field name format #2": { map[string]*Schema{ - "WithCapitals": &Schema{ + "WithCapitals": { Type: TypeString, Optional: true, }, @@ -3529,7 +3529,7 @@ func TestSchemaMap_InternalValidate(t *testing.T) { "invalid field name format of a Deprecated field": { map[string]*Schema{ - "WithCapitals": &Schema{ + "WithCapitals": { Type: TypeString, Optional: true, Deprecated: "Use with_underscores instead", @@ -3540,7 +3540,7 @@ func TestSchemaMap_InternalValidate(t *testing.T) { "invalid field name format of a Removed field": { map[string]*Schema{ - "WithCapitals": &Schema{ + "WithCapitals": { Type: TypeString, Optional: true, Removed: "Use with_underscores instead", @@ -3551,7 +3551,7 @@ func TestSchemaMap_InternalValidate(t *testing.T) { "ConfigModeBlock with Elem *Resource": { map[string]*Schema{ - "block": &Schema{ + "block": { Type: TypeList, ConfigMode: SchemaConfigModeBlock, Optional: true, @@ -3563,7 +3563,7 @@ func TestSchemaMap_InternalValidate(t *testing.T) { "ConfigModeBlock Computed with Elem *Resource": { map[string]*Schema{ - "block": &Schema{ + "block": { Type: TypeList, ConfigMode: SchemaConfigModeBlock, Computed: true, @@ -3575,7 +3575,7 @@ func TestSchemaMap_InternalValidate(t *testing.T) { "ConfigModeBlock with Elem *Schema": { map[string]*Schema{ - "block": &Schema{ + "block": { Type: TypeList, ConfigMode: SchemaConfigModeBlock, Optional: true, @@ -3589,7 +3589,7 @@ func TestSchemaMap_InternalValidate(t *testing.T) { "ConfigModeBlock with no Elem": { map[string]*Schema{ - "block": &Schema{ + "block": { Type: TypeString, ConfigMode: SchemaConfigModeBlock, Optional: true, @@ -3600,13 +3600,13 @@ func TestSchemaMap_InternalValidate(t *testing.T) { "ConfigModeBlock inside ConfigModeAttr": { map[string]*Schema{ - "block": &Schema{ + "block": { Type: TypeList, ConfigMode: SchemaConfigModeAttr, Optional: true, Elem: &Resource{ Schema: map[string]*Schema{ - "sub": &Schema{ + "sub": { Type: TypeList, ConfigMode: SchemaConfigModeBlock, Elem: &Resource{}, @@ -3620,13 +3620,13 @@ func TestSchemaMap_InternalValidate(t *testing.T) { "ConfigModeAuto with *Resource inside ConfigModeAttr": { map[string]*Schema{ - "block": &Schema{ + "block": { Type: TypeList, ConfigMode: SchemaConfigModeAttr, Optional: true, Elem: &Resource{ Schema: map[string]*Schema{ - "sub": &Schema{ + "sub": { Type: TypeList, Elem: &Resource{}, }, @@ -3639,12 +3639,12 @@ func TestSchemaMap_InternalValidate(t *testing.T) { "TypeMap with Elem *Resource": { map[string]*Schema{ - "map": &Schema{ + "map": { Type: TypeMap, Optional: true, Elem: &Resource{ Schema: map[string]*Schema{ - "keynothandled": &Schema{ + "keynothandled": { Type: TypeString, Optional: true, }, @@ -3782,21 +3782,21 @@ func TestSchemaMap_DiffSuppress(t *testing.T) { "Complex structure with set of computed string should mark root set as computed": { Schema: map[string]*Schema{ - "outer": &Schema{ + "outer": { Type: TypeSet, Optional: true, Elem: &Resource{ Schema: map[string]*Schema{ - "outer_str": &Schema{ + "outer_str": { Type: TypeString, Optional: true, }, - "inner": &Schema{ + "inner": { Type: TypeSet, Optional: true, Elem: &Resource{ Schema: map[string]*Schema{ - "inner_str": &Schema{ + "inner_str": { Type: TypeString, Optional: true, }, @@ -3831,19 +3831,19 @@ func TestSchemaMap_DiffSuppress(t *testing.T) { ExpectedDiff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "outer.#": &terraform.ResourceAttrDiff{ + "outer.#": { Old: "0", New: "1", }, - "outer.~1.outer_str": &terraform.ResourceAttrDiff{ + "outer.~1.outer_str": { Old: "", New: "foo", }, - "outer.~1.inner.#": &terraform.ResourceAttrDiff{ + "outer.~1.inner.#": { Old: "0", New: "1", }, - "outer.~1.inner.~2.inner_str": &terraform.ResourceAttrDiff{ + "outer.~1.inner.~2.inner_str": { Old: "", New: hcl2shim.UnknownVariableValue, NewComputed: true, @@ -3856,21 +3856,21 @@ func TestSchemaMap_DiffSuppress(t *testing.T) { "Complex structure with complex list of computed string should mark root set as computed": { Schema: map[string]*Schema{ - "outer": &Schema{ + "outer": { Type: TypeSet, Optional: true, Elem: &Resource{ Schema: map[string]*Schema{ - "outer_str": &Schema{ + "outer_str": { Type: TypeString, Optional: true, }, - "inner": &Schema{ + "inner": { Type: TypeList, Optional: true, Elem: &Resource{ Schema: map[string]*Schema{ - "inner_str": &Schema{ + "inner_str": { Type: TypeString, Optional: true, }, @@ -3902,19 +3902,19 @@ func TestSchemaMap_DiffSuppress(t *testing.T) { ExpectedDiff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "outer.#": &terraform.ResourceAttrDiff{ + "outer.#": { Old: "0", New: "1", }, - "outer.~1.outer_str": &terraform.ResourceAttrDiff{ + "outer.~1.outer_str": { Old: "", New: "foo", }, - "outer.~1.inner.#": &terraform.ResourceAttrDiff{ + "outer.~1.inner.#": { Old: "0", New: "1", }, - "outer.~1.inner.0.inner_str": &terraform.ResourceAttrDiff{ + "outer.~1.inner.0.inner_str": { Old: "", New: hcl2shim.UnknownVariableValue, NewComputed: true, @@ -3952,7 +3952,7 @@ func TestSchemaMap_Validate(t *testing.T) { }{ "Good": { Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Optional: true, Computed: true, @@ -3967,7 +3967,7 @@ func TestSchemaMap_Validate(t *testing.T) { "Good, because the var is not set and that error will come elsewhere": { Schema: map[string]*Schema{ - "size": &Schema{ + "size": { Type: TypeInt, Required: true, }, @@ -3980,7 +3980,7 @@ func TestSchemaMap_Validate(t *testing.T) { "Required field not set": { Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Required: true, }, @@ -3993,7 +3993,7 @@ func TestSchemaMap_Validate(t *testing.T) { "Invalid basic type": { Schema: map[string]*Schema{ - "port": &Schema{ + "port": { Type: TypeInt, Required: true, }, @@ -4008,7 +4008,7 @@ func TestSchemaMap_Validate(t *testing.T) { "Invalid complex type": { Schema: map[string]*Schema{ - "user_data": &Schema{ + "user_data": { Type: TypeString, Optional: true, }, @@ -4027,7 +4027,7 @@ func TestSchemaMap_Validate(t *testing.T) { "Bad type": { Schema: map[string]*Schema{ - "size": &Schema{ + "size": { Type: TypeInt, Required: true, }, @@ -4042,7 +4042,7 @@ func TestSchemaMap_Validate(t *testing.T) { "Required but has DefaultFunc": { Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Required: true, DefaultFunc: func() (interface{}, error) { @@ -4056,7 +4056,7 @@ func TestSchemaMap_Validate(t *testing.T) { "Required but has DefaultFunc return nil": { Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Required: true, DefaultFunc: func() (interface{}, error) { @@ -4072,11 +4072,11 @@ func TestSchemaMap_Validate(t *testing.T) { "Optional sub-resource": { Schema: map[string]*Schema{ - "ingress": &Schema{ + "ingress": { Type: TypeList, Elem: &Resource{ Schema: map[string]*Schema{ - "from": &Schema{ + "from": { Type: TypeInt, Required: true, }, @@ -4092,12 +4092,12 @@ func TestSchemaMap_Validate(t *testing.T) { "Sub-resource is the wrong type": { Schema: map[string]*Schema{ - "ingress": &Schema{ + "ingress": { Type: TypeList, Required: true, Elem: &Resource{ Schema: map[string]*Schema{ - "from": &Schema{ + "from": { Type: TypeInt, Required: true, }, @@ -4115,12 +4115,12 @@ func TestSchemaMap_Validate(t *testing.T) { "Not a list nested block": { Schema: map[string]*Schema{ - "ingress": &Schema{ + "ingress": { Type: TypeList, Optional: true, Elem: &Resource{ Schema: map[string]*Schema{ - "from": &Schema{ + "from": { Type: TypeInt, Required: true, }, @@ -4141,7 +4141,7 @@ func TestSchemaMap_Validate(t *testing.T) { "Not a list primitive": { Schema: map[string]*Schema{ - "strings": &Schema{ + "strings": { Type: TypeList, Optional: true, Elem: &Schema{ @@ -4162,7 +4162,7 @@ func TestSchemaMap_Validate(t *testing.T) { "Unknown list": { Schema: map[string]*Schema{ - "strings": &Schema{ + "strings": { Type: TypeList, Optional: true, Elem: &Schema{ @@ -4180,7 +4180,7 @@ func TestSchemaMap_Validate(t *testing.T) { "Unknown + Deprecation": { Schema: map[string]*Schema{ - "old_news": &Schema{ + "old_news": { Type: TypeString, Optional: true, Deprecated: "please use 'new_news' instead", @@ -4198,11 +4198,11 @@ func TestSchemaMap_Validate(t *testing.T) { "Required sub-resource field": { Schema: map[string]*Schema{ - "ingress": &Schema{ + "ingress": { Type: TypeList, Elem: &Resource{ Schema: map[string]*Schema{ - "from": &Schema{ + "from": { Type: TypeInt, Required: true, }, @@ -4222,12 +4222,12 @@ func TestSchemaMap_Validate(t *testing.T) { "Good sub-resource": { Schema: map[string]*Schema{ - "ingress": &Schema{ + "ingress": { Type: TypeList, Optional: true, Elem: &Resource{ Schema: map[string]*Schema{ - "from": &Schema{ + "from": { Type: TypeInt, Required: true, }, @@ -4249,12 +4249,12 @@ func TestSchemaMap_Validate(t *testing.T) { "Good sub-resource, computed value": { Schema: map[string]*Schema{ - "ingress": &Schema{ + "ingress": { Type: TypeList, Optional: true, Elem: &Resource{ Schema: map[string]*Schema{ - "from": &Schema{ + "from": { Type: TypeInt, Optional: true, }, @@ -4276,7 +4276,7 @@ func TestSchemaMap_Validate(t *testing.T) { "Invalid/unknown field": { Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Optional: true, Computed: true, @@ -4293,7 +4293,7 @@ func TestSchemaMap_Validate(t *testing.T) { "Invalid/unknown field with computed value": { Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Optional: true, Computed: true, @@ -4310,7 +4310,7 @@ func TestSchemaMap_Validate(t *testing.T) { "Computed field set": { Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Computed: true, }, @@ -4325,7 +4325,7 @@ func TestSchemaMap_Validate(t *testing.T) { "Not a set": { Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeSet, Required: true, Elem: &Schema{Type: TypeInt}, @@ -4344,7 +4344,7 @@ func TestSchemaMap_Validate(t *testing.T) { "Maps": { Schema: map[string]*Schema{ - "user_data": &Schema{ + "user_data": { Type: TypeMap, Optional: true, }, @@ -4359,7 +4359,7 @@ func TestSchemaMap_Validate(t *testing.T) { "Good map: data surrounded by extra slice": { Schema: map[string]*Schema{ - "user_data": &Schema{ + "user_data": { Type: TypeMap, Optional: true, }, @@ -4376,7 +4376,7 @@ func TestSchemaMap_Validate(t *testing.T) { "Good map": { Schema: map[string]*Schema{ - "user_data": &Schema{ + "user_data": { Type: TypeMap, Optional: true, }, @@ -4391,7 +4391,7 @@ func TestSchemaMap_Validate(t *testing.T) { "Map with type specified as value type": { Schema: map[string]*Schema{ - "user_data": &Schema{ + "user_data": { Type: TypeMap, Optional: true, Elem: TypeBool, @@ -4409,7 +4409,7 @@ func TestSchemaMap_Validate(t *testing.T) { "Map with type specified as nested Schema": { Schema: map[string]*Schema{ - "user_data": &Schema{ + "user_data": { Type: TypeMap, Optional: true, Elem: &Schema{Type: TypeBool}, @@ -4427,7 +4427,7 @@ func TestSchemaMap_Validate(t *testing.T) { "Bad map: just a slice": { Schema: map[string]*Schema{ - "user_data": &Schema{ + "user_data": { Type: TypeMap, Optional: true, }, @@ -4444,7 +4444,7 @@ func TestSchemaMap_Validate(t *testing.T) { "Good set: config has slice with single interpolated value": { Schema: map[string]*Schema{ - "security_groups": &Schema{ + "security_groups": { Type: TypeSet, Optional: true, Computed: true, @@ -4465,7 +4465,7 @@ func TestSchemaMap_Validate(t *testing.T) { "Bad set: config has single interpolated value": { Schema: map[string]*Schema{ - "security_groups": &Schema{ + "security_groups": { Type: TypeSet, Optional: true, Computed: true, @@ -4483,12 +4483,12 @@ func TestSchemaMap_Validate(t *testing.T) { "Bad, subresource should not allow unknown elements": { Schema: map[string]*Schema{ - "ingress": &Schema{ + "ingress": { Type: TypeList, Optional: true, Elem: &Resource{ Schema: map[string]*Schema{ - "port": &Schema{ + "port": { Type: TypeInt, Required: true, }, @@ -4511,12 +4511,12 @@ func TestSchemaMap_Validate(t *testing.T) { "Bad, subresource should not allow invalid types": { Schema: map[string]*Schema{ - "ingress": &Schema{ + "ingress": { Type: TypeList, Optional: true, Elem: &Resource{ Schema: map[string]*Schema{ - "port": &Schema{ + "port": { Type: TypeInt, Required: true, }, @@ -4538,7 +4538,7 @@ func TestSchemaMap_Validate(t *testing.T) { "Bad, should not allow lists to be assigned to string attributes": { Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Required: true, }, @@ -4553,7 +4553,7 @@ func TestSchemaMap_Validate(t *testing.T) { "Bad, should not allow maps to be assigned to string attributes": { Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Required: true, }, @@ -4568,7 +4568,7 @@ func TestSchemaMap_Validate(t *testing.T) { "Deprecated attribute usage generates warning, but not error": { Schema: map[string]*Schema{ - "old_news": &Schema{ + "old_news": { Type: TypeString, Optional: true, Deprecated: "please use 'new_news' instead", @@ -4588,7 +4588,7 @@ func TestSchemaMap_Validate(t *testing.T) { "Deprecated generates no warnings if attr not used": { Schema: map[string]*Schema{ - "old_news": &Schema{ + "old_news": { Type: TypeString, Optional: true, Deprecated: "please use 'new_news' instead", @@ -4602,7 +4602,7 @@ func TestSchemaMap_Validate(t *testing.T) { "Removed attribute usage generates error": { Schema: map[string]*Schema{ - "long_gone": &Schema{ + "long_gone": { Type: TypeString, Optional: true, Removed: "no longer supported by Cloud API", @@ -4621,7 +4621,7 @@ func TestSchemaMap_Validate(t *testing.T) { "Removed generates no errors if attr not used": { Schema: map[string]*Schema{ - "long_gone": &Schema{ + "long_gone": { Type: TypeString, Optional: true, Removed: "no longer supported by Cloud API", @@ -4633,11 +4633,11 @@ func TestSchemaMap_Validate(t *testing.T) { "Conflicting attributes generate error": { Schema: map[string]*Schema{ - "whitelist": &Schema{ + "whitelist": { Type: TypeString, Optional: true, }, - "blacklist": &Schema{ + "blacklist": { Type: TypeString, Optional: true, ConflictsWith: []string{"whitelist"}, @@ -4657,11 +4657,11 @@ func TestSchemaMap_Validate(t *testing.T) { "Conflicting attributes okay when unknown 1": { Schema: map[string]*Schema{ - "whitelist": &Schema{ + "whitelist": { Type: TypeString, Optional: true, }, - "blacklist": &Schema{ + "blacklist": { Type: TypeString, Optional: true, ConflictsWith: []string{"whitelist"}, @@ -4678,12 +4678,12 @@ func TestSchemaMap_Validate(t *testing.T) { "Conflicting list attributes okay when unknown 1": { Schema: map[string]*Schema{ - "whitelist": &Schema{ + "whitelist": { Type: TypeList, Optional: true, Elem: &Schema{Type: TypeString}, }, - "blacklist": &Schema{ + "blacklist": { Type: TypeList, Optional: true, Elem: &Schema{Type: TypeString}, @@ -4701,11 +4701,11 @@ func TestSchemaMap_Validate(t *testing.T) { "Conflicting attributes okay when unknown 2": { Schema: map[string]*Schema{ - "whitelist": &Schema{ + "whitelist": { Type: TypeString, Optional: true, }, - "blacklist": &Schema{ + "blacklist": { Type: TypeString, Optional: true, ConflictsWith: []string{"whitelist"}, @@ -4722,17 +4722,17 @@ func TestSchemaMap_Validate(t *testing.T) { "Conflicting attributes generate error even if one is unknown": { Schema: map[string]*Schema{ - "whitelist": &Schema{ + "whitelist": { Type: TypeString, Optional: true, ConflictsWith: []string{"blacklist", "greenlist"}, }, - "blacklist": &Schema{ + "blacklist": { Type: TypeString, Optional: true, ConflictsWith: []string{"whitelist", "greenlist"}, }, - "greenlist": &Schema{ + "greenlist": { Type: TypeString, Optional: true, ConflictsWith: []string{"whitelist", "blacklist"}, @@ -4754,11 +4754,11 @@ func TestSchemaMap_Validate(t *testing.T) { "Required attribute & undefined conflicting optional are good": { Schema: map[string]*Schema{ - "required_att": &Schema{ + "required_att": { Type: TypeString, Required: true, }, - "optional_att": &Schema{ + "optional_att": { Type: TypeString, Optional: true, ConflictsWith: []string{"required_att"}, @@ -4774,11 +4774,11 @@ func TestSchemaMap_Validate(t *testing.T) { "Required conflicting attribute & defined optional generate error": { Schema: map[string]*Schema{ - "required_att": &Schema{ + "required_att": { Type: TypeString, Required: true, }, - "optional_att": &Schema{ + "optional_att": { Type: TypeString, Optional: true, ConflictsWith: []string{"required_att"}, @@ -4798,13 +4798,13 @@ func TestSchemaMap_Validate(t *testing.T) { "Computed + Optional fields conflicting with each other": { Schema: map[string]*Schema{ - "foo_att": &Schema{ + "foo_att": { Type: TypeString, Optional: true, Computed: true, ConflictsWith: []string{"bar_att"}, }, - "bar_att": &Schema{ + "bar_att": { Type: TypeString, Optional: true, Computed: true, @@ -4826,13 +4826,13 @@ func TestSchemaMap_Validate(t *testing.T) { "Computed + Optional fields NOT conflicting with each other": { Schema: map[string]*Schema{ - "foo_att": &Schema{ + "foo_att": { Type: TypeString, Optional: true, Computed: true, ConflictsWith: []string{"bar_att"}, }, - "bar_att": &Schema{ + "bar_att": { Type: TypeString, Optional: true, Computed: true, @@ -4849,13 +4849,13 @@ func TestSchemaMap_Validate(t *testing.T) { "Computed + Optional fields that conflict with none set": { Schema: map[string]*Schema{ - "foo_att": &Schema{ + "foo_att": { Type: TypeString, Optional: true, Computed: true, ConflictsWith: []string{"bar_att"}, }, - "bar_att": &Schema{ + "bar_att": { Type: TypeString, Optional: true, Computed: true, @@ -4870,7 +4870,7 @@ func TestSchemaMap_Validate(t *testing.T) { "Good with ValidateFunc": { Schema: map[string]*Schema{ - "validate_me": &Schema{ + "validate_me": { Type: TypeString, Required: true, ValidateFunc: func(v interface{}, k string) (ws []string, es []error) { @@ -4886,7 +4886,7 @@ func TestSchemaMap_Validate(t *testing.T) { "Bad with ValidateFunc": { Schema: map[string]*Schema{ - "validate_me": &Schema{ + "validate_me": { Type: TypeString, Required: true, ValidateFunc: func(v interface{}, k string) (ws []string, es []error) { @@ -4906,7 +4906,7 @@ func TestSchemaMap_Validate(t *testing.T) { "ValidateFunc not called when type does not match": { Schema: map[string]*Schema{ - "number": &Schema{ + "number": { Type: TypeInt, Required: true, ValidateFunc: func(v interface{}, k string) (ws []string, es []error) { @@ -4923,7 +4923,7 @@ func TestSchemaMap_Validate(t *testing.T) { "ValidateFunc gets decoded type": { Schema: map[string]*Schema{ - "maybe": &Schema{ + "maybe": { Type: TypeBool, Required: true, ValidateFunc: func(v interface{}, k string) (ws []string, es []error) { @@ -4941,7 +4941,7 @@ func TestSchemaMap_Validate(t *testing.T) { "ValidateFunc is not called with a computed value": { Schema: map[string]*Schema{ - "validate_me": &Schema{ + "validate_me": { Type: TypeString, Required: true, ValidateFunc: func(v interface{}, k string) (ws []string, es []error) { @@ -4959,7 +4959,7 @@ func TestSchemaMap_Validate(t *testing.T) { "special timeouts field": { Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Optional: true, Computed: true, @@ -5014,7 +5014,7 @@ func TestSchemaMap_Validate(t *testing.T) { // Invalid map values "invalid bool map value": { Schema: map[string]*Schema{ - "boolMap": &Schema{ + "boolMap": { Type: TypeMap, Elem: TypeBool, Optional: true, @@ -5029,7 +5029,7 @@ func TestSchemaMap_Validate(t *testing.T) { }, "invalid int map value": { Schema: map[string]*Schema{ - "intMap": &Schema{ + "intMap": { Type: TypeMap, Elem: TypeInt, Optional: true, @@ -5044,7 +5044,7 @@ func TestSchemaMap_Validate(t *testing.T) { }, "invalid float map value": { Schema: map[string]*Schema{ - "floatMap": &Schema{ + "floatMap": { Type: TypeMap, Elem: TypeFloat, Optional: true, @@ -5060,7 +5060,7 @@ func TestSchemaMap_Validate(t *testing.T) { "map with positive validate function": { Schema: map[string]*Schema{ - "floatInt": &Schema{ + "floatInt": { Type: TypeMap, Elem: TypeInt, Optional: true, @@ -5079,7 +5079,7 @@ func TestSchemaMap_Validate(t *testing.T) { }, "map with negative validate function": { Schema: map[string]*Schema{ - "floatInt": &Schema{ + "floatInt": { Type: TypeMap, Elem: TypeInt, Optional: true, @@ -5102,13 +5102,13 @@ func TestSchemaMap_Validate(t *testing.T) { // non-computed values. "set with partially computed list and map": { Schema: map[string]*Schema{ - "outer": &Schema{ + "outer": { Type: TypeSet, Optional: true, Computed: true, Elem: &Resource{ Schema: map[string]*Schema{ - "list": &Schema{ + "list": { Type: TypeList, Optional: true, Elem: &Schema{ @@ -5136,19 +5136,19 @@ func TestSchemaMap_Validate(t *testing.T) { }, "unexpected nils values": { Schema: map[string]*Schema{ - "strings": &Schema{ + "strings": { Type: TypeList, Optional: true, Elem: &Schema{ Type: TypeString, }, }, - "block": &Schema{ + "block": { Type: TypeList, Optional: true, Elem: &Resource{ Schema: map[string]*Schema{ - "int": &Schema{ + "int": { Type: TypeInt, Required: true, }, @@ -5215,7 +5215,7 @@ func TestSchemaSet_ValidateMaxItems(t *testing.T) { }{ "#0": { Schema: map[string]*Schema{ - "aliases": &Schema{ + "aliases": { Type: TypeSet, Optional: true, MaxItems: 1, @@ -5234,7 +5234,7 @@ func TestSchemaSet_ValidateMaxItems(t *testing.T) { }, "#1": { Schema: map[string]*Schema{ - "aliases": &Schema{ + "aliases": { Type: TypeSet, Optional: true, Elem: &Schema{Type: TypeString}, @@ -5250,7 +5250,7 @@ func TestSchemaSet_ValidateMaxItems(t *testing.T) { }, "#2": { Schema: map[string]*Schema{ - "aliases": &Schema{ + "aliases": { Type: TypeSet, Optional: true, MaxItems: 1, @@ -5303,7 +5303,7 @@ func TestSchemaSet_ValidateMinItems(t *testing.T) { }{ "#0": { Schema: map[string]*Schema{ - "aliases": &Schema{ + "aliases": { Type: TypeSet, Optional: true, MinItems: 2, @@ -5320,7 +5320,7 @@ func TestSchemaSet_ValidateMinItems(t *testing.T) { }, "#1": { Schema: map[string]*Schema{ - "aliases": &Schema{ + "aliases": { Type: TypeSet, Optional: true, Elem: &Schema{Type: TypeString}, @@ -5336,7 +5336,7 @@ func TestSchemaSet_ValidateMinItems(t *testing.T) { }, "#2": { Schema: map[string]*Schema{ - "aliases": &Schema{ + "aliases": { Type: TypeSet, Optional: true, MinItems: 2, @@ -5390,7 +5390,7 @@ func (e errorSort) Less(i, j int) bool { func TestSchemaMapDeepCopy(t *testing.T) { schema := map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeString, }, } @@ -5413,12 +5413,12 @@ func TestValidateExactlyOneOfAttributes(t *testing.T) { "two attributes specified": { Key: "whitelist", Schema: map[string]*Schema{ - "whitelist": &Schema{ + "whitelist": { Type: TypeBool, Optional: true, ExactlyOneOf: []string{"blacklist"}, }, - "blacklist": &Schema{ + "blacklist": { Type: TypeBool, Optional: true, ExactlyOneOf: []string{"whitelist"}, @@ -5435,12 +5435,12 @@ func TestValidateExactlyOneOfAttributes(t *testing.T) { "one attributes specified": { Key: "whitelist", Schema: map[string]*Schema{ - "whitelist": &Schema{ + "whitelist": { Type: TypeBool, Optional: true, ExactlyOneOf: []string{"blacklist"}, }, - "blacklist": &Schema{ + "blacklist": { Type: TypeBool, Optional: true, ExactlyOneOf: []string{"whitelist"}, @@ -5456,17 +5456,17 @@ func TestValidateExactlyOneOfAttributes(t *testing.T) { "two attributes of three specified": { Key: "whitelist", Schema: map[string]*Schema{ - "whitelist": &Schema{ + "whitelist": { Type: TypeBool, Optional: true, ExactlyOneOf: []string{"blacklist", "purplelist"}, }, - "blacklist": &Schema{ + "blacklist": { Type: TypeBool, Optional: true, ExactlyOneOf: []string{"whitelist", "purplelist"}, }, - "purplelist": &Schema{ + "purplelist": { Type: TypeBool, Optional: true, ExactlyOneOf: []string{"whitelist", "blacklist"}, @@ -5483,17 +5483,17 @@ func TestValidateExactlyOneOfAttributes(t *testing.T) { "one attributes of three specified": { Key: "whitelist", Schema: map[string]*Schema{ - "whitelist": &Schema{ + "whitelist": { Type: TypeBool, Optional: true, ExactlyOneOf: []string{"blacklist", "purplelist"}, }, - "blacklist": &Schema{ + "blacklist": { Type: TypeBool, Optional: true, ExactlyOneOf: []string{"whitelist", "purplelist"}, }, - "purplelist": &Schema{ + "purplelist": { Type: TypeBool, Optional: true, ExactlyOneOf: []string{"whitelist", "blacklist"}, @@ -5509,17 +5509,17 @@ func TestValidateExactlyOneOfAttributes(t *testing.T) { "no attributes of three specified": { Key: "whitelist", Schema: map[string]*Schema{ - "whitelist": &Schema{ + "whitelist": { Type: TypeBool, Optional: true, ExactlyOneOf: []string{"blacklist", "purplelist"}, }, - "blacklist": &Schema{ + "blacklist": { Type: TypeBool, Optional: true, ExactlyOneOf: []string{"whitelist", "purplelist"}, }, - "purplelist": &Schema{ + "purplelist": { Type: TypeBool, Optional: true, ExactlyOneOf: []string{"whitelist", "blacklist"}, @@ -5533,17 +5533,17 @@ func TestValidateExactlyOneOfAttributes(t *testing.T) { "Only Unknown Variable Value": { Key: "whitelist", Schema: map[string]*Schema{ - "whitelist": &Schema{ + "whitelist": { Type: TypeBool, Optional: true, ExactlyOneOf: []string{"blacklist", "purplelist"}, }, - "blacklist": &Schema{ + "blacklist": { Type: TypeBool, Optional: true, ExactlyOneOf: []string{"whitelist", "purplelist"}, }, - "purplelist": &Schema{ + "purplelist": { Type: TypeBool, Optional: true, ExactlyOneOf: []string{"whitelist", "blacklist"}, @@ -5559,17 +5559,17 @@ func TestValidateExactlyOneOfAttributes(t *testing.T) { "Unknown Variable Value and Known Value": { Key: "whitelist", Schema: map[string]*Schema{ - "whitelist": &Schema{ + "whitelist": { Type: TypeBool, Optional: true, ExactlyOneOf: []string{"blacklist", "purplelist"}, }, - "blacklist": &Schema{ + "blacklist": { Type: TypeBool, Optional: true, ExactlyOneOf: []string{"whitelist", "purplelist"}, }, - "purplelist": &Schema{ + "purplelist": { Type: TypeBool, Optional: true, ExactlyOneOf: []string{"whitelist", "blacklist"}, @@ -5586,17 +5586,17 @@ func TestValidateExactlyOneOfAttributes(t *testing.T) { "Unknown Variable Value and 2 Known Value": { Key: "whitelist", Schema: map[string]*Schema{ - "whitelist": &Schema{ + "whitelist": { Type: TypeBool, Optional: true, ExactlyOneOf: []string{"blacklist", "purplelist"}, }, - "blacklist": &Schema{ + "blacklist": { Type: TypeBool, Optional: true, ExactlyOneOf: []string{"whitelist", "purplelist"}, }, - "purplelist": &Schema{ + "purplelist": { Type: TypeBool, Optional: true, ExactlyOneOf: []string{"whitelist", "blacklist"}, @@ -5614,7 +5614,7 @@ func TestValidateExactlyOneOfAttributes(t *testing.T) { "unknown list values": { Key: "allow", Schema: map[string]*Schema{ - "allow": &Schema{ + "allow": { Type: TypeList, Optional: true, Elem: &Resource{ @@ -5634,7 +5634,7 @@ func TestValidateExactlyOneOfAttributes(t *testing.T) { }, ExactlyOneOf: []string{"allow", "deny"}, }, - "deny": &Schema{ + "deny": { Type: TypeList, Optional: true, Elem: &Resource{ @@ -5654,7 +5654,7 @@ func TestValidateExactlyOneOfAttributes(t *testing.T) { }, ExactlyOneOf: []string{"allow", "deny"}, }, - "purplelist": &Schema{ + "purplelist": { Type: TypeString, Optional: true, }, @@ -5678,7 +5678,7 @@ func TestValidateExactlyOneOfAttributes(t *testing.T) { "partially known list values": { Key: "allow", Schema: map[string]*Schema{ - "allow": &Schema{ + "allow": { Type: TypeList, Optional: true, Elem: &Resource{ @@ -5698,7 +5698,7 @@ func TestValidateExactlyOneOfAttributes(t *testing.T) { }, ExactlyOneOf: []string{"allow", "deny"}, }, - "deny": &Schema{ + "deny": { Type: TypeList, Optional: true, Elem: &Resource{ @@ -5718,7 +5718,7 @@ func TestValidateExactlyOneOfAttributes(t *testing.T) { }, ExactlyOneOf: []string{"allow", "deny"}, }, - "purplelist": &Schema{ + "purplelist": { Type: TypeString, Optional: true, }, @@ -5740,7 +5740,7 @@ func TestValidateExactlyOneOfAttributes(t *testing.T) { "known list values": { Key: "allow", Schema: map[string]*Schema{ - "allow": &Schema{ + "allow": { Type: TypeList, Optional: true, Elem: &Resource{ @@ -5760,7 +5760,7 @@ func TestValidateExactlyOneOfAttributes(t *testing.T) { }, ExactlyOneOf: []string{"allow", "deny"}, }, - "deny": &Schema{ + "deny": { Type: TypeList, Optional: true, Elem: &Resource{ @@ -5797,7 +5797,7 @@ func TestValidateExactlyOneOfAttributes(t *testing.T) { "wholly unknown set values": { Key: "allow", Schema: map[string]*Schema{ - "allow": &Schema{ + "allow": { Type: TypeSet, Optional: true, Elem: &Resource{ @@ -5817,7 +5817,7 @@ func TestValidateExactlyOneOfAttributes(t *testing.T) { }, ExactlyOneOf: []string{"allow", "deny"}, }, - "deny": &Schema{ + "deny": { Type: TypeSet, Optional: true, Elem: &Resource{ @@ -5837,7 +5837,7 @@ func TestValidateExactlyOneOfAttributes(t *testing.T) { }, ExactlyOneOf: []string{"allow", "deny"}, }, - "purplelist": &Schema{ + "purplelist": { Type: TypeString, Optional: true, }, @@ -5861,7 +5861,7 @@ func TestValidateExactlyOneOfAttributes(t *testing.T) { "partially known set values": { Key: "allow", Schema: map[string]*Schema{ - "allow": &Schema{ + "allow": { Type: TypeSet, Optional: true, Elem: &Resource{ @@ -5881,7 +5881,7 @@ func TestValidateExactlyOneOfAttributes(t *testing.T) { }, ExactlyOneOf: []string{"allow", "deny"}, }, - "deny": &Schema{ + "deny": { Type: TypeSet, Optional: true, Elem: &Resource{ @@ -5918,7 +5918,7 @@ func TestValidateExactlyOneOfAttributes(t *testing.T) { "known set values": { Key: "allow", Schema: map[string]*Schema{ - "allow": &Schema{ + "allow": { Type: TypeSet, Optional: true, Elem: &Resource{ @@ -5938,7 +5938,7 @@ func TestValidateExactlyOneOfAttributes(t *testing.T) { }, ExactlyOneOf: []string{"allow", "deny"}, }, - "deny": &Schema{ + "deny": { Type: TypeSet, Optional: true, Elem: &Resource{ @@ -5975,19 +5975,19 @@ func TestValidateExactlyOneOfAttributes(t *testing.T) { "wholly unknown simple lists": { Key: "allow", Schema: map[string]*Schema{ - "allow": &Schema{ + "allow": { Type: TypeList, Optional: true, Elem: &Schema{Type: TypeString}, ExactlyOneOf: []string{"allow", "deny"}, }, - "deny": &Schema{ + "deny": { Type: TypeList, Optional: true, Elem: &Schema{Type: TypeString}, ExactlyOneOf: []string{"allow", "deny"}, }, - "purplelist": &Schema{ + "purplelist": { Type: TypeString, Optional: true, }, @@ -6011,13 +6011,13 @@ func TestValidateExactlyOneOfAttributes(t *testing.T) { "partially known simple lists": { Key: "allow", Schema: map[string]*Schema{ - "allow": &Schema{ + "allow": { Type: TypeList, Optional: true, Elem: &Schema{Type: TypeString}, ExactlyOneOf: []string{"allow", "deny"}, }, - "deny": &Schema{ + "deny": { Type: TypeList, Optional: true, Elem: &Schema{Type: TypeString}, @@ -6040,13 +6040,13 @@ func TestValidateExactlyOneOfAttributes(t *testing.T) { "known simple lists": { Key: "allow", Schema: map[string]*Schema{ - "allow": &Schema{ + "allow": { Type: TypeList, Optional: true, Elem: &Schema{Type: TypeString}, ExactlyOneOf: []string{"allow", "deny"}, }, - "deny": &Schema{ + "deny": { Type: TypeList, Optional: true, Elem: &Schema{Type: TypeString}, @@ -6068,17 +6068,17 @@ func TestValidateExactlyOneOfAttributes(t *testing.T) { "wholly unknown map keys and values": { Key: "allow", Schema: map[string]*Schema{ - "allow": &Schema{ + "allow": { Type: TypeMap, Optional: true, ExactlyOneOf: []string{"allow", "deny"}, }, - "deny": &Schema{ + "deny": { Type: TypeList, Optional: true, ExactlyOneOf: []string{"allow", "deny"}, }, - "purplelist": &Schema{ + "purplelist": { Type: TypeString, Optional: true, }, @@ -6100,17 +6100,17 @@ func TestValidateExactlyOneOfAttributes(t *testing.T) { "wholly unknown map values": { Key: "allow", Schema: map[string]*Schema{ - "allow": &Schema{ + "allow": { Type: TypeMap, Optional: true, ExactlyOneOf: []string{"allow", "deny"}, }, - "deny": &Schema{ + "deny": { Type: TypeList, Optional: true, ExactlyOneOf: []string{"allow", "deny"}, }, - "purplelist": &Schema{ + "purplelist": { Type: TypeString, Optional: true, }, @@ -6132,17 +6132,17 @@ func TestValidateExactlyOneOfAttributes(t *testing.T) { "partially known maps": { Key: "allow", Schema: map[string]*Schema{ - "allow": &Schema{ + "allow": { Type: TypeMap, Optional: true, ExactlyOneOf: []string{"allow", "deny"}, }, - "deny": &Schema{ + "deny": { Type: TypeList, Optional: true, ExactlyOneOf: []string{"allow", "deny"}, }, - "purplelist": &Schema{ + "purplelist": { Type: TypeString, Optional: true, }, @@ -6164,12 +6164,12 @@ func TestValidateExactlyOneOfAttributes(t *testing.T) { "known maps": { Key: "allow", Schema: map[string]*Schema{ - "allow": &Schema{ + "allow": { Type: TypeMap, Optional: true, ExactlyOneOf: []string{"allow", "deny"}, }, - "deny": &Schema{ + "deny": { Type: TypeList, Optional: true, ExactlyOneOf: []string{"allow", "deny"}, @@ -6217,12 +6217,12 @@ func TestValidateAtLeastOneOfAttributes(t *testing.T) { "two attributes specified": { Key: "whitelist", Schema: map[string]*Schema{ - "whitelist": &Schema{ + "whitelist": { Type: TypeBool, Optional: true, AtLeastOneOf: []string{"blacklist"}, }, - "blacklist": &Schema{ + "blacklist": { Type: TypeBool, Optional: true, AtLeastOneOf: []string{"whitelist"}, @@ -6239,12 +6239,12 @@ func TestValidateAtLeastOneOfAttributes(t *testing.T) { "one attributes specified": { Key: "whitelist", Schema: map[string]*Schema{ - "whitelist": &Schema{ + "whitelist": { Type: TypeBool, Optional: true, AtLeastOneOf: []string{"blacklist"}, }, - "blacklist": &Schema{ + "blacklist": { Type: TypeBool, Optional: true, AtLeastOneOf: []string{"whitelist"}, @@ -6260,17 +6260,17 @@ func TestValidateAtLeastOneOfAttributes(t *testing.T) { "two attributes of three specified": { Key: "whitelist", Schema: map[string]*Schema{ - "whitelist": &Schema{ + "whitelist": { Type: TypeBool, Optional: true, AtLeastOneOf: []string{"blacklist", "purplelist"}, }, - "blacklist": &Schema{ + "blacklist": { Type: TypeBool, Optional: true, AtLeastOneOf: []string{"whitelist", "purplelist"}, }, - "purplelist": &Schema{ + "purplelist": { Type: TypeBool, Optional: true, AtLeastOneOf: []string{"whitelist", "blacklist"}, @@ -6287,17 +6287,17 @@ func TestValidateAtLeastOneOfAttributes(t *testing.T) { "three attributes of three specified": { Key: "whitelist", Schema: map[string]*Schema{ - "whitelist": &Schema{ + "whitelist": { Type: TypeBool, Optional: true, AtLeastOneOf: []string{"blacklist", "purplelist"}, }, - "blacklist": &Schema{ + "blacklist": { Type: TypeBool, Optional: true, AtLeastOneOf: []string{"whitelist", "purplelist"}, }, - "purplelist": &Schema{ + "purplelist": { Type: TypeBool, Optional: true, AtLeastOneOf: []string{"whitelist", "blacklist"}, @@ -6315,17 +6315,17 @@ func TestValidateAtLeastOneOfAttributes(t *testing.T) { "one attributes of three specified": { Key: "whitelist", Schema: map[string]*Schema{ - "whitelist": &Schema{ + "whitelist": { Type: TypeBool, Optional: true, AtLeastOneOf: []string{"blacklist", "purplelist"}, }, - "blacklist": &Schema{ + "blacklist": { Type: TypeBool, Optional: true, AtLeastOneOf: []string{"whitelist", "purplelist"}, }, - "purplelist": &Schema{ + "purplelist": { Type: TypeBool, Optional: true, AtLeastOneOf: []string{"whitelist", "blacklist"}, @@ -6341,17 +6341,17 @@ func TestValidateAtLeastOneOfAttributes(t *testing.T) { "no attributes of three specified": { Key: "whitelist", Schema: map[string]*Schema{ - "whitelist": &Schema{ + "whitelist": { Type: TypeBool, Optional: true, AtLeastOneOf: []string{"whitelist", "blacklist", "purplelist"}, }, - "blacklist": &Schema{ + "blacklist": { Type: TypeBool, Optional: true, AtLeastOneOf: []string{"whitelist", "blacklist", "purplelist"}, }, - "purplelist": &Schema{ + "purplelist": { Type: TypeBool, Optional: true, AtLeastOneOf: []string{"whitelist", "blacklist", "purplelist"}, @@ -6364,17 +6364,17 @@ func TestValidateAtLeastOneOfAttributes(t *testing.T) { "Only Unknown Variable Value": { Schema: map[string]*Schema{ - "whitelist": &Schema{ + "whitelist": { Type: TypeBool, Optional: true, AtLeastOneOf: []string{"whitelist", "blacklist", "purplelist"}, }, - "blacklist": &Schema{ + "blacklist": { Type: TypeBool, Optional: true, AtLeastOneOf: []string{"whitelist", "blacklist", "purplelist"}, }, - "purplelist": &Schema{ + "purplelist": { Type: TypeBool, Optional: true, AtLeastOneOf: []string{"whitelist", "blacklist", "purplelist"}, @@ -6390,13 +6390,13 @@ func TestValidateAtLeastOneOfAttributes(t *testing.T) { "only unknown list value": { Schema: map[string]*Schema{ - "whitelist": &Schema{ + "whitelist": { Type: TypeList, Optional: true, Elem: &Schema{Type: TypeString}, AtLeastOneOf: []string{"whitelist", "blacklist"}, }, - "blacklist": &Schema{ + "blacklist": { Type: TypeList, Optional: true, Elem: &Schema{Type: TypeString}, @@ -6413,17 +6413,17 @@ func TestValidateAtLeastOneOfAttributes(t *testing.T) { "Unknown Variable Value and Known Value": { Schema: map[string]*Schema{ - "whitelist": &Schema{ + "whitelist": { Type: TypeBool, Optional: true, AtLeastOneOf: []string{"whitelist", "blacklist", "purplelist"}, }, - "blacklist": &Schema{ + "blacklist": { Type: TypeBool, Optional: true, AtLeastOneOf: []string{"whitelist", "blacklist", "purplelist"}, }, - "purplelist": &Schema{ + "purplelist": { Type: TypeBool, Optional: true, AtLeastOneOf: []string{"whitelist", "blacklist", "purplelist"}, diff --git a/helper/schema/serialize_test.go b/helper/schema/serialize_test.go index c5480272038..efa01c95006 100644 --- a/helper/schema/serialize_test.go +++ b/helper/schema/serialize_test.go @@ -13,7 +13,7 @@ func TestSerializeForHash(t *testing.T) { } tests := []testCase{ - testCase{ + { Schema: &Schema{ Type: TypeInt, }, @@ -21,7 +21,7 @@ func TestSerializeForHash(t *testing.T) { Expected: "0;", }, - testCase{ + { Schema: &Schema{ Type: TypeInt, }, @@ -29,7 +29,7 @@ func TestSerializeForHash(t *testing.T) { Expected: "200;", }, - testCase{ + { Schema: &Schema{ Type: TypeBool, }, @@ -37,7 +37,7 @@ func TestSerializeForHash(t *testing.T) { Expected: "1;", }, - testCase{ + { Schema: &Schema{ Type: TypeBool, }, @@ -45,7 +45,7 @@ func TestSerializeForHash(t *testing.T) { Expected: "0;", }, - testCase{ + { Schema: &Schema{ Type: TypeFloat, }, @@ -53,7 +53,7 @@ func TestSerializeForHash(t *testing.T) { Expected: "1;", }, - testCase{ + { Schema: &Schema{ Type: TypeFloat, }, @@ -61,7 +61,7 @@ func TestSerializeForHash(t *testing.T) { Expected: "1.54;", }, - testCase{ + { Schema: &Schema{ Type: TypeFloat, }, @@ -69,7 +69,7 @@ func TestSerializeForHash(t *testing.T) { Expected: "0.1;", }, - testCase{ + { Schema: &Schema{ Type: TypeString, }, @@ -77,7 +77,7 @@ func TestSerializeForHash(t *testing.T) { Expected: "hello;", }, - testCase{ + { Schema: &Schema{ Type: TypeString, }, @@ -85,7 +85,7 @@ func TestSerializeForHash(t *testing.T) { Expected: "1;", }, - testCase{ + { Schema: &Schema{ Type: TypeList, Elem: &Schema{ @@ -96,7 +96,7 @@ func TestSerializeForHash(t *testing.T) { Expected: "();", }, - testCase{ + { Schema: &Schema{ Type: TypeList, Elem: &Schema{ @@ -107,16 +107,16 @@ func TestSerializeForHash(t *testing.T) { Expected: "(hello;world;);", }, - testCase{ + { Schema: &Schema{ Type: TypeList, Elem: &Resource{ Schema: map[string]*Schema{ - "fo": &Schema{ + "fo": { Type: TypeString, Required: true, }, - "fum": &Schema{ + "fum": { Type: TypeString, Required: true, }, @@ -135,7 +135,7 @@ func TestSerializeForHash(t *testing.T) { Expected: "(;;);", }, - testCase{ + { Schema: &Schema{ Type: TypeSet, Elem: &Schema{ @@ -149,7 +149,7 @@ func TestSerializeForHash(t *testing.T) { Expected: "{woo;hello;};", }, - testCase{ + { Schema: &Schema{ Type: TypeMap, Elem: &Schema{ @@ -163,23 +163,23 @@ func TestSerializeForHash(t *testing.T) { Expected: "[baz:foo;foo:bar;];", }, - testCase{ + { Schema: &Resource{ Schema: map[string]*Schema{ - "name": &Schema{ + "name": { Type: TypeString, Required: true, }, - "size": &Schema{ + "size": { Type: TypeInt, Optional: true, }, - "green": &Schema{ + "green": { Type: TypeBool, Optional: true, Computed: true, }, - "upside_down": &Schema{ + "upside_down": { Type: TypeBool, Computed: true, }, @@ -194,10 +194,10 @@ func TestSerializeForHash(t *testing.T) { }, // test TypeMap nested in Schema: GH-7091 - testCase{ + { Schema: &Resource{ Schema: map[string]*Schema{ - "outer": &Schema{ + "outer": { Type: TypeSet, Required: true, Elem: &Schema{ @@ -218,14 +218,14 @@ func TestSerializeForHash(t *testing.T) { Expected: "outer:{[baz:foo;foo:bar;];};", }, - testCase{ + { Schema: &Resource{ Schema: map[string]*Schema{ - "attr1": &Schema{ + "attr1": { Type: TypeString, Computed: true, }, - "attr2": &Schema{ + "attr2": { Type: TypeString, Computed: true, }, diff --git a/helper/schema/shims_test.go b/helper/schema/shims_test.go index 40822942439..cb54eb10bdd 100644 --- a/helper/schema/shims_test.go +++ b/helper/schema/shims_test.go @@ -85,7 +85,7 @@ func TestShimResourcePlan_destroyCreate(t *testing.T) { r := &Resource{ SchemaVersion: 2, Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeInt, Optional: true, ForceNew: true, @@ -95,7 +95,7 @@ func TestShimResourcePlan_destroyCreate(t *testing.T) { d := &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "foo": &terraform.ResourceAttrDiff{ + "foo": { RequiresNew: true, Old: "3", New: "42", @@ -125,7 +125,7 @@ func TestShimResourceApply_create(t *testing.T) { r := &Resource{ SchemaVersion: 2, Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeInt, Optional: true, }, @@ -143,7 +143,7 @@ func TestShimResourceApply_create(t *testing.T) { d := &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "foo": &terraform.ResourceAttrDiff{ + "foo": { New: "42", }, }, @@ -189,7 +189,7 @@ func TestShimResourceApply_Timeout_state(t *testing.T) { r := &Resource{ SchemaVersion: 2, Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeInt, Optional: true, }, @@ -212,7 +212,7 @@ func TestShimResourceApply_Timeout_state(t *testing.T) { d := &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "foo": &terraform.ResourceAttrDiff{ + "foo": { New: "42", }, }, @@ -266,7 +266,7 @@ func TestShimResourceApply_Timeout_state(t *testing.T) { func TestShimResourceDiff_Timeout_diff(t *testing.T) { r := &Resource{ Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeInt, Optional: true, }, @@ -298,7 +298,7 @@ func TestShimResourceDiff_Timeout_diff(t *testing.T) { expected := &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "foo": &terraform.ResourceAttrDiff{ + "foo": { New: "42", }, }, @@ -358,7 +358,7 @@ func TestShimResourceDiff_Timeout_diff(t *testing.T) { func TestShimResourceApply_destroy(t *testing.T) { r := &Resource{ Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeInt, Optional: true, }, @@ -401,13 +401,13 @@ func TestShimResourceApply_destroy(t *testing.T) { func TestShimResourceApply_destroyCreate(t *testing.T) { r := &Resource{ Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeInt, Optional: true, ForceNew: true, }, - "tags": &Schema{ + "tags": { Type: TypeMap, Optional: true, Computed: true, @@ -435,15 +435,15 @@ func TestShimResourceApply_destroyCreate(t *testing.T) { d := &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "id": &terraform.ResourceAttrDiff{ + "id": { New: "foo", }, - "foo": &terraform.ResourceAttrDiff{ + "foo": { Old: "7", New: "42", RequiresNew: true, }, - "tags.Name": &terraform.ResourceAttrDiff{ + "tags.Name": { Old: "foo", New: "foo", RequiresNew: true, @@ -504,7 +504,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "diff-1", Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Optional: true, Computed: true, @@ -520,7 +520,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "availability_zone": &terraform.ResourceAttrDiff{ + "availability_zone": { Old: "", New: "foo", RequiresNew: true, @@ -534,7 +534,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "diff-2", Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Optional: true, Computed: true, @@ -548,7 +548,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "availability_zone": &terraform.ResourceAttrDiff{ + "availability_zone": { Old: "", NewComputed: true, RequiresNew: true, @@ -562,7 +562,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "diff-3", Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Optional: true, Computed: true, @@ -584,7 +584,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "Computed, but set in config", Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Optional: true, Computed: true, @@ -604,7 +604,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "availability_zone": &terraform.ResourceAttrDiff{ + "availability_zone": { Old: "foo", New: "bar", }, @@ -617,7 +617,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "Default", Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Optional: true, Default: "foo", @@ -630,7 +630,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "availability_zone": &terraform.ResourceAttrDiff{ + "availability_zone": { Old: "", New: "foo", }, @@ -643,7 +643,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "DefaultFunc, value", Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Optional: true, DefaultFunc: func() (interface{}, error) { @@ -658,7 +658,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "availability_zone": &terraform.ResourceAttrDiff{ + "availability_zone": { Old: "", New: "foo", }, @@ -671,7 +671,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "DefaultFunc, configuration set", Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Optional: true, DefaultFunc: func() (interface{}, error) { @@ -688,7 +688,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "availability_zone": &terraform.ResourceAttrDiff{ + "availability_zone": { Old: "", New: "bar", }, @@ -701,7 +701,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "String with StateFunc", Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Optional: true, Computed: true, @@ -719,7 +719,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "availability_zone": &terraform.ResourceAttrDiff{ + "availability_zone": { Old: "", New: "foo!", NewExtra: "foo", @@ -733,7 +733,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "StateFunc not called with nil value", Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Optional: true, Computed: true, @@ -750,7 +750,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "availability_zone": &terraform.ResourceAttrDiff{ + "availability_zone": { Old: "", New: "", NewComputed: true, @@ -764,7 +764,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "Variable computed", Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Optional: true, }, @@ -778,7 +778,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "availability_zone": &terraform.ResourceAttrDiff{ + "availability_zone": { Old: "", New: hcl2shim.UnknownVariableValue, NewComputed: true, @@ -792,7 +792,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "Int decode", Schema: map[string]*Schema{ - "port": &Schema{ + "port": { Type: TypeInt, Optional: true, Computed: true, @@ -808,7 +808,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "port": &terraform.ResourceAttrDiff{ + "port": { Old: "", New: "27", RequiresNew: true, @@ -822,7 +822,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "bool decode", Schema: map[string]*Schema{ - "port": &Schema{ + "port": { Type: TypeBool, Optional: true, Computed: true, @@ -838,7 +838,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "port": &terraform.ResourceAttrDiff{ + "port": { Old: "", New: "false", RequiresNew: true, @@ -852,7 +852,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "Bool", Schema: map[string]*Schema{ - "delete": &Schema{ + "delete": { Type: TypeBool, Optional: true, Default: false, @@ -876,7 +876,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "List decode", Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeList, Required: true, Elem: &Schema{Type: TypeInt}, @@ -891,19 +891,19 @@ func TestShimSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "ports.#": &terraform.ResourceAttrDiff{ + "ports.#": { Old: "0", New: "3", }, - "ports.0": &terraform.ResourceAttrDiff{ + "ports.0": { Old: "", New: "1", }, - "ports.1": &terraform.ResourceAttrDiff{ + "ports.1": { Old: "", New: "2", }, - "ports.2": &terraform.ResourceAttrDiff{ + "ports.2": { Old: "", New: "5", }, @@ -915,7 +915,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeList, Required: true, Elem: &Schema{Type: TypeInt}, @@ -930,19 +930,19 @@ func TestShimSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "ports.#": &terraform.ResourceAttrDiff{ + "ports.#": { Old: "0", New: "3", }, - "ports.0": &terraform.ResourceAttrDiff{ + "ports.0": { Old: "", New: "1", }, - "ports.1": &terraform.ResourceAttrDiff{ + "ports.1": { Old: "", New: "2", }, - "ports.2": &terraform.ResourceAttrDiff{ + "ports.2": { Old: "", New: "5", }, @@ -954,7 +954,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeList, Required: true, Elem: &Schema{Type: TypeInt}, @@ -969,7 +969,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "ports.#": &terraform.ResourceAttrDiff{ + "ports.#": { Old: "0", New: "", NewComputed: true, @@ -982,7 +982,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeList, Required: true, Elem: &Schema{Type: TypeInt}, @@ -1011,7 +1011,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "", Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeList, Required: true, Elem: &Schema{Type: TypeInt}, @@ -1033,11 +1033,11 @@ func TestShimSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "ports.#": &terraform.ResourceAttrDiff{ + "ports.#": { Old: "2", New: "3", }, - "ports.2": &terraform.ResourceAttrDiff{ + "ports.2": { Old: "", New: "5", }, @@ -1050,7 +1050,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "", Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeList, Required: true, Elem: &Schema{Type: TypeInt}, @@ -1066,22 +1066,22 @@ func TestShimSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "ports.#": &terraform.ResourceAttrDiff{ + "ports.#": { Old: "0", New: "3", RequiresNew: true, }, - "ports.0": &terraform.ResourceAttrDiff{ + "ports.0": { Old: "", New: "1", RequiresNew: true, }, - "ports.1": &terraform.ResourceAttrDiff{ + "ports.1": { Old: "", New: "2", RequiresNew: true, }, - "ports.2": &terraform.ResourceAttrDiff{ + "ports.2": { Old: "", New: "5", RequiresNew: true, @@ -1095,7 +1095,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "", Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeList, Optional: true, Computed: true, @@ -1109,7 +1109,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "ports.#": &terraform.ResourceAttrDiff{ + "ports.#": { Old: "", NewComputed: true, }, @@ -1122,7 +1122,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "List with computed set", Schema: map[string]*Schema{ - "config": &Schema{ + "config": { Type: TypeList, Optional: true, ForceNew: true, @@ -1157,18 +1157,18 @@ func TestShimSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "config.#": &terraform.ResourceAttrDiff{ + "config.#": { Old: "0", New: "1", RequiresNew: true, }, - "config.0.name": &terraform.ResourceAttrDiff{ + "config.0.name": { Old: "", New: "hello", }, - "config.0.rules.#": &terraform.ResourceAttrDiff{ + "config.0.rules.#": { Old: "", NewComputed: true, }, @@ -1181,7 +1181,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "Set-1", Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeSet, Required: true, Elem: &Schema{Type: TypeInt}, @@ -1199,19 +1199,19 @@ func TestShimSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "ports.#": &terraform.ResourceAttrDiff{ + "ports.#": { Old: "0", New: "3", }, - "ports.1": &terraform.ResourceAttrDiff{ + "ports.1": { Old: "", New: "1", }, - "ports.2": &terraform.ResourceAttrDiff{ + "ports.2": { Old: "", New: "2", }, - "ports.5": &terraform.ResourceAttrDiff{ + "ports.5": { Old: "", New: "5", }, @@ -1224,7 +1224,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "Set-2", Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeSet, Computed: true, Required: true, @@ -1252,7 +1252,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "Set-3", Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeSet, Optional: true, Computed: true, @@ -1269,7 +1269,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "ports.#": &terraform.ResourceAttrDiff{ + "ports.#": { Old: "", NewComputed: true, }, @@ -1282,7 +1282,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "Set-4", Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeSet, Required: true, Elem: &Schema{Type: TypeInt}, @@ -1300,19 +1300,19 @@ func TestShimSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "ports.#": &terraform.ResourceAttrDiff{ + "ports.#": { Old: "0", New: "3", }, - "ports.1": &terraform.ResourceAttrDiff{ + "ports.1": { Old: "", New: "1", }, - "ports.2": &terraform.ResourceAttrDiff{ + "ports.2": { Old: "", New: "2", }, - "ports.5": &terraform.ResourceAttrDiff{ + "ports.5": { Old: "", New: "5", }, @@ -1325,7 +1325,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "Set-5", Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeSet, Required: true, Elem: &Schema{Type: TypeInt}, @@ -1343,7 +1343,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "ports.#": &terraform.ResourceAttrDiff{ + "ports.#": { Old: "", New: "", NewComputed: true, @@ -1357,7 +1357,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "Set-6", Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeSet, Required: true, Elem: &Schema{Type: TypeInt}, @@ -1382,19 +1382,19 @@ func TestShimSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "ports.#": &terraform.ResourceAttrDiff{ + "ports.#": { Old: "2", New: "3", }, - "ports.1": &terraform.ResourceAttrDiff{ + "ports.1": { Old: "1", New: "1", }, - "ports.2": &terraform.ResourceAttrDiff{ + "ports.2": { Old: "2", New: "2", }, - "ports.5": &terraform.ResourceAttrDiff{ + "ports.5": { Old: "", New: "5", }, @@ -1407,7 +1407,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "Set-8", Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeSet, Optional: true, Computed: true, @@ -1437,12 +1437,12 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "Set-9", Schema: map[string]*Schema{ - "ingress": &Schema{ + "ingress": { Type: TypeSet, Required: true, Elem: &Resource{ Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeList, Optional: true, Elem: &Schema{Type: TypeInt}, @@ -1491,12 +1491,12 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "List of structure decode", Schema: map[string]*Schema{ - "ingress": &Schema{ + "ingress": { Type: TypeList, Required: true, Elem: &Resource{ Schema: map[string]*Schema{ - "from": &Schema{ + "from": { Type: TypeInt, Required: true, }, @@ -1517,11 +1517,11 @@ func TestShimSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "ingress.#": &terraform.ResourceAttrDiff{ + "ingress.#": { Old: "0", New: "1", }, - "ingress.0.from": &terraform.ResourceAttrDiff{ + "ingress.0.from": { Old: "", New: "8080", }, @@ -1534,13 +1534,13 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "ComputedWhen", Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Computed: true, ComputedWhen: []string{"port"}, }, - "port": &Schema{ + "port": { Type: TypeInt, Optional: true, }, @@ -1566,13 +1566,13 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "computed", Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Computed: true, ComputedWhen: []string{"port"}, }, - "port": &Schema{ + "port": { Type: TypeInt, Optional: true, }, @@ -1586,10 +1586,10 @@ func TestShimSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "availability_zone": &terraform.ResourceAttrDiff{ + "availability_zone": { NewComputed: true, }, - "port": &terraform.ResourceAttrDiff{ + "port": { New: "80", }, }, @@ -1601,13 +1601,13 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "computed, exists", Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Computed: true, ComputedWhen: []string{"port"}, }, - "port": &Schema{ + "port": { Type: TypeInt, Optional: true, }, @@ -1633,7 +1633,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "Maps-1", Schema: map[string]*Schema{ - "config_vars": &Schema{ + "config_vars": { Type: TypeMap, }, }, @@ -1648,12 +1648,12 @@ func TestShimSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "config_vars.%": &terraform.ResourceAttrDiff{ + "config_vars.%": { Old: "0", New: "1", }, - "config_vars.bar": &terraform.ResourceAttrDiff{ + "config_vars.bar": { Old: "", New: "baz", }, @@ -1666,7 +1666,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "Maps-2", Schema: map[string]*Schema{ - "config_vars": &Schema{ + "config_vars": { Type: TypeMap, }, }, @@ -1687,11 +1687,11 @@ func TestShimSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "config_vars.foo": &terraform.ResourceAttrDiff{ + "config_vars.foo": { Old: "bar", NewRemoved: true, }, - "config_vars.bar": &terraform.ResourceAttrDiff{ + "config_vars.bar": { Old: "", New: "baz", }, @@ -1704,7 +1704,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "Maps-3", Schema: map[string]*Schema{ - "vars": &Schema{ + "vars": { Type: TypeMap, Optional: true, Computed: true, @@ -1727,12 +1727,12 @@ func TestShimSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "vars.foo": &terraform.ResourceAttrDiff{ + "vars.foo": { Old: "bar", New: "", NewRemoved: true, }, - "vars.bar": &terraform.ResourceAttrDiff{ + "vars.bar": { Old: "", New: "baz", }, @@ -1745,7 +1745,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "Maps-4", Schema: map[string]*Schema{ - "vars": &Schema{ + "vars": { Type: TypeMap, Computed: true, }, @@ -1769,7 +1769,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "Maps-5", Schema: map[string]*Schema{ - "config_vars": &Schema{ + "config_vars": { Type: TypeList, Elem: &Schema{Type: TypeMap}, }, @@ -1794,11 +1794,11 @@ func TestShimSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "config_vars.0.foo": &terraform.ResourceAttrDiff{ + "config_vars.0.foo": { Old: "bar", NewRemoved: true, }, - "config_vars.0.bar": &terraform.ResourceAttrDiff{ + "config_vars.0.bar": { Old: "", New: "baz", }, @@ -1811,7 +1811,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "Maps-6", Schema: map[string]*Schema{ - "config_vars": &Schema{ + "config_vars": { Type: TypeList, Elem: &Schema{Type: TypeMap}, Optional: true, @@ -1832,19 +1832,19 @@ func TestShimSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "config_vars.#": &terraform.ResourceAttrDiff{ + "config_vars.#": { Old: "1", New: "0", }, - "config_vars.0.%": &terraform.ResourceAttrDiff{ + "config_vars.0.%": { Old: "2", New: "0", }, - "config_vars.0.foo": &terraform.ResourceAttrDiff{ + "config_vars.0.foo": { Old: "bar", NewRemoved: true, }, - "config_vars.0.bar": &terraform.ResourceAttrDiff{ + "config_vars.0.bar": { Old: "baz", NewRemoved: true, }, @@ -1857,13 +1857,13 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "ForceNews", Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Optional: true, ForceNew: true, }, - "address": &Schema{ + "address": { Type: TypeString, Optional: true, Computed: true, @@ -1884,7 +1884,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "availability_zone": &terraform.ResourceAttrDiff{ + "availability_zone": { Old: "bar", New: "foo", RequiresNew: true, @@ -1898,13 +1898,13 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "Set-10", Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Optional: true, ForceNew: true, }, - "ports": &Schema{ + "ports": { Type: TypeSet, Optional: true, Computed: true, @@ -1930,7 +1930,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "availability_zone": &terraform.ResourceAttrDiff{ + "availability_zone": { Old: "bar", New: "foo", RequiresNew: true, @@ -1944,7 +1944,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "Set-11", Schema: map[string]*Schema{ - "instances": &Schema{ + "instances": { Type: TypeSet, Elem: &Schema{Type: TypeString}, Optional: true, @@ -1968,7 +1968,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "instances.#": &terraform.ResourceAttrDiff{ + "instances.#": { NewComputed: true, }, }, @@ -1980,17 +1980,17 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "Set-12", Schema: map[string]*Schema{ - "route": &Schema{ + "route": { Type: TypeSet, Optional: true, Elem: &Resource{ Schema: map[string]*Schema{ - "index": &Schema{ + "index": { Type: TypeInt, Required: true, }, - "gateway": &Schema{ + "gateway": { Type: TypeString, Optional: true, }, @@ -2016,15 +2016,15 @@ func TestShimSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "route.#": &terraform.ResourceAttrDiff{ + "route.#": { Old: "0", New: "1", }, - "route.~1.index": &terraform.ResourceAttrDiff{ + "route.~1.index": { Old: "", New: "1", }, - "route.~1.gateway": &terraform.ResourceAttrDiff{ + "route.~1.gateway": { Old: "", New: hcl2shim.UnknownVariableValue, NewComputed: true, @@ -2038,17 +2038,17 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "Set-13", Schema: map[string]*Schema{ - "route": &Schema{ + "route": { Type: TypeSet, Optional: true, Elem: &Resource{ Schema: map[string]*Schema{ - "index": &Schema{ + "index": { Type: TypeInt, Required: true, }, - "gateway": &Schema{ + "gateway": { Type: TypeSet, Optional: true, Elem: &Schema{Type: TypeInt}, @@ -2080,15 +2080,15 @@ func TestShimSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "route.#": &terraform.ResourceAttrDiff{ + "route.#": { Old: "0", New: "1", }, - "route.~1.index": &terraform.ResourceAttrDiff{ + "route.~1.index": { Old: "", New: "1", }, - "route.~1.gateway.#": &terraform.ResourceAttrDiff{ + "route.~1.gateway.#": { NewComputed: true, }, }, @@ -2100,7 +2100,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "Computed maps", Schema: map[string]*Schema{ - "vars": &Schema{ + "vars": { Type: TypeMap, Computed: true, }, @@ -2112,7 +2112,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "vars.%": &terraform.ResourceAttrDiff{ + "vars.%": { Old: "", NewComputed: true, }, @@ -2125,7 +2125,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "Computed maps", Schema: map[string]*Schema{ - "vars": &Schema{ + "vars": { Type: TypeMap, Computed: true, }, @@ -2146,7 +2146,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "vars.%": &terraform.ResourceAttrDiff{ + "vars.%": { Old: "", NewComputed: true, }, @@ -2172,7 +2172,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "Float", Schema: map[string]*Schema{ - "some_threshold": &Schema{ + "some_threshold": { Type: TypeFloat, }, }, @@ -2190,7 +2190,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "some_threshold": &terraform.ResourceAttrDiff{ + "some_threshold": { Old: "567.8", New: "12.34", }, @@ -2203,17 +2203,17 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "https://github.com/hashicorp/terraform-plugin-sdk/issues/824", Schema: map[string]*Schema{ - "block_device": &Schema{ + "block_device": { Type: TypeSet, Optional: true, Computed: true, Elem: &Resource{ Schema: map[string]*Schema{ - "device_name": &Schema{ + "device_name": { Type: TypeString, Required: true, }, - "delete_on_termination": &Schema{ + "delete_on_termination": { Type: TypeBool, Optional: true, Default: true, @@ -2258,7 +2258,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "Zero value in state shouldn't result in diff", Schema: map[string]*Schema{ - "port": &Schema{ + "port": { Type: TypeBool, Optional: true, ForceNew: true, @@ -2282,17 +2282,17 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "Same as prev, but for sets", Schema: map[string]*Schema{ - "route": &Schema{ + "route": { Type: TypeSet, Optional: true, Elem: &Resource{ Schema: map[string]*Schema{ - "index": &Schema{ + "index": { Type: TypeInt, Required: true, }, - "gateway": &Schema{ + "gateway": { Type: TypeSet, Optional: true, Elem: &Schema{Type: TypeInt}, @@ -2326,7 +2326,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "A set computed element shouldn't cause a diff", Schema: map[string]*Schema{ - "active": &Schema{ + "active": { Type: TypeBool, Computed: true, ForceNew: true, @@ -2350,7 +2350,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "An empty set should show up in the diff", Schema: map[string]*Schema{ - "instances": &Schema{ + "instances": { Type: TypeSet, Elem: &Schema{Type: TypeString}, Optional: true, @@ -2373,12 +2373,12 @@ func TestShimSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "instances.#": &terraform.ResourceAttrDiff{ + "instances.#": { Old: "1", New: "0", RequiresNew: true, }, - "instances.3": &terraform.ResourceAttrDiff{ + "instances.3": { Old: "foo", New: "", NewRemoved: true, @@ -2393,7 +2393,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "Map with empty value", Schema: map[string]*Schema{ - "vars": &Schema{ + "vars": { Type: TypeMap, }, }, @@ -2408,11 +2408,11 @@ func TestShimSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "vars.%": &terraform.ResourceAttrDiff{ + "vars.%": { Old: "0", New: "1", }, - "vars.foo": &terraform.ResourceAttrDiff{ + "vars.foo": { Old: "", New: "", }, @@ -2425,7 +2425,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "Unset bool, not in state", Schema: map[string]*Schema{ - "force": &Schema{ + "force": { Type: TypeBool, Optional: true, ForceNew: true, @@ -2444,7 +2444,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "Unset set, not in state", Schema: map[string]*Schema{ - "metadata_keys": &Schema{ + "metadata_keys": { Type: TypeSet, Optional: true, ForceNew: true, @@ -2465,7 +2465,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "Unset list in state, should not show up computed", Schema: map[string]*Schema{ - "metadata_keys": &Schema{ + "metadata_keys": { Type: TypeList, Optional: true, Computed: true, @@ -2491,7 +2491,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "Computed map without config that's known to be empty does not generate diff", Schema: map[string]*Schema{ - "tags": &Schema{ + "tags": { Type: TypeMap, Computed: true, }, @@ -2514,17 +2514,17 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "Set with hyphen keys", Schema: map[string]*Schema{ - "route": &Schema{ + "route": { Type: TypeSet, Optional: true, Elem: &Resource{ Schema: map[string]*Schema{ - "index": &Schema{ + "index": { Type: TypeInt, Required: true, }, - "gateway-name": &Schema{ + "gateway-name": { Type: TypeString, Optional: true, }, @@ -2550,15 +2550,15 @@ func TestShimSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "route.#": &terraform.ResourceAttrDiff{ + "route.#": { Old: "0", New: "1", }, - "route.1.index": &terraform.ResourceAttrDiff{ + "route.1.index": { Old: "", New: "1", }, - "route.1.gateway-name": &terraform.ResourceAttrDiff{ + "route.1.gateway-name": { Old: "", New: "hello", }, @@ -2571,13 +2571,13 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "StateFunc in nested set (#1759)", Schema: map[string]*Schema{ - "service_account": &Schema{ + "service_account": { Type: TypeList, Optional: true, ForceNew: true, Elem: &Resource{ Schema: map[string]*Schema{ - "scopes": &Schema{ + "scopes": { Type: TypeSet, Required: true, ForceNew: true, @@ -2612,17 +2612,17 @@ func TestShimSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "service_account.#": &terraform.ResourceAttrDiff{ + "service_account.#": { Old: "0", New: "1", RequiresNew: true, }, - "service_account.0.scopes.#": &terraform.ResourceAttrDiff{ + "service_account.0.scopes.#": { Old: "0", New: "1", RequiresNew: true, }, - "service_account.0.scopes.123": &terraform.ResourceAttrDiff{ + "service_account.0.scopes.123": { Old: "", New: "123!", NewExtra: "123", @@ -2637,7 +2637,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "Removing set elements", Schema: map[string]*Schema{ - "instances": &Schema{ + "instances": { Type: TypeSet, Elem: &Schema{Type: TypeString}, Optional: true, @@ -2663,17 +2663,17 @@ func TestShimSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "instances.2": &terraform.ResourceAttrDiff{ + "instances.2": { Old: "22", New: "", NewRemoved: true, RequiresNew: true, }, - "instances.3": &terraform.ResourceAttrDiff{ + "instances.3": { Old: "333", New: "333", }, - "instances.4": &terraform.ResourceAttrDiff{ + "instances.4": { Old: "", New: "4444", RequiresNew: true, @@ -2687,15 +2687,15 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "Bools can be set with 0/1 in config, still get true/false", Schema: map[string]*Schema{ - "one": &Schema{ + "one": { Type: TypeBool, Optional: true, }, - "two": &Schema{ + "two": { Type: TypeBool, Optional: true, }, - "three": &Schema{ + "three": { Type: TypeBool, Optional: true, }, @@ -2717,15 +2717,15 @@ func TestShimSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "one": &terraform.ResourceAttrDiff{ + "one": { Old: "false", New: "true", }, - "two": &terraform.ResourceAttrDiff{ + "two": { Old: "true", New: "false", }, - "three": &terraform.ResourceAttrDiff{ + "three": { Old: "true", New: "false", NewRemoved: true, @@ -2759,7 +2759,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "Set ForceNew only marks the changing element as ForceNew", Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeSet, Required: true, ForceNew: true, @@ -2786,20 +2786,20 @@ func TestShimSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "ports.1": &terraform.ResourceAttrDiff{ + "ports.1": { Old: "1", New: "1", }, - "ports.2": &terraform.ResourceAttrDiff{ + "ports.2": { Old: "2", New: "2", }, - "ports.5": &terraform.ResourceAttrDiff{ + "ports.5": { Old: "", New: "5", RequiresNew: true, }, - "ports.4": &terraform.ResourceAttrDiff{ + "ports.4": { Old: "4", New: "0", NewRemoved: true, @@ -2812,7 +2812,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "removed optional items should trigger ForceNew", Schema: map[string]*Schema{ - "description": &Schema{ + "description": { Type: TypeString, ForceNew: true, Optional: true, @@ -2830,7 +2830,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "description": &terraform.ResourceAttrDiff{ + "description": { Old: "foo", New: "", RequiresNew: true, @@ -2846,7 +2846,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "computed value for boolean field", Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeBool, ForceNew: true, Computed: true, @@ -2864,7 +2864,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "foo": &terraform.ResourceAttrDiff{ + "foo": { Old: "", New: "false", NewComputed: true, @@ -2879,7 +2879,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "Set ForceNew marks count as ForceNew if computed", Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeSet, Required: true, ForceNew: true, @@ -2906,7 +2906,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "ports.#": &terraform.ResourceAttrDiff{ + "ports.#": { NewComputed: true, RequiresNew: true, }, @@ -2917,7 +2917,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "List with computed schema and ForceNew", Schema: map[string]*Schema{ - "config": &Schema{ + "config": { Type: TypeList, Optional: true, ForceNew: true, @@ -2942,7 +2942,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "config.#": &terraform.ResourceAttrDiff{ + "config.#": { Old: "2", New: "", RequiresNew: true, @@ -2957,7 +2957,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "overridden diff with a CustomizeDiff function, ForceNew not in schema", Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Optional: true, Computed: true, @@ -2982,7 +2982,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "availability_zone": &terraform.ResourceAttrDiff{ + "availability_zone": { Old: "", New: "bar", RequiresNew: true, @@ -3000,7 +3000,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { // intended diff still shows up. Name: "overridden removed attribute diff with a CustomizeDiff function, ForceNew not in schema", Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Optional: true, Computed: true, @@ -3023,7 +3023,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "availability_zone": &terraform.ResourceAttrDiff{ + "availability_zone": { Old: "", New: "bar", RequiresNew: true, @@ -3038,7 +3038,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { Name: "overridden diff with a CustomizeDiff function, ForceNew in schema", Schema: map[string]*Schema{ - "availability_zone": &Schema{ + "availability_zone": { Type: TypeString, Optional: true, Computed: true, @@ -3061,7 +3061,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "availability_zone": &terraform.ResourceAttrDiff{ + "availability_zone": { Old: "", New: "bar", RequiresNew: true, @@ -3075,11 +3075,11 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "required field with computed diff added with CustomizeDiff function", Schema: map[string]*Schema{ - "ami_id": &Schema{ + "ami_id": { Type: TypeString, Required: true, }, - "instance_id": &Schema{ + "instance_id": { Type: TypeString, Computed: true, }, @@ -3100,11 +3100,11 @@ func TestShimSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "ami_id": &terraform.ResourceAttrDiff{ + "ami_id": { Old: "", New: "foo", }, - "instance_id": &terraform.ResourceAttrDiff{ + "instance_id": { Old: "", New: "bar", }, @@ -3117,7 +3117,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "Set ForceNew only marks the changing element as ForceNew - CustomizeDiffFunc edition", Schema: map[string]*Schema{ - "ports": &Schema{ + "ports": { Type: TypeSet, Optional: true, Computed: true, @@ -3154,20 +3154,20 @@ func TestShimSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "ports.1": &terraform.ResourceAttrDiff{ + "ports.1": { Old: "1", New: "1", }, - "ports.2": &terraform.ResourceAttrDiff{ + "ports.2": { Old: "2", New: "2", }, - "ports.5": &terraform.ResourceAttrDiff{ + "ports.5": { Old: "", New: "5", RequiresNew: true, }, - "ports.4": &terraform.ResourceAttrDiff{ + "ports.4": { Old: "4", New: "0", NewRemoved: true, @@ -3206,12 +3206,12 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "NewComputed based on a conditional with CustomizeDiffFunc", Schema: map[string]*Schema{ - "etag": &Schema{ + "etag": { Type: TypeString, Optional: true, Computed: true, }, - "version_id": &Schema{ + "version_id": { Type: TypeString, Computed: true, }, @@ -3238,11 +3238,11 @@ func TestShimSchemaMap_Diff(t *testing.T) { Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ - "etag": &terraform.ResourceAttrDiff{ + "etag": { Old: "foo", New: "bar", }, - "version_id": &terraform.ResourceAttrDiff{ + "version_id": { Old: "1", New: "", NewComputed: true, @@ -3256,7 +3256,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "vetoing a diff", Schema: map[string]*Schema{ - "foo": &Schema{ + "foo": { Type: TypeString, Optional: true, Computed: true, @@ -3286,7 +3286,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { { Name: "optional, computed, empty string", Schema: map[string]*Schema{ - "attr": &Schema{ + "attr": { Type: TypeString, Optional: true, Computed: true, diff --git a/internal/configs/configschema/decoder_spec_test.go b/internal/configs/configschema/decoder_spec_test.go index 8189160b8fe..3bffc553591 100644 --- a/internal/configs/configschema/decoder_spec_test.go +++ b/internal/configs/configschema/decoder_spec_test.go @@ -204,13 +204,13 @@ func TestBlockDecoderSpec(t *testing.T) { &hcl.Block{ Type: "map", Labels: []string{"foo"}, - LabelRanges: []hcl.Range{hcl.Range{}}, + LabelRanges: []hcl.Range{{}}, Body: hcl.EmptyBody(), }, &hcl.Block{ Type: "map", Labels: []string{"bar"}, - LabelRanges: []hcl.Range{hcl.Range{}}, + LabelRanges: []hcl.Range{{}}, Body: hcl.EmptyBody(), }, &hcl.Block{ @@ -291,13 +291,13 @@ func TestBlockDecoderSpec(t *testing.T) { &hcl.Block{ Type: "map", Labels: []string{"foo"}, - LabelRanges: []hcl.Range{hcl.Range{}}, + LabelRanges: []hcl.Range{{}}, Body: hcl.EmptyBody(), }, &hcl.Block{ Type: "map", Labels: []string{"bar"}, - LabelRanges: []hcl.Range{hcl.Range{}}, + LabelRanges: []hcl.Range{{}}, Body: hcl.EmptyBody(), }, }, diff --git a/internal/configs/configschema/implied_type_test.go b/internal/configs/configschema/implied_type_test.go index 85e4a88d552..b7bdd1d92ed 100644 --- a/internal/configs/configschema/implied_type_test.go +++ b/internal/configs/configschema/implied_type_test.go @@ -50,7 +50,7 @@ func TestBlockImpliedType(t *testing.T) { "blocks": { &Block{ BlockTypes: map[string]*NestedBlock{ - "single": &NestedBlock{ + "single": { Nesting: NestingSingle, Block: Block{ Attributes: map[string]*Attribute{ @@ -61,13 +61,13 @@ func TestBlockImpliedType(t *testing.T) { }, }, }, - "list": &NestedBlock{ + "list": { Nesting: NestingList, }, - "set": &NestedBlock{ + "set": { Nesting: NestingSet, }, - "map": &NestedBlock{ + "map": { Nesting: NestingMap, }, }, @@ -84,15 +84,15 @@ func TestBlockImpliedType(t *testing.T) { "deep block nesting": { &Block{ BlockTypes: map[string]*NestedBlock{ - "single": &NestedBlock{ + "single": { Nesting: NestingSingle, Block: Block{ BlockTypes: map[string]*NestedBlock{ - "list": &NestedBlock{ + "list": { Nesting: NestingList, Block: Block{ BlockTypes: map[string]*NestedBlock{ - "set": &NestedBlock{ + "set": { Nesting: NestingSet, }, }, diff --git a/internal/configs/configschema/internal_validate_test.go b/internal/configs/configschema/internal_validate_test.go index 93ac7f6872e..1e1a5198fbb 100644 --- a/internal/configs/configschema/internal_validate_test.go +++ b/internal/configs/configschema/internal_validate_test.go @@ -19,54 +19,54 @@ func TestBlockInternalValidate(t *testing.T) { "valid": { &Block{ Attributes: map[string]*Attribute{ - "foo": &Attribute{ + "foo": { Type: cty.String, Required: true, }, - "bar": &Attribute{ + "bar": { Type: cty.String, Optional: true, }, - "baz": &Attribute{ + "baz": { Type: cty.String, Computed: true, }, - "baz_maybe": &Attribute{ + "baz_maybe": { Type: cty.String, Optional: true, Computed: true, }, }, BlockTypes: map[string]*NestedBlock{ - "single": &NestedBlock{ + "single": { Nesting: NestingSingle, Block: Block{}, }, - "single_required": &NestedBlock{ + "single_required": { Nesting: NestingSingle, Block: Block{}, MinItems: 1, MaxItems: 1, }, - "list": &NestedBlock{ + "list": { Nesting: NestingList, Block: Block{}, }, - "list_required": &NestedBlock{ + "list_required": { Nesting: NestingList, Block: Block{}, MinItems: 1, }, - "set": &NestedBlock{ + "set": { Nesting: NestingSet, Block: Block{}, }, - "set_required": &NestedBlock{ + "set_required": { Nesting: NestingSet, Block: Block{}, MinItems: 1, }, - "map": &NestedBlock{ + "map": { Nesting: NestingMap, Block: Block{}, }, @@ -77,7 +77,7 @@ func TestBlockInternalValidate(t *testing.T) { "attribute with no flags set": { &Block{ Attributes: map[string]*Attribute{ - "foo": &Attribute{ + "foo": { Type: cty.String, }, }, @@ -87,7 +87,7 @@ func TestBlockInternalValidate(t *testing.T) { "attribute required and optional": { &Block{ Attributes: map[string]*Attribute{ - "foo": &Attribute{ + "foo": { Type: cty.String, Required: true, Optional: true, @@ -99,7 +99,7 @@ func TestBlockInternalValidate(t *testing.T) { "attribute required and computed": { &Block{ Attributes: map[string]*Attribute{ - "foo": &Attribute{ + "foo": { Type: cty.String, Required: true, Computed: true, @@ -111,7 +111,7 @@ func TestBlockInternalValidate(t *testing.T) { "attribute optional and computed": { &Block{ Attributes: map[string]*Attribute{ - "foo": &Attribute{ + "foo": { Type: cty.String, Optional: true, Computed: true, @@ -123,7 +123,7 @@ func TestBlockInternalValidate(t *testing.T) { "attribute with missing type": { &Block{ Attributes: map[string]*Attribute{ - "foo": &Attribute{ + "foo": { Optional: true, }, }, @@ -133,7 +133,7 @@ func TestBlockInternalValidate(t *testing.T) { "attribute with invalid name": { &Block{ Attributes: map[string]*Attribute{ - "fooBar": &Attribute{ + "fooBar": { Type: cty.String, Optional: true, }, @@ -144,7 +144,7 @@ func TestBlockInternalValidate(t *testing.T) { "block type with invalid name": { &Block{ BlockTypes: map[string]*NestedBlock{ - "fooBar": &NestedBlock{ + "fooBar": { Nesting: NestingSingle, }, }, @@ -154,13 +154,13 @@ func TestBlockInternalValidate(t *testing.T) { "colliding names": { &Block{ Attributes: map[string]*Attribute{ - "foo": &Attribute{ + "foo": { Type: cty.String, Optional: true, }, }, BlockTypes: map[string]*NestedBlock{ - "foo": &NestedBlock{ + "foo": { Nesting: NestingSingle, }, }, @@ -170,11 +170,11 @@ func TestBlockInternalValidate(t *testing.T) { "nested block with badness": { &Block{ BlockTypes: map[string]*NestedBlock{ - "bad": &NestedBlock{ + "bad": { Nesting: NestingSingle, Block: Block{ Attributes: map[string]*Attribute{ - "nested_bad": &Attribute{ + "nested_bad": { Type: cty.String, Required: true, Optional: true, @@ -189,11 +189,11 @@ func TestBlockInternalValidate(t *testing.T) { "nested list block with dynamically-typed attribute": { &Block{ BlockTypes: map[string]*NestedBlock{ - "bad": &NestedBlock{ + "bad": { Nesting: NestingList, Block: Block{ Attributes: map[string]*Attribute{ - "nested_bad": &Attribute{ + "nested_bad": { Type: cty.DynamicPseudoType, Optional: true, }, @@ -207,11 +207,11 @@ func TestBlockInternalValidate(t *testing.T) { "nested set block with dynamically-typed attribute": { &Block{ BlockTypes: map[string]*NestedBlock{ - "bad": &NestedBlock{ + "bad": { Nesting: NestingSet, Block: Block{ Attributes: map[string]*Attribute{ - "nested_bad": &Attribute{ + "nested_bad": { Type: cty.DynamicPseudoType, Optional: true, }, diff --git a/internal/configs/hcl2shim/paths_test.go b/internal/configs/hcl2shim/paths_test.go index 4933fa691c8..d9cf3712a47 100644 --- a/internal/configs/hcl2shim/paths_test.go +++ b/internal/configs/hcl2shim/paths_test.go @@ -246,7 +246,7 @@ func TestRequiresReplace(t *testing.T) { "foo": cty.String, }), expected: []cty.Path{ - cty.Path{cty.GetAttrStep{Name: "foo"}}, + {cty.GetAttrStep{Name: "foo"}}, }, }, { @@ -260,8 +260,8 @@ func TestRequiresReplace(t *testing.T) { "bar": cty.String, }), expected: []cty.Path{ - cty.Path{cty.GetAttrStep{Name: "foo"}}, - cty.Path{cty.GetAttrStep{Name: "bar"}}, + {cty.GetAttrStep{Name: "foo"}}, + {cty.GetAttrStep{Name: "bar"}}, }, }, { @@ -275,7 +275,7 @@ func TestRequiresReplace(t *testing.T) { }), }), expected: []cty.Path{ - cty.Path{cty.GetAttrStep{Name: "foo"}, cty.GetAttrStep{Name: "bar"}}, + {cty.GetAttrStep{Name: "foo"}, cty.GetAttrStep{Name: "bar"}}, }, }, { @@ -291,7 +291,7 @@ func TestRequiresReplace(t *testing.T) { }), }), expected: []cty.Path{ - cty.Path{cty.GetAttrStep{Name: "foo"}, cty.GetAttrStep{Name: "bar"}, cty.GetAttrStep{Name: "baz"}}, + {cty.GetAttrStep{Name: "foo"}, cty.GetAttrStep{Name: "bar"}, cty.GetAttrStep{Name: "baz"}}, }, }, { @@ -304,7 +304,7 @@ func TestRequiresReplace(t *testing.T) { "foo": cty.Map(cty.String), }), expected: []cty.Path{ - cty.Path{cty.GetAttrStep{Name: "foo"}}, + {cty.GetAttrStep{Name: "foo"}}, }, }, { @@ -317,7 +317,7 @@ func TestRequiresReplace(t *testing.T) { "foo": cty.Map(cty.String), }), expected: []cty.Path{ - cty.Path{cty.GetAttrStep{Name: "foo"}}, + {cty.GetAttrStep{Name: "foo"}}, }, }, { @@ -333,7 +333,7 @@ func TestRequiresReplace(t *testing.T) { )), }), expected: []cty.Path{ - cty.Path{cty.GetAttrStep{Name: "foo"}, cty.IndexStep{Key: cty.StringVal("bar")}, cty.GetAttrStep{Name: "baz"}}, + {cty.GetAttrStep{Name: "foo"}, cty.IndexStep{Key: cty.StringVal("bar")}, cty.GetAttrStep{Name: "baz"}}, }, }, { @@ -349,7 +349,7 @@ func TestRequiresReplace(t *testing.T) { )), }), expected: []cty.Path{ - cty.Path{cty.GetAttrStep{Name: "foo"}, cty.IndexStep{Key: cty.NumberIntVal(1)}, cty.GetAttrStep{Name: "baz"}}, + {cty.GetAttrStep{Name: "foo"}, cty.IndexStep{Key: cty.NumberIntVal(1)}, cty.GetAttrStep{Name: "baz"}}, }, }, } { diff --git a/internal/helper/plugin/grpc_provider_test.go b/internal/helper/plugin/grpc_provider_test.go index 7fb2cb2e13c..8204a014be8 100644 --- a/internal/helper/plugin/grpc_provider_test.go +++ b/internal/helper/plugin/grpc_provider_test.go @@ -660,7 +660,7 @@ func TestPrepareProviderConfig(t *testing.T) { { Name: "test prepare", Schema: map[string]*schema.Schema{ - "foo": &schema.Schema{ + "foo": { Type: schema.TypeString, Optional: true, }, @@ -675,7 +675,7 @@ func TestPrepareProviderConfig(t *testing.T) { { Name: "test default", Schema: map[string]*schema.Schema{ - "foo": &schema.Schema{ + "foo": { Type: schema.TypeString, Optional: true, Default: "default", @@ -691,7 +691,7 @@ func TestPrepareProviderConfig(t *testing.T) { { Name: "test defaultfunc", Schema: map[string]*schema.Schema{ - "foo": &schema.Schema{ + "foo": { Type: schema.TypeString, Optional: true, DefaultFunc: func() (interface{}, error) { @@ -709,7 +709,7 @@ func TestPrepareProviderConfig(t *testing.T) { { Name: "test default required", Schema: map[string]*schema.Schema{ - "foo": &schema.Schema{ + "foo": { Type: schema.TypeString, Required: true, DefaultFunc: func() (interface{}, error) { @@ -727,7 +727,7 @@ func TestPrepareProviderConfig(t *testing.T) { { Name: "test incorrect type", Schema: map[string]*schema.Schema{ - "foo": &schema.Schema{ + "foo": { Type: schema.TypeString, Required: true, }, @@ -742,7 +742,7 @@ func TestPrepareProviderConfig(t *testing.T) { { Name: "test incorrect default type", Schema: map[string]*schema.Schema{ - "foo": &schema.Schema{ + "foo": { Type: schema.TypeString, Optional: true, Default: true, @@ -758,7 +758,7 @@ func TestPrepareProviderConfig(t *testing.T) { { Name: "test incorrect default bool type", Schema: map[string]*schema.Schema{ - "foo": &schema.Schema{ + "foo": { Type: schema.TypeBool, Optional: true, Default: "", @@ -774,7 +774,7 @@ func TestPrepareProviderConfig(t *testing.T) { { Name: "test deprecated default", Schema: map[string]*schema.Schema{ - "foo": &schema.Schema{ + "foo": { Type: schema.TypeString, Optional: true, Default: "do not use", diff --git a/internal/helper/plugin/unknown_test.go b/internal/helper/plugin/unknown_test.go index 5ed9f79626c..a0d2782b1ad 100644 --- a/internal/helper/plugin/unknown_test.go +++ b/internal/helper/plugin/unknown_test.go @@ -68,7 +68,7 @@ func TestSetUnknowns(t *testing.T) { // if the object has no computed attributes, it should stay null &configschema.Block{ Attributes: map[string]*configschema.Attribute{ - "foo": &configschema.Attribute{ + "foo": { Type: cty.String, }, }, @@ -104,7 +104,7 @@ func TestSetUnknowns(t *testing.T) { // the set value should remain null &configschema.Block{ Attributes: map[string]*configschema.Attribute{ - "foo": &configschema.Attribute{ + "foo": { Type: cty.String, Computed: true, }, diff --git a/internal/plugin/convert/schema_test.go b/internal/plugin/convert/schema_test.go index eeaf96f6ca1..c48d0485a63 100644 --- a/internal/plugin/convert/schema_test.go +++ b/internal/plugin/convert/schema_test.go @@ -106,16 +106,16 @@ func TestConvertSchemaBlocks(t *testing.T) { }, &configschema.Block{ BlockTypes: map[string]*configschema.NestedBlock{ - "list": &configschema.NestedBlock{ + "list": { Nesting: configschema.NestingList, }, - "map": &configschema.NestedBlock{ + "map": { Nesting: configschema.NestingMap, }, - "set": &configschema.NestedBlock{ + "set": { Nesting: configschema.NestingSet, }, - "single": &configschema.NestedBlock{ + "single": { Nesting: configschema.NestingSingle, Block: configschema.Block{ Attributes: map[string]*configschema.Attribute{ @@ -157,15 +157,15 @@ func TestConvertSchemaBlocks(t *testing.T) { }, &configschema.Block{ BlockTypes: map[string]*configschema.NestedBlock{ - "single": &configschema.NestedBlock{ + "single": { Nesting: configschema.NestingSingle, Block: configschema.Block{ BlockTypes: map[string]*configschema.NestedBlock{ - "list": &configschema.NestedBlock{ + "list": { Nesting: configschema.NestingList, Block: configschema.Block{ BlockTypes: map[string]*configschema.NestedBlock{ - "set": &configschema.NestedBlock{ + "set": { Nesting: configschema.NestingSet, }, }, @@ -278,16 +278,16 @@ func TestConvertProtoSchemaBlocks(t *testing.T) { }, &configschema.Block{ BlockTypes: map[string]*configschema.NestedBlock{ - "list": &configschema.NestedBlock{ + "list": { Nesting: configschema.NestingList, }, - "map": &configschema.NestedBlock{ + "map": { Nesting: configschema.NestingMap, }, - "set": &configschema.NestedBlock{ + "set": { Nesting: configschema.NestingSet, }, - "single": &configschema.NestedBlock{ + "single": { Nesting: configschema.NestingSingle, Block: configschema.Block{ Attributes: map[string]*configschema.Attribute{ @@ -329,15 +329,15 @@ func TestConvertProtoSchemaBlocks(t *testing.T) { }, &configschema.Block{ BlockTypes: map[string]*configschema.NestedBlock{ - "single": &configschema.NestedBlock{ + "single": { Nesting: configschema.NestingSingle, Block: configschema.Block{ BlockTypes: map[string]*configschema.NestedBlock{ - "list": &configschema.NestedBlock{ + "list": { Nesting: configschema.NestingList, Block: configschema.Block{ BlockTypes: map[string]*configschema.NestedBlock{ - "set": &configschema.NestedBlock{ + "set": { Nesting: configschema.NestingSet, }, }, diff --git a/scripts/gofmtcheck.sh b/scripts/gofmtcheck.sh index c65c78b921b..bad9ba41aae 100755 --- a/scripts/gofmtcheck.sh +++ b/scripts/gofmtcheck.sh @@ -2,7 +2,7 @@ set -e echo "==> Checking that code complies with gofmt requirements..." -gofmt_files=$(gofmt -l `find . -name '*.go'`) +gofmt_files=$(gofmt -s -l `find . -name '*.go'`) if [[ -n ${gofmt_files} ]]; then echo 'gofmt needs running on the following files:' echo "${gofmt_files}" diff --git a/terraform/diff.go b/terraform/diff.go index 258e0ac9b21..067ab13aeff 100644 --- a/terraform/diff.go +++ b/terraform/diff.go @@ -809,7 +809,7 @@ func (d *InstanceDiff) Same(d2 *InstanceDiff) (bool, string) { // Found it! Ignore all of these. The prefix here is stripping // off the "%" so it is just "k." prefix := k[:len(k)-1] - for k2, _ := range d.Attributes { + for k2 := range d.Attributes { if strings.HasPrefix(k2, prefix) { ignoreAttrs[k2] = struct{}{} } @@ -849,17 +849,17 @@ func (d *InstanceDiff) Same(d2 *InstanceDiff) (bool, string) { // same attributes. To start, build up the check map to be all the keys. checkOld := make(map[string]struct{}) checkNew := make(map[string]struct{}) - for k, _ := range d.Attributes { + for k := range d.Attributes { checkOld[k] = struct{}{} } - for k, _ := range d2.CopyAttributes() { + for k := range d2.CopyAttributes() { checkNew[k] = struct{}{} } // Make an ordered list so we are sure the approximated hashes are left // to process at the end of the loop keys := make([]string, 0, len(d.Attributes)) - for k, _ := range d.Attributes { + for k := range d.Attributes { keys = append(keys, k) } sort.StringSlice(keys).Sort() @@ -917,7 +917,7 @@ func (d *InstanceDiff) Same(d2 *InstanceDiff) (bool, string) { return false, fmt.Sprintf("regexp failed to compile; err: %#v", err) } - for k2, _ := range checkNew { + for k2 := range checkNew { if re.MatchString(k2) { delete(checkNew, k2) } @@ -954,12 +954,12 @@ func (d *InstanceDiff) Same(d2 *InstanceDiff) (bool, string) { // This is a computed list, set, or map, so remove any keys with // this prefix from the check list. kprefix := k[:len(k)-matchLen] - for k2, _ := range checkOld { + for k2 := range checkOld { if strings.HasPrefix(k2, kprefix) { delete(checkOld, k2) } } - for k2, _ := range checkNew { + for k2 := range checkNew { if strings.HasPrefix(k2, kprefix) { delete(checkNew, k2) } @@ -979,7 +979,7 @@ func (d *InstanceDiff) Same(d2 *InstanceDiff) (bool, string) { // Check for leftover attributes if len(checkNew) > 0 { extras := make([]string, 0, len(checkNew)) - for attr, _ := range checkNew { + for attr := range checkNew { extras = append(extras, attr) } return false, diff --git a/terraform/diff_test.go b/terraform/diff_test.go index 3fc25118008..81235f7cd4f 100644 --- a/terraform/diff_test.go +++ b/terraform/diff_test.go @@ -22,7 +22,7 @@ func TestInstanceDiff_ChangeType(t *testing.T) { { &InstanceDiff{ Attributes: map[string]*ResourceAttrDiff{ - "foo": &ResourceAttrDiff{ + "foo": { Old: "", New: "bar", }, @@ -33,7 +33,7 @@ func TestInstanceDiff_ChangeType(t *testing.T) { { &InstanceDiff{ Attributes: map[string]*ResourceAttrDiff{ - "foo": &ResourceAttrDiff{ + "foo": { Old: "", New: "bar", RequiresNew: true, @@ -46,7 +46,7 @@ func TestInstanceDiff_ChangeType(t *testing.T) { &InstanceDiff{ Destroy: true, Attributes: map[string]*ResourceAttrDiff{ - "foo": &ResourceAttrDiff{ + "foo": { Old: "", New: "bar", RequiresNew: true, @@ -59,7 +59,7 @@ func TestInstanceDiff_ChangeType(t *testing.T) { &InstanceDiff{ DestroyTainted: true, Attributes: map[string]*ResourceAttrDiff{ - "foo": &ResourceAttrDiff{ + "foo": { Old: "", New: "bar", RequiresNew: true, @@ -99,7 +99,7 @@ func TestInstanceDiff_Empty(t *testing.T) { rd = &InstanceDiff{ Attributes: map[string]*ResourceAttrDiff{ - "foo": &ResourceAttrDiff{ + "foo": { New: "bar", }, }, @@ -113,7 +113,7 @@ func TestInstanceDiff_Empty(t *testing.T) { func TestInstanceDiff_RequiresNew(t *testing.T) { rd := &InstanceDiff{ Attributes: map[string]*ResourceAttrDiff{ - "foo": &ResourceAttrDiff{}, + "foo": {}, }, } @@ -173,12 +173,12 @@ func TestInstanceDiffSame(t *testing.T) { { &InstanceDiff{ Attributes: map[string]*ResourceAttrDiff{ - "foo": &ResourceAttrDiff{}, + "foo": {}, }, }, &InstanceDiff{ Attributes: map[string]*ResourceAttrDiff{ - "foo": &ResourceAttrDiff{}, + "foo": {}, }, }, true, @@ -188,12 +188,12 @@ func TestInstanceDiffSame(t *testing.T) { { &InstanceDiff{ Attributes: map[string]*ResourceAttrDiff{ - "bar": &ResourceAttrDiff{}, + "bar": {}, }, }, &InstanceDiff{ Attributes: map[string]*ResourceAttrDiff{ - "foo": &ResourceAttrDiff{}, + "foo": {}, }, }, false, @@ -204,13 +204,13 @@ func TestInstanceDiffSame(t *testing.T) { { &InstanceDiff{ Attributes: map[string]*ResourceAttrDiff{ - "foo": &ResourceAttrDiff{}, + "foo": {}, }, }, &InstanceDiff{ Attributes: map[string]*ResourceAttrDiff{ - "foo": &ResourceAttrDiff{}, - "bar": &ResourceAttrDiff{}, + "foo": {}, + "bar": {}, }, }, false, @@ -220,12 +220,12 @@ func TestInstanceDiffSame(t *testing.T) { { &InstanceDiff{ Attributes: map[string]*ResourceAttrDiff{ - "foo": &ResourceAttrDiff{RequiresNew: true}, + "foo": {RequiresNew: true}, }, }, &InstanceDiff{ Attributes: map[string]*ResourceAttrDiff{ - "foo": &ResourceAttrDiff{RequiresNew: false}, + "foo": {RequiresNew: false}, }, }, false, @@ -236,7 +236,7 @@ func TestInstanceDiffSame(t *testing.T) { { &InstanceDiff{ Attributes: map[string]*ResourceAttrDiff{ - "foo": &ResourceAttrDiff{ + "foo": { Old: "", New: "${var.foo}", NewComputed: true, @@ -245,7 +245,7 @@ func TestInstanceDiffSame(t *testing.T) { }, &InstanceDiff{ Attributes: map[string]*ResourceAttrDiff{ - "foo": &ResourceAttrDiff{ + "foo": { Old: "0", New: "1", }, @@ -259,7 +259,7 @@ func TestInstanceDiffSame(t *testing.T) { { &InstanceDiff{ Attributes: map[string]*ResourceAttrDiff{ - "foo": &ResourceAttrDiff{ + "foo": { Old: "", New: "${var.foo}", NewComputed: true, @@ -277,7 +277,7 @@ func TestInstanceDiffSame(t *testing.T) { { &InstanceDiff{ Attributes: map[string]*ResourceAttrDiff{ - "foo.#": &ResourceAttrDiff{ + "foo.#": { Old: "", New: "", NewComputed: true, @@ -286,12 +286,12 @@ func TestInstanceDiffSame(t *testing.T) { }, &InstanceDiff{ Attributes: map[string]*ResourceAttrDiff{ - "foo.1": &ResourceAttrDiff{ + "foo.1": { Old: "foo", New: "", NewRemoved: true, }, - "foo.2": &ResourceAttrDiff{ + "foo.2": { Old: "", New: "bar", }, @@ -304,16 +304,16 @@ func TestInstanceDiffSame(t *testing.T) { { &InstanceDiff{ Attributes: map[string]*ResourceAttrDiff{ - "foo.#": &ResourceAttrDiff{NewComputed: true}, + "foo.#": {NewComputed: true}, }, }, &InstanceDiff{ Attributes: map[string]*ResourceAttrDiff{ - "foo.#": &ResourceAttrDiff{ + "foo.#": { Old: "0", New: "1", }, - "foo.0": &ResourceAttrDiff{ + "foo.0": { Old: "", New: "12", }, @@ -326,11 +326,11 @@ func TestInstanceDiffSame(t *testing.T) { { &InstanceDiff{ Attributes: map[string]*ResourceAttrDiff{ - "foo.#": &ResourceAttrDiff{ + "foo.#": { Old: "0", New: "1", }, - "foo.~35964334.bar": &ResourceAttrDiff{ + "foo.~35964334.bar": { Old: "", New: "${var.foo}", }, @@ -338,11 +338,11 @@ func TestInstanceDiffSame(t *testing.T) { }, &InstanceDiff{ Attributes: map[string]*ResourceAttrDiff{ - "foo.#": &ResourceAttrDiff{ + "foo.#": { Old: "0", New: "1", }, - "foo.87654323.bar": &ResourceAttrDiff{ + "foo.87654323.bar": { Old: "", New: "12", }, @@ -355,7 +355,7 @@ func TestInstanceDiffSame(t *testing.T) { { &InstanceDiff{ Attributes: map[string]*ResourceAttrDiff{ - "foo.#": &ResourceAttrDiff{ + "foo.#": { Old: "0", NewComputed: true, }, @@ -372,7 +372,7 @@ func TestInstanceDiffSame(t *testing.T) { { &InstanceDiff{ Attributes: map[string]*ResourceAttrDiff{ - "foo.#": &ResourceAttrDiff{ + "foo.#": { Old: "0", NewComputed: true, RequiresNew: true, @@ -390,7 +390,7 @@ func TestInstanceDiffSame(t *testing.T) { { &InstanceDiff{ Attributes: map[string]*ResourceAttrDiff{ - "foo.#": &ResourceAttrDiff{ + "foo.#": { Old: "0", NewComputed: true, RequiresNew: true, @@ -410,7 +410,7 @@ func TestInstanceDiffSame(t *testing.T) { { &InstanceDiff{ Attributes: map[string]*ResourceAttrDiff{ - "foo.#": &ResourceAttrDiff{ + "foo.#": { Old: "0", NewComputed: true, RequiresNew: true, @@ -421,11 +421,11 @@ func TestInstanceDiffSame(t *testing.T) { }, &InstanceDiff{ Attributes: map[string]*ResourceAttrDiff{ - "foo.#": &ResourceAttrDiff{ + "foo.#": { Old: "1", New: "1", }, - "foo.12": &ResourceAttrDiff{ + "foo.12": { Old: "4", New: "12", RequiresNew: true, @@ -445,11 +445,11 @@ func TestInstanceDiffSame(t *testing.T) { { &InstanceDiff{ Attributes: map[string]*ResourceAttrDiff{ - "foo.#": &ResourceAttrDiff{ + "foo.#": { Old: "0", New: "1", }, - "foo.~35964334.bar": &ResourceAttrDiff{ + "foo.~35964334.bar": { Old: "", New: "${var.foo}", }, @@ -457,19 +457,19 @@ func TestInstanceDiffSame(t *testing.T) { }, &InstanceDiff{ Attributes: map[string]*ResourceAttrDiff{ - "foo.#": &ResourceAttrDiff{ + "foo.#": { Old: "0", New: "2", }, - "foo.87654323.bar": &ResourceAttrDiff{ + "foo.87654323.bar": { Old: "", New: "12", }, - "foo.87654325.bar": &ResourceAttrDiff{ + "foo.87654325.bar": { Old: "", New: "12", }, - "foo.87654325.baz": &ResourceAttrDiff{ + "foo.87654325.baz": { Old: "", New: "12", }, @@ -483,7 +483,7 @@ func TestInstanceDiffSame(t *testing.T) { { &InstanceDiff{ Attributes: map[string]*ResourceAttrDiff{ - "foo.%": &ResourceAttrDiff{ + "foo.%": { Old: "", New: "", NewComputed: true, @@ -492,12 +492,12 @@ func TestInstanceDiffSame(t *testing.T) { }, &InstanceDiff{ Attributes: map[string]*ResourceAttrDiff{ - "foo.%": &ResourceAttrDiff{ + "foo.%": { Old: "0", New: "1", NewComputed: false, }, - "foo.val": &ResourceAttrDiff{ + "foo.val": { Old: "", New: "something", }, @@ -518,12 +518,12 @@ func TestInstanceDiffSame(t *testing.T) { { &InstanceDiff{ Attributes: map[string]*ResourceAttrDiff{ - "somemap.oldkey": &ResourceAttrDiff{ + "somemap.oldkey": { Old: "long ago", New: "", NewRemoved: true, }, - "somemap.newkey": &ResourceAttrDiff{ + "somemap.newkey": { Old: "", New: "brave new world", }, @@ -531,7 +531,7 @@ func TestInstanceDiffSame(t *testing.T) { }, &InstanceDiff{ Attributes: map[string]*ResourceAttrDiff{ - "somemap.newkey": &ResourceAttrDiff{ + "somemap.newkey": { Old: "", New: "brave new world", }, @@ -549,16 +549,16 @@ func TestInstanceDiffSame(t *testing.T) { { &InstanceDiff{ Attributes: map[string]*ResourceAttrDiff{ - "reqnew": &ResourceAttrDiff{ + "reqnew": { Old: "old", New: "new", RequiresNew: true, }, - "somemap.#": &ResourceAttrDiff{ + "somemap.#": { Old: "1", New: "0", }, - "somemap.oldkey": &ResourceAttrDiff{ + "somemap.oldkey": { Old: "long ago", New: "", NewRemoved: true, @@ -567,7 +567,7 @@ func TestInstanceDiffSame(t *testing.T) { }, &InstanceDiff{ Attributes: map[string]*ResourceAttrDiff{ - "reqnew": &ResourceAttrDiff{ + "reqnew": { Old: "", New: "new", RequiresNew: true, @@ -581,16 +581,16 @@ func TestInstanceDiffSame(t *testing.T) { { &InstanceDiff{ Attributes: map[string]*ResourceAttrDiff{ - "reqnew": &ResourceAttrDiff{ + "reqnew": { Old: "old", New: "new", RequiresNew: true, }, - "somemap.%": &ResourceAttrDiff{ + "somemap.%": { Old: "1", New: "0", }, - "somemap.oldkey": &ResourceAttrDiff{ + "somemap.oldkey": { Old: "long ago", New: "", NewRemoved: true, @@ -599,7 +599,7 @@ func TestInstanceDiffSame(t *testing.T) { }, &InstanceDiff{ Attributes: map[string]*ResourceAttrDiff{ - "reqnew": &ResourceAttrDiff{ + "reqnew": { Old: "", New: "new", RequiresNew: true, @@ -614,19 +614,19 @@ func TestInstanceDiffSame(t *testing.T) { { &InstanceDiff{ Attributes: map[string]*ResourceAttrDiff{ - "foo.#": &ResourceAttrDiff{ + "foo.#": { Old: "0", New: "1", }, - "foo.~1.outer_val": &ResourceAttrDiff{ + "foo.~1.outer_val": { Old: "", New: "foo", }, - "foo.~1.inner.#": &ResourceAttrDiff{ + "foo.~1.inner.#": { Old: "0", New: "1", }, - "foo.~1.inner.~2.value": &ResourceAttrDiff{ + "foo.~1.inner.~2.value": { Old: "", New: "${var.bar}", NewComputed: true, @@ -635,19 +635,19 @@ func TestInstanceDiffSame(t *testing.T) { }, &InstanceDiff{ Attributes: map[string]*ResourceAttrDiff{ - "foo.#": &ResourceAttrDiff{ + "foo.#": { Old: "0", New: "1", }, - "foo.12.outer_val": &ResourceAttrDiff{ + "foo.12.outer_val": { Old: "", New: "foo", }, - "foo.12.inner.#": &ResourceAttrDiff{ + "foo.12.inner.#": { Old: "0", New: "1", }, - "foo.12.inner.42.value": &ResourceAttrDiff{ + "foo.12.inner.42.value": { Old: "", New: "baz", }, @@ -661,19 +661,19 @@ func TestInstanceDiffSame(t *testing.T) { { &InstanceDiff{ Attributes: map[string]*ResourceAttrDiff{ - "foo.#": &ResourceAttrDiff{ + "foo.#": { Old: "0", New: "1", }, - "foo.~1.outer_val": &ResourceAttrDiff{ + "foo.~1.outer_val": { Old: "", New: "foo", }, - "foo.~1.inner.#": &ResourceAttrDiff{ + "foo.~1.inner.#": { Old: "0", New: "1", }, - "foo.~1.inner.0.value": &ResourceAttrDiff{ + "foo.~1.inner.0.value": { Old: "", New: "${var.bar}", NewComputed: true, @@ -682,19 +682,19 @@ func TestInstanceDiffSame(t *testing.T) { }, &InstanceDiff{ Attributes: map[string]*ResourceAttrDiff{ - "foo.#": &ResourceAttrDiff{ + "foo.#": { Old: "0", New: "1", }, - "foo.12.outer_val": &ResourceAttrDiff{ + "foo.12.outer_val": { Old: "", New: "foo", }, - "foo.12.inner.#": &ResourceAttrDiff{ + "foo.12.inner.#": { Old: "0", New: "1", }, - "foo.12.inner.0.value": &ResourceAttrDiff{ + "foo.12.inner.0.value": { Old: "", New: "baz", }, @@ -710,12 +710,12 @@ func TestInstanceDiffSame(t *testing.T) { { &InstanceDiff{ Attributes: map[string]*ResourceAttrDiff{ - "foo.%": &ResourceAttrDiff{ + "foo.%": { Old: "1", New: "0", RequiresNew: true, }, - "foo.bar": &ResourceAttrDiff{ + "foo.bar": { Old: "baz", New: "", NewRemoved: true, @@ -731,12 +731,12 @@ func TestInstanceDiffSame(t *testing.T) { { &InstanceDiff{ Attributes: map[string]*ResourceAttrDiff{ - "foo.#": &ResourceAttrDiff{ + "foo.#": { Old: "1", New: "0", RequiresNew: true, }, - "foo.0": &ResourceAttrDiff{ + "foo.0": { Old: "baz", New: "", NewRemoved: true, @@ -755,7 +755,7 @@ func TestInstanceDiffSame(t *testing.T) { &InstanceDiff{ DestroyTainted: true, Attributes: map[string]*ResourceAttrDiff{ - "foo": &ResourceAttrDiff{ + "foo": { Old: "foo", New: "foo", }, @@ -764,7 +764,7 @@ func TestInstanceDiffSame(t *testing.T) { &InstanceDiff{ DestroyTainted: true, Attributes: map[string]*ResourceAttrDiff{ - "foo": &ResourceAttrDiff{ + "foo": { Old: "", New: "foo", }, @@ -777,11 +777,11 @@ func TestInstanceDiffSame(t *testing.T) { { &InstanceDiff{ Attributes: map[string]*ResourceAttrDiff{ - "foo": &ResourceAttrDiff{ + "foo": { Old: "foo", New: "foo", }, - "bar": &ResourceAttrDiff{ + "bar": { Old: "bar", New: "baz", RequiresNew: true, @@ -790,11 +790,11 @@ func TestInstanceDiffSame(t *testing.T) { }, &InstanceDiff{ Attributes: map[string]*ResourceAttrDiff{ - "foo": &ResourceAttrDiff{ + "foo": { Old: "", New: "foo", }, - "bar": &ResourceAttrDiff{ + "bar": { Old: "", New: "baz", RequiresNew: true, diff --git a/terraform/resource_test.go b/terraform/resource_test.go index babd4186e26..ae515a40823 100644 --- a/terraform/resource_test.go +++ b/terraform/resource_test.go @@ -592,12 +592,12 @@ func TestNewResourceConfigShimmed(t *testing.T) { }), Schema: &configschema.Block{ Attributes: map[string]*configschema.Attribute{ - "bar": &configschema.Attribute{ + "bar": { Type: cty.Set(cty.Object(map[string]cty.Type{ "val": cty.String, })), }, - "baz": &configschema.Attribute{ + "baz": { Type: cty.Set(cty.Object(map[string]cty.Type{ "obj": cty.Object(map[string]cty.Type{ "attr": cty.List(cty.String), diff --git a/terraform/state.go b/terraform/state.go index 3a8480436f9..a2d6395a922 100644 --- a/terraform/state.go +++ b/terraform/state.go @@ -956,7 +956,7 @@ func (m *ModuleState) String() string { } names := make([]string, 0, len(m.Resources)) - for name, _ := range m.Resources { + for name := range m.Resources { names = append(names, name) } @@ -993,7 +993,7 @@ func (m *ModuleState) String() string { attributes = rs.Primary.Attributes } attrKeys := make([]string, 0, len(attributes)) - for ak, _ := range attributes { + for ak := range attributes { if ak == "id" { continue } @@ -1028,7 +1028,7 @@ func (m *ModuleState) String() string { buf.WriteString("\nOutputs:\n\n") ks := make([]string, 0, len(m.Outputs)) - for k, _ := range m.Outputs { + for k := range m.Outputs { ks = append(ks, k) } @@ -1043,7 +1043,7 @@ func (m *ModuleState) String() string { buf.WriteString(fmt.Sprintf("%s = %s\n", k, vTyped)) case map[string]interface{}: var mapKeys []string - for key, _ := range vTyped { + for key := range vTyped { mapKeys = append(mapKeys, key) } sort.Strings(mapKeys) @@ -1575,7 +1575,7 @@ func (s *InstanceState) String() string { attributes := s.Attributes attrKeys := make([]string, 0, len(attributes)) - for ak, _ := range attributes { + for ak := range attributes { if ak == "id" { continue } diff --git a/terraform/state_test.go b/terraform/state_test.go index 590b44a0c53..48ce025b1b9 100644 --- a/terraform/state_test.go +++ b/terraform/state_test.go @@ -25,10 +25,10 @@ func TestStateValidate(t *testing.T) { "multiple modules": { &State{ Modules: []*ModuleState{ - &ModuleState{ + { Path: []string{"root", "foo"}, }, - &ModuleState{ + { Path: []string{"root", "foo"}, }, }, @@ -59,8 +59,8 @@ func TestStateAddModule(t *testing.T) { addrs.RootModuleInstance.Child("child", addrs.NoKey), }, [][]string{ - []string{"root"}, - []string{"root", "child"}, + {"root"}, + {"root", "child"}, }, }, @@ -72,10 +72,10 @@ func TestStateAddModule(t *testing.T) { addrs.RootModuleInstance.Child("bar", addrs.NoKey), }, [][]string{ - []string{"root"}, - []string{"root", "bar"}, - []string{"root", "foo"}, - []string{"root", "foo", "bar"}, + {"root"}, + {"root", "bar"}, + {"root", "foo"}, + {"root", "foo", "bar"}, }, }, // Same last element, different middle element @@ -88,11 +88,11 @@ func TestStateAddModule(t *testing.T) { addrs.RootModuleInstance.Child("bar", addrs.NoKey), }, [][]string{ - []string{"root"}, - []string{"root", "bar"}, - []string{"root", "foo"}, - []string{"root", "bar", "bar"}, - []string{"root", "foo", "bar"}, + {"root"}, + {"root", "bar"}, + {"root", "foo"}, + {"root", "bar", "bar"}, + {"root", "foo", "bar"}, }, }, } @@ -134,10 +134,10 @@ func TestStateDeepCopy(t *testing.T) { &State{ Version: 6, Modules: []*ModuleState{ - &ModuleState{ + { Path: rootModulePath, Resources: map[string]*ResourceState{ - "test_instance.foo": &ResourceState{ + "test_instance.foo": { Primary: &InstanceState{ Meta: map[string]interface{}{}, }, @@ -154,10 +154,10 @@ func TestStateDeepCopy(t *testing.T) { &State{ Version: 6, Modules: []*ModuleState{ - &ModuleState{ + { Path: rootModulePath, Resources: map[string]*ResourceState{ - "test_instance.foo": &ResourceState{ + "test_instance.foo": { Primary: &InstanceState{ Meta: map[string]interface{}{}, }, @@ -219,7 +219,7 @@ func TestStateEqual(t *testing.T) { false, &State{ Modules: []*ModuleState{ - &ModuleState{ + { Path: []string{"root"}, }, }, @@ -232,14 +232,14 @@ func TestStateEqual(t *testing.T) { true, &State{ Modules: []*ModuleState{ - &ModuleState{ + { Path: []string{"root"}, }, }, }, &State{ Modules: []*ModuleState{ - &ModuleState{ + { Path: []string{"root"}, }, }, @@ -252,10 +252,10 @@ func TestStateEqual(t *testing.T) { false, &State{ Modules: []*ModuleState{ - &ModuleState{ + { Path: rootModulePath, Resources: map[string]*ResourceState{ - "test_instance.foo": &ResourceState{ + "test_instance.foo": { Primary: &InstanceState{ Meta: map[string]interface{}{ "schema_version": "1", @@ -268,10 +268,10 @@ func TestStateEqual(t *testing.T) { }, &State{ Modules: []*ModuleState{ - &ModuleState{ + { Path: rootModulePath, Resources: map[string]*ResourceState{ - "test_instance.foo": &ResourceState{ + "test_instance.foo": { Primary: &InstanceState{ Meta: map[string]interface{}{ "schema_version": "2", @@ -290,10 +290,10 @@ func TestStateEqual(t *testing.T) { true, &State{ Modules: []*ModuleState{ - &ModuleState{ + { Path: rootModulePath, Resources: map[string]*ResourceState{ - "test_instance.foo": &ResourceState{ + "test_instance.foo": { Primary: &InstanceState{ Meta: map[string]interface{}{ "timeouts": map[string]interface{}{ @@ -309,10 +309,10 @@ func TestStateEqual(t *testing.T) { }, &State{ Modules: []*ModuleState{ - &ModuleState{ + { Path: rootModulePath, Resources: map[string]*ResourceState{ - "test_instance.foo": &ResourceState{ + "test_instance.foo": { Primary: &InstanceState{ Meta: map[string]interface{}{ "timeouts": map[string]interface{}{ @@ -334,10 +334,10 @@ func TestStateEqual(t *testing.T) { true, &State{ Modules: []*ModuleState{ - &ModuleState{ + { Path: rootModulePath, Resources: map[string]*ResourceState{ - "test_instance.foo": &ResourceState{ + "test_instance.foo": { Primary: &InstanceState{ Meta: map[string]interface{}{ "timeouts": map[string]interface{}{ @@ -353,10 +353,10 @@ func TestStateEqual(t *testing.T) { }, &State{ Modules: []*ModuleState{ - &ModuleState{ + { Path: rootModulePath, Resources: map[string]*ResourceState{ - "test_instance.foo": &ResourceState{ + "test_instance.foo": { Primary: &InstanceState{ Meta: map[string]interface{}{ "timeouts": map[string]interface{}{ @@ -544,17 +544,17 @@ func TestStateRemove(t *testing.T) { "test_instance.foo", &State{ Modules: []*ModuleState{ - &ModuleState{ + { Path: rootModulePath, Resources: map[string]*ResourceState{ - "test_instance.foo": &ResourceState{ + "test_instance.foo": { Type: "test_instance", Primary: &InstanceState{ ID: "foo", }, }, - "test_instance.bar": &ResourceState{ + "test_instance.bar": { Type: "test_instance", Primary: &InstanceState{ ID: "foo", @@ -566,10 +566,10 @@ func TestStateRemove(t *testing.T) { }, &State{ Modules: []*ModuleState{ - &ModuleState{ + { Path: rootModulePath, Resources: map[string]*ResourceState{ - "test_instance.bar": &ResourceState{ + "test_instance.bar": { Type: "test_instance", Primary: &InstanceState{ ID: "foo", @@ -585,10 +585,10 @@ func TestStateRemove(t *testing.T) { "test_instance.foo.primary", &State{ Modules: []*ModuleState{ - &ModuleState{ + { Path: rootModulePath, Resources: map[string]*ResourceState{ - "test_instance.foo": &ResourceState{ + "test_instance.foo": { Type: "test_instance", Primary: &InstanceState{ ID: "foo", @@ -600,7 +600,7 @@ func TestStateRemove(t *testing.T) { }, &State{ Modules: []*ModuleState{ - &ModuleState{ + { Path: rootModulePath, Resources: map[string]*ResourceState{}, }, @@ -612,17 +612,17 @@ func TestStateRemove(t *testing.T) { "test_instance.foo[0]", &State{ Modules: []*ModuleState{ - &ModuleState{ + { Path: rootModulePath, Resources: map[string]*ResourceState{ - "test_instance.foo.0": &ResourceState{ + "test_instance.foo.0": { Type: "test_instance", Primary: &InstanceState{ ID: "foo", }, }, - "test_instance.foo.1": &ResourceState{ + "test_instance.foo.1": { Type: "test_instance", Primary: &InstanceState{ ID: "foo", @@ -634,10 +634,10 @@ func TestStateRemove(t *testing.T) { }, &State{ Modules: []*ModuleState{ - &ModuleState{ + { Path: rootModulePath, Resources: map[string]*ResourceState{ - "test_instance.foo.1": &ResourceState{ + "test_instance.foo.1": { Type: "test_instance", Primary: &InstanceState{ ID: "foo", @@ -653,17 +653,17 @@ func TestStateRemove(t *testing.T) { "test_instance.foo", &State{ Modules: []*ModuleState{ - &ModuleState{ + { Path: rootModulePath, Resources: map[string]*ResourceState{ - "test_instance.foo.0": &ResourceState{ + "test_instance.foo.0": { Type: "test_instance", Primary: &InstanceState{ ID: "foo", }, }, - "test_instance.foo.1": &ResourceState{ + "test_instance.foo.1": { Type: "test_instance", Primary: &InstanceState{ ID: "foo", @@ -675,7 +675,7 @@ func TestStateRemove(t *testing.T) { }, &State{ Modules: []*ModuleState{ - &ModuleState{ + { Path: rootModulePath, Resources: map[string]*ResourceState{}, }, @@ -687,10 +687,10 @@ func TestStateRemove(t *testing.T) { "module.foo", &State{ Modules: []*ModuleState{ - &ModuleState{ + { Path: rootModulePath, Resources: map[string]*ResourceState{ - "test_instance.foo": &ResourceState{ + "test_instance.foo": { Type: "test_instance", Primary: &InstanceState{ ID: "foo", @@ -699,17 +699,17 @@ func TestStateRemove(t *testing.T) { }, }, - &ModuleState{ + { Path: []string{"root", "foo"}, Resources: map[string]*ResourceState{ - "test_instance.foo": &ResourceState{ + "test_instance.foo": { Type: "test_instance", Primary: &InstanceState{ ID: "foo", }, }, - "test_instance.bar": &ResourceState{ + "test_instance.bar": { Type: "test_instance", Primary: &InstanceState{ ID: "foo", @@ -721,10 +721,10 @@ func TestStateRemove(t *testing.T) { }, &State{ Modules: []*ModuleState{ - &ModuleState{ + { Path: rootModulePath, Resources: map[string]*ResourceState{ - "test_instance.foo": &ResourceState{ + "test_instance.foo": { Type: "test_instance", Primary: &InstanceState{ ID: "foo", @@ -740,10 +740,10 @@ func TestStateRemove(t *testing.T) { "module.foo", &State{ Modules: []*ModuleState{ - &ModuleState{ + { Path: rootModulePath, Resources: map[string]*ResourceState{ - "test_instance.foo": &ResourceState{ + "test_instance.foo": { Type: "test_instance", Primary: &InstanceState{ ID: "foo", @@ -752,17 +752,17 @@ func TestStateRemove(t *testing.T) { }, }, - &ModuleState{ + { Path: []string{"root", "foo"}, Resources: map[string]*ResourceState{ - "test_instance.foo": &ResourceState{ + "test_instance.foo": { Type: "test_instance", Primary: &InstanceState{ ID: "foo", }, }, - "test_instance.bar": &ResourceState{ + "test_instance.bar": { Type: "test_instance", Primary: &InstanceState{ ID: "foo", @@ -771,17 +771,17 @@ func TestStateRemove(t *testing.T) { }, }, - &ModuleState{ + { Path: []string{"root", "foo", "bar"}, Resources: map[string]*ResourceState{ - "test_instance.foo": &ResourceState{ + "test_instance.foo": { Type: "test_instance", Primary: &InstanceState{ ID: "foo", }, }, - "test_instance.bar": &ResourceState{ + "test_instance.bar": { Type: "test_instance", Primary: &InstanceState{ ID: "foo", @@ -793,10 +793,10 @@ func TestStateRemove(t *testing.T) { }, &State{ Modules: []*ModuleState{ - &ModuleState{ + { Path: rootModulePath, Resources: map[string]*ResourceState{ - "test_instance.foo": &ResourceState{ + "test_instance.foo": { Type: "test_instance", Primary: &InstanceState{ ID: "foo", @@ -1099,7 +1099,7 @@ func TestStateEmpty(t *testing.T) { { &State{ Modules: []*ModuleState{ - &ModuleState{}, + {}, }, }, false, @@ -1135,7 +1135,7 @@ func TestStateHasResources(t *testing.T) { { &State{ Modules: []*ModuleState{ - &ModuleState{}, + {}, }, }, false, @@ -1143,8 +1143,8 @@ func TestStateHasResources(t *testing.T) { { &State{ Modules: []*ModuleState{ - &ModuleState{}, - &ModuleState{}, + {}, + {}, }, }, false, @@ -1152,10 +1152,10 @@ func TestStateHasResources(t *testing.T) { { &State{ Modules: []*ModuleState{ - &ModuleState{}, - &ModuleState{ + {}, + { Resources: map[string]*ResourceState{ - "foo.foo": &ResourceState{}, + "foo.foo": {}, }, }, }, @@ -1210,20 +1210,20 @@ func TestInstanceState_MergeDiff(t *testing.T) { diff := &InstanceDiff{ Attributes: map[string]*ResourceAttrDiff{ - "foo": &ResourceAttrDiff{ + "foo": { Old: "bar", New: "baz", }, - "bar": &ResourceAttrDiff{ + "bar": { Old: "", New: "foo", }, - "baz": &ResourceAttrDiff{ + "baz": { Old: "", New: "foo", NewComputed: true, }, - "port": &ResourceAttrDiff{ + "port": { NewRemoved: true, }, }, @@ -1250,18 +1250,18 @@ func TestInstanceState_MergeDiff_computedSet(t *testing.T) { diff := &InstanceDiff{ Attributes: map[string]*ResourceAttrDiff{ - "config.#": &ResourceAttrDiff{ + "config.#": { Old: "0", New: "1", RequiresNew: true, }, - "config.0.name": &ResourceAttrDiff{ + "config.0.name": { Old: "", New: "hello", }, - "config.0.rules.#": &ResourceAttrDiff{ + "config.0.rules.#": { Old: "", NewComputed: true, }, @@ -1286,7 +1286,7 @@ func TestInstanceState_MergeDiff_nil(t *testing.T) { diff := &InstanceDiff{ Attributes: map[string]*ResourceAttrDiff{ - "foo": &ResourceAttrDiff{ + "foo": { Old: "", New: "baz", },