diff --git a/staging/terraform/backend/remote-state/azure/backend_test.go b/staging/terraform/backend/remote-state/azure/backend_test.go index 9c6c7f2..ceacbe5 100644 --- a/staging/terraform/backend/remote-state/azure/backend_test.go +++ b/staging/terraform/backend/remote-state/azure/backend_test.go @@ -20,7 +20,7 @@ func TestBackendConfig(t *testing.T) { // This test just instantiates the client. Shouldn't make any actual // requests nor incur any costs. - config := map[string]interface{}{ + config := map[string]any{ "storage_account_name": "tfaccount", "container_name": "tfcontainer", "key": "state", @@ -56,7 +56,7 @@ func TestAccBackendAccessKeyBasic(t *testing.T) { t.Fatalf("Error creating Test Resources: %q", err) } - b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "storage_account_name": res.storageAccountName, "container_name": res.storageContainerName, "key": res.storageKeyName, @@ -86,7 +86,7 @@ func TestAccBackendSASTokenBasic(t *testing.T) { t.Fatalf("Error building SAS Token: %+v", err) } - b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "storage_account_name": res.storageAccountName, "container_name": res.storageContainerName, "key": res.storageKeyName, @@ -111,7 +111,7 @@ func TestAccBackendOIDCBasic(t *testing.T) { t.Fatalf("Error creating Test Resources: %q", err) } - b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "storage_account_name": res.storageAccountName, "container_name": res.storageContainerName, "key": res.storageKeyName, @@ -141,7 +141,7 @@ func TestAccBackendAzureADAuthBasic(t *testing.T) { t.Fatalf("Error creating Test Resources: %q", err) } - b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "storage_account_name": res.storageAccountName, "container_name": res.storageContainerName, "key": res.storageKeyName, @@ -167,7 +167,7 @@ func TestAccBackendManagedServiceIdentityBasic(t *testing.T) { t.Fatalf("Error creating Test Resources: %q", err) } - b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "storage_account_name": res.storageAccountName, "container_name": res.storageContainerName, "key": res.storageKeyName, @@ -202,7 +202,7 @@ func TestAccBackendServicePrincipalClientCertificateBasic(t *testing.T) { t.Fatalf("Error creating Test Resources: %q", err) } - b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "storage_account_name": res.storageAccountName, "container_name": res.storageContainerName, "key": res.storageKeyName, @@ -232,7 +232,7 @@ func TestAccBackendServicePrincipalClientSecretBasic(t *testing.T) { t.Fatalf("Error creating Test Resources: %q", err) } - b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "storage_account_name": res.storageAccountName, "container_name": res.storageContainerName, "key": res.storageKeyName, @@ -268,7 +268,7 @@ func TestAccBackendServicePrincipalClientSecretCustomEndpoint(t *testing.T) { t.Fatalf("Error creating Test Resources: %q", err) } - b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "storage_account_name": res.storageAccountName, "container_name": res.storageContainerName, "key": res.storageKeyName, @@ -297,7 +297,7 @@ func TestAccBackendAccessKeyLocked(t *testing.T) { t.Fatalf("Error creating Test Resources: %q", err) } - b1 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b1 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "storage_account_name": res.storageAccountName, "container_name": res.storageContainerName, "key": res.storageKeyName, @@ -306,7 +306,7 @@ func TestAccBackendAccessKeyLocked(t *testing.T) { "endpoint": os.Getenv("ARM_ENDPOINT"), })).(*Backend) - b2 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b2 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "storage_account_name": res.storageAccountName, "container_name": res.storageContainerName, "key": res.storageKeyName, @@ -335,7 +335,7 @@ func TestAccBackendServicePrincipalLocked(t *testing.T) { t.Fatalf("Error creating Test Resources: %q", err) } - b1 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b1 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "storage_account_name": res.storageAccountName, "container_name": res.storageContainerName, "key": res.storageKeyName, @@ -348,7 +348,7 @@ func TestAccBackendServicePrincipalLocked(t *testing.T) { "endpoint": os.Getenv("ARM_ENDPOINT"), })).(*Backend) - b2 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b2 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "storage_account_name": res.storageAccountName, "container_name": res.storageContainerName, "key": res.storageKeyName, diff --git a/staging/terraform/backend/remote-state/azure/client_test.go b/staging/terraform/backend/remote-state/azure/client_test.go index fb69a04..4c82966 100644 --- a/staging/terraform/backend/remote-state/azure/client_test.go +++ b/staging/terraform/backend/remote-state/azure/client_test.go @@ -32,7 +32,7 @@ func TestRemoteClientAccessKeyBasic(t *testing.T) { t.Fatalf("Error creating Test Resources: %q", err) } - b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "storage_account_name": res.storageAccountName, "container_name": res.storageContainerName, "key": res.storageKeyName, @@ -62,7 +62,7 @@ func TestRemoteClientManagedServiceIdentityBasic(t *testing.T) { t.Fatalf("Error creating Test Resources: %q", err) } - b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "storage_account_name": res.storageAccountName, "container_name": res.storageContainerName, "key": res.storageKeyName, @@ -100,7 +100,7 @@ func TestRemoteClientSasTokenBasic(t *testing.T) { t.Fatalf("Error building SAS Token: %+v", err) } - b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "storage_account_name": res.storageAccountName, "container_name": res.storageContainerName, "key": res.storageKeyName, @@ -130,7 +130,7 @@ func TestRemoteClientServicePrincipalBasic(t *testing.T) { t.Fatalf("Error creating Test Resources: %q", err) } - b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "storage_account_name": res.storageAccountName, "container_name": res.storageContainerName, "key": res.storageKeyName, @@ -164,7 +164,7 @@ func TestRemoteClientAccessKeyLocks(t *testing.T) { t.Fatalf("Error creating Test Resources: %q", err) } - b1 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b1 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "storage_account_name": res.storageAccountName, "container_name": res.storageContainerName, "key": res.storageKeyName, @@ -173,7 +173,7 @@ func TestRemoteClientAccessKeyLocks(t *testing.T) { "endpoint": os.Getenv("ARM_ENDPOINT"), })).(*Backend) - b2 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b2 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "storage_account_name": res.storageAccountName, "container_name": res.storageContainerName, "key": res.storageKeyName, @@ -208,7 +208,7 @@ func TestRemoteClientServicePrincipalLocks(t *testing.T) { t.Fatalf("Error creating Test Resources: %q", err) } - b1 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b1 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "storage_account_name": res.storageAccountName, "container_name": res.storageContainerName, "key": res.storageKeyName, @@ -221,7 +221,7 @@ func TestRemoteClientServicePrincipalLocks(t *testing.T) { "endpoint": os.Getenv("ARM_ENDPOINT"), })).(*Backend) - b2 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b2 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "storage_account_name": res.storageAccountName, "container_name": res.storageContainerName, "key": res.storageKeyName, diff --git a/staging/terraform/backend/remote-state/consul/backend_test.go b/staging/terraform/backend/remote-state/consul/backend_test.go index 97c661b..7c3490c 100644 --- a/staging/terraform/backend/remote-state/consul/backend_test.go +++ b/staging/terraform/backend/remote-state/consul/backend_test.go @@ -53,12 +53,12 @@ func TestBackend(t *testing.T) { path := fmt.Sprintf("tf-unit/%s", time.Now().String()) // Get the backend. We need two to test locking. - b1 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b1 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "address": srv.HTTPAddr, "path": path, })) - b2 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b2 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "address": srv.HTTPAddr, "path": path, })) @@ -74,13 +74,13 @@ func TestBackend_lockDisabled(t *testing.T) { path := fmt.Sprintf("tf-unit/%s", time.Now().String()) // Get the backend. We need two to test locking. - b1 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b1 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "address": srv.HTTPAddr, "path": path, "lock": false, })) - b2 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b2 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "address": srv.HTTPAddr, "path": path + "different", // Diff so locking test would fail if it was locking "lock": false, @@ -95,7 +95,7 @@ func TestBackend_gzip(t *testing.T) { srv := newConsulTestServer(t) // Get the backend - b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "address": srv.HTTPAddr, "path": fmt.Sprintf("tf-unit/%s", time.Now().String()), "gzip": true, diff --git a/staging/terraform/backend/remote-state/consul/client.go b/staging/terraform/backend/remote-state/consul/client.go index 8385b3a..1b8c62a 100644 --- a/staging/terraform/backend/remote-state/consul/client.go +++ b/staging/terraform/backend/remote-state/consul/client.go @@ -283,7 +283,7 @@ func (c *RemoteClient) Put(data []byte) error { } // Then we update the link to point to the new chunks - payload, err = json.Marshal(map[string]interface{}{ + payload, err = json.Marshal(map[string]any{ "current-hash": fmt.Sprintf("%x", md5), "chunks": chunkPaths, }) @@ -669,7 +669,7 @@ func (c *RemoteClient) chunkedMode() (bool, string, []string, *consulapi.KVPair, return false, "", nil, pair, err } if pair != nil { - var d map[string]interface{} + var d map[string]any err = json.Unmarshal(pair.Value, &d) // If there is an error when unmarshaling the payload, the state has // probably been gziped in single entry mode. @@ -678,7 +678,7 @@ func (c *RemoteClient) chunkedMode() (bool, string, []string, *consulapi.KVPair, hash, ok := d["current-hash"] if ok { chunks := make([]string, 0) - for _, c := range d["chunks"].([]interface{}) { + for _, c := range d["chunks"].([]any) { chunks = append(chunks, c.(string)) } return true, hash.(string), chunks, pair, nil diff --git a/staging/terraform/backend/remote-state/consul/client_test.go b/staging/terraform/backend/remote-state/consul/client_test.go index b5a3744..6f26d66 100644 --- a/staging/terraform/backend/remote-state/consul/client_test.go +++ b/staging/terraform/backend/remote-state/consul/client_test.go @@ -37,7 +37,7 @@ func TestRemoteClient(t *testing.T) { for _, path := range testCases { t.Run(path, func(*testing.T) { // Get the backend - b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "address": srv.HTTPAddr, "path": path, })) @@ -61,7 +61,7 @@ func TestRemoteClient_gzipUpgrade(t *testing.T) { statePath := fmt.Sprintf("tf-unit/%s", time.Now().String()) // Get the backend - b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "address": srv.HTTPAddr, "path": statePath, })) @@ -76,7 +76,7 @@ func TestRemoteClient_gzipUpgrade(t *testing.T) { remote.TestClient(t, state.(*remote.State).Client) // create a new backend with gzip - b = backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b = backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "address": srv.HTTPAddr, "path": statePath, "gzip": true, @@ -100,7 +100,7 @@ func TestConsul_largeState(t *testing.T) { path := "tf-unit/test-large-state" - b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "address": srv.HTTPAddr, "path": path, })) @@ -186,7 +186,7 @@ func TestConsul_largeState(t *testing.T) { ) // Test with gzip and chunks - b = backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b = backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "address": srv.HTTPAddr, "path": path, "gzip": true, @@ -247,7 +247,7 @@ func TestConsul_stateLock(t *testing.T) { for _, path := range testCases { t.Run(path, func(*testing.T) { // create 2 instances to get 2 remote.Clients - sA, err := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + sA, err := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "address": srv.HTTPAddr, "path": path, })).StateMgr(backend.DefaultStateName) @@ -255,7 +255,7 @@ func TestConsul_stateLock(t *testing.T) { t.Fatal(err) } - sB, err := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + sB, err := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "address": srv.HTTPAddr, "path": path, })).StateMgr(backend.DefaultStateName) @@ -290,7 +290,7 @@ func TestConsul_destroyLock(t *testing.T) { for _, path := range testCases { t.Run(path, func(*testing.T) { // Get the backend - b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "address": srv.HTTPAddr, "path": path, })) @@ -356,7 +356,7 @@ func TestConsul_lostLock(t *testing.T) { path := fmt.Sprintf("tf-unit/%s", time.Now().String()) // create 2 instances to get 2 remote.Clients - sA, err := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + sA, err := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "address": srv.HTTPAddr, "path": path, })).StateMgr(backend.DefaultStateName) @@ -364,7 +364,7 @@ func TestConsul_lostLock(t *testing.T) { t.Fatal(err) } - sB, err := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + sB, err := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "address": srv.HTTPAddr, "path": path + "-not-used", })).StateMgr(backend.DefaultStateName) @@ -413,7 +413,7 @@ func TestConsul_lostLockConnection(t *testing.T) { path := fmt.Sprintf("tf-unit/%s", time.Now().String()) - b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "address": srv.HTTPAddr, "path": path, })) diff --git a/staging/terraform/backend/remote-state/cos/backend.go b/staging/terraform/backend/remote-state/cos/backend.go index 7688e9e..d0ff6af 100644 --- a/staging/terraform/backend/remote-state/cos/backend.go +++ b/staging/terraform/backend/remote-state/cos/backend.go @@ -91,7 +91,7 @@ func New() backend.Backend { Type: schema.TypeString, Optional: true, Description: "The directory for saving the state file in bucket", - ValidateFunc: func(v interface{}, s string) ([]string, []error) { + ValidateFunc: func(v any, s string) ([]string, []error) { prefix := v.(string) if strings.HasPrefix(prefix, "/") || strings.HasPrefix(prefix, "./") { return nil, []error{fmt.Errorf("prefix must not start with '/' or './'")} @@ -104,7 +104,7 @@ func New() backend.Backend { Optional: true, Description: "The path for saving the state file in bucket", Default: "terraform.tfstate", - ValidateFunc: func(v interface{}, s string) ([]string, []error) { + ValidateFunc: func(v any, s string) ([]string, []error) { if strings.HasPrefix(v.(string), "/") || strings.HasSuffix(v.(string), "/") { return nil, []error{fmt.Errorf("key can not start and end with '/'")} } @@ -122,7 +122,7 @@ func New() backend.Backend { Optional: true, Description: "Object ACL to be applied to the state file", Default: "private", - ValidateFunc: func(v interface{}, s string) ([]string, []error) { + ValidateFunc: func(v any, s string) ([]string, []error) { value := v.(string) if value != "private" && value != "public-read" { return nil, []error{fmt.Errorf( @@ -160,7 +160,7 @@ func New() backend.Backend { "session_duration": { Type: schema.TypeInt, Required: true, - DefaultFunc: func() (interface{}, error) { + DefaultFunc: func() (any, error) { if v := os.Getenv(PROVIDER_ASSUME_ROLE_SESSION_DURATION); v != "" { return strconv.Atoi(v) } @@ -187,7 +187,7 @@ func New() backend.Backend { } func validateIntegerInRange(min, max int64) schema.SchemaValidateFunc { - return func(v interface{}, k string) (ws []string, errors []error) { + return func(v any, k string) (ws []string, errors []error) { value := int64(v.(int)) if value < min { errors = append(errors, fmt.Errorf( @@ -262,7 +262,7 @@ func (b *Backend) configure(ctx context.Context) error { func handleAssumeRole(data *schema.ResourceData, b *Backend) error { assumeRoleList := data.Get("assume_role").(*schema.Set).List() if len(assumeRoleList) == 1 { - assumeRole := assumeRoleList[0].(map[string]interface{}) + assumeRole := assumeRoleList[0].(map[string]any) assumeRoleArn := assumeRole["role_arn"].(string) assumeRoleSessionName := assumeRole["session_name"].(string) assumeRoleSessionDuration := assumeRole["session_duration"].(int) diff --git a/staging/terraform/backend/remote-state/cos/backend_test.go b/staging/terraform/backend/remote-state/cos/backend_test.go index 5975f6c..bf76796 100644 --- a/staging/terraform/backend/remote-state/cos/backend_test.go +++ b/staging/terraform/backend/remote-state/cos/backend_test.go @@ -216,7 +216,7 @@ func setupBackend(t *testing.T, bucket, prefix, key string, encrypt bool) backen appId := os.Getenv("TF_COS_APPID") region := os.Getenv(PROVIDER_REGION) - config := map[string]interface{}{ + config := map[string]any{ "region": region, "bucket": bucket + appId, "prefix": prefix, diff --git a/staging/terraform/backend/remote-state/gcs/backend.go b/staging/terraform/backend/remote-state/gcs/backend.go index f6dba07..b8baf6c 100644 --- a/staging/terraform/backend/remote-state/gcs/backend.go +++ b/staging/terraform/backend/remote-state/gcs/backend.go @@ -182,7 +182,7 @@ func (b *Backend) configure(ctx context.Context) error { var delegates []string if v, ok := data.GetOk("impersonate_service_account_delegates"); ok { - d := v.([]interface{}) + d := v.([]any) if len(delegates) > 0 { delegates = make([]string, 0, len(d)) } diff --git a/staging/terraform/backend/remote-state/gcs/backend_test.go b/staging/terraform/backend/remote-state/gcs/backend_test.go index 9601166..53ae07d 100644 --- a/staging/terraform/backend/remote-state/gcs/backend_test.go +++ b/staging/terraform/backend/remote-state/gcs/backend_test.go @@ -222,7 +222,7 @@ func setupBackend(t *testing.T, bucket, prefix, key, kmsName string) backend.Bac "the TF_ACC and GOOGLE_PROJECT environment variables are set.") } - config := map[string]interface{}{ + config := map[string]any{ "bucket": bucket, "prefix": prefix, } diff --git a/staging/terraform/backend/remote-state/http/mock_server_test.go b/staging/terraform/backend/remote-state/http/mock_server_test.go index ac6a3e3..0c93c9c 100644 --- a/staging/terraform/backend/remote-state/http/mock_server_test.go +++ b/staging/terraform/backend/remote-state/http/mock_server_test.go @@ -41,7 +41,7 @@ func (m *MockHttpServerCallback) StateDELETE(req *http.Request) { } // StateDELETE indicates an expected call of StateDELETE. -func (mr *MockHttpServerCallbackMockRecorder) StateDELETE(req interface{}) *gomock.Call { +func (mr *MockHttpServerCallbackMockRecorder) StateDELETE(req any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateDELETE", reflect.TypeOf((*MockHttpServerCallback)(nil).StateDELETE), req) } @@ -53,7 +53,7 @@ func (m *MockHttpServerCallback) StateGET(req *http.Request) { } // StateGET indicates an expected call of StateGET. -func (mr *MockHttpServerCallbackMockRecorder) StateGET(req interface{}) *gomock.Call { +func (mr *MockHttpServerCallbackMockRecorder) StateGET(req any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateGET", reflect.TypeOf((*MockHttpServerCallback)(nil).StateGET), req) } @@ -65,7 +65,7 @@ func (m *MockHttpServerCallback) StateLOCK(req *http.Request) { } // StateLOCK indicates an expected call of StateLOCK. -func (mr *MockHttpServerCallbackMockRecorder) StateLOCK(req interface{}) *gomock.Call { +func (mr *MockHttpServerCallbackMockRecorder) StateLOCK(req any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateLOCK", reflect.TypeOf((*MockHttpServerCallback)(nil).StateLOCK), req) } @@ -77,7 +77,7 @@ func (m *MockHttpServerCallback) StatePOST(req *http.Request) { } // StatePOST indicates an expected call of StatePOST. -func (mr *MockHttpServerCallbackMockRecorder) StatePOST(req interface{}) *gomock.Call { +func (mr *MockHttpServerCallbackMockRecorder) StatePOST(req any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StatePOST", reflect.TypeOf((*MockHttpServerCallback)(nil).StatePOST), req) } @@ -89,7 +89,7 @@ func (m *MockHttpServerCallback) StateUNLOCK(req *http.Request) { } // StateUNLOCK indicates an expected call of StateUNLOCK. -func (mr *MockHttpServerCallbackMockRecorder) StateUNLOCK(req interface{}) *gomock.Call { +func (mr *MockHttpServerCallbackMockRecorder) StateUNLOCK(req any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateUNLOCK", reflect.TypeOf((*MockHttpServerCallback)(nil).StateUNLOCK), req) } diff --git a/staging/terraform/backend/remote-state/http/server_test.go b/staging/terraform/backend/remote-state/http/server_test.go index bcbfd1a..062b9f5 100644 --- a/staging/terraform/backend/remote-state/http/server_test.go +++ b/staging/terraform/backend/remote-state/http/server_test.go @@ -194,7 +194,7 @@ func (h *httpServer) handleStateUNLOCK(writer http.ResponseWriter, req *http.Req writer.WriteHeader(http.StatusBadRequest) return } - var lockInfo map[string]interface{} + var lockInfo map[string]any if err = json.Unmarshal(data, &lockInfo); err != nil { writer.WriteHeader(http.StatusInternalServerError) return @@ -204,7 +204,7 @@ func (h *httpServer) handleStateUNLOCK(writer http.ResponseWriter, req *http.Req defer h.lock.Unlock() if existingLock, ok := h.locks[resource]; ok { - var existingLockInfo map[string]interface{} + var existingLockInfo map[string]any if err = json.Unmarshal([]byte(existingLock), &existingLockInfo); err != nil { writer.WriteHeader(http.StatusInternalServerError) return diff --git a/staging/terraform/backend/remote-state/inmem/backend_test.go b/staging/terraform/backend/remote-state/inmem/backend_test.go index d23034d..4139a6d 100644 --- a/staging/terraform/backend/remote-state/inmem/backend_test.go +++ b/staging/terraform/backend/remote-state/inmem/backend_test.go @@ -30,7 +30,7 @@ func TestBackendConfig(t *testing.T) { defer Reset() testID := "test_lock_id" - config := map[string]interface{}{ + config := map[string]any{ "lock_id": testID, } diff --git a/staging/terraform/backend/remote-state/kubernetes/backend.go b/staging/terraform/backend/remote-state/kubernetes/backend.go index 0d2d7f6..6cbf2ad 100644 --- a/staging/terraform/backend/remote-state/kubernetes/backend.go +++ b/staging/terraform/backend/remote-state/kubernetes/backend.go @@ -271,7 +271,7 @@ func (b *Backend) configure(ctx context.Context) error { if v, ok := data.GetOk("labels"); ok { labels := map[string]string{} - for k, vv := range v.(map[string]interface{}) { + for k, vv := range v.(map[string]any) { labels[k] = vv.(string) } b.labels = labels @@ -314,7 +314,7 @@ func tryLoadingConfigFile(d *schema.ResourceData) (*restclient.Config, error) { configPaths := []string{} if v, ok := d.Get("config_path").(string); ok && v != "" { configPaths = []string{v} - } else if v, ok := d.Get("config_paths").([]interface{}); ok && len(v) > 0 { + } else if v, ok := d.Get("config_paths").([]any); ok && len(v) > 0 { for _, p := range v { configPaths = append(configPaths, p.(string)) } @@ -367,11 +367,11 @@ func tryLoadingConfigFile(d *schema.ResourceData) (*restclient.Config, error) { if v, ok := d.GetOk("exec"); ok { exec := &clientcmdapi.ExecConfig{} - if spec, ok := v.([]interface{})[0].(map[string]interface{}); ok { + if spec, ok := v.([]any)[0].(map[string]any); ok { exec.APIVersion = spec["api_version"].(string) exec.Command = spec["command"].(string) - exec.Args = expandStringSlice(spec["args"].([]interface{})) - for kk, vv := range spec["env"].(map[string]interface{}) { + exec.Args = expandStringSlice(spec["args"].([]any)) + for kk, vv := range spec["env"].(map[string]any) { exec.Env = append(exec.Env, clientcmdapi.ExecEnvVar{Name: kk, Value: vv.(string)}) } } else { @@ -394,7 +394,7 @@ func tryLoadingConfigFile(d *schema.ResourceData) (*restclient.Config, error) { return cfg, nil } -func expandStringSlice(s []interface{}) []string { +func expandStringSlice(s []any) []string { result := make([]string, len(s), len(s)) for k, v := range s { // Handle the Terraform parser bug which turns empty strings in lists to nil. diff --git a/staging/terraform/backend/remote-state/kubernetes/backend_test.go b/staging/terraform/backend/remote-state/kubernetes/backend_test.go index 1de79b8..7c7d8ea 100644 --- a/staging/terraform/backend/remote-state/kubernetes/backend_test.go +++ b/staging/terraform/backend/remote-state/kubernetes/backend_test.go @@ -50,7 +50,7 @@ func TestBackend(t *testing.T) { testACC(t) defer cleanupK8sResources(t) - b1 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b1 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "secret_suffix": secretSuffix, })) @@ -63,11 +63,11 @@ func TestBackendLocks(t *testing.T) { defer cleanupK8sResources(t) // Get the backend. We need two to test locking. - b1 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b1 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "secret_suffix": secretSuffix, })) - b2 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b2 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "secret_suffix": secretSuffix, })) @@ -85,7 +85,7 @@ func TestBackendLocksSoak(t *testing.T) { lockers := []statemgr.Locker{} for i := 0; i < clientCount; i++ { - b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "secret_suffix": secretSuffix, })) @@ -130,7 +130,7 @@ func TestBackendLocksSoak(t *testing.T) { func cleanupK8sResources(t *testing.T) { ctx := context.Background() // Get a backend to use the k8s client - b1 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b1 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "secret_suffix": secretSuffix, })) diff --git a/staging/terraform/backend/remote-state/kubernetes/client.go b/staging/terraform/backend/remote-state/kubernetes/client.go index 8dbafa0..38627de 100644 --- a/staging/terraform/backend/remote-state/kubernetes/client.go +++ b/staging/terraform/backend/remote-state/kubernetes/client.go @@ -100,7 +100,7 @@ func (c *RemoteClient) Put(data []byte) error { } secret = &unstructured.Unstructured{ - Object: map[string]interface{}{ + Object: map[string]any{ "metadata": metav1.ObjectMeta{ Name: secretName, Namespace: c.namespace, @@ -376,11 +376,11 @@ func uncompressState(data string) ([]byte, error) { return b.Bytes(), nil } -func getSecretData(secret *unstructured.Unstructured) map[string]interface{} { - if m, ok := secret.Object["data"].(map[string]interface{}); ok { +func getSecretData(secret *unstructured.Unstructured) map[string]any { + if m, ok := secret.Object["data"].(map[string]any); ok { return m } - return map[string]interface{}{} + return map[string]any{} } func getLockInfo(lease *coordinationv1.Lease) ([]byte, bool) { diff --git a/staging/terraform/backend/remote-state/kubernetes/client_test.go b/staging/terraform/backend/remote-state/kubernetes/client_test.go index d87ba2b..abc43b0 100644 --- a/staging/terraform/backend/remote-state/kubernetes/client_test.go +++ b/staging/terraform/backend/remote-state/kubernetes/client_test.go @@ -20,7 +20,7 @@ func TestRemoteClient(t *testing.T) { testACC(t) defer cleanupK8sResources(t) - b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "secret_suffix": secretSuffix, })) @@ -36,11 +36,11 @@ func TestRemoteClientLocks(t *testing.T) { testACC(t) defer cleanupK8sResources(t) - b1 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b1 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "secret_suffix": secretSuffix, })) - b2 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b2 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "secret_suffix": secretSuffix, })) @@ -61,11 +61,11 @@ func TestForceUnlock(t *testing.T) { testACC(t) defer cleanupK8sResources(t) - b1 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b1 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "secret_suffix": secretSuffix, })) - b2 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b2 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "secret_suffix": secretSuffix, })) diff --git a/staging/terraform/backend/remote-state/oss/backend.go b/staging/terraform/backend/remote-state/oss/backend.go index 3520c2a..1eb3715 100644 --- a/staging/terraform/backend/remote-state/oss/backend.go +++ b/staging/terraform/backend/remote-state/oss/backend.go @@ -67,7 +67,7 @@ func deprecatedAssumeRoleSchema() *schema.Schema { Type: schema.TypeInt, Optional: true, Description: "The time after which the established session for assuming role expires.", - ValidateFunc: func(v interface{}, k string) ([]string, []error) { + ValidateFunc: func(v any, k string) ([]string, []error) { min := 900 max := 3600 value, ok := v.(int) @@ -155,7 +155,7 @@ func New() backend.Backend { Optional: true, Description: "The directory where state files will be saved inside the bucket", Default: "env:", - ValidateFunc: func(v interface{}, s string) ([]string, []error) { + ValidateFunc: func(v any, s string) ([]string, []error) { prefix := v.(string) if strings.HasPrefix(prefix, "/") || strings.HasPrefix(prefix, "./") { return nil, []error{fmt.Errorf("workspace_key_prefix must not start with '/' or './'")} @@ -168,7 +168,7 @@ func New() backend.Backend { Type: schema.TypeString, Optional: true, Description: "The path of the state file inside the bucket", - ValidateFunc: func(v interface{}, s string) ([]string, []error) { + ValidateFunc: func(v any, s string) ([]string, []error) { if strings.HasPrefix(v.(string), "/") || strings.HasSuffix(v.(string), "/") { return nil, []error{fmt.Errorf("key can not start and end with '/'")} } @@ -196,7 +196,7 @@ func New() backend.Backend { Optional: true, Description: "Object ACL to be applied to the state file", Default: "", - ValidateFunc: func(v interface{}, k string) ([]string, []error) { + ValidateFunc: func(v any, k string) ([]string, []error) { if value := v.(string); value != "" { acls := oss.ACLType(value) if acls != oss.ACLPrivate && acls != oss.ACLPublicRead && acls != oss.ACLPublicReadWrite { @@ -242,7 +242,7 @@ func New() backend.Backend { Type: schema.TypeInt, Optional: true, Description: "The time after which the established session for assuming role expires.", - ValidateFunc: func(v interface{}, k string) ([]string, []error) { + ValidateFunc: func(v any, k string) ([]string, []error) { min := 900 max := 3600 value, ok := v.(int) @@ -337,7 +337,7 @@ func (b *Backend) configure(ctx context.Context) error { } else if v, ok := d.GetOk("assume_role"); ok { // deprecated assume_role block for _, v := range v.(*schema.Set).List() { - assumeRole := v.(map[string]interface{}) + assumeRole := v.(map[string]any) if assumeRole["role_arn"].(string) != "" { roleArn = assumeRole["role_arn"].(string) } @@ -544,9 +544,9 @@ func (a *Invoker) Run(f func() error) error { return err } -var providerConfig map[string]interface{} +var providerConfig map[string]any -func getConfigFromProfile(d *schema.ResourceData, ProfileKey string) (interface{}, error) { +func getConfigFromProfile(d *schema.ResourceData, ProfileKey string) (any, error) { if providerConfig == nil { if v, ok := d.GetOk("profile"); !ok || v.(string) == "" { @@ -564,21 +564,21 @@ func getConfigFromProfile(d *schema.ResourceData, ProfileKey string) (interface{ profilePath = fmt.Sprintf("%s/.aliyun/config.json", os.Getenv("USERPROFILE")) } } - providerConfig = make(map[string]interface{}) + providerConfig = make(map[string]any) _, err = os.Stat(profilePath) if !os.IsNotExist(err) { data, err := ioutil.ReadFile(profilePath) if err != nil { return nil, err } - config := map[string]interface{}{} + config := map[string]any{} err = json.Unmarshal(data, &config) if err != nil { return nil, err } - for _, v := range config["profiles"].([]interface{}) { - if current == v.(map[string]interface{})["name"] { - providerConfig = v.(map[string]interface{}) + for _, v := range config["profiles"].([]any) { + if current == v.(map[string]any)["name"] { + providerConfig = v.(map[string]any) } } } @@ -652,7 +652,7 @@ func getAuthCredentialByEcsRoleName(ecsRoleName string) (accessKey, secretKey, t err = fmt.Errorf("get Ecs sts token err, httpStatus: %d, message = %s", response.GetHttpStatus(), response.GetHttpContentString()) return } - var data interface{} + var data any err = json.Unmarshal(response.GetHttpContentBytes(), &data) if err != nil { err = fmt.Errorf("refresh Ecs sts token err, json.Unmarshal fail: %s", err.Error()) diff --git a/staging/terraform/backend/remote-state/oss/backend_test.go b/staging/terraform/backend/remote-state/oss/backend_test.go index cff0f11..6f68efd 100644 --- a/staging/terraform/backend/remote-state/oss/backend_test.go +++ b/staging/terraform/backend/remote-state/oss/backend_test.go @@ -39,7 +39,7 @@ func TestBackend_impl(t *testing.T) { func TestBackendConfig(t *testing.T) { testACC(t) - config := map[string]interface{}{ + config := map[string]any{ "region": "cn-beijing", "bucket": "terraform-backend-oss-test", "prefix": "mystate", @@ -74,7 +74,7 @@ func TestBackendConfig(t *testing.T) { func TestBackendConfigWorkSpace(t *testing.T) { testACC(t) bucketName := fmt.Sprintf("terraform-backend-oss-test-%d", rand.Intn(1000)) - config := map[string]interface{}{ + config := map[string]any{ "region": "cn-beijing", "bucket": bucketName, "prefix": "mystate", @@ -112,7 +112,7 @@ func TestBackendConfigWorkSpace(t *testing.T) { func TestBackendConfigProfile(t *testing.T) { testACC(t) - config := map[string]interface{}{ + config := map[string]any{ "region": "cn-beijing", "bucket": "terraform-backend-oss-test", "prefix": "mystate", @@ -147,7 +147,7 @@ func TestBackendConfigProfile(t *testing.T) { func TestBackendConfig_invalidKey(t *testing.T) { testACC(t) - cfg := hcl2shim.HCL2ValueFromConfigValue(map[string]interface{}{ + cfg := hcl2shim.HCL2ValueFromConfigValue(map[string]any{ "region": "cn-beijing", "bucket": "terraform-backend-oss-test", "prefix": "/leading-slash", @@ -168,12 +168,12 @@ func TestBackend(t *testing.T) { bucketName := fmt.Sprintf("terraform-remote-oss-test-%x", time.Now().Unix()) statePrefix := "multi/level/path/" - b1 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b1 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "bucket": bucketName, "prefix": statePrefix, })).(*Backend) - b2 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b2 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "bucket": bucketName, "prefix": statePrefix, })).(*Backend) diff --git a/staging/terraform/backend/remote-state/oss/client_test.go b/staging/terraform/backend/remote-state/oss/client_test.go index 1d7e289..26b4bfc 100644 --- a/staging/terraform/backend/remote-state/oss/client_test.go +++ b/staging/terraform/backend/remote-state/oss/client_test.go @@ -31,7 +31,7 @@ func TestRemoteClient(t *testing.T) { bucketName := fmt.Sprintf("tf-remote-oss-test-%x", time.Now().Unix()) path := "testState" - b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "bucket": bucketName, "prefix": path, "encrypt": true, @@ -54,7 +54,7 @@ func TestRemoteClientLocks(t *testing.T) { tableName := fmt.Sprintf("tfRemoteTestForce%x", time.Now().Unix()) path := "testState" - b1 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b1 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "bucket": bucketName, "prefix": path, "encrypt": true, @@ -62,7 +62,7 @@ func TestRemoteClientLocks(t *testing.T) { "tablestore_endpoint": RemoteTestUsedOTSEndpoint, })).(*Backend) - b2 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b2 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "bucket": bucketName, "prefix": path, "encrypt": true, @@ -95,7 +95,7 @@ func TestRemoteClientLocks_multipleStates(t *testing.T) { tableName := fmt.Sprintf("tfRemoteTestForce%x", time.Now().Unix()) path := "testState" - b1 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b1 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "bucket": bucketName, "prefix": path, "encrypt": true, @@ -103,7 +103,7 @@ func TestRemoteClientLocks_multipleStates(t *testing.T) { "tablestore_endpoint": RemoteTestUsedOTSEndpoint, })).(*Backend) - b2 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b2 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "bucket": bucketName, "prefix": path, "encrypt": true, @@ -141,7 +141,7 @@ func TestRemoteForceUnlock(t *testing.T) { tableName := fmt.Sprintf("tfRemoteTestForce%x", time.Now().Unix()) path := "testState" - b1 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b1 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "bucket": bucketName, "prefix": path, "encrypt": true, @@ -149,7 +149,7 @@ func TestRemoteForceUnlock(t *testing.T) { "tablestore_endpoint": RemoteTestUsedOTSEndpoint, })).(*Backend) - b2 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b2 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "bucket": bucketName, "prefix": path, "encrypt": true, @@ -221,7 +221,7 @@ func TestRemoteClient_clientMD5(t *testing.T) { tableName := fmt.Sprintf("tfRemoteTestForce%x", time.Now().Unix()) path := "testState" - b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "bucket": bucketName, "prefix": path, "tablestore_table": tableName, @@ -271,7 +271,7 @@ func TestRemoteClient_stateChecksum(t *testing.T) { tableName := fmt.Sprintf("tfRemoteTestForce%x", time.Now().Unix()) path := "testState" - b1 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b1 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "bucket": bucketName, "prefix": path, "tablestore_table": tableName, @@ -304,7 +304,7 @@ func TestRemoteClient_stateChecksum(t *testing.T) { // Use b2 without a tablestore_table to bypass the lock table to write the state directly. // client2 will write the "incorrect" state, simulating oss eventually consistency delays - b2 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b2 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "bucket": bucketName, "prefix": path, })).(*Backend) diff --git a/staging/terraform/backend/remote-state/pg/backend.go b/staging/terraform/backend/remote-state/pg/backend.go index 0736cce..755f385 100644 --- a/staging/terraform/backend/remote-state/pg/backend.go +++ b/staging/terraform/backend/remote-state/pg/backend.go @@ -21,7 +21,7 @@ const ( ) func defaultBoolFunc(k string, dv bool) schema.SchemaDefaultFunc { - return func() (interface{}, error) { + return func() (any, error) { if v := os.Getenv(k); v != "" { return strconv.ParseBool(v) } diff --git a/staging/terraform/backend/remote-state/pg/backend_test.go b/staging/terraform/backend/remote-state/pg/backend_test.go index 8a2edf6..ac7cda9 100644 --- a/staging/terraform/backend/remote-state/pg/backend_test.go +++ b/staging/terraform/backend/remote-state/pg/backend_test.go @@ -55,13 +55,13 @@ func TestBackendConfig(t *testing.T) { testCases := []struct { Name string EnvVars map[string]string - Config map[string]interface{} + Config map[string]any ExpectConfigurationError string ExpectConnectionError string }{ { Name: "valid-config", - Config: map[string]interface{}{ + Config: map[string]any{ "conn_str": connStr, "schema_name": fmt.Sprintf("terraform_%s", t.Name()), }, @@ -72,7 +72,7 @@ func TestBackendConfig(t *testing.T) { "PGSSLMODE": "disable", "PGDATABASE": databaseName, }, - Config: map[string]interface{}{ + Config: map[string]any{ "schema_name": fmt.Sprintf("terraform_%s", t.Name()), }, }, @@ -81,7 +81,7 @@ func TestBackendConfig(t *testing.T) { EnvVars: map[string]string{ "PG_CONN_STR": connStr, }, - Config: map[string]interface{}{ + Config: map[string]any{ "schema_name": fmt.Sprintf("terraform_%s", t.Name()), }, }, @@ -91,7 +91,7 @@ func TestBackendConfig(t *testing.T) { "PGUSER": "baduser", "PGPASSWORD": "badpassword", }, - Config: map[string]interface{}{ + Config: map[string]any{ "conn_str": connStr, "schema_name": fmt.Sprintf("terraform_%s", t.Name()), }, @@ -102,7 +102,7 @@ func TestBackendConfig(t *testing.T) { EnvVars: map[string]string{ "PGHOST": "hostthatdoesnotexist", }, - Config: map[string]interface{}{ + Config: map[string]any{ "schema_name": fmt.Sprintf("terraform_%s", t.Name()), }, ExpectConnectionError: `no such host`, @@ -116,7 +116,7 @@ func TestBackendConfig(t *testing.T) { "PG_SKIP_INDEX_CREATION": "f", "PGDATABASE": databaseName, }, - Config: map[string]interface{}{ + Config: map[string]any{ "schema_name": fmt.Sprintf("terraform_%s", t.Name()), }, }, @@ -127,7 +127,7 @@ func TestBackendConfig(t *testing.T) { "PG_SKIP_SCHEMA_CREATION": "foo", "PGDATABASE": databaseName, }, - Config: map[string]interface{}{ + Config: map[string]any{ "schema_name": fmt.Sprintf("terraform_%s", t.Name()), }, ExpectConfigurationError: `error getting default for "skip_schema_creation"`, @@ -295,7 +295,7 @@ func TestBackendConfigSkipOptions(t *testing.T) { t.Run(tc.Name, func(t *testing.T) { schemaName := tc.Name - config := backend.TestWrapConfig(map[string]interface{}{ + config := backend.TestWrapConfig(map[string]any{ "conn_str": connStr, "schema_name": schemaName, "skip_schema_creation": tc.SkipSchemaCreation, @@ -382,7 +382,7 @@ func TestBackendStates(t *testing.T) { } defer dbCleaner.Query(fmt.Sprintf("DROP SCHEMA IF EXISTS %s CASCADE", pq.QuoteIdentifier(schemaName))) - config := backend.TestWrapConfig(map[string]interface{}{ + config := backend.TestWrapConfig(map[string]any{ "conn_str": connStr, "schema_name": schemaName, }) @@ -407,7 +407,7 @@ func TestBackendStateLocks(t *testing.T) { } defer dbCleaner.Query(fmt.Sprintf("DROP SCHEMA IF EXISTS %s CASCADE", schemaName)) - config := backend.TestWrapConfig(map[string]interface{}{ + config := backend.TestWrapConfig(map[string]any{ "conn_str": connStr, "schema_name": schemaName, }) @@ -436,7 +436,7 @@ func TestBackendConcurrentLock(t *testing.T) { getStateMgr := func(schemaName string) (statemgr.Full, *statemgr.LockInfo) { defer dbCleaner.Query(fmt.Sprintf("DROP SCHEMA IF EXISTS %s CASCADE", schemaName)) - config := backend.TestWrapConfig(map[string]interface{}{ + config := backend.TestWrapConfig(map[string]any{ "conn_str": connStr, "schema_name": schemaName, }) diff --git a/staging/terraform/backend/remote-state/pg/client_test.go b/staging/terraform/backend/remote-state/pg/client_test.go index 5eba64b..42c40a2 100644 --- a/staging/terraform/backend/remote-state/pg/client_test.go +++ b/staging/terraform/backend/remote-state/pg/client_test.go @@ -30,7 +30,7 @@ func TestRemoteClient(t *testing.T) { } defer dbCleaner.Query(fmt.Sprintf("DROP SCHEMA IF EXISTS %s CASCADE", schemaName)) - config := backend.TestWrapConfig(map[string]interface{}{ + config := backend.TestWrapConfig(map[string]any{ "conn_str": connStr, "schema_name": schemaName, }) @@ -58,7 +58,7 @@ func TestRemoteLocks(t *testing.T) { } defer dbCleaner.Query(fmt.Sprintf("DROP SCHEMA IF EXISTS %s CASCADE", schemaName)) - config := backend.TestWrapConfig(map[string]interface{}{ + config := backend.TestWrapConfig(map[string]any{ "conn_str": connStr, "schema_name": schemaName, }) diff --git a/staging/terraform/backend/remote-state/s3/backend.go b/staging/terraform/backend/remote-state/s3/backend.go index 64f22a7..25952b2 100644 --- a/staging/terraform/backend/remote-state/s3/backend.go +++ b/staging/terraform/backend/remote-state/s3/backend.go @@ -34,7 +34,7 @@ func New() backend.Backend { Type: schema.TypeString, Required: true, Description: "The path to the state file inside the bucket", - ValidateFunc: func(v interface{}, s string) ([]string, []error) { + ValidateFunc: func(v any, s string) ([]string, []error) { // s3 will strip leading slashes from an object, so while this will // technically be accepted by s3, it will break our workspace hierarchy. if strings.HasPrefix(v.(string), "/") { @@ -177,7 +177,7 @@ func New() backend.Backend { Description: "The base64-encoded encryption key to use for server-side encryption with customer-provided keys (SSE-C).", DefaultFunc: schema.EnvDefaultFunc("AWS_SSE_CUSTOMER_KEY", ""), Sensitive: true, - ValidateFunc: func(v interface{}, s string) ([]string, []error) { + ValidateFunc: func(v any, s string) ([]string, []error) { key := v.(string) if key != "" && len(key) != 44 { return nil, []error{errors.New("sse_customer_key must be 44 characters in length (256 bits, base64 encoded)")} @@ -246,7 +246,7 @@ func New() backend.Backend { Optional: true, Description: "The prefix applied to the non-default state path inside the bucket.", Default: "env:", - ValidateFunc: func(v interface{}, s string) ([]string, []error) { + ValidateFunc: func(v any, s string) ([]string, []error) { prefix := v.(string) if strings.HasPrefix(prefix, "/") || strings.HasSuffix(prefix, "/") { return nil, []error{errors.New("workspace_key_prefix must not start or end with '/'")} @@ -367,7 +367,7 @@ func (b *Backend) configure(ctx context.Context) error { } } - if tagMap := data.Get("assume_role_tags").(map[string]interface{}); len(tagMap) > 0 { + if tagMap := data.Get("assume_role_tags").(map[string]any); len(tagMap) > 0 { cfg.AssumeRoleTags = make(map[string]string) for k, vRaw := range tagMap { diff --git a/staging/terraform/backend/remote-state/s3/backend_test.go b/staging/terraform/backend/remote-state/s3/backend_test.go index 11850db..11e18cb 100644 --- a/staging/terraform/backend/remote-state/s3/backend_test.go +++ b/staging/terraform/backend/remote-state/s3/backend_test.go @@ -46,7 +46,7 @@ func TestBackend_impl(t *testing.T) { func TestBackendConfig(t *testing.T) { testACC(t) - config := map[string]interface{}{ + config := map[string]any{ "region": "us-west-1", "bucket": "tf-test", "key": "state", @@ -82,12 +82,12 @@ func TestBackendConfig_AssumeRole(t *testing.T) { testACC(t) testCases := []struct { - Config map[string]interface{} + Config map[string]any Description string MockStsEndpoints []*awsbase.MockEndpoint }{ { - Config: map[string]interface{}{ + Config: map[string]any{ "bucket": "tf-test", "key": "state", "region": "us-west-1", @@ -113,7 +113,7 @@ func TestBackendConfig_AssumeRole(t *testing.T) { }, }, { - Config: map[string]interface{}{ + Config: map[string]any{ "assume_role_duration_seconds": 3600, "bucket": "tf-test", "key": "state", @@ -140,7 +140,7 @@ func TestBackendConfig_AssumeRole(t *testing.T) { }, }, { - Config: map[string]interface{}{ + Config: map[string]any{ "bucket": "tf-test", "external_id": awsbase.MockStsAssumeRoleExternalId, "key": "state", @@ -168,7 +168,7 @@ func TestBackendConfig_AssumeRole(t *testing.T) { }, }, { - Config: map[string]interface{}{ + Config: map[string]any{ "assume_role_policy": awsbase.MockStsAssumeRolePolicy, "bucket": "tf-test", "key": "state", @@ -196,8 +196,8 @@ func TestBackendConfig_AssumeRole(t *testing.T) { }, }, { - Config: map[string]interface{}{ - "assume_role_policy_arns": []interface{}{awsbase.MockStsAssumeRolePolicyArn}, + Config: map[string]any{ + "assume_role_policy_arns": []any{awsbase.MockStsAssumeRolePolicyArn}, "bucket": "tf-test", "key": "state", "region": "us-west-1", @@ -224,8 +224,8 @@ func TestBackendConfig_AssumeRole(t *testing.T) { }, }, { - Config: map[string]interface{}{ - "assume_role_tags": map[string]interface{}{ + Config: map[string]any{ + "assume_role_tags": map[string]any{ awsbase.MockStsAssumeRoleTagKey: awsbase.MockStsAssumeRoleTagValue, }, "bucket": "tf-test", @@ -255,11 +255,11 @@ func TestBackendConfig_AssumeRole(t *testing.T) { }, }, { - Config: map[string]interface{}{ - "assume_role_tags": map[string]interface{}{ + Config: map[string]any{ + "assume_role_tags": map[string]any{ awsbase.MockStsAssumeRoleTagKey: awsbase.MockStsAssumeRoleTagValue, }, - "assume_role_transitive_tag_keys": []interface{}{awsbase.MockStsAssumeRoleTagKey}, + "assume_role_transitive_tag_keys": []any{awsbase.MockStsAssumeRoleTagKey}, "bucket": "tf-test", "key": "state", "region": "us-west-1", @@ -317,7 +317,7 @@ func TestBackendConfig_AssumeRole(t *testing.T) { func TestBackendConfig_invalidKey(t *testing.T) { testACC(t) - cfg := hcl2shim.HCL2ValueFromConfigValue(map[string]interface{}{ + cfg := hcl2shim.HCL2ValueFromConfigValue(map[string]any{ "region": "us-west-1", "bucket": "tf-test", "key": "/leading-slash", @@ -330,7 +330,7 @@ func TestBackendConfig_invalidKey(t *testing.T) { t.Fatal("expected config validation error") } - cfg = hcl2shim.HCL2ValueFromConfigValue(map[string]interface{}{ + cfg = hcl2shim.HCL2ValueFromConfigValue(map[string]any{ "region": "us-west-1", "bucket": "tf-test", "key": "trailing-slash/", @@ -346,7 +346,7 @@ func TestBackendConfig_invalidKey(t *testing.T) { func TestBackendConfig_invalidSSECustomerKeyLength(t *testing.T) { testACC(t) - cfg := hcl2shim.HCL2ValueFromConfigValue(map[string]interface{}{ + cfg := hcl2shim.HCL2ValueFromConfigValue(map[string]any{ "region": "us-west-1", "bucket": "tf-test", "encrypt": true, @@ -363,7 +363,7 @@ func TestBackendConfig_invalidSSECustomerKeyLength(t *testing.T) { func TestBackendConfig_invalidSSECustomerKeyEncoding(t *testing.T) { testACC(t) - cfg := hcl2shim.HCL2ValueFromConfigValue(map[string]interface{}{ + cfg := hcl2shim.HCL2ValueFromConfigValue(map[string]any{ "region": "us-west-1", "bucket": "tf-test", "encrypt": true, @@ -380,7 +380,7 @@ func TestBackendConfig_invalidSSECustomerKeyEncoding(t *testing.T) { func TestBackendConfig_conflictingEncryptionSchema(t *testing.T) { testACC(t) - cfg := hcl2shim.HCL2ValueFromConfigValue(map[string]interface{}{ + cfg := hcl2shim.HCL2ValueFromConfigValue(map[string]any{ "region": "us-west-1", "bucket": "tf-test", "key": "state", @@ -402,7 +402,7 @@ func TestBackend(t *testing.T) { bucketName := fmt.Sprintf("terraform-remote-s3-test-%x", time.Now().Unix()) keyName := "testState" - b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "bucket": bucketName, "key": keyName, "encrypt": true, @@ -420,14 +420,14 @@ func TestBackendLocked(t *testing.T) { bucketName := fmt.Sprintf("terraform-remote-s3-test-%x", time.Now().Unix()) keyName := "test/state" - b1 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b1 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "bucket": bucketName, "key": keyName, "encrypt": true, "dynamodb_table": bucketName, })).(*Backend) - b2 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b2 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "bucket": bucketName, "key": keyName, "encrypt": true, @@ -447,7 +447,7 @@ func TestBackendSSECustomerKey(t *testing.T) { testACC(t) bucketName := fmt.Sprintf("terraform-remote-s3-test-%x", time.Now().Unix()) - b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "bucket": bucketName, "encrypt": true, "key": "test-SSE-C", @@ -466,7 +466,7 @@ func TestBackendExtraPaths(t *testing.T) { bucketName := fmt.Sprintf("terraform-remote-s3-test-%x", time.Now().Unix()) keyName := "test/state/tfstate" - b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "bucket": bucketName, "key": keyName, "encrypt": true, @@ -594,7 +594,7 @@ func TestBackendPrefixInWorkspace(t *testing.T) { testACC(t) bucketName := fmt.Sprintf("terraform-remote-s3-test-%x", time.Now().Unix()) - b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "bucket": bucketName, "key": "test-env.tfstate", "workspace_key_prefix": "env", @@ -622,7 +622,7 @@ func TestKeyEnv(t *testing.T) { keyName := "some/paths/tfstate" bucket0Name := fmt.Sprintf("terraform-remote-s3-test-%x-0", time.Now().Unix()) - b0 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b0 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "bucket": bucket0Name, "key": keyName, "encrypt": true, @@ -633,7 +633,7 @@ func TestKeyEnv(t *testing.T) { defer deleteS3Bucket(t, b0.s3Client, bucket0Name) bucket1Name := fmt.Sprintf("terraform-remote-s3-test-%x-1", time.Now().Unix()) - b1 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b1 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "bucket": bucket1Name, "key": keyName, "encrypt": true, @@ -644,7 +644,7 @@ func TestKeyEnv(t *testing.T) { defer deleteS3Bucket(t, b1.s3Client, bucket1Name) bucket2Name := fmt.Sprintf("terraform-remote-s3-test-%x-2", time.Now().Unix()) - b2 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b2 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "bucket": bucket2Name, "key": keyName, "encrypt": true, diff --git a/staging/terraform/backend/remote-state/s3/client_test.go b/staging/terraform/backend/remote-state/s3/client_test.go index 4bb07ce..9b144ca 100644 --- a/staging/terraform/backend/remote-state/s3/client_test.go +++ b/staging/terraform/backend/remote-state/s3/client_test.go @@ -27,7 +27,7 @@ func TestRemoteClient(t *testing.T) { bucketName := fmt.Sprintf("terraform-remote-s3-test-%x", time.Now().Unix()) keyName := "testState" - b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "bucket": bucketName, "key": keyName, "encrypt": true, @@ -49,14 +49,14 @@ func TestRemoteClientLocks(t *testing.T) { bucketName := fmt.Sprintf("terraform-remote-s3-test-%x", time.Now().Unix()) keyName := "testState" - b1 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b1 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "bucket": bucketName, "key": keyName, "encrypt": true, "dynamodb_table": bucketName, })).(*Backend) - b2 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b2 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "bucket": bucketName, "key": keyName, "encrypt": true, @@ -87,14 +87,14 @@ func TestForceUnlock(t *testing.T) { bucketName := fmt.Sprintf("terraform-remote-s3-test-force-%x", time.Now().Unix()) keyName := "testState" - b1 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b1 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "bucket": bucketName, "key": keyName, "encrypt": true, "dynamodb_table": bucketName, })).(*Backend) - b2 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b2 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "bucket": bucketName, "key": keyName, "encrypt": true, @@ -164,7 +164,7 @@ func TestRemoteClient_clientMD5(t *testing.T) { bucketName := fmt.Sprintf("terraform-remote-s3-test-%x", time.Now().Unix()) keyName := "testState" - b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "bucket": bucketName, "key": keyName, "dynamodb_table": bucketName, @@ -212,7 +212,7 @@ func TestRemoteClient_stateChecksum(t *testing.T) { bucketName := fmt.Sprintf("terraform-remote-s3-test-%x", time.Now().Unix()) keyName := "testState" - b1 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b1 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "bucket": bucketName, "key": keyName, "dynamodb_table": bucketName, @@ -244,7 +244,7 @@ func TestRemoteClient_stateChecksum(t *testing.T) { // Use b2 without a dynamodb_table to bypass the lock table to write the state directly. // client2 will write the "incorrect" state, simulating s3 eventually consistency delays - b2 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]interface{}{ + b2 := backend.TestBackendConfig(t, New(), backend.TestWrapConfig(map[string]any{ "bucket": bucketName, "key": keyName, })).(*Backend) diff --git a/staging/terraform/backend/remote/testing.go b/staging/terraform/backend/remote/testing.go index 4405d11..fa79f53 100644 --- a/staging/terraform/backend/remote/testing.go +++ b/staging/terraform/backend/remote/testing.go @@ -39,7 +39,7 @@ const ( var ( tfeHost = svchost.Hostname(defaultHostname) - credsSrc = auth.StaticCredentialsSource(map[svchost.Hostname]map[string]interface{}{ + credsSrc = auth.StaticCredentialsSource(map[svchost.Hostname]map[string]any{ tfeHost: {"token": testCred}, }) ) @@ -287,7 +287,7 @@ func testServer(t *testing.T) *httptest.Server { // testDisco returns a *disco.Disco mapping app.terraform.io and // localhost to a local test server. func testDisco(s *httptest.Server) *disco.Disco { - services := map[string]interface{}{ + services := map[string]any{ "state.v2": fmt.Sprintf("%s/api/v2/", s.URL), "tfe.v2.1": fmt.Sprintf("%s/api/v2/", s.URL), "versions.v1": fmt.Sprintf("%s/v1/versions/", s.URL), diff --git a/staging/terraform/backend/testing.go b/staging/terraform/backend/testing.go index 8db78a9..9b5c66b 100644 --- a/staging/terraform/backend/testing.go +++ b/staging/terraform/backend/testing.go @@ -66,7 +66,7 @@ func TestBackendConfig(t *testing.T, b Backend, c hcl.Body) Backend { // The given structure should only include values that can be accepted by // hcl2shim.HCL2ValueFromConfigValue. If incompatible values are given, // this function will panic. -func TestWrapConfig(raw map[string]interface{}) hcl.Body { +func TestWrapConfig(raw map[string]any) hcl.Body { obj := hcl2shim.HCL2ValueFromConfigValue(raw) return configs.SynthBody("", obj.AsValueMap()) } diff --git a/staging/terraform/cloud/testing.go b/staging/terraform/cloud/testing.go index bdb6341..f5cbab4 100644 --- a/staging/terraform/cloud/testing.go +++ b/staging/terraform/cloud/testing.go @@ -42,7 +42,7 @@ const ( var ( tfeHost = svchost.Hostname(defaultHostname) - credsSrc = auth.StaticCredentialsSource(map[svchost.Hostname]map[string]interface{}{ + credsSrc = auth.StaticCredentialsSource(map[svchost.Hostname]map[string]any{ tfeHost: {"token": testCred}, }) testBackendSingleWorkspaceName = "app-prod" @@ -170,8 +170,8 @@ func testBackendWithOutputs(t *testing.T) (*Cloud, func()) { DetailedType: "string", }) - var dt interface{} - var val interface{} + var dt any + var val any err := json.Unmarshal([]byte(`["object", {"foo":"string"}]`), &dt) if err != nil { t.Fatalf("could not unmarshal detailed type: %s", err) @@ -488,7 +488,7 @@ func mockSROWorkspace(t *testing.T, b *Cloud, workspaceName string) { // testDisco returns a *disco.Disco mapping app.terraform.io and // localhost to a local test server. func testDisco(s *httptest.Server) *disco.Disco { - services := map[string]interface{}{ + services := map[string]any{ "tfe.v2": fmt.Sprintf("%s/api/v2/", s.URL), } d := disco.NewWithCredentialsSource(credsSrc) diff --git a/staging/terraform/command/cliconfig/cliconfig.go b/staging/terraform/command/cliconfig/cliconfig.go index ed607ec..d3b26b9 100644 --- a/staging/terraform/command/cliconfig/cliconfig.go +++ b/staging/terraform/command/cliconfig/cliconfig.go @@ -58,7 +58,7 @@ type Config struct { Hosts map[string]*ConfigHost `hcl:"host"` - Credentials map[string]map[string]interface{} `hcl:"credentials"` + Credentials map[string]map[string]any `hcl:"credentials"` CredentialsHelpers map[string]*ConfigCredentialsHelper `hcl:"credentials_helper"` // ProviderInstallation represents any provider_installation blocks @@ -72,7 +72,7 @@ type Config struct { // configuration, which can be used to override the default service host // discovery behavior for a particular hostname. type ConfigHost struct { - Services map[string]interface{} `hcl:"services"` + Services map[string]any `hcl:"services"` } // ConfigCredentialsHelper is the structure of the "credentials_helper" @@ -384,7 +384,7 @@ func (c *Config) Merge(c2 *Config) *Config { } if (len(c.Credentials) + len(c2.Credentials)) > 0 { - result.Credentials = make(map[string]map[string]interface{}) + result.Credentials = make(map[string]map[string]any) for host, creds := range c.Credentials { result.Credentials[host] = creds } diff --git a/staging/terraform/command/cliconfig/cliconfig_test.go b/staging/terraform/command/cliconfig/cliconfig_test.go index 5fe3c49..13addc8 100644 --- a/staging/terraform/command/cliconfig/cliconfig_test.go +++ b/staging/terraform/command/cliconfig/cliconfig_test.go @@ -228,7 +228,7 @@ func TestLoadConfig_hosts(t *testing.T) { want := &Config{ Hosts: map[string]*ConfigHost{ "example.com": { - Services: map[string]interface{}{ + Services: map[string]any{ "modules.v1": "https://example.com/", }, }, @@ -247,11 +247,11 @@ func TestLoadConfig_credentials(t *testing.T) { } want := &Config{ - Credentials: map[string]map[string]interface{}{ - "example.com": map[string]interface{}{ + Credentials: map[string]map[string]any{ + "example.com": map[string]any{ "token": "foo the bar baz", }, - "example.net": map[string]interface{}{ + "example.net": map[string]any{ "username": "foo", "password": "baz", }, @@ -299,8 +299,8 @@ func TestConfigValidate(t *testing.T) { }, "credentials good": { &Config{ - Credentials: map[string]map[string]interface{}{ - "example.com": map[string]interface{}{ + Credentials: map[string]map[string]any{ + "example.com": map[string]any{ "token": "foo", }, }, @@ -309,8 +309,8 @@ func TestConfigValidate(t *testing.T) { }, "credentials with bad hostname": { &Config{ - Credentials: map[string]map[string]interface{}{ - "example..com": map[string]interface{}{ + Credentials: map[string]map[string]any{ + "example..com": map[string]any{ "token": "foo", }, }, @@ -390,12 +390,12 @@ func TestConfig_Merge(t *testing.T) { }, Hosts: map[string]*ConfigHost{ "example.com": { - Services: map[string]interface{}{ + Services: map[string]any{ "modules.v1": "http://example.com/", }, }, }, - Credentials: map[string]map[string]interface{}{ + Credentials: map[string]map[string]any{ "foo": { "bar": "baz", }, @@ -428,12 +428,12 @@ func TestConfig_Merge(t *testing.T) { }, Hosts: map[string]*ConfigHost{ "example.net": { - Services: map[string]interface{}{ + Services: map[string]any{ "modules.v1": "https://example.net/", }, }, }, - Credentials: map[string]map[string]interface{}{ + Credentials: map[string]map[string]any{ "fee": { "bur": "bez", }, @@ -463,17 +463,17 @@ func TestConfig_Merge(t *testing.T) { }, Hosts: map[string]*ConfigHost{ "example.com": { - Services: map[string]interface{}{ + Services: map[string]any{ "modules.v1": "http://example.com/", }, }, "example.net": { - Services: map[string]interface{}{ + Services: map[string]any{ "modules.v1": "https://example.net/", }, }, }, - Credentials: map[string]map[string]interface{}{ + Credentials: map[string]map[string]any{ "foo": { "bar": "baz", }, diff --git a/staging/terraform/command/cliconfig/credentials.go b/staging/terraform/command/cliconfig/credentials.go index 760f968..7d6459a 100644 --- a/staging/terraform/command/cliconfig/credentials.go +++ b/staging/terraform/command/cliconfig/credentials.go @@ -333,7 +333,7 @@ func (s *CredentialsSource) updateLocalHostCredentials(host svchost.Hostname, ne return fmt.Errorf("cannot read %s: %s", filename, err) } - var raw map[string]interface{} + var raw map[string]any if len(oldSrc) > 0 { // When decoding we use a custom decoder so we can decode any numbers as @@ -345,15 +345,15 @@ func (s *CredentialsSource) updateLocalHostCredentials(host svchost.Hostname, ne return fmt.Errorf("cannot read %s: %s", filename, err) } } else { - raw = make(map[string]interface{}) + raw = make(map[string]any) } rawCredsI, ok := raw["credentials"] if !ok { - rawCredsI = make(map[string]interface{}) + rawCredsI = make(map[string]any) raw["credentials"] = rawCredsI } - rawCredsMap, ok := rawCredsI.(map[string]interface{}) + rawCredsMap, ok := rawCredsI.(map[string]any) if !ok { return fmt.Errorf("credentials file %s has invalid value for \"credentials\" property: must be a JSON object", filename) } @@ -458,7 +458,7 @@ func readHostsInCredentialsFile(filename string) map[svchost.Hostname]struct{} { return nil } - var raw map[string]interface{} + var raw map[string]any err = json.Unmarshal(src, &raw) if err != nil { return nil @@ -468,7 +468,7 @@ func readHostsInCredentialsFile(filename string) map[svchost.Hostname]struct{} { if !ok { return nil } - rawCredsMap, ok := rawCredsI.(map[string]interface{}) + rawCredsMap, ok := rawCredsI.(map[string]any) if !ok { return nil } diff --git a/staging/terraform/command/cliconfig/credentials_test.go b/staging/terraform/command/cliconfig/credentials_test.go index 2d15a13..128c437 100644 --- a/staging/terraform/command/cliconfig/credentials_test.go +++ b/staging/terraform/command/cliconfig/credentials_test.go @@ -31,7 +31,7 @@ func TestCredentialsForHost(t *testing.T) { // a credentials helper program, since we're only testing the logic // for choosing when to delegate to the helper here. The logic for // interacting with a helper program is tested in the svcauth package. - helper: svcauth.StaticCredentialsSource(map[svchost.Hostname]map[string]interface{}{ + helper: svcauth.StaticCredentialsSource(map[svchost.Hostname]map[string]any{ "from-helper.example.com": { "token": "from-helper", }, @@ -219,7 +219,7 @@ func TestCredentialsStoreForget(t *testing.T) { cfg := &Config{ // This simulates there being a credentials block manually configured // in some file _other than_ credentials.tfrc.json. - Credentials: map[string]map[string]interface{}{ + Credentials: map[string]map[string]any{ "manually-configured.example.com": { "token": "manually-configured", }, @@ -307,7 +307,7 @@ func TestCredentialsStoreForget(t *testing.T) { // If we were loading the real CLI config from disk here then this // entry would already be in cfg.Credentials, but we need to fake that // in the test because we're constructing this *Config value directly. - cfg.Credentials["stored-locally.example.com"] = map[string]interface{}{ + cfg.Credentials["stored-locally.example.com"] = map[string]any{ "token": "stored-locally", } mockHelper := &mockCredentialsHelper{current: make(map[svchost.Hostname]cty.Value)} diff --git a/staging/terraform/command/command_test.go b/staging/terraform/command/command_test.go index bbfcd2c..b95c107 100644 --- a/staging/terraform/command/command_test.go +++ b/staging/terraform/command/command_test.go @@ -998,7 +998,7 @@ func testServices(t *testing.T) (services *disco.Disco, cleanup func()) { server := httptest.NewServer(http.HandlerFunc(fakeRegistryHandler)) services = disco.New() - services.ForceHostServices(svchost.Hostname("registry.terraform.io"), map[string]interface{}{ + services.ForceHostServices(svchost.Hostname("registry.terraform.io"), map[string]any{ "providers.v1": server.URL + "/providers/v1/", }) @@ -1137,10 +1137,10 @@ func checkGoldenReference(t *testing.T, output *terminal.TestOutput, fixturePath } // Compare the rest of the lines against the golden reference - var gotLineMaps []map[string]interface{} + var gotLineMaps []map[string]any for i, line := range gotLines[1:] { index := i + 1 - var gotMap map[string]interface{} + var gotMap map[string]any if err := json.Unmarshal([]byte(line), &gotMap); err != nil { t.Errorf("failed to unmarshal got line %d: %s\n%s", index, err, gotLines[index]) } @@ -1150,10 +1150,10 @@ func checkGoldenReference(t *testing.T, output *terminal.TestOutput, fixturePath delete(gotMap, "@timestamp") gotLineMaps = append(gotLineMaps, gotMap) } - var wantLineMaps []map[string]interface{} + var wantLineMaps []map[string]any for i, line := range wantLines[1:] { index := i + 1 - var wantMap map[string]interface{} + var wantMap map[string]any if err := json.Unmarshal([]byte(line), &wantMap); err != nil { t.Errorf("failed to unmarshal want line %d: %s\n%s", index, err, gotLines[index]) } diff --git a/staging/terraform/command/format/diagnostic_test.go b/staging/terraform/command/format/diagnostic_test.go index 3772d23..0097c9f 100644 --- a/staging/terraform/command/format/diagnostic_test.go +++ b/staging/terraform/command/format/diagnostic_test.go @@ -24,7 +24,7 @@ import ( func TestDiagnostic(t *testing.T) { tests := map[string]struct { - Diag interface{} + Diag any Want string }{ "sourceless error": { @@ -292,7 +292,7 @@ func TestDiagnostic(t *testing.T) { func TestDiagnosticPlain(t *testing.T) { tests := map[string]struct { - Diag interface{} + Diag any Want string }{ "sourceless error": { diff --git a/staging/terraform/command/init_test.go b/staging/terraform/command/init_test.go index 180e19e..fa62985 100644 --- a/staging/terraform/command/init_test.go +++ b/staging/terraform/command/init_test.go @@ -706,7 +706,7 @@ func TestInit_backendConfigKVReInit(t *testing.T) { // make sure the backend is configured how we expect configState := testDataStateRead(t, filepath.Join(DefaultDataDir, DefaultStateFilename)) - cfg := map[string]interface{}{} + cfg := map[string]any{} if err := json.Unmarshal(configState.Backend.ConfigRaw, &cfg); err != nil { t.Fatal(err) } @@ -722,7 +722,7 @@ func TestInit_backendConfigKVReInit(t *testing.T) { // make sure the backend is configured how we expect configState = testDataStateRead(t, filepath.Join(DefaultDataDir, DefaultStateFilename)) - cfg = map[string]interface{}{} + cfg = map[string]any{} if err := json.Unmarshal(configState.Backend.ConfigRaw, &cfg); err != nil { t.Fatal(err) } @@ -770,7 +770,7 @@ func TestInit_backendConfigKVReInitWithConfigDiff(t *testing.T) { // make sure the backend is configured how we expect configState := testDataStateRead(t, filepath.Join(DefaultDataDir, DefaultStateFilename)) - cfg := map[string]interface{}{} + cfg := map[string]any{} if err := json.Unmarshal(configState.Backend.ConfigRaw, &cfg); err != nil { t.Fatal(err) } @@ -1370,18 +1370,18 @@ func TestInit_getProvider(t *testing.T) { // Construct a mock state file from the far future type FutureState struct { - Version uint `json:"version"` - Lineage string `json:"lineage"` - TerraformVersion string `json:"terraform_version"` - Outputs map[string]interface{} `json:"outputs"` - Resources []map[string]interface{} `json:"resources"` + Version uint `json:"version"` + Lineage string `json:"lineage"` + TerraformVersion string `json:"terraform_version"` + Outputs map[string]any `json:"outputs"` + Resources []map[string]any `json:"resources"` } fs := &FutureState{ Version: 999, Lineage: "123-456-789", TerraformVersion: "999.0.0", - Outputs: make(map[string]interface{}), - Resources: make([]map[string]interface{}, 0), + Outputs: make(map[string]any), + Resources: make([]map[string]any, 0), } src, err := json.MarshalIndent(fs, "", " ") if err != nil { diff --git a/staging/terraform/command/jsonchecks/objects.go b/staging/terraform/command/jsonchecks/objects.go index eb20b23..12958b8 100644 --- a/staging/terraform/command/jsonchecks/objects.go +++ b/staging/terraform/command/jsonchecks/objects.go @@ -9,10 +9,10 @@ import ( "github.com/hashicorp/terraform/addrs" ) -type staticObjectAddr map[string]interface{} +type staticObjectAddr map[string]any func makeStaticObjectAddr(addr addrs.ConfigCheckable) staticObjectAddr { - ret := map[string]interface{}{ + ret := map[string]any{ "to_display": addr.String(), } @@ -66,10 +66,10 @@ func makeStaticObjectAddr(addr addrs.ConfigCheckable) staticObjectAddr { return ret } -type dynamicObjectAddr map[string]interface{} +type dynamicObjectAddr map[string]any func makeDynamicObjectAddr(addr addrs.Checkable) dynamicObjectAddr { - ret := map[string]interface{}{ + ret := map[string]any{ "to_display": addr.String(), } diff --git a/staging/terraform/command/jsonconfig/config.go b/staging/terraform/command/jsonconfig/config.go index 4898c74..1b73cc7 100644 --- a/staging/terraform/command/jsonconfig/config.go +++ b/staging/terraform/command/jsonconfig/config.go @@ -29,12 +29,12 @@ type config struct { // provider configurations are the one concept in Terraform that can span across // module boundaries. type providerConfig struct { - Name string `json:"name,omitempty"` - FullName string `json:"full_name,omitempty"` - Alias string `json:"alias,omitempty"` - VersionConstraint string `json:"version_constraint,omitempty"` - ModuleAddress string `json:"module_address,omitempty"` - Expressions map[string]interface{} `json:"expressions,omitempty"` + Name string `json:"name,omitempty"` + FullName string `json:"full_name,omitempty"` + Alias string `json:"alias,omitempty"` + VersionConstraint string `json:"version_constraint,omitempty"` + ModuleAddress string `json:"module_address,omitempty"` + Expressions map[string]any `json:"expressions,omitempty"` parentKey string } @@ -48,13 +48,13 @@ type module struct { } type moduleCall struct { - Source string `json:"source,omitempty"` - Expressions map[string]interface{} `json:"expressions,omitempty"` - CountExpression *expression `json:"count_expression,omitempty"` - ForEachExpression *expression `json:"for_each_expression,omitempty"` - Module module `json:"module,omitempty"` - VersionConstraint string `json:"version_constraint,omitempty"` - DependsOn []string `json:"depends_on,omitempty"` + Source string `json:"source,omitempty"` + Expressions map[string]any `json:"expressions,omitempty"` + CountExpression *expression `json:"count_expression,omitempty"` + ForEachExpression *expression `json:"for_each_expression,omitempty"` + Module module `json:"module,omitempty"` + VersionConstraint string `json:"version_constraint,omitempty"` + DependsOn []string `json:"depends_on,omitempty"` } // variables is the JSON representation of the variables provided to the current @@ -92,7 +92,7 @@ type resource struct { // Expressions" describes the resource-type-specific content of the // configuration block. - Expressions map[string]interface{} `json:"expressions,omitempty"` + Expressions map[string]any `json:"expressions,omitempty"` // SchemaVersion indicates which version of the resource type schema the // "values" property conforms to. @@ -115,8 +115,8 @@ type output struct { } type provisioner struct { - Type string `json:"type,omitempty"` - Expressions map[string]interface{} `json:"expressions,omitempty"` + Type string `json:"type,omitempty"` + Expressions map[string]any `json:"expressions,omitempty"` } // Marshal returns the json encoding of terraform configuration. diff --git a/staging/terraform/command/jsonconfig/expression.go b/staging/terraform/command/jsonconfig/expression.go index 6c636b4..1d9a82f 100644 --- a/staging/terraform/command/jsonconfig/expression.go +++ b/staging/terraform/command/jsonconfig/expression.go @@ -90,7 +90,7 @@ func (e *expression) Empty() bool { // expressions is used to represent the entire content of a block. Attribute // arguments are mapped directly with the attribute name as key and an // expression as value. -type expressions map[string]interface{} +type expressions map[string]any func marshalExpressions(body hcl.Body, schema *configschema.Block) expressions { // Since we want the raw, un-evaluated expressions we need to use the @@ -138,16 +138,16 @@ func marshalExpressions(body hcl.Body, schema *configschema.Block) expressions { ret[typeName] = marshalExpressions(block.Body, &blockS.Block) case configschema.NestingList, configschema.NestingSet: if _, exists := ret[typeName]; !exists { - ret[typeName] = make([]map[string]interface{}, 0, 1) + ret[typeName] = make([]map[string]any, 0, 1) } - ret[typeName] = append(ret[typeName].([]map[string]interface{}), marshalExpressions(block.Body, &blockS.Block)) + ret[typeName] = append(ret[typeName].([]map[string]any), marshalExpressions(block.Body, &blockS.Block)) case configschema.NestingMap: if _, exists := ret[typeName]; !exists { - ret[typeName] = make(map[string]map[string]interface{}) + ret[typeName] = make(map[string]map[string]any) } // NestingMap blocks always have the key in the first (and only) label key := block.Labels[0] - retMap := ret[typeName].(map[string]map[string]interface{}) + retMap := ret[typeName].(map[string]map[string]any) retMap[key] = marshalExpressions(block.Body, &blockS.Block) } } diff --git a/staging/terraform/command/jsonformat/computed/renderers/json.go b/staging/terraform/command/jsonformat/computed/renderers/json.go index e5e35f9..7523427 100644 --- a/staging/terraform/command/jsonformat/computed/renderers/json.go +++ b/staging/terraform/command/jsonformat/computed/renderers/json.go @@ -19,7 +19,7 @@ import ( // our JSON string rendering here. func RendererJsonOpts() jsondiff.JsonOpts { return jsondiff.JsonOpts{ - Primitive: func(before, after interface{}, ctype cty.Type, action plans.Action) computed.Diff { + Primitive: func(before, after any, ctype cty.Type, action plans.Action) computed.Diff { return computed.NewDiff(Primitive(before, after, ctype), action, false) }, Object: func(elements map[string]computed.Diff, action plans.Action) computed.Diff { diff --git a/staging/terraform/command/jsonformat/computed/renderers/primitive.go b/staging/terraform/command/jsonformat/computed/renderers/primitive.go index e5217ba..0d03bd2 100644 --- a/staging/terraform/command/jsonformat/computed/renderers/primitive.go +++ b/staging/terraform/command/jsonformat/computed/renderers/primitive.go @@ -19,7 +19,7 @@ import ( var _ computed.DiffRenderer = (*primitiveRenderer)(nil) -func Primitive(before, after interface{}, ctype cty.Type) computed.DiffRenderer { +func Primitive(before, after any, ctype cty.Type) computed.DiffRenderer { return &primitiveRenderer{ before: before, after: after, @@ -30,8 +30,8 @@ func Primitive(before, after interface{}, ctype cty.Type) computed.DiffRenderer type primitiveRenderer struct { NoWarningsRenderer - before interface{} - after interface{} + before any + after any ctype cty.Type } @@ -55,7 +55,7 @@ func (renderer primitiveRenderer) RenderHuman(diff computed.Diff, indent int, op } } -func renderPrimitiveValue(value interface{}, t cty.Type, opts computed.RenderHumanOpts) string { +func renderPrimitiveValue(value any, t cty.Type, opts computed.RenderHumanOpts) string { if value == nil { return opts.Colorize.Color("[dark_gray]null[reset]") } diff --git a/staging/terraform/command/jsonformat/computed/renderers/string.go b/staging/terraform/command/jsonformat/computed/renderers/string.go index d07423d..7c4215c 100644 --- a/staging/terraform/command/jsonformat/computed/renderers/string.go +++ b/staging/terraform/command/jsonformat/computed/renderers/string.go @@ -13,13 +13,13 @@ import ( type evaluatedString struct { String string - Json interface{} + Json any IsMultiline bool IsNull bool } -func evaluatePrimitiveString(value interface{}, opts computed.RenderHumanOpts) evaluatedString { +func evaluatePrimitiveString(value any, opts computed.RenderHumanOpts) evaluatedString { if value == nil { return evaluatedString{ String: opts.Colorize.Color("[dark_gray]null[reset]"), @@ -30,7 +30,7 @@ func evaluatePrimitiveString(value interface{}, opts computed.RenderHumanOpts) e str := value.(string) if strings.HasPrefix(str, "{") || strings.HasPrefix(str, "[") { - var jv interface{} + var jv any if err := json.Unmarshal([]byte(str), &jv); err == nil { return evaluatedString{ String: str, diff --git a/staging/terraform/command/jsonformat/computed/renderers/testing.go b/staging/terraform/command/jsonformat/computed/renderers/testing.go index 154c4a2..208dee0 100644 --- a/staging/terraform/command/jsonformat/computed/renderers/testing.go +++ b/staging/terraform/command/jsonformat/computed/renderers/testing.go @@ -21,7 +21,7 @@ func validateDiff(t *testing.T, diff computed.Diff, expectedAction plans.Action, } } -func ValidatePrimitive(before, after interface{}, action plans.Action, replace bool) ValidateDiffFunction { +func ValidatePrimitive(before, after any, action plans.Action, replace bool) ValidateDiffFunction { return func(t *testing.T, diff computed.Diff) { validateDiff(t, diff, action, replace) diff --git a/staging/terraform/command/jsonformat/differ/differ_test.go b/staging/terraform/command/jsonformat/differ/differ_test.go index 7ee5bc1..5146a94 100644 --- a/staging/terraform/command/jsonformat/differ/differ_test.go +++ b/staging/terraform/command/jsonformat/differ/differ_test.go @@ -51,11 +51,11 @@ func TestValue_SimpleBlocks(t *testing.T) { }{ "delete_with_null_sensitive_value": { input: structured.Change{ - Before: map[string]interface{}{ + Before: map[string]any{ "normal_attribute": "some value", }, After: nil, - BeforeSensitive: map[string]interface{}{ + BeforeSensitive: map[string]any{ "sensitive_attribute": true, }, AfterSensitive: false, @@ -77,10 +77,10 @@ func TestValue_SimpleBlocks(t *testing.T) { "create_with_null_sensitive_value": { input: structured.Change{ Before: nil, - After: map[string]interface{}{ + After: map[string]any{ "normal_attribute": "some value", }, - BeforeSensitive: map[string]interface{}{ + BeforeSensitive: map[string]any{ "sensitive_attribute": true, }, AfterSensitive: false, @@ -139,7 +139,7 @@ func TestValue_ObjectAttributes(t *testing.T) { "create": { input: structured.Change{ Before: nil, - After: map[string]interface{}{ + After: map[string]any{ "attribute_one": "new", }, }, @@ -154,7 +154,7 @@ func TestValue_ObjectAttributes(t *testing.T) { }, "delete": { input: structured.Change{ - Before: map[string]interface{}{ + Before: map[string]any{ "attribute_one": "old", }, After: nil, @@ -171,7 +171,7 @@ func TestValue_ObjectAttributes(t *testing.T) { "create_sensitive": { input: structured.Change{ Before: nil, - After: map[string]interface{}{ + After: map[string]any{ "attribute_one": "new", }, AfterSensitive: true, @@ -196,7 +196,7 @@ func TestValue_ObjectAttributes(t *testing.T) { }, "delete_sensitive": { input: structured.Change{ - Before: map[string]interface{}{ + Before: map[string]any{ "attribute_one": "old", }, BeforeSensitive: true, @@ -225,7 +225,7 @@ func TestValue_ObjectAttributes(t *testing.T) { }, "update_unknown": { input: structured.Change{ - Before: map[string]interface{}{ + Before: map[string]any{ "attribute_one": "old", }, After: nil, @@ -255,8 +255,8 @@ func TestValue_ObjectAttributes(t *testing.T) { }, "create_attribute": { input: structured.Change{ - Before: map[string]interface{}{}, - After: map[string]interface{}{ + Before: map[string]any{}, + After: map[string]any{ "attribute_one": "new", }, }, @@ -285,10 +285,10 @@ func TestValue_ObjectAttributes(t *testing.T) { }, "create_attribute_from_explicit_null": { input: structured.Change{ - Before: map[string]interface{}{ + Before: map[string]any{ "attribute_one": nil, }, - After: map[string]interface{}{ + After: map[string]any{ "attribute_one": "new", }, }, @@ -317,10 +317,10 @@ func TestValue_ObjectAttributes(t *testing.T) { }, "delete_attribute": { input: structured.Change{ - Before: map[string]interface{}{ + Before: map[string]any{ "attribute_one": "old", }, - After: map[string]interface{}{}, + After: map[string]any{}, }, attributes: map[string]cty.Type{ "attribute_one": cty.String, @@ -347,10 +347,10 @@ func TestValue_ObjectAttributes(t *testing.T) { }, "delete_attribute_to_explicit_null": { input: structured.Change{ - Before: map[string]interface{}{ + Before: map[string]any{ "attribute_one": "old", }, - After: map[string]interface{}{ + After: map[string]any{ "attribute_one": nil, }, }, @@ -379,10 +379,10 @@ func TestValue_ObjectAttributes(t *testing.T) { }, "update_attribute": { input: structured.Change{ - Before: map[string]interface{}{ + Before: map[string]any{ "attribute_one": "old", }, - After: map[string]interface{}{ + After: map[string]any{ "attribute_one": "new", }, }, @@ -413,11 +413,11 @@ func TestValue_ObjectAttributes(t *testing.T) { }, "create_sensitive_attribute": { input: structured.Change{ - Before: map[string]interface{}{}, - After: map[string]interface{}{ + Before: map[string]any{}, + After: map[string]any{ "attribute_one": "new", }, - AfterSensitive: map[string]interface{}{ + AfterSensitive: map[string]any{ "attribute_one": true, }, }, @@ -446,13 +446,13 @@ func TestValue_ObjectAttributes(t *testing.T) { }, "delete_sensitive_attribute": { input: structured.Change{ - Before: map[string]interface{}{ + Before: map[string]any{ "attribute_one": "old", }, - BeforeSensitive: map[string]interface{}{ + BeforeSensitive: map[string]any{ "attribute_one": true, }, - After: map[string]interface{}{}, + After: map[string]any{}, }, attributes: map[string]cty.Type{ "attribute_one": cty.String, @@ -479,16 +479,16 @@ func TestValue_ObjectAttributes(t *testing.T) { }, "update_sensitive_attribute": { input: structured.Change{ - Before: map[string]interface{}{ + Before: map[string]any{ "attribute_one": "old", }, - BeforeSensitive: map[string]interface{}{ + BeforeSensitive: map[string]any{ "attribute_one": true, }, - After: map[string]interface{}{ + After: map[string]any{ "attribute_one": "new", }, - AfterSensitive: map[string]interface{}{ + AfterSensitive: map[string]any{ "attribute_one": true, }, }, @@ -519,9 +519,9 @@ func TestValue_ObjectAttributes(t *testing.T) { }, "create_computed_attribute": { input: structured.Change{ - Before: map[string]interface{}{}, - After: map[string]interface{}{}, - Unknown: map[string]interface{}{ + Before: map[string]any{}, + After: map[string]any{}, + Unknown: map[string]any{ "attribute_one": true, }, }, @@ -536,11 +536,11 @@ func TestValue_ObjectAttributes(t *testing.T) { }, "update_computed_attribute": { input: structured.Change{ - Before: map[string]interface{}{ + Before: map[string]any{ "attribute_one": "old", }, - After: map[string]interface{}{}, - Unknown: map[string]interface{}{ + After: map[string]any{}, + Unknown: map[string]any{ "attribute_one": true, }, }, @@ -574,8 +574,8 @@ func TestValue_ObjectAttributes(t *testing.T) { }, "ignores_unset_fields": { input: structured.Change{ - Before: map[string]interface{}{}, - After: map[string]interface{}{}, + Before: map[string]any{}, + After: map[string]any{}, }, attributes: map[string]cty.Type{ "attribute_one": cty.String, @@ -586,14 +586,14 @@ func TestValue_ObjectAttributes(t *testing.T) { }, "update_replace_self": { input: structured.Change{ - Before: map[string]interface{}{ + Before: map[string]any{ "attribute_one": "old", }, - After: map[string]interface{}{ + After: map[string]any{ "attribute_one": "new", }, ReplacePaths: &attribute_path.PathMatcher{ - Paths: [][]interface{}{ + Paths: [][]any{ {}, }, }, @@ -625,14 +625,14 @@ func TestValue_ObjectAttributes(t *testing.T) { }, "update_replace_attribute": { input: structured.Change{ - Before: map[string]interface{}{ + Before: map[string]any{ "attribute_one": "old", }, - After: map[string]interface{}{ + After: map[string]any{ "attribute_one": "new", }, ReplacePaths: &attribute_path.PathMatcher{ - Paths: [][]interface{}{ + Paths: [][]any{ {"attribute_one"}, }, }, @@ -664,16 +664,16 @@ func TestValue_ObjectAttributes(t *testing.T) { }, "update_includes_relevant_attributes": { input: structured.Change{ - Before: map[string]interface{}{ + Before: map[string]any{ "attribute_one": "old_one", "attribute_two": "old_two", }, - After: map[string]interface{}{ + After: map[string]any{ "attribute_one": "new_one", "attribute_two": "new_two", }, RelevantAttributes: &attribute_path.PathMatcher{ - Paths: [][]interface{}{ + Paths: [][]any{ {"attribute_one"}, }, }, @@ -1032,15 +1032,15 @@ func TestValue_BlockAttributesAndNestedBlocks(t *testing.T) { // different block types. tcs := map[string]struct { - before interface{} - after interface{} + before any + after any block *jsonprovider.Block validate renderers.ValidateDiffFunction validateSet []renderers.ValidateDiffFunction }{ "create_attribute": { - before: map[string]interface{}{}, - after: map[string]interface{}{ + before: map[string]any{}, + after: map[string]any{ "attribute_one": "new", }, block: &jsonprovider.Block{ @@ -1061,10 +1061,10 @@ func TestValue_BlockAttributesAndNestedBlocks(t *testing.T) { }, }, "update_attribute": { - before: map[string]interface{}{ + before: map[string]any{ "attribute_one": "old", }, - after: map[string]interface{}{ + after: map[string]any{ "attribute_one": "new", }, block: &jsonprovider.Block{ @@ -1087,10 +1087,10 @@ func TestValue_BlockAttributesAndNestedBlocks(t *testing.T) { }, }, "delete_attribute": { - before: map[string]interface{}{ + before: map[string]any{ "attribute_one": "old", }, - after: map[string]interface{}{}, + after: map[string]any{}, block: &jsonprovider.Block{ Attributes: map[string]*jsonprovider.Attribute{ "attribute_one": { @@ -1109,9 +1109,9 @@ func TestValue_BlockAttributesAndNestedBlocks(t *testing.T) { }, }, "create_block": { - before: map[string]interface{}{}, - after: map[string]interface{}{ - "block_one": map[string]interface{}{ + before: map[string]any{}, + after: map[string]any{ + "block_one": map[string]any{ "attribute_one": "new", }, }, @@ -1144,13 +1144,13 @@ func TestValue_BlockAttributesAndNestedBlocks(t *testing.T) { }, }, "update_block": { - before: map[string]interface{}{ - "block_one": map[string]interface{}{ + before: map[string]any{ + "block_one": map[string]any{ "attribute_one": "old", }, }, - after: map[string]interface{}{ - "block_one": map[string]interface{}{ + after: map[string]any{ + "block_one": map[string]any{ "attribute_one": "new", }, }, @@ -1187,12 +1187,12 @@ func TestValue_BlockAttributesAndNestedBlocks(t *testing.T) { }, }, "delete_block": { - before: map[string]interface{}{ - "block_one": map[string]interface{}{ + before: map[string]any{ + "block_one": map[string]any{ "attribute_one": "old", }, }, - after: map[string]interface{}{}, + after: map[string]any{}, block: &jsonprovider.Block{ BlockTypes: map[string]*jsonprovider.BlockType{ "block_one": { @@ -1228,10 +1228,10 @@ func TestValue_BlockAttributesAndNestedBlocks(t *testing.T) { t.Run(name, func(t *testing.T) { t.Run("single", func(t *testing.T) { input := structured.Change{ - Before: map[string]interface{}{ + Before: map[string]any{ "block_type": tc.before, }, - After: map[string]interface{}{ + After: map[string]any{ "block_type": tc.after, }, ReplacePaths: &attribute_path.PathMatcher{}, @@ -1254,13 +1254,13 @@ func TestValue_BlockAttributesAndNestedBlocks(t *testing.T) { }) t.Run("map", func(t *testing.T) { input := structured.Change{ - Before: map[string]interface{}{ - "block_type": map[string]interface{}{ + Before: map[string]any{ + "block_type": map[string]any{ "one": tc.before, }, }, - After: map[string]interface{}{ - "block_type": map[string]interface{}{ + After: map[string]any{ + "block_type": map[string]any{ "one": tc.after, }, }, @@ -1286,13 +1286,13 @@ func TestValue_BlockAttributesAndNestedBlocks(t *testing.T) { }) t.Run("list", func(t *testing.T) { input := structured.Change{ - Before: map[string]interface{}{ - "block_type": []interface{}{ + Before: map[string]any{ + "block_type": []any{ tc.before, }, }, - After: map[string]interface{}{ - "block_type": []interface{}{ + After: map[string]any{ + "block_type": []any{ tc.after, }, }, @@ -1318,13 +1318,13 @@ func TestValue_BlockAttributesAndNestedBlocks(t *testing.T) { }) t.Run("set", func(t *testing.T) { input := structured.Change{ - Before: map[string]interface{}{ - "block_type": []interface{}{ + Before: map[string]any{ + "block_type": []any{ tc.before, }, }, - After: map[string]interface{}{ - "block_type": []interface{}{ + After: map[string]any{ + "block_type": []any{ tc.after, }, }, @@ -1370,7 +1370,7 @@ func TestValue_Outputs(t *testing.T) { "object_create": { input: structured.Change{ Before: nil, - After: map[string]interface{}{ + After: map[string]any{ "element_one": "new_one", "element_two": "new_two", }, @@ -1383,7 +1383,7 @@ func TestValue_Outputs(t *testing.T) { "list_create": { input: structured.Change{ Before: nil, - After: []interface{}{ + After: []any{ "new_one", "new_two", }, @@ -1402,11 +1402,11 @@ func TestValue_Outputs(t *testing.T) { }, "object_update": { input: structured.Change{ - Before: map[string]interface{}{ + Before: map[string]any{ "element_one": "old_one", "element_two": "old_two", }, - After: map[string]interface{}{ + After: map[string]any{ "element_one": "new_one", "element_two": "new_two", }, @@ -1418,11 +1418,11 @@ func TestValue_Outputs(t *testing.T) { }, "list_update": { input: structured.Change{ - Before: []interface{}{ + Before: []any{ "old_one", "old_two", }, - After: []interface{}{ + After: []any{ "new_one", "new_two", }, @@ -1443,7 +1443,7 @@ func TestValue_Outputs(t *testing.T) { }, "object_delete": { input: structured.Change{ - Before: map[string]interface{}{ + Before: map[string]any{ "element_one": "old_one", "element_two": "old_two", }, @@ -1456,7 +1456,7 @@ func TestValue_Outputs(t *testing.T) { }, "list_delete": { input: structured.Change{ - Before: []interface{}{ + Before: []any{ "old_one", "old_two", }, @@ -1470,7 +1470,7 @@ func TestValue_Outputs(t *testing.T) { "primitive_to_list": { input: structured.Change{ Before: "old", - After: []interface{}{ + After: []any{ "new_one", "new_two", }, @@ -1485,7 +1485,7 @@ func TestValue_Outputs(t *testing.T) { "primitive_to_object": { input: structured.Change{ Before: "old", - After: map[string]interface{}{ + After: map[string]any{ "element_one": "new_one", "element_two": "new_two", }, @@ -1499,7 +1499,7 @@ func TestValue_Outputs(t *testing.T) { }, "list_to_primitive": { input: structured.Change{ - Before: []interface{}{ + Before: []any{ "old_one", "old_two", }, @@ -1515,11 +1515,11 @@ func TestValue_Outputs(t *testing.T) { }, "list_to_object": { input: structured.Change{ - Before: []interface{}{ + Before: []any{ "old_one", "old_two", }, - After: map[string]interface{}{ + After: map[string]any{ "element_one": "new_one", "element_two": "new_two", }, @@ -1536,7 +1536,7 @@ func TestValue_Outputs(t *testing.T) { }, "object_to_primitive": { input: structured.Change{ - Before: map[string]interface{}{ + Before: map[string]any{ "element_one": "old_one", "element_two": "old_two", }, @@ -1552,11 +1552,11 @@ func TestValue_Outputs(t *testing.T) { }, "object_to_list": { input: structured.Change{ - Before: map[string]interface{}{ + Before: map[string]any{ "element_one": "old_one", "element_two": "old_two", }, - After: []interface{}{ + After: []any{ "new_one", "new_two", }, @@ -1711,7 +1711,7 @@ func TestValue_PrimitiveAttributes(t *testing.T) { Before: "old", After: "new", ReplacePaths: &attribute_path.PathMatcher{ - Paths: [][]interface{}{ + Paths: [][]any{ {}, // An empty path suggests replace should be true. }, }, @@ -1845,7 +1845,7 @@ func TestValue_CollectionAttributes(t *testing.T) { "map_create_empty": { input: structured.Change{ Before: nil, - After: map[string]interface{}{}, + After: map[string]any{}, }, attribute: &jsonprovider.Attribute{ AttributeType: unmarshalType(t, cty.Map(cty.String)), @@ -1855,7 +1855,7 @@ func TestValue_CollectionAttributes(t *testing.T) { "map_create_populated": { input: structured.Change{ Before: nil, - After: map[string]interface{}{ + After: map[string]any{ "element_one": "one", "element_two": "two", }, @@ -1870,7 +1870,7 @@ func TestValue_CollectionAttributes(t *testing.T) { }, "map_delete_empty": { input: structured.Change{ - Before: map[string]interface{}{}, + Before: map[string]any{}, After: nil, }, attribute: &jsonprovider.Attribute{ @@ -1880,7 +1880,7 @@ func TestValue_CollectionAttributes(t *testing.T) { }, "map_delete_populated": { input: structured.Change{ - Before: map[string]interface{}{ + Before: map[string]any{ "element_one": "one", "element_two": "two", }, @@ -1897,7 +1897,7 @@ func TestValue_CollectionAttributes(t *testing.T) { "map_create_sensitive": { input: structured.Change{ Before: nil, - After: map[string]interface{}{}, + After: map[string]any{}, AfterSensitive: true, }, attribute: &jsonprovider.Attribute{ @@ -1907,11 +1907,11 @@ func TestValue_CollectionAttributes(t *testing.T) { }, "map_update_sensitive": { input: structured.Change{ - Before: map[string]interface{}{ + Before: map[string]any{ "element": "one", }, BeforeSensitive: true, - After: map[string]interface{}{}, + After: map[string]any{}, AfterSensitive: true, }, attribute: &jsonprovider.Attribute{ @@ -1923,7 +1923,7 @@ func TestValue_CollectionAttributes(t *testing.T) { }, "map_delete_sensitive": { input: structured.Change{ - Before: map[string]interface{}{}, + Before: map[string]any{}, BeforeSensitive: true, After: nil, }, @@ -1935,7 +1935,7 @@ func TestValue_CollectionAttributes(t *testing.T) { "map_create_unknown": { input: structured.Change{ Before: nil, - After: map[string]interface{}{}, + After: map[string]any{}, Unknown: true, }, attribute: &jsonprovider.Attribute{ @@ -1945,8 +1945,8 @@ func TestValue_CollectionAttributes(t *testing.T) { }, "map_update_unknown": { input: structured.Change{ - Before: map[string]interface{}{}, - After: map[string]interface{}{ + Before: map[string]any{}, + After: map[string]any{ "element": "one", }, Unknown: true, @@ -1959,7 +1959,7 @@ func TestValue_CollectionAttributes(t *testing.T) { "list_create_empty": { input: structured.Change{ Before: nil, - After: []interface{}{}, + After: []any{}, }, attribute: &jsonprovider.Attribute{ AttributeType: unmarshalType(t, cty.List(cty.String)), @@ -1969,7 +1969,7 @@ func TestValue_CollectionAttributes(t *testing.T) { "list_create_populated": { input: structured.Change{ Before: nil, - After: []interface{}{"one", "two"}, + After: []any{"one", "two"}, }, attribute: &jsonprovider.Attribute{ AttributeType: unmarshalType(t, cty.List(cty.String)), @@ -1981,7 +1981,7 @@ func TestValue_CollectionAttributes(t *testing.T) { }, "list_delete_empty": { input: structured.Change{ - Before: []interface{}{}, + Before: []any{}, After: nil, }, attribute: &jsonprovider.Attribute{ @@ -1991,7 +1991,7 @@ func TestValue_CollectionAttributes(t *testing.T) { }, "list_delete_populated": { input: structured.Change{ - Before: []interface{}{"one", "two"}, + Before: []any{"one", "two"}, After: nil, }, attribute: &jsonprovider.Attribute{ @@ -2005,7 +2005,7 @@ func TestValue_CollectionAttributes(t *testing.T) { "list_create_sensitive": { input: structured.Change{ Before: nil, - After: []interface{}{}, + After: []any{}, AfterSensitive: true, }, attribute: &jsonprovider.Attribute{ @@ -2015,9 +2015,9 @@ func TestValue_CollectionAttributes(t *testing.T) { }, "list_update_sensitive": { input: structured.Change{ - Before: []interface{}{"one"}, + Before: []any{"one"}, BeforeSensitive: true, - After: []interface{}{}, + After: []any{}, AfterSensitive: true, }, attribute: &jsonprovider.Attribute{ @@ -2029,7 +2029,7 @@ func TestValue_CollectionAttributes(t *testing.T) { }, "list_delete_sensitive": { input: structured.Change{ - Before: []interface{}{}, + Before: []any{}, BeforeSensitive: true, After: nil, }, @@ -2041,7 +2041,7 @@ func TestValue_CollectionAttributes(t *testing.T) { "list_create_unknown": { input: structured.Change{ Before: nil, - After: []interface{}{}, + After: []any{}, Unknown: true, }, attribute: &jsonprovider.Attribute{ @@ -2051,8 +2051,8 @@ func TestValue_CollectionAttributes(t *testing.T) { }, "list_update_unknown": { input: structured.Change{ - Before: []interface{}{}, - After: []interface{}{"one"}, + Before: []any{}, + After: []any{"one"}, Unknown: true, }, attribute: &jsonprovider.Attribute{ @@ -2063,7 +2063,7 @@ func TestValue_CollectionAttributes(t *testing.T) { "set_create_empty": { input: structured.Change{ Before: nil, - After: []interface{}{}, + After: []any{}, }, attribute: &jsonprovider.Attribute{ AttributeType: unmarshalType(t, cty.Set(cty.String)), @@ -2073,7 +2073,7 @@ func TestValue_CollectionAttributes(t *testing.T) { "set_create_populated": { input: structured.Change{ Before: nil, - After: []interface{}{"one", "two"}, + After: []any{"one", "two"}, }, attribute: &jsonprovider.Attribute{ AttributeType: unmarshalType(t, cty.Set(cty.String)), @@ -2085,7 +2085,7 @@ func TestValue_CollectionAttributes(t *testing.T) { }, "set_delete_empty": { input: structured.Change{ - Before: []interface{}{}, + Before: []any{}, After: nil, }, attribute: &jsonprovider.Attribute{ @@ -2095,7 +2095,7 @@ func TestValue_CollectionAttributes(t *testing.T) { }, "set_delete_populated": { input: structured.Change{ - Before: []interface{}{"one", "two"}, + Before: []any{"one", "two"}, After: nil, }, attribute: &jsonprovider.Attribute{ @@ -2109,7 +2109,7 @@ func TestValue_CollectionAttributes(t *testing.T) { "set_create_sensitive": { input: structured.Change{ Before: nil, - After: []interface{}{}, + After: []any{}, AfterSensitive: true, }, attribute: &jsonprovider.Attribute{ @@ -2119,9 +2119,9 @@ func TestValue_CollectionAttributes(t *testing.T) { }, "set_update_sensitive": { input: structured.Change{ - Before: []interface{}{"one"}, + Before: []any{"one"}, BeforeSensitive: true, - After: []interface{}{}, + After: []any{}, AfterSensitive: true, }, attribute: &jsonprovider.Attribute{ @@ -2133,7 +2133,7 @@ func TestValue_CollectionAttributes(t *testing.T) { }, "set_delete_sensitive": { input: structured.Change{ - Before: []interface{}{}, + Before: []any{}, BeforeSensitive: true, After: nil, }, @@ -2145,7 +2145,7 @@ func TestValue_CollectionAttributes(t *testing.T) { "set_create_unknown": { input: structured.Change{ Before: nil, - After: []interface{}{}, + After: []any{}, Unknown: true, }, attribute: &jsonprovider.Attribute{ @@ -2155,8 +2155,8 @@ func TestValue_CollectionAttributes(t *testing.T) { }, "set_update_unknown": { input: structured.Change{ - Before: []interface{}{}, - After: []interface{}{"one"}, + Before: []any{}, + After: []any{"one"}, Unknown: true, }, attribute: &jsonprovider.Attribute{ @@ -2166,12 +2166,12 @@ func TestValue_CollectionAttributes(t *testing.T) { }, "tuple_primitive": { input: structured.Change{ - Before: []interface{}{ + Before: []any{ "one", 2.0, "three", }, - After: []interface{}{ + After: []any{ "one", 4.0, "three", @@ -2212,16 +2212,16 @@ func TestRelevantAttributes(t *testing.T) { }{ "simple_attributes": { input: structured.Change{ - Before: map[string]interface{}{ + Before: map[string]any{ "id": "old_id", "ignore": "doesn't matter", }, - After: map[string]interface{}{ + After: map[string]any{ "id": "new_id", "ignore": "doesn't matter but modified", }, RelevantAttributes: &attribute_path.PathMatcher{ - Paths: [][]interface{}{ + Paths: [][]any{ { "id", }, @@ -2245,28 +2245,28 @@ func TestRelevantAttributes(t *testing.T) { }, "nested_attributes": { input: structured.Change{ - Before: map[string]interface{}{ - "list_block": []interface{}{ - map[string]interface{}{ + Before: map[string]any{ + "list_block": []any{ + map[string]any{ "id": "old_one", }, - map[string]interface{}{ + map[string]any{ "id": "ignored", }, }, }, - After: map[string]interface{}{ - "list_block": []interface{}{ - map[string]interface{}{ + After: map[string]any{ + "list_block": []any{ + map[string]any{ "id": "new_one", }, - map[string]interface{}{ + map[string]any{ "id": "ignored_but_changed", }, }, }, RelevantAttributes: &attribute_path.PathMatcher{ - Paths: [][]interface{}{ + Paths: [][]any{ { "list_block", float64(0), @@ -2302,19 +2302,19 @@ func TestRelevantAttributes(t *testing.T) { }, "nested_attributes_in_object": { input: structured.Change{ - Before: map[string]interface{}{ - "object": map[string]interface{}{ + Before: map[string]any{ + "object": map[string]any{ "id": "old_id", }, }, - After: map[string]interface{}{ - "object": map[string]interface{}{ + After: map[string]any{ + "object": map[string]any{ "id": "new_id", }, }, RelevantAttributes: &attribute_path.PathMatcher{ Propagate: true, - Paths: [][]interface{}{ + Paths: [][]any{ { "object", // Even though we just specify object, it should now include every below object as well. }, @@ -2338,18 +2338,18 @@ func TestRelevantAttributes(t *testing.T) { }, "elements_in_list": { input: structured.Change{ - Before: map[string]interface{}{ - "list": []interface{}{ + Before: map[string]any{ + "list": []any{ 0, 1, 2, 3, 4, }, }, - After: map[string]interface{}{ - "list": []interface{}{ + After: map[string]any{ + "list": []any{ 0, 5, 6, 7, 4, }, }, RelevantAttributes: &attribute_path.PathMatcher{ - Paths: [][]interface{}{ // The list is actually just going to ignore this. + Paths: [][]any{ { "list", float64(0), @@ -2389,22 +2389,22 @@ func TestRelevantAttributes(t *testing.T) { }, "elements_in_map": { input: structured.Change{ - Before: map[string]interface{}{ - "map": map[string]interface{}{ + Before: map[string]any{ + "map": map[string]any{ "key_one": "value_one", "key_two": "value_two", "key_three": "value_three", }, }, - After: map[string]interface{}{ - "map": map[string]interface{}{ + After: map[string]any{ + "map": map[string]any{ "key_one": "value_three", "key_two": "value_seven", "key_four": "value_four", }, }, RelevantAttributes: &attribute_path.PathMatcher{ - Paths: [][]interface{}{ + Paths: [][]any{ { "map", "key_one", @@ -2438,19 +2438,19 @@ func TestRelevantAttributes(t *testing.T) { }, "elements_in_set": { input: structured.Change{ - Before: map[string]interface{}{ - "set": []interface{}{ + Before: map[string]any{ + "set": []any{ 0, 1, 2, 3, 4, }, }, - After: map[string]interface{}{ - "set": []interface{}{ + After: map[string]any{ + "set": []any{ 0, 2, 4, 5, 6, }, }, RelevantAttributes: &attribute_path.PathMatcher{ Propagate: true, - Paths: [][]interface{}{ + Paths: [][]any{ { "set", }, @@ -2478,37 +2478,37 @@ func TestRelevantAttributes(t *testing.T) { }, "dynamic_types": { input: structured.Change{ - Before: map[string]interface{}{ - "dynamic_nested_type": map[string]interface{}{ + Before: map[string]any{ + "dynamic_nested_type": map[string]any{ "nested_id": "nomatch", - "nested_object": map[string]interface{}{ + "nested_object": map[string]any{ "nested_nested_id": "matched", }, }, - "dynamic_nested_type_match": map[string]interface{}{ + "dynamic_nested_type_match": map[string]any{ "nested_id": "allmatch", - "nested_object": map[string]interface{}{ + "nested_object": map[string]any{ "nested_nested_id": "allmatch", }, }, }, - After: map[string]interface{}{ - "dynamic_nested_type": map[string]interface{}{ + After: map[string]any{ + "dynamic_nested_type": map[string]any{ "nested_id": "nomatch_changed", - "nested_object": map[string]interface{}{ + "nested_object": map[string]any{ "nested_nested_id": "matched", }, }, - "dynamic_nested_type_match": map[string]interface{}{ + "dynamic_nested_type_match": map[string]any{ "nested_id": "allmatch", - "nested_object": map[string]interface{}{ + "nested_object": map[string]any{ "nested_nested_id": "allmatch", }, }, }, RelevantAttributes: &attribute_path.PathMatcher{ Propagate: true, - Paths: [][]interface{}{ + Paths: [][]any{ { "dynamic_nested_type", "nested_object", @@ -2564,12 +2564,12 @@ func TestDynamicPseudoType(t *testing.T) { "after_sensitive_in_dynamic_type": { input: structured.Change{ Before: nil, - After: map[string]interface{}{ + After: map[string]any{ "key": "value", }, Unknown: false, BeforeSensitive: false, - AfterSensitive: map[string]interface{}{ + AfterSensitive: map[string]any{ "key": true, }, ReplacePaths: attribute_path.Empty(false), @@ -2581,12 +2581,12 @@ func TestDynamicPseudoType(t *testing.T) { }, "before_sensitive_in_dynamic_type": { input: structured.Change{ - Before: map[string]interface{}{ + Before: map[string]any{ "key": "value", }, After: nil, Unknown: false, - BeforeSensitive: map[string]interface{}{ + BeforeSensitive: map[string]any{ "key": true, }, AfterSensitive: false, @@ -2599,17 +2599,17 @@ func TestDynamicPseudoType(t *testing.T) { }, "sensitive_in_dynamic_type": { input: structured.Change{ - Before: map[string]interface{}{ + Before: map[string]any{ "key": "before", }, - After: map[string]interface{}{ + After: map[string]any{ "key": "after", }, Unknown: false, - BeforeSensitive: map[string]interface{}{ + BeforeSensitive: map[string]any{ "key": true, }, - AfterSensitive: map[string]interface{}{ + AfterSensitive: map[string]any{ "key": true, }, ReplacePaths: attribute_path.Empty(false), @@ -2622,8 +2622,8 @@ func TestDynamicPseudoType(t *testing.T) { "create_unknown_in_dynamic_type": { input: structured.Change{ Before: nil, - After: map[string]interface{}{}, - Unknown: map[string]interface{}{ + After: map[string]any{}, + Unknown: map[string]any{ "key": true, }, BeforeSensitive: false, @@ -2637,11 +2637,11 @@ func TestDynamicPseudoType(t *testing.T) { }, "update_unknown_in_dynamic_type": { input: structured.Change{ - Before: map[string]interface{}{ + Before: map[string]any{ "key": "before", }, - After: map[string]interface{}{}, - Unknown: map[string]interface{}{ + After: map[string]any{}, + Unknown: map[string]any{ "key": true, }, BeforeSensitive: false, @@ -2673,18 +2673,18 @@ func TestSpecificCases(t *testing.T) { "issues/33016/unknown": { input: structured.Change{ Before: nil, - After: map[string]interface{}{ - "triggers": map[string]interface{}{}, + After: map[string]any{ + "triggers": map[string]any{}, }, - Unknown: map[string]interface{}{ + Unknown: map[string]any{ "id": true, - "triggers": map[string]interface{}{ + "triggers": map[string]any{ "rotation": true, }, }, BeforeSensitive: false, - AfterSensitive: map[string]interface{}{ - "triggers": map[string]interface{}{}, + AfterSensitive: map[string]any{ + "triggers": map[string]any{}, }, ReplacePaths: attribute_path.Empty(false), RelevantAttributes: attribute_path.AlwaysMatcher(), @@ -2709,18 +2709,18 @@ func TestSpecificCases(t *testing.T) { "issues/33016/null": { input: structured.Change{ Before: nil, - After: map[string]interface{}{ - "triggers": map[string]interface{}{ + After: map[string]any{ + "triggers": map[string]any{ "rotation": nil, }, }, - Unknown: map[string]interface{}{ + Unknown: map[string]any{ "id": true, - "triggers": map[string]interface{}{}, + "triggers": map[string]any{}, }, BeforeSensitive: false, - AfterSensitive: map[string]interface{}{ - "triggers": map[string]interface{}{}, + AfterSensitive: map[string]any{ + "triggers": map[string]any{}, }, ReplacePaths: attribute_path.Empty(false), RelevantAttributes: attribute_path.AlwaysMatcher(), @@ -2756,16 +2756,16 @@ func TestSpecificCases(t *testing.T) { "issues/33472/expected": { input: structured.Change{ - Before: map[string]interface{}{ - "list": []interface{}{ - map[string]interface{}{ + Before: map[string]any{ + "list": []any{ + map[string]any{ "number": -1, }, }, }, - After: map[string]interface{}{ - "list": []interface{}{ - map[string]interface{}{ + After: map[string]any{ + "list": []any{ + map[string]any{ "number": 2, }, }, @@ -2776,7 +2776,7 @@ func TestSpecificCases(t *testing.T) { ReplacePaths: attribute_path.Empty(false), RelevantAttributes: &attribute_path.PathMatcher{ Propagate: true, - Paths: [][]interface{}{ + Paths: [][]any{ { "list", 0.0, // This is normal and expected so easy case. @@ -2805,16 +2805,16 @@ func TestSpecificCases(t *testing.T) { "issues/33472/coerce": { input: structured.Change{ - Before: map[string]interface{}{ - "list": []interface{}{ - map[string]interface{}{ + Before: map[string]any{ + "list": []any{ + map[string]any{ "number": -1, }, }, }, - After: map[string]interface{}{ - "list": []interface{}{ - map[string]interface{}{ + After: map[string]any{ + "list": []any{ + map[string]any{ "number": 2, }, }, @@ -2825,7 +2825,7 @@ func TestSpecificCases(t *testing.T) { ReplacePaths: attribute_path.Empty(false), RelevantAttributes: &attribute_path.PathMatcher{ Propagate: true, - Paths: [][]interface{}{ + Paths: [][]any{ { "list", "0", // Difficult but allowed, we need to handle this. @@ -2873,16 +2873,16 @@ func unmarshalType(t *testing.T, ctyType cty.Type) json.RawMessage { // wrapChangeInSlice does the same as wrapChangeInMap, except it wraps it into a // slice internally. func wrapChangeInSlice(input structured.Change) structured.Change { - return wrapChange(input, float64(0), func(value interface{}, unknown interface{}, explicit bool) interface{} { + return wrapChange(input, float64(0), func(value any, unknown any, explicit bool) any { switch value.(type) { case nil: if set, ok := unknown.(bool); (set && ok) || explicit { - return []interface{}{nil} + return []any{nil} } - return []interface{}{} + return []any{} default: - return []interface{}{value} + return []any{value} } }) } @@ -2891,28 +2891,28 @@ func wrapChangeInSlice(input structured.Change) structured.Change { // structured.Change that represents a map with a single element. That single // element is the input value. func wrapChangeInMap(input structured.Change) structured.Change { - return wrapChange(input, "element", func(value interface{}, unknown interface{}, explicit bool) interface{} { + return wrapChange(input, "element", func(value any, unknown any, explicit bool) any { switch value.(type) { case nil: if set, ok := unknown.(bool); (set && ok) || explicit { - return map[string]interface{}{ + return map[string]any{ "element": nil, } } - return map[string]interface{}{} + return map[string]any{} default: - return map[string]interface{}{ + return map[string]any{ "element": value, } } }) } -func wrapChange(input structured.Change, step interface{}, wrap func(interface{}, interface{}, bool) interface{}) structured.Change { +func wrapChange(input structured.Change, step any, wrap func(any, any, bool) any) structured.Change { replacePaths := &attribute_path.PathMatcher{} for _, path := range input.ReplacePaths.(*attribute_path.PathMatcher).Paths { - var updated []interface{} + var updated []any updated = append(updated, step) updated = append(updated, path...) replacePaths.Paths = append(replacePaths.Paths, updated) @@ -2926,7 +2926,7 @@ func wrapChange(input structured.Change, step interface{}, wrap func(interface{} newRelevantAttributes := &attribute_path.PathMatcher{} for _, path := range concrete.Paths { - var updated []interface{} + var updated []any updated = append(updated, step) updated = append(updated, path...) newRelevantAttributes.Paths = append(newRelevantAttributes.Paths, updated) diff --git a/staging/terraform/command/jsonformat/differ/list.go b/staging/terraform/command/jsonformat/differ/list.go index 6c20b22..0486a2b 100644 --- a/staging/terraform/command/jsonformat/differ/list.go +++ b/staging/terraform/command/jsonformat/differ/list.go @@ -44,7 +44,7 @@ func computeAttributeDiffAsList(change structured.Change, elementType cty.Type) return ComputeDiffForType(value, elementType) } - isObjType := func(_ interface{}) bool { + isObjType := func(_ any) bool { return elementType.IsObjectType() } diff --git a/staging/terraform/command/jsonformat/differ/unknown.go b/staging/terraform/command/jsonformat/differ/unknown.go index f6180d2..8940121 100644 --- a/staging/terraform/command/jsonformat/differ/unknown.go +++ b/staging/terraform/command/jsonformat/differ/unknown.go @@ -25,7 +25,7 @@ func checkForUnknownNestedAttribute(change structured.Change, attribute *jsonpro // We want our child attributes to show up as computed instead of deleted. // Let's populate that here. - childUnknown := make(map[string]interface{}) + childUnknown := make(map[string]any) for key := range attribute.Attributes { childUnknown[key] = true } @@ -42,7 +42,7 @@ func checkForUnknownBlock(change structured.Change, block *jsonprovider.Block) ( // We want our child attributes to show up as computed instead of deleted. // Let's populate that here. - childUnknown := make(map[string]interface{}) + childUnknown := make(map[string]any) for key := range block.Attributes { childUnknown[key] = true } diff --git a/staging/terraform/command/jsonformat/jsondiff/diff.go b/staging/terraform/command/jsonformat/jsondiff/diff.go index adbc779..cec7253 100644 --- a/staging/terraform/command/jsonformat/jsondiff/diff.go +++ b/staging/terraform/command/jsonformat/jsondiff/diff.go @@ -14,7 +14,7 @@ import ( "github.com/hashicorp/terraform/plans" ) -type TransformPrimitiveJson func(before, after interface{}, ctype cty.Type, action plans.Action) computed.Diff +type TransformPrimitiveJson func(before, after any, ctype cty.Type, action plans.Action) computed.Diff type TransformObjectJson func(map[string]computed.Diff, plans.Action) computed.Diff type TransformArrayJson func([]computed.Diff, plans.Action) computed.Diff type TransformUnknownJson func(computed.Diff, plans.Action) computed.Diff @@ -115,7 +115,7 @@ func (opts JsonOpts) processArray(change structured.ChangeSlice) computed.Diff { return opts.Transform(change.GetChild(beforeIx, afterIx)) } - isObjType := func(value interface{}) bool { + isObjType := func(value any) bool { return GetType(value) == Object } diff --git a/staging/terraform/command/jsonformat/jsondiff/types.go b/staging/terraform/command/jsonformat/jsondiff/types.go index eaa8c1b..aae12a4 100644 --- a/staging/terraform/command/jsonformat/jsondiff/types.go +++ b/staging/terraform/command/jsonformat/jsondiff/types.go @@ -16,9 +16,9 @@ const ( Null Type = "null" ) -func GetType(json interface{}) Type { +func GetType(json any) Type { switch json.(type) { - case []interface{}: + case []any: return Array case float64: return Number @@ -28,7 +28,7 @@ func GetType(json interface{}) Type { return Bool case nil: return Null - case map[string]interface{}: + case map[string]any: return Object default: panic(fmt.Sprintf("unrecognized json type %T", json)) diff --git a/staging/terraform/command/jsonformat/plan.go b/staging/terraform/command/jsonformat/plan.go index f0999c3..3ff19e0 100644 --- a/staging/terraform/command/jsonformat/plan.go +++ b/staging/terraform/command/jsonformat/plan.go @@ -435,7 +435,7 @@ func resourceChangeComment(resource jsonplan.ResourceChange, action plans.Action // which module instance keys are actually declared. buf.WriteString(fmt.Sprintf("\n # (because %s is not in configuration)", resource.ModuleAddress)) case jsonplan.ResourceInstanceDeleteBecauseWrongRepetition: - var index interface{} + var index any if resource.Index != nil { if err := json.Unmarshal(resource.Index, &index); err != nil { panic(err) diff --git a/staging/terraform/command/jsonformat/plan_test.go b/staging/terraform/command/jsonformat/plan_test.go index ca0dd71..1a4dcf9 100644 --- a/staging/terraform/command/jsonformat/plan_test.go +++ b/staging/terraform/command/jsonformat/plan_test.go @@ -117,11 +117,11 @@ func TestRenderHuman_Imports(t *testing.T) { ProviderName: "test", Change: jsonplan.Change{ Actions: []string{"no-op"}, - Before: marshalJson(t, map[string]interface{}{ + Before: marshalJson(t, map[string]any{ "id": "1D5F5E9E-F2E5-401B-9ED5-692A215AC67E", "value": "Hello, World!", }), - After: marshalJson(t, map[string]interface{}{ + After: marshalJson(t, map[string]any{ "id": "1D5F5E9E-F2E5-401B-9ED5-692A215AC67E", "value": "Hello, World!", }), @@ -155,11 +155,11 @@ Plan: 1 to import, 0 to add, 0 to change, 0 to destroy. ProviderName: "test", Change: jsonplan.Change{ Actions: []string{"no-op"}, - Before: marshalJson(t, map[string]interface{}{ + Before: marshalJson(t, map[string]any{ "id": "1D5F5E9E-F2E5-401B-9ED5-692A215AC67E", "value": "Hello, World!", }), - After: marshalJson(t, map[string]interface{}{ + After: marshalJson(t, map[string]any{ "id": "1D5F5E9E-F2E5-401B-9ED5-692A215AC67E", "value": "Hello, World!", }), @@ -199,11 +199,11 @@ Plan: 1 to import, 0 to add, 0 to change, 0 to destroy. ProviderName: "test", Change: jsonplan.Change{ Actions: []string{"no-op"}, - Before: marshalJson(t, map[string]interface{}{ + Before: marshalJson(t, map[string]any{ "id": "1D5F5E9E-F2E5-401B-9ED5-692A215AC67E", "value": "Hello, World!", }), - After: marshalJson(t, map[string]interface{}{ + After: marshalJson(t, map[string]any{ "id": "1D5F5E9E-F2E5-401B-9ED5-692A215AC67E", "value": "Hello, World!", }), @@ -239,11 +239,11 @@ Plan: 1 to import, 0 to add, 0 to change, 0 to destroy. ProviderName: "test", Change: jsonplan.Change{ Actions: []string{"update"}, - Before: marshalJson(t, map[string]interface{}{ + Before: marshalJson(t, map[string]any{ "id": "1D5F5E9E-F2E5-401B-9ED5-692A215AC67E", "value": "Hello, World!", }), - After: marshalJson(t, map[string]interface{}{ + After: marshalJson(t, map[string]any{ "id": "1D5F5E9E-F2E5-401B-9ED5-692A215AC67E", "value": "Hello, Universe!", }), @@ -283,11 +283,11 @@ Plan: 1 to import, 0 to add, 1 to change, 0 to destroy. ProviderName: "test", Change: jsonplan.Change{ Actions: []string{"update"}, - Before: marshalJson(t, map[string]interface{}{ + Before: marshalJson(t, map[string]any{ "id": "1D5F5E9E-F2E5-401B-9ED5-692A215AC67E", "value": "Hello, World!", }), - After: marshalJson(t, map[string]interface{}{ + After: marshalJson(t, map[string]any{ "id": "1D5F5E9E-F2E5-401B-9ED5-692A215AC67E", "value": "Hello, Universe!", }), @@ -326,11 +326,11 @@ Plan: 1 to import, 0 to add, 1 to change, 0 to destroy. ProviderName: "test", Change: jsonplan.Change{ Actions: []string{"update"}, - Before: marshalJson(t, map[string]interface{}{ + Before: marshalJson(t, map[string]any{ "id": "1D5F5E9E-F2E5-401B-9ED5-692A215AC67E", "value": "Hello, World!", }), - After: marshalJson(t, map[string]interface{}{ + After: marshalJson(t, map[string]any{ "id": "1D5F5E9E-F2E5-401B-9ED5-692A215AC67E", "value": "Hello, Universe!", }), @@ -367,11 +367,11 @@ Plan: 1 to import, 0 to add, 1 to change, 0 to destroy. ProviderName: "test", Change: jsonplan.Change{ Actions: []string{"create", "delete"}, - Before: marshalJson(t, map[string]interface{}{ + Before: marshalJson(t, map[string]any{ "id": "1D5F5E9E-F2E5-401B-9ED5-692A215AC67E", "value": "Hello, World!", }), - After: marshalJson(t, map[string]interface{}{ + After: marshalJson(t, map[string]any{ "id": "9794FB1F-7260-442F-830C-F2D450E90CE3", "value": "Hello, World!", }), @@ -7305,7 +7305,7 @@ func testSchemaPlus(nesting configschema.NestingMode) *configschema.Block { } } -func marshalJson(t *testing.T, data interface{}) json.RawMessage { +func marshalJson(t *testing.T, data any) json.RawMessage { result, err := json.Marshal(data) if err != nil { t.Fatalf("failed to marshal json: %v", err) diff --git a/staging/terraform/command/jsonformat/renderer.go b/staging/terraform/command/jsonformat/renderer.go index 8748a82..658f2d8 100644 --- a/staging/terraform/command/jsonformat/renderer.go +++ b/staging/terraform/command/jsonformat/renderer.go @@ -25,11 +25,11 @@ import ( type JSONLogType string type JSONLog struct { - Message string `json:"@message"` - Type JSONLogType `json:"type"` - Diagnostic *viewsjson.Diagnostic `json:"diagnostic"` - Outputs viewsjson.Outputs `json:"outputs"` - Hook map[string]interface{} `json:"hook"` + Message string `json:"@message"` + Type JSONLogType `json:"type"` + Diagnostic *viewsjson.Diagnostic `json:"diagnostic"` + Outputs viewsjson.Outputs `json:"outputs"` + Hook map[string]any `json:"hook"` } const ( @@ -155,7 +155,7 @@ func (renderer Renderer) RenderLog(log *JSONLog) error { case LogProvisionProgress: provisioner := log.Hook["provisioner"].(string) output := log.Hook["output"].(string) - resource := log.Hook["resource"].(map[string]interface{}) + resource := log.Hook["resource"].(map[string]any) resourceAddr := resource["addr"].(string) msg := fmt.Sprintf(renderer.Colorize.Color("[bold]%s: (%s):[reset] %s"), diff --git a/staging/terraform/command/jsonformat/structured/attribute_path/matcher.go b/staging/terraform/command/jsonformat/structured/attribute_path/matcher.go index 409fc60..2bd9e0f 100644 --- a/staging/terraform/command/jsonformat/structured/attribute_path/matcher.go +++ b/staging/terraform/command/jsonformat/structured/attribute_path/matcher.go @@ -77,7 +77,7 @@ func Empty(propagate bool) *PathMatcher { // // The new PathMatcher is created fresh, and the existing one is unchanged. func Append(matcher *PathMatcher, message json.RawMessage) *PathMatcher { - var values [][]interface{} + var values [][]any if err := json.Unmarshal(message, &values); err != nil { panic("failed to unmarshal attribute paths: " + err.Error()) } @@ -93,7 +93,7 @@ func Append(matcher *PathMatcher, message json.RawMessage) *PathMatcher { // // The new PathMatcher is created fresh, and the existing one is unchanged. func AppendSingle(matcher *PathMatcher, message json.RawMessage) *PathMatcher { - var values []interface{} + var values []any if err := json.Unmarshal(message, &values); err != nil { panic("failed to unmarshal attribute paths: " + err.Error()) } @@ -112,7 +112,7 @@ type PathMatcher struct { // is no (easy) way to reproduce the original cty.Paths object. Instead, // we simply rely on the external callers to know the type information and // call the correct GetChild function. - Paths [][]interface{} + Paths [][]any // Propagate tells the matcher that it should propagate any matches it finds // onto the children of that match. diff --git a/staging/terraform/command/jsonformat/structured/attribute_path/matcher_test.go b/staging/terraform/command/jsonformat/structured/attribute_path/matcher_test.go index a893aae..7067b93 100644 --- a/staging/terraform/command/jsonformat/structured/attribute_path/matcher_test.go +++ b/staging/terraform/command/jsonformat/structured/attribute_path/matcher_test.go @@ -9,7 +9,7 @@ func TestPathMatcher_FollowsPath(t *testing.T) { var matcher Matcher matcher = &PathMatcher{ - Paths: [][]interface{}{ + Paths: [][]any{ { float64(0), "key", @@ -56,7 +56,7 @@ func TestPathMatcher_Propagates(t *testing.T) { var matcher Matcher matcher = &PathMatcher{ - Paths: [][]interface{}{ + Paths: [][]any{ { float64(0), "key", @@ -103,7 +103,7 @@ func TestPathMatcher_DoesNotPropagate(t *testing.T) { var matcher Matcher matcher = &PathMatcher{ - Paths: [][]interface{}{ + Paths: [][]any{ { float64(0), "key", @@ -150,7 +150,7 @@ func TestPathMatcher_BreaksPath(t *testing.T) { var matcher Matcher matcher = &PathMatcher{ - Paths: [][]interface{}{ + Paths: [][]any{ { float64(0), "key", @@ -190,7 +190,7 @@ func TestPathMatcher_MultiplePaths(t *testing.T) { var matcher Matcher matcher = &PathMatcher{ - Paths: [][]interface{}{ + Paths: [][]any{ { float64(0), "key", diff --git a/staging/terraform/command/jsonformat/structured/change.go b/staging/terraform/command/jsonformat/structured/change.go index 6e8a5ee..bbd2230 100644 --- a/staging/terraform/command/jsonformat/structured/change.go +++ b/staging/terraform/command/jsonformat/structured/change.go @@ -54,13 +54,13 @@ type Change struct { // // The type of the value should be informed by the schema and cast // appropriately when needed. - Before interface{} + Before any // After contains the value after the proposed change. // // The type of the value should be informed by the schema and cast // appropriately when needed. - After interface{} + After any // Unknown describes whether the After value is known or unknown at the time // of the plan. In practice, this means the after value should be rendered @@ -70,15 +70,15 @@ type Change struct { // the After value is unknown, or it could be a list or a map depending on // the schema describing whether specific elements or attributes within the // value are unknown. - Unknown interface{} + Unknown any // BeforeSensitive matches Unknown, but references whether the Before value // is sensitive. - BeforeSensitive interface{} + BeforeSensitive any // AfterSensitive matches Unknown, but references whether the After value is // sensitive. - AfterSensitive interface{} + AfterSensitive any // ReplacePaths contains a set of paths that point to attributes/elements // that are causing the overall resource to be replaced rather than simply @@ -259,20 +259,20 @@ func (change Change) AsCreate() Change { } } -func unmarshalGeneric(raw json.RawMessage) interface{} { +func unmarshalGeneric(raw json.RawMessage) any { if raw == nil { return nil } - var out interface{} + var out any if err := json.Unmarshal(raw, &out); err != nil { panic("unrecognized json type: " + err.Error()) } return out } -func unwrapAttributeValues(values jsonstate.AttributeValues) map[string]interface{} { - out := make(map[string]interface{}) +func unwrapAttributeValues(values jsonstate.AttributeValues) map[string]any { + out := make(map[string]any) for key, value := range values { out[key] = unmarshalGeneric(value) } diff --git a/staging/terraform/command/jsonformat/structured/map.go b/staging/terraform/command/jsonformat/structured/map.go index f41ea09..eac5bfd 100644 --- a/staging/terraform/command/jsonformat/structured/map.go +++ b/staging/terraform/command/jsonformat/structured/map.go @@ -11,22 +11,22 @@ import ( // converted the relevant interfaces into maps for easier access. type ChangeMap struct { // Before contains the value before the proposed change. - Before map[string]interface{} + Before map[string]any // After contains the value after the proposed change. - After map[string]interface{} + After map[string]any // Unknown contains the unknown status of any elements/attributes of this // map/object. - Unknown map[string]interface{} + Unknown map[string]any // BeforeSensitive contains the before sensitive status of any // elements/attributes of this map/object. - BeforeSensitive map[string]interface{} + BeforeSensitive map[string]any // AfterSensitive contains the after sensitive status of any // elements/attributes of this map/object. - AfterSensitive map[string]interface{} + AfterSensitive map[string]any // ReplacePaths matches the same attributes in Change exactly. ReplacePaths attribute_path.Matcher @@ -144,7 +144,7 @@ func (m ChangeMap) AllKeys() []string { return dedupedKeys } -func getFromGenericMap(generic map[string]interface{}, key string) (interface{}, bool) { +func getFromGenericMap(generic map[string]any, key string) (any, bool) { if generic == nil { return nil, false } @@ -155,8 +155,8 @@ func getFromGenericMap(generic map[string]interface{}, key string) (interface{}, return nil, false } -func genericToMap(generic interface{}) map[string]interface{} { - if concrete, ok := generic.(map[string]interface{}); ok { +func genericToMap(generic any) map[string]any { + if concrete, ok := generic.(map[string]any); ok { return concrete } return nil diff --git a/staging/terraform/command/jsonformat/structured/slice.go b/staging/terraform/command/jsonformat/structured/slice.go index 8909a6a..71c9a28 100644 --- a/staging/terraform/command/jsonformat/structured/slice.go +++ b/staging/terraform/command/jsonformat/structured/slice.go @@ -11,21 +11,21 @@ import ( // converted the relevant interfaces into slices for easier access. type ChangeSlice struct { // Before contains the value before the proposed change. - Before []interface{} + Before []any // After contains the value after the proposed change. - After []interface{} + After []any // Unknown contains the unknown status of any elements of this list/set. - Unknown []interface{} + Unknown []any // BeforeSensitive contains the before sensitive status of any elements of // this list/set. - BeforeSensitive []interface{} + BeforeSensitive []any // AfterSensitive contains the after sensitive status of any elements of // this list/set. - AfterSensitive []interface{} + AfterSensitive []any // ReplacePaths matches the same attributes in Change exactly. ReplacePaths attribute_path.Matcher @@ -76,7 +76,7 @@ func (s ChangeSlice) GetChild(beforeIx, afterIx int) Change { } } -func getFromGenericSlice(generic []interface{}, ix int) (interface{}, bool) { +func getFromGenericSlice(generic []any, ix int) (any, bool) { if generic == nil { return nil, false } @@ -86,8 +86,8 @@ func getFromGenericSlice(generic []interface{}, ix int) (interface{}, bool) { return generic[ix], true } -func genericToSlice(generic interface{}) []interface{} { - if concrete, ok := generic.([]interface{}); ok { +func genericToSlice(generic any) []any { + if concrete, ok := generic.([]any); ok { return concrete } return nil diff --git a/staging/terraform/command/jsonformat/structured/unknown.go b/staging/terraform/command/jsonformat/structured/unknown.go index d36605c..df93476 100644 --- a/staging/terraform/command/jsonformat/structured/unknown.go +++ b/staging/terraform/command/jsonformat/structured/unknown.go @@ -37,7 +37,7 @@ func (change Change) IsUnknown() bool { // about the type being processed to provide a list of known children that might // not be present in the before or after values. These values will be propagated // as the unknown values in the before value should it be needed. -func (change Change) CheckForUnknown(childUnknown interface{}, process ProcessUnknown, processBefore ProcessUnknownWithBefore) (computed.Diff, bool) { +func (change Change) CheckForUnknown(childUnknown any, process ProcessUnknown, processBefore ProcessUnknownWithBefore) (computed.Diff, bool) { unknown := change.IsUnknown() if !unknown { diff --git a/staging/terraform/command/jsonplan/values.go b/staging/terraform/command/jsonplan/values.go index 98f2042..22c7d6a 100644 --- a/staging/terraform/command/jsonplan/values.go +++ b/staging/terraform/command/jsonplan/values.go @@ -28,7 +28,7 @@ type stateValues struct { // attributeValues is the JSON representation of the attribute values of the // resource, whose structure depends on the resource type schema. -type attributeValues map[string]interface{} +type attributeValues map[string]any func marshalAttributeValues(value cty.Value, schema *configschema.Block) attributeValues { if value == cty.NilVal || value.IsNull() { diff --git a/staging/terraform/command/login.go b/staging/terraform/command/login.go index 19c759d..3628d4b 100644 --- a/staging/terraform/command/login.go +++ b/staging/terraform/command/login.go @@ -230,8 +230,8 @@ func (c *LoginCommand) Run(args []string) int { c.Ui.Output("\n---------------------------------------------------------------------------------\n") if hostname == "app.terraform.io" { // Terraform Cloud var motd struct { - Message string `json:"msg"` - Errors []interface{} `json:"errors"` + Message string `json:"msg"` + Errors []any `json:"errors"` } // Throughout the entire process of fetching a MOTD from TFC, use a default diff --git a/staging/terraform/command/login_test.go b/staging/terraform/command/login_test.go index 6ad16a0..181224f 100644 --- a/staging/terraform/command/login_test.go +++ b/staging/terraform/command/login_test.go @@ -53,8 +53,8 @@ func TestLogin(t *testing.T) { svcs := disco.NewWithCredentialsSource(creds) svcs.SetUserAgent(httpclient.TerraformUserAgent(version.String())) - svcs.ForceHostServices(svchost.Hostname("example.com"), map[string]interface{}{ - "login.v1": map[string]interface{}{ + svcs.ForceHostServices(svchost.Hostname("example.com"), map[string]any{ + "login.v1": map[string]any{ // For this fake hostname we'll use a conventional OAuth flow, // with browser-based consent that we'll mock away using a // mock browser launcher below. @@ -63,17 +63,17 @@ func TestLogin(t *testing.T) { "token": s.URL + "/token", }, }) - svcs.ForceHostServices(svchost.Hostname("with-scopes.example.com"), map[string]interface{}{ - "login.v1": map[string]interface{}{ + svcs.ForceHostServices(svchost.Hostname("with-scopes.example.com"), map[string]any{ + "login.v1": map[string]any{ // with scopes // mock browser launcher below. "client": "scopes_test", "authz": s.URL + "/authz", "token": s.URL + "/token", - "scopes": []interface{}{"app1.full_access", "app2.read_only"}, + "scopes": []any{"app1.full_access", "app2.read_only"}, }, }) - svcs.ForceHostServices(svchost.Hostname("app.terraform.io"), map[string]interface{}{ + svcs.ForceHostServices(svchost.Hostname("app.terraform.io"), map[string]any{ // This represents Terraform Cloud, which does not yet support the // login API, but does support its own bespoke tokens API. "tfe.v2": ts.URL + "/api/v2", @@ -81,16 +81,14 @@ func TestLogin(t *testing.T) { "tfe.v2.2": ts.URL + "/api/v2", "motd.v1": ts.URL + "/api/terraform/motd", }) - svcs.ForceHostServices(svchost.Hostname("tfe.acme.com"), map[string]interface{}{ + svcs.ForceHostServices(svchost.Hostname("tfe.acme.com"), map[string]any{ // This represents a Terraform Enterprise instance which does not // yet support the login API, but does support its own bespoke tokens API. "tfe.v2": ts.URL + "/api/v2", "tfe.v2.1": ts.URL + "/api/v2", "tfe.v2.2": ts.URL + "/api/v2", }) - svcs.ForceHostServices(svchost.Hostname("unsupported.example.net"), map[string]interface{}{ - // This host intentionally left blank. - }) + svcs.ForceHostServices(svchost.Hostname("unsupported.example.net"), map[string]any{}) c := &LoginCommand{ Meta: Meta{ diff --git a/staging/terraform/command/meta.go b/staging/terraform/command/meta.go index dae8190..813c188 100644 --- a/staging/terraform/command/meta.go +++ b/staging/terraform/command/meta.go @@ -641,7 +641,7 @@ func (m *Meta) confirm(opts *terraform.InputOpts) (bool, error) { // // Internally this function uses Diagnostics.Append, and so it will panic // if given unsupported value types, just as Append does. -func (m *Meta) showDiagnostics(vals ...interface{}) { +func (m *Meta) showDiagnostics(vals ...any) { var diags tfdiags.Diagnostics diags = diags.Append(vals...) diags.Sort() diff --git a/staging/terraform/command/providers_mirror.go b/staging/terraform/command/providers_mirror.go index 1d5046e..1b09eb3 100644 --- a/staging/terraform/command/providers_mirror.go +++ b/staging/terraform/command/providers_mirror.go @@ -267,8 +267,8 @@ func (c *ProvidersMirrorCommand) Run(args []string) int { indexDir := filepath.Dir(getproviders.PackedFilePathForPackage( outputDir, provider, versions.Unspecified, getproviders.CurrentPlatform, )) - indexVersions := map[string]interface{}{} - indexArchives := map[getproviders.Version]map[string]interface{}{} + indexVersions := map[string]any{} + indexArchives := map[getproviders.Version]map[string]any{} for _, meta := range metas { archivePath, ok := meta.Location.(getproviders.PackageLocalArchive) if !ok { @@ -288,16 +288,16 @@ func (c *ProvidersMirrorCommand) Run(args []string) int { )) continue } - indexVersions[meta.Version.String()] = map[string]interface{}{} + indexVersions[meta.Version.String()] = map[string]any{} if _, ok := indexArchives[version]; !ok { - indexArchives[version] = map[string]interface{}{} + indexArchives[version] = map[string]any{} } - indexArchives[version][platform.String()] = map[string]interface{}{ + indexArchives[version][platform.String()] = map[string]any{ "url": archiveFilename, // a relative URL from the index file's URL "hashes": []string{hash.String()}, // an array to allow for additional hash formats in future } } - mainIndex := map[string]interface{}{ + mainIndex := map[string]any{ "versions": indexVersions, } mainIndexJSON, err := json.MarshalIndent(mainIndex, "", " ") @@ -322,7 +322,7 @@ func (c *ProvidersMirrorCommand) Run(args []string) int { )) } for version, archiveIndex := range indexArchives { - versionIndex := map[string]interface{}{ + versionIndex := map[string]any{ "archives": archiveIndex, } versionIndexJSON, err := json.MarshalIndent(versionIndex, "", " ") diff --git a/staging/terraform/command/providers_schema_test.go b/staging/terraform/command/providers_schema_test.go index b4e461b..2d0e084 100644 --- a/staging/terraform/command/providers_schema_test.go +++ b/staging/terraform/command/providers_schema_test.go @@ -109,9 +109,9 @@ type providerSchemas struct { } type providerSchema struct { - Provider interface{} `json:"provider,omitempty"` - ResourceSchemas map[string]interface{} `json:"resource_schemas,omitempty"` - DataSourceSchemas map[string]interface{} `json:"data_source_schemas,omitempty"` + Provider any `json:"provider,omitempty"` + ResourceSchemas map[string]any `json:"resource_schemas,omitempty"` + DataSourceSchemas map[string]any `json:"data_source_schemas,omitempty"` } // testProvider returns a mock provider that is configured for basic diff --git a/staging/terraform/command/show_test.go b/staging/terraform/command/show_test.go index f3f27b6..e3a93ee 100644 --- a/staging/terraform/command/show_test.go +++ b/staging/terraform/command/show_test.go @@ -840,10 +840,10 @@ func TestShow_json_output_state(t *testing.T) { // compare ui output to wanted output type state struct { - FormatVersion string `json:"format_version,omitempty"` - TerraformVersion string `json:"terraform_version"` - Values map[string]interface{} `json:"values,omitempty"` - SensitiveValues map[string]bool `json:"sensitive_values,omitempty"` + FormatVersion string `json:"format_version,omitempty"` + TerraformVersion string `json:"terraform_version"` + Values map[string]any `json:"values,omitempty"` + SensitiveValues map[string]bool `json:"sensitive_values,omitempty"` } var got, want state @@ -1142,18 +1142,18 @@ func showFixturePlanFile(t *testing.T, action plans.Action) string { // to avoid needing to constantly update the expected output; as a potential // TODO we could write a jsonplan compare function. type plan struct { - FormatVersion string `json:"format_version,omitempty"` - Variables map[string]interface{} `json:"variables,omitempty"` - PlannedValues map[string]interface{} `json:"planned_values,omitempty"` - ResourceDrift []interface{} `json:"resource_drift,omitempty"` - ResourceChanges []interface{} `json:"resource_changes,omitempty"` - OutputChanges map[string]interface{} `json:"output_changes,omitempty"` - PriorState priorState `json:"prior_state,omitempty"` - Config map[string]interface{} `json:"configuration,omitempty"` + FormatVersion string `json:"format_version,omitempty"` + Variables map[string]any `json:"variables,omitempty"` + PlannedValues map[string]any `json:"planned_values,omitempty"` + ResourceDrift []any `json:"resource_drift,omitempty"` + ResourceChanges []any `json:"resource_changes,omitempty"` + OutputChanges map[string]any `json:"output_changes,omitempty"` + PriorState priorState `json:"prior_state,omitempty"` + Config map[string]any `json:"configuration,omitempty"` } type priorState struct { - FormatVersion string `json:"format_version,omitempty"` - Values map[string]interface{} `json:"values,omitempty"` - SensitiveValues map[string]bool `json:"sensitive_values,omitempty"` + FormatVersion string `json:"format_version,omitempty"` + Values map[string]any `json:"values,omitempty"` + SensitiveValues map[string]bool `json:"sensitive_values,omitempty"` } diff --git a/staging/terraform/command/testdata/login-oauth-server/oauthserver.go b/staging/terraform/command/testdata/login-oauth-server/oauthserver.go index 5454a1d..ca76b5c 100644 --- a/staging/terraform/command/testdata/login-oauth-server/oauthserver.go +++ b/staging/terraform/command/testdata/login-oauth-server/oauthserver.go @@ -16,9 +16,9 @@ import ( // Handler is an implementation of net/http.Handler that provides a stub // OAuth server implementation with the following endpoints: // -// /authz - authorization endpoint -// /token - token endpoint -// /revoke - token revocation (logout) endpoint +// /authz - authorization endpoint +// /token - token endpoint +// /revoke - token revocation (logout) endpoint // // The authorization endpoint returns HTML per normal OAuth conventions, but // it also includes an HTTP header X-Redirect-To giving the same URL that the diff --git a/staging/terraform/command/testdata/login-tfe-server/tfeserver.go b/staging/terraform/command/testdata/login-tfe-server/tfeserver.go index 111c071..aa69a68 100644 --- a/staging/terraform/command/testdata/login-tfe-server/tfeserver.go +++ b/staging/terraform/command/testdata/login-tfe-server/tfeserver.go @@ -17,8 +17,8 @@ const ( // Handler is an implementation of net/http.Handler that provides a stub // TFE API server implementation with the following endpoints: // -// /ping - API existence endpoint -// /account/details - current user endpoint +// /ping - API existence endpoint +// /account/details - current user endpoint var Handler http.Handler type handler struct{} diff --git a/staging/terraform/command/validate_test.go b/staging/terraform/command/validate_test.go index da2c815..4a2bccd 100644 --- a/staging/terraform/command/validate_test.go +++ b/staging/terraform/command/validate_test.go @@ -238,7 +238,7 @@ func TestValidate_json(t *testing.T) { for _, tc := range tests { t.Run(tc.path, func(t *testing.T) { - var want, got map[string]interface{} + var want, got map[string]any wantFile, err := os.Open(path.Join(testFixturePath(tc.path), "output.json")) if err != nil { diff --git a/staging/terraform/command/views/apply_test.go b/staging/terraform/command/views/apply_test.go index 830a8c2..a935310 100644 --- a/staging/terraform/command/views/apply_test.go +++ b/staging/terraform/command/views/apply_test.go @@ -247,19 +247,19 @@ func TestApplyJSON_outputs(t *testing.T) { "password": {Value: cty.StringVal("horse-battery").Mark(marks.Sensitive), Sensitive: true}, }) - want := []map[string]interface{}{ + want := []map[string]any{ { "@level": "info", "@message": "Outputs: 2", "@module": "terraform.ui", "type": "outputs", - "outputs": map[string]interface{}{ - "boop_count": map[string]interface{}{ + "outputs": map[string]any{ + "boop_count": map[string]any{ "sensitive": false, "value": float64(92), "type": "number", }, - "password": map[string]interface{}{ + "password": map[string]any{ "sensitive": true, "type": "string", }, diff --git a/staging/terraform/command/views/hook_json_test.go b/staging/terraform/command/views/hook_json_test.go index 5c50dc2..70f9c9c 100644 --- a/staging/terraform/command/views/hook_json_test.go +++ b/staging/terraform/command/views/hook_json_test.go @@ -93,7 +93,7 @@ func TestJSONHook_create(t *testing.T) { } hook.applyingLock.Unlock() - wantResource := map[string]interface{}{ + wantResource := map[string]any{ "addr": string("test_instance.boop"), "implied_provider": string("test"), "module": string(""), @@ -102,13 +102,13 @@ func TestJSONHook_create(t *testing.T) { "resource_name": string("boop"), "resource_type": string("test_instance"), } - want := []map[string]interface{}{ + want := []map[string]any{ { "@level": "info", "@message": "test_instance.boop: Creating...", "@module": "terraform.ui", "type": "apply_start", - "hook": map[string]interface{}{ + "hook": map[string]any{ "action": string("create"), "resource": wantResource, }, @@ -118,7 +118,7 @@ func TestJSONHook_create(t *testing.T) { "@message": "test_instance.boop: Provisioning with 'local-exec'...", "@module": "terraform.ui", "type": "provision_start", - "hook": map[string]interface{}{ + "hook": map[string]any{ "provisioner": "local-exec", "resource": wantResource, }, @@ -128,7 +128,7 @@ func TestJSONHook_create(t *testing.T) { "@message": `test_instance.boop: (local-exec): Executing: ["/bin/sh" "-c" "touch /etc/motd"]`, "@module": "terraform.ui", "type": "provision_progress", - "hook": map[string]interface{}{ + "hook": map[string]any{ "output": `Executing: ["/bin/sh" "-c" "touch /etc/motd"]`, "provisioner": "local-exec", "resource": wantResource, @@ -139,7 +139,7 @@ func TestJSONHook_create(t *testing.T) { "@message": "test_instance.boop: (local-exec) Provisioning complete", "@module": "terraform.ui", "type": "provision_complete", - "hook": map[string]interface{}{ + "hook": map[string]any{ "provisioner": "local-exec", "resource": wantResource, }, @@ -149,7 +149,7 @@ func TestJSONHook_create(t *testing.T) { "@message": "test_instance.boop: Still creating... [10s elapsed]", "@module": "terraform.ui", "type": "apply_progress", - "hook": map[string]interface{}{ + "hook": map[string]any{ "action": string("create"), "elapsed_seconds": float64(10), "resource": wantResource, @@ -160,7 +160,7 @@ func TestJSONHook_create(t *testing.T) { "@message": "test_instance.boop: Still creating... [20s elapsed]", "@module": "terraform.ui", "type": "apply_progress", - "hook": map[string]interface{}{ + "hook": map[string]any{ "action": string("create"), "elapsed_seconds": float64(20), "resource": wantResource, @@ -171,7 +171,7 @@ func TestJSONHook_create(t *testing.T) { "@message": "test_instance.boop: Creation complete after 22s [id=test]", "@module": "terraform.ui", "type": "apply_complete", - "hook": map[string]interface{}{ + "hook": map[string]any{ "action": string("create"), "elapsed_seconds": float64(22), "id_key": "id", @@ -224,7 +224,7 @@ func TestJSONHook_errors(t *testing.T) { } hook.applyingLock.Unlock() - wantResource := map[string]interface{}{ + wantResource := map[string]any{ "addr": string("test_instance.boop"), "implied_provider": string("test"), "module": string(""), @@ -233,13 +233,13 @@ func TestJSONHook_errors(t *testing.T) { "resource_name": string("boop"), "resource_type": string("test_instance"), } - want := []map[string]interface{}{ + want := []map[string]any{ { "@level": "info", "@message": "test_instance.boop: Destroying...", "@module": "terraform.ui", "type": "apply_start", - "hook": map[string]interface{}{ + "hook": map[string]any{ "action": string("delete"), "resource": wantResource, }, @@ -249,7 +249,7 @@ func TestJSONHook_errors(t *testing.T) { "@message": "test_instance.boop: (local-exec) Provisioning errored", "@module": "terraform.ui", "type": "provision_errored", - "hook": map[string]interface{}{ + "hook": map[string]any{ "provisioner": "local-exec", "resource": wantResource, }, @@ -259,7 +259,7 @@ func TestJSONHook_errors(t *testing.T) { "@message": "test_instance.boop: Destruction errored after 0s", "@module": "terraform.ui", "type": "apply_errored", - "hook": map[string]interface{}{ + "hook": map[string]any{ "action": string("delete"), "elapsed_seconds": float64(0), "resource": wantResource, @@ -292,7 +292,7 @@ func TestJSONHook_refresh(t *testing.T) { action, err = hook.PostRefresh(addr, states.CurrentGen, state, state) testHookReturnValues(t, action, err) - wantResource := map[string]interface{}{ + wantResource := map[string]any{ "addr": string("data.test_data_source.beep"), "implied_provider": string("test"), "module": string(""), @@ -301,13 +301,13 @@ func TestJSONHook_refresh(t *testing.T) { "resource_name": string("beep"), "resource_type": string("test_data_source"), } - want := []map[string]interface{}{ + want := []map[string]any{ { "@level": "info", "@message": "data.test_data_source.beep: Refreshing state... [id=honk]", "@module": "terraform.ui", "type": "refresh_start", - "hook": map[string]interface{}{ + "hook": map[string]any{ "resource": wantResource, "id_key": "id", "id_value": "honk", @@ -318,7 +318,7 @@ func TestJSONHook_refresh(t *testing.T) { "@message": "data.test_data_source.beep: Refresh complete [id=honk]", "@module": "terraform.ui", "type": "refresh_complete", - "hook": map[string]interface{}{ + "hook": map[string]any{ "resource": wantResource, "id_key": "id", "id_value": "honk", diff --git a/staging/terraform/command/views/json/diagnostic_test.go b/staging/terraform/command/views/json/diagnostic_test.go index d402500..6a00471 100644 --- a/staging/terraform/command/views/json/diagnostic_test.go +++ b/staging/terraform/command/views/json/diagnostic_test.go @@ -50,7 +50,7 @@ func TestNewDiagnostic(t *testing.T) { `), } testCases := map[string]struct { - diag interface{} // allow various kinds of diags + diag any // allow various kinds of diags want *Diagnostic }{ "sourceless warning": { diff --git a/staging/terraform/command/views/json_view_test.go b/staging/terraform/command/views/json_view_test.go index 020adab..d95089c 100644 --- a/staging/terraform/command/views/json_view_test.go +++ b/staging/terraform/command/views/json_view_test.go @@ -26,7 +26,7 @@ func TestNewJSONView(t *testing.T) { NewJSONView(NewView(streams)) version := tfversion.String() - want := []map[string]interface{}{ + want := []map[string]any{ { "@level": "info", "@message": fmt.Sprintf("Terraform %s", version), @@ -46,7 +46,7 @@ func TestJSONView_Log(t *testing.T) { jv.Log("hello, world") - want := []map[string]interface{}{ + want := []map[string]any{ { "@level": "info", "@message": "hello, world", @@ -77,13 +77,13 @@ func TestJSONView_Diagnostics(t *testing.T) { jv.Diagnostics(diags) - want := []map[string]interface{}{ + want := []map[string]any{ { "@level": "warn", "@message": `Warning: Improper use of "less"`, "@module": "terraform.ui", "type": "diagnostic", - "diagnostic": map[string]interface{}{ + "diagnostic": map[string]any{ "severity": "warning", "summary": `Improper use of "less"`, "detail": `You probably mean "10 buckets or fewer"`, @@ -94,7 +94,7 @@ func TestJSONView_Diagnostics(t *testing.T) { "@message": "Error: Unusually stripey cat detected", "@module": "terraform.ui", "type": "diagnostic", - "diagnostic": map[string]interface{}{ + "diagnostic": map[string]any{ "severity": "error", "summary": "Unusually stripey cat detected", "detail": "Are you sure this random_pet isn't a cheetah?", @@ -122,15 +122,15 @@ func TestJSONView_PlannedChange(t *testing.T) { } jv.PlannedChange(viewsjson.NewResourceInstanceChange(cs)) - want := []map[string]interface{}{ + want := []map[string]any{ { "@level": "info", "@message": `module.foo.test_instance.bar["boop"]: Plan to create`, "@module": "terraform.ui", "type": "planned_change", - "change": map[string]interface{}{ + "change": map[string]any{ "action": "create", - "resource": map[string]interface{}{ + "resource": map[string]any{ "addr": `module.foo.test_instance.bar["boop"]`, "implied_provider": "test", "module": "module.foo", @@ -163,15 +163,15 @@ func TestJSONView_ResourceDrift(t *testing.T) { } jv.ResourceDrift(viewsjson.NewResourceInstanceChange(cs)) - want := []map[string]interface{}{ + want := []map[string]any{ { "@level": "info", "@message": `module.foo.test_instance.bar["boop"]: Drift detected (update)`, "@module": "terraform.ui", "type": "resource_drift", - "change": map[string]interface{}{ + "change": map[string]any{ "action": "update", - "resource": map[string]interface{}{ + "resource": map[string]any{ "addr": `module.foo.test_instance.bar["boop"]`, "implied_provider": "test", "module": "module.foo", @@ -197,13 +197,13 @@ func TestJSONView_ChangeSummary(t *testing.T) { Operation: viewsjson.OperationApplied, }) - want := []map[string]interface{}{ + want := []map[string]any{ { "@level": "info", "@message": "Apply complete! Resources: 1 added, 2 changed, 3 destroyed.", "@module": "terraform.ui", "type": "change_summary", - "changes": map[string]interface{}{ + "changes": map[string]any{ "add": float64(1), "import": float64(0), "change": float64(2), @@ -227,13 +227,13 @@ func TestJSONView_ChangeSummaryWithImport(t *testing.T) { Operation: viewsjson.OperationApplied, }) - want := []map[string]interface{}{ + want := []map[string]any{ { "@level": "info", "@message": "Apply complete! Resources: 1 imported, 1 added, 2 changed, 3 destroyed.", "@module": "terraform.ui", "type": "change_summary", - "changes": map[string]interface{}{ + "changes": map[string]any{ "add": float64(1), "change": float64(2), "remove": float64(3), @@ -259,14 +259,14 @@ func TestJSONView_Hook(t *testing.T) { jv.Hook(hook) - want := []map[string]interface{}{ + want := []map[string]any{ { "@level": "info", "@message": `module.foo.test_instance.bar["boop"]: Creation complete after 34s [id=boop-beep]`, "@module": "terraform.ui", "type": "apply_complete", - "hook": map[string]interface{}{ - "resource": map[string]interface{}{ + "hook": map[string]any{ + "resource": map[string]any{ "addr": `module.foo.test_instance.bar["boop"]`, "implied_provider": "test", "module": "module.foo", @@ -302,19 +302,19 @@ func TestJSONView_Outputs(t *testing.T) { }, }) - want := []map[string]interface{}{ + want := []map[string]any{ { "@level": "info", "@message": "Outputs: 2", "@module": "terraform.ui", "type": "outputs", - "outputs": map[string]interface{}{ - "boop_count": map[string]interface{}{ + "outputs": map[string]any{ + "boop_count": map[string]any{ "sensitive": false, "value": float64(92), "type": "number", }, - "password": map[string]interface{}{ + "password": map[string]any{ "sensitive": true, "value": "horse-battery", "type": "string", @@ -329,7 +329,7 @@ func TestJSONView_Outputs(t *testing.T) { // against a slice of structs representing the desired log messages. It // verifies that the output of JSONView is in JSON log format, one message per // line. -func testJSONViewOutputEqualsFull(t *testing.T, output string, want []map[string]interface{}) { +func testJSONViewOutputEqualsFull(t *testing.T, output string, want []map[string]any) { t.Helper() // Remove final trailing newline @@ -344,7 +344,7 @@ func testJSONViewOutputEqualsFull(t *testing.T, output string, want []map[string // Unmarshal each line and compare to the expected value for i := range gotLines { - var gotStruct map[string]interface{} + var gotStruct map[string]any if i >= len(want) { t.Error("reached end of want messages too soon") break @@ -375,7 +375,7 @@ func testJSONViewOutputEqualsFull(t *testing.T, output string, want []map[string // testJSONViewOutputEquals skips the first line of output, since it ought to // be a version message that we don't care about for most of our tests. -func testJSONViewOutputEquals(t *testing.T, output string, want []map[string]interface{}) { +func testJSONViewOutputEquals(t *testing.T, output string, want []map[string]any) { t.Helper() // Remove up to the first newline diff --git a/staging/terraform/command/views/operation_test.go b/staging/terraform/command/views/operation_test.go index b6d8122..0ae02a5 100644 --- a/staging/terraform/command/views/operation_test.go +++ b/staging/terraform/command/views/operation_test.go @@ -72,7 +72,7 @@ func TestOperation_emergencyDumpState(t *testing.T) { // Check that the result (on stderr) looks like JSON state raw := done(t).Stderr() - var state map[string]interface{} + var state map[string]any if err := json.Unmarshal([]byte(raw), &state); err != nil { t.Fatalf("unexpected error parsing dumped state: %s\nraw:\n%s", err, raw) } @@ -484,7 +484,7 @@ func TestOperationJSON_logs(t *testing.T) { v.Interrupted() v.FatalInterrupt() - want := []map[string]interface{}{ + want := []map[string]any{ { "@level": "info", "@message": "Apply cancelled", @@ -534,7 +534,7 @@ func TestOperationJSON_emergencyDumpState(t *testing.T) { if err != nil { t.Fatal(err) } - var stateJSON map[string]interface{} + var stateJSON map[string]any err = json.Unmarshal(stateBuf.Bytes(), &stateJSON) if err != nil { t.Fatal(err) @@ -545,7 +545,7 @@ func TestOperationJSON_emergencyDumpState(t *testing.T) { t.Fatalf("unexpected error dumping state: %s", err) } - want := []map[string]interface{}{ + want := []map[string]any{ { "@level": "info", "@message": "Emergency state dump", @@ -567,13 +567,13 @@ func TestOperationJSON_planNoChanges(t *testing.T) { } v.Plan(plan, nil) - want := []map[string]interface{}{ + want := []map[string]any{ { "@level": "info", "@message": "Plan: 0 to add, 0 to change, 0 to destroy.", "@module": "terraform.ui", "type": "change_summary", - "changes": map[string]interface{}{ + "changes": map[string]any{ "operation": "plan", "add": float64(0), "import": float64(0), @@ -638,16 +638,16 @@ func TestOperationJSON_plan(t *testing.T) { } v.Plan(plan, testSchemas()) - want := []map[string]interface{}{ + want := []map[string]any{ // Create-then-delete should result in replace { "@level": "info", "@message": "test_resource.boop[0]: Plan to replace", "@module": "terraform.ui", "type": "planned_change", - "change": map[string]interface{}{ + "change": map[string]any{ "action": "replace", - "resource": map[string]interface{}{ + "resource": map[string]any{ "addr": `test_resource.boop[0]`, "implied_provider": "test", "module": "", @@ -664,9 +664,9 @@ func TestOperationJSON_plan(t *testing.T) { "@message": "test_resource.boop[1]: Plan to create", "@module": "terraform.ui", "type": "planned_change", - "change": map[string]interface{}{ + "change": map[string]any{ "action": "create", - "resource": map[string]interface{}{ + "resource": map[string]any{ "addr": `test_resource.boop[1]`, "implied_provider": "test", "module": "", @@ -683,9 +683,9 @@ func TestOperationJSON_plan(t *testing.T) { "@message": "module.vpc.test_resource.boop[0]: Plan to delete", "@module": "terraform.ui", "type": "planned_change", - "change": map[string]interface{}{ + "change": map[string]any{ "action": "delete", - "resource": map[string]interface{}{ + "resource": map[string]any{ "addr": `module.vpc.test_resource.boop[0]`, "implied_provider": "test", "module": "module.vpc", @@ -702,9 +702,9 @@ func TestOperationJSON_plan(t *testing.T) { "@message": "test_resource.beep: Plan to replace", "@module": "terraform.ui", "type": "planned_change", - "change": map[string]interface{}{ + "change": map[string]any{ "action": "replace", - "resource": map[string]interface{}{ + "resource": map[string]any{ "addr": `test_resource.beep`, "implied_provider": "test", "module": "", @@ -721,9 +721,9 @@ func TestOperationJSON_plan(t *testing.T) { "@message": "module.vpc.test_resource.beep: Plan to update", "@module": "terraform.ui", "type": "planned_change", - "change": map[string]interface{}{ + "change": map[string]any{ "action": "update", - "resource": map[string]interface{}{ + "resource": map[string]any{ "addr": `module.vpc.test_resource.beep`, "implied_provider": "test", "module": "module.vpc", @@ -741,7 +741,7 @@ func TestOperationJSON_plan(t *testing.T) { "@message": "Plan: 3 to add, 1 to change, 3 to destroy.", "@module": "terraform.ui", "type": "change_summary", - "changes": map[string]interface{}{ + "changes": map[string]any{ "operation": "plan", "add": float64(3), "import": float64(0), @@ -794,16 +794,16 @@ func TestOperationJSON_planWithImport(t *testing.T) { } v.Plan(plan, testSchemas()) - want := []map[string]interface{}{ + want := []map[string]any{ // Simple import { "@level": "info", "@message": "module.vpc.test_resource.boop[0]: Plan to import", "@module": "terraform.ui", "type": "planned_change", - "change": map[string]interface{}{ + "change": map[string]any{ "action": "import", - "resource": map[string]interface{}{ + "resource": map[string]any{ "addr": `module.vpc.test_resource.boop[0]`, "implied_provider": "test", "module": "module.vpc", @@ -812,7 +812,7 @@ func TestOperationJSON_planWithImport(t *testing.T) { "resource_name": "boop", "resource_type": "test_resource", }, - "importing": map[string]interface{}{ + "importing": map[string]any{ "id": "DECD6D77", }, }, @@ -823,9 +823,9 @@ func TestOperationJSON_planWithImport(t *testing.T) { "@message": "module.vpc.test_resource.boop[1]: Plan to delete", "@module": "terraform.ui", "type": "planned_change", - "change": map[string]interface{}{ + "change": map[string]any{ "action": "delete", - "resource": map[string]interface{}{ + "resource": map[string]any{ "addr": `module.vpc.test_resource.boop[1]`, "implied_provider": "test", "module": "module.vpc", @@ -834,7 +834,7 @@ func TestOperationJSON_planWithImport(t *testing.T) { "resource_name": "boop", "resource_type": "test_resource", }, - "importing": map[string]interface{}{ + "importing": map[string]any{ "id": "DECD6D77", }, }, @@ -845,9 +845,9 @@ func TestOperationJSON_planWithImport(t *testing.T) { "@message": "test_resource.boop[0]: Plan to replace", "@module": "terraform.ui", "type": "planned_change", - "change": map[string]interface{}{ + "change": map[string]any{ "action": "replace", - "resource": map[string]interface{}{ + "resource": map[string]any{ "addr": `test_resource.boop[0]`, "implied_provider": "test", "module": "", @@ -856,7 +856,7 @@ func TestOperationJSON_planWithImport(t *testing.T) { "resource_name": "boop", "resource_type": "test_resource", }, - "importing": map[string]interface{}{ + "importing": map[string]any{ "id": "DECD6D77", }, }, @@ -867,9 +867,9 @@ func TestOperationJSON_planWithImport(t *testing.T) { "@message": "test_resource.beep: Plan to update", "@module": "terraform.ui", "type": "planned_change", - "change": map[string]interface{}{ + "change": map[string]any{ "action": "update", - "resource": map[string]interface{}{ + "resource": map[string]any{ "addr": `test_resource.beep`, "implied_provider": "test", "module": "", @@ -878,7 +878,7 @@ func TestOperationJSON_planWithImport(t *testing.T) { "resource_name": "beep", "resource_type": "test_resource", }, - "importing": map[string]interface{}{ + "importing": map[string]any{ "id": "DECD6D77", }, }, @@ -888,7 +888,7 @@ func TestOperationJSON_planWithImport(t *testing.T) { "@message": "Plan: 4 to import, 1 to add, 1 to change, 2 to destroy.", "@module": "terraform.ui", "type": "change_summary", - "changes": map[string]interface{}{ + "changes": map[string]any{ "operation": "plan", "add": float64(1), "import": float64(4), @@ -943,16 +943,16 @@ func TestOperationJSON_planDriftWithMove(t *testing.T) { } v.Plan(plan, testSchemas()) - want := []map[string]interface{}{ + want := []map[string]any{ // Drift detected: delete { "@level": "info", "@message": "test_resource.beep: Drift detected (delete)", "@module": "terraform.ui", "type": "resource_drift", - "change": map[string]interface{}{ + "change": map[string]any{ "action": "delete", - "resource": map[string]interface{}{ + "resource": map[string]any{ "addr": "test_resource.beep", "implied_provider": "test", "module": "", @@ -969,9 +969,9 @@ func TestOperationJSON_planDriftWithMove(t *testing.T) { "@message": "test_resource.boop: Drift detected (update)", "@module": "terraform.ui", "type": "resource_drift", - "change": map[string]interface{}{ + "change": map[string]any{ "action": "update", - "resource": map[string]interface{}{ + "resource": map[string]any{ "addr": "test_resource.boop", "implied_provider": "test", "module": "", @@ -980,7 +980,7 @@ func TestOperationJSON_planDriftWithMove(t *testing.T) { "resource_name": "boop", "resource_type": "test_resource", }, - "previous_resource": map[string]interface{}{ + "previous_resource": map[string]any{ "addr": "test_resource.blep", "implied_provider": "test", "module": "", @@ -997,9 +997,9 @@ func TestOperationJSON_planDriftWithMove(t *testing.T) { "@message": `test_resource.honk["bonk"]: Plan to move`, "@module": "terraform.ui", "type": "planned_change", - "change": map[string]interface{}{ + "change": map[string]any{ "action": "move", - "resource": map[string]interface{}{ + "resource": map[string]any{ "addr": `test_resource.honk["bonk"]`, "implied_provider": "test", "module": "", @@ -1008,7 +1008,7 @@ func TestOperationJSON_planDriftWithMove(t *testing.T) { "resource_name": "honk", "resource_type": "test_resource", }, - "previous_resource": map[string]interface{}{ + "previous_resource": map[string]any{ "addr": `test_resource.honk[0]`, "implied_provider": "test", "module": "", @@ -1025,7 +1025,7 @@ func TestOperationJSON_planDriftWithMove(t *testing.T) { "@message": "Plan: 0 to add, 0 to change, 0 to destroy.", "@module": "terraform.ui", "type": "change_summary", - "changes": map[string]interface{}{ + "changes": map[string]any{ "operation": "plan", "add": float64(0), "import": float64(0), @@ -1074,16 +1074,16 @@ func TestOperationJSON_planDriftWithMoveRefreshOnly(t *testing.T) { } v.Plan(plan, testSchemas()) - want := []map[string]interface{}{ + want := []map[string]any{ // Drift detected: delete { "@level": "info", "@message": "test_resource.beep: Drift detected (delete)", "@module": "terraform.ui", "type": "resource_drift", - "change": map[string]interface{}{ + "change": map[string]any{ "action": "delete", - "resource": map[string]interface{}{ + "resource": map[string]any{ "addr": "test_resource.beep", "implied_provider": "test", "module": "", @@ -1100,9 +1100,9 @@ func TestOperationJSON_planDriftWithMoveRefreshOnly(t *testing.T) { "@message": "test_resource.boop: Drift detected (update)", "@module": "terraform.ui", "type": "resource_drift", - "change": map[string]interface{}{ + "change": map[string]any{ "action": "update", - "resource": map[string]interface{}{ + "resource": map[string]any{ "addr": "test_resource.boop", "implied_provider": "test", "module": "", @@ -1111,7 +1111,7 @@ func TestOperationJSON_planDriftWithMoveRefreshOnly(t *testing.T) { "resource_name": "boop", "resource_type": "test_resource", }, - "previous_resource": map[string]interface{}{ + "previous_resource": map[string]any{ "addr": "test_resource.blep", "implied_provider": "test", "module": "", @@ -1128,9 +1128,9 @@ func TestOperationJSON_planDriftWithMoveRefreshOnly(t *testing.T) { "@message": `test_resource.honk["bonk"]: Drift detected (move)`, "@module": "terraform.ui", "type": "resource_drift", - "change": map[string]interface{}{ + "change": map[string]any{ "action": "move", - "resource": map[string]interface{}{ + "resource": map[string]any{ "addr": `test_resource.honk["bonk"]`, "implied_provider": "test", "module": "", @@ -1139,7 +1139,7 @@ func TestOperationJSON_planDriftWithMoveRefreshOnly(t *testing.T) { "resource_name": "honk", "resource_type": "test_resource", }, - "previous_resource": map[string]interface{}{ + "previous_resource": map[string]any{ "addr": `test_resource.honk[0]`, "implied_provider": "test", "module": "", @@ -1156,7 +1156,7 @@ func TestOperationJSON_planDriftWithMoveRefreshOnly(t *testing.T) { "@message": "Plan: 0 to add, 0 to change, 0 to destroy.", "@module": "terraform.ui", "type": "change_summary", - "changes": map[string]interface{}{ + "changes": map[string]any{ "operation": "plan", "add": float64(0), "import": float64(0), @@ -1209,14 +1209,14 @@ func TestOperationJSON_planOutputChanges(t *testing.T) { } v.Plan(plan, testSchemas()) - want := []map[string]interface{}{ + want := []map[string]any{ // No resource changes { "@level": "info", "@message": "Plan: 0 to add, 0 to change, 0 to destroy.", "@module": "terraform.ui", "type": "change_summary", - "changes": map[string]interface{}{ + "changes": map[string]any{ "operation": "plan", "add": float64(0), "import": float64(0), @@ -1230,20 +1230,20 @@ func TestOperationJSON_planOutputChanges(t *testing.T) { "@message": "Outputs: 4", "@module": "terraform.ui", "type": "outputs", - "outputs": map[string]interface{}{ - "boop": map[string]interface{}{ + "outputs": map[string]any{ + "boop": map[string]any{ "action": "noop", "sensitive": false, }, - "beep": map[string]interface{}{ + "beep": map[string]any{ "action": "create", "sensitive": false, }, - "bonk": map[string]interface{}{ + "bonk": map[string]any{ "action": "delete", "sensitive": false, }, - "honk": map[string]interface{}{ + "honk": map[string]any{ "action": "update", "sensitive": true, }, @@ -1285,16 +1285,16 @@ func TestOperationJSON_plannedChange(t *testing.T) { }) // Expect only two messages, as the data source deletion should be a no-op - want := []map[string]interface{}{ + want := []map[string]any{ { "@level": "info", "@message": "test_instance.boop[0]: Plan to replace", "@module": "terraform.ui", "type": "planned_change", - "change": map[string]interface{}{ + "change": map[string]any{ "action": "replace", "reason": "requested", - "resource": map[string]interface{}{ + "resource": map[string]any{ "addr": `test_instance.boop[0]`, "implied_provider": "test", "module": "", @@ -1310,9 +1310,9 @@ func TestOperationJSON_plannedChange(t *testing.T) { "@message": "test_instance.boop[1]: Plan to create", "@module": "terraform.ui", "type": "planned_change", - "change": map[string]interface{}{ + "change": map[string]any{ "action": "create", - "resource": map[string]interface{}{ + "resource": map[string]any{ "addr": `test_instance.boop[1]`, "implied_provider": "test", "module": "", diff --git a/staging/terraform/command/views/refresh_test.go b/staging/terraform/command/views/refresh_test.go index 7cc581d..6fe3458 100644 --- a/staging/terraform/command/views/refresh_test.go +++ b/staging/terraform/command/views/refresh_test.go @@ -87,19 +87,19 @@ func TestRefreshJSON_outputs(t *testing.T) { "password": {Value: cty.StringVal("horse-battery").Mark(marks.Sensitive), Sensitive: true}, }) - want := []map[string]interface{}{ + want := []map[string]any{ { "@level": "info", "@message": "Outputs: 2", "@module": "terraform.ui", "type": "outputs", - "outputs": map[string]interface{}{ - "boop_count": map[string]interface{}{ + "outputs": map[string]any{ + "boop_count": map[string]any{ "sensitive": false, "value": float64(92), "type": "number", }, - "password": map[string]interface{}{ + "password": map[string]any{ "sensitive": true, "type": "string", }, diff --git a/staging/terraform/command/views/show_test.go b/staging/terraform/command/views/show_test.go index 29266cd..040307f 100644 --- a/staging/terraform/command/views/show_test.go +++ b/staging/terraform/command/views/show_test.go @@ -152,7 +152,7 @@ func TestShowJSON(t *testing.T) { // Make sure the result looks like JSON; we comprehensively test // the structure of this output in the command package tests. - var result map[string]interface{} + var result map[string]any got := done(t).All() t.Logf("output: %s", got) if err := json.Unmarshal([]byte(got), &result); err != nil { diff --git a/staging/terraform/command/views/validate_test.go b/staging/terraform/command/views/validate_test.go index 960af6e..0045a84 100644 --- a/staging/terraform/command/views/validate_test.go +++ b/staging/terraform/command/views/validate_test.go @@ -126,7 +126,7 @@ func TestValidateJSON(t *testing.T) { // Make sure the result looks like JSON; we comprehensively test // the structure of this output in the command package tests. - var result map[string]interface{} + var result map[string]any if err := json.Unmarshal([]byte(got), &result); err != nil { t.Fatal(err) diff --git a/staging/terraform/configs/configload/loader_snapshot.go b/staging/terraform/configs/configload/loader_snapshot.go index bee1cb8..3c597fb 100644 --- a/staging/terraform/configs/configload/loader_snapshot.go +++ b/staging/terraform/configs/configload/loader_snapshot.go @@ -447,7 +447,7 @@ func (fi snapshotFileInfo) IsDir() bool { return fi.isDir } -func (fi snapshotFileInfo) Sys() interface{} { +func (fi snapshotFileInfo) Sys() any { return nil } diff --git a/staging/terraform/configs/hcl2shim/values.go b/staging/terraform/configs/hcl2shim/values.go index a17a8f1..0bddc1e 100644 --- a/staging/terraform/configs/hcl2shim/values.go +++ b/staging/terraform/configs/hcl2shim/values.go @@ -35,7 +35,7 @@ const UnknownVariableValue = "74D93920-ED26-11E3-AC10-0800200C9A66" // terraform.ResourceConfig before calling to a legacy provider, since // helper/schema (the old provider SDK) is particularly sensitive to these // subtle differences within its validation code. -func ConfigValueFromHCL2Block(v cty.Value, schema *configschema.Block) map[string]interface{} { +func ConfigValueFromHCL2Block(v cty.Value, schema *configschema.Block) map[string]any { if v.IsNull() { return nil } @@ -47,7 +47,7 @@ func ConfigValueFromHCL2Block(v cty.Value, schema *configschema.Block) map[strin } atys := v.Type().AttributeTypes() - ret := make(map[string]interface{}) + ret := make(map[string]any) for name := range schema.Attributes { if _, exists := atys[name]; !exists { @@ -87,7 +87,7 @@ func ConfigValueFromHCL2Block(v cty.Value, schema *configschema.Block) map[strin continue } - elems := make([]interface{}, 0, l) + elems := make([]any, 0, l) for it := bv.ElementIterator(); it.Next(); { _, ev := it.Element() if !ev.IsKnown() { @@ -104,7 +104,7 @@ func ConfigValueFromHCL2Block(v cty.Value, schema *configschema.Block) map[strin continue } - elems := make(map[string]interface{}) + elems := make(map[string]any) for it := bv.ElementIterator(); it.Next(); { ek, ev := it.Element() if !ev.IsKnown() { @@ -127,7 +127,7 @@ func ConfigValueFromHCL2Block(v cty.Value, schema *configschema.Block) map[strin // This function will transform a cty null value into a Go nil value, which // isn't a possible outcome of the HCL/HIL-based decoder and so callers may // need to detect and reject any null values. -func ConfigValueFromHCL2(v cty.Value) interface{} { +func ConfigValueFromHCL2(v cty.Value) any { if !v.IsKnown() { return UnknownVariableValue } @@ -165,7 +165,7 @@ func ConfigValueFromHCL2(v cty.Value) interface{} { } if v.Type().IsListType() || v.Type().IsSetType() || v.Type().IsTupleType() { - l := make([]interface{}, 0, v.LengthInt()) + l := make([]any, 0, v.LengthInt()) it := v.ElementIterator() for it.Next() { _, ev := it.Element() @@ -175,7 +175,7 @@ func ConfigValueFromHCL2(v cty.Value) interface{} { } if v.Type().IsMapType() || v.Type().IsObjectType() { - l := make(map[string]interface{}) + l := make(map[string]any) it := v.ElementIterator() for it.Next() { ek, ev := it.Element() @@ -196,7 +196,7 @@ func ConfigValueFromHCL2(v cty.Value) interface{} { // HCL2ValueFromConfigValue is the opposite of configValueFromHCL2: it takes // a value as would be returned from the old interpolator and turns it into // a cty.Value so it can be used within, for example, an HCL2 EvalContext. -func HCL2ValueFromConfigValue(v interface{}) cty.Value { +func HCL2ValueFromConfigValue(v any) cty.Value { if v == nil { return cty.NullVal(cty.DynamicPseudoType) } @@ -213,13 +213,13 @@ func HCL2ValueFromConfigValue(v interface{}) cty.Value { return cty.NumberIntVal(int64(tv)) case float64: return cty.NumberFloatVal(tv) - case []interface{}: + case []any: vals := make([]cty.Value, len(tv)) for i, ev := range tv { vals[i] = HCL2ValueFromConfigValue(ev) } return cty.TupleVal(vals) - case map[string]interface{}: + case map[string]any: vals := map[string]cty.Value{} for k, ev := range tv { vals[k] = HCL2ValueFromConfigValue(ev) diff --git a/staging/terraform/configs/hcl2shim/values_test.go b/staging/terraform/configs/hcl2shim/values_test.go index 0ec8d2d..9838fae 100644 --- a/staging/terraform/configs/hcl2shim/values_test.go +++ b/staging/terraform/configs/hcl2shim/values_test.go @@ -16,7 +16,7 @@ func TestConfigValueFromHCL2Block(t *testing.T) { tests := []struct { Input cty.Value Schema *configschema.Block - Want map[string]interface{} + Want map[string]any }{ { cty.ObjectVal(map[string]cty.Value{ @@ -48,11 +48,11 @@ func TestConfigValueFromHCL2Block(t *testing.T) { }, }, }, - map[string]interface{}{ + map[string]any{ "name": "Ermintrude", "age": int(19), - "address": map[string]interface{}{ - "street": []interface{}{"421 Shoreham Loop"}, + "address": map[string]any{ + "street": []any{"421 Shoreham Loop"}, "city": "Fridgewater", "state": "MA", "zip": "91037", @@ -89,7 +89,7 @@ func TestConfigValueFromHCL2Block(t *testing.T) { }, }, }, - map[string]interface{}{ + map[string]any{ "name": "Ermintrude", "age": int(19), }, @@ -124,11 +124,11 @@ func TestConfigValueFromHCL2Block(t *testing.T) { }, }, }, - map[string]interface{}{ + map[string]any{ "name": "Ermintrude", "age": int(19), - "address": map[string]interface{}{ - "street": []interface{}{"421 Shoreham Loop"}, + "address": map[string]any{ + "street": []any{"421 Shoreham Loop"}, "city": "Fridgewater", "state": "MA", }, @@ -146,9 +146,9 @@ func TestConfigValueFromHCL2Block(t *testing.T) { }, }, }, - map[string]interface{}{ - "address": []interface{}{ - map[string]interface{}{}, + map[string]any{ + "address": []any{ + map[string]any{}, }, }, }, @@ -164,7 +164,7 @@ func TestConfigValueFromHCL2Block(t *testing.T) { }, }, }, - map[string]interface{}{}, + map[string]any{}, }, { cty.ObjectVal(map[string]cty.Value{ @@ -178,9 +178,9 @@ func TestConfigValueFromHCL2Block(t *testing.T) { }, }, }, - map[string]interface{}{ - "address": []interface{}{ - map[string]interface{}{}, + map[string]any{ + "address": []any{ + map[string]any{}, }, }, }, @@ -196,7 +196,7 @@ func TestConfigValueFromHCL2Block(t *testing.T) { }, }, }, - map[string]interface{}{}, + map[string]any{}, }, { cty.ObjectVal(map[string]cty.Value{ @@ -210,9 +210,9 @@ func TestConfigValueFromHCL2Block(t *testing.T) { }, }, }, - map[string]interface{}{ - "address": map[string]interface{}{ - "foo": map[string]interface{}{}, + map[string]any{ + "address": map[string]any{ + "foo": map[string]any{}, }, }, }, @@ -228,7 +228,7 @@ func TestConfigValueFromHCL2Block(t *testing.T) { }, }, }, - map[string]interface{}{}, + map[string]any{}, }, { cty.NullVal(cty.EmptyObject), @@ -250,7 +250,7 @@ func TestConfigValueFromHCL2Block(t *testing.T) { func TestConfigValueFromHCL2(t *testing.T) { tests := []struct { Input cty.Value - Want interface{} + Want any }{ { cty.True, @@ -283,11 +283,11 @@ func TestConfigValueFromHCL2(t *testing.T) { "zip": cty.StringVal("91037"), }), }), - map[string]interface{}{ + map[string]any{ "name": "Ermintrude", "age": int(19), - "address": map[string]interface{}{ - "street": []interface{}{"421 Shoreham Loop"}, + "address": map[string]any{ + "street": []any{"421 Shoreham Loop"}, "city": "Fridgewater", "state": "MA", "zip": "91037", @@ -299,7 +299,7 @@ func TestConfigValueFromHCL2(t *testing.T) { "foo": cty.StringVal("bar"), "bar": cty.StringVal("baz"), }), - map[string]interface{}{ + map[string]any{ "foo": "bar", "bar": "baz", }, @@ -309,7 +309,7 @@ func TestConfigValueFromHCL2(t *testing.T) { cty.StringVal("foo"), cty.True, }), - []interface{}{ + []any{ "foo", true, }, @@ -336,7 +336,7 @@ func TestConfigValueFromHCL2(t *testing.T) { func TestHCL2ValueFromConfigValue(t *testing.T) { tests := []struct { - Input interface{} + Input any Want cty.Value }{ { @@ -376,27 +376,27 @@ func TestHCL2ValueFromConfigValue(t *testing.T) { cty.StringVal("\u00D6"), // NFC-normalized on entry into cty }, { - []interface{}{}, + []any{}, cty.EmptyTupleVal, }, { - []interface{}(nil), + []any(nil), cty.EmptyTupleVal, }, { - []interface{}{"hello", "world"}, + []any{"hello", "world"}, cty.TupleVal([]cty.Value{cty.StringVal("hello"), cty.StringVal("world")}), }, { - map[string]interface{}{}, + map[string]any{}, cty.EmptyObjectVal, }, { - map[string]interface{}(nil), + map[string]any(nil), cty.EmptyObjectVal, }, { - map[string]interface{}{ + map[string]any{ "foo": "bar", "bar": "baz", }, diff --git a/staging/terraform/configs/parser_test.go b/staging/terraform/configs/parser_test.go index 6de8c71..d7472a8 100644 --- a/staging/terraform/configs/parser_test.go +++ b/staging/terraform/configs/parser_test.go @@ -171,7 +171,7 @@ func assertExactDiagnostics(t *testing.T, diags hcl.Diagnostics, want []string) return bad } -func assertResultDeepEqual(t *testing.T, got, want interface{}) bool { +func assertResultDeepEqual(t *testing.T, got, want any) bool { t.Helper() if !reflect.DeepEqual(got, want) { t.Errorf("wrong result\ngot: %swant: %s", spew.Sdump(got), spew.Sdump(want)) diff --git a/staging/terraform/dag/edge.go b/staging/terraform/dag/edge.go index 2f69aaa..b8362da 100644 --- a/staging/terraform/dag/edge.go +++ b/staging/terraform/dag/edge.go @@ -23,8 +23,8 @@ type basicEdge struct { S, T Vertex } -func (e *basicEdge) Hashcode() interface{} { - return [...]interface{}{e.S, e.T} +func (e *basicEdge) Hashcode() any { + return [...]any{e.S, e.T} } func (e *basicEdge) Source() Vertex { diff --git a/staging/terraform/dag/graph.go b/staging/terraform/dag/graph.go index 37807aa..be93df2 100644 --- a/staging/terraform/dag/graph.go +++ b/staging/terraform/dag/graph.go @@ -13,8 +13,8 @@ import ( type Graph struct { vertices Set edges Set - downEdges map[interface{}]Set - upEdges map[interface{}]Set + downEdges map[any]Set + upEdges map[any]Set } // Subgrapher allows a Vertex to be a Graph itself, by returning a Grapher. @@ -30,7 +30,7 @@ type Grapher interface { } // Vertex of the graph. -type Vertex interface{} +type Vertex any // NamedVertex is an optional interface that can be implemented by Vertex // to give it a human-friendly name that is used for outputting the graph. @@ -246,11 +246,11 @@ func (g *Graph) Connect(edge Edge) { func (g *Graph) Subsume(other *Graph) { // We're using Set.Filter just as a "visit each element" here, so we're // not doing anything with the result (which will always be empty). - other.vertices.Filter(func(i interface{}) bool { + other.vertices.Filter(func(i any) bool { g.Add(i) return false }) - other.edges.Filter(func(i interface{}) bool { + other.edges.Filter(func(i any) bool { g.Connect(i.(Edge)) return false }) @@ -345,10 +345,10 @@ func (g *Graph) init() { g.edges = make(Set) } if g.downEdges == nil { - g.downEdges = make(map[interface{}]Set) + g.downEdges = make(map[any]Set) } if g.upEdges == nil { - g.upEdges = make(map[interface{}]Set) + g.upEdges = make(map[any]Set) } } diff --git a/staging/terraform/dag/graph_test.go b/staging/terraform/dag/graph_test.go index 43d1e9f..c83043f 100644 --- a/staging/terraform/dag/graph_test.go +++ b/staging/terraform/dag/graph_test.go @@ -210,10 +210,10 @@ func TestGraphUpdownEdges(t *testing.T) { } type hashVertex struct { - code interface{} + code any } -func (v *hashVertex) Hashcode() interface{} { +func (v *hashVertex) Hashcode() any { return v.code } diff --git a/staging/terraform/dag/set.go b/staging/terraform/dag/set.go index 30c0e7d..cfd1ebf 100644 --- a/staging/terraform/dag/set.go +++ b/staging/terraform/dag/set.go @@ -4,17 +4,17 @@ package dag // Set is a set data structure. -type Set map[interface{}]interface{} +type Set map[any]any // Hashable is the interface used by set to get the hash code of a value. // If this isn't given, then the value of the item being added to the set // itself is used as the comparison value. type Hashable interface { - Hashcode() interface{} + Hashcode() any } // hashcode returns the hashcode used for set elements. -func hashcode(v interface{}) interface{} { +func hashcode(v any) any { if h, ok := v.(Hashable); ok { return h.Hashcode() } @@ -23,17 +23,17 @@ func hashcode(v interface{}) interface{} { } // Add adds an item to the set -func (s Set) Add(v interface{}) { +func (s Set) Add(v any) { s[hashcode(v)] = v } // Delete removes an item from the set. -func (s Set) Delete(v interface{}) { +func (s Set) Delete(v any) { delete(s, hashcode(v)) } // Include returns true/false of whether a value is in the set. -func (s Set) Include(v interface{}) bool { +func (s Set) Include(v any) bool { _, ok := s[hashcode(v)] return ok } @@ -75,7 +75,7 @@ func (s Set) Difference(other Set) Set { // Filter returns a set that contains the elements from the receiver // where the given callback returns true. -func (s Set) Filter(cb func(interface{}) bool) Set { +func (s Set) Filter(cb func(any) bool) Set { result := make(Set) for _, v := range s { @@ -93,12 +93,12 @@ func (s Set) Len() int { } // List returns the list of set elements. -func (s Set) List() []interface{} { +func (s Set) List() []any { if s == nil { return nil } - r := make([]interface{}, 0, len(s)) + r := make([]any, 0, len(s)) for _, v := range s { r = append(r, v) } diff --git a/staging/terraform/dag/set_test.go b/staging/terraform/dag/set_test.go index 952d4b8..177ef13 100644 --- a/staging/terraform/dag/set_test.go +++ b/staging/terraform/dag/set_test.go @@ -11,34 +11,34 @@ import ( func TestSetDifference(t *testing.T) { cases := []struct { Name string - A, B []interface{} - Expected []interface{} + A, B []any + Expected []any }{ { "same", - []interface{}{1, 2, 3}, - []interface{}{3, 1, 2}, - []interface{}{}, + []any{1, 2, 3}, + []any{3, 1, 2}, + []any{}, }, { "A has extra elements", - []interface{}{1, 2, 3}, - []interface{}{3, 2}, - []interface{}{1}, + []any{1, 2, 3}, + []any{3, 2}, + []any{1}, }, { "B has extra elements", - []interface{}{1, 2, 3}, - []interface{}{3, 2, 1, 4}, - []interface{}{}, + []any{1, 2, 3}, + []any{3, 2, 1, 4}, + []any{}, }, { "B is nil", - []interface{}{1, 2, 3}, + []any{1, 2, 3}, nil, - []interface{}{1, 2, 3}, + []any{1, 2, 3}, }, } @@ -71,22 +71,22 @@ func TestSetDifference(t *testing.T) { func TestSetFilter(t *testing.T) { cases := []struct { - Input []interface{} - Expected []interface{} + Input []any + Expected []any }{ { - []interface{}{1, 2, 3}, - []interface{}{1, 2, 3}, + []any{1, 2, 3}, + []any{1, 2, 3}, }, { - []interface{}{4, 5, 6}, - []interface{}{4}, + []any{4, 5, 6}, + []any{4}, }, { - []interface{}{7, 8, 9}, - []interface{}{}, + []any{7, 8, 9}, + []any{}, }, } @@ -101,7 +101,7 @@ func TestSetFilter(t *testing.T) { expected.Add(v) } - actual := input.Filter(func(v interface{}) bool { + actual := input.Filter(func(v any) bool { return v.(int) < 5 }) match := actual.Intersection(expected) diff --git a/staging/terraform/dag/walk_test.go b/staging/terraform/dag/walk_test.go index 84254eb..0f5d935 100644 --- a/staging/terraform/dag/walk_test.go +++ b/staging/terraform/dag/walk_test.go @@ -21,7 +21,7 @@ func TestWalker_basic(t *testing.T) { // Run it a bunch of times since it is timing dependent for i := 0; i < 50; i++ { - var order []interface{} + var order []any w := &Walker{Callback: walkCbRecord(&order)} w.Update(&g) @@ -31,7 +31,7 @@ func TestWalker_basic(t *testing.T) { } // Check - expected := []interface{}{1, 2} + expected := []any{1, 2} if !reflect.DeepEqual(order, expected) { t.Errorf("wrong order\ngot: %#v\nwant: %#v", order, expected) } @@ -46,7 +46,7 @@ func TestWalker_updateNilGraph(t *testing.T) { // Run it a bunch of times since it is timing dependent for i := 0; i < 50; i++ { - var order []interface{} + var order []any w := &Walker{Callback: walkCbRecord(&order)} w.Update(&g) w.Update(nil) @@ -69,7 +69,7 @@ func TestWalker_error(t *testing.T) { g.Connect(BasicEdge(3, 4)) // Record function - var order []interface{} + var order []any recordF := walkCbRecord(&order) // Build a callback that delays until we close a channel @@ -92,7 +92,7 @@ func TestWalker_error(t *testing.T) { } // Check - expected := []interface{}{1} + expected := []any{1} if !reflect.DeepEqual(order, expected) { t.Errorf("wrong order\ngot: %#v\nwant: %#v", order, expected) } @@ -105,7 +105,7 @@ func TestWalker_newVertex(t *testing.T) { g.Connect(BasicEdge(1, 2)) // Record function - var order []interface{} + var order []any recordF := walkCbRecord(&order) done2 := make(chan int) @@ -139,7 +139,7 @@ func TestWalker_newVertex(t *testing.T) { } // Check - expected := []interface{}{1, 2, 3} + expected := []any{1, 2, 3} if !reflect.DeepEqual(order, expected) { t.Errorf("wrong order\ngot: %#v\nwant: %#v", order, expected) } @@ -152,7 +152,7 @@ func TestWalker_removeVertex(t *testing.T) { g.Connect(BasicEdge(1, 2)) // Record function - var order []interface{} + var order []any recordF := walkCbRecord(&order) var w *Walker @@ -175,7 +175,7 @@ func TestWalker_removeVertex(t *testing.T) { } // Check - expected := []interface{}{1} + expected := []any{1} if !reflect.DeepEqual(order, expected) { t.Errorf("wrong order\ngot: %#v\nwant: %#v", order, expected) } @@ -188,7 +188,7 @@ func TestWalker_newEdge(t *testing.T) { g.Connect(BasicEdge(1, 2)) // Record function - var order []interface{} + var order []any recordF := walkCbRecord(&order) var w *Walker @@ -215,7 +215,7 @@ func TestWalker_newEdge(t *testing.T) { } // Check - expected := []interface{}{1, 3, 2} + expected := []any{1, 3, 2} if !reflect.DeepEqual(order, expected) { t.Errorf("wrong order\ngot: %#v\nwant: %#v", order, expected) } @@ -231,7 +231,7 @@ func TestWalker_removeEdge(t *testing.T) { g.Connect(BasicEdge(3, 2)) // Record function - var order []interface{} + var order []any recordF := walkCbRecord(&order) // The way this works is that our original graph forces @@ -283,14 +283,14 @@ func TestWalker_removeEdge(t *testing.T) { } // Check - expected := []interface{}{1, 2, 3} + expected := []any{1, 2, 3} if !reflect.DeepEqual(order, expected) { t.Errorf("wrong order\ngot: %#v\nwant: %#v", order, expected) } } // walkCbRecord is a test helper callback that just records the order called. -func walkCbRecord(order *[]interface{}) WalkFunc { +func walkCbRecord(order *[]any) WalkFunc { var l sync.Mutex return func(v Vertex) tfdiags.Diagnostics { l.Lock() diff --git a/staging/terraform/getproviders/http_mirror_source_test.go b/staging/terraform/getproviders/http_mirror_source_test.go index f293bd0..939fb81 100644 --- a/staging/terraform/getproviders/http_mirror_source_test.go +++ b/staging/terraform/getproviders/http_mirror_source_test.go @@ -30,7 +30,7 @@ func TestHTTPMirrorSource(t *testing.T) { if err != nil { t.Fatalf("httptest.NewTLSServer returned a server with an invalid URL") } - creds := svcauth.StaticCredentialsSource(map[svchost.Hostname]map[string]interface{}{ + creds := svcauth.StaticCredentialsSource(map[svchost.Hostname]map[string]any{ svchost.Hostname(baseURL.Host): { "token": "placeholder-token", }, diff --git a/staging/terraform/getproviders/memoize_source_test.go b/staging/terraform/getproviders/memoize_source_test.go index 5bad43f..d31e8a0 100644 --- a/staging/terraform/getproviders/memoize_source_test.go +++ b/staging/terraform/getproviders/memoize_source_test.go @@ -57,7 +57,7 @@ func TestMemoizeSource(t *testing.T) { } gotLog := mock.CallLog() - wantLog := [][]interface{}{ + wantLog := [][]any{ // Only one call for the main provider, because the others were returned from the cache. {"AvailableVersions", provider}, @@ -131,7 +131,7 @@ func TestMemoizeSource(t *testing.T) { } gotLog := mock.CallLog() - wantLog := [][]interface{}{ + wantLog := [][]any{ // Only one call for the main provider, because the others were returned from the cache. {"PackageMeta", provider, version, platform}, @@ -157,7 +157,7 @@ func TestMemoizeSource(t *testing.T) { } gotLog := mock.CallLog() - wantLog := [][]interface{}{ + wantLog := [][]any{ // Only one call, because the other was returned from the cache. {"AvailableVersions", nonexistProvider}, } @@ -179,7 +179,7 @@ func TestMemoizeSource(t *testing.T) { } gotLog := mock.CallLog() - wantLog := [][]interface{}{ + wantLog := [][]any{ // Only one call, because the other was returned from the cache. {"PackageMeta", nonexistProvider, version, platform}, } diff --git a/staging/terraform/getproviders/mock_source.go b/staging/terraform/getproviders/mock_source.go index 32a99c1..8c0e670 100644 --- a/staging/terraform/getproviders/mock_source.go +++ b/staging/terraform/getproviders/mock_source.go @@ -22,7 +22,7 @@ import ( type MockSource struct { packages []PackageMeta warnings map[addrs.Provider]Warnings - calls [][]interface{} + calls [][]any } var _ Source = (*MockSource)(nil) @@ -44,7 +44,7 @@ func NewMockSource(packages []PackageMeta, warns map[addrs.Provider]Warnings) *M // are available in the fixed set of packages that were passed to // NewMockSource when creating the receiving source. func (s *MockSource) AvailableVersions(ctx context.Context, provider addrs.Provider) (VersionList, Warnings, error) { - s.calls = append(s.calls, []interface{}{"AvailableVersions", provider}) + s.calls = append(s.calls, []any{"AvailableVersions", provider}) var ret VersionList for _, pkg := range s.packages { if pkg.Provider == provider { @@ -80,7 +80,7 @@ func (s *MockSource) AvailableVersions(ctx context.Context, provider addrs.Provi // of other sources in an equivalent situation because it's a degenerate case // with undefined results. func (s *MockSource) PackageMeta(ctx context.Context, provider addrs.Provider, version Version, target Platform) (PackageMeta, error) { - s.calls = append(s.calls, []interface{}{"PackageMeta", provider, version, target}) + s.calls = append(s.calls, []any{"PackageMeta", provider, version, target}) for _, pkg := range s.packages { if pkg.Provider != provider { @@ -119,7 +119,7 @@ func (s *MockSource) PackageMeta(ctx context.Context, provider addrs.Provider, v // // Callers are forbidden from modifying any objects accessible via the returned // value. -func (s *MockSource) CallLog() [][]interface{} { +func (s *MockSource) CallLog() [][]any { return s.calls } diff --git a/staging/terraform/getproviders/registry_client_test.go b/staging/terraform/getproviders/registry_client_test.go index 2154941..84431f6 100644 --- a/staging/terraform/getproviders/registry_client_test.go +++ b/staging/terraform/getproviders/registry_client_test.go @@ -111,16 +111,16 @@ func testRegistryServices(t *testing.T) (services *disco.Disco, baseURL string, server := httptest.NewServer(http.HandlerFunc(fakeRegistryHandler)) services = disco.New() - services.ForceHostServices(svchost.Hostname("example.com"), map[string]interface{}{ + services.ForceHostServices(svchost.Hostname("example.com"), map[string]any{ "providers.v1": server.URL + "/providers/v1/", }) - services.ForceHostServices(svchost.Hostname("not.example.com"), map[string]interface{}{}) - services.ForceHostServices(svchost.Hostname("too-new.example.com"), map[string]interface{}{ + services.ForceHostServices(svchost.Hostname("not.example.com"), map[string]any{}) + services.ForceHostServices(svchost.Hostname("too-new.example.com"), map[string]any{ // This service doesn't actually work; it's here only to be // detected as "too new" by the discovery logic. "providers.v99": server.URL + "/providers/v99/", }) - services.ForceHostServices(svchost.Hostname("fails.example.com"), map[string]interface{}{ + services.ForceHostServices(svchost.Hostname("fails.example.com"), map[string]any{ "providers.v1": server.URL + "/fails-immediately/", }) @@ -129,7 +129,7 @@ func testRegistryServices(t *testing.T) (services *disco.Disco, baseURL string, // hostname. It behaves the same as example.com, which should be preferred // if you're not testing something specific to the default registry in order // to ensure that most things are hostname-agnostic. - services.ForceHostServices(svchost.Hostname("registry.terraform.io"), map[string]interface{}{ + services.ForceHostServices(svchost.Hostname("registry.terraform.io"), map[string]any{ "providers.v1": server.URL + "/providers/v1/", }) @@ -275,7 +275,7 @@ func fakeRegistryHandler(resp http.ResponseWriter, req *http.Request) { protocols = []string{"5.0"} } - body := map[string]interface{}{ + body := map[string]any{ "protocols": protocols, "os": pathParts[4], "arch": pathParts[5], @@ -284,8 +284,8 @@ func fakeRegistryHandler(resp http.ResponseWriter, req *http.Request) { "download_url": "/pkg/awesomesauce/happycloud_" + version + ".zip", "shasums_url": "/pkg/awesomesauce/happycloud_" + version + "_SHA256SUMS", "shasums_signature_url": "/pkg/awesomesauce/happycloud_" + version + "_SHA256SUMS.sig", - "signing_keys": map[string]interface{}{ - "gpg_public_keys": []map[string]interface{}{ + "signing_keys": map[string]any{ + "gpg_public_keys": []map[string]any{ { "ascii_armor": HashicorpPublicKey, }, diff --git a/staging/terraform/initwd/module_install_test.go b/staging/terraform/initwd/module_install_test.go index cf1ff6d..1f7cc5a 100644 --- a/staging/terraform/initwd/module_install_test.go +++ b/staging/terraform/initwd/module_install_test.go @@ -837,7 +837,7 @@ func assertDiagnosticSummary(t *testing.T, diags tfdiags.Diagnostics, want strin return true } -func assertResultDeepEqual(t *testing.T, got, want interface{}) bool { +func assertResultDeepEqual(t *testing.T, got, want any) bool { t.Helper() if diff := deep.Equal(got, want); diff != nil { for _, problem := range diff { diff --git a/staging/terraform/lang/funcs/redact.go b/staging/terraform/lang/funcs/redact.go index 44b5134..fb835d6 100644 --- a/staging/terraform/lang/funcs/redact.go +++ b/staging/terraform/lang/funcs/redact.go @@ -10,7 +10,7 @@ import ( "github.com/zclconf/go-cty/cty" ) -func redactIfSensitive(value interface{}, markses ...cty.ValueMarks) string { +func redactIfSensitive(value any, markses ...cty.ValueMarks) string { if marks.Has(cty.DynamicVal.WithMarks(markses...), marks.Sensitive) { return "(sensitive value)" } diff --git a/staging/terraform/lang/funcs/redact_test.go b/staging/terraform/lang/funcs/redact_test.go index 42496f7..5709a07 100644 --- a/staging/terraform/lang/funcs/redact_test.go +++ b/staging/terraform/lang/funcs/redact_test.go @@ -12,7 +12,7 @@ import ( func TestRedactIfSensitive(t *testing.T) { testCases := map[string]struct { - value interface{} + value any marks []cty.ValueMarks want string }{ diff --git a/staging/terraform/legacy/helper/schema/backend.go b/staging/terraform/legacy/helper/schema/backend.go index 9c23fe4..4cb36d0 100644 --- a/staging/terraform/legacy/helper/schema/backend.go +++ b/staging/terraform/legacy/helper/schema/backend.go @@ -185,10 +185,10 @@ func (b *Backend) Configure(obj cty.Value) tfdiags.Diagnostics { // that should be populated enough to appease the not-yet-updated functionality // in this package. This should be removed once everything is updated. func (b *Backend) shimConfig(obj cty.Value) *terraform.ResourceConfig { - shimMap, ok := hcl2shim.ConfigValueFromHCL2(obj).(map[string]interface{}) + shimMap, ok := hcl2shim.ConfigValueFromHCL2(obj).(map[string]any) if !ok { // If the configVal was nil, we still want a non-nil map here. - shimMap = map[string]interface{}{} + shimMap = map[string]any{} } return &terraform.ResourceConfig{ Config: shimMap, diff --git a/staging/terraform/legacy/helper/schema/backend_test.go b/staging/terraform/legacy/helper/schema/backend_test.go index ca28e06..063a29d 100644 --- a/staging/terraform/legacy/helper/schema/backend_test.go +++ b/staging/terraform/legacy/helper/schema/backend_test.go @@ -113,7 +113,7 @@ func TestBackendPrepare(t *testing.T) { "foo": &Schema{ Type: TypeString, Optional: true, - DefaultFunc: func() (interface{}, error) { + DefaultFunc: func() (any, error) { return "baz", nil }, }, diff --git a/staging/terraform/legacy/helper/schema/core_schema_test.go b/staging/terraform/legacy/helper/schema/core_schema_test.go index 1574edf..2ce1390 100644 --- a/staging/terraform/legacy/helper/schema/core_schema_test.go +++ b/staging/terraform/legacy/helper/schema/core_schema_test.go @@ -389,7 +389,7 @@ func TestSchemaMapCoreConfigSchema(t *testing.T) { "string": { Type: TypeString, Required: true, - DefaultFunc: func() (interface{}, error) { + DefaultFunc: func() (any, error) { return nil, nil }, }, @@ -409,7 +409,7 @@ func TestSchemaMapCoreConfigSchema(t *testing.T) { "string": { Type: TypeString, Required: true, - DefaultFunc: func() (interface{}, error) { + DefaultFunc: func() (any, error) { // If we return a non-nil default then this overrides // the "Required: true" for the purpose of building // the core schema, so that core will ignore it not @@ -433,7 +433,7 @@ func TestSchemaMapCoreConfigSchema(t *testing.T) { "string": { Type: TypeString, Required: true, - DefaultFunc: func() (interface{}, error) { + DefaultFunc: func() (any, error) { return nil, fmt.Errorf("placeholder error") }, }, diff --git a/staging/terraform/legacy/helper/schema/data_source_resource_shim.go b/staging/terraform/legacy/helper/schema/data_source_resource_shim.go index 3a01c0f..aced177 100644 --- a/staging/terraform/legacy/helper/schema/data_source_resource_shim.go +++ b/staging/terraform/legacy/helper/schema/data_source_resource_shim.go @@ -27,7 +27,7 @@ func DataSourceResourceShim(name string, dataSource *Resource) *Resource { dataSourceResourceShimAdjustSchema(dataSource.Schema) dataSource.Create = CreateFunc(dataSource.Read) - dataSource.Delete = func(d *ResourceData, meta interface{}) error { + dataSource.Delete = func(d *ResourceData, meta any) error { d.SetId("") return nil } diff --git a/staging/terraform/legacy/helper/schema/equal.go b/staging/terraform/legacy/helper/schema/equal.go index 92a02b3..838e7e5 100644 --- a/staging/terraform/legacy/helper/schema/equal.go +++ b/staging/terraform/legacy/helper/schema/equal.go @@ -5,5 +5,5 @@ package schema // Equal is an interface that checks for deep equality between two objects. type Equal interface { - Equal(interface{}) bool + Equal(any) bool } diff --git a/staging/terraform/legacy/helper/schema/field_reader.go b/staging/terraform/legacy/helper/schema/field_reader.go index cd72a61..c1accf1 100644 --- a/staging/terraform/legacy/helper/schema/field_reader.go +++ b/staging/terraform/legacy/helper/schema/field_reader.go @@ -23,8 +23,8 @@ type FieldReadResult struct { // or the items that should be removed (if they existed). NegValue // doesn't make sense for primitives but is important for any // container types such as maps, sets, lists. - Value interface{} - ValueProcessed interface{} + Value any + ValueProcessed any // Exists is true if the field was found in the data. False means // it wasn't found if there was no error. @@ -37,7 +37,7 @@ type FieldReadResult struct { // ValueOrZero returns the value of this result or the zero value of the // schema type, ensuring a consistent non-nil return value. -func (r *FieldReadResult) ValueOrZero(s *Schema) interface{} { +func (r *FieldReadResult) ValueOrZero(s *Schema) any { if r.Value != nil { return r.Value } @@ -200,14 +200,14 @@ func readListField( // If we have an empty list, then return an empty list if countResult.Computed || countResult.Value.(int) == 0 { return FieldReadResult{ - Value: []interface{}{}, + Value: []any{}, Exists: countResult.Exists, Computed: countResult.Computed, }, nil } // Go through each count, and get the item value out of it - result := make([]interface{}, countResult.Value.(int)) + result := make([]any, countResult.Value.(int)) for i, _ := range result { is := strconv.FormatInt(int64(i), 10) addrPadded[len(addrPadded)-1] = is @@ -238,7 +238,7 @@ func readObjectField( r FieldReader, addr []string, schema map[string]*Schema) (FieldReadResult, error) { - result := make(map[string]interface{}) + result := make(map[string]any) exists := false for field, s := range schema { addrRead := make([]string, len(addr), len(addr)+1) @@ -262,7 +262,7 @@ func readObjectField( } // convert map values to the proper primitive type based on schema.Elem -func mapValuesToPrimitive(k string, m map[string]interface{}, schema *Schema) error { +func mapValuesToPrimitive(k string, m map[string]any, schema *Schema) error { elemType, err := getValueType(k, schema) if err != nil { return err @@ -288,8 +288,8 @@ func mapValuesToPrimitive(k string, m map[string]interface{}, schema *Schema) er } func stringToPrimitive( - value string, computed bool, schema *Schema) (interface{}, error) { - var returnVal interface{} + value string, computed bool, schema *Schema) (any, error) { + var returnVal any switch schema.Type { case TypeBool: if value == "" { diff --git a/staging/terraform/legacy/helper/schema/field_reader_config.go b/staging/terraform/legacy/helper/schema/field_reader_config.go index 95246f5..a7421a1 100644 --- a/staging/terraform/legacy/helper/schema/field_reader_config.go +++ b/staging/terraform/legacy/helper/schema/field_reader_config.go @@ -123,7 +123,7 @@ func (r *ConfigFieldReader) readField( if schema.PromoteSingle { result, err := r.readPrimitive(k, schema.Elem.(*Schema)) if err == nil && result.Exists { - result.Value = []interface{}{result.Value} + result.Value = []any{result.Value} return result, nil } } @@ -163,7 +163,7 @@ func (r *ConfigFieldReader) readMap(k string, schema *Schema) (FieldReadResult, mraw = "${INTERPOLATED}" } - result := make(map[string]interface{}) + result := make(map[string]any) computed := false switch m := mraw.(type) { case string: @@ -173,7 +173,7 @@ func (r *ConfigFieldReader) readMap(k string, schema *Schema) (FieldReadResult, v, _ := r.Config.Get(k) // If this isn't a map[string]interface, it must be computed. - mapV, ok := v.(map[string]interface{}) + mapV, ok := v.(map[string]any) if !ok { return FieldReadResult{ Exists: true, @@ -185,9 +185,9 @@ func (r *ConfigFieldReader) readMap(k string, schema *Schema) (FieldReadResult, for i, iv := range mapV { result[i] = iv } - case []interface{}: + case []any: for i, innerRaw := range m { - for ik := range innerRaw.(map[string]interface{}) { + for ik := range innerRaw.(map[string]any) { key := fmt.Sprintf("%s.%d.%s", k, i, ik) if r.Config.IsComputed(key) { computed = true @@ -198,7 +198,7 @@ func (r *ConfigFieldReader) readMap(k string, schema *Schema) (FieldReadResult, result[ik] = v } } - case []map[string]interface{}: + case []map[string]any: for i, innerRaw := range m { for ik := range innerRaw { key := fmt.Sprintf("%s.%d.%s", k, i, ik) @@ -211,7 +211,7 @@ func (r *ConfigFieldReader) readMap(k string, schema *Schema) (FieldReadResult, result[ik] = v } } - case map[string]interface{}: + case map[string]any: for ik := range m { key := fmt.Sprintf("%s.%s", k, ik) if r.Config.IsComputed(key) { @@ -234,7 +234,7 @@ func (r *ConfigFieldReader) readMap(k string, schema *Schema) (FieldReadResult, return FieldReadResult{}, nil } - var value interface{} + var value any if !computed { value = result } @@ -304,7 +304,7 @@ func (r *ConfigFieldReader) readSet( } // Build up the set from the list elements - for i, v := range raw.Value.([]interface{}) { + for i, v := range raw.Value.([]any) { // Check if any of the keys in this item are computed computed := r.hasComputedSubKeys( fmt.Sprintf("%s.%d", strings.Join(address, "."), i), schema) diff --git a/staging/terraform/legacy/helper/schema/field_reader_config_test.go b/staging/terraform/legacy/helper/schema/field_reader_config_test.go index fc3301d..0e3797b 100644 --- a/staging/terraform/legacy/helper/schema/field_reader_config_test.go +++ b/staging/terraform/legacy/helper/schema/field_reader_config_test.go @@ -23,43 +23,43 @@ func TestConfigFieldReader(t *testing.T) { return &ConfigFieldReader{ Schema: s, - Config: testConfig(t, map[string]interface{}{ + Config: testConfig(t, map[string]any{ "bool": true, "float": 3.1415, "int": 42, "string": "string", - "list": []interface{}{"foo", "bar"}, + "list": []any{"foo", "bar"}, - "listInt": []interface{}{21, 42}, + "listInt": []any{21, 42}, - "map": map[string]interface{}{ + "map": map[string]any{ "foo": "bar", "bar": "baz", }, - "mapInt": map[string]interface{}{ + "mapInt": map[string]any{ "one": "1", "two": "2", }, - "mapIntNestedSchema": map[string]interface{}{ + "mapIntNestedSchema": map[string]any{ "one": "1", "two": "2", }, - "mapFloat": map[string]interface{}{ + "mapFloat": map[string]any{ "oneDotTwo": "1.2", }, - "mapBool": map[string]interface{}{ + "mapBool": map[string]any{ "True": "true", "False": "false", }, - "set": []interface{}{10, 50}, - "setDeep": []interface{}{ - map[string]interface{}{ + "set": []any{10, 50}, + "setDeep": []any{ + map[string]any{ "index": 10, "value": "foo", }, - map[string]interface{}{ + map[string]any{ "index": 50, "value": "bar", }, @@ -89,7 +89,7 @@ func TestConfigFieldReader_custom(t *testing.T) { Value: true, Exists: true, }, - testConfig(t, map[string]interface{}{ + testConfig(t, map[string]any{ "bool": true, }), false, @@ -101,7 +101,7 @@ func TestConfigFieldReader_custom(t *testing.T) { Exists: true, Computed: true, }, - testConfig(t, map[string]interface{}{ + testConfig(t, map[string]any{ "bool": hcl2shim.UnknownVariableValue, }), false, @@ -137,7 +137,7 @@ func TestConfigFieldReader_DefaultHandling(t *testing.T) { }, "strWithDefaultFunc": &Schema{ Type: TypeString, - DefaultFunc: func() (interface{}, error) { + DefaultFunc: func() (any, error) { return "FuncDefault", nil }, }, @@ -156,7 +156,7 @@ func TestConfigFieldReader_DefaultHandling(t *testing.T) { Exists: true, Computed: false, }, - testConfig(t, map[string]interface{}{}), + testConfig(t, map[string]any{}), false, }, "config overrides default value": { @@ -166,7 +166,7 @@ func TestConfigFieldReader_DefaultHandling(t *testing.T) { Exists: true, Computed: false, }, - testConfig(t, map[string]interface{}{ + testConfig(t, map[string]any{ "strWithDefault": "fromConfig", }), false, @@ -178,7 +178,7 @@ func TestConfigFieldReader_DefaultHandling(t *testing.T) { Exists: true, Computed: false, }, - testConfig(t, map[string]interface{}{}), + testConfig(t, map[string]any{}), false, }, "config overrides default function": { @@ -188,7 +188,7 @@ func TestConfigFieldReader_DefaultHandling(t *testing.T) { Exists: true, Computed: false, }, - testConfig(t, map[string]interface{}{ + testConfig(t, map[string]any{ "strWithDefaultFunc": "fromConfig", }), false, @@ -243,14 +243,14 @@ func TestConfigFieldReader_ComputedMap(t *testing.T) { "set, normal", []string{"map"}, FieldReadResult{ - Value: map[string]interface{}{ + Value: map[string]any{ "foo": "bar", }, Exists: true, Computed: false, }, - testConfig(t, map[string]interface{}{ - "map": map[string]interface{}{ + testConfig(t, map[string]any{ + "map": map[string]any{ "foo": "bar", }, }), @@ -264,8 +264,8 @@ func TestConfigFieldReader_ComputedMap(t *testing.T) { Exists: true, Computed: true, }, - testConfig(t, map[string]interface{}{ - "map": map[string]interface{}{ + testConfig(t, map[string]any{ + "map": map[string]any{ "foo": hcl2shim.UnknownVariableValue, }, }), @@ -276,15 +276,15 @@ func TestConfigFieldReader_ComputedMap(t *testing.T) { "native map", []string{"map"}, FieldReadResult{ - Value: map[string]interface{}{ + Value: map[string]any{ "bar": "baz", "baz": "bar", }, Exists: true, Computed: false, }, - testConfig(t, map[string]interface{}{ - "map": map[string]interface{}{ + testConfig(t, map[string]any{ + "map": map[string]any{ "bar": "baz", "baz": "bar", }, @@ -296,15 +296,15 @@ func TestConfigFieldReader_ComputedMap(t *testing.T) { "map-from-list-of-maps", []string{"maplist", "0"}, FieldReadResult{ - Value: map[string]interface{}{ + Value: map[string]any{ "key": "bar", }, Exists: true, Computed: false, }, - testConfig(t, map[string]interface{}{ - "maplist": []interface{}{ - map[string]interface{}{ + testConfig(t, map[string]any{ + "maplist": []any{ + map[string]any{ "key": "bar", }, }, @@ -320,9 +320,9 @@ func TestConfigFieldReader_ComputedMap(t *testing.T) { Exists: true, Computed: false, }, - testConfig(t, map[string]interface{}{ - "maplist": []interface{}{ - map[string]interface{}{ + testConfig(t, map[string]any{ + "maplist": []any{ + map[string]any{ "key": "bar", }, }, @@ -334,13 +334,13 @@ func TestConfigFieldReader_ComputedMap(t *testing.T) { "list-from-map-of-lists", []string{"listmap", "key"}, FieldReadResult{ - Value: []interface{}{"bar"}, + Value: []any{"bar"}, Exists: true, Computed: false, }, - testConfig(t, map[string]interface{}{ - "listmap": map[string]interface{}{ - "key": []interface{}{ + testConfig(t, map[string]any{ + "listmap": map[string]any{ + "key": []any{ "bar", }, }, @@ -356,9 +356,9 @@ func TestConfigFieldReader_ComputedMap(t *testing.T) { Exists: true, Computed: false, }, - testConfig(t, map[string]interface{}{ - "listmap": map[string]interface{}{ - "key": []interface{}{ + testConfig(t, map[string]any{ + "listmap": map[string]any{ + "key": []any{ "bar", }, }, @@ -409,14 +409,14 @@ func TestConfigFieldReader_ComputedSet(t *testing.T) { "set, normal": { []string{"strSet"}, FieldReadResult{ - Value: map[string]interface{}{ + Value: map[string]any{ "2356372769": "foo", }, Exists: true, Computed: false, }, - testConfig(t, map[string]interface{}{ - "strSet": []interface{}{"foo"}, + testConfig(t, map[string]any{ + "strSet": []any{"foo"}, }), false, }, @@ -428,8 +428,8 @@ func TestConfigFieldReader_ComputedSet(t *testing.T) { Exists: true, Computed: true, }, - testConfig(t, map[string]interface{}{ - "strSet": []interface{}{hcl2shim.UnknownVariableValue}, + testConfig(t, map[string]any{ + "strSet": []any{hcl2shim.UnknownVariableValue}, }), false, }, @@ -458,9 +458,9 @@ func TestConfigFieldReader_ComputedSet(t *testing.T) { } func TestConfigFieldReader_computedComplexSet(t *testing.T) { - hashfunc := func(v interface{}) int { + hashfunc := func(v any) int { var buf bytes.Buffer - m := v.(map[string]interface{}) + m := v.(map[string]any) buf.WriteString(fmt.Sprintf("%s-", m["name"].(string))) buf.WriteString(fmt.Sprintf("%s-", m["vhd_uri"].(string))) return hashcode.String(buf.String()) @@ -495,8 +495,8 @@ func TestConfigFieldReader_computedComplexSet(t *testing.T) { "set, normal": { []string{"set"}, FieldReadResult{ - Value: map[string]interface{}{ - "532860136": map[string]interface{}{ + Value: map[string]any{ + "532860136": map[string]any{ "name": "myosdisk1", "vhd_uri": "bar", }, @@ -504,9 +504,9 @@ func TestConfigFieldReader_computedComplexSet(t *testing.T) { Exists: true, Computed: false, }, - testConfig(t, map[string]interface{}{ - "set": []interface{}{ - map[string]interface{}{ + testConfig(t, map[string]any{ + "set": []any{ + map[string]any{ "name": "myosdisk1", "vhd_uri": "bar", }, @@ -538,6 +538,6 @@ func TestConfigFieldReader_computedComplexSet(t *testing.T) { } } -func testConfig(t *testing.T, raw map[string]interface{}) *terraform.ResourceConfig { +func testConfig(t *testing.T, raw map[string]any) *terraform.ResourceConfig { return terraform.NewResourceConfigRaw(raw) } diff --git a/staging/terraform/legacy/helper/schema/field_reader_diff.go b/staging/terraform/legacy/helper/schema/field_reader_diff.go index 4ed5eea..a964a1d 100644 --- a/staging/terraform/legacy/helper/schema/field_reader_diff.go +++ b/staging/terraform/legacy/helper/schema/field_reader_diff.go @@ -89,7 +89,7 @@ func (r *DiffFieldReader) ReadField(address []string) (FieldReadResult, error) { func (r *DiffFieldReader) readMap( address []string, schema *Schema) (FieldReadResult, error) { - result := make(map[string]interface{}) + result := make(map[string]any) resultSet := false // First read the map from the underlying source @@ -100,7 +100,7 @@ func (r *DiffFieldReader) readMap( if source.Exists { // readMap may return a nil value, or an unknown value placeholder in // some cases, causing the type assertion to panic if we don't assign the ok value - result, _ = source.Value.(map[string]interface{}) + result, _ = source.Value.(map[string]any) resultSet = true } @@ -133,7 +133,7 @@ func (r *DiffFieldReader) readMap( return FieldReadResult{}, nil } - var resultVal interface{} + var resultVal any if resultSet { resultVal = result } diff --git a/staging/terraform/legacy/helper/schema/field_reader_diff_test.go b/staging/terraform/legacy/helper/schema/field_reader_diff_test.go index 441059f..06626fe 100644 --- a/staging/terraform/legacy/helper/schema/field_reader_diff_test.go +++ b/staging/terraform/legacy/helper/schema/field_reader_diff_test.go @@ -15,8 +15,8 @@ func TestDiffFieldReader_impl(t *testing.T) { } func TestDiffFieldReader_NestedSetUpdate(t *testing.T) { - hashFn := func(a interface{}) int { - m := a.(map[string]interface{}) + hashFn := func(a any) int { + m := a.(map[string]any) return m["val"].(int) } @@ -100,11 +100,11 @@ func TestDiffFieldReader_NestedSetUpdate(t *testing.T) { } s := &Set{F: hashFn} - s.Add(map[string]interface{}{"val": 1}) + s.Add(map[string]any{"val": 1}) expected := s.List() - l := out.Value.([]interface{}) - i := l[0].(map[string]interface{}) + l := out.Value.([]any) + i := l[0].(map[string]any) actual := i["nested_set"].(*Set).List() if !reflect.DeepEqual(expected, actual) { @@ -147,7 +147,7 @@ func TestDiffFieldReader_MapHandling(t *testing.T) { t.Fatalf("ReadField failed: %#v", err) } - expected := map[string]interface{}{ + expected := map[string]any{ "foo": "bar", "baz": "qux", } @@ -186,8 +186,8 @@ func TestDiffFieldReader_extra(t *testing.T) { }, }, }, - Set: func(a interface{}) int { - m := a.(map[string]interface{}) + Set: func(a any) int { + m := a.(map[string]any) return m["index"].(int) }, }, @@ -208,8 +208,8 @@ func TestDiffFieldReader_extra(t *testing.T) { }, }, }, - Set: func(a interface{}) int { - m := a.(map[string]interface{}) + Set: func(a any) int { + m := a.(map[string]any) return m["index"].(int) }, }, @@ -287,11 +287,11 @@ func TestDiffFieldReader_extra(t *testing.T) { "listMapRemoval": { []string{"listMap"}, FieldReadResult{ - Value: []interface{}{ - map[string]interface{}{ + Value: []any{ + map[string]any{ "foo": "bar", }, - map[string]interface{}{ + map[string]any{ "baz": "baz", }, }, @@ -303,7 +303,7 @@ func TestDiffFieldReader_extra(t *testing.T) { "mapRemove": { []string{"mapRemove"}, FieldReadResult{ - Value: map[string]interface{}{ + Value: map[string]any{ "foo": "bar", }, Exists: true, @@ -315,8 +315,8 @@ func TestDiffFieldReader_extra(t *testing.T) { "setChange": { []string{"setChange"}, FieldReadResult{ - Value: []interface{}{ - map[string]interface{}{ + Value: []any{ + map[string]any{ "index": 10, "value": "80", }, @@ -329,7 +329,7 @@ func TestDiffFieldReader_extra(t *testing.T) { "setEmpty": { []string{"setEmpty"}, FieldReadResult{ - Value: []interface{}{}, + Value: []any{}, Exists: true, }, false, diff --git a/staging/terraform/legacy/helper/schema/field_reader_map.go b/staging/terraform/legacy/helper/schema/field_reader_map.go index 0a96a24..9dfd285 100644 --- a/staging/terraform/legacy/helper/schema/field_reader_map.go +++ b/staging/terraform/legacy/helper/schema/field_reader_map.go @@ -40,7 +40,7 @@ func (r *MapFieldReader) ReadField(address []string) (FieldReadResult, error) { } func (r *MapFieldReader) readMap(k string, schema *Schema) (FieldReadResult, error) { - result := make(map[string]interface{}) + result := make(map[string]any) resultSet := false // If the name of the map field is directly in the map with an @@ -69,7 +69,7 @@ func (r *MapFieldReader) readMap(k string, schema *Schema) (FieldReadResult, err return FieldReadResult{}, nil } - var resultVal interface{} + var resultVal any if resultSet { resultVal = result } diff --git a/staging/terraform/legacy/helper/schema/field_reader_map_test.go b/staging/terraform/legacy/helper/schema/field_reader_map_test.go index f3df889..9fea826 100644 --- a/staging/terraform/legacy/helper/schema/field_reader_map_test.go +++ b/staging/terraform/legacy/helper/schema/field_reader_map_test.go @@ -80,14 +80,14 @@ func TestMapFieldReader_extra(t *testing.T) { cases := map[string]struct { Addr []string - Out interface{} + Out any OutOk bool OutComputed bool OutErr bool }{ "mapDel": { []string{"mapDel"}, - map[string]interface{}{}, + map[string]any{}, true, false, false, @@ -95,7 +95,7 @@ func TestMapFieldReader_extra(t *testing.T) { "mapEmpty": { []string{"mapEmpty"}, - map[string]interface{}{}, + map[string]any{}, true, false, false, diff --git a/staging/terraform/legacy/helper/schema/field_reader_multi_test.go b/staging/terraform/legacy/helper/schema/field_reader_multi_test.go index f719e60..b13da70 100644 --- a/staging/terraform/legacy/helper/schema/field_reader_multi_test.go +++ b/staging/terraform/legacy/helper/schema/field_reader_multi_test.go @@ -208,11 +208,11 @@ func TestMultiLevelFieldReaderReadFieldMerge(t *testing.T) { }, Result: FieldReadResult{ - Value: []interface{}{ - map[string]interface{}{ + Value: []any{ + map[string]any{ "foo": "bar", }, - map[string]interface{}{ + map[string]any{ "bar": "baz", }, }, diff --git a/staging/terraform/legacy/helper/schema/field_reader_test.go b/staging/terraform/legacy/helper/schema/field_reader_test.go index 4c5060f..c59f979 100644 --- a/staging/terraform/legacy/helper/schema/field_reader_test.go +++ b/staging/terraform/legacy/helper/schema/field_reader_test.go @@ -94,7 +94,7 @@ func TestAddrToSchema(t *testing.T) { "set": &Schema{ Type: TypeSet, Elem: &Schema{Type: TypeInt}, - Set: func(a interface{}) int { + Set: func(a any) int { return a.(int) }, }, @@ -108,7 +108,7 @@ func TestAddrToSchema(t *testing.T) { "set": &Schema{ Type: TypeSet, Elem: &Schema{Type: TypeInt}, - Set: func(a interface{}) int { + Set: func(a any) int { return a.(int) }, }, @@ -122,7 +122,7 @@ func TestAddrToSchema(t *testing.T) { "set": &Schema{ Type: TypeSet, Elem: &Schema{Type: TypeInt}, - Set: func(a interface{}) int { + Set: func(a any) int { return a.(int) }, }, @@ -164,8 +164,8 @@ func TestAddrToSchema(t *testing.T) { "value": &Schema{Type: TypeString}, }, }, - Set: func(a interface{}) int { - return a.(map[string]interface{})["index"].(int) + Set: func(a any) int { + return a.(map[string]any)["index"].(int) }, }, }, @@ -238,7 +238,7 @@ func testFieldReader(t *testing.T, f func(map[string]*Schema) FieldReader) { "set": &Schema{ Type: TypeSet, Elem: &Schema{Type: TypeInt}, - Set: func(a interface{}) int { + Set: func(a any) int { return a.(int) }, }, @@ -250,14 +250,14 @@ func testFieldReader(t *testing.T, f func(map[string]*Schema) FieldReader) { "value": &Schema{Type: TypeString}, }, }, - Set: func(a interface{}) int { - return a.(map[string]interface{})["index"].(int) + Set: func(a any) int { + return a.(map[string]any)["index"].(int) }, }, "setEmpty": &Schema{ Type: TypeSet, Elem: &Schema{Type: TypeInt}, - Set: func(a interface{}) int { + Set: func(a any) int { return a.(int) }, }, @@ -321,7 +321,7 @@ func testFieldReader(t *testing.T, f func(map[string]*Schema) FieldReader) { "list": { []string{"list"}, FieldReadResult{ - Value: []interface{}{ + Value: []any{ "foo", "bar", }, @@ -334,7 +334,7 @@ func testFieldReader(t *testing.T, f func(map[string]*Schema) FieldReader) { "listInt": { []string{"listInt"}, FieldReadResult{ - Value: []interface{}{ + Value: []any{ 21, 42, }, @@ -347,7 +347,7 @@ func testFieldReader(t *testing.T, f func(map[string]*Schema) FieldReader) { "map": { []string{"map"}, FieldReadResult{ - Value: map[string]interface{}{ + Value: map[string]any{ "foo": "bar", "bar": "baz", }, @@ -360,7 +360,7 @@ func testFieldReader(t *testing.T, f func(map[string]*Schema) FieldReader) { "mapInt": { []string{"mapInt"}, FieldReadResult{ - Value: map[string]interface{}{ + Value: map[string]any{ "one": 1, "two": 2, }, @@ -373,7 +373,7 @@ func testFieldReader(t *testing.T, f func(map[string]*Schema) FieldReader) { "mapIntNestedSchema": { []string{"mapIntNestedSchema"}, FieldReadResult{ - Value: map[string]interface{}{ + Value: map[string]any{ "one": 1, "two": 2, }, @@ -386,7 +386,7 @@ func testFieldReader(t *testing.T, f func(map[string]*Schema) FieldReader) { "mapFloat": { []string{"mapFloat"}, FieldReadResult{ - Value: map[string]interface{}{ + Value: map[string]any{ "oneDotTwo": 1.2, }, Exists: true, @@ -398,7 +398,7 @@ func testFieldReader(t *testing.T, f func(map[string]*Schema) FieldReader) { "mapBool": { []string{"mapBool"}, FieldReadResult{ - Value: map[string]interface{}{ + Value: map[string]any{ "True": true, "False": false, }, @@ -421,7 +421,7 @@ func testFieldReader(t *testing.T, f func(map[string]*Schema) FieldReader) { "set": { []string{"set"}, FieldReadResult{ - Value: []interface{}{10, 50}, + Value: []any{10, 50}, Exists: true, Computed: false, }, @@ -431,12 +431,12 @@ func testFieldReader(t *testing.T, f func(map[string]*Schema) FieldReader) { "setDeep": { []string{"setDeep"}, FieldReadResult{ - Value: []interface{}{ - map[string]interface{}{ + Value: []any{ + map[string]any{ "index": 10, "value": "foo", }, - map[string]interface{}{ + map[string]any{ "index": 50, "value": "bar", }, @@ -450,7 +450,7 @@ func testFieldReader(t *testing.T, f func(map[string]*Schema) FieldReader) { "setEmpty": { []string{"setEmpty"}, FieldReadResult{ - Value: []interface{}{}, + Value: []any{}, Exists: false, }, false, diff --git a/staging/terraform/legacy/helper/schema/field_writer.go b/staging/terraform/legacy/helper/schema/field_writer.go index be4fae5..c54d8e8 100644 --- a/staging/terraform/legacy/helper/schema/field_writer.go +++ b/staging/terraform/legacy/helper/schema/field_writer.go @@ -7,5 +7,5 @@ package schema // a proper typed representation. ResourceData uses this to write new data // into existing sources. type FieldWriter interface { - WriteField([]string, interface{}) error + WriteField([]string, any) error } diff --git a/staging/terraform/legacy/helper/schema/field_writer_map.go b/staging/terraform/legacy/helper/schema/field_writer_map.go index f022b18..f282030 100644 --- a/staging/terraform/legacy/helper/schema/field_writer_map.go +++ b/staging/terraform/legacy/helper/schema/field_writer_map.go @@ -55,7 +55,7 @@ func (w *MapFieldWriter) clearTree(addr []string) { } } -func (w *MapFieldWriter) WriteField(addr []string, value interface{}) error { +func (w *MapFieldWriter) WriteField(addr []string, value any) error { w.lock.Lock() defer w.lock.Unlock() if w.result == nil { @@ -92,7 +92,7 @@ func (w *MapFieldWriter) WriteField(addr []string, value interface{}) error { return w.set(addr, value) } -func (w *MapFieldWriter) set(addr []string, value interface{}) error { +func (w *MapFieldWriter) set(addr []string, value any) error { schemaList := addrToSchema(addr, w.Schema) if len(schemaList) == 0 { return fmt.Errorf("Invalid address to set: %#v", addr) @@ -117,16 +117,16 @@ func (w *MapFieldWriter) set(addr []string, value interface{}) error { func (w *MapFieldWriter) setList( addr []string, - v interface{}, + v any, schema *Schema) error { k := strings.Join(addr, ".") - setElement := func(idx string, value interface{}) error { + setElement := func(idx string, value any) error { addrCopy := make([]string, len(addr), len(addr)+1) copy(addrCopy, addr) return w.set(append(addrCopy, idx), value) } - var vs []interface{} + var vs []any if err := mapstructure.Decode(v, &vs); err != nil { return fmt.Errorf("%s: %s", k, err) } @@ -163,11 +163,11 @@ func (w *MapFieldWriter) setList( func (w *MapFieldWriter) setMap( addr []string, - value interface{}, + value any, schema *Schema) error { k := strings.Join(addr, ".") v := reflect.ValueOf(value) - vs := make(map[string]interface{}) + vs := make(map[string]any) if value == nil { // The empty string here means the map is removed. @@ -210,10 +210,10 @@ func (w *MapFieldWriter) setMap( func (w *MapFieldWriter) setObject( addr []string, - value interface{}, + value any, schema *Schema) error { // Set the entire object. First decode into a proper structure - var v map[string]interface{} + var v map[string]any if err := mapstructure.Decode(value, &v); err != nil { return fmt.Errorf("%s: %s", strings.Join(addr, "."), err) } @@ -240,7 +240,7 @@ func (w *MapFieldWriter) setObject( func (w *MapFieldWriter) setPrimitive( addr []string, - v interface{}, + v any, schema *Schema) error { k := strings.Join(addr, ".") @@ -285,7 +285,7 @@ func (w *MapFieldWriter) setPrimitive( func (w *MapFieldWriter) setSet( addr []string, - value interface{}, + value any, schema *Schema) error { addrCopy := make([]string, len(addr), len(addr)+1) copy(addrCopy, addr) diff --git a/staging/terraform/legacy/helper/schema/field_writer_map_test.go b/staging/terraform/legacy/helper/schema/field_writer_map_test.go index db0b711..69e416c 100644 --- a/staging/terraform/legacy/helper/schema/field_writer_map_test.go +++ b/staging/terraform/legacy/helper/schema/field_writer_map_test.go @@ -42,7 +42,7 @@ func TestMapFieldWriter(t *testing.T) { "set": &Schema{ Type: TypeSet, Elem: &Schema{Type: TypeInt}, - Set: func(a interface{}) int { + Set: func(a any) int { return a.(int) }, }, @@ -54,15 +54,15 @@ func TestMapFieldWriter(t *testing.T) { "value": &Schema{Type: TypeString}, }, }, - Set: func(a interface{}) int { - return a.(map[string]interface{})["index"].(int) + Set: func(a any) int { + return a.(map[string]any)["index"].(int) }, }, } cases := map[string]struct { Addr []string - Value interface{} + Value any Err bool Out map[string]string }{ @@ -111,8 +111,8 @@ func TestMapFieldWriter(t *testing.T) { "list of resources": { []string{"listResource"}, - []interface{}{ - map[string]interface{}{ + []any{ + map[string]any{ "value": 80, }, }, @@ -125,7 +125,7 @@ func TestMapFieldWriter(t *testing.T) { "list of resources empty": { []string{"listResource"}, - []interface{}{}, + []any{}, false, map[string]string{ "listResource.#": "0", @@ -143,7 +143,7 @@ func TestMapFieldWriter(t *testing.T) { "list of strings": { []string{"list"}, - []interface{}{"foo", "bar"}, + []any{"foo", "bar"}, false, map[string]string{ "list.#": "2", @@ -161,7 +161,7 @@ func TestMapFieldWriter(t *testing.T) { "map": { []string{"map"}, - map[string]interface{}{"foo": "bar"}, + map[string]any{"foo": "bar"}, false, map[string]string{ "map.%": "1", @@ -187,7 +187,7 @@ func TestMapFieldWriter(t *testing.T) { "set": { []string{"set"}, - []interface{}{1, 2, 5}, + []any{1, 2, 5}, false, map[string]string{ "set.#": "3", @@ -217,12 +217,12 @@ func TestMapFieldWriter(t *testing.T) { "set resource": { []string{"setDeep"}, - []interface{}{ - map[string]interface{}{ + []any{ + map[string]any{ "index": 10, "value": "foo", }, - map[string]interface{}{ + map[string]any{ "index": 50, "value": "bar", }, @@ -246,9 +246,9 @@ func TestMapFieldWriter(t *testing.T) { "full object": { nil, - map[string]interface{}{ + map[string]any{ "string": "foo", - "list": []interface{}{"foo", "bar"}, + "list": []any{"foo", "bar"}, }, false, map[string]string{ @@ -284,25 +284,25 @@ func TestMapFieldWriterCleanSet(t *testing.T) { "value": &Schema{Type: TypeString}, }, }, - Set: func(a interface{}) int { - return a.(map[string]interface{})["index"].(int) + Set: func(a any) int { + return a.(map[string]any)["index"].(int) }, }, } values := []struct { Addr []string - Value interface{} + Value any Out map[string]string }{ { []string{"setDeep"}, - []interface{}{ - map[string]interface{}{ + []any{ + map[string]any{ "index": 10, "value": "foo", }, - map[string]interface{}{ + map[string]any{ "index": 50, "value": "bar", }, @@ -317,12 +317,12 @@ func TestMapFieldWriterCleanSet(t *testing.T) { }, { []string{"setDeep"}, - []interface{}{ - map[string]interface{}{ + []any{ + map[string]any{ "index": 20, "value": "baz", }, - map[string]interface{}{ + map[string]any{ "index": 60, "value": "qux", }, @@ -337,12 +337,12 @@ func TestMapFieldWriterCleanSet(t *testing.T) { }, { []string{"setDeep"}, - []interface{}{ - map[string]interface{}{ + []any{ + map[string]any{ "index": 30, "value": "one", }, - map[string]interface{}{ + map[string]any{ "index": 70, "value": "two", }, @@ -387,26 +387,26 @@ func TestMapFieldWriterCleanList(t *testing.T) { values := []struct { Addr []string - Value interface{} + Value any Out map[string]string }{ { // Base list []string{"listDeep"}, - []interface{}{ - map[string]interface{}{ + []any{ + map[string]any{ "thing1": "a", "thing2": "b", }, - map[string]interface{}{ + map[string]any{ "thing1": "c", "thing2": "d", }, - map[string]interface{}{ + map[string]any{ "thing1": "e", "thing2": "f", }, - map[string]interface{}{ + map[string]any{ "thing1": "g", "thing2": "h", }, @@ -426,16 +426,16 @@ func TestMapFieldWriterCleanList(t *testing.T) { { // Remove an element []string{"listDeep"}, - []interface{}{ - map[string]interface{}{ + []any{ + map[string]any{ "thing1": "a", "thing2": "b", }, - map[string]interface{}{ + map[string]any{ "thing1": "c", "thing2": "d", }, - map[string]interface{}{ + map[string]any{ "thing1": "e", "thing2": "f", }, @@ -456,14 +456,14 @@ func TestMapFieldWriterCleanList(t *testing.T) { // brevity we want to make sure that what exists in the writer is exactly // what the last write looked like coming from the provider. []string{"listDeep"}, - []interface{}{ - map[string]interface{}{ + []any{ + map[string]any{ "thing1": "a", }, - map[string]interface{}{ + map[string]any{ "thing1": "c", }, - map[string]interface{}{ + map[string]any{ "thing1": "e", }, }, @@ -499,12 +499,12 @@ func TestMapFieldWriterCleanMap(t *testing.T) { } values := []struct { - Value interface{} + Value any Out map[string]string }{ { // Base map - map[string]interface{}{ + map[string]any{ "thing1": "a", "thing2": "b", "thing3": "c", @@ -520,7 +520,7 @@ func TestMapFieldWriterCleanMap(t *testing.T) { }, { // Base map - map[string]interface{}{ + map[string]any{ "thing1": "a", "thing2": "b", "thing4": "d", diff --git a/staging/terraform/legacy/helper/schema/provider.go b/staging/terraform/legacy/helper/schema/provider.go index 6e7035c..19dbee1 100644 --- a/staging/terraform/legacy/helper/schema/provider.go +++ b/staging/terraform/legacy/helper/schema/provider.go @@ -72,7 +72,7 @@ type Provider struct { // the provider. MetaReset func() error - meta interface{} + meta any // a mutex is required because TestReset can directly replace the stopCtx stopMu sync.Mutex @@ -89,7 +89,7 @@ type Provider struct { // the subsequent resources as the meta parameter. This return value is // usually used to pass along a configured API client, a configuration // structure, etc. -type ConfigureFunc func(*ResourceData) (interface{}, error) +type ConfigureFunc func(*ResourceData) (any, error) // InternalValidate should be called to validate the structure // of the provider. @@ -141,14 +141,14 @@ func isReservedProviderFieldName(name string) bool { // Meta returns the metadata associated with this provider that was // returned by the Configure call. It will be nil until Configure is called. -func (p *Provider) Meta() interface{} { +func (p *Provider) Meta() any { return p.meta } // SetMeta can be used to forcefully set the Meta object of the provider. // Note that if Configure is called the return value will override anything // set here. -func (p *Provider) SetMeta(v interface{}) { +func (p *Provider) SetMeta(v any) { p.meta = v } diff --git a/staging/terraform/legacy/helper/schema/provider_test.go b/staging/terraform/legacy/helper/schema/provider_test.go index 8ed0830..ace4866 100644 --- a/staging/terraform/legacy/helper/schema/provider_test.go +++ b/staging/terraform/legacy/helper/schema/provider_test.go @@ -102,7 +102,7 @@ func TestProviderGetSchema(t *testing.T) { func TestProviderConfigure(t *testing.T) { cases := []struct { P *Provider - Config map[string]interface{} + Config map[string]any Err bool }{ { @@ -120,7 +120,7 @@ func TestProviderConfigure(t *testing.T) { }, }, - ConfigureFunc: func(d *ResourceData) (interface{}, error) { + ConfigureFunc: func(d *ResourceData) (any, error) { if d.Get("foo").(int) == 42 { return nil, nil } @@ -128,7 +128,7 @@ func TestProviderConfigure(t *testing.T) { return nil, fmt.Errorf("nope") }, }, - Config: map[string]interface{}{ + Config: map[string]any{ "foo": 42, }, Err: false, @@ -143,7 +143,7 @@ func TestProviderConfigure(t *testing.T) { }, }, - ConfigureFunc: func(d *ResourceData) (interface{}, error) { + ConfigureFunc: func(d *ResourceData) (any, error) { if d.Get("foo").(int) == 42 { return nil, nil } @@ -151,7 +151,7 @@ func TestProviderConfigure(t *testing.T) { return nil, fmt.Errorf("nope") }, }, - Config: map[string]interface{}{ + Config: map[string]any{ "foo": 52, }, Err: true, @@ -249,7 +249,7 @@ func TestProviderDataSources(t *testing.T) { func TestProviderValidate(t *testing.T) { cases := []struct { P *Provider - Config map[string]interface{} + Config map[string]any Err bool }{ { @@ -289,10 +289,10 @@ func TestProviderDiff_legacyTimeoutType(t *testing.T) { }, } - invalidCfg := map[string]interface{}{ + invalidCfg := map[string]any{ "foo": 42, - "timeouts": []interface{}{ - map[string]interface{}{ + "timeouts": []any{ + map[string]any{ "create": "40m", }, }, @@ -327,9 +327,9 @@ func TestProviderDiff_timeoutInvalidValue(t *testing.T) { }, } - invalidCfg := map[string]interface{}{ + invalidCfg := map[string]any{ "foo": 42, - "timeouts": map[string]interface{}{ + "timeouts": map[string]any{ "create": "invalid", }, } @@ -356,7 +356,7 @@ func TestProviderValidateResource(t *testing.T) { cases := []struct { P *Provider Type string - Config map[string]interface{} + Config map[string]any Err bool }{ { @@ -413,7 +413,7 @@ func TestProviderImportState_default(t *testing.T) { func TestProviderImportState_setsId(t *testing.T) { var val string - stateFunc := func(d *ResourceData, meta interface{}) ([]*ResourceData, error) { + stateFunc := func(d *ResourceData, meta any) ([]*ResourceData, error) { val = d.Id() return []*ResourceData{d}, nil } @@ -442,7 +442,7 @@ func TestProviderImportState_setsId(t *testing.T) { func TestProviderImportState_setsType(t *testing.T) { var tVal string - stateFunc := func(d *ResourceData, meta interface{}) ([]*ResourceData, error) { + stateFunc := func(d *ResourceData, meta any) ([]*ResourceData, error) { d.SetId("foo") tVal = d.State().Ephemeral.Type return []*ResourceData{d}, nil diff --git a/staging/terraform/legacy/helper/schema/provisioner.go b/staging/terraform/legacy/helper/schema/provisioner.go index ba49020..41da118 100644 --- a/staging/terraform/legacy/helper/schema/provisioner.go +++ b/staging/terraform/legacy/helper/schema/provisioner.go @@ -141,7 +141,7 @@ func (p *Provisioner) Apply( // terraform.ResourceConfig so that we can use that type to more // easily build a ResourceData structure. We do this by simply treating // the conn info as configuration input. - raw := make(map[string]interface{}) + raw := make(map[string]any) if s != nil { for k, v := range s.Ephemeral.ConnInfo { raw[k] = v diff --git a/staging/terraform/legacy/helper/schema/provisioner_test.go b/staging/terraform/legacy/helper/schema/provisioner_test.go index ea2d7aa..6c8a2ec 100644 --- a/staging/terraform/legacy/helper/schema/provisioner_test.go +++ b/staging/terraform/legacy/helper/schema/provisioner_test.go @@ -25,7 +25,7 @@ func TestProvisionerValidate(t *testing.T) { cases := []struct { Name string P *Provisioner - Config map[string]interface{} + Config map[string]any Err bool Warns []string }{ @@ -73,7 +73,7 @@ func TestProvisionerValidate(t *testing.T) { }, ApplyFunc: noopApply, }, - map[string]interface{}{ + map[string]any{ "foo": "bar", }, false, @@ -86,7 +86,7 @@ func TestProvisionerValidate(t *testing.T) { "foo": { Type: TypeString, Optional: true, - ValidateFunc: func(v interface{}, k string) (ws []string, errors []error) { + ValidateFunc: func(v any, k string) (ws []string, errors []error) { ws = append(ws, "Simple warning from property validation") return }, @@ -94,7 +94,7 @@ func TestProvisionerValidate(t *testing.T) { }, ApplyFunc: noopApply, }, - Config: map[string]interface{}{ + Config: map[string]any{ "foo": "", }, Err: false, @@ -144,7 +144,7 @@ func TestProvisionerApply(t *testing.T) { Name string P *Provisioner Conn map[string]string - Config map[string]interface{} + Config map[string]any Err bool }{ { @@ -180,7 +180,7 @@ func TestProvisionerApply(t *testing.T) { map[string]string{ "foo": "bar", }, - map[string]interface{}{ + map[string]any{ "foo": 42, }, false, @@ -226,7 +226,7 @@ func TestProvisionerApply_nilState(t *testing.T) { }, } - conf := map[string]interface{}{ + conf := map[string]any{ "foo": 42, } @@ -286,7 +286,7 @@ func TestProvisionerStop_apply(t *testing.T) { "foo": "bar", } - conf := map[string]interface{}{ + conf := map[string]any{ "foo": 42, } diff --git a/staging/terraform/legacy/helper/schema/resource.go b/staging/terraform/legacy/helper/schema/resource.go index 971e32c..a4b9647 100644 --- a/staging/terraform/legacy/helper/schema/resource.go +++ b/staging/terraform/legacy/helper/schema/resource.go @@ -199,23 +199,23 @@ func (r *Resource) ShimInstanceStateFromValue(state cty.Value) (*terraform.Insta } // See Resource documentation. -type CreateFunc func(*ResourceData, interface{}) error +type CreateFunc func(*ResourceData, any) error // See Resource documentation. -type ReadFunc func(*ResourceData, interface{}) error +type ReadFunc func(*ResourceData, any) error // See Resource documentation. -type UpdateFunc func(*ResourceData, interface{}) error +type UpdateFunc func(*ResourceData, any) error // See Resource documentation. -type DeleteFunc func(*ResourceData, interface{}) error +type DeleteFunc func(*ResourceData, any) error // See Resource documentation. -type ExistsFunc func(*ResourceData, interface{}) (bool, error) +type ExistsFunc func(*ResourceData, any) (bool, error) // See Resource documentation. type StateMigrateFunc func( - int, *terraform.InstanceState, interface{}) (*terraform.InstanceState, error) + int, *terraform.InstanceState, any) (*terraform.InstanceState, error) type StateUpgrader struct { // Version is the version schema that this Upgrader will handle, converting @@ -236,16 +236,16 @@ type StateUpgrader struct { } // See StateUpgrader -type StateUpgradeFunc func(rawState map[string]interface{}, meta interface{}) (map[string]interface{}, error) +type StateUpgradeFunc func(rawState map[string]any, meta any) (map[string]any, error) // See Resource documentation. -type CustomizeDiffFunc func(*ResourceDiff, interface{}) error +type CustomizeDiffFunc func(*ResourceDiff, any) error // Apply creates, updates, and/or deletes a resource. func (r *Resource) Apply( s *terraform.InstanceState, d *terraform.InstanceDiff, - meta interface{}) (*terraform.InstanceState, error) { + meta any) (*terraform.InstanceState, error) { data, err := schemaMap(r.Schema).Data(s, d) if err != nil { return s, err @@ -324,7 +324,7 @@ func (r *Resource) Apply( func (r *Resource) Diff( s *terraform.InstanceState, c *terraform.ResourceConfig, - meta interface{}) (*terraform.InstanceDiff, error) { + meta any) (*terraform.InstanceDiff, error) { t := &ResourceTimeout{} err := t.ConfigDecode(r, c) @@ -352,7 +352,7 @@ func (r *Resource) Diff( func (r *Resource) simpleDiff( s *terraform.InstanceState, c *terraform.ResourceConfig, - meta interface{}) (*terraform.InstanceDiff, error) { + meta any) (*terraform.InstanceDiff, error) { instanceDiff, err := schemaMap(r.Schema).Diff(s, c, r.CustomizeDiff, meta, false) if err != nil { @@ -392,7 +392,7 @@ func (r *Resource) Validate(c *terraform.ResourceConfig) ([]string, []error) { // describes the configuration arguments and desired computed attributes. func (r *Resource) ReadDataApply( d *terraform.InstanceDiff, - meta interface{}, + meta any, ) (*terraform.InstanceState, error) { // Data sources are always built completely from scratch // on each read, so the source state is always nil. @@ -420,7 +420,7 @@ func (r *Resource) ReadDataApply( // RefreshWithoutUpgrade is part of the new plugin shims. func (r *Resource) RefreshWithoutUpgrade( s *terraform.InstanceState, - meta interface{}) (*terraform.InstanceState, error) { + meta any) (*terraform.InstanceState, error) { // If the ID is already somehow blank, it doesn't exist if s.ID == "" { return nil, nil @@ -478,7 +478,7 @@ func (r *Resource) RefreshWithoutUpgrade( // Refresh refreshes the state of the resource. func (r *Resource) Refresh( s *terraform.InstanceState, - meta interface{}) (*terraform.InstanceState, error) { + meta any) (*terraform.InstanceState, error) { // If the ID is already somehow blank, it doesn't exist if s.ID == "" { return nil, nil @@ -531,7 +531,7 @@ func (r *Resource) Refresh( return r.recordCurrentSchemaVersion(state), err } -func (r *Resource) upgradeState(s *terraform.InstanceState, meta interface{}) (*terraform.InstanceState, error) { +func (r *Resource) upgradeState(s *terraform.InstanceState, meta any) (*terraform.InstanceState, error) { var err error needsMigration, stateSchemaVersion := r.checkSchemaVersion(s) @@ -760,7 +760,7 @@ func (r *Resource) Data(s *terraform.InstanceState) *ResourceData { } // Set the schema version to latest by default - result.meta = map[string]interface{}{ + result.meta = map[string]any{ "schema_version": strconv.Itoa(r.SchemaVersion), } @@ -823,7 +823,7 @@ func (r *Resource) recordCurrentSchemaVersion( state *terraform.InstanceState) *terraform.InstanceState { if state != nil && r.SchemaVersion > 0 { if state.Meta == nil { - state.Meta = make(map[string]interface{}) + state.Meta = make(map[string]any) } state.Meta["schema_version"] = strconv.Itoa(r.SchemaVersion) } @@ -832,14 +832,14 @@ func (r *Resource) recordCurrentSchemaVersion( // Noop is a convenience implementation of resource function which takes // no action and returns no error. -func Noop(*ResourceData, interface{}) error { +func Noop(*ResourceData, any) error { return nil } // RemoveFromState is a convenience implementation of a resource function // which sets the resource ID to empty string (to remove it from state) // and returns no error. -func RemoveFromState(d *ResourceData, _ interface{}) error { +func RemoveFromState(d *ResourceData, _ any) error { d.SetId("") return nil } diff --git a/staging/terraform/legacy/helper/schema/resource_data.go b/staging/terraform/legacy/helper/schema/resource_data.go index 7ed2591..686a741 100644 --- a/staging/terraform/legacy/helper/schema/resource_data.go +++ b/staging/terraform/legacy/helper/schema/resource_data.go @@ -29,7 +29,7 @@ type ResourceData struct { config *terraform.ResourceConfig state *terraform.InstanceState diff *terraform.InstanceDiff - meta map[string]interface{} + meta map[string]any timeouts *ResourceTimeout providerMeta cty.Value @@ -48,8 +48,8 @@ type ResourceData struct { // getResult is the internal structure that is generated when a Get // is called that contains some extra data that might be used. type getResult struct { - Value interface{} - ValueProcessed interface{} + Value any + ValueProcessed any Computed bool Exists bool Schema *Schema @@ -75,7 +75,7 @@ func (d *ResourceData) UnsafeSetFieldRaw(key string, value string) { // // If you want to test if something is set at all in the configuration, // use GetOk. -func (d *ResourceData) Get(key string) interface{} { +func (d *ResourceData) Get(key string) any { v, _ := d.GetOk(key) return v } @@ -86,7 +86,7 @@ func (d *ResourceData) Get(key string) interface{} { // that both the old and new value are the same if the old value was not // set and the new value is. This is common, for example, for boolean // fields which have a zero value of false. -func (d *ResourceData) GetChange(key string) (interface{}, interface{}) { +func (d *ResourceData) GetChange(key string) (any, any) { o, n := d.getChange(key, getSourceState, getSourceDiff) return o.Value, n.Value } @@ -96,7 +96,7 @@ func (d *ResourceData) GetChange(key string) (interface{}, interface{}) { // // The first result will not necessarilly be nil if the value doesn't exist. // The second result should be checked to determine this information. -func (d *ResourceData) GetOk(key string) (interface{}, bool) { +func (d *ResourceData) GetOk(key string) (any, bool) { r := d.getRaw(key, getSourceSet) exists := r.Exists && !r.Computed if exists { @@ -124,7 +124,7 @@ func (d *ResourceData) GetOk(key string) (interface{}, bool) { // without a default, to fully check for a literal assignment, regardless // of the zero-value for that type. // This should only be used if absolutely required/needed. -func (d *ResourceData) GetOkExists(key string) (interface{}, bool) { +func (d *ResourceData) GetOkExists(key string) (any, bool) { r := d.getRaw(key, getSourceSet) exists := r.Exists && !r.Computed return r.Value, exists @@ -173,7 +173,7 @@ func (d *ResourceData) Partial(on bool) { // // If the key is invalid or the value is not a correct type, an error // will be returned. -func (d *ResourceData) Set(key string, value interface{}) error { +func (d *ResourceData) Set(key string, value any) error { d.once.Do(d.init) // If the value is a pointer to a non-struct, get its value and @@ -320,7 +320,7 @@ func (d *ResourceData) State() *terraform.InstanceState { // In order to build the final state attributes, we read the full // attribute set as a map[string]interface{}, write it to a MapFieldWriter, // and then use that map. - rawMap := make(map[string]interface{}) + rawMap := make(map[string]any) for k := range d.schema { source := getSourceSet if d.partial { @@ -478,7 +478,7 @@ func (d *ResourceData) init() { } func (d *ResourceData) diffChange( - k string) (interface{}, interface{}, bool, bool, bool) { + k string) (any, any, bool, bool, bool) { // Get the change between the state and the config. o, n := d.getChange(k, getSourceState, getSourceConfig|getSourceExact) if !o.Exists { @@ -556,7 +556,7 @@ func (d *ResourceData) get(addr []string, source getSource) getResult { } } -func (d *ResourceData) GetProviderMeta(dst interface{}) error { +func (d *ResourceData) GetProviderMeta(dst any) error { if d.providerMeta.IsNull() { return nil } diff --git a/staging/terraform/legacy/helper/schema/resource_data_test.go b/staging/terraform/legacy/helper/schema/resource_data_test.go index d1b5913..b19493b 100644 --- a/staging/terraform/legacy/helper/schema/resource_data_test.go +++ b/staging/terraform/legacy/helper/schema/resource_data_test.go @@ -20,7 +20,7 @@ func TestResourceDataGet(t *testing.T) { State *terraform.InstanceState Diff *terraform.InstanceDiff Key string - Value interface{} + Value any }{ // #0 { @@ -269,7 +269,7 @@ func TestResourceDataGet(t *testing.T) { Key: "ports", - Value: []interface{}{1, 2, 5}, + Value: []any{1, 2, 5}, }, // #10 @@ -306,7 +306,7 @@ func TestResourceDataGet(t *testing.T) { Key: "ingress.0", - Value: map[string]interface{}{ + Value: map[string]any{ "from": 8080, }, }, @@ -345,8 +345,8 @@ func TestResourceDataGet(t *testing.T) { Key: "ingress", - Value: []interface{}{ - map[string]interface{}{ + Value: []any{ + map[string]any{ "from": 8080, }, }, @@ -397,7 +397,7 @@ func TestResourceDataGet(t *testing.T) { Key: "", - Value: map[string]interface{}{ + Value: map[string]any{ "availability_zone": "foo", }, }, @@ -436,11 +436,11 @@ func TestResourceDataGet(t *testing.T) { Key: "config_vars", - Value: []interface{}{ - map[string]interface{}{ + Value: []any{ + map[string]any{ "foo": "bar", }, - map[string]interface{}{ + map[string]any{ "bar": "baz", }, }, @@ -471,11 +471,11 @@ func TestResourceDataGet(t *testing.T) { Key: "config_vars", - Value: []interface{}{ - map[string]interface{}{ + Value: []any{ + map[string]any{ "foo": "baz", }, - map[string]interface{}{ + map[string]any{ "bar": "bar", }, }, @@ -516,7 +516,7 @@ func TestResourceDataGet(t *testing.T) { Key: "config_vars", - Value: []interface{}{}, + Value: []any{}, }, // #17 Sets @@ -527,7 +527,7 @@ func TestResourceDataGet(t *testing.T) { Optional: true, Computed: true, Elem: &Schema{Type: TypeInt}, - Set: func(a interface{}) int { + Set: func(a any) int { return a.(int) }, }, @@ -544,7 +544,7 @@ func TestResourceDataGet(t *testing.T) { Key: "ports", - Value: []interface{}{80}, + Value: []any{80}, }, // #18 @@ -566,8 +566,8 @@ func TestResourceDataGet(t *testing.T) { }, }, }, - Set: func(a interface{}) int { - m := a.(map[string]interface{}) + Set: func(a any) int { + m := a.(map[string]any) return m["index"].(int) }, }, @@ -592,8 +592,8 @@ func TestResourceDataGet(t *testing.T) { Key: "data", - Value: []interface{}{ - map[string]interface{}{ + Value: []any{ + map[string]any{ "index": 10, "value": "80", }, @@ -608,7 +608,7 @@ func TestResourceDataGet(t *testing.T) { Optional: true, Computed: true, Elem: &Schema{Type: TypeInt}, - Set: func(a interface{}) int { + Set: func(a any) int { return a.(int) }, }, @@ -620,7 +620,7 @@ func TestResourceDataGet(t *testing.T) { Key: "ports", - Value: []interface{}{}, + Value: []any{}, }, // #20 Float zero @@ -703,7 +703,7 @@ func TestResourceDataGet(t *testing.T) { Optional: true, Computed: true, Elem: &Schema{Type: TypeInt}, - Set: func(a interface{}) int { + Set: func(a any) int { return a.(int) }, }, @@ -736,7 +736,7 @@ func TestResourceDataGet(t *testing.T) { Key: "ports", - Value: []interface{}{80}, + Value: []any{80}, }, } @@ -763,8 +763,8 @@ func TestResourceDataGetChange(t *testing.T) { State *terraform.InstanceState Diff *terraform.InstanceDiff Key string - OldValue interface{} - NewValue interface{} + OldValue any + NewValue any }{ { Schema: map[string]*Schema{ @@ -849,7 +849,7 @@ func TestResourceDataGetOk(t *testing.T) { State *terraform.InstanceState Diff *terraform.InstanceDiff Key string - Value interface{} + Value any Ok bool }{ /* @@ -945,7 +945,7 @@ func TestResourceDataGetOk(t *testing.T) { Diff: nil, Key: "ports", - Value: []interface{}{}, + Value: []any{}, Ok: false, }, @@ -966,7 +966,7 @@ func TestResourceDataGetOk(t *testing.T) { Diff: nil, Key: "ports", - Value: map[string]interface{}{}, + Value: map[string]any{}, Ok: false, }, @@ -980,7 +980,7 @@ func TestResourceDataGetOk(t *testing.T) { Type: TypeSet, Optional: true, Elem: &Schema{Type: TypeInt}, - Set: func(a interface{}) int { return a.(int) }, + Set: func(a any) int { return a.(int) }, }, }, @@ -989,7 +989,7 @@ func TestResourceDataGetOk(t *testing.T) { Diff: nil, Key: "ports", - Value: []interface{}{}, + Value: []any{}, Ok: false, }, @@ -999,7 +999,7 @@ func TestResourceDataGetOk(t *testing.T) { Type: TypeSet, Optional: true, Elem: &Schema{Type: TypeInt}, - Set: func(a interface{}) int { return a.(int) }, + Set: func(a any) int { return a.(int) }, }, }, @@ -1018,7 +1018,7 @@ func TestResourceDataGetOk(t *testing.T) { Type: TypeSet, Optional: true, Elem: &Schema{Type: TypeInt}, - Set: func(a interface{}) int { return a.(int) }, + Set: func(a any) int { return a.(int) }, }, }, @@ -1034,7 +1034,7 @@ func TestResourceDataGetOk(t *testing.T) { }, Key: "ports", - Value: []interface{}{}, + Value: []any{}, Ok: false, }, @@ -1093,7 +1093,7 @@ func TestResourceDataGetOkExists(t *testing.T) { State *terraform.InstanceState Diff *terraform.InstanceDiff Key string - Value interface{} + Value any Ok bool }{ /* @@ -1193,7 +1193,7 @@ func TestResourceDataGetOkExists(t *testing.T) { Diff: nil, Key: "ports", - Value: []interface{}{}, + Value: []any{}, Ok: false, }, @@ -1215,7 +1215,7 @@ func TestResourceDataGetOkExists(t *testing.T) { Diff: nil, Key: "ports", - Value: map[string]interface{}{}, + Value: map[string]any{}, Ok: false, }, @@ -1230,7 +1230,7 @@ func TestResourceDataGetOkExists(t *testing.T) { Type: TypeSet, Optional: true, Elem: &Schema{Type: TypeInt}, - Set: func(a interface{}) int { return a.(int) }, + Set: func(a any) int { return a.(int) }, }, }, @@ -1239,7 +1239,7 @@ func TestResourceDataGetOkExists(t *testing.T) { Diff: nil, Key: "ports", - Value: []interface{}{}, + Value: []any{}, Ok: false, }, @@ -1250,7 +1250,7 @@ func TestResourceDataGetOkExists(t *testing.T) { Type: TypeSet, Optional: true, Elem: &Schema{Type: TypeInt}, - Set: func(a interface{}) int { return a.(int) }, + Set: func(a any) int { return a.(int) }, }, }, @@ -1512,7 +1512,7 @@ func TestResourceDataHasChange(t *testing.T) { Type: TypeSet, Optional: true, Elem: &Schema{Type: TypeInt}, - Set: func(a interface{}) int { return a.(int) }, + Set: func(a any) int { return a.(int) }, }, }, @@ -1544,7 +1544,7 @@ func TestResourceDataHasChange(t *testing.T) { Type: TypeSet, Optional: true, Elem: &Schema{Type: TypeInt}, - Set: func(a interface{}) int { return a.(int) }, + Set: func(a any) int { return a.(int) }, }, }, @@ -1591,14 +1591,14 @@ func TestResourceDataSet(t *testing.T) { State *terraform.InstanceState Diff *terraform.InstanceDiff Key string - Value interface{} + Value any Err bool GetKey string - GetValue interface{} + GetValue any // GetPreProcess can be set to munge the return value before being // compared to GetValue - GetPreProcess func(interface{}) interface{} + GetPreProcess func(any) any }{ // #0: Basic good { @@ -1725,7 +1725,7 @@ func TestResourceDataSet(t *testing.T) { Value: []int{1, 2, 5}, GetKey: "ports", - GetValue: []interface{}{1, 2, 5}, + GetValue: []any{1, 2, 5}, }, // #6: List of primitives, set list with error @@ -1743,11 +1743,11 @@ func TestResourceDataSet(t *testing.T) { Diff: nil, Key: "ports", - Value: []interface{}{1, "NOPE", 5}, + Value: []any{1, "NOPE", 5}, Err: true, GetKey: "ports", - GetValue: []interface{}{}, + GetValue: []any{}, }, // #7: Set a list of maps @@ -1768,22 +1768,22 @@ func TestResourceDataSet(t *testing.T) { Diff: nil, Key: "config_vars", - Value: []interface{}{ - map[string]interface{}{ + Value: []any{ + map[string]any{ "foo": "bar", }, - map[string]interface{}{ + map[string]any{ "bar": "baz", }, }, Err: false, GetKey: "config_vars", - GetValue: []interface{}{ - map[string]interface{}{ + GetValue: []any{ + map[string]any{ "foo": "bar", }, - map[string]interface{}{ + map[string]any{ "bar": "baz", }, }, @@ -1797,7 +1797,7 @@ func TestResourceDataSet(t *testing.T) { Optional: true, Computed: true, Elem: &Schema{Type: TypeInt}, - Set: func(a interface{}) int { + Set: func(a any) int { return a.(int) }, }, @@ -1813,10 +1813,10 @@ func TestResourceDataSet(t *testing.T) { }, Key: "ports", - Value: []interface{}{100, 125, 125}, + Value: []any{100, 125, 125}, GetKey: "ports", - GetValue: []interface{}{100, 125}, + GetValue: []any{100, 125}, }, // #9: Set, with Set @@ -1827,7 +1827,7 @@ func TestResourceDataSet(t *testing.T) { Optional: true, Computed: true, Elem: &Schema{Type: TypeInt}, - Set: func(a interface{}) int { + Set: func(a any) int { return a.(int) }, }, @@ -1844,14 +1844,14 @@ func TestResourceDataSet(t *testing.T) { Key: "ports", Value: &Set{ - m: map[string]interface{}{ + m: map[string]any{ "1": 1, "2": 2, }, }, GetKey: "ports", - GetValue: []interface{}{1, 2}, + GetValue: []any{1, 2}, }, // #10: Set single item @@ -1862,7 +1862,7 @@ func TestResourceDataSet(t *testing.T) { Optional: true, Computed: true, Elem: &Schema{Type: TypeInt}, - Set: func(a interface{}) int { + Set: func(a any) int { return a.(int) }, }, @@ -1881,7 +1881,7 @@ func TestResourceDataSet(t *testing.T) { Err: true, GetKey: "ports", - GetValue: []interface{}{100, 80}, + GetValue: []any{100, 80}, }, // #11: Set with nested set @@ -1898,14 +1898,14 @@ func TestResourceDataSet(t *testing.T) { "set": &Schema{ Type: TypeSet, Elem: &Schema{Type: TypeInt}, - Set: func(a interface{}) int { + Set: func(a any) int { return a.(int) }, }, }, }, - Set: func(a interface{}) int { - return a.(map[string]interface{})["port"].(int) + Set: func(a any) int { + return a.(map[string]any)["port"].(int) }, }, }, @@ -1913,30 +1913,30 @@ func TestResourceDataSet(t *testing.T) { State: nil, Key: "ports", - Value: []interface{}{ - map[string]interface{}{ + Value: []any{ + map[string]any{ "port": 80, }, }, GetKey: "ports", - GetValue: []interface{}{ - map[string]interface{}{ + GetValue: []any{ + map[string]any{ "port": 80, - "set": []interface{}{}, + "set": []any{}, }, }, - GetPreProcess: func(v interface{}) interface{} { + GetPreProcess: func(v any) any { if v == nil { return v } - s, ok := v.([]interface{}) + s, ok := v.([]any) if !ok { return v } for _, v := range s { - m, ok := v.(map[string]interface{}) + m, ok := v.(map[string]any) if !ok { continue } @@ -1970,7 +1970,7 @@ func TestResourceDataSet(t *testing.T) { Value: []float64{1.0, 2.2, 5.5}, GetKey: "ratios", - GetValue: []interface{}{1.0, 2.2, 5.5}, + GetValue: []any{1.0, 2.2, 5.5}, }, // #12: Set of floats, set list @@ -1980,7 +1980,7 @@ func TestResourceDataSet(t *testing.T) { Type: TypeSet, Computed: true, Elem: &Schema{Type: TypeFloat}, - Set: func(a interface{}) int { + Set: func(a any) int { return int(math.Float64bits(a.(float64))) }, }, @@ -1994,7 +1994,7 @@ func TestResourceDataSet(t *testing.T) { Value: []float64{1.0, 2.2, 5.5}, GetKey: "ratios", - GetValue: []interface{}{1.0, 2.2, 5.5}, + GetValue: []any{1.0, 2.2, 5.5}, }, // #13: Basic pointer @@ -2073,7 +2073,7 @@ func TestResourceDataSet(t *testing.T) { "set": &Schema{ Type: TypeSet, Elem: &Schema{Type: TypeInt}, - Set: func(a interface{}) int { + Set: func(a any) int { return a.(int) }, }, @@ -2085,32 +2085,32 @@ func TestResourceDataSet(t *testing.T) { State: nil, Key: "ports", - Value: []interface{}{ - map[string]interface{}{ - "set": []interface{}{ + Value: []any{ + map[string]any{ + "set": []any{ 1, }, }, }, GetKey: "ports", - GetValue: []interface{}{ - map[string]interface{}{ - "set": []interface{}{ + GetValue: []any{ + map[string]any{ + "set": []any{ 1, }, }, }, - GetPreProcess: func(v interface{}) interface{} { + GetPreProcess: func(v any) any { if v == nil { return v } - s, ok := v.([]interface{}) + s, ok := v.([]any) if !ok { return v } for _, v := range s { - m, ok := v.(map[string]interface{}) + m, ok := v.(map[string]any) if !ok { continue } @@ -2162,7 +2162,7 @@ func TestResourceDataState_dynamicAttributes(t *testing.T) { Schema map[string]*Schema State *terraform.InstanceState Diff *terraform.InstanceDiff - Set map[string]interface{} + Set map[string]any UnsafeSet map[string]string Result *terraform.InstanceState }{ @@ -2183,7 +2183,7 @@ func TestResourceDataState_dynamicAttributes(t *testing.T) { Diff: nil, - Set: map[string]interface{}{ + Set: map[string]any{ "schema_field": "present", }, @@ -2242,7 +2242,7 @@ func TestResourceDataState_schema(t *testing.T) { Schema map[string]*Schema State *terraform.InstanceState Diff *terraform.InstanceDiff - Set map[string]interface{} + Set map[string]any Result *terraform.InstanceState Partial []string }{ @@ -2299,7 +2299,7 @@ func TestResourceDataState_schema(t *testing.T) { }, }, - Set: map[string]interface{}{ + Set: map[string]any{ "availability_zone": "bar", }, @@ -2323,7 +2323,7 @@ func TestResourceDataState_schema(t *testing.T) { Diff: nil, - Set: map[string]interface{}{ + Set: map[string]any{ "vpc": true, }, @@ -2341,7 +2341,7 @@ func TestResourceDataState_schema(t *testing.T) { Type: TypeString, Optional: true, Computed: true, - StateFunc: func(interface{}) string { return "" }, + StateFunc: func(any) string { return "" }, }, }, @@ -2485,12 +2485,12 @@ func TestResourceDataState_schema(t *testing.T) { }, }, - Set: map[string]interface{}{ - "config_vars": []map[string]interface{}{ - map[string]interface{}{ + Set: map[string]any{ + "config_vars": []map[string]any{ + map[string]any{ "foo": "bar", }, - map[string]interface{}{ + map[string]any{ "baz": "bang", }, }, @@ -2592,7 +2592,7 @@ func TestResourceDataState_schema(t *testing.T) { Optional: true, Computed: true, Elem: &Schema{Type: TypeInt}, - Set: func(a interface{}) int { + Set: func(a any) int { return a.(int) }, }, @@ -2627,7 +2627,7 @@ func TestResourceDataState_schema(t *testing.T) { Optional: true, Computed: true, Elem: &Schema{Type: TypeInt}, - Set: func(a interface{}) int { + Set: func(a any) int { return a.(int) }, }, @@ -2637,8 +2637,8 @@ func TestResourceDataState_schema(t *testing.T) { Diff: nil, - Set: map[string]interface{}{ - "ports": []interface{}{100, 80}, + Set: map[string]any{ + "ports": []any{100, 80}, }, Result: &terraform.InstanceState{ @@ -2674,8 +2674,8 @@ func TestResourceDataState_schema(t *testing.T) { }, }, }, - Set: func(a interface{}) int { - m := a.(map[string]interface{}) + Set: func(a any) int { + m := a.(map[string]any) return m["order"].(int) }, }, @@ -2693,15 +2693,15 @@ func TestResourceDataState_schema(t *testing.T) { }, }, - Set: map[string]interface{}{ - "ports": []interface{}{ - map[string]interface{}{ + Set: map[string]any{ + "ports": []any{ + map[string]any{ "order": 20, - "b": []interface{}{100}, + "b": []any{100}, }, - map[string]interface{}{ + map[string]any{ "order": 10, - "a": []interface{}{80}, + "a": []any{80}, }, }, }, @@ -2819,8 +2819,8 @@ func TestResourceDataState_schema(t *testing.T) { Partial: []string{}, - Set: map[string]interface{}{ - "ports": []interface{}{}, + Set: map[string]any{ + "ports": []any{}, }, Result: &terraform.InstanceState{ @@ -2909,12 +2909,12 @@ func TestResourceDataState_schema(t *testing.T) { }, }, - Set: map[string]interface{}{ - "config_vars": []map[string]interface{}{ - map[string]interface{}{ + Set: map[string]any{ + "config_vars": []map[string]any{ + map[string]any{ "foo": "bar", }, - map[string]interface{}{ + map[string]any{ "baz": "bang", }, }, @@ -2943,7 +2943,7 @@ func TestResourceDataState_schema(t *testing.T) { Optional: true, Computed: true, Elem: &Schema{Type: TypeInt}, - Set: func(a interface{}) int { + Set: func(a any) int { return a.(int) }, }, @@ -2986,7 +2986,7 @@ func TestResourceDataState_schema(t *testing.T) { Optional: true, Computed: true, Elem: &Schema{Type: TypeInt}, - Set: func(a interface{}) int { + Set: func(a any) int { return a.(int) }, }, @@ -3060,7 +3060,7 @@ func TestResourceDataState_schema(t *testing.T) { }, }, - Set: map[string]interface{}{ + Set: map[string]any{ "tags": map[string]string{}, }, @@ -3116,7 +3116,7 @@ func TestResourceDataState_schema(t *testing.T) { }, }, - Set: map[string]interface{}{ + Set: map[string]any{ "foo": "bar", }, @@ -3140,8 +3140,8 @@ func TestResourceDataState_schema(t *testing.T) { "uuids": &Schema{Type: TypeMap}, }, }, - Set: func(a interface{}) int { - m := a.(map[string]interface{}) + Set: func(a any) int { + m := a.(map[string]any) return m["index"].(int) }, }, @@ -3157,11 +3157,11 @@ func TestResourceDataState_schema(t *testing.T) { }, }, - Set: map[string]interface{}{ - "ports": []interface{}{ - map[string]interface{}{ + Set: map[string]any{ + "ports": []any{ + map[string]any{ "index": 10, - "uuids": map[string]interface{}{ + "uuids": map[string]any{ "80": "value", }, }, @@ -3186,7 +3186,7 @@ func TestResourceDataState_schema(t *testing.T) { Optional: true, Computed: true, Elem: &Schema{Type: TypeInt}, - Set: func(a interface{}) int { + Set: func(a any) int { return a.(int) }, }, @@ -3225,7 +3225,7 @@ func TestResourceDataState_schema(t *testing.T) { Optional: true, Computed: true, Elem: &Schema{Type: TypeInt}, - Set: func(a interface{}) int { + Set: func(a any) int { return a.(int) }, }, @@ -3235,8 +3235,8 @@ func TestResourceDataState_schema(t *testing.T) { Diff: nil, - Set: map[string]interface{}{ - "ports": []interface{}{}, + Set: map[string]any{ + "ports": []any{}, }, Result: &terraform.InstanceState{ @@ -3261,8 +3261,8 @@ func TestResourceDataState_schema(t *testing.T) { Diff: nil, - Set: map[string]interface{}{ - "ports": []interface{}{}, + Set: map[string]any{ + "ports": []any{}, }, Result: &terraform.InstanceState{ @@ -3298,11 +3298,11 @@ func TestResourceDataState_schema(t *testing.T) { }, }, - Set: map[string]interface{}{ - "ports": []interface{}{ - map[string]interface{}{ + Set: map[string]any{ + "ports": []any{ + map[string]any{ "index": 10, - "uuids": map[string]interface{}{ + "uuids": map[string]any{ "80": "value", }, }, @@ -3449,7 +3449,7 @@ func TestResourceData_nonStringValuesInMap(t *testing.T) { t.Fatalf("err: %s", err) } - m, ok := d.Get(c.MapFieldName).(map[string]interface{}) + m, ok := d.Get(c.MapFieldName).(map[string]any) if !ok { t.Fatalf("expected %q to be castable to a map", c.MapFieldName) } @@ -3562,6 +3562,6 @@ func TestResourceDataSetType(t *testing.T) { } } -func testPtrTo(raw interface{}) interface{} { +func testPtrTo(raw any) any { return &raw } diff --git a/staging/terraform/legacy/helper/schema/resource_diff.go b/staging/terraform/legacy/helper/schema/resource_diff.go index 5676c10..c843f26 100644 --- a/staging/terraform/legacy/helper/schema/resource_diff.go +++ b/staging/terraform/legacy/helper/schema/resource_diff.go @@ -39,7 +39,7 @@ func (w *newValueWriter) init() { // WriteField overrides MapValueWriter's WriteField, adding the ability to flag // the address as computed. -func (w *newValueWriter) WriteField(address []string, value interface{}, computed bool) error { +func (w *newValueWriter) WriteField(address []string, value any, computed bool) error { // Fail the write if we have a non-nil value and computed is true. // NewComputed values should not have a value when written. if value != nil && computed { @@ -271,7 +271,7 @@ func (d *ResourceDiff) GetChangedKeysPrefix(prefix string) []string { // diffChange helps to implement resourceDiffer and derives its change values // from ResourceDiff's own change data, in addition to existing diff, config, and state. -func (d *ResourceDiff) diffChange(key string) (interface{}, interface{}, bool, bool, bool) { +func (d *ResourceDiff) diffChange(key string) (any, any, bool, bool, bool) { old, new, customized := d.getChange(key) if !old.Exists { @@ -289,7 +289,7 @@ func (d *ResourceDiff) diffChange(key string) (interface{}, interface{}, bool, b // sets). The original value from the state is used as the old value. // // This function is only allowed on computed attributes. -func (d *ResourceDiff) SetNew(key string, value interface{}) error { +func (d *ResourceDiff) SetNew(key string, value any) error { if err := d.checkKey(key, "SetNew", false); err != nil { return err } @@ -310,7 +310,7 @@ func (d *ResourceDiff) SetNewComputed(key string) error { } // setDiff performs common diff setting behaviour. -func (d *ResourceDiff) setDiff(key string, new interface{}, computed bool) error { +func (d *ResourceDiff) setDiff(key string, new any, computed bool) error { if err := d.clear(key); err != nil { return err } @@ -364,7 +364,7 @@ func (d *ResourceDiff) ForceNew(key string) error { } // Get hands off to ResourceData.Get. -func (d *ResourceDiff) Get(key string) interface{} { +func (d *ResourceDiff) Get(key string) any { r, _ := d.GetOk(key) return r } @@ -375,7 +375,7 @@ func (d *ResourceDiff) Get(key string) interface{} { // This implementation differs from ResourceData's in the way that we first get // results from the exact levels for the new diff, then from state and diff as // per normal. -func (d *ResourceDiff) GetChange(key string) (interface{}, interface{}) { +func (d *ResourceDiff) GetChange(key string) (any, any) { old, new, _ := d.getChange(key) return old.Value, new.Value } @@ -383,7 +383,7 @@ func (d *ResourceDiff) GetChange(key string) (interface{}, interface{}) { // GetOk functions the same way as ResourceData.GetOk, but it also checks the // new diff levels to provide data consistent with the current state of the // customized diff. -func (d *ResourceDiff) GetOk(key string) (interface{}, bool) { +func (d *ResourceDiff) GetOk(key string) (any, bool) { r := d.get(strings.Split(key, "."), "newDiff") exists := r.Exists && !r.Computed if exists { @@ -409,7 +409,7 @@ func (d *ResourceDiff) GetOk(key string) (interface{}, bool) { // for the zero value of the attribute's type. This allows for attributes // without a default, to fully check for a literal assignment, regardless // of the zero-value for that type. -func (d *ResourceDiff) GetOkExists(key string) (interface{}, bool) { +func (d *ResourceDiff) GetOkExists(key string) (any, bool) { r := d.get(strings.Split(key, "."), "newDiff") exists := r.Exists && !r.Computed return r.Value, exists diff --git a/staging/terraform/legacy/helper/schema/resource_diff_test.go b/staging/terraform/legacy/helper/schema/resource_diff_test.go index 85fcda3..08b8e95 100644 --- a/staging/terraform/legacy/helper/schema/resource_diff_test.go +++ b/staging/terraform/legacy/helper/schema/resource_diff_test.go @@ -19,8 +19,8 @@ import ( // // This is not foolproof as since it performs sums, you can run into // collisions. Spec tests accordingly. :P -func testSetFunc(v interface{}) int { - m := v.(map[string]interface{}) +func testSetFunc(v any) int { + m := v.(map[string]any) return m["foo"].(int) + m["bar"].(int) } @@ -32,8 +32,8 @@ type resourceDiffTestCase struct { Config *terraform.ResourceConfig Diff *terraform.InstanceDiff Key string - OldValue interface{} - NewValue interface{} + OldValue any + NewValue any Expected *terraform.InstanceDiff ExpectedKeys []string ExpectedError bool @@ -56,7 +56,7 @@ func testDiffCases(t *testing.T, oldPrefix string, oldOffset int, computed bool) "foo": "bar", }, }, - Config: testConfig(t, map[string]interface{}{ + Config: testConfig(t, map[string]any{ "foo": "baz", }), Diff: &terraform.InstanceDiff{ @@ -101,8 +101,8 @@ func testDiffCases(t *testing.T, oldPrefix string, oldOffset int, computed bool) "foo.1996459178": "bar", }, }, - Config: testConfig(t, map[string]interface{}{ - "foo": []interface{}{"baz"}, + Config: testConfig(t, map[string]any{ + "foo": []any{"baz"}, }), Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ @@ -118,7 +118,7 @@ func testDiffCases(t *testing.T, oldPrefix string, oldOffset int, computed bool) }, }, Key: "foo", - NewValue: []interface{}{"qux"}, + NewValue: []any{"qux"}, Expected: &terraform.InstanceDiff{ Attributes: func() map[string]*terraform.ResourceAttrDiff { result := map[string]*terraform.ResourceAttrDiff{} @@ -159,8 +159,8 @@ func testDiffCases(t *testing.T, oldPrefix string, oldOffset int, computed bool) "foo.0": "bar", }, }, - Config: testConfig(t, map[string]interface{}{ - "foo": []interface{}{"baz"}, + Config: testConfig(t, map[string]any{ + "foo": []any{"baz"}, }), Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ @@ -171,7 +171,7 @@ func testDiffCases(t *testing.T, oldPrefix string, oldOffset int, computed bool) }, }, Key: "foo", - NewValue: []interface{}{"qux"}, + NewValue: []any{"qux"}, Expected: &terraform.InstanceDiff{ Attributes: func() map[string]*terraform.ResourceAttrDiff { result := make(map[string]*terraform.ResourceAttrDiff) @@ -206,8 +206,8 @@ func testDiffCases(t *testing.T, oldPrefix string, oldOffset int, computed bool) "foo.bar": "baz", }, }, - Config: testConfig(t, map[string]interface{}{ - "foo": map[string]interface{}{"bar": "qux"}, + Config: testConfig(t, map[string]any{ + "foo": map[string]any{"bar": "qux"}, }), Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ @@ -218,7 +218,7 @@ func testDiffCases(t *testing.T, oldPrefix string, oldOffset int, computed bool) }, }, Key: "foo", - NewValue: map[string]interface{}{"bar": "quux"}, + NewValue: map[string]any{"bar": "quux"}, Expected: &terraform.InstanceDiff{ Attributes: func() map[string]*terraform.ResourceAttrDiff { result := make(map[string]*terraform.ResourceAttrDiff) @@ -262,7 +262,7 @@ func testDiffCases(t *testing.T, oldPrefix string, oldOffset int, computed bool) "one": "two", }, }, - Config: testConfig(t, map[string]interface{}{ + Config: testConfig(t, map[string]any{ "foo": "baz", }), Diff: &terraform.InstanceDiff{ @@ -312,7 +312,7 @@ func testDiffCases(t *testing.T, oldPrefix string, oldOffset int, computed bool) "one": "two", }, }, - Config: testConfig(t, map[string]interface{}{ + Config: testConfig(t, map[string]any{ "foo": "baz", }), Diff: &terraform.InstanceDiff{ @@ -377,13 +377,13 @@ func testDiffCases(t *testing.T, oldPrefix string, oldOffset int, computed bool) "top.23.bar": "12", }, }, - Config: testConfig(t, map[string]interface{}{ - "top": []interface{}{ - map[string]interface{}{ + Config: testConfig(t, map[string]any{ + "top": []any{ + map[string]any{ "foo": 1, "bar": 3, }, - map[string]interface{}{ + map[string]any{ "foo": 12, "bar": 12, }, @@ -410,16 +410,16 @@ func testDiffCases(t *testing.T, oldPrefix string, oldOffset int, computed bool) }, }, Key: "top", - NewValue: NewSet(testSetFunc, []interface{}{ - map[string]interface{}{ + NewValue: NewSet(testSetFunc, []any{ + map[string]any{ "foo": 1, "bar": 4, }, - map[string]interface{}{ + map[string]any{ "foo": 13, "bar": 12, }, - map[string]interface{}{ + map[string]any{ "foo": 21, "bar": 22, }, @@ -480,7 +480,7 @@ func testDiffCases(t *testing.T, oldPrefix string, oldOffset int, computed bool) "foo": "bar", }, }, - Config: testConfig(t, map[string]interface{}{}), + Config: testConfig(t, map[string]any{}), Diff: &terraform.InstanceDiff{Attributes: map[string]*terraform.ResourceAttrDiff{}}, Key: "foo", NewValue: "baz", @@ -512,7 +512,7 @@ func testDiffCases(t *testing.T, oldPrefix string, oldOffset int, computed bool) "foo": "bar", }, }, - Config: testConfig(t, map[string]interface{}{ + Config: testConfig(t, map[string]any{ "foo": "baz", }), Diff: &terraform.InstanceDiff{ @@ -540,7 +540,7 @@ func testDiffCases(t *testing.T, oldPrefix string, oldOffset int, computed bool) "foo": "bar", }, }, - Config: testConfig(t, map[string]interface{}{ + Config: testConfig(t, map[string]any{ "foo": "baz", }), Diff: &terraform.InstanceDiff{ @@ -574,7 +574,7 @@ func testDiffCases(t *testing.T, oldPrefix string, oldOffset int, computed bool) "foo": "bar", }, }, - Config: testConfig(t, map[string]interface{}{}), + Config: testConfig(t, map[string]any{}), Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ "foo": &terraform.ResourceAttrDiff{ @@ -615,7 +615,7 @@ func testDiffCases(t *testing.T, oldPrefix string, oldOffset int, computed bool) }, ID: "pre-existing", }, - Config: testConfig(t, map[string]interface{}{}), + Config: testConfig(t, map[string]any{}), Diff: &terraform.InstanceDiff{Attributes: map[string]*terraform.ResourceAttrDiff{}}, Key: "foo", NewValue: "", @@ -705,7 +705,7 @@ func TestForceNew(t *testing.T) { "foo": "bar", }, }, - Config: testConfig(t, map[string]interface{}{ + Config: testConfig(t, map[string]any{ "foo": "baz", }), Diff: &terraform.InstanceDiff{ @@ -741,7 +741,7 @@ func TestForceNew(t *testing.T) { "foo": "bar", }, }, - Config: testConfig(t, map[string]interface{}{ + Config: testConfig(t, map[string]any{ "foo": "bar", }), ExpectedError: true, @@ -759,7 +759,7 @@ func TestForceNew(t *testing.T) { "foo": "bar", }, }, - Config: testConfig(t, map[string]interface{}{ + Config: testConfig(t, map[string]any{ "foo": "baz", }), Diff: &terraform.InstanceDiff{ @@ -809,9 +809,9 @@ func TestForceNew(t *testing.T) { "foo.0.baz": "xyz", }, }, - Config: testConfig(t, map[string]interface{}{ - "foo": []interface{}{ - map[string]interface{}{ + Config: testConfig(t, map[string]any{ + "foo": []any{ + map[string]any{ "bar": "abcdefg", "baz": "changed", }, @@ -857,7 +857,7 @@ func TestForceNew(t *testing.T) { "foo": "bar", }, }, - Config: testConfig(t, map[string]interface{}{}), + Config: testConfig(t, map[string]any{}), Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ "foo": &terraform.ResourceAttrDiff{ @@ -906,9 +906,9 @@ func TestForceNew(t *testing.T) { "foo.0.bar": "abc", }, }, - Config: testConfig(t, map[string]interface{}{ - "foo": []interface{}{ - map[string]interface{}{ + Config: testConfig(t, map[string]any{ + "foo": []any{ + map[string]any{ "bar": "abcdefg", }, }, @@ -974,7 +974,7 @@ func TestClear(t *testing.T) { "foo": "bar", }, }, - Config: testConfig(t, map[string]interface{}{ + Config: testConfig(t, map[string]any{ "foo": "baz", }), Diff: &terraform.InstanceDiff{ @@ -1001,7 +1001,7 @@ func TestClear(t *testing.T) { "foo": "bar", }, }, - Config: testConfig(t, map[string]interface{}{ + Config: testConfig(t, map[string]any{ "foo": "baz", }), Diff: &terraform.InstanceDiff{ @@ -1035,7 +1035,7 @@ func TestClear(t *testing.T) { "one": "two", }, }, - Config: testConfig(t, map[string]interface{}{ + Config: testConfig(t, map[string]any{ "foo": "baz", "one": "three", }), @@ -1090,9 +1090,9 @@ func TestClear(t *testing.T) { "foo.0.baz": "baz1", }, }, - Config: testConfig(t, map[string]interface{}{ - "foo": []interface{}{ - map[string]interface{}{ + Config: testConfig(t, map[string]any{ + "foo": []any{ + map[string]any{ "bar": "bar2", "baz": "baz1", }, @@ -1138,9 +1138,9 @@ func TestClear(t *testing.T) { "foo.0.baz": "baz1", }, }, - Config: testConfig(t, map[string]interface{}{ - "foo": []interface{}{ - map[string]interface{}{ + Config: testConfig(t, map[string]any{ + "foo": []any{ + map[string]any{ "bar": "bar2", "baz": "baz2", }, @@ -1208,7 +1208,7 @@ func TestGetChangedKeysPrefix(t *testing.T) { "foo": "bar", }, }, - Config: testConfig(t, map[string]interface{}{ + Config: testConfig(t, map[string]any{ "foo": "baz", }), Diff: &terraform.InstanceDiff{ @@ -1257,10 +1257,10 @@ func TestGetChangedKeysPrefix(t *testing.T) { "foo.0.baz": "xyz", }, }, - Config: testConfig(t, map[string]interface{}{ + Config: testConfig(t, map[string]any{ "testfield": "modified", - "foo": []interface{}{ - map[string]interface{}{ + "foo": []any{ + map[string]any{ "bar": "abcdefg", "baz": "changed", }, @@ -1318,7 +1318,7 @@ func TestResourceDiffGetOkExists(t *testing.T) { Config *terraform.ResourceConfig Diff *terraform.InstanceDiff Key string - Value interface{} + Value any Ok bool }{ /* @@ -1422,7 +1422,7 @@ func TestResourceDiffGetOkExists(t *testing.T) { Diff: nil, Key: "ports", - Value: []interface{}{}, + Value: []any{}, Ok: false, }, @@ -1445,7 +1445,7 @@ func TestResourceDiffGetOkExists(t *testing.T) { Diff: nil, Key: "ports", - Value: map[string]interface{}{}, + Value: map[string]any{}, Ok: false, }, @@ -1460,7 +1460,7 @@ func TestResourceDiffGetOkExists(t *testing.T) { Type: TypeSet, Optional: true, Elem: &Schema{Type: TypeInt}, - Set: func(a interface{}) int { return a.(int) }, + Set: func(a any) int { return a.(int) }, }, }, @@ -1470,7 +1470,7 @@ func TestResourceDiffGetOkExists(t *testing.T) { Diff: nil, Key: "ports", - Value: []interface{}{}, + Value: []any{}, Ok: false, }, @@ -1481,7 +1481,7 @@ func TestResourceDiffGetOkExists(t *testing.T) { Type: TypeSet, Optional: true, Elem: &Schema{Type: TypeInt}, - Set: func(a interface{}) int { return a.(int) }, + Set: func(a any) int { return a.(int) }, }, }, @@ -1562,7 +1562,7 @@ func TestResourceDiffGetOkExists(t *testing.T) { "availability_zone": "foo", }, }, - Config: testConfig(t, map[string]interface{}{ + Config: testConfig(t, map[string]any{ "availability_zone": "foo", }), @@ -1584,7 +1584,7 @@ func TestResourceDiffGetOkExists(t *testing.T) { }, State: nil, - Config: testConfig(t, map[string]interface{}{ + Config: testConfig(t, map[string]any{ "availability_zone": "foo", }), @@ -1616,7 +1616,7 @@ func TestResourceDiffGetOkExists(t *testing.T) { "availability_zone": "foo", }, }, - Config: testConfig(t, map[string]interface{}{ + Config: testConfig(t, map[string]any{ "availability_zone": "bar", }), @@ -1647,7 +1647,7 @@ func TestResourceDiffGetOkExists(t *testing.T) { "availability_zone": "foo", }, }, - Config: testConfig(t, map[string]interface{}{}), + Config: testConfig(t, map[string]any{}), Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ @@ -1690,7 +1690,7 @@ func TestResourceDiffGetOkExistsSetNew(t *testing.T) { State *terraform.InstanceState Diff *terraform.InstanceDiff Key string - Value interface{} + Value any Ok bool }{ Schema: map[string]*Schema{ @@ -1712,7 +1712,7 @@ func TestResourceDiffGetOkExistsSetNew(t *testing.T) { Ok: true, } - d := newResourceDiff(tc.Schema, testConfig(t, map[string]interface{}{}), tc.State, tc.Diff) + d := newResourceDiff(tc.Schema, testConfig(t, map[string]any{}), tc.State, tc.Diff) d.SetNew(tc.Key, tc.Value) v, ok := d.GetOkExists(tc.Key) @@ -1734,7 +1734,7 @@ func TestResourceDiffGetOkExistsSetNewComputed(t *testing.T) { State *terraform.InstanceState Diff *terraform.InstanceDiff Key string - Value interface{} + Value any Ok bool }{ Schema: map[string]*Schema{ @@ -1760,7 +1760,7 @@ func TestResourceDiffGetOkExistsSetNewComputed(t *testing.T) { Ok: false, } - d := newResourceDiff(tc.Schema, testConfig(t, map[string]interface{}{}), tc.State, tc.Diff) + d := newResourceDiff(tc.Schema, testConfig(t, map[string]any{}), tc.State, tc.Diff) d.SetNewComputed(tc.Key) _, ok := d.GetOkExists(tc.Key) @@ -1789,7 +1789,7 @@ func TestResourceDiffNewValueKnown(t *testing.T) { }, }, State: nil, - Config: testConfig(t, map[string]interface{}{ + Config: testConfig(t, map[string]any{ "availability_zone": "foo", }), Diff: &terraform.InstanceDiff{ @@ -1816,7 +1816,7 @@ func TestResourceDiffNewValueKnown(t *testing.T) { "availability_zone": "foo", }, }, - Config: testConfig(t, map[string]interface{}{ + Config: testConfig(t, map[string]any{ "availability_zone": "foo", }), Diff: &terraform.InstanceDiff{ @@ -1838,7 +1838,7 @@ func TestResourceDiffNewValueKnown(t *testing.T) { "availability_zone": "foo", }, }, - Config: testConfig(t, map[string]interface{}{}), + Config: testConfig(t, map[string]any{}), Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{}, }, @@ -1859,7 +1859,7 @@ func TestResourceDiffNewValueKnown(t *testing.T) { "availability_zone": "foo", }, }, - Config: testConfig(t, map[string]interface{}{}), + Config: testConfig(t, map[string]any{}), Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{}, }, @@ -1880,7 +1880,7 @@ func TestResourceDiffNewValueKnown(t *testing.T) { "availability_zone": "foo", }, }, - Config: testConfig(t, map[string]interface{}{ + Config: testConfig(t, map[string]any{ "availability_zone": "foo", }), Diff: &terraform.InstanceDiff{ @@ -1904,7 +1904,7 @@ func TestResourceDiffNewValueKnown(t *testing.T) { }, Config: testConfig( t, - map[string]interface{}{ + map[string]any{ "availability_zone": hcl2shim.UnknownVariableValue, }, ), @@ -1929,7 +1929,7 @@ func TestResourceDiffNewValueKnown(t *testing.T) { }, Config: testConfig( t, - map[string]interface{}{ + map[string]any{ "availability_zone": hcl2shim.UnknownVariableValue, }, ), @@ -1966,7 +1966,7 @@ func TestResourceDiffNewValueKnownSetNew(t *testing.T) { Config *terraform.ResourceConfig Diff *terraform.InstanceDiff Key string - Value interface{} + Value any Expected bool }{ Schema: map[string]*Schema{ @@ -1983,7 +1983,7 @@ func TestResourceDiffNewValueKnownSetNew(t *testing.T) { }, Config: testConfig( t, - map[string]interface{}{ + map[string]any{ "availability_zone": hcl2shim.UnknownVariableValue, }, ), @@ -2030,7 +2030,7 @@ func TestResourceDiffNewValueKnownSetNewComputed(t *testing.T) { "availability_zone": "foo", }, }, - Config: testConfig(t, map[string]interface{}{}), + Config: testConfig(t, map[string]any{}), Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{}, }, diff --git a/staging/terraform/legacy/helper/schema/resource_importer.go b/staging/terraform/legacy/helper/schema/resource_importer.go index a2b84c6..ac54f69 100644 --- a/staging/terraform/legacy/helper/schema/resource_importer.go +++ b/staging/terraform/legacy/helper/schema/resource_importer.go @@ -34,7 +34,7 @@ type ResourceImporter struct { // // To create the ResourceData structures for other resource types (if // you have to), instantiate your resource and call the Data function. -type StateFunc func(*ResourceData, interface{}) ([]*ResourceData, error) +type StateFunc func(*ResourceData, any) ([]*ResourceData, error) // InternalValidate should be called to validate the structure of this // importer. This should be called in a unit test. @@ -50,6 +50,6 @@ func (r *ResourceImporter) InternalValidate() error { // ImportStatePassthrough is an implementation of StateFunc that can be // used to simply pass the ID directly through. This should be used only // in the case that an ID-only refresh is possible. -func ImportStatePassthrough(d *ResourceData, m interface{}) ([]*ResourceData, error) { +func ImportStatePassthrough(d *ResourceData, m any) ([]*ResourceData, error) { return []*ResourceData{d}, nil } diff --git a/staging/terraform/legacy/helper/schema/resource_test.go b/staging/terraform/legacy/helper/schema/resource_test.go index 70b0b05..994c95a 100644 --- a/staging/terraform/legacy/helper/schema/resource_test.go +++ b/staging/terraform/legacy/helper/schema/resource_test.go @@ -31,7 +31,7 @@ func TestResourceApply_create(t *testing.T) { } called := false - r.Create = func(d *ResourceData, m interface{}) error { + r.Create = func(d *ResourceData, m any) error { called = true d.SetId("foo") return nil @@ -62,7 +62,7 @@ func TestResourceApply_create(t *testing.T) { "id": "foo", "foo": "42", }, - Meta: map[string]interface{}{ + Meta: map[string]any{ "schema_version": "2", }, } @@ -89,7 +89,7 @@ func TestResourceApply_Timeout_state(t *testing.T) { } called := false - r.Create = func(d *ResourceData, m interface{}) error { + r.Create = func(d *ResourceData, m any) error { called = true d.SetId("foo") return nil @@ -130,7 +130,7 @@ func TestResourceApply_Timeout_state(t *testing.T) { "id": "foo", "foo": "42", }, - Meta: map[string]interface{}{ + Meta: map[string]any{ "schema_version": "2", TimeoutKey: expectedForValues(40, 0, 80, 40, 0), }, @@ -163,7 +163,7 @@ func TestResourceApply_Timeout_destroy(t *testing.T) { called := false var delTimeout time.Duration - r.Delete = func(d *ResourceData, m interface{}) error { + r.Delete = func(d *ResourceData, m any) error { delTimeout = d.Timeout(TimeoutDelete) called = true return nil @@ -214,15 +214,15 @@ func TestResourceDiff_Timeout_diff(t *testing.T) { }, } - r.Create = func(d *ResourceData, m interface{}) error { + r.Create = func(d *ResourceData, m any) error { d.SetId("foo") return nil } conf := terraform.NewResourceConfigRaw( - map[string]interface{}{ + map[string]any{ "foo": 42, - TimeoutsConfigKey: map[string]interface{}{ + TimeoutsConfigKey: map[string]any{ "create": "2h", }, }, @@ -269,13 +269,13 @@ func TestResourceDiff_CustomizeFunc(t *testing.T) { var called bool - r.CustomizeDiff = func(d *ResourceDiff, m interface{}) error { + r.CustomizeDiff = func(d *ResourceDiff, m any) error { called = true return nil } conf := terraform.NewResourceConfigRaw( - map[string]interface{}{ + map[string]any{ "foo": 42, }, ) @@ -303,7 +303,7 @@ func TestResourceApply_destroy(t *testing.T) { } called := false - r.Delete = func(d *ResourceData, m interface{}) error { + r.Delete = func(d *ResourceData, m any) error { called = true return nil } @@ -347,12 +347,12 @@ func TestResourceApply_destroyCreate(t *testing.T) { } change := false - r.Create = func(d *ResourceData, m interface{}) error { + r.Create = func(d *ResourceData, m any) error { change = d.HasChange("tags") d.SetId("foo") return nil } - r.Delete = func(d *ResourceData, m interface{}) error { + r.Delete = func(d *ResourceData, m any) error { return nil } @@ -413,7 +413,7 @@ func TestResourceApply_destroyPartial(t *testing.T) { SchemaVersion: 3, } - r.Delete = func(d *ResourceData, m interface{}) error { + r.Delete = func(d *ResourceData, m any) error { d.Set("foo", 42) return fmt.Errorf("some error") } @@ -440,7 +440,7 @@ func TestResourceApply_destroyPartial(t *testing.T) { "id": "bar", "foo": "42", }, - Meta: map[string]interface{}{ + Meta: map[string]any{ "schema_version": "3", }, } @@ -460,7 +460,7 @@ func TestResourceApply_update(t *testing.T) { }, } - r.Update = func(d *ResourceData, m interface{}) error { + r.Update = func(d *ResourceData, m any) error { d.Set("foo", 42) return nil } @@ -552,14 +552,14 @@ func TestResourceApply_isNewResource(t *testing.T) { }, } - updateFunc := func(d *ResourceData, m interface{}) error { + updateFunc := func(d *ResourceData, m any) error { d.Set("foo", "updated") if d.IsNewResource() { d.Set("foo", "new-resource") } return nil } - r.Create = func(d *ResourceData, m interface{}) error { + r.Create = func(d *ResourceData, m any) error { d.SetId("foo") d.Set("foo", "created") return updateFunc(d, m) @@ -653,7 +653,7 @@ func TestResourceInternalValidate(t *testing.T) { // Update undefined for non-ForceNew field 2: { &Resource{ - Create: func(d *ResourceData, meta interface{}) error { return nil }, + Create: func(d *ResourceData, meta any) error { return nil }, Schema: map[string]*Schema{ "boo": &Schema{ Type: TypeInt, @@ -668,8 +668,8 @@ func TestResourceInternalValidate(t *testing.T) { // Update defined for ForceNew field 3: { &Resource{ - Create: func(d *ResourceData, meta interface{}) error { return nil }, - Update: func(d *ResourceData, meta interface{}) error { return nil }, + Create: func(d *ResourceData, meta any) error { return nil }, + Update: func(d *ResourceData, meta any) error { return nil }, Schema: map[string]*Schema{ "goo": &Schema{ Type: TypeInt, @@ -699,7 +699,7 @@ func TestResourceInternalValidate(t *testing.T) { // non-writable *must not* have Create 5: { &Resource{ - Create: func(d *ResourceData, meta interface{}) error { return nil }, + Create: func(d *ResourceData, meta any) error { return nil }, Schema: map[string]*Schema{ "goo": &Schema{ Type: TypeInt, @@ -714,9 +714,9 @@ func TestResourceInternalValidate(t *testing.T) { // writable must have Read 6: { &Resource{ - Create: func(d *ResourceData, meta interface{}) error { return nil }, - Update: func(d *ResourceData, meta interface{}) error { return nil }, - Delete: func(d *ResourceData, meta interface{}) error { return nil }, + Create: func(d *ResourceData, meta any) error { return nil }, + Update: func(d *ResourceData, meta any) error { return nil }, + Delete: func(d *ResourceData, meta any) error { return nil }, Schema: map[string]*Schema{ "goo": &Schema{ Type: TypeInt, @@ -731,9 +731,9 @@ func TestResourceInternalValidate(t *testing.T) { // writable must have Delete 7: { &Resource{ - Create: func(d *ResourceData, meta interface{}) error { return nil }, - Read: func(d *ResourceData, meta interface{}) error { return nil }, - Update: func(d *ResourceData, meta interface{}) error { return nil }, + Create: func(d *ResourceData, meta any) error { return nil }, + Read: func(d *ResourceData, meta any) error { return nil }, + Update: func(d *ResourceData, meta any) error { return nil }, Schema: map[string]*Schema{ "goo": &Schema{ Type: TypeInt, @@ -747,10 +747,10 @@ func TestResourceInternalValidate(t *testing.T) { 8: { // Reserved name at root should be disallowed &Resource{ - Create: func(d *ResourceData, meta interface{}) error { return nil }, - Read: func(d *ResourceData, meta interface{}) error { return nil }, - Update: func(d *ResourceData, meta interface{}) error { return nil }, - Delete: func(d *ResourceData, meta interface{}) error { return nil }, + Create: func(d *ResourceData, meta any) error { return nil }, + Read: func(d *ResourceData, meta any) error { return nil }, + Update: func(d *ResourceData, meta any) error { return nil }, + Delete: func(d *ResourceData, meta any) error { return nil }, Schema: map[string]*Schema{ "count": { Type: TypeInt, @@ -764,10 +764,10 @@ func TestResourceInternalValidate(t *testing.T) { 9: { // Reserved name at nested levels should be allowed &Resource{ - Create: func(d *ResourceData, meta interface{}) error { return nil }, - Read: func(d *ResourceData, meta interface{}) error { return nil }, - Update: func(d *ResourceData, meta interface{}) error { return nil }, - Delete: func(d *ResourceData, meta interface{}) error { return nil }, + Create: func(d *ResourceData, meta any) error { return nil }, + Read: func(d *ResourceData, meta any) error { return nil }, + Update: func(d *ResourceData, meta any) error { return nil }, + Delete: func(d *ResourceData, meta any) error { return nil }, Schema: map[string]*Schema{ "parent_list": &Schema{ Type: TypeString, @@ -789,10 +789,10 @@ func TestResourceInternalValidate(t *testing.T) { 10: { // Provider reserved name should be allowed in resource &Resource{ - Create: func(d *ResourceData, meta interface{}) error { return nil }, - Read: func(d *ResourceData, meta interface{}) error { return nil }, - Update: func(d *ResourceData, meta interface{}) error { return nil }, - Delete: func(d *ResourceData, meta interface{}) error { return nil }, + Create: func(d *ResourceData, meta any) error { return nil }, + Read: func(d *ResourceData, meta any) error { return nil }, + Update: func(d *ResourceData, meta any) error { return nil }, + Delete: func(d *ResourceData, meta any) error { return nil }, Schema: map[string]*Schema{ "alias": &Schema{ Type: TypeString, @@ -806,7 +806,7 @@ func TestResourceInternalValidate(t *testing.T) { 11: { // ID should be allowed in data source &Resource{ - Read: func(d *ResourceData, meta interface{}) error { return nil }, + Read: func(d *ResourceData, meta any) error { return nil }, Schema: map[string]*Schema{ "id": &Schema{ Type: TypeString, @@ -820,10 +820,10 @@ func TestResourceInternalValidate(t *testing.T) { 12: { // Deprecated ID should be allowed in resource &Resource{ - Create: func(d *ResourceData, meta interface{}) error { return nil }, - Read: func(d *ResourceData, meta interface{}) error { return nil }, - Update: func(d *ResourceData, meta interface{}) error { return nil }, - Delete: func(d *ResourceData, meta interface{}) error { return nil }, + Create: func(d *ResourceData, meta any) error { return nil }, + Read: func(d *ResourceData, meta any) error { return nil }, + Update: func(d *ResourceData, meta any) error { return nil }, + Delete: func(d *ResourceData, meta any) error { return nil }, Schema: map[string]*Schema{ "id": &Schema{ Type: TypeString, @@ -838,21 +838,21 @@ func TestResourceInternalValidate(t *testing.T) { 13: { // non-writable must not define CustomizeDiff &Resource{ - Read: func(d *ResourceData, meta interface{}) error { return nil }, + Read: func(d *ResourceData, meta any) error { return nil }, Schema: map[string]*Schema{ "goo": &Schema{ Type: TypeInt, Optional: true, }, }, - CustomizeDiff: func(*ResourceDiff, interface{}) error { return nil }, + CustomizeDiff: func(*ResourceDiff, any) error { return nil }, }, false, true, }, 14: { // Deprecated resource &Resource{ - Read: func(d *ResourceData, meta interface{}) error { return nil }, + Read: func(d *ResourceData, meta any) error { return nil }, Schema: map[string]*Schema{ "goo": &Schema{ Type: TypeInt, @@ -895,7 +895,7 @@ func TestResourceRefresh(t *testing.T) { }, } - r.Read = func(d *ResourceData, m interface{}) error { + r.Read = func(d *ResourceData, m any) error { if m != 42 { return fmt.Errorf("meta not passed") } @@ -916,7 +916,7 @@ func TestResourceRefresh(t *testing.T) { "id": "bar", "foo": "13", }, - Meta: map[string]interface{}{ + Meta: map[string]any{ "schema_version": "2", }, } @@ -941,7 +941,7 @@ func TestResourceRefresh_blankId(t *testing.T) { }, } - r.Read = func(d *ResourceData, m interface{}) error { + r.Read = func(d *ResourceData, m any) error { d.SetId("foo") return nil } @@ -970,7 +970,7 @@ func TestResourceRefresh_delete(t *testing.T) { }, } - r.Read = func(d *ResourceData, m interface{}) error { + r.Read = func(d *ResourceData, m any) error { d.SetId("") return nil } @@ -1002,11 +1002,11 @@ func TestResourceRefresh_existsError(t *testing.T) { }, } - r.Exists = func(*ResourceData, interface{}) (bool, error) { + r.Exists = func(*ResourceData, any) (bool, error) { return false, fmt.Errorf("error") } - r.Read = func(d *ResourceData, m interface{}) error { + r.Read = func(d *ResourceData, m any) error { panic("shouldn't be called") } @@ -1036,11 +1036,11 @@ func TestResourceRefresh_noExists(t *testing.T) { }, } - r.Exists = func(*ResourceData, interface{}) (bool, error) { + r.Exists = func(*ResourceData, any) (bool, error) { return false, nil } - r.Read = func(d *ResourceData, m interface{}) error { + r.Read = func(d *ResourceData, m any) error { panic("shouldn't be called") } @@ -1072,14 +1072,14 @@ func TestResourceRefresh_needsMigration(t *testing.T) { }, } - r.Read = func(d *ResourceData, m interface{}) error { + r.Read = func(d *ResourceData, m any) error { return d.Set("newfoo", d.Get("newfoo").(int)+1) } r.MigrateState = func( v int, s *terraform.InstanceState, - meta interface{}) (*terraform.InstanceState, error) { + meta any) (*terraform.InstanceState, error) { // Real state migration functions will probably switch on this value, // but we'll just assert on it for now. if v != 1 { @@ -1107,7 +1107,7 @@ func TestResourceRefresh_needsMigration(t *testing.T) { Attributes: map[string]string{ "oldfoo": "1.2", }, - Meta: map[string]interface{}{ + Meta: map[string]any{ "schema_version": "1", }, } @@ -1123,7 +1123,7 @@ func TestResourceRefresh_needsMigration(t *testing.T) { "id": "bar", "newfoo": "13", }, - Meta: map[string]interface{}{ + Meta: map[string]any{ "schema_version": "2", }, } @@ -1144,14 +1144,14 @@ func TestResourceRefresh_noMigrationNeeded(t *testing.T) { }, } - r.Read = func(d *ResourceData, m interface{}) error { + r.Read = func(d *ResourceData, m any) error { return d.Set("newfoo", d.Get("newfoo").(int)+1) } r.MigrateState = func( v int, s *terraform.InstanceState, - meta interface{}) (*terraform.InstanceState, error) { + meta any) (*terraform.InstanceState, error) { t.Fatal("Migrate function shouldn't be called!") return nil, nil } @@ -1161,7 +1161,7 @@ func TestResourceRefresh_noMigrationNeeded(t *testing.T) { Attributes: map[string]string{ "newfoo": "12", }, - Meta: map[string]interface{}{ + Meta: map[string]any{ "schema_version": "2", }, } @@ -1177,7 +1177,7 @@ func TestResourceRefresh_noMigrationNeeded(t *testing.T) { "id": "bar", "newfoo": "13", }, - Meta: map[string]interface{}{ + Meta: map[string]any{ "schema_version": "2", }, } @@ -1199,14 +1199,14 @@ func TestResourceRefresh_stateSchemaVersionUnset(t *testing.T) { }, } - r.Read = func(d *ResourceData, m interface{}) error { + r.Read = func(d *ResourceData, m any) error { return d.Set("newfoo", d.Get("newfoo").(int)+1) } r.MigrateState = func( v int, s *terraform.InstanceState, - meta interface{}) (*terraform.InstanceState, error) { + meta any) (*terraform.InstanceState, error) { s.Attributes["newfoo"] = s.Attributes["oldfoo"] return s, nil } @@ -1229,7 +1229,7 @@ func TestResourceRefresh_stateSchemaVersionUnset(t *testing.T) { "id": "bar", "newfoo": "13", }, - Meta: map[string]interface{}{ + Meta: map[string]any{ "schema_version": "1", }, } @@ -1250,7 +1250,7 @@ func TestResourceRefresh_migrateStateErr(t *testing.T) { }, } - r.Read = func(d *ResourceData, m interface{}) error { + r.Read = func(d *ResourceData, m any) error { t.Fatal("Read should never be called!") return nil } @@ -1258,7 +1258,7 @@ func TestResourceRefresh_migrateStateErr(t *testing.T) { r.MigrateState = func( v int, s *terraform.InstanceState, - meta interface{}) (*terraform.InstanceState, error) { + meta any) (*terraform.InstanceState, error) { return s, fmt.Errorf("triggering an error") } @@ -1303,7 +1303,7 @@ func TestResourceData(t *testing.T) { } // Set expectations - state.Meta = map[string]interface{}{ + state.Meta = map[string]any{ "schema_version": "2", } @@ -1390,7 +1390,7 @@ func TestResource_UpgradeState(t *testing.T) { "id": cty.String, "oldfoo": cty.Number, }), - Upgrade: func(m map[string]interface{}, meta interface{}) (map[string]interface{}, error) { + Upgrade: func(m map[string]any, meta any) (map[string]any, error) { oldfoo, ok := m["oldfoo"].(float64) if !ok { @@ -1421,7 +1421,7 @@ func TestResource_UpgradeState(t *testing.T) { } // unmarshal the state using the json default types - var m map[string]interface{} + var m map[string]any if err := json.Unmarshal(js, &m); err != nil { t.Fatal(err) } @@ -1431,7 +1431,7 @@ func TestResource_UpgradeState(t *testing.T) { t.Fatalf("err: %s", err) } - expected := map[string]interface{}{ + expected := map[string]any{ "id": "bar", "newfoo": 12, } @@ -1461,7 +1461,7 @@ func TestResource_ValidateUpgradeState(t *testing.T) { Type: cty.Object(map[string]cty.Type{ "id": cty.String, }), - Upgrade: func(m map[string]interface{}, _ interface{}) (map[string]interface{}, error) { + Upgrade: func(m map[string]any, _ any) (map[string]any, error) { return m, nil }, }) @@ -1483,7 +1483,7 @@ func TestResource_ValidateUpgradeState(t *testing.T) { if err := r.InternalValidate(nil, true); err == nil { t.Fatal("StateUpgrader must have an Upgrade func") } - r.StateUpgraders[0].Upgrade = func(m map[string]interface{}, _ interface{}) (map[string]interface{}, error) { + r.StateUpgraders[0].Upgrade = func(m map[string]any, _ any) (map[string]any, error) { return m, nil } @@ -1494,7 +1494,7 @@ func TestResource_ValidateUpgradeState(t *testing.T) { Type: cty.Object(map[string]cty.Type{ "id": cty.String, }), - Upgrade: func(m map[string]interface{}, _ interface{}) (map[string]interface{}, error) { + Upgrade: func(m map[string]any, _ any) (map[string]any, error) { return m, nil }, }) @@ -1508,7 +1508,7 @@ func TestResource_ValidateUpgradeState(t *testing.T) { Type: cty.Object(map[string]cty.Type{ "id": cty.String, }), - Upgrade: func(m map[string]interface{}, _ interface{}) (map[string]interface{}, error) { + Upgrade: func(m map[string]any, _ any) (map[string]any, error) { return m, nil }, }) @@ -1527,7 +1527,7 @@ func TestResource_ValidateUpgradeState(t *testing.T) { Type: cty.Object(map[string]cty.Type{ "id": cty.String, }), - Upgrade: func(m map[string]interface{}, _ interface{}) (map[string]interface{}, error) { + Upgrade: func(m map[string]any, _ any) (map[string]any, error) { return m, nil }, }) @@ -1548,7 +1548,7 @@ func TestResource_migrateAndUpgrade(t *testing.T) { }, }, // this MigrateState will take the state to version 2 - MigrateState: func(v int, is *terraform.InstanceState, _ interface{}) (*terraform.InstanceState, error) { + MigrateState: func(v int, is *terraform.InstanceState, _ any) (*terraform.InstanceState, error) { switch v { case 0: _, ok := is.Attributes["zero"] @@ -1572,7 +1572,7 @@ func TestResource_migrateAndUpgrade(t *testing.T) { }, } - r.Read = func(d *ResourceData, m interface{}) error { + r.Read = func(d *ResourceData, m any) error { return d.Set("four", 4) } @@ -1583,7 +1583,7 @@ func TestResource_migrateAndUpgrade(t *testing.T) { "id": cty.String, "two": cty.Number, }), - Upgrade: func(m map[string]interface{}, meta interface{}) (map[string]interface{}, error) { + Upgrade: func(m map[string]any, meta any) (map[string]any, error) { _, ok := m["two"].(float64) if !ok { return nil, fmt.Errorf("two not found in %#v", m) @@ -1599,7 +1599,7 @@ func TestResource_migrateAndUpgrade(t *testing.T) { "id": cty.String, "three": cty.Number, }), - Upgrade: func(m map[string]interface{}, meta interface{}) (map[string]interface{}, error) { + Upgrade: func(m map[string]any, meta any) (map[string]any, error) { _, ok := m["three"].(float64) if !ok { return nil, fmt.Errorf("three not found in %#v", m) @@ -1618,7 +1618,7 @@ func TestResource_migrateAndUpgrade(t *testing.T) { "id": "bar", "zero": "0", }, - Meta: map[string]interface{}{ + Meta: map[string]any{ "schema_version": "0", }, }, @@ -1628,7 +1628,7 @@ func TestResource_migrateAndUpgrade(t *testing.T) { "id": "bar", "one": "1", }, - Meta: map[string]interface{}{ + Meta: map[string]any{ "schema_version": "1", }, }, @@ -1638,7 +1638,7 @@ func TestResource_migrateAndUpgrade(t *testing.T) { "id": "bar", "two": "2", }, - Meta: map[string]interface{}{ + Meta: map[string]any{ "schema_version": "2", }, }, @@ -1648,7 +1648,7 @@ func TestResource_migrateAndUpgrade(t *testing.T) { "id": "bar", "three": "3", }, - Meta: map[string]interface{}{ + Meta: map[string]any{ "schema_version": "3", }, }, @@ -1658,7 +1658,7 @@ func TestResource_migrateAndUpgrade(t *testing.T) { "id": "bar", "four": "4", }, - Meta: map[string]interface{}{ + Meta: map[string]any{ "schema_version": "4", }, }, @@ -1677,7 +1677,7 @@ func TestResource_migrateAndUpgrade(t *testing.T) { "id": "bar", "four": "4", }, - Meta: map[string]interface{}{ + Meta: map[string]any{ "schema_version": "4", }, } diff --git a/staging/terraform/legacy/helper/schema/resource_timeout.go b/staging/terraform/legacy/helper/schema/resource_timeout.go index 32a4c0c..ff22643 100644 --- a/staging/terraform/legacy/helper/schema/resource_timeout.go +++ b/staging/terraform/legacy/helper/schema/resource_timeout.go @@ -35,7 +35,7 @@ func timeoutKeys() []string { } // could be time.Duration, int64 or float64 -func DefaultTimeout(tx interface{}) *time.Duration { +func DefaultTimeout(tx any) *time.Duration { var td time.Duration switch raw := tx.(type) { case time.Duration: @@ -66,11 +66,11 @@ func (t *ResourceTimeout) ConfigDecode(s *Resource, c *terraform.ResourceConfig) } if raw, ok := c.Config[TimeoutsConfigKey]; ok { - var rawTimeouts []map[string]interface{} + var rawTimeouts []map[string]any switch raw := raw.(type) { - case map[string]interface{}: + case map[string]any: rawTimeouts = append(rawTimeouts, raw) - case []map[string]interface{}: + case []map[string]any: rawTimeouts = raw case string: if raw == hcl2shim.UnknownVariableValue { @@ -81,9 +81,9 @@ func (t *ResourceTimeout) ConfigDecode(s *Resource, c *terraform.ResourceConfig) log.Printf("[ERROR] Invalid timeout value: %q", raw) return fmt.Errorf("Invalid Timeout value found") } - case []interface{}: + case []any: for _, r := range raw { - if rMap, ok := r.(map[string]interface{}); ok { + if rMap, ok := r.(map[string]any); ok { rawTimeouts = append(rawTimeouts, rMap) } else { // Go will not allow a fallthrough @@ -168,8 +168,8 @@ func (t *ResourceTimeout) StateEncode(is *terraform.InstanceState) error { // and stores it in the Meta field of the interface it's given. // Assumes the interface is either *terraform.InstanceState or // *terraform.InstanceDiff, returns an error otherwise -func (t *ResourceTimeout) metaEncode(ids interface{}) error { - m := make(map[string]interface{}) +func (t *ResourceTimeout) metaEncode(ids any) error { + m := make(map[string]any) if t.Create != nil { m[TimeoutCreate] = t.Create.Nanoseconds() @@ -199,12 +199,12 @@ func (t *ResourceTimeout) metaEncode(ids interface{}) error { switch instance := ids.(type) { case *terraform.InstanceDiff: if instance.Meta == nil { - instance.Meta = make(map[string]interface{}) + instance.Meta = make(map[string]any) } instance.Meta[TimeoutKey] = m case *terraform.InstanceState: if instance.Meta == nil { - instance.Meta = make(map[string]interface{}) + instance.Meta = make(map[string]any) } instance.Meta[TimeoutKey] = m default: @@ -222,8 +222,8 @@ func (t *ResourceTimeout) DiffDecode(is *terraform.InstanceDiff) error { return t.metaDecode(is) } -func (t *ResourceTimeout) metaDecode(ids interface{}) error { - var rawMeta interface{} +func (t *ResourceTimeout) metaDecode(ids any) error { + var rawMeta any var ok bool switch rawInstance := ids.(type) { case *terraform.InstanceDiff: @@ -240,7 +240,7 @@ func (t *ResourceTimeout) metaDecode(ids interface{}) error { return fmt.Errorf("Unknown or unsupported type in metaDecode: %#v", ids) } - times := rawMeta.(map[string]interface{}) + times := rawMeta.(map[string]any) if len(times) == 0 { return nil } diff --git a/staging/terraform/legacy/helper/schema/resource_timeout_test.go b/staging/terraform/legacy/helper/schema/resource_timeout_test.go index f272c5f..bb562c2 100644 --- a/staging/terraform/legacy/helper/schema/resource_timeout_test.go +++ b/staging/terraform/legacy/helper/schema/resource_timeout_test.go @@ -18,7 +18,7 @@ func TestResourceTimeout_ConfigDecode_badkey(t *testing.T) { // what the resource has defined in source ResourceDefaultTimeout *ResourceTimeout // configuration provider by user in tf file - Config map[string]interface{} + Config map[string]any // what we expect the parsed ResourceTimeout to be Expected *ResourceTimeout // Should we have an error (key not defined in source) @@ -48,7 +48,7 @@ func TestResourceTimeout_ConfigDecode_badkey(t *testing.T) { { Name: "Use something besides 'minutes'", ResourceDefaultTimeout: timeoutForValues(10, 0, 5, 0, 3), - Config: map[string]interface{}{ + Config: map[string]any{ "create": "2h", }, Expected: timeoutForValues(120, 0, 5, 0, 3), @@ -63,7 +63,7 @@ func TestResourceTimeout_ConfigDecode_badkey(t *testing.T) { } conf := terraform.NewResourceConfigRaw( - map[string]interface{}{ + map[string]any{ "foo": "bar", TimeoutsConfigKey: c.Config, }, @@ -100,9 +100,9 @@ func TestResourceTimeout_ConfigDecode(t *testing.T) { } c := terraform.NewResourceConfigRaw( - map[string]interface{}{ + map[string]any{ "foo": "bar", - TimeoutsConfigKey: map[string]interface{}{ + TimeoutsConfigKey: map[string]any{ "create": "2m", "update": "1m", }, @@ -134,10 +134,10 @@ func TestResourceTimeout_legacyConfigDecode(t *testing.T) { } c := terraform.NewResourceConfigRaw( - map[string]interface{}{ + map[string]any{ "foo": "bar", - TimeoutsConfigKey: []interface{}{ - map[string]interface{}{ + TimeoutsConfigKey: []any{ + map[string]any{ "create": "2m", "update": "1m", }, @@ -164,26 +164,26 @@ func TestResourceTimeout_legacyConfigDecode(t *testing.T) { func TestResourceTimeout_DiffEncode_basic(t *testing.T) { cases := []struct { Timeout *ResourceTimeout - Expected map[string]interface{} + Expected map[string]any // Not immediately clear when an error would hit ShouldErr bool }{ // Two fields { Timeout: timeoutForValues(10, 0, 5, 0, 0), - Expected: map[string]interface{}{TimeoutKey: expectedForValues(10, 0, 5, 0, 0)}, + Expected: map[string]any{TimeoutKey: expectedForValues(10, 0, 5, 0, 0)}, ShouldErr: false, }, // Two fields, one is Default { Timeout: timeoutForValues(10, 0, 0, 0, 7), - Expected: map[string]interface{}{TimeoutKey: expectedForValues(10, 0, 0, 0, 7)}, + Expected: map[string]any{TimeoutKey: expectedForValues(10, 0, 0, 0, 7)}, ShouldErr: false, }, // All fields { Timeout: timeoutForValues(10, 3, 4, 1, 7), - Expected: map[string]interface{}{TimeoutKey: expectedForValues(10, 3, 4, 1, 7)}, + Expected: map[string]any{TimeoutKey: expectedForValues(10, 3, 4, 1, 7)}, ShouldErr: false, }, // No fields @@ -232,19 +232,19 @@ func TestResourceTimeout_MetaDecode_basic(t *testing.T) { }{ // Two fields { - State: &terraform.InstanceDiff{Meta: map[string]interface{}{TimeoutKey: expectedForValues(10, 0, 5, 0, 0)}}, + State: &terraform.InstanceDiff{Meta: map[string]any{TimeoutKey: expectedForValues(10, 0, 5, 0, 0)}}, Expected: timeoutForValues(10, 0, 5, 0, 0), ShouldErr: false, }, // Two fields, one is Default { - State: &terraform.InstanceDiff{Meta: map[string]interface{}{TimeoutKey: expectedForValues(10, 0, 0, 0, 7)}}, + State: &terraform.InstanceDiff{Meta: map[string]any{TimeoutKey: expectedForValues(10, 0, 0, 0, 7)}}, Expected: timeoutForValues(10, 7, 7, 7, 7), ShouldErr: false, }, // All fields { - State: &terraform.InstanceDiff{Meta: map[string]interface{}{TimeoutKey: expectedForValues(10, 3, 4, 1, 7)}}, + State: &terraform.InstanceDiff{Meta: map[string]any{TimeoutKey: expectedForValues(10, 3, 4, 1, 7)}}, Expected: timeoutForValues(10, 3, 4, 1, 7), ShouldErr: false, }, @@ -326,8 +326,8 @@ func expectedTimeoutForValues(create, read, update, del, def int) *ResourceTimeo return &rt } -func expectedForValues(create, read, update, del, def int) map[string]interface{} { - ex := make(map[string]interface{}) +func expectedForValues(create, read, update, del, def int) map[string]any { + ex := make(map[string]any) if create != 0 { ex["create"] = DefaultTimeout(time.Duration(create) * time.Minute).Nanoseconds() @@ -356,8 +356,8 @@ func expectedForValues(create, read, update, del, def int) map[string]interface{ return ex } -func expectedConfigForValues(create, read, update, delete, def int) map[string]interface{} { - ex := make(map[string]interface{}, 0) +func expectedConfigForValues(create, read, update, delete, def int) map[string]any { + ex := make(map[string]any, 0) if create != 0 { ex["create"] = fmt.Sprintf("%dm", create) diff --git a/staging/terraform/legacy/helper/schema/schema.go b/staging/terraform/legacy/helper/schema/schema.go index 5857d04..bc96880 100644 --- a/staging/terraform/legacy/helper/schema/schema.go +++ b/staging/terraform/legacy/helper/schema/schema.go @@ -138,7 +138,7 @@ type Schema struct { // // If either of these is set, then the user won't be asked for input // for this key if the default is not nil. - Default interface{} + Default any DefaultFunc SchemaDefaultFunc // Description is used as the description for docs or asking for user @@ -175,7 +175,7 @@ type Schema struct { // *Resource. If it is *Schema, the element type is just a simple value. // If it is *Resource, the element type is a complex structure, // potentially managed via its own CRUD actions on the API. - Elem interface{} + Elem any // The following fields are only set for a TypeList or TypeSet. // @@ -272,13 +272,13 @@ type SchemaDiffSuppressFunc func(k, old, new string, d *ResourceData) bool // SchemaDefaultFunc is a function called to return a default value for // a field. -type SchemaDefaultFunc func() (interface{}, error) +type SchemaDefaultFunc func() (any, error) // EnvDefaultFunc is a helper function that returns the value of the // given environment variable, if one exists, or the default value // otherwise. -func EnvDefaultFunc(k string, dv interface{}) SchemaDefaultFunc { - return func() (interface{}, error) { +func EnvDefaultFunc(k string, dv any) SchemaDefaultFunc { + return func() (any, error) { if v := os.Getenv(k); v != "" { return v, nil } @@ -291,8 +291,8 @@ func EnvDefaultFunc(k string, dv interface{}) SchemaDefaultFunc { // environment variable in the given list that returns a non-empty value. If // none of the environment variables return a value, the default value is // returned. -func MultiEnvDefaultFunc(ks []string, dv interface{}) SchemaDefaultFunc { - return func() (interface{}, error) { +func MultiEnvDefaultFunc(ks []string, dv any) SchemaDefaultFunc { + return func() (any, error) { for _, k := range ks { if v := os.Getenv(k); v != "" { return v, nil @@ -304,15 +304,15 @@ func MultiEnvDefaultFunc(ks []string, dv interface{}) SchemaDefaultFunc { // SchemaSetFunc is a function that must return a unique ID for the given // element. This unique ID is used to store the element in a hash. -type SchemaSetFunc func(interface{}) int +type SchemaSetFunc func(any) int // SchemaStateFunc is a function used to convert some type to a string // to be stored in the state. -type SchemaStateFunc func(interface{}) string +type SchemaStateFunc func(any) string // SchemaValidateFunc is a function used to validate a single field in the // schema. -type SchemaValidateFunc func(interface{}, string) ([]string, []error) +type SchemaValidateFunc func(any, string) ([]string, []error) func (s *Schema) GoString() string { return fmt.Sprintf("*%#v", *s) @@ -320,7 +320,7 @@ func (s *Schema) GoString() string { // Returns a default value for this schema by either reading Default or // evaluating DefaultFunc. If neither of these are defined, returns nil. -func (s *Schema) DefaultValue() (interface{}, error) { +func (s *Schema) DefaultValue() (any, error) { if s.Default != nil { return s.Default, nil } @@ -337,7 +337,7 @@ func (s *Schema) DefaultValue() (interface{}, error) { } // Returns a zero value for the schema. -func (s *Schema) ZeroValue() interface{} { +func (s *Schema) ZeroValue() any { // If it's a set then we'll do a bit of extra work to provide the // right hashing function in our empty value. if s.Type == TypeSet { @@ -473,7 +473,7 @@ func (m schemaMap) Diff( s *terraform.InstanceState, c *terraform.ResourceConfig, customizeDiff CustomizeDiffFunc, - meta interface{}, + meta any, handleRequiresNew bool) (*terraform.InstanceDiff, error) { result := new(terraform.InstanceDiff) result.Attributes = make(map[string]*terraform.ResourceAttrDiff) @@ -654,7 +654,7 @@ func (m schemaMap) Input( continue } - var value interface{} + var value any switch v.Type { case TypeBool, TypeInt, TypeFloat, TypeSet, TypeList: continue @@ -857,10 +857,10 @@ func isValidFieldName(name string) bool { // This helps facilitate diff logic for both ResourceData and ResoureDiff with // minimal divergence in code. type resourceDiffer interface { - diffChange(string) (interface{}, interface{}, bool, bool, bool) - Get(string) interface{} - GetChange(string) (interface{}, interface{}) - GetOk(string) (interface{}, bool) + diffChange(string) (any, any, bool, bool, bool) + Get(string) any + GetChange(string) (any, any) + GetOk(string) (any, bool) HasChange(string) bool Id() string } @@ -933,10 +933,10 @@ func (m schemaMap) diffList( } if o == nil { - o = []interface{}{} + o = []any{} } if n == nil { - n = []interface{}{} + n = []any{} } if s, ok := o.(*Set); ok { o = s.List() @@ -944,8 +944,8 @@ func (m schemaMap) diffList( if s, ok := n.(*Set); ok { n = s.List() } - os := o.([]interface{}) - vs := n.([]interface{}) + os := o.([]any) + vs := n.([]any) // If the new value was set, and the two are equal, then we're done. // We have to do this check here because sets might be NOT @@ -1269,7 +1269,7 @@ func (m schemaMap) diffString( diff *terraform.InstanceDiff, d resourceDiffer, all bool) error { - var originalN interface{} + var originalN any var os, ns string o, n, _, computed, customized := d.diffChange(k) if schema.StateFunc != nil && n != nil { @@ -1325,7 +1325,7 @@ func (m schemaMap) diffString( func (m schemaMap) inputString( input terraform.UIInput, k string, - schema *Schema) (interface{}, error) { + schema *Schema) (any, error) { result, err := input.Input(context.Background(), &terraform.InputOpts{ Id: k, Query: k, @@ -1389,19 +1389,19 @@ func (m schemaMap) validate( } // isWhollyKnown returns false if the argument contains an UnknownVariableValue -func isWhollyKnown(raw interface{}) bool { +func isWhollyKnown(raw any) bool { switch raw := raw.(type) { case string: if raw == hcl2shim.UnknownVariableValue { return false } - case []interface{}: + case []any: for _, v := range raw { if !isWhollyKnown(v) { return false } } - case map[string]interface{}: + case map[string]any: for _, v := range raw { if !isWhollyKnown(v) { return false @@ -1436,7 +1436,7 @@ func (m schemaMap) validateConflictingAttributes( func (m schemaMap) validateList( k string, - raw interface{}, + raw any, schema *Schema, c *terraform.ResourceConfig) ([]string, []error) { // first check if the list is wholly unknown @@ -1458,7 +1458,7 @@ func (m schemaMap) validateList( // If we support promotion and the raw value isn't a slice, wrap // it in []interface{} and check again. if schema.PromoteSingle && rawV.Kind() != reflect.Slice { - raw = []interface{}{raw} + raw = []any{raw} rawV = reflect.ValueOf(raw) } @@ -1488,7 +1488,7 @@ func (m schemaMap) validateList( } // Now build the []interface{} - raws := make([]interface{}, rawV.Len()) + raws := make([]any, rawV.Len()) for i, _ := range raws { raws[i] = rawV.Index(i).Interface() } @@ -1528,7 +1528,7 @@ func (m schemaMap) validateList( func (m schemaMap) validateMap( k string, - raw interface{}, + raw any, schema *Schema, c *terraform.ResourceConfig) ([]string, []error) { // first check if the list is wholly unknown @@ -1564,7 +1564,7 @@ func (m schemaMap) validateMap( // If it is not a slice, validate directly if rawV.Kind() != reflect.Slice { mapIface := rawV.Interface() - if _, errs := validateMapValues(k, mapIface.(map[string]interface{}), schema); len(errs) > 0 { + if _, errs := validateMapValues(k, mapIface.(map[string]any), schema); len(errs) > 0 { return nil, errs } if schema.ValidateFunc != nil { @@ -1574,7 +1574,7 @@ func (m schemaMap) validateMap( } // It is a slice, verify that all the elements are maps - raws := make([]interface{}, rawV.Len()) + raws := make([]any, rawV.Len()) for i, _ := range raws { raws[i] = rawV.Index(i).Interface() } @@ -1586,15 +1586,15 @@ func (m schemaMap) validateMap( "%s: should be a map", k)} } mapIface := v.Interface() - if _, errs := validateMapValues(k, mapIface.(map[string]interface{}), schema); len(errs) > 0 { + if _, errs := validateMapValues(k, mapIface.(map[string]any), schema); len(errs) > 0 { return nil, errs } } if schema.ValidateFunc != nil { - validatableMap := make(map[string]interface{}) + validatableMap := make(map[string]any) for _, raw := range raws { - for k, v := range raw.(map[string]interface{}) { + for k, v := range raw.(map[string]any) { validatableMap[k] = v } } @@ -1605,7 +1605,7 @@ func (m schemaMap) validateMap( return nil, nil } -func validateMapValues(k string, m map[string]interface{}, schema *Schema) ([]string, []error) { +func validateMapValues(k string, m map[string]any, schema *Schema) ([]string, []error) { for key, raw := range m { valueType, err := getValueType(k, schema) if err != nil { @@ -1674,7 +1674,7 @@ func (m schemaMap) validateObject( return nil, nil } - if _, ok := raw.(map[string]interface{}); !ok && !c.IsComputed(k) { + if _, ok := raw.(map[string]any); !ok && !c.IsComputed(k) { return nil, []error{fmt.Errorf( "%s: expected object, got %s", k, reflect.ValueOf(raw).Kind())} @@ -1698,7 +1698,7 @@ func (m schemaMap) validateObject( } // Detect any extra/unknown keys and report those as errors. - if m, ok := raw.(map[string]interface{}); ok { + if m, ok := raw.(map[string]any); ok { for subk, _ := range m { if _, ok := schema[subk]; !ok { if subk == TimeoutsConfigKey { @@ -1715,7 +1715,7 @@ func (m schemaMap) validateObject( func (m schemaMap) validatePrimitive( k string, - raw interface{}, + raw any, schema *Schema, c *terraform.ResourceConfig) ([]string, []error) { @@ -1747,7 +1747,7 @@ func (m schemaMap) validatePrimitive( return nil, nil } - var decoded interface{} + var decoded any switch schema.Type { case TypeBool: // Verify that we can parse this as the correct type @@ -1803,7 +1803,7 @@ func (m schemaMap) validatePrimitive( func (m schemaMap) validateType( k string, - raw interface{}, + raw any, schema *Schema, c *terraform.ResourceConfig) ([]string, []error) { var ws []string @@ -1831,7 +1831,7 @@ func (m schemaMap) validateType( } // Zero returns the zero value for a type. -func (t ValueType) Zero() interface{} { +func (t ValueType) Zero() any { switch t { case TypeInvalid: return nil @@ -1844,13 +1844,13 @@ func (t ValueType) Zero() interface{} { case TypeString: return "" case TypeList: - return []interface{}{} + return []any{} case TypeMap: - return map[string]interface{}{} + return map[string]any{} case TypeSet: return new(Set) case typeObject: - return map[string]interface{}{} + return map[string]any{} default: panic(fmt.Sprintf("unknown type %s", t)) } diff --git a/staging/terraform/legacy/helper/schema/schema_test.go b/staging/terraform/legacy/helper/schema/schema_test.go index 8974097..906fb9b 100644 --- a/staging/terraform/legacy/helper/schema/schema_test.go +++ b/staging/terraform/legacy/helper/schema/schema_test.go @@ -109,14 +109,14 @@ func TestMultiEnvDefaultFunc(t *testing.T) { func TestValueType_Zero(t *testing.T) { cases := []struct { Type ValueType - Value interface{} + Value any }{ {TypeBool, false}, {TypeInt, 0}, {TypeFloat, 0.0}, {TypeString, ""}, - {TypeList, []interface{}{}}, - {TypeMap, map[string]interface{}{}}, + {TypeList, []any{}}, + {TypeMap, map[string]any{}}, {TypeSet, new(Set)}, } @@ -133,7 +133,7 @@ func TestSchemaMap_Diff(t *testing.T) { Name string Schema map[string]*Schema State *terraform.InstanceState - Config map[string]interface{} + Config map[string]any CustomizeDiff CustomizeDiffFunc Diff *terraform.InstanceDiff Err bool @@ -150,7 +150,7 @@ func TestSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{ + Config: map[string]any{ "availability_zone": "foo", }, @@ -179,7 +179,7 @@ func TestSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{}, + Config: map[string]any{}, Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ @@ -208,7 +208,7 @@ func TestSchemaMap_Diff(t *testing.T) { ID: "foo", }, - Config: map[string]interface{}{}, + Config: map[string]any{}, Diff: nil, @@ -231,7 +231,7 @@ func TestSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{ + Config: map[string]any{ "availability_zone": "bar", }, @@ -279,7 +279,7 @@ func TestSchemaMap_Diff(t *testing.T) { "availability_zone": &Schema{ Type: TypeString, Optional: true, - DefaultFunc: func() (interface{}, error) { + DefaultFunc: func() (any, error) { return "foo", nil }, }, @@ -307,7 +307,7 @@ func TestSchemaMap_Diff(t *testing.T) { "availability_zone": &Schema{ Type: TypeString, Optional: true, - DefaultFunc: func() (interface{}, error) { + DefaultFunc: func() (any, error) { return "foo", nil }, }, @@ -315,7 +315,7 @@ func TestSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{ + Config: map[string]any{ "availability_zone": "bar", }, @@ -338,7 +338,7 @@ func TestSchemaMap_Diff(t *testing.T) { Type: TypeString, Optional: true, Computed: true, - StateFunc: func(a interface{}) string { + StateFunc: func(a any) string { return a.(string) + "!" }, }, @@ -346,7 +346,7 @@ func TestSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{ + Config: map[string]any{ "availability_zone": "foo", }, @@ -370,7 +370,7 @@ func TestSchemaMap_Diff(t *testing.T) { Type: TypeString, Optional: true, Computed: true, - StateFunc: func(a interface{}) string { + StateFunc: func(a any) string { t.Fatalf("should not get here!") return "" }, @@ -379,7 +379,7 @@ func TestSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{}, + Config: map[string]any{}, Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ @@ -405,7 +405,7 @@ func TestSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{ + Config: map[string]any{ "availability_zone": hcl2shim.UnknownVariableValue, }, @@ -435,7 +435,7 @@ func TestSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{ + Config: map[string]any{ "port": 27, }, @@ -465,7 +465,7 @@ func TestSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{ + Config: map[string]any{ "port": false, }, @@ -517,8 +517,8 @@ func TestSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{ - "ports": []interface{}{1, 2, 5}, + Config: map[string]any{ + "ports": []any{1, 2, 5}, }, Diff: &terraform.InstanceDiff{ @@ -558,7 +558,7 @@ func TestSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{ + Config: map[string]any{ "ports": "5", }, @@ -591,8 +591,8 @@ func TestSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{ - "ports": []interface{}{"5"}, + Config: map[string]any{ + "ports": []any{"5"}, }, Diff: &terraform.InstanceDiff{ @@ -622,8 +622,8 @@ func TestSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{ - "ports": []interface{}{1, 2, 5}, + Config: map[string]any{ + "ports": []any{1, 2, 5}, }, Diff: &terraform.InstanceDiff{ @@ -661,8 +661,8 @@ func TestSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{ - "ports": []interface{}{1, hcl2shim.UnknownVariableValue, 5}, + Config: map[string]any{ + "ports": []any{1, hcl2shim.UnknownVariableValue, 5}, }, Diff: &terraform.InstanceDiff{ @@ -696,8 +696,8 @@ func TestSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{ - "ports": []interface{}{1, 2, 5}, + Config: map[string]any{ + "ports": []any{1, 2, 5}, }, Diff: nil, @@ -723,8 +723,8 @@ func TestSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{ - "ports": []interface{}{1, 2, 5}, + Config: map[string]any{ + "ports": []any{1, 2, 5}, }, Diff: &terraform.InstanceDiff{ @@ -756,8 +756,8 @@ func TestSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{ - "ports": []interface{}{1, 2, 5}, + Config: map[string]any{ + "ports": []any{1, 2, 5}, }, Diff: &terraform.InstanceDiff{ @@ -801,7 +801,7 @@ func TestSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{}, + Config: map[string]any{}, Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ @@ -843,9 +843,9 @@ func TestSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{ - "config": []interface{}{ - map[string]interface{}{ + Config: map[string]any{ + "config": []any{ + map[string]any{ "name": "hello", }, }, @@ -881,7 +881,7 @@ func TestSchemaMap_Diff(t *testing.T) { Type: TypeSet, Required: true, Elem: &Schema{Type: TypeInt}, - Set: func(a interface{}) int { + Set: func(a any) int { return a.(int) }, }, @@ -889,8 +889,8 @@ func TestSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{ - "ports": []interface{}{5, 2, 1}, + Config: map[string]any{ + "ports": []any{5, 2, 1}, }, Diff: &terraform.InstanceDiff{ @@ -925,7 +925,7 @@ func TestSchemaMap_Diff(t *testing.T) { Computed: true, Required: true, Elem: &Schema{Type: TypeInt}, - Set: func(a interface{}) int { + Set: func(a any) int { return a.(int) }, }, @@ -952,7 +952,7 @@ func TestSchemaMap_Diff(t *testing.T) { Optional: true, Computed: true, Elem: &Schema{Type: TypeInt}, - Set: func(a interface{}) int { + Set: func(a any) int { return a.(int) }, }, @@ -981,7 +981,7 @@ func TestSchemaMap_Diff(t *testing.T) { Type: TypeSet, Required: true, Elem: &Schema{Type: TypeInt}, - Set: func(a interface{}) int { + Set: func(a any) int { return a.(int) }, }, @@ -989,8 +989,8 @@ func TestSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{ - "ports": []interface{}{"2", "5", 1}, + Config: map[string]any{ + "ports": []any{"2", "5", 1}, }, Diff: &terraform.InstanceDiff{ @@ -1024,7 +1024,7 @@ func TestSchemaMap_Diff(t *testing.T) { Type: TypeSet, Required: true, Elem: &Schema{Type: TypeInt}, - Set: func(a interface{}) int { + Set: func(a any) int { return a.(int) }, }, @@ -1032,8 +1032,8 @@ func TestSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{ - "ports": []interface{}{1, hcl2shim.UnknownVariableValue, "5"}, + Config: map[string]any{ + "ports": []any{1, hcl2shim.UnknownVariableValue, "5"}, }, Diff: &terraform.InstanceDiff{ @@ -1056,7 +1056,7 @@ func TestSchemaMap_Diff(t *testing.T) { Type: TypeSet, Required: true, Elem: &Schema{Type: TypeInt}, - Set: func(a interface{}) int { + Set: func(a any) int { return a.(int) }, }, @@ -1070,8 +1070,8 @@ func TestSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{ - "ports": []interface{}{5, 2, 1}, + Config: map[string]any{ + "ports": []any{5, 2, 1}, }, Diff: &terraform.InstanceDiff{ @@ -1105,7 +1105,7 @@ func TestSchemaMap_Diff(t *testing.T) { Type: TypeSet, Required: true, Elem: &Schema{Type: TypeInt}, - Set: func(a interface{}) int { + Set: func(a any) int { return a.(int) }, }, @@ -1119,7 +1119,7 @@ func TestSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{}, + Config: map[string]any{}, Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ @@ -1151,7 +1151,7 @@ func TestSchemaMap_Diff(t *testing.T) { Optional: true, Computed: true, Elem: &Schema{Type: TypeInt}, - Set: func(a interface{}) int { + Set: func(a any) int { return a.(int) }, }, @@ -1165,7 +1165,7 @@ func TestSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{}, + Config: map[string]any{}, Diff: nil, @@ -1187,9 +1187,9 @@ func TestSchemaMap_Diff(t *testing.T) { }, }, }, - Set: func(v interface{}) int { - m := v.(map[string]interface{}) - ps := m["ports"].([]interface{}) + Set: func(v any) int { + m := v.(map[string]any) + ps := m["ports"].([]any) result := 0 for _, p := range ps { result += p.(int) @@ -1209,13 +1209,13 @@ func TestSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{ - "ingress": []interface{}{ - map[string]interface{}{ - "ports": []interface{}{443}, + Config: map[string]any{ + "ingress": []any{ + map[string]any{ + "ports": []any{443}, }, - map[string]interface{}{ - "ports": []interface{}{80}, + map[string]any{ + "ports": []any{80}, }, }, }, @@ -1244,9 +1244,9 @@ func TestSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{ - "ingress": []interface{}{ - map[string]interface{}{ + Config: map[string]any{ + "ingress": []any{ + map[string]any{ "from": 8080, }, }, @@ -1290,7 +1290,7 @@ func TestSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{ + Config: map[string]any{ "port": 80, }, @@ -1320,7 +1320,7 @@ func TestSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{ + Config: map[string]any{ "port": 80, }, @@ -1388,9 +1388,9 @@ func TestSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{ - "config_vars": []interface{}{ - map[string]interface{}{ + Config: map[string]any{ + "config_vars": []any{ + map[string]any{ "bar": "baz", }, }, @@ -1427,9 +1427,9 @@ func TestSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{ - "config_vars": []interface{}{ - map[string]interface{}{ + Config: map[string]any{ + "config_vars": []any{ + map[string]any{ "bar": "baz", }, }, @@ -1467,9 +1467,9 @@ func TestSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{ - "vars": []interface{}{ - map[string]interface{}{ + Config: map[string]any{ + "vars": []any{ + map[string]any{ "bar": "baz", }, }, @@ -1530,9 +1530,9 @@ func TestSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{ - "config_vars": []interface{}{ - map[string]interface{}{ + Config: map[string]any{ + "config_vars": []any{ + map[string]any{ "bar": "baz", }, }, @@ -1571,7 +1571,7 @@ func TestSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{}, + Config: map[string]any{}, Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ @@ -1620,7 +1620,7 @@ func TestSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{ + Config: map[string]any{ "availability_zone": "foo", }, @@ -1657,7 +1657,7 @@ func TestSchemaMap_Diff(t *testing.T) { Optional: true, Computed: true, Elem: &Schema{Type: TypeInt}, - Set: func(a interface{}) int { + Set: func(a any) int { return a.(int) }, }, @@ -1671,7 +1671,7 @@ func TestSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{ + Config: map[string]any{ "availability_zone": "foo", }, @@ -1702,7 +1702,7 @@ func TestSchemaMap_Diff(t *testing.T) { Elem: &Schema{Type: TypeString}, Optional: true, Computed: true, - Set: func(v interface{}) int { + Set: func(v any) int { return len(v.(string)) }, }, @@ -1714,8 +1714,8 @@ func TestSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{ - "instances": []interface{}{hcl2shim.UnknownVariableValue}, + Config: map[string]any{ + "instances": []any{hcl2shim.UnknownVariableValue}, }, Diff: &terraform.InstanceDiff{ @@ -1748,8 +1748,8 @@ func TestSchemaMap_Diff(t *testing.T) { }, }, }, - Set: func(v interface{}) int { - m := v.(map[string]interface{}) + Set: func(v any) int { + m := v.(map[string]any) return m["index"].(int) }, }, @@ -1757,9 +1757,9 @@ func TestSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{ - "route": []interface{}{ - map[string]interface{}{ + Config: map[string]any{ + "route": []any{ + map[string]any{ "index": "1", "gateway": hcl2shim.UnknownVariableValue, }, @@ -1804,14 +1804,14 @@ func TestSchemaMap_Diff(t *testing.T) { Type: TypeSet, Optional: true, Elem: &Schema{Type: TypeInt}, - Set: func(a interface{}) int { + Set: func(a any) int { return a.(int) }, }, }, }, - Set: func(v interface{}) int { - m := v.(map[string]interface{}) + Set: func(v any) int { + m := v.(map[string]any) return m["index"].(int) }, }, @@ -1819,11 +1819,11 @@ func TestSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{ - "route": []interface{}{ - map[string]interface{}{ + Config: map[string]any{ + "route": []any{ + map[string]any{ "index": "1", - "gateway": []interface{}{ + "gateway": []any{ hcl2shim.UnknownVariableValue, }, }, @@ -1889,8 +1889,8 @@ func TestSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{ - "vars": map[string]interface{}{ + Config: map[string]any{ + "vars": map[string]any{ "bar": hcl2shim.UnknownVariableValue, }, }, @@ -1913,7 +1913,7 @@ func TestSchemaMap_Diff(t *testing.T) { State: &terraform.InstanceState{}, - Config: map[string]interface{}{}, + Config: map[string]any{}, Diff: nil, @@ -1934,7 +1934,7 @@ func TestSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{ + Config: map[string]any{ "some_threshold": 12.34, }, @@ -1970,9 +1970,9 @@ func TestSchemaMap_Diff(t *testing.T) { }, }, }, - Set: func(v interface{}) int { + Set: func(v any) int { var buf bytes.Buffer - m := v.(map[string]interface{}) + m := v.(map[string]any) buf.WriteString(fmt.Sprintf("%s-", m["device_name"].(string))) buf.WriteString(fmt.Sprintf("%t-", m["delete_on_termination"].(bool))) return hashcode.String(buf.String()) @@ -1990,12 +1990,12 @@ func TestSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{ - "block_device": []interface{}{ - map[string]interface{}{ + Config: map[string]any{ + "block_device": []any{ + map[string]any{ "device_name": "/dev/sda1", }, - map[string]interface{}{ + map[string]any{ "device_name": "/dev/sdx", }, }, @@ -2020,7 +2020,7 @@ func TestSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{}, + Config: map[string]any{}, Diff: nil, @@ -2044,14 +2044,14 @@ func TestSchemaMap_Diff(t *testing.T) { Type: TypeSet, Optional: true, Elem: &Schema{Type: TypeInt}, - Set: func(a interface{}) int { + Set: func(a any) int { return a.(int) }, }, }, }, - Set: func(v interface{}) int { - m := v.(map[string]interface{}) + Set: func(v any) int { + m := v.(map[string]any) return m["index"].(int) }, }, @@ -2063,7 +2063,7 @@ func TestSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{}, + Config: map[string]any{}, Diff: nil, @@ -2086,7 +2086,7 @@ func TestSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{}, + Config: map[string]any{}, Diff: nil, @@ -2101,7 +2101,7 @@ func TestSchemaMap_Diff(t *testing.T) { Elem: &Schema{Type: TypeString}, Optional: true, ForceNew: true, - Set: func(v interface{}) int { + Set: func(v any) int { return len(v.(string)) }, }, @@ -2114,7 +2114,7 @@ func TestSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{}, + Config: map[string]any{}, Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ @@ -2145,8 +2145,8 @@ func TestSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{ - "vars": map[string]interface{}{ + Config: map[string]any{ + "vars": map[string]any{ "foo": "", }, }, @@ -2179,7 +2179,7 @@ func TestSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{}, + Config: map[string]any{}, Diff: nil, @@ -2194,13 +2194,13 @@ func TestSchemaMap_Diff(t *testing.T) { Optional: true, ForceNew: true, Elem: &Schema{Type: TypeInt}, - Set: func(interface{}) int { return 0 }, + Set: func(any) int { return 0 }, }, }, State: nil, - Config: map[string]interface{}{}, + Config: map[string]any{}, Diff: nil, @@ -2225,7 +2225,7 @@ func TestSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{}, + Config: map[string]any{}, Diff: nil, @@ -2239,7 +2239,7 @@ func TestSchemaMap_Diff(t *testing.T) { Type: TypeSet, Required: true, Elem: &Schema{Type: TypeInt}, - Set: func(a interface{}) int { + Set: func(a any) int { return a.(int) }, }, @@ -2247,8 +2247,8 @@ func TestSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{ - "ports": []interface{}{1, hcl2shim.UnknownVariableValue}, + Config: map[string]any{ + "ports": []any{1, hcl2shim.UnknownVariableValue}, }, Diff: &terraform.InstanceDiff{ @@ -2305,8 +2305,8 @@ func TestSchemaMap_Diff(t *testing.T) { }, }, }, - Set: func(v interface{}) int { - m := v.(map[string]interface{}) + Set: func(v any) int { + m := v.(map[string]any) return m["index"].(int) }, }, @@ -2314,9 +2314,9 @@ func TestSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{ - "route": []interface{}{ - map[string]interface{}{ + Config: map[string]any{ + "route": []any{ + map[string]any{ "index": "1", "gateway-name": "hello", }, @@ -2358,11 +2358,11 @@ func TestSchemaMap_Diff(t *testing.T) { ForceNew: true, Elem: &Schema{ Type: TypeString, - StateFunc: func(v interface{}) string { + StateFunc: func(v any) string { return v.(string) + "!" }, }, - Set: func(v interface{}) int { + Set: func(v any) int { i, err := strconv.Atoi(v.(string)) if err != nil { t.Fatalf("err: %s", err) @@ -2377,10 +2377,10 @@ func TestSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{ - "service_account": []interface{}{ - map[string]interface{}{ - "scopes": []interface{}{"123"}, + Config: map[string]any{ + "service_account": []any{ + map[string]any{ + "scopes": []any{"123"}, }, }, }, @@ -2417,7 +2417,7 @@ func TestSchemaMap_Diff(t *testing.T) { Elem: &Schema{Type: TypeString}, Optional: true, ForceNew: true, - Set: func(v interface{}) int { + Set: func(v any) int { return len(v.(string)) }, }, @@ -2431,8 +2431,8 @@ func TestSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{ - "instances": []interface{}{"333", "4444"}, + Config: map[string]any{ + "instances": []any{"333", "4444"}, }, Diff: &terraform.InstanceDiff{ @@ -2487,7 +2487,7 @@ func TestSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{ + Config: map[string]any{ "one": "1", "two": "0", }, @@ -2524,7 +2524,7 @@ func TestSchemaMap_Diff(t *testing.T) { Tainted: true, }, - Config: map[string]interface{}{}, + Config: map[string]any{}, Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{}, @@ -2542,7 +2542,7 @@ func TestSchemaMap_Diff(t *testing.T) { Required: true, ForceNew: true, Elem: &Schema{Type: TypeInt}, - Set: func(a interface{}) int { + Set: func(a any) int { return a.(int) }, }, @@ -2557,8 +2557,8 @@ func TestSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{ - "ports": []interface{}{5, 2, 1}, + Config: map[string]any{ + "ports": []any{5, 2, 1}, }, Diff: &terraform.InstanceDiff{ @@ -2606,7 +2606,7 @@ func TestSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{}, + Config: map[string]any{}, Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ @@ -2636,7 +2636,7 @@ func TestSchemaMap_Diff(t *testing.T) { State: &terraform.InstanceState{}, - Config: map[string]interface{}{ + Config: map[string]any{ "foo": hcl2shim.UnknownVariableValue, }, @@ -2662,7 +2662,7 @@ func TestSchemaMap_Diff(t *testing.T) { Required: true, ForceNew: true, Elem: &Schema{Type: TypeInt}, - Set: func(a interface{}) int { + Set: func(a any) int { return a.(int) }, }, @@ -2677,8 +2677,8 @@ func TestSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{ - "ports": []interface{}{hcl2shim.UnknownVariableValue, 2, 1}, + Config: map[string]any{ + "ports": []any{hcl2shim.UnknownVariableValue, 2, 1}, }, Diff: &terraform.InstanceDiff{ @@ -2714,8 +2714,8 @@ func TestSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{ - "config": []interface{}{hcl2shim.UnknownVariableValue, hcl2shim.UnknownVariableValue}, + Config: map[string]any{ + "config": []any{hcl2shim.UnknownVariableValue, hcl2shim.UnknownVariableValue}, }, Diff: &terraform.InstanceDiff{ @@ -2744,11 +2744,11 @@ func TestSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{ + Config: map[string]any{ "availability_zone": "foo", }, - CustomizeDiff: func(d *ResourceDiff, meta interface{}) error { + CustomizeDiff: func(d *ResourceDiff, meta any) error { if err := d.SetNew("availability_zone", "bar"); err != nil { return err } @@ -2787,9 +2787,9 @@ func TestSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{}, + Config: map[string]any{}, - CustomizeDiff: func(d *ResourceDiff, meta interface{}) error { + CustomizeDiff: func(d *ResourceDiff, meta any) error { if err := d.SetNew("availability_zone", "bar"); err != nil { return err } @@ -2826,11 +2826,11 @@ func TestSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{ + Config: map[string]any{ "availability_zone": "foo", }, - CustomizeDiff: func(d *ResourceDiff, meta interface{}) error { + CustomizeDiff: func(d *ResourceDiff, meta any) error { if err := d.SetNew("availability_zone", "bar"); err != nil { return err } @@ -2865,11 +2865,11 @@ func TestSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{ + Config: map[string]any{ "ami_id": "foo", }, - CustomizeDiff: func(d *ResourceDiff, meta interface{}) error { + CustomizeDiff: func(d *ResourceDiff, meta any) error { if err := d.SetNew("instance_id", "bar"); err != nil { return err } @@ -2900,7 +2900,7 @@ func TestSchemaMap_Diff(t *testing.T) { Optional: true, Computed: true, Elem: &Schema{Type: TypeInt}, - Set: func(a interface{}) int { + Set: func(a any) int { return a.(int) }, }, @@ -2915,12 +2915,12 @@ func TestSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{ - "ports": []interface{}{5, 2, 6}, + Config: map[string]any{ + "ports": []any{5, 2, 6}, }, - CustomizeDiff: func(d *ResourceDiff, meta interface{}) error { - if err := d.SetNew("ports", []interface{}{5, 2, 1}); err != nil { + CustomizeDiff: func(d *ResourceDiff, meta any) error { + if err := d.SetNew("ports", []any{5, 2, 1}); err != nil { return err } if err := d.ForceNew("ports"); err != nil { @@ -2969,9 +2969,9 @@ func TestSchemaMap_Diff(t *testing.T) { Tainted: true, }, - Config: map[string]interface{}{}, + Config: map[string]any{}, - CustomizeDiff: func(d *ResourceDiff, meta interface{}) error { + CustomizeDiff: func(d *ResourceDiff, meta any) error { return errors.New("diff customization should not have run") }, @@ -3004,11 +3004,11 @@ func TestSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{ + Config: map[string]any{ "etag": "bar", }, - CustomizeDiff: func(d *ResourceDiff, meta interface{}) error { + CustomizeDiff: func(d *ResourceDiff, meta any) error { if d.HasChange("etag") { d.SetNewComputed("version_id") } @@ -3048,9 +3048,9 @@ func TestSchemaMap_Diff(t *testing.T) { ID: "pre-existing", }, - Config: map[string]interface{}{}, + Config: map[string]any{}, - CustomizeDiff: func(d *ResourceDiff, meta interface{}) error { + CustomizeDiff: func(d *ResourceDiff, meta any) error { d.SetNewComputed("foo") return nil }, @@ -3082,11 +3082,11 @@ func TestSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{ + Config: map[string]any{ "foo": "baz", }, - CustomizeDiff: func(d *ResourceDiff, meta interface{}) error { + CustomizeDiff: func(d *ResourceDiff, meta any) error { return fmt.Errorf("diff vetoed") }, @@ -3113,7 +3113,7 @@ func TestSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{ + Config: map[string]any{ "attr": "", }, }, @@ -3144,11 +3144,11 @@ func TestSchemaMap_Diff(t *testing.T) { "stream_view_type": "KEYS_ONLY", }, }, - Config: map[string]interface{}{ + Config: map[string]any{ "stream_enabled": false, "stream_view_type": "", }, - CustomizeDiff: func(diff *ResourceDiff, v interface{}) error { + CustomizeDiff: func(diff *ResourceDiff, v any) error { v, ok := diff.GetOk("unrelated_set") if ok { return fmt.Errorf("Didn't expect unrelated_set: %#v", v) @@ -3185,9 +3185,9 @@ func TestSchemaMap_Diff(t *testing.T) { func TestSchemaMap_Input(t *testing.T) { cases := map[string]struct { Schema map[string]*Schema - Config map[string]interface{} + Config map[string]any Input map[string]string - Result map[string]interface{} + Result map[string]any Err bool }{ /* @@ -3203,7 +3203,7 @@ func TestSchemaMap_Input(t *testing.T) { }, Input: map[string]string{}, - Result: map[string]interface{}{}, + Result: map[string]any{}, Err: false, }, @@ -3215,7 +3215,7 @@ func TestSchemaMap_Input(t *testing.T) { }, }, - Config: map[string]interface{}{ + Config: map[string]any{ "availability_zone": "bar", }, @@ -3223,7 +3223,7 @@ func TestSchemaMap_Input(t *testing.T) { "availability_zone": "foo", }, - Result: map[string]interface{}{}, + Result: map[string]any{}, Err: false, }, @@ -3241,7 +3241,7 @@ func TestSchemaMap_Input(t *testing.T) { "availability_zone": "bar", }, - Result: map[string]interface{}{}, + Result: map[string]any{}, Err: false, }, @@ -3250,7 +3250,7 @@ func TestSchemaMap_Input(t *testing.T) { Schema: map[string]*Schema{ "availability_zone": &Schema{ Type: TypeString, - DefaultFunc: func() (interface{}, error) { + DefaultFunc: func() (any, error) { return "foo", nil }, Optional: true, @@ -3261,7 +3261,7 @@ func TestSchemaMap_Input(t *testing.T) { "availability_zone": "bar", }, - Result: map[string]interface{}{}, + Result: map[string]any{}, Err: false, }, @@ -3279,7 +3279,7 @@ func TestSchemaMap_Input(t *testing.T) { "availability_zone": "bar", }, - Result: map[string]interface{}{}, + Result: map[string]any{}, Err: false, }, @@ -3288,7 +3288,7 @@ func TestSchemaMap_Input(t *testing.T) { Schema: map[string]*Schema{ "availability_zone": &Schema{ Type: TypeString, - DefaultFunc: func() (interface{}, error) { + DefaultFunc: func() (any, error) { return nil, nil }, Required: true, @@ -3299,7 +3299,7 @@ func TestSchemaMap_Input(t *testing.T) { "availability_zone": "bar", }, - Result: map[string]interface{}{ + Result: map[string]any{ "availability_zone": "bar", }, @@ -3310,7 +3310,7 @@ func TestSchemaMap_Input(t *testing.T) { Schema: map[string]*Schema{ "availability_zone": &Schema{ Type: TypeString, - DefaultFunc: func() (interface{}, error) { + DefaultFunc: func() (any, error) { return nil, nil }, Optional: true, @@ -3318,21 +3318,21 @@ func TestSchemaMap_Input(t *testing.T) { }, Input: map[string]string{}, - Result: map[string]interface{}{}, + Result: map[string]any{}, Err: false, }, } for i, tc := range cases { if tc.Config == nil { - tc.Config = make(map[string]interface{}) + tc.Config = make(map[string]any) } input := new(terraform.MockUIInput) input.InputReturnMap = tc.Input rc := terraform.NewResourceConfigRaw(tc.Config) - rc.Config = make(map[string]interface{}) + rc.Config = make(map[string]any) actual, err := schemaMap(tc.Schema).Input(input, rc) if err != nil != tc.Err { @@ -3346,9 +3346,9 @@ func TestSchemaMap_Input(t *testing.T) { } func TestSchemaMap_InputDefault(t *testing.T) { - emptyConfig := make(map[string]interface{}) + emptyConfig := make(map[string]any) rc := terraform.NewResourceConfigRaw(emptyConfig) - rc.Config = make(map[string]interface{}) + rc.Config = make(map[string]any) input := new(terraform.MockUIInput) input.InputFn = func(opts *terraform.InputOpts) (string, error) { @@ -3368,7 +3368,7 @@ func TestSchemaMap_InputDefault(t *testing.T) { t.Fatalf("err: %s", err) } - expected := map[string]interface{}{} + expected := map[string]any{} if !reflect.DeepEqual(expected, actual.Config) { t.Fatalf("got: %#v\nexpected: %#v", actual.Config, expected) @@ -3376,9 +3376,9 @@ func TestSchemaMap_InputDefault(t *testing.T) { } func TestSchemaMap_InputDeprecated(t *testing.T) { - emptyConfig := make(map[string]interface{}) + emptyConfig := make(map[string]any) rc := terraform.NewResourceConfigRaw(emptyConfig) - rc.Config = make(map[string]interface{}) + rc.Config = make(map[string]any) input := new(terraform.MockUIInput) input.InputFn = func(opts *terraform.InputOpts) (string, error) { @@ -3398,7 +3398,7 @@ func TestSchemaMap_InputDeprecated(t *testing.T) { t.Fatalf("err: %s", err) } - expected := map[string]interface{}{} + expected := map[string]any{} if !reflect.DeepEqual(expected, actual.Config) { t.Fatalf("got: %#v\nexpected: %#v", actual.Config, expected) @@ -3528,7 +3528,7 @@ func TestSchemaMap_InternalValidate(t *testing.T) { "foo": &Schema{ Type: TypeList, Elem: &Schema{Type: TypeInt}, - Set: func(interface{}) int { return 0 }, + Set: func(any) int { return 0 }, Optional: true, }, }, @@ -3636,7 +3636,7 @@ func TestSchemaMap_InternalValidate(t *testing.T) { "foo": &Schema{ Type: TypeSet, Required: true, - ValidateFunc: func(v interface{}, k string) (ws []string, es []error) { + ValidateFunc: func(v any, k string) (ws []string, es []error) { return }, }, @@ -3649,7 +3649,7 @@ func TestSchemaMap_InternalValidate(t *testing.T) { "string": &Schema{ Type: TypeString, Computed: true, - ValidateFunc: func(v interface{}, k string) (ws []string, es []error) { + ValidateFunc: func(v any, k string) (ws []string, es []error) { es = append(es, fmt.Errorf("this is not fine")) return }, @@ -3821,7 +3821,7 @@ func TestSchemaMap_DiffSuppress(t *testing.T) { cases := map[string]struct { Schema map[string]*Schema State *terraform.InstanceState - Config map[string]interface{} + Config map[string]any ExpectedDiff *terraform.InstanceDiff Err bool }{ @@ -3839,7 +3839,7 @@ func TestSchemaMap_DiffSuppress(t *testing.T) { State: nil, - Config: map[string]interface{}{ + Config: map[string]any{ "availability_zone": "foo", }, @@ -3862,7 +3862,7 @@ func TestSchemaMap_DiffSuppress(t *testing.T) { State: nil, - Config: map[string]interface{}{ + Config: map[string]any{ "availability_zone": "foo", }, @@ -3892,7 +3892,7 @@ func TestSchemaMap_DiffSuppress(t *testing.T) { State: nil, - Config: map[string]interface{}{}, + Config: map[string]any{}, ExpectedDiff: nil, @@ -3913,7 +3913,7 @@ func TestSchemaMap_DiffSuppress(t *testing.T) { State: nil, - Config: map[string]interface{}{}, + Config: map[string]any{}, ExpectedDiff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ @@ -3949,13 +3949,13 @@ func TestSchemaMap_DiffSuppress(t *testing.T) { }, }, }, - Set: func(v interface{}) int { + Set: func(v any) int { return 2 }, }, }, }, - Set: func(v interface{}) int { + Set: func(v any) int { return 1 }, }, @@ -3963,12 +3963,12 @@ func TestSchemaMap_DiffSuppress(t *testing.T) { State: nil, - Config: map[string]interface{}{ - "outer": []interface{}{ - map[string]interface{}{ + Config: map[string]any{ + "outer": []any{ + map[string]any{ "outer_str": "foo", - "inner": []interface{}{ - map[string]interface{}{ + "inner": []any{ + map[string]any{ "inner_str": hcl2shim.UnknownVariableValue, }, }, @@ -4026,7 +4026,7 @@ func TestSchemaMap_DiffSuppress(t *testing.T) { }, }, }, - Set: func(v interface{}) int { + Set: func(v any) int { return 1 }, }, @@ -4034,12 +4034,12 @@ func TestSchemaMap_DiffSuppress(t *testing.T) { State: nil, - Config: map[string]interface{}{ - "outer": []interface{}{ - map[string]interface{}{ + Config: map[string]any{ + "outer": []any{ + map[string]any{ "outer_str": "foo", - "inner": []interface{}{ - map[string]interface{}{ + "inner": []any{ + map[string]any{ "inner_str": hcl2shim.UnknownVariableValue, }, }, @@ -4092,7 +4092,7 @@ func TestSchemaMap_DiffSuppress(t *testing.T) { func TestSchemaMap_Validate(t *testing.T) { cases := map[string]struct { Schema map[string]*Schema - Config map[string]interface{} + Config map[string]any Err bool Errors []error Warnings []string @@ -4107,7 +4107,7 @@ func TestSchemaMap_Validate(t *testing.T) { }, }, - Config: map[string]interface{}{ + Config: map[string]any{ "availability_zone": "foo", }, }, @@ -4120,7 +4120,7 @@ func TestSchemaMap_Validate(t *testing.T) { }, }, - Config: map[string]interface{}{ + Config: map[string]any{ "size": hcl2shim.UnknownVariableValue, }, }, @@ -4133,7 +4133,7 @@ func TestSchemaMap_Validate(t *testing.T) { }, }, - Config: map[string]interface{}{}, + Config: map[string]any{}, Err: true, }, @@ -4146,7 +4146,7 @@ func TestSchemaMap_Validate(t *testing.T) { }, }, - Config: map[string]interface{}{ + Config: map[string]any{ "port": "I am invalid", }, @@ -4161,9 +4161,9 @@ func TestSchemaMap_Validate(t *testing.T) { }, }, - Config: map[string]interface{}{ - "user_data": []interface{}{ - map[string]interface{}{ + Config: map[string]any{ + "user_data": []any{ + map[string]any{ "foo": "bar", }, }, @@ -4180,7 +4180,7 @@ func TestSchemaMap_Validate(t *testing.T) { }, }, - Config: map[string]interface{}{ + Config: map[string]any{ "size": "nope", }, @@ -4192,7 +4192,7 @@ func TestSchemaMap_Validate(t *testing.T) { "availability_zone": &Schema{ Type: TypeString, Required: true, - DefaultFunc: func() (interface{}, error) { + DefaultFunc: func() (any, error) { return "foo", nil }, }, @@ -4206,7 +4206,7 @@ func TestSchemaMap_Validate(t *testing.T) { "availability_zone": &Schema{ Type: TypeString, Required: true, - DefaultFunc: func() (interface{}, error) { + DefaultFunc: func() (any, error) { return nil, nil }, }, @@ -4227,7 +4227,7 @@ func TestSchemaMap_Validate(t *testing.T) { }, }, - Config: map[string]interface{}{ + Config: map[string]any{ "ingress": "5", }, @@ -4244,8 +4244,8 @@ func TestSchemaMap_Validate(t *testing.T) { }, }, - Config: map[string]interface{}{ - "ingress": []interface{}{"5"}, + Config: map[string]any{ + "ingress": []any{"5"}, }, Err: false, @@ -4266,7 +4266,7 @@ func TestSchemaMap_Validate(t *testing.T) { }, }, - Config: map[string]interface{}{}, + Config: map[string]any{}, Err: false, }, @@ -4287,8 +4287,8 @@ func TestSchemaMap_Validate(t *testing.T) { }, }, - Config: map[string]interface{}{ - "ingress": []interface{}{"foo"}, + Config: map[string]any{ + "ingress": []any{"foo"}, }, Err: true, @@ -4310,7 +4310,7 @@ func TestSchemaMap_Validate(t *testing.T) { }, }, - Config: map[string]interface{}{ + Config: map[string]any{ "ingress": "foo", }, @@ -4331,7 +4331,7 @@ func TestSchemaMap_Validate(t *testing.T) { }, }, - Config: map[string]interface{}{ + Config: map[string]any{ "strings": "foo", }, @@ -4352,7 +4352,7 @@ func TestSchemaMap_Validate(t *testing.T) { }, }, - Config: map[string]interface{}{ + Config: map[string]any{ "strings": hcl2shim.UnknownVariableValue, }, @@ -4368,7 +4368,7 @@ func TestSchemaMap_Validate(t *testing.T) { }, }, - Config: map[string]interface{}{ + Config: map[string]any{ "old_news": hcl2shim.UnknownVariableValue, }, @@ -4392,9 +4392,9 @@ func TestSchemaMap_Validate(t *testing.T) { }, }, - Config: map[string]interface{}{ - "ingress": []interface{}{ - map[string]interface{}{}, + Config: map[string]any{ + "ingress": []any{ + map[string]any{}, }, }, @@ -4417,9 +4417,9 @@ func TestSchemaMap_Validate(t *testing.T) { }, }, - Config: map[string]interface{}{ - "ingress": []interface{}{ - map[string]interface{}{ + Config: map[string]any{ + "ingress": []any{ + map[string]any{ "from": 80, }, }, @@ -4444,9 +4444,9 @@ func TestSchemaMap_Validate(t *testing.T) { }, }, - Config: map[string]interface{}{ - "ingress": []interface{}{ - map[string]interface{}{ + Config: map[string]any{ + "ingress": []any{ + map[string]any{ "from": hcl2shim.UnknownVariableValue, }, }, @@ -4465,7 +4465,7 @@ func TestSchemaMap_Validate(t *testing.T) { }, }, - Config: map[string]interface{}{ + Config: map[string]any{ "foo": "bar", }, @@ -4482,7 +4482,7 @@ func TestSchemaMap_Validate(t *testing.T) { }, }, - Config: map[string]interface{}{ + Config: map[string]any{ "foo": hcl2shim.UnknownVariableValue, }, @@ -4497,7 +4497,7 @@ func TestSchemaMap_Validate(t *testing.T) { }, }, - Config: map[string]interface{}{ + Config: map[string]any{ "availability_zone": "bar", }, @@ -4510,13 +4510,13 @@ func TestSchemaMap_Validate(t *testing.T) { Type: TypeSet, Required: true, Elem: &Schema{Type: TypeInt}, - Set: func(a interface{}) int { + Set: func(a any) int { return a.(int) }, }, }, - Config: map[string]interface{}{ + Config: map[string]any{ "ports": "foo", }, @@ -4531,7 +4531,7 @@ func TestSchemaMap_Validate(t *testing.T) { }, }, - Config: map[string]interface{}{ + Config: map[string]any{ "user_data": "foo", }, @@ -4546,9 +4546,9 @@ func TestSchemaMap_Validate(t *testing.T) { }, }, - Config: map[string]interface{}{ - "user_data": []interface{}{ - map[string]interface{}{ + Config: map[string]any{ + "user_data": []any{ + map[string]any{ "foo": "bar", }, }, @@ -4563,8 +4563,8 @@ func TestSchemaMap_Validate(t *testing.T) { }, }, - Config: map[string]interface{}{ - "user_data": map[string]interface{}{ + Config: map[string]any{ + "user_data": map[string]any{ "foo": "bar", }, }, @@ -4579,8 +4579,8 @@ func TestSchemaMap_Validate(t *testing.T) { }, }, - Config: map[string]interface{}{ - "user_data": map[string]interface{}{ + Config: map[string]any{ + "user_data": map[string]any{ "foo": "not_a_bool", }, }, @@ -4597,8 +4597,8 @@ func TestSchemaMap_Validate(t *testing.T) { }, }, - Config: map[string]interface{}{ - "user_data": map[string]interface{}{ + Config: map[string]any{ + "user_data": map[string]any{ "foo": "not_a_bool", }, }, @@ -4614,8 +4614,8 @@ func TestSchemaMap_Validate(t *testing.T) { }, }, - Config: map[string]interface{}{ - "user_data": []interface{}{ + Config: map[string]any{ + "user_data": []any{ "foo", }, }, @@ -4631,14 +4631,14 @@ func TestSchemaMap_Validate(t *testing.T) { Computed: true, ForceNew: true, Elem: &Schema{Type: TypeString}, - Set: func(v interface{}) int { + Set: func(v any) int { return len(v.(string)) }, }, }, - Config: map[string]interface{}{ - "security_groups": []interface{}{"${var.foo}"}, + Config: map[string]any{ + "security_groups": []any{"${var.foo}"}, }, Err: false, @@ -4655,7 +4655,7 @@ func TestSchemaMap_Validate(t *testing.T) { }, }, - Config: map[string]interface{}{ + Config: map[string]any{ "security_groups": "${var.foo}", }, @@ -4678,9 +4678,9 @@ func TestSchemaMap_Validate(t *testing.T) { }, }, - Config: map[string]interface{}{ - "ingress": []interface{}{ - map[string]interface{}{ + Config: map[string]any{ + "ingress": []any{ + map[string]any{ "port": 80, "other": "yes", }, @@ -4706,9 +4706,9 @@ func TestSchemaMap_Validate(t *testing.T) { }, }, - Config: map[string]interface{}{ - "ingress": []interface{}{ - map[string]interface{}{ + Config: map[string]any{ + "ingress": []any{ + map[string]any{ "port": "bad", }, }, @@ -4725,8 +4725,8 @@ func TestSchemaMap_Validate(t *testing.T) { }, }, - Config: map[string]interface{}{ - "availability_zone": []interface{}{"foo", "bar", "baz"}, + Config: map[string]any{ + "availability_zone": []any{"foo", "bar", "baz"}, }, Err: true, @@ -4740,8 +4740,8 @@ func TestSchemaMap_Validate(t *testing.T) { }, }, - Config: map[string]interface{}{ - "availability_zone": map[string]interface{}{"foo": "bar", "baz": "thing"}, + Config: map[string]any{ + "availability_zone": map[string]any{"foo": "bar", "baz": "thing"}, }, Err: true, @@ -4756,7 +4756,7 @@ func TestSchemaMap_Validate(t *testing.T) { }, }, - Config: map[string]interface{}{ + Config: map[string]any{ "old_news": "extra extra!", }, @@ -4790,7 +4790,7 @@ func TestSchemaMap_Validate(t *testing.T) { }, }, - Config: map[string]interface{}{ + Config: map[string]any{ "long_gone": "still here!", }, @@ -4825,7 +4825,7 @@ func TestSchemaMap_Validate(t *testing.T) { }, }, - Config: map[string]interface{}{ + Config: map[string]any{ "b": "b-val", "a": "a-val", }, @@ -4849,7 +4849,7 @@ func TestSchemaMap_Validate(t *testing.T) { }, }, - Config: map[string]interface{}{ + Config: map[string]any{ "b": "b-val", "a": hcl2shim.UnknownVariableValue, }, @@ -4870,7 +4870,7 @@ func TestSchemaMap_Validate(t *testing.T) { }, }, - Config: map[string]interface{}{ + Config: map[string]any{ "b": hcl2shim.UnknownVariableValue, "a": "a-val", }, @@ -4897,7 +4897,7 @@ func TestSchemaMap_Validate(t *testing.T) { }, }, - Config: map[string]interface{}{ + Config: map[string]any{ "b": hcl2shim.UnknownVariableValue, "a": "a-val", "c": "c-val", @@ -4923,7 +4923,7 @@ func TestSchemaMap_Validate(t *testing.T) { }, }, - Config: map[string]interface{}{ + Config: map[string]any{ "required_att": "required-val", }, @@ -4943,7 +4943,7 @@ func TestSchemaMap_Validate(t *testing.T) { }, }, - Config: map[string]interface{}{ + Config: map[string]any{ "required_att": "required-val", "optional_att": "optional-val", }, @@ -4970,7 +4970,7 @@ func TestSchemaMap_Validate(t *testing.T) { }, }, - Config: map[string]interface{}{ + Config: map[string]any{ "foo_att": "foo-val", "bar_att": "bar-val", }, @@ -4998,7 +4998,7 @@ func TestSchemaMap_Validate(t *testing.T) { }, }, - Config: map[string]interface{}{ + Config: map[string]any{ "foo_att": "foo-val", }, @@ -5021,7 +5021,7 @@ func TestSchemaMap_Validate(t *testing.T) { }, }, - Config: map[string]interface{}{}, + Config: map[string]any{}, Err: false, }, @@ -5031,12 +5031,12 @@ func TestSchemaMap_Validate(t *testing.T) { "validate_me": &Schema{ Type: TypeString, Required: true, - ValidateFunc: func(v interface{}, k string) (ws []string, es []error) { + ValidateFunc: func(v any, k string) (ws []string, es []error) { return }, }, }, - Config: map[string]interface{}{ + Config: map[string]any{ "validate_me": "valid", }, Err: false, @@ -5047,13 +5047,13 @@ func TestSchemaMap_Validate(t *testing.T) { "validate_me": &Schema{ Type: TypeString, Required: true, - ValidateFunc: func(v interface{}, k string) (ws []string, es []error) { + ValidateFunc: func(v any, k string) (ws []string, es []error) { es = append(es, fmt.Errorf("something is not right here")) return }, }, }, - Config: map[string]interface{}{ + Config: map[string]any{ "validate_me": "invalid", }, Err: true, @@ -5067,13 +5067,13 @@ func TestSchemaMap_Validate(t *testing.T) { "number": &Schema{ Type: TypeInt, Required: true, - ValidateFunc: func(v interface{}, k string) (ws []string, es []error) { + ValidateFunc: func(v any, k string) (ws []string, es []error) { t.Fatalf("Should not have gotten validate call") return }, }, }, - Config: map[string]interface{}{ + Config: map[string]any{ "number": "NaN", }, Err: true, @@ -5084,7 +5084,7 @@ func TestSchemaMap_Validate(t *testing.T) { "maybe": &Schema{ Type: TypeBool, Required: true, - ValidateFunc: func(v interface{}, k string) (ws []string, es []error) { + ValidateFunc: func(v any, k string) (ws []string, es []error) { if _, ok := v.(bool); !ok { t.Fatalf("Expected bool, got: %#v", v) } @@ -5092,7 +5092,7 @@ func TestSchemaMap_Validate(t *testing.T) { }, }, }, - Config: map[string]interface{}{ + Config: map[string]any{ "maybe": "true", }, }, @@ -5102,13 +5102,13 @@ func TestSchemaMap_Validate(t *testing.T) { "validate_me": &Schema{ Type: TypeString, Required: true, - ValidateFunc: func(v interface{}, k string) (ws []string, es []error) { + ValidateFunc: func(v any, k string) (ws []string, es []error) { es = append(es, fmt.Errorf("something is not right here")) return }, }, }, - Config: map[string]interface{}{ + Config: map[string]any{ "validate_me": hcl2shim.UnknownVariableValue, }, @@ -5125,7 +5125,7 @@ func TestSchemaMap_Validate(t *testing.T) { }, }, - Config: map[string]interface{}{ + Config: map[string]any{ TimeoutsConfigKey: "bar", }, @@ -5139,7 +5139,7 @@ func TestSchemaMap_Validate(t *testing.T) { Optional: true, }, }, - Config: map[string]interface{}{ + Config: map[string]any{ "bool_field": "abcdef", }, Err: true, @@ -5151,7 +5151,7 @@ func TestSchemaMap_Validate(t *testing.T) { Optional: true, }, }, - Config: map[string]interface{}{ + Config: map[string]any{ "integer_field": "abcdef", }, Err: true, @@ -5163,7 +5163,7 @@ func TestSchemaMap_Validate(t *testing.T) { Optional: true, }, }, - Config: map[string]interface{}{ + Config: map[string]any{ "float_field": "abcdef", }, Err: true, @@ -5178,8 +5178,8 @@ func TestSchemaMap_Validate(t *testing.T) { Optional: true, }, }, - Config: map[string]interface{}{ - "boolMap": map[string]interface{}{ + Config: map[string]any{ + "boolMap": map[string]any{ "boolField": "notbool", }, }, @@ -5193,8 +5193,8 @@ func TestSchemaMap_Validate(t *testing.T) { Optional: true, }, }, - Config: map[string]interface{}{ - "intMap": map[string]interface{}{ + Config: map[string]any{ + "intMap": map[string]any{ "intField": "notInt", }, }, @@ -5208,8 +5208,8 @@ func TestSchemaMap_Validate(t *testing.T) { Optional: true, }, }, - Config: map[string]interface{}{ - "floatMap": map[string]interface{}{ + Config: map[string]any{ + "floatMap": map[string]any{ "floatField": "notFloat", }, }, @@ -5222,13 +5222,13 @@ func TestSchemaMap_Validate(t *testing.T) { Type: TypeMap, Elem: TypeInt, Optional: true, - ValidateFunc: func(v interface{}, k string) (ws []string, es []error) { + ValidateFunc: func(v any, k string) (ws []string, es []error) { return }, }, }, - Config: map[string]interface{}{ - "floatInt": map[string]interface{}{ + Config: map[string]any{ + "floatInt": map[string]any{ "rightAnswer": "42", "tooMuch": "43", }, @@ -5241,14 +5241,14 @@ func TestSchemaMap_Validate(t *testing.T) { Type: TypeMap, Elem: TypeInt, Optional: true, - ValidateFunc: func(v interface{}, k string) (ws []string, es []error) { + ValidateFunc: func(v any, k string) (ws []string, es []error) { es = append(es, fmt.Errorf("this is not fine")) return }, }, }, - Config: map[string]interface{}{ - "floatInt": map[string]interface{}{ + Config: map[string]any{ + "floatInt": map[string]any{ "rightAnswer": "42", "tooMuch": "43", }, @@ -5271,7 +5271,7 @@ func TestSchemaMap_Validate(t *testing.T) { Optional: true, Elem: &Schema{ Type: TypeString, - ValidateFunc: func(v interface{}, k string) (ws []string, es []error) { + ValidateFunc: func(v any, k string) (ws []string, es []error) { if strings.HasPrefix(v.(string), "${") { es = append(es, fmt.Errorf("should not have interpolations")) } @@ -5283,10 +5283,10 @@ func TestSchemaMap_Validate(t *testing.T) { }, }, }, - Config: map[string]interface{}{ - "outer": []interface{}{ - map[string]interface{}{ - "list": []interface{}{"A", hcl2shim.UnknownVariableValue, "c"}, + Config: map[string]any{ + "outer": []any{ + map[string]any{ + "list": []any{"A", hcl2shim.UnknownVariableValue, "c"}, }, }, }, @@ -5315,9 +5315,9 @@ func TestSchemaMap_Validate(t *testing.T) { }, }, - Config: map[string]interface{}{ - "strings": []interface{}{"1", nil}, - "block": []interface{}{map[string]interface{}{ + Config: map[string]any{ + "strings": []any{"1", nil}, + "block": []any{map[string]any{ "int": nil, }, nil, @@ -5365,7 +5365,7 @@ func TestSchemaSet_ValidateMaxItems(t *testing.T) { cases := map[string]struct { Schema map[string]*Schema State *terraform.InstanceState - Config map[string]interface{} + Config map[string]any ConfigVariables map[string]string Diff *terraform.InstanceDiff Err bool @@ -5381,8 +5381,8 @@ func TestSchemaSet_ValidateMaxItems(t *testing.T) { }, }, State: nil, - Config: map[string]interface{}{ - "aliases": []interface{}{"foo", "bar"}, + Config: map[string]any{ + "aliases": []any{"foo", "bar"}, }, Diff: nil, Err: true, @@ -5399,8 +5399,8 @@ func TestSchemaSet_ValidateMaxItems(t *testing.T) { }, }, State: nil, - Config: map[string]interface{}{ - "aliases": []interface{}{"foo", "bar"}, + Config: map[string]any{ + "aliases": []any{"foo", "bar"}, }, Diff: nil, Err: false, @@ -5416,8 +5416,8 @@ func TestSchemaSet_ValidateMaxItems(t *testing.T) { }, }, State: nil, - Config: map[string]interface{}{ - "aliases": []interface{}{"foo"}, + Config: map[string]any{ + "aliases": []any{"foo"}, }, Diff: nil, Err: false, @@ -5453,7 +5453,7 @@ func TestSchemaSet_ValidateMinItems(t *testing.T) { cases := map[string]struct { Schema map[string]*Schema State *terraform.InstanceState - Config map[string]interface{} + Config map[string]any ConfigVariables map[string]string Diff *terraform.InstanceDiff Err bool @@ -5469,8 +5469,8 @@ func TestSchemaSet_ValidateMinItems(t *testing.T) { }, }, State: nil, - Config: map[string]interface{}{ - "aliases": []interface{}{"foo", "bar"}, + Config: map[string]any{ + "aliases": []any{"foo", "bar"}, }, Diff: nil, Err: false, @@ -5485,8 +5485,8 @@ func TestSchemaSet_ValidateMinItems(t *testing.T) { }, }, State: nil, - Config: map[string]interface{}{ - "aliases": []interface{}{"foo", "bar"}, + Config: map[string]any{ + "aliases": []any{"foo", "bar"}, }, Diff: nil, Err: false, @@ -5502,8 +5502,8 @@ func TestSchemaSet_ValidateMinItems(t *testing.T) { }, }, State: nil, - Config: map[string]interface{}{ - "aliases": []interface{}{"foo"}, + Config: map[string]any{ + "aliases": []any{"foo"}, }, Diff: nil, Err: true, diff --git a/staging/terraform/legacy/helper/schema/serialize.go b/staging/terraform/legacy/helper/schema/serialize.go index a36f85b..656a5ba 100644 --- a/staging/terraform/legacy/helper/schema/serialize.go +++ b/staging/terraform/legacy/helper/schema/serialize.go @@ -10,7 +10,7 @@ import ( "strconv" ) -func SerializeValueForHash(buf *bytes.Buffer, val interface{}, schema *Schema) { +func SerializeValueForHash(buf *bytes.Buffer, val any, schema *Schema) { if val == nil { buf.WriteRune(';') return @@ -31,14 +31,14 @@ func SerializeValueForHash(buf *bytes.Buffer, val interface{}, schema *Schema) { buf.WriteString(val.(string)) case TypeList: buf.WriteRune('(') - l := val.([]interface{}) + l := val.([]any) for _, innerVal := range l { serializeCollectionMemberForHash(buf, innerVal, schema.Elem) } buf.WriteRune(')') case TypeMap: - m := val.(map[string]interface{}) + m := val.(map[string]any) var keys []string for k := range m { keys = append(keys, k) @@ -87,12 +87,12 @@ func SerializeValueForHash(buf *bytes.Buffer, val interface{}, schema *Schema) { // Its primary purpose is as input into a hashing function in order // to hash complex substructures when used in sets, and so the serialization // is not reversible. -func SerializeResourceForHash(buf *bytes.Buffer, val interface{}, resource *Resource) { +func SerializeResourceForHash(buf *bytes.Buffer, val any, resource *Resource) { if val == nil { return } sm := resource.Schema - m := val.(map[string]interface{}) + m := val.(map[string]any) var keys []string for k := range sm { keys = append(keys, k) @@ -114,7 +114,7 @@ func SerializeResourceForHash(buf *bytes.Buffer, val interface{}, resource *Reso } } -func serializeCollectionMemberForHash(buf *bytes.Buffer, val interface{}, elem interface{}) { +func serializeCollectionMemberForHash(buf *bytes.Buffer, val any, elem any) { switch tElem := elem.(type) { case *Schema: SerializeValueForHash(buf, val, tElem) diff --git a/staging/terraform/legacy/helper/schema/serialize_test.go b/staging/terraform/legacy/helper/schema/serialize_test.go index 499a603..a7b0d0f 100644 --- a/staging/terraform/legacy/helper/schema/serialize_test.go +++ b/staging/terraform/legacy/helper/schema/serialize_test.go @@ -10,8 +10,8 @@ import ( func TestSerializeForHash(t *testing.T) { type testCase struct { - Schema interface{} - Value interface{} + Schema any + Value any Expected string } @@ -95,7 +95,7 @@ func TestSerializeForHash(t *testing.T) { Type: TypeString, }, }, - Value: []interface{}{}, + Value: []any{}, Expected: "();", }, @@ -106,7 +106,7 @@ func TestSerializeForHash(t *testing.T) { Type: TypeString, }, }, - Value: []interface{}{"hello", "world"}, + Value: []any{"hello", "world"}, Expected: "(hello;world;);", }, @@ -126,11 +126,11 @@ func TestSerializeForHash(t *testing.T) { }, }, }, - Value: []interface{}{ - map[string]interface{}{ + Value: []any{ + map[string]any{ "fo": "bar", }, - map[string]interface{}{ + map[string]any{ "fo": "baz", "fum": "boz", }, @@ -145,7 +145,7 @@ func TestSerializeForHash(t *testing.T) { Type: TypeString, }, }, - Value: NewSet(func(i interface{}) int { return len(i.(string)) }, []interface{}{ + Value: NewSet(func(i any) int { return len(i.(string)) }, []any{ "hello", "woo", }), @@ -159,7 +159,7 @@ func TestSerializeForHash(t *testing.T) { Type: TypeString, }, }, - Value: map[string]interface{}{ + Value: map[string]any{ "foo": "bar", "baz": "foo", }, @@ -188,7 +188,7 @@ func TestSerializeForHash(t *testing.T) { }, }, }, - Value: map[string]interface{}{ + Value: map[string]any{ "name": "my-fun-database", "size": 12, "green": true, @@ -210,9 +210,9 @@ func TestSerializeForHash(t *testing.T) { }, }, }, - Value: map[string]interface{}{ - "outer": NewSet(func(i interface{}) int { return 42 }, []interface{}{ - map[string]interface{}{ + Value: map[string]any{ + "outer": NewSet(func(i any) int { return 42 }, []any{ + map[string]any{ "foo": "bar", "baz": "foo", }, diff --git a/staging/terraform/legacy/helper/schema/set.go b/staging/terraform/legacy/helper/schema/set.go index 2971e2f..1dccd77 100644 --- a/staging/terraform/legacy/helper/schema/set.go +++ b/staging/terraform/legacy/helper/schema/set.go @@ -16,13 +16,13 @@ import ( // HashString hashes strings. If you want a Set of strings, this is the // SchemaSetFunc you want. -func HashString(v interface{}) int { +func HashString(v any) int { return hashcode.String(v.(string)) } // HashInt hashes integers. If you want a Set of integers, this is the // SchemaSetFunc you want. -func HashInt(v interface{}) int { +func HashInt(v any) int { return hashcode.String(strconv.Itoa(v.(int))) } @@ -30,7 +30,7 @@ func HashInt(v interface{}) int { // a *Resource. This is the default set implementation used when a set's // element type is a full resource. func HashResource(resource *Resource) SchemaSetFunc { - return func(v interface{}) int { + return func(v any) int { var buf bytes.Buffer SerializeResourceForHash(&buf, v, resource) return hashcode.String(buf.String()) @@ -41,7 +41,7 @@ func HashResource(resource *Resource) SchemaSetFunc { // default set implementation used when a set's element type is a single // schema. func HashSchema(schema *Schema) SchemaSetFunc { - return func(v interface{}) int { + return func(v any) int { var buf bytes.Buffer SerializeValueForHash(&buf, v, schema) return hashcode.String(buf.String()) @@ -53,13 +53,13 @@ func HashSchema(schema *Schema) SchemaSetFunc { type Set struct { F SchemaSetFunc - m map[string]interface{} + m map[string]any once sync.Once } // NewSet is a convenience method for creating a new set with the given // items. -func NewSet(f SchemaSetFunc, items []interface{}) *Set { +func NewSet(f SchemaSetFunc, items []any) *Set { s := &Set{F: f} for _, i := range items { s.Add(i) @@ -74,17 +74,17 @@ func CopySet(otherSet *Set) *Set { } // Add adds an item to the set if it isn't already in the set. -func (s *Set) Add(item interface{}) { +func (s *Set) Add(item any) { s.add(item, false) } // Remove removes an item if it's already in the set. Idempotent. -func (s *Set) Remove(item interface{}) { +func (s *Set) Remove(item any) { s.remove(item) } // Contains checks if the set has the given item. -func (s *Set) Contains(item interface{}) bool { +func (s *Set) Contains(item any) bool { _, ok := s.m[s.hash(item)] return ok } @@ -98,8 +98,8 @@ func (s *Set) Len() int { // // The order of the returned elements is deterministic. Given the same // set, the order of this will always be the same. -func (s *Set) List() []interface{} { - result := make([]interface{}, len(s.m)) +func (s *Set) List() []any { + result := make([]any, len(s.m)) for i, k := range s.listCode() { result[i] = s.m[k] } @@ -153,7 +153,7 @@ func (s *Set) Union(other *Set) *Set { return result } -func (s *Set) Equal(raw interface{}) bool { +func (s *Set) Equal(raw any) bool { other, ok := raw.(*Set) if !ok { return false @@ -165,7 +165,7 @@ func (s *Set) Equal(raw interface{}) bool { // HashEqual simply checks to the keys the top-level map to the keys in the // other set's top-level map to see if they are equal. This obviously assumes // you have a properly working hash function - use HashResource if in doubt. -func (s *Set) HashEqual(raw interface{}) bool { +func (s *Set) HashEqual(raw any) bool { other, ok := raw.(*Set) if !ok { return false @@ -192,10 +192,10 @@ func (s *Set) GoString() string { } func (s *Set) init() { - s.m = make(map[string]interface{}) + s.m = make(map[string]any) } -func (s *Set) add(item interface{}, computed bool) string { +func (s *Set) add(item any, computed bool) string { s.once.Do(s.init) code := s.hash(item) @@ -220,7 +220,7 @@ func (s *Set) add(item interface{}, computed bool) string { return code } -func (s *Set) hash(item interface{}) string { +func (s *Set) hash(item any) string { code := s.F(item) // Always return a nonnegative hashcode. if code < 0 { @@ -229,7 +229,7 @@ func (s *Set) hash(item interface{}) string { return strconv.Itoa(code) } -func (s *Set) remove(item interface{}) string { +func (s *Set) remove(item any) string { s.once.Do(s.init) code := s.hash(item) @@ -238,7 +238,7 @@ func (s *Set) remove(item interface{}) string { return code } -func (s *Set) index(item interface{}) int { +func (s *Set) index(item any) int { return sort.SearchStrings(s.listCode(), s.hash(item)) } diff --git a/staging/terraform/legacy/helper/schema/set_test.go b/staging/terraform/legacy/helper/schema/set_test.go index 1d37b24..b17f697 100644 --- a/staging/terraform/legacy/helper/schema/set_test.go +++ b/staging/terraform/legacy/helper/schema/set_test.go @@ -14,7 +14,7 @@ func TestSetAdd(t *testing.T) { s.Add(5) s.Add(25) - expected := []interface{}{1, 25, 5} + expected := []any{1, 25, 5} actual := s.List() if !reflect.DeepEqual(actual, expected) { t.Fatalf("bad: %#v", actual) @@ -28,7 +28,7 @@ func TestSetAdd_negative(t *testing.T) { s.Add(-1) s.Add(1) - expected := []interface{}{-1} + expected := []any{-1} actual := s.List() if !reflect.DeepEqual(actual, expected) { t.Fatalf("bad: %#v", actual) @@ -64,7 +64,7 @@ func TestSetDifference(t *testing.T) { difference := s1.Difference(s2) difference.Add(2) - expected := []interface{}{1, 2} + expected := []any{1, 2} actual := difference.List() if !reflect.DeepEqual(actual, expected) { t.Fatalf("bad: %#v", actual) @@ -84,7 +84,7 @@ func TestSetIntersection(t *testing.T) { intersection := s1.Intersection(s2) intersection.Add(2) - expected := []interface{}{2, 5} + expected := []any{2, 5} actual := intersection.List() if !reflect.DeepEqual(actual, expected) { t.Fatalf("bad: %#v", actual) @@ -104,14 +104,14 @@ func TestSetUnion(t *testing.T) { union := s1.Union(s2) union.Add(2) - expected := []interface{}{1, 2, 25, 5} + expected := []any{1, 2, 25, 5} actual := union.List() if !reflect.DeepEqual(actual, expected) { t.Fatalf("bad: %#v", actual) } } -func testSetInt(v interface{}) int { +func testSetInt(v any) int { return v.(int) } @@ -154,29 +154,29 @@ func TestHashEqual(t *testing.T) { }, }, } - n1 := map[string]interface{}{"foo": "bar"} - n2 := map[string]interface{}{"foo": "baz"} + n1 := map[string]any{"foo": "bar"} + n2 := map[string]any{"foo": "baz"} - r1 := map[string]interface{}{ + r1 := map[string]any{ "bar": "baz", - "nested": NewSet(HashResource(nested), []interface{}{n1}), + "nested": NewSet(HashResource(nested), []any{n1}), } - r2 := map[string]interface{}{ + r2 := map[string]any{ "bar": "qux", - "nested": NewSet(HashResource(nested), []interface{}{n2}), + "nested": NewSet(HashResource(nested), []any{n2}), } - r3 := map[string]interface{}{ + r3 := map[string]any{ "bar": "baz", - "nested": NewSet(HashResource(nested), []interface{}{n2}), + "nested": NewSet(HashResource(nested), []any{n2}), } - r4 := map[string]interface{}{ + r4 := map[string]any{ "bar": "qux", - "nested": NewSet(HashResource(nested), []interface{}{n1}), + "nested": NewSet(HashResource(nested), []any{n1}), } - s1 := NewSet(HashResource(root), []interface{}{r1}) - s2 := NewSet(HashResource(root), []interface{}{r2}) - s3 := NewSet(HashResource(root), []interface{}{r3}) - s4 := NewSet(HashResource(root), []interface{}{r4}) + s1 := NewSet(HashResource(root), []any{r1}) + s2 := NewSet(HashResource(root), []any{r2}) + s3 := NewSet(HashResource(root), []any{r3}) + s4 := NewSet(HashResource(root), []any{r4}) cases := []struct { name string diff --git a/staging/terraform/legacy/helper/schema/shims.go b/staging/terraform/legacy/helper/schema/shims.go index 4011951..57ec9ca 100644 --- a/staging/terraform/legacy/helper/schema/shims.go +++ b/staging/terraform/legacy/helper/schema/shims.go @@ -49,20 +49,20 @@ func diffFromValues(prior, planned cty.Value, res *Resource, cust CustomizeDiffF // During apply the only unknown values are those which are to be computed by // the resource itself. These may have been marked as unknown config values, and // need to be removed to prevent the UnknownVariableValue from appearing the diff. -func removeConfigUnknowns(cfg map[string]interface{}) { +func removeConfigUnknowns(cfg map[string]any) { for k, v := range cfg { switch v := v.(type) { case string: if v == hcl2shim.UnknownVariableValue { delete(cfg, k) } - case []interface{}: + case []any: for _, i := range v { - if m, ok := i.(map[string]interface{}); ok { + if m, ok := i.(map[string]any); ok { removeConfigUnknowns(m) } } - case map[string]interface{}: + case map[string]any: removeConfigUnknowns(v) } } @@ -78,13 +78,13 @@ func ApplyDiff(base cty.Value, d *terraform.InstanceDiff, schema *configschema.B // StateValueToJSONMap converts a cty.Value to generic JSON map via the cty JSON // encoding. -func StateValueToJSONMap(val cty.Value, ty cty.Type) (map[string]interface{}, error) { +func StateValueToJSONMap(val cty.Value, ty cty.Type) (map[string]any, error) { js, err := ctyjson.Marshal(val, ty) if err != nil { return nil, err } - var m map[string]interface{} + var m map[string]any if err := json.Unmarshal(js, &m); err != nil { return nil, err } @@ -94,7 +94,7 @@ func StateValueToJSONMap(val cty.Value, ty cty.Type) (map[string]interface{}, er // JSONMapToStateValue takes a generic json map[string]interface{} and converts it // to the specific type, ensuring that the values conform to the schema. -func JSONMapToStateValue(m map[string]interface{}, block *configschema.Block) (cty.Value, error) { +func JSONMapToStateValue(m map[string]any, block *configschema.Block) (cty.Value, error) { var val cty.Value js, err := json.Marshal(m) diff --git a/staging/terraform/legacy/helper/schema/shims_test.go b/staging/terraform/legacy/helper/schema/shims_test.go index 8029f39..9a0d51d 100644 --- a/staging/terraform/legacy/helper/schema/shims_test.go +++ b/staging/terraform/legacy/helper/schema/shims_test.go @@ -114,7 +114,7 @@ func TestShimResourcePlan_destroyCreate(t *testing.T) { "id": hcl2shim.UnknownVariableValue, "foo": "42", }, - Meta: map[string]interface{}{ + Meta: map[string]any{ "schema_version": "2", }, } @@ -134,7 +134,7 @@ func TestShimResourceApply_create(t *testing.T) { } called := false - r.Create = func(d *ResourceData, m interface{}) error { + r.Create = func(d *ResourceData, m any) error { called = true d.SetId("foo") return nil @@ -165,7 +165,7 @@ func TestShimResourceApply_create(t *testing.T) { "id": "foo", "foo": "42", }, - Meta: map[string]interface{}{ + Meta: map[string]any{ "schema_version": "2", }, } @@ -203,7 +203,7 @@ func TestShimResourceApply_Timeout_state(t *testing.T) { } called := false - r.Create = func(d *ResourceData, m interface{}) error { + r.Create = func(d *ResourceData, m any) error { called = true d.SetId("foo") return nil @@ -244,7 +244,7 @@ func TestShimResourceApply_Timeout_state(t *testing.T) { "id": "foo", "foo": "42", }, - Meta: map[string]interface{}{ + Meta: map[string]any{ "schema_version": "2", TimeoutKey: expectedForValues(40, 0, 80, 40, 0), }, @@ -279,14 +279,14 @@ func TestShimResourceDiff_Timeout_diff(t *testing.T) { }, } - r.Create = func(d *ResourceData, m interface{}) error { + r.Create = func(d *ResourceData, m any) error { d.SetId("foo") return nil } - conf := terraform.NewResourceConfigRaw(map[string]interface{}{ + conf := terraform.NewResourceConfigRaw(map[string]any{ "foo": 42, - TimeoutsConfigKey: map[string]interface{}{ + TimeoutsConfigKey: map[string]any{ "create": "2h", }, }) @@ -367,7 +367,7 @@ func TestShimResourceApply_destroy(t *testing.T) { } called := false - r.Delete = func(d *ResourceData, m interface{}) error { + r.Delete = func(d *ResourceData, m any) error { called = true return nil } @@ -417,12 +417,12 @@ func TestShimResourceApply_destroyCreate(t *testing.T) { } change := false - r.Create = func(d *ResourceData, m interface{}) error { + r.Create = func(d *ResourceData, m any) error { change = d.HasChange("tags") d.SetId("foo") return nil } - r.Delete = func(d *ResourceData, m interface{}) error { + r.Delete = func(d *ResourceData, m any) error { return nil } @@ -497,7 +497,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { Name string Schema map[string]*Schema State *terraform.InstanceState - Config map[string]interface{} + Config map[string]any CustomizeDiff CustomizeDiffFunc Diff *terraform.InstanceDiff Err bool @@ -515,7 +515,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{ + Config: map[string]any{ "availability_zone": "foo", }, @@ -545,7 +545,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{}, + Config: map[string]any{}, Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ @@ -575,7 +575,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { ID: "foo", }, - Config: map[string]interface{}{}, + Config: map[string]any{}, Diff: nil, @@ -599,7 +599,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{ + Config: map[string]any{ "availability_zone": "bar", }, @@ -647,7 +647,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { "availability_zone": &Schema{ Type: TypeString, Optional: true, - DefaultFunc: func() (interface{}, error) { + DefaultFunc: func() (any, error) { return "foo", nil }, }, @@ -675,7 +675,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { "availability_zone": &Schema{ Type: TypeString, Optional: true, - DefaultFunc: func() (interface{}, error) { + DefaultFunc: func() (any, error) { return "foo", nil }, }, @@ -683,7 +683,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{ + Config: map[string]any{ "availability_zone": "bar", }, @@ -706,7 +706,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { Type: TypeString, Optional: true, Computed: true, - StateFunc: func(a interface{}) string { + StateFunc: func(a any) string { return a.(string) + "!" }, }, @@ -714,7 +714,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{ + Config: map[string]any{ "availability_zone": "foo", }, @@ -738,7 +738,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { Type: TypeString, Optional: true, Computed: true, - StateFunc: func(a interface{}) string { + StateFunc: func(a any) string { t.Error("should not get here!") return "" }, @@ -747,7 +747,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{}, + Config: map[string]any{}, Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ @@ -773,7 +773,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{ + Config: map[string]any{ "availability_zone": hcl2shim.UnknownVariableValue, }, @@ -803,7 +803,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{ + Config: map[string]any{ "port": 27, }, @@ -833,7 +833,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{ + Config: map[string]any{ "port": false, }, @@ -886,8 +886,8 @@ func TestShimSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{ - "ports": []interface{}{1, 2, 5}, + Config: map[string]any{ + "ports": []any{1, 2, 5}, }, Diff: &terraform.InstanceDiff{ @@ -927,8 +927,8 @@ func TestShimSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{ - "ports": []interface{}{"5"}, + Config: map[string]any{ + "ports": []any{"5"}, }, Diff: &terraform.InstanceDiff{ @@ -958,8 +958,8 @@ func TestShimSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{ - "ports": []interface{}{1, 2, 5}, + Config: map[string]any{ + "ports": []any{1, 2, 5}, }, Diff: &terraform.InstanceDiff{ @@ -997,8 +997,8 @@ func TestShimSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{ - "ports": []interface{}{1, hcl2shim.UnknownVariableValue, "5"}, + Config: map[string]any{ + "ports": []any{1, hcl2shim.UnknownVariableValue, "5"}, }, Diff: &terraform.InstanceDiff{ @@ -1033,8 +1033,8 @@ func TestShimSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{ - "ports": []interface{}{1, 2, 5}, + Config: map[string]any{ + "ports": []any{1, 2, 5}, }, Diff: nil, @@ -1061,8 +1061,8 @@ func TestShimSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{ - "ports": []interface{}{1, 2, 5}, + Config: map[string]any{ + "ports": []any{1, 2, 5}, }, Diff: &terraform.InstanceDiff{ @@ -1094,8 +1094,8 @@ func TestShimSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{ - "ports": []interface{}{1, 2, 5}, + Config: map[string]any{ + "ports": []any{1, 2, 5}, }, Diff: &terraform.InstanceDiff{ @@ -1139,7 +1139,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{}, + Config: map[string]any{}, Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ @@ -1181,9 +1181,9 @@ func TestShimSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{ - "config": []interface{}{ - map[string]interface{}{ + Config: map[string]any{ + "config": []any{ + map[string]any{ "name": "hello", }, }, @@ -1219,7 +1219,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { Type: TypeSet, Required: true, Elem: &Schema{Type: TypeInt}, - Set: func(a interface{}) int { + Set: func(a any) int { return a.(int) }, }, @@ -1227,8 +1227,8 @@ func TestShimSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{ - "ports": []interface{}{5, 2, 1}, + Config: map[string]any{ + "ports": []any{5, 2, 1}, }, Diff: &terraform.InstanceDiff{ @@ -1263,7 +1263,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { Computed: true, Required: true, Elem: &Schema{Type: TypeInt}, - Set: func(a interface{}) int { + Set: func(a any) int { return a.(int) }, }, @@ -1291,7 +1291,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { Optional: true, Computed: true, Elem: &Schema{Type: TypeInt}, - Set: func(a interface{}) int { + Set: func(a any) int { return a.(int) }, }, @@ -1320,7 +1320,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { Type: TypeSet, Required: true, Elem: &Schema{Type: TypeInt}, - Set: func(a interface{}) int { + Set: func(a any) int { return a.(int) }, }, @@ -1328,8 +1328,8 @@ func TestShimSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{ - "ports": []interface{}{"2", "5", 1}, + Config: map[string]any{ + "ports": []any{"2", "5", 1}, }, Diff: &terraform.InstanceDiff{ @@ -1363,7 +1363,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { Type: TypeSet, Required: true, Elem: &Schema{Type: TypeInt}, - Set: func(a interface{}) int { + Set: func(a any) int { return a.(int) }, }, @@ -1371,8 +1371,8 @@ func TestShimSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{ - "ports": []interface{}{1, hcl2shim.UnknownVariableValue, 5}, + Config: map[string]any{ + "ports": []any{1, hcl2shim.UnknownVariableValue, 5}, }, Diff: &terraform.InstanceDiff{ @@ -1395,7 +1395,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { Type: TypeSet, Required: true, Elem: &Schema{Type: TypeInt}, - Set: func(a interface{}) int { + Set: func(a any) int { return a.(int) }, }, @@ -1410,8 +1410,8 @@ func TestShimSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{ - "ports": []interface{}{5, 2, 1}, + Config: map[string]any{ + "ports": []any{5, 2, 1}, }, Diff: &terraform.InstanceDiff{ @@ -1446,7 +1446,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { Optional: true, Computed: true, Elem: &Schema{Type: TypeInt}, - Set: func(a interface{}) int { + Set: func(a any) int { return a.(int) }, }, @@ -1461,7 +1461,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{}, + Config: map[string]any{}, Diff: nil, @@ -1483,9 +1483,9 @@ func TestShimSchemaMap_Diff(t *testing.T) { }, }, }, - Set: func(v interface{}) int { - m := v.(map[string]interface{}) - ps := m["ports"].([]interface{}) + Set: func(v any) int { + m := v.(map[string]any) + ps := m["ports"].([]any) result := 0 for _, p := range ps { result += p.(int) @@ -1506,13 +1506,13 @@ func TestShimSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{ - "ingress": []interface{}{ - map[string]interface{}{ - "ports": []interface{}{443}, + Config: map[string]any{ + "ingress": []any{ + map[string]any{ + "ports": []any{443}, }, - map[string]interface{}{ - "ports": []interface{}{80}, + map[string]any{ + "ports": []any{80}, }, }, }, @@ -1541,9 +1541,9 @@ func TestShimSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{ - "ingress": []interface{}{ - map[string]interface{}{ + Config: map[string]any{ + "ingress": []any{ + map[string]any{ "from": 8080, }, }, @@ -1588,7 +1588,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{ + Config: map[string]any{ "port": 80, }, @@ -1614,7 +1614,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{ + Config: map[string]any{ "port": 80, }, @@ -1654,7 +1654,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{ + Config: map[string]any{ "port": 80, }, @@ -1674,8 +1674,8 @@ func TestShimSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{ - "config_vars": map[string]interface{}{ + Config: map[string]any{ + "config_vars": map[string]any{ "bar": "baz", }, }, @@ -1713,8 +1713,8 @@ func TestShimSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{ - "config_vars": map[string]interface{}{ + Config: map[string]any{ + "config_vars": map[string]any{ "bar": "baz", }, }, @@ -1753,8 +1753,8 @@ func TestShimSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{ - "vars": map[string]interface{}{ + Config: map[string]any{ + "vars": map[string]any{ "bar": "baz", }, }, @@ -1818,9 +1818,9 @@ func TestShimSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{ - "config_vars": []interface{}{ - map[string]interface{}{ + Config: map[string]any{ + "config_vars": []any{ + map[string]any{ "bar": "baz", }, }, @@ -1862,7 +1862,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{}, + Config: map[string]any{}, Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ @@ -1912,7 +1912,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{ + Config: map[string]any{ "availability_zone": "foo", }, @@ -1943,7 +1943,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { Optional: true, Computed: true, Elem: &Schema{Type: TypeInt}, - Set: func(a interface{}) int { + Set: func(a any) int { return a.(int) }, }, @@ -1958,7 +1958,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{ + Config: map[string]any{ "availability_zone": "foo", }, @@ -1983,7 +1983,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { Elem: &Schema{Type: TypeString}, Optional: true, Computed: true, - Set: func(v interface{}) int { + Set: func(v any) int { return len(v.(string)) }, }, @@ -1996,8 +1996,8 @@ func TestShimSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{ - "instances": []interface{}{hcl2shim.UnknownVariableValue}, + Config: map[string]any{ + "instances": []any{hcl2shim.UnknownVariableValue}, }, Diff: &terraform.InstanceDiff{ @@ -2030,8 +2030,8 @@ func TestShimSchemaMap_Diff(t *testing.T) { }, }, }, - Set: func(v interface{}) int { - m := v.(map[string]interface{}) + Set: func(v any) int { + m := v.(map[string]any) return m["index"].(int) }, }, @@ -2039,9 +2039,9 @@ func TestShimSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{ - "route": []interface{}{ - map[string]interface{}{ + Config: map[string]any{ + "route": []any{ + map[string]any{ "index": "1", "gateway": hcl2shim.UnknownVariableValue, }, @@ -2086,14 +2086,14 @@ func TestShimSchemaMap_Diff(t *testing.T) { Type: TypeSet, Optional: true, Elem: &Schema{Type: TypeInt}, - Set: func(a interface{}) int { + Set: func(a any) int { return a.(int) }, }, }, }, - Set: func(v interface{}) int { - m := v.(map[string]interface{}) + Set: func(v any) int { + m := v.(map[string]any) return m["index"].(int) }, }, @@ -2101,11 +2101,11 @@ func TestShimSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{ - "route": []interface{}{ - map[string]interface{}{ + Config: map[string]any{ + "route": []any{ + map[string]any{ "index": "1", - "gateway": []interface{}{ + "gateway": []any{ hcl2shim.UnknownVariableValue, }, }, @@ -2172,8 +2172,8 @@ func TestShimSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{ - "vars": map[string]interface{}{ + Config: map[string]any{ + "vars": map[string]any{ "bar": hcl2shim.UnknownVariableValue, }, }, @@ -2196,7 +2196,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { State: &terraform.InstanceState{}, - Config: map[string]interface{}{}, + Config: map[string]any{}, Diff: nil, @@ -2218,7 +2218,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{ + Config: map[string]any{ "some_threshold": 12.34, }, @@ -2254,9 +2254,9 @@ func TestShimSchemaMap_Diff(t *testing.T) { }, }, }, - Set: func(v interface{}) int { + Set: func(v any) int { var buf bytes.Buffer - m := v.(map[string]interface{}) + m := v.(map[string]any) buf.WriteString(fmt.Sprintf("%s-", m["device_name"].(string))) buf.WriteString(fmt.Sprintf("%t-", m["delete_on_termination"].(bool))) return hashcode.String(buf.String()) @@ -2275,12 +2275,12 @@ func TestShimSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{ - "block_device": []interface{}{ - map[string]interface{}{ + Config: map[string]any{ + "block_device": []any{ + map[string]any{ "device_name": "/dev/sda1", }, - map[string]interface{}{ + map[string]any{ "device_name": "/dev/sdx", }, }, @@ -2306,7 +2306,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{}, + Config: map[string]any{}, Diff: nil, @@ -2330,14 +2330,14 @@ func TestShimSchemaMap_Diff(t *testing.T) { Type: TypeSet, Optional: true, Elem: &Schema{Type: TypeInt}, - Set: func(a interface{}) int { + Set: func(a any) int { return a.(int) }, }, }, }, - Set: func(v interface{}) int { - m := v.(map[string]interface{}) + Set: func(v any) int { + m := v.(map[string]any) return m["index"].(int) }, }, @@ -2350,7 +2350,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{}, + Config: map[string]any{}, Diff: nil, @@ -2374,7 +2374,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{}, + Config: map[string]any{}, Diff: nil, @@ -2389,7 +2389,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { Elem: &Schema{Type: TypeString}, Optional: true, ForceNew: true, - Set: func(v interface{}) int { + Set: func(v any) int { return len(v.(string)) }, }, @@ -2403,7 +2403,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{}, + Config: map[string]any{}, Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ @@ -2434,8 +2434,8 @@ func TestShimSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{ - "vars": map[string]interface{}{ + Config: map[string]any{ + "vars": map[string]any{ "foo": "", }, }, @@ -2468,7 +2468,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{}, + Config: map[string]any{}, Diff: nil, @@ -2483,13 +2483,13 @@ func TestShimSchemaMap_Diff(t *testing.T) { Optional: true, ForceNew: true, Elem: &Schema{Type: TypeInt}, - Set: func(interface{}) int { return 0 }, + Set: func(any) int { return 0 }, }, }, State: nil, - Config: map[string]interface{}{}, + Config: map[string]any{}, Diff: nil, @@ -2515,7 +2515,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{}, + Config: map[string]any{}, Diff: nil, @@ -2564,8 +2564,8 @@ func TestShimSchemaMap_Diff(t *testing.T) { }, }, }, - Set: func(v interface{}) int { - m := v.(map[string]interface{}) + Set: func(v any) int { + m := v.(map[string]any) return m["index"].(int) }, }, @@ -2573,9 +2573,9 @@ func TestShimSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{ - "route": []interface{}{ - map[string]interface{}{ + Config: map[string]any{ + "route": []any{ + map[string]any{ "index": "1", "gateway-name": "hello", }, @@ -2617,11 +2617,11 @@ func TestShimSchemaMap_Diff(t *testing.T) { ForceNew: true, Elem: &Schema{ Type: TypeString, - StateFunc: func(v interface{}) string { + StateFunc: func(v any) string { return v.(string) + "!" }, }, - Set: func(v interface{}) int { + Set: func(v any) int { i, err := strconv.Atoi(v.(string)) if err != nil { t.Fatalf("err: %s", err) @@ -2636,10 +2636,10 @@ func TestShimSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{ - "service_account": []interface{}{ - map[string]interface{}{ - "scopes": []interface{}{"123"}, + Config: map[string]any{ + "service_account": []any{ + map[string]any{ + "scopes": []any{"123"}, }, }, }, @@ -2676,7 +2676,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { Elem: &Schema{Type: TypeString}, Optional: true, ForceNew: true, - Set: func(v interface{}) int { + Set: func(v any) int { return len(v.(string)) }, }, @@ -2691,8 +2691,8 @@ func TestShimSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{ - "instances": []interface{}{"333", "4444"}, + Config: map[string]any{ + "instances": []any{"333", "4444"}, }, Diff: &terraform.InstanceDiff{ @@ -2744,7 +2744,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{ + Config: map[string]any{ "one": "1", "two": "0", }, @@ -2782,7 +2782,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { Tainted: true, }, - Config: map[string]interface{}{}, + Config: map[string]any{}, Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{}, @@ -2798,7 +2798,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { Required: true, ForceNew: true, Elem: &Schema{Type: TypeInt}, - Set: func(a interface{}) int { + Set: func(a any) int { return a.(int) }, }, @@ -2814,8 +2814,8 @@ func TestShimSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{ - "ports": []interface{}{5, 2, 1}, + Config: map[string]any{ + "ports": []any{5, 2, 1}, }, Diff: &terraform.InstanceDiff{ @@ -2860,7 +2860,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{}, + Config: map[string]any{}, Diff: &terraform.InstanceDiff{ Attributes: map[string]*terraform.ResourceAttrDiff{ @@ -2892,7 +2892,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { ID: "id", }, - Config: map[string]interface{}{ + Config: map[string]any{ "foo": hcl2shim.UnknownVariableValue, }, @@ -2918,7 +2918,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { Required: true, ForceNew: true, Elem: &Schema{Type: TypeInt}, - Set: func(a interface{}) int { + Set: func(a any) int { return a.(int) }, }, @@ -2934,8 +2934,8 @@ func TestShimSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{ - "ports": []interface{}{hcl2shim.UnknownVariableValue, 2, 1}, + Config: map[string]any{ + "ports": []any{hcl2shim.UnknownVariableValue, 2, 1}, }, Diff: &terraform.InstanceDiff{ @@ -2970,8 +2970,8 @@ func TestShimSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{ - "config": []interface{}{hcl2shim.UnknownVariableValue, hcl2shim.UnknownVariableValue}, + Config: map[string]any{ + "config": []any{hcl2shim.UnknownVariableValue, hcl2shim.UnknownVariableValue}, }, Diff: &terraform.InstanceDiff{ @@ -3000,11 +3000,11 @@ func TestShimSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{ + Config: map[string]any{ "availability_zone": "foo", }, - CustomizeDiff: func(d *ResourceDiff, meta interface{}) error { + CustomizeDiff: func(d *ResourceDiff, meta any) error { if err := d.SetNew("availability_zone", "bar"); err != nil { return err } @@ -3043,9 +3043,9 @@ func TestShimSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{}, + Config: map[string]any{}, - CustomizeDiff: func(d *ResourceDiff, meta interface{}) error { + CustomizeDiff: func(d *ResourceDiff, meta any) error { if err := d.SetNew("availability_zone", "bar"); err != nil { return err } @@ -3082,11 +3082,11 @@ func TestShimSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{ + Config: map[string]any{ "availability_zone": "foo", }, - CustomizeDiff: func(d *ResourceDiff, meta interface{}) error { + CustomizeDiff: func(d *ResourceDiff, meta any) error { if err := d.SetNew("availability_zone", "bar"); err != nil { return err } @@ -3121,11 +3121,11 @@ func TestShimSchemaMap_Diff(t *testing.T) { State: nil, - Config: map[string]interface{}{ + Config: map[string]any{ "ami_id": "foo", }, - CustomizeDiff: func(d *ResourceDiff, meta interface{}) error { + CustomizeDiff: func(d *ResourceDiff, meta any) error { if err := d.SetNew("instance_id", "bar"); err != nil { return err } @@ -3156,7 +3156,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { Optional: true, Computed: true, Elem: &Schema{Type: TypeInt}, - Set: func(a interface{}) int { + Set: func(a any) int { return a.(int) }, }, @@ -3172,12 +3172,12 @@ func TestShimSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{ - "ports": []interface{}{5, 2, 6}, + Config: map[string]any{ + "ports": []any{5, 2, 6}, }, - CustomizeDiff: func(d *ResourceDiff, meta interface{}) error { - if err := d.SetNew("ports", []interface{}{5, 2, 1}); err != nil { + CustomizeDiff: func(d *ResourceDiff, meta any) error { + if err := d.SetNew("ports", []any{5, 2, 1}); err != nil { return err } if err := d.ForceNew("ports"); err != nil { @@ -3223,9 +3223,9 @@ func TestShimSchemaMap_Diff(t *testing.T) { Tainted: true, }, - Config: map[string]interface{}{}, + Config: map[string]any{}, - CustomizeDiff: func(d *ResourceDiff, meta interface{}) error { + CustomizeDiff: func(d *ResourceDiff, meta any) error { return errors.New("diff customization should not have run") }, @@ -3259,11 +3259,11 @@ func TestShimSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{ + Config: map[string]any{ "etag": "bar", }, - CustomizeDiff: func(d *ResourceDiff, meta interface{}) error { + CustomizeDiff: func(d *ResourceDiff, meta any) error { if d.HasChange("etag") { d.SetNewComputed("version_id") } @@ -3304,11 +3304,11 @@ func TestShimSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{ + Config: map[string]any{ "foo": "baz", }, - CustomizeDiff: func(d *ResourceDiff, meta interface{}) error { + CustomizeDiff: func(d *ResourceDiff, meta any) error { return fmt.Errorf("diff vetoed") }, @@ -3334,7 +3334,7 @@ func TestShimSchemaMap_Diff(t *testing.T) { }, }, - Config: map[string]interface{}{ + Config: map[string]any{ "attr": "", }, }, @@ -3366,11 +3366,11 @@ func TestShimSchemaMap_Diff(t *testing.T) { "stream_view_type": "KEYS_ONLY", }, }, - Config: map[string]interface{}{ + Config: map[string]any{ "stream_enabled": false, "stream_view_type": "", }, - CustomizeDiff: func(diff *ResourceDiff, v interface{}) error { + CustomizeDiff: func(diff *ResourceDiff, v any) error { v, ok := diff.GetOk("unrelated_set") if ok { return fmt.Errorf("Didn't expect unrelated_set: %#v", v) @@ -3477,21 +3477,21 @@ func resourceSchemaToBlock(s map[string]*Schema) *configschema.Block { } func TestRemoveConfigUnknowns(t *testing.T) { - cfg := map[string]interface{}{ + cfg := map[string]any{ "id": "74D93920-ED26-11E3-AC10-0800200C9A66", - "route_rules": []interface{}{ - map[string]interface{}{ + "route_rules": []any{ + map[string]any{ "cidr_block": "74D93920-ED26-11E3-AC10-0800200C9A66", "destination": "0.0.0.0/0", "destination_type": "CIDR_BLOCK", "network_entity_id": "1", }, - map[string]interface{}{ + map[string]any{ "cidr_block": "74D93920-ED26-11E3-AC10-0800200C9A66", "destination": "0.0.0.0/0", "destination_type": "CIDR_BLOCK", - "sub_block": []interface{}{ - map[string]interface{}{ + "sub_block": []any{ + map[string]any{ "computed": "74D93920-ED26-11E3-AC10-0800200C9A66", }, }, @@ -3499,18 +3499,18 @@ func TestRemoveConfigUnknowns(t *testing.T) { }, } - expect := map[string]interface{}{ - "route_rules": []interface{}{ - map[string]interface{}{ + expect := map[string]any{ + "route_rules": []any{ + map[string]any{ "destination": "0.0.0.0/0", "destination_type": "CIDR_BLOCK", "network_entity_id": "1", }, - map[string]interface{}{ + map[string]any{ "destination": "0.0.0.0/0", "destination_type": "CIDR_BLOCK", - "sub_block": []interface{}{ - map[string]interface{}{}, + "sub_block": []any{ + map[string]any{}, }, }, }, diff --git a/staging/terraform/legacy/helper/schema/testing.go b/staging/terraform/legacy/helper/schema/testing.go index 8889d1f..74c7ebc 100644 --- a/staging/terraform/legacy/helper/schema/testing.go +++ b/staging/terraform/legacy/helper/schema/testing.go @@ -11,7 +11,7 @@ import ( // TestResourceDataRaw creates a ResourceData from a raw configuration map. func TestResourceDataRaw( - t *testing.T, schema map[string]*Schema, raw map[string]interface{}) *ResourceData { + t *testing.T, schema map[string]*Schema, raw map[string]any) *ResourceData { t.Helper() c := terraform.NewResourceConfigRaw(raw) diff --git a/staging/terraform/legacy/terraform/diff.go b/staging/terraform/legacy/terraform/diff.go index 440c422..9ae8ad5 100644 --- a/staging/terraform/legacy/terraform/diff.go +++ b/staging/terraform/legacy/terraform/diff.go @@ -406,7 +406,7 @@ type InstanceDiff struct { // plans but otherwise is completely ignored by Terraform core. It is // meant to be used for additional data a resource may want to pass through. // The value here must only contain Go primitives and collections. - Meta map[string]interface{} + Meta map[string]any } func (d *InstanceDiff) Lock() { d.mu.Lock() } @@ -961,13 +961,13 @@ func countFlatmapContainerValues(key string, attrs map[string]string) string { // ResourceAttrDiff is the diff of a single attribute of a resource. type ResourceAttrDiff struct { - Old string // Old Value - New string // New Value - NewComputed bool // True if new value is computed (unknown currently) - NewRemoved bool // True if this attribute is being removed - NewExtra interface{} // Extra information for the provider - RequiresNew bool // True if change requires new resource - Sensitive bool // True if the data should not be displayed in UI output + Old string // Old Value + New string // New Value + NewComputed bool // True if new value is computed (unknown currently) + NewRemoved bool // True if this attribute is being removed + NewExtra any // Extra information for the provider + RequiresNew bool // True if change requires new resource + Sensitive bool // True if the data should not be displayed in UI output Type DiffAttrType } diff --git a/staging/terraform/legacy/terraform/provider_mock.go b/staging/terraform/legacy/terraform/provider_mock.go index 99b82b3..b604e61 100644 --- a/staging/terraform/legacy/terraform/provider_mock.go +++ b/staging/terraform/legacy/terraform/provider_mock.go @@ -22,7 +22,7 @@ type MockProvider struct { sync.Mutex // Anything you want, in case you need to store extra data with the mock. - Meta interface{} + Meta any GetSchemaCalled bool GetSchemaReturn *ProviderSchema // This is using ProviderSchema directly rather than providers.GetProviderSchemaResponse for compatibility with old tests diff --git a/staging/terraform/legacy/terraform/provisioner_mock.go b/staging/terraform/legacy/terraform/provisioner_mock.go index eebaebc..31461c4 100644 --- a/staging/terraform/legacy/terraform/provisioner_mock.go +++ b/staging/terraform/legacy/terraform/provisioner_mock.go @@ -16,7 +16,7 @@ var _ provisioners.Interface = (*MockProvisioner)(nil) type MockProvisioner struct { sync.Mutex // Anything you want, in case you need to store extra data with the mock. - Meta interface{} + Meta any GetSchemaCalled bool GetSchemaResponse provisioners.GetSchemaResponse diff --git a/staging/terraform/legacy/terraform/resource.go b/staging/terraform/legacy/terraform/resource.go index 7734c95..2c4450a 100644 --- a/staging/terraform/legacy/terraform/resource.go +++ b/staging/terraform/legacy/terraform/resource.go @@ -185,8 +185,8 @@ func (i *InstanceInfo) ResourceAddress() *ResourceAddress { // APIs that still use this type, via NewResourceConfigShimmed. type ResourceConfig struct { ComputedKeys []string - Raw map[string]interface{} - Config map[string]interface{} + Raw map[string]any + Config map[string]any } // NewResourceConfigRaw constructs a ResourceConfig whose content is exactly @@ -195,7 +195,7 @@ type ResourceConfig struct { // The given value may contain hcl2shim.UnknownVariableValue to signal that // something is computed, but it must not contain unprocessed interpolation // sequences as we might've seen in Terraform v0.11 and prior. -func NewResourceConfigRaw(raw map[string]interface{}) *ResourceConfig { +func NewResourceConfigRaw(raw map[string]any) *ResourceConfig { v := hcl2shim.HCL2ValueFromConfigValue(raw) // This is a little weird but we round-trip the value through the hcl2shim @@ -205,7 +205,7 @@ func NewResourceConfigRaw(raw map[string]interface{}) *ResourceConfig { // something is relying on the fact that in the old world the raw and // config maps were always distinct, and thus you could in principle mutate // one without affecting the other. (I sure hope nobody was doing that, though!) - cfg := hcl2shim.ConfigValueFromHCL2(v).(map[string]interface{}) + cfg := hcl2shim.ConfigValueFromHCL2(v).(map[string]any) return &ResourceConfig{ Raw: raw, @@ -242,7 +242,7 @@ func NewResourceConfigShimmed(val cty.Value, schema *configschema.Block) *Resour // a child block can be partially unknown. ret.ComputedKeys = newResourceConfigShimmedComputedKeys(val, "") } else { - ret.Config = make(map[string]interface{}) + ret.Config = make(map[string]any) } ret.Raw = ret.Config @@ -330,7 +330,7 @@ func (c *ResourceConfig) Equal(c2 *ResourceConfig) bool { // We don't compare "raw" because it is never used again after // initialization and for all intents and purposes they are equal // if the exported properties are equal. - check := [][2]interface{}{ + check := [][2]any{ {c.ComputedKeys, c2.ComputedKeys}, {c.Raw, c2.Raw}, {c.Config, c2.Config}, @@ -365,7 +365,7 @@ func (c *ResourceConfig) CheckSet(keys []string) []error { // The second return value is true if the get was successful. Get will // return the raw value if the key is computed, so you should pair this // with IsComputed. -func (c *ResourceConfig) Get(k string) (interface{}, bool) { +func (c *ResourceConfig) Get(k string) (any, bool) { // We aim to get a value from the configuration. If it is computed, // then we return the pure raw value. source := c.Config @@ -381,7 +381,7 @@ func (c *ResourceConfig) Get(k string) (interface{}, bool) { // // The second return value is true if the get was successful. Get will // not succeed if the value is being computed. -func (c *ResourceConfig) GetRaw(k string) (interface{}, bool) { +func (c *ResourceConfig) GetRaw(k string) (any, bool) { return c.get(k, c.Raw) } @@ -431,14 +431,14 @@ func (c *ResourceConfig) IsSet(k string) bool { } func (c *ResourceConfig) get( - k string, raw map[string]interface{}) (interface{}, bool) { + k string, raw map[string]any) (any, bool) { parts := strings.Split(k, ".") if len(parts) == 1 && parts[0] == "" { parts = nil } - var current interface{} = raw - var previous interface{} = nil + var current any = raw + var previous any = nil for i, part := range parts { if current == nil { return nil, false @@ -491,7 +491,7 @@ func (c *ResourceConfig) get( // This happens when map keys contain "." and have a common // prefix so were split as path components above. actualKey := strings.Join(parts[i-1:], ".") - if prevMap, ok := previous.(map[string]interface{}); ok { + if prevMap, ok := previous.(map[string]any); ok { v, ok := prevMap[actualKey] return v, ok } diff --git a/staging/terraform/legacy/terraform/resource_address.go b/staging/terraform/legacy/terraform/resource_address.go index a9ff2ae..df2408d 100644 --- a/staging/terraform/legacy/terraform/resource_address.go +++ b/staging/terraform/legacy/terraform/resource_address.go @@ -468,7 +468,7 @@ func (addr *ResourceAddress) Contains(other *ResourceAddress) bool { // // See also Contains, which takes a more hierarchical approach to comparing // addresses. -func (addr *ResourceAddress) Equals(raw interface{}) bool { +func (addr *ResourceAddress) Equals(raw any) bool { other, ok := raw.(*ResourceAddress) if !ok { return false diff --git a/staging/terraform/legacy/terraform/resource_address_test.go b/staging/terraform/legacy/terraform/resource_address_test.go index 2fb7e4c..6d7458c 100644 --- a/staging/terraform/legacy/terraform/resource_address_test.go +++ b/staging/terraform/legacy/terraform/resource_address_test.go @@ -610,7 +610,7 @@ func TestResourceAddressContains(t *testing.T) { func TestResourceAddressEquals(t *testing.T) { cases := map[string]struct { Address *ResourceAddress - Other interface{} + Other any Expect bool }{ "basic match": { diff --git a/staging/terraform/legacy/terraform/resource_provider_mock.go b/staging/terraform/legacy/terraform/resource_provider_mock.go index c026be4..3e2abfa 100644 --- a/staging/terraform/legacy/terraform/resource_provider_mock.go +++ b/staging/terraform/legacy/terraform/resource_provider_mock.go @@ -13,7 +13,7 @@ type MockResourceProvider struct { sync.Mutex // Anything you want, in case you need to store extra data with the mock. - Meta interface{} + Meta any CloseCalled bool CloseError error diff --git a/staging/terraform/legacy/terraform/resource_provisioner_mock.go b/staging/terraform/legacy/terraform/resource_provisioner_mock.go index f0d0a38..2737740 100644 --- a/staging/terraform/legacy/terraform/resource_provisioner_mock.go +++ b/staging/terraform/legacy/terraform/resource_provisioner_mock.go @@ -14,7 +14,7 @@ import ( type MockResourceProvisioner struct { sync.Mutex // Anything you want, in case you need to store extra data with the mock. - Meta interface{} + Meta any GetConfigSchemaCalled bool GetConfigSchemaReturnSchema *configschema.Block diff --git a/staging/terraform/legacy/terraform/resource_test.go b/staging/terraform/legacy/terraform/resource_test.go index 65a4fe7..e376d80 100644 --- a/staging/terraform/legacy/terraform/resource_test.go +++ b/staging/terraform/legacy/terraform/resource_test.go @@ -31,7 +31,7 @@ func TestResourceConfigGet(t *testing.T) { Config cty.Value Schema *configschema.Block Key string - Value interface{} + Value any }{ { Config: cty.ObjectVal(map[string]cty.Value{ @@ -268,7 +268,7 @@ func TestResourceConfigEqual_computedKeyOrder(t *testing.T) { func TestUnknownCheckWalker(t *testing.T) { cases := []struct { Name string - Input interface{} + Input any Result bool }{ { @@ -285,15 +285,15 @@ func TestUnknownCheckWalker(t *testing.T) { { "list", - []interface{}{"foo", hcl2shim.UnknownVariableValue}, + []any{"foo", hcl2shim.UnknownVariableValue}, true, }, { "nested list", - []interface{}{ + []any{ "foo", - []interface{}{hcl2shim.UnknownVariableValue}, + []any{hcl2shim.UnknownVariableValue}, }, true, }, @@ -332,8 +332,8 @@ func TestNewResourceConfigShimmed(t *testing.T) { }, }, Expected: &ResourceConfig{ - Raw: map[string]interface{}{}, - Config: map[string]interface{}{}, + Raw: map[string]any{}, + Config: map[string]any{}, }, }, { @@ -350,10 +350,10 @@ func TestNewResourceConfigShimmed(t *testing.T) { }, }, Expected: &ResourceConfig{ - Raw: map[string]interface{}{ + Raw: map[string]any{ "foo": "bar", }, - Config: map[string]interface{}{ + Config: map[string]any{ "foo": "bar", }, }, @@ -372,8 +372,8 @@ func TestNewResourceConfigShimmed(t *testing.T) { }, }, Expected: &ResourceConfig{ - Raw: map[string]interface{}{}, - Config: map[string]interface{}{}, + Raw: map[string]any{}, + Config: map[string]any{}, }, }, { @@ -391,10 +391,10 @@ func TestNewResourceConfigShimmed(t *testing.T) { }, Expected: &ResourceConfig{ ComputedKeys: []string{"foo"}, - Raw: map[string]interface{}{ + Raw: map[string]any{ "foo": hcl2shim.UnknownVariableValue, }, - Config: map[string]interface{}{ + Config: map[string]any{ "foo": hcl2shim.UnknownVariableValue, }, }, @@ -419,11 +419,11 @@ func TestNewResourceConfigShimmed(t *testing.T) { }, Expected: &ResourceConfig{ ComputedKeys: []string{"bar", "baz"}, - Raw: map[string]interface{}{ + Raw: map[string]any{ "bar": hcl2shim.UnknownVariableValue, "baz": hcl2shim.UnknownVariableValue, }, - Config: map[string]interface{}{ + Config: map[string]any{ "bar": hcl2shim.UnknownVariableValue, "baz": hcl2shim.UnknownVariableValue, }, @@ -448,8 +448,8 @@ func TestNewResourceConfigShimmed(t *testing.T) { }, }, Expected: &ResourceConfig{ - Raw: map[string]interface{}{}, - Config: map[string]interface{}{}, + Raw: map[string]any{}, + Config: map[string]any{}, }, }, { @@ -472,11 +472,11 @@ func TestNewResourceConfigShimmed(t *testing.T) { }, Expected: &ResourceConfig{ ComputedKeys: []string{"bar", "baz"}, - Raw: map[string]interface{}{ + Raw: map[string]any{ "bar": hcl2shim.UnknownVariableValue, "baz": hcl2shim.UnknownVariableValue, }, - Config: map[string]interface{}{ + Config: map[string]any{ "bar": hcl2shim.UnknownVariableValue, "baz": hcl2shim.UnknownVariableValue, }, @@ -518,16 +518,16 @@ func TestNewResourceConfigShimmed(t *testing.T) { }, Expected: &ResourceConfig{ ComputedKeys: []string{"bar.0.baz.0.list"}, - Raw: map[string]interface{}{ - "bar": []interface{}{map[string]interface{}{ - "baz": []interface{}{map[string]interface{}{ + Raw: map[string]any{ + "bar": []any{map[string]any{ + "baz": []any{map[string]any{ "list": "74D93920-ED26-11E3-AC10-0800200C9A66", }}, }}, }, - Config: map[string]interface{}{ - "bar": []interface{}{map[string]interface{}{ - "baz": []interface{}{map[string]interface{}{ + Config: map[string]any{ + "bar": []any{map[string]any{ + "baz": []any{map[string]any{ "list": "74D93920-ED26-11E3-AC10-0800200C9A66", }}, }}, @@ -560,13 +560,13 @@ func TestNewResourceConfigShimmed(t *testing.T) { }, Expected: &ResourceConfig{ ComputedKeys: []string{"bar.0.val"}, - Raw: map[string]interface{}{ - "bar": []interface{}{map[string]interface{}{ + Raw: map[string]any{ + "bar": []any{map[string]any{ "val": "74D93920-ED26-11E3-AC10-0800200C9A66", }}, }, - Config: map[string]interface{}{ - "bar": []interface{}{map[string]interface{}{ + Config: map[string]any{ + "bar": []any{map[string]any{ "val": "74D93920-ED26-11E3-AC10-0800200C9A66", }}, }, @@ -611,32 +611,32 @@ func TestNewResourceConfigShimmed(t *testing.T) { }, Expected: &ResourceConfig{ ComputedKeys: []string{"bar.0.val", "baz.0.obj.attr", "baz.1.obj"}, - Raw: map[string]interface{}{ - "bar": []interface{}{map[string]interface{}{ + Raw: map[string]any{ + "bar": []any{map[string]any{ "val": "74D93920-ED26-11E3-AC10-0800200C9A66", }}, - "baz": []interface{}{ - map[string]interface{}{ - "obj": map[string]interface{}{ + "baz": []any{ + map[string]any{ + "obj": map[string]any{ "attr": "74D93920-ED26-11E3-AC10-0800200C9A66", }, }, - map[string]interface{}{ + map[string]any{ "obj": "74D93920-ED26-11E3-AC10-0800200C9A66", }, }, }, - Config: map[string]interface{}{ - "bar": []interface{}{map[string]interface{}{ + Config: map[string]any{ + "bar": []any{map[string]any{ "val": "74D93920-ED26-11E3-AC10-0800200C9A66", }}, - "baz": []interface{}{ - map[string]interface{}{ - "obj": map[string]interface{}{ + "baz": []any{ + map[string]any{ + "obj": map[string]any{ "attr": "74D93920-ED26-11E3-AC10-0800200C9A66", }, }, - map[string]interface{}{ + map[string]any{ "obj": "74D93920-ED26-11E3-AC10-0800200C9A66", }, }, @@ -662,8 +662,8 @@ func TestNewResourceConfigShimmed(t *testing.T) { }, }, Expected: &ResourceConfig{ - Raw: map[string]interface{}{}, - Config: map[string]interface{}{}, + Raw: map[string]any{}, + Config: map[string]any{}, }, }, } { diff --git a/staging/terraform/legacy/terraform/state.go b/staging/terraform/legacy/terraform/state.go index f3f94fb..df10355 100644 --- a/staging/terraform/legacy/terraform/state.go +++ b/staging/terraform/legacy/terraform/state.go @@ -355,7 +355,7 @@ func (s *State) Remove(addr ...string) error { } // Go through each result and grab what we need - removed := make(map[interface{}]struct{}) + removed := make(map[any]struct{}) for _, r := range results { // Convert the path to our own type path := append([]string{"root"}, r.Path...) @@ -907,7 +907,7 @@ type OutputState struct { Type string `json:"type"` // Value contains the value of the output, in the structure described // by the Type field. - Value interface{} `json:"value"` + Value any `json:"value"` mu sync.Mutex } @@ -970,7 +970,7 @@ type ModuleState struct { // Locals are kept only transiently in-memory, because we can always // re-compute them. - Locals map[string]interface{} `json:"-"` + Locals map[string]any `json:"-"` // Outputs declared by the module and maintained for each module // even though only the root module technically needs to be kept. @@ -1310,9 +1310,9 @@ func (m *ModuleState) String() string { switch vTyped := v.Value.(type) { case string: buf.WriteString(fmt.Sprintf("%s = %s\n", k, vTyped)) - case []interface{}: + case []any: buf.WriteString(fmt.Sprintf("%s = %s\n", k, vTyped)) - case map[string]interface{}: + case map[string]any: var mapKeys []string for key, _ := range vTyped { mapKeys = append(mapKeys, key) @@ -1634,7 +1634,7 @@ type InstanceState struct { // ignored by Terraform core. It's meant to be used for accounting by // external client code. The value here must only contain Go primitives // and collections. - Meta map[string]interface{} `json:"meta"` + Meta map[string]any `json:"meta"` ProviderMeta cty.Value @@ -1655,7 +1655,7 @@ func (s *InstanceState) init() { s.Attributes = make(map[string]string) } if s.Meta == nil { - s.Meta = make(map[string]interface{}) + s.Meta = make(map[string]any) } s.Ephemeral.init() } @@ -1670,7 +1670,7 @@ func NewInstanceStateShimmedFromValue(state cty.Value, schemaVersion int) *Insta return &InstanceState{ ID: attrs["id"], Attributes: attrs, - Meta: map[string]interface{}{ + Meta: map[string]any{ "schema_version": schemaVersion, }, } diff --git a/staging/terraform/legacy/terraform/state_filter.go b/staging/terraform/legacy/terraform/state_filter.go index b605bf0..6827e6f 100644 --- a/staging/terraform/legacy/terraform/state_filter.go +++ b/staging/terraform/legacy/terraform/state_filter.go @@ -168,7 +168,7 @@ func (f *StateFilter) filterSingle(a *ResourceAddress) []*StateFilterResult { } // relevant checks for relevance of this address against the given value. -func (f *StateFilter) relevant(addr *ResourceAddress, raw interface{}) bool { +func (f *StateFilter) relevant(addr *ResourceAddress, raw any) bool { switch v := raw.(type) { case *ModuleState: path := v.Path[1:] @@ -223,7 +223,7 @@ type StateFilterResult struct { // Value is the actual value. This must be type switched on. It can be // any data structures that `State` can hold: `ModuleState`, // `ResourceState`, `InstanceState`. - Value interface{} + Value any } func (r *StateFilterResult) String() string { diff --git a/staging/terraform/legacy/terraform/state_test.go b/staging/terraform/legacy/terraform/state_test.go index 117fe19..6cfdfae 100644 --- a/staging/terraform/legacy/terraform/state_test.go +++ b/staging/terraform/legacy/terraform/state_test.go @@ -177,7 +177,7 @@ func TestStateDeepCopy(t *testing.T) { Resources: map[string]*ResourceState{ "test_instance.foo": &ResourceState{ Primary: &InstanceState{ - Meta: map[string]interface{}{}, + Meta: map[string]any{}, }, }, }, @@ -197,7 +197,7 @@ func TestStateDeepCopy(t *testing.T) { Resources: map[string]*ResourceState{ "test_instance.foo": &ResourceState{ Primary: &InstanceState{ - Meta: map[string]interface{}{}, + Meta: map[string]any{}, }, Deposed: []*InstanceState{ {ID: "test"}, @@ -295,7 +295,7 @@ func TestStateEqual(t *testing.T) { Resources: map[string]*ResourceState{ "test_instance.foo": &ResourceState{ Primary: &InstanceState{ - Meta: map[string]interface{}{ + Meta: map[string]any{ "schema_version": "1", }, }, @@ -311,7 +311,7 @@ func TestStateEqual(t *testing.T) { Resources: map[string]*ResourceState{ "test_instance.foo": &ResourceState{ Primary: &InstanceState{ - Meta: map[string]interface{}{ + Meta: map[string]any{ "schema_version": "2", }, }, @@ -333,8 +333,8 @@ func TestStateEqual(t *testing.T) { Resources: map[string]*ResourceState{ "test_instance.foo": &ResourceState{ Primary: &InstanceState{ - Meta: map[string]interface{}{ - "timeouts": map[string]interface{}{ + Meta: map[string]any{ + "timeouts": map[string]any{ "create": 42, "read": "27", }, @@ -352,8 +352,8 @@ func TestStateEqual(t *testing.T) { Resources: map[string]*ResourceState{ "test_instance.foo": &ResourceState{ Primary: &InstanceState{ - Meta: map[string]interface{}{ - "timeouts": map[string]interface{}{ + Meta: map[string]any{ + "timeouts": map[string]any{ "create": 42, "read": "27", }, @@ -377,8 +377,8 @@ func TestStateEqual(t *testing.T) { Resources: map[string]*ResourceState{ "test_instance.foo": &ResourceState{ Primary: &InstanceState{ - Meta: map[string]interface{}{ - "timeouts": map[string]interface{}{ + Meta: map[string]any{ + "timeouts": map[string]any{ "create": int(42), "read": "27", }, @@ -396,8 +396,8 @@ func TestStateEqual(t *testing.T) { Resources: map[string]*ResourceState{ "test_instance.foo": &ResourceState{ Primary: &InstanceState{ - Meta: map[string]interface{}{ - "timeouts": map[string]interface{}{ + Meta: map[string]any{ + "timeouts": map[string]any{ "create": float64(42), "read": "27", }, diff --git a/staging/terraform/legacy/terraform/state_upgrade_v1_to_v2.go b/staging/terraform/legacy/terraform/state_upgrade_v1_to_v2.go index 757a3d0..19652c5 100644 --- a/staging/terraform/legacy/terraform/state_upgrade_v1_to_v2.go +++ b/staging/terraform/legacy/terraform/state_upgrade_v1_to_v2.go @@ -168,7 +168,7 @@ func (old *instanceStateV1) upgradeToV2() (*InstanceState, error) { return nil, fmt.Errorf("Error upgrading InstanceState V1: %v", err) } - newMeta := make(map[string]interface{}) + newMeta := make(map[string]any) for k, v := range meta.(map[string]string) { newMeta[k] = v } diff --git a/staging/terraform/logging/panic.go b/staging/terraform/logging/panic.go index 79c81f2..ba13633 100644 --- a/staging/terraform/logging/panic.go +++ b/staging/terraform/logging/panic.go @@ -157,7 +157,7 @@ func (l *logPanicWrapper) Named(name string) hclog.Logger { // we only need to implement Debug, since that is the default output level used // by go-plugin when encountering unstructured output on stderr. -func (l *logPanicWrapper) Debug(msg string, args ...interface{}) { +func (l *logPanicWrapper) Debug(msg string, args ...any) { // We don't have access to the binary itself, so guess based on the stderr // output if this is the start of the traceback. An occasional false // positive shouldn't be a big deal, since this is only retrieved after an diff --git a/staging/terraform/plans/internal/planproto/planfile.pb.go b/staging/terraform/plans/internal/planproto/planfile.pb.go index 0c3e65b..11505d6 100644 --- a/staging/terraform/plans/internal/planproto/planfile.pb.go +++ b/staging/terraform/plans/internal/planproto/planfile.pb.go @@ -1555,7 +1555,7 @@ func file_planfile_proto_rawDescGZIP() []byte { var file_planfile_proto_enumTypes = make([]protoimpl.EnumInfo, 5) var file_planfile_proto_msgTypes = make([]protoimpl.MessageInfo, 13) -var file_planfile_proto_goTypes = []interface{}{ +var file_planfile_proto_goTypes = []any{ (Mode)(0), // 0: tfplan.Mode (Action)(0), // 1: tfplan.Action (ResourceInstanceActionReason)(0), // 2: tfplan.ResourceInstanceActionReason @@ -1615,7 +1615,7 @@ func file_planfile_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_planfile_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_planfile_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*Plan); i { case 0: return &v.state @@ -1627,7 +1627,7 @@ func file_planfile_proto_init() { return nil } } - file_planfile_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_planfile_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*Backend); i { case 0: return &v.state @@ -1639,7 +1639,7 @@ func file_planfile_proto_init() { return nil } } - file_planfile_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_planfile_proto_msgTypes[2].Exporter = func(v any, i int) any { switch v := v.(*Change); i { case 0: return &v.state @@ -1651,7 +1651,7 @@ func file_planfile_proto_init() { return nil } } - file_planfile_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_planfile_proto_msgTypes[3].Exporter = func(v any, i int) any { switch v := v.(*ResourceInstanceChange); i { case 0: return &v.state @@ -1663,7 +1663,7 @@ func file_planfile_proto_init() { return nil } } - file_planfile_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + file_planfile_proto_msgTypes[4].Exporter = func(v any, i int) any { switch v := v.(*OutputChange); i { case 0: return &v.state @@ -1675,7 +1675,7 @@ func file_planfile_proto_init() { return nil } } - file_planfile_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + file_planfile_proto_msgTypes[5].Exporter = func(v any, i int) any { switch v := v.(*CheckResults); i { case 0: return &v.state @@ -1687,7 +1687,7 @@ func file_planfile_proto_init() { return nil } } - file_planfile_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + file_planfile_proto_msgTypes[6].Exporter = func(v any, i int) any { switch v := v.(*DynamicValue); i { case 0: return &v.state @@ -1699,7 +1699,7 @@ func file_planfile_proto_init() { return nil } } - file_planfile_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + file_planfile_proto_msgTypes[7].Exporter = func(v any, i int) any { switch v := v.(*Path); i { case 0: return &v.state @@ -1711,7 +1711,7 @@ func file_planfile_proto_init() { return nil } } - file_planfile_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + file_planfile_proto_msgTypes[8].Exporter = func(v any, i int) any { switch v := v.(*Importing); i { case 0: return &v.state @@ -1723,7 +1723,7 @@ func file_planfile_proto_init() { return nil } } - file_planfile_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + file_planfile_proto_msgTypes[10].Exporter = func(v any, i int) any { switch v := v.(*PlanResourceAttr); i { case 0: return &v.state @@ -1735,7 +1735,7 @@ func file_planfile_proto_init() { return nil } } - file_planfile_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + file_planfile_proto_msgTypes[11].Exporter = func(v any, i int) any { switch v := v.(*CheckResults_ObjectResult); i { case 0: return &v.state @@ -1747,7 +1747,7 @@ func file_planfile_proto_init() { return nil } } - file_planfile_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + file_planfile_proto_msgTypes[12].Exporter = func(v any, i int) any { switch v := v.(*Path_Step); i { case 0: return &v.state @@ -1760,7 +1760,7 @@ func file_planfile_proto_init() { } } } - file_planfile_proto_msgTypes[12].OneofWrappers = []interface{}{ + file_planfile_proto_msgTypes[12].OneofWrappers = []any{ (*Path_Step_AttributeName)(nil), (*Path_Step_ElementKey)(nil), } diff --git a/staging/terraform/plugin/convert/diagnostics.go b/staging/terraform/plugin/convert/diagnostics.go index c6bd8e0..d546463 100644 --- a/staging/terraform/plugin/convert/diagnostics.go +++ b/staging/terraform/plugin/convert/diagnostics.go @@ -25,7 +25,7 @@ func WarnsAndErrsToProto(warns []string, errs []error) (diags []*proto.Diagnosti // AppendProtoDiag appends a new diagnostic from a warning string or an error. // This panics if d is not a string or error. -func AppendProtoDiag(diags []*proto.Diagnostic, d interface{}) []*proto.Diagnostic { +func AppendProtoDiag(diags []*proto.Diagnostic, d any) []*proto.Diagnostic { switch d := d.(type) { case cty.PathError: ap := PathToAttributePath(d.Path) diff --git a/staging/terraform/plugin/convert/diagnostics_test.go b/staging/terraform/plugin/convert/diagnostics_test.go index 1fb0a46..7d267bb 100644 --- a/staging/terraform/plugin/convert/diagnostics_test.go +++ b/staging/terraform/plugin/convert/diagnostics_test.go @@ -62,7 +62,7 @@ func TestProtoDiagnostics(t *testing.T) { func TestDiagnostics(t *testing.T) { type diagFlat struct { Severity tfdiags.Severity - Attr []interface{} + Attr []any Summary string Detail string } @@ -204,7 +204,7 @@ func TestDiagnostics(t *testing.T) { Severity: tfdiags.Error, Summary: "error", Detail: "error detail", - Attr: []interface{}{"attribute_name"}, + Attr: []any{"attribute_name"}, }, }, }, @@ -301,25 +301,25 @@ func TestDiagnostics(t *testing.T) { Severity: tfdiags.Error, Summary: "error 1", Detail: "error 1 detail", - Attr: []interface{}{"attr"}, + Attr: []any{"attr"}, }, { Severity: tfdiags.Error, Summary: "error 2", Detail: "error 2 detail", - Attr: []interface{}{"attr", "sub"}, + Attr: []any{"attr", "sub"}, }, { Severity: tfdiags.Warning, Summary: "warning", Detail: "warning detail", - Attr: []interface{}{"attr", 1, "sub"}, + Attr: []any{"attr", 1, "sub"}, }, { Severity: tfdiags.Error, Summary: "error 3", Detail: "error 3 detail", - Attr: []interface{}{"attr", "idx", "sub"}, + Attr: []any{"attr", "idx", "sub"}, }, }, }, @@ -330,7 +330,7 @@ func TestDiagnostics(t *testing.T) { for _, item := range ds { desc := item.Description() - var attr []interface{} + var attr []any for _, a := range tfdiags.GetAttribute(item) { switch step := a.(type) { diff --git a/staging/terraform/plugin/convert/schema.go b/staging/terraform/plugin/convert/schema.go index 0edbe4a..4934aff 100644 --- a/staging/terraform/plugin/convert/schema.go +++ b/staging/terraform/plugin/convert/schema.go @@ -174,7 +174,7 @@ func schemaNestedBlock(b *proto.Schema_NestedBlock) *configschema.NestedBlock { // sortedKeys returns the lexically sorted keys from the given map. This is // used to make schema conversions are deterministic. This panics if map keys // are not a string. -func sortedKeys(m interface{}) []string { +func sortedKeys(m any) []string { v := reflect.ValueOf(m) keys := make([]string, v.Len()) diff --git a/staging/terraform/plugin/grpc_provider.go b/staging/terraform/plugin/grpc_provider.go index 012fcec..1b5f228 100644 --- a/staging/terraform/plugin/grpc_provider.go +++ b/staging/terraform/plugin/grpc_provider.go @@ -29,7 +29,7 @@ type GRPCProviderPlugin struct { GRPCProvider func() proto.ProviderServer } -func (p *GRPCProviderPlugin) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error) { +func (p *GRPCProviderPlugin) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (any, error) { return &GRPCProvider{ client: proto.NewProviderClient(c), ctx: ctx, diff --git a/staging/terraform/plugin/grpc_provider_test.go b/staging/terraform/plugin/grpc_provider_test.go index bde1bee..99da113 100644 --- a/staging/terraform/plugin/grpc_provider_test.go +++ b/staging/terraform/plugin/grpc_provider_test.go @@ -167,7 +167,7 @@ func TestGRPCProvider_PrepareProviderConfig(t *testing.T) { gomock.Any(), ).Return(&proto.PrepareProviderConfig_Response{}, nil) - cfg := hcl2shim.HCL2ValueFromConfigValue(map[string]interface{}{"attr": "value"}) + cfg := hcl2shim.HCL2ValueFromConfigValue(map[string]any{"attr": "value"}) resp := p.ValidateProviderConfig(providers.ValidateProviderConfigRequest{Config: cfg}) checkDiags(t, resp.Diagnostics) } @@ -183,7 +183,7 @@ func TestGRPCProvider_ValidateResourceConfig(t *testing.T) { gomock.Any(), ).Return(&proto.ValidateResourceTypeConfig_Response{}, nil) - cfg := hcl2shim.HCL2ValueFromConfigValue(map[string]interface{}{"attr": "value"}) + cfg := hcl2shim.HCL2ValueFromConfigValue(map[string]any{"attr": "value"}) resp := p.ValidateResourceConfig(providers.ValidateResourceConfigRequest{ TypeName: "resource", Config: cfg, @@ -202,7 +202,7 @@ func TestGRPCProvider_ValidateDataSourceConfig(t *testing.T) { gomock.Any(), ).Return(&proto.ValidateDataSourceConfig_Response{}, nil) - cfg := hcl2shim.HCL2ValueFromConfigValue(map[string]interface{}{"attr": "value"}) + cfg := hcl2shim.HCL2ValueFromConfigValue(map[string]any{"attr": "value"}) resp := p.ValidateDataResourceConfig(providers.ValidateDataResourceConfigRequest{ TypeName: "data", Config: cfg, diff --git a/staging/terraform/plugin/grpc_provisioner.go b/staging/terraform/plugin/grpc_provisioner.go index 22cfa3a..3a580f1 100644 --- a/staging/terraform/plugin/grpc_provisioner.go +++ b/staging/terraform/plugin/grpc_provisioner.go @@ -25,7 +25,7 @@ type GRPCProvisionerPlugin struct { GRPCProvisioner func() proto.ProvisionerServer } -func (p *GRPCProvisionerPlugin) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error) { +func (p *GRPCProvisionerPlugin) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (any, error) { return &GRPCProvisioner{ client: proto.NewProvisionerClient(c), ctx: ctx, diff --git a/staging/terraform/plugin/grpc_provisioner_test.go b/staging/terraform/plugin/grpc_provisioner_test.go index b0f27a4..61e6eb6 100644 --- a/staging/terraform/plugin/grpc_provisioner_test.go +++ b/staging/terraform/plugin/grpc_provisioner_test.go @@ -75,7 +75,7 @@ func TestGRPCProvisioner_ValidateProvisionerConfig(t *testing.T) { gomock.Any(), ).Return(&proto.ValidateProvisionerConfig_Response{}, nil) - cfg := hcl2shim.HCL2ValueFromConfigValue(map[string]interface{}{"attr": "value"}) + cfg := hcl2shim.HCL2ValueFromConfigValue(map[string]any{"attr": "value"}) resp := p.ValidateProvisionerConfig(provisioners.ValidateProvisionerConfigRequest{Config: cfg}) checkDiags(t, resp.Diagnostics) } diff --git a/staging/terraform/plugin/mock_proto/mock.go b/staging/terraform/plugin/mock_proto/mock.go index b911537..e8c40b9 100644 --- a/staging/terraform/plugin/mock_proto/mock.go +++ b/staging/terraform/plugin/mock_proto/mock.go @@ -40,7 +40,7 @@ func (m *MockProviderClient) EXPECT() *MockProviderClientMockRecorder { // ApplyResourceChange mocks base method. func (m *MockProviderClient) ApplyResourceChange(arg0 context.Context, arg1 *tfplugin5.ApplyResourceChange_Request, arg2 ...grpc.CallOption) (*tfplugin5.ApplyResourceChange_Response, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -51,16 +51,16 @@ func (m *MockProviderClient) ApplyResourceChange(arg0 context.Context, arg1 *tfp } // ApplyResourceChange indicates an expected call of ApplyResourceChange. -func (mr *MockProviderClientMockRecorder) ApplyResourceChange(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockProviderClientMockRecorder) ApplyResourceChange(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ApplyResourceChange", reflect.TypeOf((*MockProviderClient)(nil).ApplyResourceChange), varargs...) } // Configure mocks base method. func (m *MockProviderClient) Configure(arg0 context.Context, arg1 *tfplugin5.Configure_Request, arg2 ...grpc.CallOption) (*tfplugin5.Configure_Response, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -71,16 +71,16 @@ func (m *MockProviderClient) Configure(arg0 context.Context, arg1 *tfplugin5.Con } // Configure indicates an expected call of Configure. -func (mr *MockProviderClientMockRecorder) Configure(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockProviderClientMockRecorder) Configure(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Configure", reflect.TypeOf((*MockProviderClient)(nil).Configure), varargs...) } // GetSchema mocks base method. func (m *MockProviderClient) GetSchema(arg0 context.Context, arg1 *tfplugin5.GetProviderSchema_Request, arg2 ...grpc.CallOption) (*tfplugin5.GetProviderSchema_Response, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -91,16 +91,16 @@ func (m *MockProviderClient) GetSchema(arg0 context.Context, arg1 *tfplugin5.Get } // GetSchema indicates an expected call of GetSchema. -func (mr *MockProviderClientMockRecorder) GetSchema(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockProviderClientMockRecorder) GetSchema(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSchema", reflect.TypeOf((*MockProviderClient)(nil).GetSchema), varargs...) } // ImportResourceState mocks base method. func (m *MockProviderClient) ImportResourceState(arg0 context.Context, arg1 *tfplugin5.ImportResourceState_Request, arg2 ...grpc.CallOption) (*tfplugin5.ImportResourceState_Response, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -111,16 +111,16 @@ func (m *MockProviderClient) ImportResourceState(arg0 context.Context, arg1 *tfp } // ImportResourceState indicates an expected call of ImportResourceState. -func (mr *MockProviderClientMockRecorder) ImportResourceState(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockProviderClientMockRecorder) ImportResourceState(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ImportResourceState", reflect.TypeOf((*MockProviderClient)(nil).ImportResourceState), varargs...) } // PlanResourceChange mocks base method. func (m *MockProviderClient) PlanResourceChange(arg0 context.Context, arg1 *tfplugin5.PlanResourceChange_Request, arg2 ...grpc.CallOption) (*tfplugin5.PlanResourceChange_Response, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -131,16 +131,16 @@ func (m *MockProviderClient) PlanResourceChange(arg0 context.Context, arg1 *tfpl } // PlanResourceChange indicates an expected call of PlanResourceChange. -func (mr *MockProviderClientMockRecorder) PlanResourceChange(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockProviderClientMockRecorder) PlanResourceChange(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PlanResourceChange", reflect.TypeOf((*MockProviderClient)(nil).PlanResourceChange), varargs...) } // PrepareProviderConfig mocks base method. func (m *MockProviderClient) PrepareProviderConfig(arg0 context.Context, arg1 *tfplugin5.PrepareProviderConfig_Request, arg2 ...grpc.CallOption) (*tfplugin5.PrepareProviderConfig_Response, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -151,16 +151,16 @@ func (m *MockProviderClient) PrepareProviderConfig(arg0 context.Context, arg1 *t } // PrepareProviderConfig indicates an expected call of PrepareProviderConfig. -func (mr *MockProviderClientMockRecorder) PrepareProviderConfig(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockProviderClientMockRecorder) PrepareProviderConfig(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PrepareProviderConfig", reflect.TypeOf((*MockProviderClient)(nil).PrepareProviderConfig), varargs...) } // ReadDataSource mocks base method. func (m *MockProviderClient) ReadDataSource(arg0 context.Context, arg1 *tfplugin5.ReadDataSource_Request, arg2 ...grpc.CallOption) (*tfplugin5.ReadDataSource_Response, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -171,16 +171,16 @@ func (m *MockProviderClient) ReadDataSource(arg0 context.Context, arg1 *tfplugin } // ReadDataSource indicates an expected call of ReadDataSource. -func (mr *MockProviderClientMockRecorder) ReadDataSource(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockProviderClientMockRecorder) ReadDataSource(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReadDataSource", reflect.TypeOf((*MockProviderClient)(nil).ReadDataSource), varargs...) } // ReadResource mocks base method. func (m *MockProviderClient) ReadResource(arg0 context.Context, arg1 *tfplugin5.ReadResource_Request, arg2 ...grpc.CallOption) (*tfplugin5.ReadResource_Response, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -191,16 +191,16 @@ func (m *MockProviderClient) ReadResource(arg0 context.Context, arg1 *tfplugin5. } // ReadResource indicates an expected call of ReadResource. -func (mr *MockProviderClientMockRecorder) ReadResource(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockProviderClientMockRecorder) ReadResource(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReadResource", reflect.TypeOf((*MockProviderClient)(nil).ReadResource), varargs...) } // Stop mocks base method. func (m *MockProviderClient) Stop(arg0 context.Context, arg1 *tfplugin5.Stop_Request, arg2 ...grpc.CallOption) (*tfplugin5.Stop_Response, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -211,16 +211,16 @@ func (m *MockProviderClient) Stop(arg0 context.Context, arg1 *tfplugin5.Stop_Req } // Stop indicates an expected call of Stop. -func (mr *MockProviderClientMockRecorder) Stop(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockProviderClientMockRecorder) Stop(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Stop", reflect.TypeOf((*MockProviderClient)(nil).Stop), varargs...) } // UpgradeResourceState mocks base method. func (m *MockProviderClient) UpgradeResourceState(arg0 context.Context, arg1 *tfplugin5.UpgradeResourceState_Request, arg2 ...grpc.CallOption) (*tfplugin5.UpgradeResourceState_Response, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -231,16 +231,16 @@ func (m *MockProviderClient) UpgradeResourceState(arg0 context.Context, arg1 *tf } // UpgradeResourceState indicates an expected call of UpgradeResourceState. -func (mr *MockProviderClientMockRecorder) UpgradeResourceState(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockProviderClientMockRecorder) UpgradeResourceState(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpgradeResourceState", reflect.TypeOf((*MockProviderClient)(nil).UpgradeResourceState), varargs...) } // ValidateDataSourceConfig mocks base method. func (m *MockProviderClient) ValidateDataSourceConfig(arg0 context.Context, arg1 *tfplugin5.ValidateDataSourceConfig_Request, arg2 ...grpc.CallOption) (*tfplugin5.ValidateDataSourceConfig_Response, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -251,16 +251,16 @@ func (m *MockProviderClient) ValidateDataSourceConfig(arg0 context.Context, arg1 } // ValidateDataSourceConfig indicates an expected call of ValidateDataSourceConfig. -func (mr *MockProviderClientMockRecorder) ValidateDataSourceConfig(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockProviderClientMockRecorder) ValidateDataSourceConfig(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ValidateDataSourceConfig", reflect.TypeOf((*MockProviderClient)(nil).ValidateDataSourceConfig), varargs...) } // ValidateResourceTypeConfig mocks base method. func (m *MockProviderClient) ValidateResourceTypeConfig(arg0 context.Context, arg1 *tfplugin5.ValidateResourceTypeConfig_Request, arg2 ...grpc.CallOption) (*tfplugin5.ValidateResourceTypeConfig_Response, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -271,9 +271,9 @@ func (m *MockProviderClient) ValidateResourceTypeConfig(arg0 context.Context, ar } // ValidateResourceTypeConfig indicates an expected call of ValidateResourceTypeConfig. -func (mr *MockProviderClientMockRecorder) ValidateResourceTypeConfig(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockProviderClientMockRecorder) ValidateResourceTypeConfig(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ValidateResourceTypeConfig", reflect.TypeOf((*MockProviderClient)(nil).ValidateResourceTypeConfig), varargs...) } @@ -303,7 +303,7 @@ func (m *MockProvisionerClient) EXPECT() *MockProvisionerClientMockRecorder { // GetSchema mocks base method. func (m *MockProvisionerClient) GetSchema(arg0 context.Context, arg1 *tfplugin5.GetProvisionerSchema_Request, arg2 ...grpc.CallOption) (*tfplugin5.GetProvisionerSchema_Response, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -314,16 +314,16 @@ func (m *MockProvisionerClient) GetSchema(arg0 context.Context, arg1 *tfplugin5. } // GetSchema indicates an expected call of GetSchema. -func (mr *MockProvisionerClientMockRecorder) GetSchema(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockProvisionerClientMockRecorder) GetSchema(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSchema", reflect.TypeOf((*MockProvisionerClient)(nil).GetSchema), varargs...) } // ProvisionResource mocks base method. func (m *MockProvisionerClient) ProvisionResource(arg0 context.Context, arg1 *tfplugin5.ProvisionResource_Request, arg2 ...grpc.CallOption) (tfplugin5.Provisioner_ProvisionResourceClient, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -334,16 +334,16 @@ func (m *MockProvisionerClient) ProvisionResource(arg0 context.Context, arg1 *tf } // ProvisionResource indicates an expected call of ProvisionResource. -func (mr *MockProvisionerClientMockRecorder) ProvisionResource(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockProvisionerClientMockRecorder) ProvisionResource(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ProvisionResource", reflect.TypeOf((*MockProvisionerClient)(nil).ProvisionResource), varargs...) } // Stop mocks base method. func (m *MockProvisionerClient) Stop(arg0 context.Context, arg1 *tfplugin5.Stop_Request, arg2 ...grpc.CallOption) (*tfplugin5.Stop_Response, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -354,16 +354,16 @@ func (m *MockProvisionerClient) Stop(arg0 context.Context, arg1 *tfplugin5.Stop_ } // Stop indicates an expected call of Stop. -func (mr *MockProvisionerClientMockRecorder) Stop(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockProvisionerClientMockRecorder) Stop(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Stop", reflect.TypeOf((*MockProvisionerClient)(nil).Stop), varargs...) } // ValidateProvisionerConfig mocks base method. func (m *MockProvisionerClient) ValidateProvisionerConfig(arg0 context.Context, arg1 *tfplugin5.ValidateProvisionerConfig_Request, arg2 ...grpc.CallOption) (*tfplugin5.ValidateProvisionerConfig_Response, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -374,9 +374,9 @@ func (m *MockProvisionerClient) ValidateProvisionerConfig(arg0 context.Context, } // ValidateProvisionerConfig indicates an expected call of ValidateProvisionerConfig. -func (mr *MockProvisionerClientMockRecorder) ValidateProvisionerConfig(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockProvisionerClientMockRecorder) ValidateProvisionerConfig(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ValidateProvisionerConfig", reflect.TypeOf((*MockProvisionerClient)(nil).ValidateProvisionerConfig), varargs...) } @@ -462,7 +462,7 @@ func (mr *MockProvisioner_ProvisionResourceClientMockRecorder) Recv() *gomock.Ca } // RecvMsg mocks base method. -func (m *MockProvisioner_ProvisionResourceClient) RecvMsg(arg0 interface{}) error { +func (m *MockProvisioner_ProvisionResourceClient) RecvMsg(arg0 any) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "RecvMsg", arg0) ret0, _ := ret[0].(error) @@ -470,13 +470,13 @@ func (m *MockProvisioner_ProvisionResourceClient) RecvMsg(arg0 interface{}) erro } // RecvMsg indicates an expected call of RecvMsg. -func (mr *MockProvisioner_ProvisionResourceClientMockRecorder) RecvMsg(arg0 interface{}) *gomock.Call { +func (mr *MockProvisioner_ProvisionResourceClientMockRecorder) RecvMsg(arg0 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RecvMsg", reflect.TypeOf((*MockProvisioner_ProvisionResourceClient)(nil).RecvMsg), arg0) } // SendMsg mocks base method. -func (m *MockProvisioner_ProvisionResourceClient) SendMsg(arg0 interface{}) error { +func (m *MockProvisioner_ProvisionResourceClient) SendMsg(arg0 any) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SendMsg", arg0) ret0, _ := ret[0].(error) @@ -484,7 +484,7 @@ func (m *MockProvisioner_ProvisionResourceClient) SendMsg(arg0 interface{}) erro } // SendMsg indicates an expected call of SendMsg. -func (mr *MockProvisioner_ProvisionResourceClientMockRecorder) SendMsg(arg0 interface{}) *gomock.Call { +func (mr *MockProvisioner_ProvisionResourceClientMockRecorder) SendMsg(arg0 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendMsg", reflect.TypeOf((*MockProvisioner_ProvisionResourceClient)(nil).SendMsg), arg0) } @@ -541,7 +541,7 @@ func (mr *MockProvisioner_ProvisionResourceServerMockRecorder) Context() *gomock } // RecvMsg mocks base method. -func (m *MockProvisioner_ProvisionResourceServer) RecvMsg(arg0 interface{}) error { +func (m *MockProvisioner_ProvisionResourceServer) RecvMsg(arg0 any) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "RecvMsg", arg0) ret0, _ := ret[0].(error) @@ -549,7 +549,7 @@ func (m *MockProvisioner_ProvisionResourceServer) RecvMsg(arg0 interface{}) erro } // RecvMsg indicates an expected call of RecvMsg. -func (mr *MockProvisioner_ProvisionResourceServerMockRecorder) RecvMsg(arg0 interface{}) *gomock.Call { +func (mr *MockProvisioner_ProvisionResourceServerMockRecorder) RecvMsg(arg0 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RecvMsg", reflect.TypeOf((*MockProvisioner_ProvisionResourceServer)(nil).RecvMsg), arg0) } @@ -563,7 +563,7 @@ func (m *MockProvisioner_ProvisionResourceServer) Send(arg0 *tfplugin5.Provision } // Send indicates an expected call of Send. -func (mr *MockProvisioner_ProvisionResourceServerMockRecorder) Send(arg0 interface{}) *gomock.Call { +func (mr *MockProvisioner_ProvisionResourceServerMockRecorder) Send(arg0 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Send", reflect.TypeOf((*MockProvisioner_ProvisionResourceServer)(nil).Send), arg0) } @@ -577,13 +577,13 @@ func (m *MockProvisioner_ProvisionResourceServer) SendHeader(arg0 metadata.MD) e } // SendHeader indicates an expected call of SendHeader. -func (mr *MockProvisioner_ProvisionResourceServerMockRecorder) SendHeader(arg0 interface{}) *gomock.Call { +func (mr *MockProvisioner_ProvisionResourceServerMockRecorder) SendHeader(arg0 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendHeader", reflect.TypeOf((*MockProvisioner_ProvisionResourceServer)(nil).SendHeader), arg0) } // SendMsg mocks base method. -func (m *MockProvisioner_ProvisionResourceServer) SendMsg(arg0 interface{}) error { +func (m *MockProvisioner_ProvisionResourceServer) SendMsg(arg0 any) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SendMsg", arg0) ret0, _ := ret[0].(error) @@ -591,7 +591,7 @@ func (m *MockProvisioner_ProvisionResourceServer) SendMsg(arg0 interface{}) erro } // SendMsg indicates an expected call of SendMsg. -func (mr *MockProvisioner_ProvisionResourceServerMockRecorder) SendMsg(arg0 interface{}) *gomock.Call { +func (mr *MockProvisioner_ProvisionResourceServerMockRecorder) SendMsg(arg0 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendMsg", reflect.TypeOf((*MockProvisioner_ProvisionResourceServer)(nil).SendMsg), arg0) } @@ -605,7 +605,7 @@ func (m *MockProvisioner_ProvisionResourceServer) SetHeader(arg0 metadata.MD) er } // SetHeader indicates an expected call of SetHeader. -func (mr *MockProvisioner_ProvisionResourceServerMockRecorder) SetHeader(arg0 interface{}) *gomock.Call { +func (mr *MockProvisioner_ProvisionResourceServerMockRecorder) SetHeader(arg0 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetHeader", reflect.TypeOf((*MockProvisioner_ProvisionResourceServer)(nil).SetHeader), arg0) } @@ -617,7 +617,7 @@ func (m *MockProvisioner_ProvisionResourceServer) SetTrailer(arg0 metadata.MD) { } // SetTrailer indicates an expected call of SetTrailer. -func (mr *MockProvisioner_ProvisionResourceServerMockRecorder) SetTrailer(arg0 interface{}) *gomock.Call { +func (mr *MockProvisioner_ProvisionResourceServerMockRecorder) SetTrailer(arg0 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetTrailer", reflect.TypeOf((*MockProvisioner_ProvisionResourceServer)(nil).SetTrailer), arg0) } diff --git a/staging/terraform/plugin/ui_output.go b/staging/terraform/plugin/ui_output.go index ec16d13..a9637c7 100644 --- a/staging/terraform/plugin/ui_output.go +++ b/staging/terraform/plugin/ui_output.go @@ -16,7 +16,7 @@ type UIOutput struct { } func (o *UIOutput) Output(v string) { - o.Client.Call("Plugin.Output", v, new(interface{})) + o.Client.Call("Plugin.Output", v, new(any)) } // UIOutputServer is the RPC server for serving UIOutput. @@ -26,7 +26,7 @@ type UIOutputServer struct { func (s *UIOutputServer) Output( v string, - reply *interface{}) error { + reply *any) error { s.UIOutput.Output(v) return nil } diff --git a/staging/terraform/plugin6/convert/diagnostics.go b/staging/terraform/plugin6/convert/diagnostics.go index 94455e9..4a51be1 100644 --- a/staging/terraform/plugin6/convert/diagnostics.go +++ b/staging/terraform/plugin6/convert/diagnostics.go @@ -25,7 +25,7 @@ func WarnsAndErrsToProto(warns []string, errs []error) (diags []*proto.Diagnosti // AppendProtoDiag appends a new diagnostic from a warning string or an error. // This panics if d is not a string or error. -func AppendProtoDiag(diags []*proto.Diagnostic, d interface{}) []*proto.Diagnostic { +func AppendProtoDiag(diags []*proto.Diagnostic, d any) []*proto.Diagnostic { switch d := d.(type) { case cty.PathError: ap := PathToAttributePath(d.Path) diff --git a/staging/terraform/plugin6/convert/diagnostics_test.go b/staging/terraform/plugin6/convert/diagnostics_test.go index 4e1c110..6dd1e3f 100644 --- a/staging/terraform/plugin6/convert/diagnostics_test.go +++ b/staging/terraform/plugin6/convert/diagnostics_test.go @@ -60,7 +60,7 @@ func TestProtoDiagnostics(t *testing.T) { func TestDiagnostics(t *testing.T) { type diagFlat struct { Severity tfdiags.Severity - Attr []interface{} + Attr []any Summary string Detail string } @@ -202,7 +202,7 @@ func TestDiagnostics(t *testing.T) { Severity: tfdiags.Error, Summary: "error", Detail: "error detail", - Attr: []interface{}{"attribute_name"}, + Attr: []any{"attribute_name"}, }, }, }, @@ -299,25 +299,25 @@ func TestDiagnostics(t *testing.T) { Severity: tfdiags.Error, Summary: "error 1", Detail: "error 1 detail", - Attr: []interface{}{"attr"}, + Attr: []any{"attr"}, }, { Severity: tfdiags.Error, Summary: "error 2", Detail: "error 2 detail", - Attr: []interface{}{"attr", "sub"}, + Attr: []any{"attr", "sub"}, }, { Severity: tfdiags.Warning, Summary: "warning", Detail: "warning detail", - Attr: []interface{}{"attr", 1, "sub"}, + Attr: []any{"attr", 1, "sub"}, }, { Severity: tfdiags.Error, Summary: "error 3", Detail: "error 3 detail", - Attr: []interface{}{"attr", "idx", "sub"}, + Attr: []any{"attr", "idx", "sub"}, }, }, }, @@ -328,7 +328,7 @@ func TestDiagnostics(t *testing.T) { for _, item := range ds { desc := item.Description() - var attr []interface{} + var attr []any for _, a := range tfdiags.GetAttribute(item) { switch step := a.(type) { diff --git a/staging/terraform/plugin6/convert/schema.go b/staging/terraform/plugin6/convert/schema.go index 38aa322..a5fc197 100644 --- a/staging/terraform/plugin6/convert/schema.go +++ b/staging/terraform/plugin6/convert/schema.go @@ -234,7 +234,7 @@ func protoObjectToConfigSchema(b *proto.Schema_Object) *configschema.Object { // sortedKeys returns the lexically sorted keys from the given map. This is // used to make schema conversions are deterministic. This panics if map keys // are not a string. -func sortedKeys(m interface{}) []string { +func sortedKeys(m any) []string { v := reflect.ValueOf(m) keys := make([]string, v.Len()) diff --git a/staging/terraform/plugin6/grpc_provider.go b/staging/terraform/plugin6/grpc_provider.go index 8202d78..fdb849d 100644 --- a/staging/terraform/plugin6/grpc_provider.go +++ b/staging/terraform/plugin6/grpc_provider.go @@ -29,7 +29,7 @@ type GRPCProviderPlugin struct { GRPCProvider func() proto6.ProviderServer } -func (p *GRPCProviderPlugin) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error) { +func (p *GRPCProviderPlugin) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (any, error) { return &GRPCProvider{ client: proto6.NewProviderClient(c), ctx: ctx, diff --git a/staging/terraform/plugin6/grpc_provider_test.go b/staging/terraform/plugin6/grpc_provider_test.go index 74d50c6..4abbeb9 100644 --- a/staging/terraform/plugin6/grpc_provider_test.go +++ b/staging/terraform/plugin6/grpc_provider_test.go @@ -174,7 +174,7 @@ func TestGRPCProvider_PrepareProviderConfig(t *testing.T) { gomock.Any(), ).Return(&proto.ValidateProviderConfig_Response{}, nil) - cfg := hcl2shim.HCL2ValueFromConfigValue(map[string]interface{}{"attr": "value"}) + cfg := hcl2shim.HCL2ValueFromConfigValue(map[string]any{"attr": "value"}) resp := p.ValidateProviderConfig(providers.ValidateProviderConfigRequest{Config: cfg}) checkDiags(t, resp.Diagnostics) } @@ -190,7 +190,7 @@ func TestGRPCProvider_ValidateResourceConfig(t *testing.T) { gomock.Any(), ).Return(&proto.ValidateResourceConfig_Response{}, nil) - cfg := hcl2shim.HCL2ValueFromConfigValue(map[string]interface{}{"attr": "value"}) + cfg := hcl2shim.HCL2ValueFromConfigValue(map[string]any{"attr": "value"}) resp := p.ValidateResourceConfig(providers.ValidateResourceConfigRequest{ TypeName: "resource", Config: cfg, @@ -209,7 +209,7 @@ func TestGRPCProvider_ValidateDataResourceConfig(t *testing.T) { gomock.Any(), ).Return(&proto.ValidateDataResourceConfig_Response{}, nil) - cfg := hcl2shim.HCL2ValueFromConfigValue(map[string]interface{}{"attr": "value"}) + cfg := hcl2shim.HCL2ValueFromConfigValue(map[string]any{"attr": "value"}) resp := p.ValidateDataResourceConfig(providers.ValidateDataResourceConfigRequest{ TypeName: "data", Config: cfg, diff --git a/staging/terraform/plugin6/mock_proto/mock.go b/staging/terraform/plugin6/mock_proto/mock.go index b6b6e50..266be43 100644 --- a/staging/terraform/plugin6/mock_proto/mock.go +++ b/staging/terraform/plugin6/mock_proto/mock.go @@ -39,7 +39,7 @@ func (m *MockProviderClient) EXPECT() *MockProviderClientMockRecorder { // ApplyResourceChange mocks base method. func (m *MockProviderClient) ApplyResourceChange(arg0 context.Context, arg1 *tfplugin6.ApplyResourceChange_Request, arg2 ...grpc.CallOption) (*tfplugin6.ApplyResourceChange_Response, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -50,16 +50,16 @@ func (m *MockProviderClient) ApplyResourceChange(arg0 context.Context, arg1 *tfp } // ApplyResourceChange indicates an expected call of ApplyResourceChange. -func (mr *MockProviderClientMockRecorder) ApplyResourceChange(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockProviderClientMockRecorder) ApplyResourceChange(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ApplyResourceChange", reflect.TypeOf((*MockProviderClient)(nil).ApplyResourceChange), varargs...) } // ConfigureProvider mocks base method. func (m *MockProviderClient) ConfigureProvider(arg0 context.Context, arg1 *tfplugin6.ConfigureProvider_Request, arg2 ...grpc.CallOption) (*tfplugin6.ConfigureProvider_Response, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -70,16 +70,16 @@ func (m *MockProviderClient) ConfigureProvider(arg0 context.Context, arg1 *tfplu } // ConfigureProvider indicates an expected call of ConfigureProvider. -func (mr *MockProviderClientMockRecorder) ConfigureProvider(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockProviderClientMockRecorder) ConfigureProvider(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ConfigureProvider", reflect.TypeOf((*MockProviderClient)(nil).ConfigureProvider), varargs...) } // GetProviderSchema mocks base method. func (m *MockProviderClient) GetProviderSchema(arg0 context.Context, arg1 *tfplugin6.GetProviderSchema_Request, arg2 ...grpc.CallOption) (*tfplugin6.GetProviderSchema_Response, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -90,16 +90,16 @@ func (m *MockProviderClient) GetProviderSchema(arg0 context.Context, arg1 *tfplu } // GetProviderSchema indicates an expected call of GetProviderSchema. -func (mr *MockProviderClientMockRecorder) GetProviderSchema(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockProviderClientMockRecorder) GetProviderSchema(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetProviderSchema", reflect.TypeOf((*MockProviderClient)(nil).GetProviderSchema), varargs...) } // ImportResourceState mocks base method. func (m *MockProviderClient) ImportResourceState(arg0 context.Context, arg1 *tfplugin6.ImportResourceState_Request, arg2 ...grpc.CallOption) (*tfplugin6.ImportResourceState_Response, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -110,16 +110,16 @@ func (m *MockProviderClient) ImportResourceState(arg0 context.Context, arg1 *tfp } // ImportResourceState indicates an expected call of ImportResourceState. -func (mr *MockProviderClientMockRecorder) ImportResourceState(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockProviderClientMockRecorder) ImportResourceState(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ImportResourceState", reflect.TypeOf((*MockProviderClient)(nil).ImportResourceState), varargs...) } // PlanResourceChange mocks base method. func (m *MockProviderClient) PlanResourceChange(arg0 context.Context, arg1 *tfplugin6.PlanResourceChange_Request, arg2 ...grpc.CallOption) (*tfplugin6.PlanResourceChange_Response, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -130,16 +130,16 @@ func (m *MockProviderClient) PlanResourceChange(arg0 context.Context, arg1 *tfpl } // PlanResourceChange indicates an expected call of PlanResourceChange. -func (mr *MockProviderClientMockRecorder) PlanResourceChange(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockProviderClientMockRecorder) PlanResourceChange(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PlanResourceChange", reflect.TypeOf((*MockProviderClient)(nil).PlanResourceChange), varargs...) } // ReadDataSource mocks base method. func (m *MockProviderClient) ReadDataSource(arg0 context.Context, arg1 *tfplugin6.ReadDataSource_Request, arg2 ...grpc.CallOption) (*tfplugin6.ReadDataSource_Response, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -150,16 +150,16 @@ func (m *MockProviderClient) ReadDataSource(arg0 context.Context, arg1 *tfplugin } // ReadDataSource indicates an expected call of ReadDataSource. -func (mr *MockProviderClientMockRecorder) ReadDataSource(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockProviderClientMockRecorder) ReadDataSource(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReadDataSource", reflect.TypeOf((*MockProviderClient)(nil).ReadDataSource), varargs...) } // ReadResource mocks base method. func (m *MockProviderClient) ReadResource(arg0 context.Context, arg1 *tfplugin6.ReadResource_Request, arg2 ...grpc.CallOption) (*tfplugin6.ReadResource_Response, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -170,16 +170,16 @@ func (m *MockProviderClient) ReadResource(arg0 context.Context, arg1 *tfplugin6. } // ReadResource indicates an expected call of ReadResource. -func (mr *MockProviderClientMockRecorder) ReadResource(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockProviderClientMockRecorder) ReadResource(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReadResource", reflect.TypeOf((*MockProviderClient)(nil).ReadResource), varargs...) } // StopProvider mocks base method. func (m *MockProviderClient) StopProvider(arg0 context.Context, arg1 *tfplugin6.StopProvider_Request, arg2 ...grpc.CallOption) (*tfplugin6.StopProvider_Response, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -190,16 +190,16 @@ func (m *MockProviderClient) StopProvider(arg0 context.Context, arg1 *tfplugin6. } // StopProvider indicates an expected call of StopProvider. -func (mr *MockProviderClientMockRecorder) StopProvider(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockProviderClientMockRecorder) StopProvider(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StopProvider", reflect.TypeOf((*MockProviderClient)(nil).StopProvider), varargs...) } // UpgradeResourceState mocks base method. func (m *MockProviderClient) UpgradeResourceState(arg0 context.Context, arg1 *tfplugin6.UpgradeResourceState_Request, arg2 ...grpc.CallOption) (*tfplugin6.UpgradeResourceState_Response, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -210,16 +210,16 @@ func (m *MockProviderClient) UpgradeResourceState(arg0 context.Context, arg1 *tf } // UpgradeResourceState indicates an expected call of UpgradeResourceState. -func (mr *MockProviderClientMockRecorder) UpgradeResourceState(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockProviderClientMockRecorder) UpgradeResourceState(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpgradeResourceState", reflect.TypeOf((*MockProviderClient)(nil).UpgradeResourceState), varargs...) } // ValidateDataResourceConfig mocks base method. func (m *MockProviderClient) ValidateDataResourceConfig(arg0 context.Context, arg1 *tfplugin6.ValidateDataResourceConfig_Request, arg2 ...grpc.CallOption) (*tfplugin6.ValidateDataResourceConfig_Response, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -230,16 +230,16 @@ func (m *MockProviderClient) ValidateDataResourceConfig(arg0 context.Context, ar } // ValidateDataResourceConfig indicates an expected call of ValidateDataResourceConfig. -func (mr *MockProviderClientMockRecorder) ValidateDataResourceConfig(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockProviderClientMockRecorder) ValidateDataResourceConfig(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ValidateDataResourceConfig", reflect.TypeOf((*MockProviderClient)(nil).ValidateDataResourceConfig), varargs...) } // ValidateProviderConfig mocks base method. func (m *MockProviderClient) ValidateProviderConfig(arg0 context.Context, arg1 *tfplugin6.ValidateProviderConfig_Request, arg2 ...grpc.CallOption) (*tfplugin6.ValidateProviderConfig_Response, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -250,16 +250,16 @@ func (m *MockProviderClient) ValidateProviderConfig(arg0 context.Context, arg1 * } // ValidateProviderConfig indicates an expected call of ValidateProviderConfig. -func (mr *MockProviderClientMockRecorder) ValidateProviderConfig(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockProviderClientMockRecorder) ValidateProviderConfig(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ValidateProviderConfig", reflect.TypeOf((*MockProviderClient)(nil).ValidateProviderConfig), varargs...) } // ValidateResourceConfig mocks base method. func (m *MockProviderClient) ValidateResourceConfig(arg0 context.Context, arg1 *tfplugin6.ValidateResourceConfig_Request, arg2 ...grpc.CallOption) (*tfplugin6.ValidateResourceConfig_Response, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} + varargs := []any{arg0, arg1} for _, a := range arg2 { varargs = append(varargs, a) } @@ -270,8 +270,8 @@ func (m *MockProviderClient) ValidateResourceConfig(arg0 context.Context, arg1 * } // ValidateResourceConfig indicates an expected call of ValidateResourceConfig. -func (mr *MockProviderClientMockRecorder) ValidateResourceConfig(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { +func (mr *MockProviderClientMockRecorder) ValidateResourceConfig(arg0, arg1 any, arg2 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) + varargs := append([]any{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ValidateResourceConfig", reflect.TypeOf((*MockProviderClient)(nil).ValidateResourceConfig), varargs...) } diff --git a/staging/terraform/providercache/installer_events_test.go b/staging/terraform/providercache/installer_events_test.go index d8915d5..aa0a50a 100644 --- a/staging/terraform/providercache/installer_events_test.go +++ b/staging/terraform/providercache/installer_events_test.go @@ -19,7 +19,7 @@ type testInstallerEventLogItem struct { // The type of Args will vary by event, but it should always be something // that can be deterministically compared using the go-cmp package. - Args interface{} + Args any } // installerLogEventsForTests is a test helper that produces an InstallerEvents diff --git a/staging/terraform/providercache/installer_test.go b/staging/terraform/providercache/installer_test.go index a0274fe..a19f64e 100644 --- a/staging/terraform/providercache/installer_test.go +++ b/staging/terraform/providercache/installer_test.go @@ -2458,16 +2458,16 @@ func testServices(t *testing.T) (services *disco.Disco, baseURL string, cleanup server := httptest.NewServer(http.HandlerFunc(fakeRegistryHandler)) services = disco.New() - services.ForceHostServices(svchost.Hostname("example.com"), map[string]interface{}{ + services.ForceHostServices(svchost.Hostname("example.com"), map[string]any{ "providers.v1": server.URL + "/providers/v1/", }) - services.ForceHostServices(svchost.Hostname("not.example.com"), map[string]interface{}{}) - services.ForceHostServices(svchost.Hostname("too-new.example.com"), map[string]interface{}{ + services.ForceHostServices(svchost.Hostname("not.example.com"), map[string]any{}) + services.ForceHostServices(svchost.Hostname("too-new.example.com"), map[string]any{ // This service doesn't actually work; it's here only to be // detected as "too new" by the discovery logic. "providers.v99": server.URL + "/providers/v99/", }) - services.ForceHostServices(svchost.Hostname("fails.example.com"), map[string]interface{}{ + services.ForceHostServices(svchost.Hostname("fails.example.com"), map[string]any{ "providers.v1": server.URL + "/fails-immediately/", }) @@ -2476,7 +2476,7 @@ func testServices(t *testing.T) (services *disco.Disco, baseURL string, cleanup // hostname. It behaves the same as example.com, which should be preferred // if you're not testing something specific to the default registry in order // to ensure that most things are hostname-agnostic. - services.ForceHostServices(svchost.Hostname("registry.terraform.io"), map[string]interface{}{ + services.ForceHostServices(svchost.Hostname("registry.terraform.io"), map[string]any{ "providers.v1": server.URL + "/providers/v1/", }) @@ -2610,7 +2610,7 @@ func fakeRegistryHandler(resp http.ResponseWriter, req *http.Request) { return } version := pathParts[2] - body := map[string]interface{}{ + body := map[string]any{ "protocols": []string{"99.0"}, "os": pathParts[4], "arch": pathParts[5], @@ -2619,8 +2619,8 @@ func fakeRegistryHandler(resp http.ResponseWriter, req *http.Request) { "download_url": "/pkg/awesomesauce/happycloud_" + version + ".zip", "shasums_url": "/pkg/awesomesauce/happycloud_" + version + "_SHA256SUMS", "shasums_signature_url": "/pkg/awesomesauce/happycloud_" + version + "_SHA256SUMS.sig", - "signing_keys": map[string]interface{}{ - "gpg_public_keys": []map[string]interface{}{ + "signing_keys": map[string]any{ + "gpg_public_keys": []map[string]any{ { "ascii_armor": getproviders.HashicorpPublicKey, }, @@ -2647,7 +2647,7 @@ func fakeRegistryHandler(resp http.ResponseWriter, req *http.Request) { protocols = []string{"5.0"} } - body := map[string]interface{}{ + body := map[string]any{ "protocols": protocols, "os": pathParts[4], "arch": pathParts[5], @@ -2656,8 +2656,8 @@ func fakeRegistryHandler(resp http.ResponseWriter, req *http.Request) { "download_url": "/pkg/awesomesauce/happycloud_" + version + ".zip", "shasums_url": "/pkg/awesomesauce/happycloud_" + version + "_SHA256SUMS", "shasums_signature_url": "/pkg/awesomesauce/happycloud_" + version + "_SHA256SUMS.sig", - "signing_keys": map[string]interface{}{ - "gpg_public_keys": []map[string]interface{}{ + "signing_keys": map[string]any{ + "gpg_public_keys": []map[string]any{ { "ascii_armor": getproviders.HashicorpPublicKey, }, diff --git a/staging/terraform/registry/response/pagination_test.go b/staging/terraform/registry/response/pagination_test.go index f0ea296..0cacbea 100644 --- a/staging/terraform/registry/response/pagination_test.go +++ b/staging/terraform/registry/response/pagination_test.go @@ -8,7 +8,7 @@ import ( "testing" ) -func prettyJSON(o interface{}) (string, error) { +func prettyJSON(o any) (string, error) { bytes, err := json.MarshalIndent(o, "", "\t") if err != nil { return "", err diff --git a/staging/terraform/registry/test/mock_registry.go b/staging/terraform/registry/test/mock_registry.go index 00ead00..112f7b8 100644 --- a/staging/terraform/registry/test/mock_registry.go +++ b/staging/terraform/registry/test/mock_registry.go @@ -22,7 +22,7 @@ import ( // Disco return a *disco.Disco mapping registry.terraform.io, localhost, // localhost.localdomain, and example.com to the test server. func Disco(s *httptest.Server) *disco.Disco { - services := map[string]interface{}{ + services := map[string]any{ // Note that both with and without trailing slashes are supported behaviours // TODO: add specific tests to enumerate both possibilities. "modules.v1": fmt.Sprintf("%s/v1/modules", s.URL), @@ -58,7 +58,7 @@ const ( var ( regHost = svchost.Hostname(regsrc.PublicRegistryHost.Normalized()) - credsSrc = auth.StaticCredentialsSource(map[svchost.Hostname]map[string]interface{}{ + credsSrc = auth.StaticCredentialsSource(map[svchost.Hostname]map[string]any{ regHost: {"token": testCred}, }) ) diff --git a/staging/terraform/states/remote/remote_test.go b/staging/terraform/states/remote/remote_test.go index f28b989..00b87f8 100644 --- a/staging/terraform/states/remote/remote_test.go +++ b/staging/terraform/states/remote/remote_test.go @@ -37,7 +37,7 @@ type mockClient struct { type mockClientRequest struct { Method string - Content map[string]interface{} + Content map[string]any } func (c *mockClient) Get() (*Payload, error) { @@ -71,7 +71,7 @@ func (c *mockClient) appendLog(method string, content []byte) { // using this to test our own State implementation here and that always // uses the JSON state format, so this is fine. - var contentVal map[string]interface{} + var contentVal map[string]any if content != nil { err := json.Unmarshal(content, &contentVal) if err != nil { @@ -122,7 +122,7 @@ func (c *mockClientForcePusher) Delete() error { return nil } func (c *mockClientForcePusher) appendLog(method string, content []byte) { - var contentVal map[string]interface{} + var contentVal map[string]any if content != nil { err := json.Unmarshal(content, &contentVal) if err != nil { diff --git a/staging/terraform/states/remote/state_test.go b/staging/terraform/states/remote/state_test.go index 0233f3c..6e54284 100644 --- a/staging/terraform/states/remote/state_test.go +++ b/staging/terraform/states/remote/state_test.go @@ -115,21 +115,21 @@ func TestStatePersist(t *testing.T) { // Expect an initial push with values and a serial of 1 { Method: "Put", - Content: map[string]interface{}{ + Content: map[string]any{ "version": 4.0, // encoding/json decodes this as float64 by default "lineage": "some meaningless value", "serial": 1.0, // encoding/json decodes this as float64 by default "terraform_version": version.Version, - "outputs": map[string]interface{}{}, - "resources": []interface{}{ - map[string]interface{}{ - "instances": []interface{}{ - map[string]interface{}{ - "attributes_flat": map[string]interface{}{ + "outputs": map[string]any{}, + "resources": []any{ + map[string]any{ + "instances": []any{ + map[string]any{ + "attributes_flat": map[string]any{ "filename": "file.txt", }, "schema_version": 0.0, - "sensitive_attributes": []interface{}{}, + "sensitive_attributes": []any{}, }, }, "mode": "managed", @@ -153,21 +153,21 @@ func TestStatePersist(t *testing.T) { expectedRequests: []mockClientRequest{ { Method: "Put", - Content: map[string]interface{}{ + Content: map[string]any{ "version": 4.0, // encoding/json decodes this as float64 by default "lineage": "mock-lineage", "serial": 2.0, // encoding/json decodes this as float64 by default "terraform_version": version.Version, - "outputs": map[string]interface{}{}, - "resources": []interface{}{ - map[string]interface{}{ - "instances": []interface{}{ - map[string]interface{}{ - "attributes_flat": map[string]interface{}{ + "outputs": map[string]any{}, + "resources": []any{ + map[string]any{ + "instances": []any{ + map[string]any{ + "attributes_flat": map[string]any{ "filename": "file.txt", }, "schema_version": 0.0, - "sensitive_attributes": []interface{}{}, + "sensitive_attributes": []any{}, }, }, "mode": "managed", @@ -191,13 +191,13 @@ func TestStatePersist(t *testing.T) { expectedRequests: []mockClientRequest{ { Method: "Put", - Content: map[string]interface{}{ + Content: map[string]any{ "version": 4.0, // encoding/json decodes this as float64 by default "lineage": "mock-lineage", "serial": 3.0, // encoding/json decodes this as float64 by default "terraform_version": version.Version, - "outputs": map[string]interface{}{}, - "resources": []interface{}{}, + "outputs": map[string]any{}, + "resources": []any{}, "check_results": nil, }, }, @@ -216,13 +216,13 @@ func TestStatePersist(t *testing.T) { expectedRequests: []mockClientRequest{ { Method: "Put", - Content: map[string]interface{}{ + Content: map[string]any{ "version": 4.0, // encoding/json decodes this as float64 by default "lineage": "mock-lineage", "serial": 5.0, // encoding/json decodes this as float64 by default "terraform_version": version.Version, - "outputs": map[string]interface{}{}, - "resources": []interface{}{}, + "outputs": map[string]any{}, + "resources": []any{}, "check_results": nil, }, }, @@ -239,18 +239,18 @@ func TestStatePersist(t *testing.T) { expectedRequests: []mockClientRequest{ { Method: "Put", - Content: map[string]interface{}{ + Content: map[string]any{ "version": 4.0, // encoding/json decodes this as float64 by default "lineage": "mock-lineage", "serial": 4.0, // encoding/json decodes this as float64 by default "terraform_version": version.Version, - "outputs": map[string]interface{}{ - "foo": map[string]interface{}{ + "outputs": map[string]any{ + "foo": map[string]any{ "type": "string", "value": "bar", }, }, - "resources": []interface{}{}, + "resources": []any{}, "check_results": nil, }, }, @@ -267,18 +267,18 @@ func TestStatePersist(t *testing.T) { expectedRequests: []mockClientRequest{ { Method: "Put", - Content: map[string]interface{}{ + Content: map[string]any{ "version": 4.0, // encoding/json decodes this as float64 by default "lineage": "mock-lineage", "serial": 5.0, // encoding/json decodes this as float64 by default "terraform_version": version.Version, - "outputs": map[string]interface{}{ - "foo": map[string]interface{}{ + "outputs": map[string]any{ + "foo": map[string]any{ "type": "string", "value": "baz", }, }, - "resources": []interface{}{}, + "resources": []any{}, "check_results": nil, }, }, @@ -303,18 +303,18 @@ func TestStatePersist(t *testing.T) { expectedRequests: []mockClientRequest{ { Method: "Put", - Content: map[string]interface{}{ + Content: map[string]any{ "version": 4.0, // encoding/json decodes this as float64 by default "lineage": "mock-lineage", "serial": 3.0, // encoding/json decodes this as float64 by default "terraform_version": version.Version, - "outputs": map[string]interface{}{ - "foo": map[string]interface{}{ + "outputs": map[string]any{ + "foo": map[string]any{ "type": "string", "value": "baz", }, }, - "resources": []interface{}{}, + "resources": []any{}, "check_results": nil, }, }, @@ -367,7 +367,7 @@ func TestStatePersist(t *testing.T) { for expectedRequestIdx := 0; expectedRequestIdx < len(tc.expectedRequests); expectedRequestIdx++ { loggedRequest := mockClient.log[logIdx] logIdx++ - if diff := cmp.Diff(tc.expectedRequests[expectedRequestIdx], loggedRequest, cmpopts.IgnoreMapEntries(func(key string, value interface{}) bool { + if diff := cmp.Diff(tc.expectedRequests[expectedRequestIdx], loggedRequest, cmpopts.IgnoreMapEntries(func(key string, value any) bool { // This is required since the initial state creation causes the lineage to be a UUID that is not known at test time. return tc.name == "first state persistence" && key == "lineage" })); len(diff) > 0 { @@ -449,13 +449,13 @@ func TestWriteStateForMigration(t *testing.T) { }, expectedRequest: mockClientRequest{ Method: "Get", - Content: map[string]interface{}{ + Content: map[string]any{ "version": 4.0, "lineage": "mock-lineage", "serial": 3.0, "terraform_version": "0.0.0", - "outputs": map[string]interface{}{"foo": map[string]interface{}{"type": string("string"), "value": string("bar")}}, - "resources": []interface{}{}, + "outputs": map[string]any{"foo": map[string]any{"type": string("string"), "value": string("bar")}}, + "resources": []any{}, }, }, }, @@ -480,13 +480,13 @@ func TestWriteStateForMigration(t *testing.T) { }, expectedRequest: mockClientRequest{ Method: "Put", - Content: map[string]interface{}{ + Content: map[string]any{ "version": 4.0, "lineage": "mock-lineage", "serial": 2.0, "terraform_version": version.Version, - "outputs": map[string]interface{}{"foo": map[string]interface{}{"type": string("string"), "value": string("bar")}}, - "resources": []interface{}{}, + "outputs": map[string]any{"foo": map[string]any{"type": string("string"), "value": string("bar")}}, + "resources": []any{}, "check_results": nil, }, }, @@ -499,13 +499,13 @@ func TestWriteStateForMigration(t *testing.T) { }, expectedRequest: mockClientRequest{ Method: "Put", - Content: map[string]interface{}{ + Content: map[string]any{ "version": 4.0, "lineage": "different-lineage", "serial": 3.0, "terraform_version": version.Version, - "outputs": map[string]interface{}{"foo": map[string]interface{}{"type": string("string"), "value": string("bar")}}, - "resources": []interface{}{}, + "outputs": map[string]any{"foo": map[string]any{"type": string("string"), "value": string("bar")}}, + "resources": []any{}, "check_results": nil, }, }, @@ -605,13 +605,13 @@ func TestWriteStateForMigrationWithForcePushClient(t *testing.T) { }, expectedRequest: mockClientRequest{ Method: "Get", - Content: map[string]interface{}{ + Content: map[string]any{ "version": 4.0, "lineage": "mock-lineage", "serial": 3.0, "terraform_version": "0.0.0", - "outputs": map[string]interface{}{"foo": map[string]interface{}{"type": string("string"), "value": string("bar")}}, - "resources": []interface{}{}, + "outputs": map[string]any{"foo": map[string]any{"type": string("string"), "value": string("bar")}}, + "resources": []any{}, }, }, }, @@ -636,13 +636,13 @@ func TestWriteStateForMigrationWithForcePushClient(t *testing.T) { }, expectedRequest: mockClientRequest{ Method: "Force Put", - Content: map[string]interface{}{ + Content: map[string]any{ "version": 4.0, "lineage": "mock-lineage", "serial": 2.0, "terraform_version": version.Version, - "outputs": map[string]interface{}{"foo": map[string]interface{}{"type": string("string"), "value": string("bar")}}, - "resources": []interface{}{}, + "outputs": map[string]any{"foo": map[string]any{"type": string("string"), "value": string("bar")}}, + "resources": []any{}, "check_results": nil, }, }, @@ -655,13 +655,13 @@ func TestWriteStateForMigrationWithForcePushClient(t *testing.T) { }, expectedRequest: mockClientRequest{ Method: "Force Put", - Content: map[string]interface{}{ + Content: map[string]any{ "version": 4.0, "lineage": "different-lineage", "serial": 3.0, "terraform_version": version.Version, - "outputs": map[string]interface{}{"foo": map[string]interface{}{"type": string("string"), "value": string("bar")}}, - "resources": []interface{}{}, + "outputs": map[string]any{"foo": map[string]any{"type": string("string"), "value": string("bar")}}, + "resources": []any{}, "check_results": nil, }, }, diff --git a/staging/terraform/states/state_string.go b/staging/terraform/states/state_string.go index 0f74d59..cfc2b55 100644 --- a/staging/terraform/states/state_string.go +++ b/staging/terraform/states/state_string.go @@ -219,9 +219,9 @@ func (ms *Module) testString() string { switch vTyped := lv.(type) { case string: buf.WriteString(fmt.Sprintf("%s = %s\n", k, vTyped)) - case []interface{}: + case []any: buf.WriteString(fmt.Sprintf("%s = %s\n", k, vTyped)) - case map[string]interface{}: + case map[string]any: var mapKeys []string for key := range vTyped { mapKeys = append(mapKeys, key) diff --git a/staging/terraform/states/statefile/version1_upgrade.go b/staging/terraform/states/statefile/version1_upgrade.go index 3004f5e..e45dd72 100644 --- a/staging/terraform/states/statefile/version1_upgrade.go +++ b/staging/terraform/states/statefile/version1_upgrade.go @@ -162,7 +162,7 @@ func (old *instanceStateV1) upgradeToV2() (*instanceStateV2, error) { return nil, fmt.Errorf("Error upgrading InstanceState V1: %v", err) } - newMeta := make(map[string]interface{}) + newMeta := make(map[string]any) for k, v := range meta.(map[string]string) { newMeta[k] = v } diff --git a/staging/terraform/states/statefile/version2.go b/staging/terraform/states/statefile/version2.go index b5765a6..1a19016 100644 --- a/staging/terraform/states/statefile/version2.go +++ b/staging/terraform/states/statefile/version2.go @@ -96,7 +96,7 @@ type outputStateV2 struct { Type string `json:"type"` // Value contains the value of the output, in the structure described // by the Type field. - Value interface{} `json:"value"` + Value any `json:"value"` } type moduleStateV2 struct { @@ -106,7 +106,7 @@ type moduleStateV2 struct { // Locals are kept only transiently in-memory, because we can always // re-compute them. - Locals map[string]interface{} `json:"-"` + Locals map[string]any `json:"-"` // Outputs declared by the module and maintained for each module // even though only the root module technically needs to be kept. @@ -194,7 +194,7 @@ type instanceStateV2 struct { // ignored by Terraform core. It's meant to be used for accounting by // external client code. The value here must only contain Go primitives // and collections. - Meta map[string]interface{} `json:"meta"` + Meta map[string]any `json:"meta"` // Tainted is used to mark a resource for recreation. Tainted bool `json:"tainted"` diff --git a/staging/terraform/states/statefile/version3_upgrade.go b/staging/terraform/states/statefile/version3_upgrade.go index 715db59..55878d4 100644 --- a/staging/terraform/states/statefile/version3_upgrade.go +++ b/staging/terraform/states/statefile/version3_upgrade.go @@ -279,7 +279,7 @@ func upgradeInstanceObjectV3ToV4(rsOld *resourceStateV2, isOld *instanceStateV2, } } - private := map[string]interface{}{} + private := map[string]any{} for k, v := range isOld.Meta { if k == "schema_version" && migratedSchemaVersion { // We're gonna promote this into our first-class schema version field @@ -303,7 +303,7 @@ func upgradeInstanceObjectV3ToV4(rsOld *resourceStateV2, isOld *instanceStateV2, status = "tainted" } - var instKeyRaw interface{} + var instKeyRaw any switch tk := instKey.(type) { case addrs.IntKey: instKeyRaw = int(tk) diff --git a/staging/terraform/states/statefile/version4.go b/staging/terraform/states/statefile/version4.go index 57d3ac2..b0370c7 100644 --- a/staging/terraform/states/statefile/version4.go +++ b/staging/terraform/states/statefile/version4.go @@ -473,7 +473,7 @@ func appendInstanceObjectStateV4(rs *states.Resource, is *states.ResourceInstanc deps[i] = depAddr.String() } - var rawKey interface{} + var rawKey any switch tk := key.(type) { case addrs.IntKey: rawKey = int(tk) @@ -705,9 +705,9 @@ type resourceStateV4 struct { } type instanceObjectStateV4 struct { - IndexKey interface{} `json:"index_key,omitempty"` - Status string `json:"status,omitempty"` - Deposed string `json:"deposed,omitempty"` + IndexKey any `json:"index_key,omitempty"` + Status string `json:"status,omitempty"` + Deposed string `json:"deposed,omitempty"` SchemaVersion uint64 `json:"schema_version"` AttributesRaw json.RawMessage `json:"attributes,omitempty"` diff --git a/staging/terraform/terminal/streams.go b/staging/terraform/terminal/streams.go index af2bdc9..3e5066a 100644 --- a/staging/terraform/terminal/streams.go +++ b/staging/terraform/terminal/streams.go @@ -78,31 +78,31 @@ func Init() (*Streams, error) { } // Print is a helper for conveniently calling fmt.Fprint on the Stdout stream. -func (s *Streams) Print(a ...interface{}) (n int, err error) { +func (s *Streams) Print(a ...any) (n int, err error) { return fmt.Fprint(s.Stdout.File, a...) } // Printf is a helper for conveniently calling fmt.Fprintf on the Stdout stream. -func (s *Streams) Printf(format string, a ...interface{}) (n int, err error) { +func (s *Streams) Printf(format string, a ...any) (n int, err error) { return fmt.Fprintf(s.Stdout.File, format, a...) } // Println is a helper for conveniently calling fmt.Fprintln on the Stdout stream. -func (s *Streams) Println(a ...interface{}) (n int, err error) { +func (s *Streams) Println(a ...any) (n int, err error) { return fmt.Fprintln(s.Stdout.File, a...) } // Eprint is a helper for conveniently calling fmt.Fprint on the Stderr stream. -func (s *Streams) Eprint(a ...interface{}) (n int, err error) { +func (s *Streams) Eprint(a ...any) (n int, err error) { return fmt.Fprint(s.Stderr.File, a...) } // Eprintf is a helper for conveniently calling fmt.Fprintf on the Stderr stream. -func (s *Streams) Eprintf(format string, a ...interface{}) (n int, err error) { +func (s *Streams) Eprintf(format string, a ...any) (n int, err error) { return fmt.Fprintf(s.Stderr.File, format, a...) } // Eprintln is a helper for conveniently calling fmt.Fprintln on the Stderr stream. -func (s *Streams) Eprintln(a ...interface{}) (n int, err error) { +func (s *Streams) Eprintln(a ...any) (n int, err error) { return fmt.Fprintln(s.Stderr.File, a...) } diff --git a/staging/terraform/terraform/context_apply_test.go b/staging/terraform/terraform/context_apply_test.go index 24bbd83..cea32d1 100644 --- a/staging/terraform/terraform/context_apply_test.go +++ b/staging/terraform/terraform/context_apply_test.go @@ -3837,15 +3837,15 @@ func TestContext2Apply_multiVarComprehensive(t *testing.T) { t.Fatalf("error during apply: %s", diags.Err()) } - want := map[string]interface{}{ - "source_ids": []interface{}{"foo", "foo", "foo"}, - "source_names": []interface{}{ + want := map[string]any{ + "source_ids": []any{"foo", "foo", "foo"}, + "source_names": []any{ "source.0", "source.1", "source.2", }, } - got := map[string]interface{}{} + got := map[string]any{} for k, s := range state.RootModule().OutputValues { got[k] = hcl2shim.ConfigValueFromHCL2(s.Value) } @@ -5519,7 +5519,7 @@ func TestContext2Apply_Provisioner_Diff(t *testing.T) { // Change the state to force a diff mod := state.RootModule() obj := mod.Resources["aws_instance.bar"].Instances[addrs.NoKey].Current - var attrs map[string]interface{} + var attrs map[string]any err := json.Unmarshal(obj.AttrsJSON, &attrs) if err != nil { t.Fatal(err) @@ -6707,7 +6707,7 @@ func TestContext2Apply_idAttr(t *testing.T) { if !ok { t.Fatal("not in state") } - var attrs map[string]interface{} + var attrs map[string]any err := json.Unmarshal(rs.Instances[addrs.NoKey].Current.AttrsJSON, &attrs) if err != nil { t.Fatal(err) @@ -8580,7 +8580,7 @@ resource "null_instance" "depends" { if is == nil { t.Fatal("data resource instance is not present in state; should be") } - var attrs map[string]interface{} + var attrs map[string]any err := json.Unmarshal(is.Current.AttrsJSON, &attrs) if err != nil { t.Fatal(err) diff --git a/staging/terraform/terraform/context_input_test.go b/staging/terraform/terraform/context_input_test.go index a157932..ba1afab 100644 --- a/staging/terraform/terraform/context_input_test.go +++ b/staging/terraform/terraform/context_input_test.go @@ -56,7 +56,7 @@ func TestContext2Input_provider(t *testing.T) { UIInput: inp, }) - var actual interface{} + var actual any p.ConfigureProviderFn = func(req providers.ConfigureProviderRequest) (resp providers.ConfigureProviderResponse) { actual = req.Config.GetAttr("foo").AsString() return @@ -137,7 +137,7 @@ func TestContext2Input_providerMulti(t *testing.T) { UIInput: inp, }) - var actual []interface{} + var actual []any var lock sync.Mutex if diags := ctx.Input(m, InputModeStd); diags.HasErrors() { @@ -163,7 +163,7 @@ func TestContext2Input_providerMulti(t *testing.T) { t.Fatalf("apply errors: %s", diags.Err()) } - expected := []interface{}{"bar", "bar"} + expected := []any{"bar", "bar"} if !reflect.DeepEqual(actual, expected) { t.Fatalf("wrong result\ngot: %#v\nwant: %#v", actual, expected) } @@ -218,7 +218,7 @@ func TestContext2Input_providerId(t *testing.T) { UIInput: input, }) - var actual interface{} + var actual any p.ConfigureProviderFn = func(req providers.ConfigureProviderRequest) (resp providers.ConfigureProviderResponse) { actual = req.Config.GetAttr("foo").AsString() return @@ -280,7 +280,7 @@ func TestContext2Input_providerOnly(t *testing.T) { "provider.aws.foo": "bar", } - var actual interface{} + var actual any p.ConfigureProviderFn = func(req providers.ConfigureProviderRequest) (resp providers.ConfigureProviderResponse) { actual = req.Config.GetAttr("foo").AsString() return @@ -340,7 +340,7 @@ func TestContext2Input_providerVars(t *testing.T) { "var.foo": "bar", } - var actual interface{} + var actual any p.ConfigureProviderFn = func(req providers.ConfigureProviderRequest) (resp providers.ConfigureProviderResponse) { actual = req.Config.GetAttr("foo").AsString() return diff --git a/staging/terraform/terraform/context_plan_test.go b/staging/terraform/terraform/context_plan_test.go index d08d434..abbabed 100644 --- a/staging/terraform/terraform/context_plan_test.go +++ b/staging/terraform/terraform/context_plan_test.go @@ -4431,7 +4431,7 @@ func TestContext2Plan_provider(t *testing.T) { m := testModule(t, "plan-provider") p := testProvider("aws") - var value interface{} + var value any p.ConfigureProviderFn = func(req providers.ConfigureProviderRequest) (resp providers.ConfigureProviderResponse) { value = req.Config.GetAttr("foo").AsString() return diff --git a/staging/terraform/terraform/graph_dot_test.go b/staging/terraform/terraform/graph_dot_test.go index 125f9c8..1d7098a 100644 --- a/staging/terraform/terraform/graph_dot_test.go +++ b/staging/terraform/terraform/graph_dot_test.go @@ -36,7 +36,7 @@ digraph { root := &testDrawableOrigin{"root"} g.Add(root) - levelOne := []interface{}{"foo", "bar"} + levelOne := []any{"foo", "bar"} for i, s := range levelOne { levelOne[i] = &testDrawable{ VertexName: s.(string), diff --git a/staging/terraform/terraform/node_local_test.go b/staging/terraform/terraform/node_local_test.go index dd92246..8bb3f3e 100644 --- a/staging/terraform/terraform/node_local_test.go +++ b/staging/terraform/terraform/node_local_test.go @@ -21,7 +21,7 @@ import ( func TestNodeLocalExecute(t *testing.T) { tests := []struct { Value string - Want interface{} + Want any Err bool }{ { diff --git a/staging/terraform/terraform/provider_mock.go b/staging/terraform/terraform/provider_mock.go index 98832ce..29aa341 100644 --- a/staging/terraform/terraform/provider_mock.go +++ b/staging/terraform/terraform/provider_mock.go @@ -24,7 +24,7 @@ type MockProvider struct { sync.Mutex // Anything you want, in case you need to store extra data with the mock. - Meta interface{} + Meta any GetProviderSchemaCalled bool GetProviderSchemaResponse *providers.GetProviderSchemaResponse diff --git a/staging/terraform/terraform/provisioner_mock.go b/staging/terraform/terraform/provisioner_mock.go index eebaebc..31461c4 100644 --- a/staging/terraform/terraform/provisioner_mock.go +++ b/staging/terraform/terraform/provisioner_mock.go @@ -16,7 +16,7 @@ var _ provisioners.Interface = (*MockProvisioner)(nil) type MockProvisioner struct { sync.Mutex // Anything you want, in case you need to store extra data with the mock. - Meta interface{} + Meta any GetSchemaCalled bool GetSchemaResponse provisioners.GetSchemaResponse diff --git a/staging/terraform/terraform/upgrade_resource_state.go b/staging/terraform/terraform/upgrade_resource_state.go index aa9f03e..4362f6a 100644 --- a/staging/terraform/terraform/upgrade_resource_state.go +++ b/staging/terraform/terraform/upgrade_resource_state.go @@ -128,7 +128,7 @@ func upgradeResourceState(addr addrs.AbsResourceInstance, provider providers.Int // stripRemovedStateAttributes deletes any attributes no longer present in the // schema, so that the json can be correctly decoded. func stripRemovedStateAttributes(state []byte, ty cty.Type) []byte { - jsonMap := map[string]interface{}{} + jsonMap := map[string]any{} err := json.Unmarshal(state, &jsonMap) if err != nil { // we just log any errors here, and let the normal decode process catch @@ -155,12 +155,12 @@ func stripRemovedStateAttributes(state []byte, ty cty.Type) []byte { // strip out the actual missing attributes, and return a bool indicating if any // changes were made. -func removeRemovedAttrs(v interface{}, ty cty.Type) bool { +func removeRemovedAttrs(v any, ty cty.Type) bool { modified := false // we're only concerned with finding maps that correspond to object // attributes switch v := v.(type) { - case []interface{}: + case []any: switch { // If these aren't blocks the next call will be a noop case ty.IsListType() || ty.IsSetType(): @@ -170,7 +170,7 @@ func removeRemovedAttrs(v interface{}, ty cty.Type) bool { } } return modified - case map[string]interface{}: + case map[string]any: switch { case ty.IsMapType(): // map blocks aren't yet supported, but handle this just in case diff --git a/staging/terraform/terraform/upgrade_resource_state_test.go b/staging/terraform/terraform/upgrade_resource_state_test.go index 0e277cb..94bed6d 100644 --- a/staging/terraform/terraform/upgrade_resource_state_test.go +++ b/staging/terraform/terraform/upgrade_resource_state_test.go @@ -13,18 +13,18 @@ import ( func TestStripRemovedStateAttributes(t *testing.T) { cases := []struct { name string - state map[string]interface{} - expect map[string]interface{} + state map[string]any + expect map[string]any ty cty.Type modified bool }{ { "removed string", - map[string]interface{}{ + map[string]any{ "a": "ok", "b": "gone", }, - map[string]interface{}{ + map[string]any{ "a": "ok", }, cty.Object(map[string]cty.Type{ @@ -34,11 +34,11 @@ func TestStripRemovedStateAttributes(t *testing.T) { }, { "removed null", - map[string]interface{}{ + map[string]any{ "a": "ok", "b": nil, }, - map[string]interface{}{ + map[string]any{ "a": "ok", }, cty.Object(map[string]cty.Type{ @@ -48,16 +48,16 @@ func TestStripRemovedStateAttributes(t *testing.T) { }, { "removed nested string", - map[string]interface{}{ + map[string]any{ "a": "ok", - "b": map[string]interface{}{ + "b": map[string]any{ "a": "ok", "b": "removed", }, }, - map[string]interface{}{ + map[string]any{ "a": "ok", - "b": map[string]interface{}{ + "b": map[string]any{ "a": "ok", }, }, @@ -71,16 +71,16 @@ func TestStripRemovedStateAttributes(t *testing.T) { }, { "removed nested list", - map[string]interface{}{ + map[string]any{ "a": "ok", - "b": map[string]interface{}{ + "b": map[string]any{ "a": "ok", - "b": []interface{}{"removed"}, + "b": []any{"removed"}, }, }, - map[string]interface{}{ + map[string]any{ "a": "ok", - "b": map[string]interface{}{ + "b": map[string]any{ "a": "ok", }, }, @@ -94,31 +94,31 @@ func TestStripRemovedStateAttributes(t *testing.T) { }, { "removed keys in set of objs", - map[string]interface{}{ + map[string]any{ "a": "ok", - "b": map[string]interface{}{ + "b": map[string]any{ "a": "ok", - "set": []interface{}{ - map[string]interface{}{ + "set": []any{ + map[string]any{ "x": "ok", "y": "removed", }, - map[string]interface{}{ + map[string]any{ "x": "ok", "y": "removed", }, }, }, }, - map[string]interface{}{ + map[string]any{ "a": "ok", - "b": map[string]interface{}{ + "b": map[string]any{ "a": "ok", - "set": []interface{}{ - map[string]interface{}{ + "set": []any{ + map[string]any{ "x": "ok", }, - map[string]interface{}{ + map[string]any{ "x": "ok", }, }, diff --git a/staging/terraform/tfdiags/checks.go b/staging/terraform/tfdiags/checks.go index c2159ce..e466242 100644 --- a/staging/terraform/tfdiags/checks.go +++ b/staging/terraform/tfdiags/checks.go @@ -35,7 +35,7 @@ func AsCheckBlockDiagnostics(diags Diagnostics) Diagnostics { // AsCheckBlockDiagnostic will wrap a Diagnostic or a hcl.Diagnostic in a // CheckBlockDiagnostic. -func AsCheckBlockDiagnostic(diag interface{}) Diagnostic { +func AsCheckBlockDiagnostic(diag any) Diagnostic { switch d := diag.(type) { case Diagnostic: return CheckBlockDiagnostic{d} @@ -71,6 +71,6 @@ func (c CheckBlockDiagnostic) FromExpr() *FromExpr { return c.diag.FromExpr() } -func (c CheckBlockDiagnostic) ExtraInfo() interface{} { +func (c CheckBlockDiagnostic) ExtraInfo() any { return c.diag.ExtraInfo() } diff --git a/staging/terraform/tfdiags/consolidate_warnings.go b/staging/terraform/tfdiags/consolidate_warnings.go index 2c9d4d6..f6f12a0 100644 --- a/staging/terraform/tfdiags/consolidate_warnings.go +++ b/staging/terraform/tfdiags/consolidate_warnings.go @@ -129,7 +129,7 @@ func (wg *warningGroup) FromExpr() *FromExpr { return wg.Warnings[0].FromExpr() } -func (wg *warningGroup) ExtraInfo() interface{} { +func (wg *warningGroup) ExtraInfo() any { return wg.Warnings[0].ExtraInfo() } diff --git a/staging/terraform/tfdiags/diagnostic.go b/staging/terraform/tfdiags/diagnostic.go index 2da94df..3d2fa21 100644 --- a/staging/terraform/tfdiags/diagnostic.go +++ b/staging/terraform/tfdiags/diagnostic.go @@ -24,7 +24,7 @@ type Diagnostic interface { // access associated information, so in most cases it'll be more convienient // to use the package-level ExtraInfo function to try to unpack a particular // specialized interface from this value. - ExtraInfo() interface{} + ExtraInfo() any } type Severity rune diff --git a/staging/terraform/tfdiags/diagnostic_base.go b/staging/terraform/tfdiags/diagnostic_base.go index 8c1707e..a913b0b 100644 --- a/staging/terraform/tfdiags/diagnostic_base.go +++ b/staging/terraform/tfdiags/diagnostic_base.go @@ -35,6 +35,6 @@ func (d diagnosticBase) FromExpr() *FromExpr { return nil } -func (d diagnosticBase) ExtraInfo() interface{} { +func (d diagnosticBase) ExtraInfo() any { return nil } diff --git a/staging/terraform/tfdiags/diagnostic_extra.go b/staging/terraform/tfdiags/diagnostic_extra.go index 4ca37b0..c6ae41a 100644 --- a/staging/terraform/tfdiags/diagnostic_extra.go +++ b/staging/terraform/tfdiags/diagnostic_extra.go @@ -50,7 +50,7 @@ func ExtraInfo[T any](diag Diagnostic) T { // of T, ExtraInfoNext does not consider whether value "previous" directly // implements interface T, on the assumption that the previous call to ExtraInfo // with the same T caused "previous" to already be that result. -func ExtraInfoNext[T any](previous interface{}) T { +func ExtraInfoNext[T any](previous any) T { // As long as T is an interface type as documented, zero will always be // a nil interface value for us to return in the non-matching case. var zero T @@ -102,7 +102,7 @@ type DiagnosticExtraUnwrapper interface { // // Implementers should never create unwrap "cycles" where a nested extra // value returns a value that was also wrapping it. - UnwrapDiagnosticExtra() interface{} + UnwrapDiagnosticExtra() any } // DiagnosticExtraBecauseUnknown is an interface implemented by values in diff --git a/staging/terraform/tfdiags/diagnostics.go b/staging/terraform/tfdiags/diagnostics.go index a7fbc54..29e381a 100644 --- a/staging/terraform/tfdiags/diagnostics.go +++ b/staging/terraform/tfdiags/diagnostics.go @@ -47,7 +47,7 @@ type Diagnostics []Diagnostic // a multierror.Error into separate error diagnostics. It can be passed // another Diagnostics to concatenate the two lists. If given something // it cannot handle, this function will panic. -func (diags Diagnostics) Append(new ...interface{}) Diagnostics { +func (diags Diagnostics) Append(new ...any) Diagnostics { for _, item := range new { if item == nil { continue diff --git a/staging/terraform/tfdiags/error.go b/staging/terraform/tfdiags/error.go index f377ddb..ed2be88 100644 --- a/staging/terraform/tfdiags/error.go +++ b/staging/terraform/tfdiags/error.go @@ -30,7 +30,7 @@ func (e nativeError) FromExpr() *FromExpr { return nil } -func (e nativeError) ExtraInfo() interface{} { +func (e nativeError) ExtraInfo() any { // Native errors don't carry any "extra information". return nil } diff --git a/staging/terraform/tfdiags/hcl.go b/staging/terraform/tfdiags/hcl.go index 5822844..0ade8df 100644 --- a/staging/terraform/tfdiags/hcl.go +++ b/staging/terraform/tfdiags/hcl.go @@ -53,7 +53,7 @@ func (d hclDiagnostic) FromExpr() *FromExpr { } } -func (d hclDiagnostic) ExtraInfo() interface{} { +func (d hclDiagnostic) ExtraInfo() any { return d.diag.Extra } diff --git a/staging/terraform/tfdiags/rpc_friendly.go b/staging/terraform/tfdiags/rpc_friendly.go index 039781e..1573d0f 100644 --- a/staging/terraform/tfdiags/rpc_friendly.go +++ b/staging/terraform/tfdiags/rpc_friendly.go @@ -57,7 +57,7 @@ func (d rpcFriendlyDiag) FromExpr() *FromExpr { return nil } -func (d rpcFriendlyDiag) ExtraInfo() interface{} { +func (d rpcFriendlyDiag) ExtraInfo() any { // RPC-friendly diagnostics always discard any "extra information". return nil } diff --git a/staging/terraform/tfdiags/simple_warning.go b/staging/terraform/tfdiags/simple_warning.go index 7a6fe38..79e61e9 100644 --- a/staging/terraform/tfdiags/simple_warning.go +++ b/staging/terraform/tfdiags/simple_warning.go @@ -32,7 +32,7 @@ func (e simpleWarning) FromExpr() *FromExpr { return nil } -func (e simpleWarning) ExtraInfo() interface{} { +func (e simpleWarning) ExtraInfo() any { // Simple warnings cannot carry extra information. return nil } diff --git a/staging/terraform/tfplugin5/tfplugin5.pb.go b/staging/terraform/tfplugin5/tfplugin5.pb.go index 3dfc603..ea1603d 100644 --- a/staging/terraform/tfplugin5/tfplugin5.pb.go +++ b/staging/terraform/tfplugin5/tfplugin5.pb.go @@ -3839,7 +3839,7 @@ func file_tfplugin5_proto_rawDescGZIP() []byte { var file_tfplugin5_proto_enumTypes = make([]protoimpl.EnumInfo, 3) var file_tfplugin5_proto_msgTypes = make([]protoimpl.MessageInfo, 59) -var file_tfplugin5_proto_goTypes = []interface{}{ +var file_tfplugin5_proto_goTypes = []any{ (StringKind)(0), // 0: tfplugin5.StringKind (Diagnostic_Severity)(0), // 1: tfplugin5.Diagnostic.Severity (Schema_NestedBlock_NestingMode)(0), // 2: tfplugin5.Schema.NestedBlock.NestingMode @@ -4011,7 +4011,7 @@ func file_tfplugin5_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_tfplugin5_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin5_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*DynamicValue); i { case 0: return &v.state @@ -4023,7 +4023,7 @@ func file_tfplugin5_proto_init() { return nil } } - file_tfplugin5_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin5_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*Diagnostic); i { case 0: return &v.state @@ -4035,7 +4035,7 @@ func file_tfplugin5_proto_init() { return nil } } - file_tfplugin5_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin5_proto_msgTypes[2].Exporter = func(v any, i int) any { switch v := v.(*AttributePath); i { case 0: return &v.state @@ -4047,7 +4047,7 @@ func file_tfplugin5_proto_init() { return nil } } - file_tfplugin5_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin5_proto_msgTypes[3].Exporter = func(v any, i int) any { switch v := v.(*Stop); i { case 0: return &v.state @@ -4059,7 +4059,7 @@ func file_tfplugin5_proto_init() { return nil } } - file_tfplugin5_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin5_proto_msgTypes[4].Exporter = func(v any, i int) any { switch v := v.(*RawState); i { case 0: return &v.state @@ -4071,7 +4071,7 @@ func file_tfplugin5_proto_init() { return nil } } - file_tfplugin5_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin5_proto_msgTypes[5].Exporter = func(v any, i int) any { switch v := v.(*Schema); i { case 0: return &v.state @@ -4083,7 +4083,7 @@ func file_tfplugin5_proto_init() { return nil } } - file_tfplugin5_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin5_proto_msgTypes[6].Exporter = func(v any, i int) any { switch v := v.(*GetProviderSchema); i { case 0: return &v.state @@ -4095,7 +4095,7 @@ func file_tfplugin5_proto_init() { return nil } } - file_tfplugin5_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin5_proto_msgTypes[7].Exporter = func(v any, i int) any { switch v := v.(*PrepareProviderConfig); i { case 0: return &v.state @@ -4107,7 +4107,7 @@ func file_tfplugin5_proto_init() { return nil } } - file_tfplugin5_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin5_proto_msgTypes[8].Exporter = func(v any, i int) any { switch v := v.(*UpgradeResourceState); i { case 0: return &v.state @@ -4119,7 +4119,7 @@ func file_tfplugin5_proto_init() { return nil } } - file_tfplugin5_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin5_proto_msgTypes[9].Exporter = func(v any, i int) any { switch v := v.(*ValidateResourceTypeConfig); i { case 0: return &v.state @@ -4131,7 +4131,7 @@ func file_tfplugin5_proto_init() { return nil } } - file_tfplugin5_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin5_proto_msgTypes[10].Exporter = func(v any, i int) any { switch v := v.(*ValidateDataSourceConfig); i { case 0: return &v.state @@ -4143,7 +4143,7 @@ func file_tfplugin5_proto_init() { return nil } } - file_tfplugin5_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin5_proto_msgTypes[11].Exporter = func(v any, i int) any { switch v := v.(*Configure); i { case 0: return &v.state @@ -4155,7 +4155,7 @@ func file_tfplugin5_proto_init() { return nil } } - file_tfplugin5_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin5_proto_msgTypes[12].Exporter = func(v any, i int) any { switch v := v.(*ReadResource); i { case 0: return &v.state @@ -4167,7 +4167,7 @@ func file_tfplugin5_proto_init() { return nil } } - file_tfplugin5_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin5_proto_msgTypes[13].Exporter = func(v any, i int) any { switch v := v.(*PlanResourceChange); i { case 0: return &v.state @@ -4179,7 +4179,7 @@ func file_tfplugin5_proto_init() { return nil } } - file_tfplugin5_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin5_proto_msgTypes[14].Exporter = func(v any, i int) any { switch v := v.(*ApplyResourceChange); i { case 0: return &v.state @@ -4191,7 +4191,7 @@ func file_tfplugin5_proto_init() { return nil } } - file_tfplugin5_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin5_proto_msgTypes[15].Exporter = func(v any, i int) any { switch v := v.(*ImportResourceState); i { case 0: return &v.state @@ -4203,7 +4203,7 @@ func file_tfplugin5_proto_init() { return nil } } - file_tfplugin5_proto_msgTypes[16].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin5_proto_msgTypes[16].Exporter = func(v any, i int) any { switch v := v.(*ReadDataSource); i { case 0: return &v.state @@ -4215,7 +4215,7 @@ func file_tfplugin5_proto_init() { return nil } } - file_tfplugin5_proto_msgTypes[17].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin5_proto_msgTypes[17].Exporter = func(v any, i int) any { switch v := v.(*GetProvisionerSchema); i { case 0: return &v.state @@ -4227,7 +4227,7 @@ func file_tfplugin5_proto_init() { return nil } } - file_tfplugin5_proto_msgTypes[18].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin5_proto_msgTypes[18].Exporter = func(v any, i int) any { switch v := v.(*ValidateProvisionerConfig); i { case 0: return &v.state @@ -4239,7 +4239,7 @@ func file_tfplugin5_proto_init() { return nil } } - file_tfplugin5_proto_msgTypes[19].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin5_proto_msgTypes[19].Exporter = func(v any, i int) any { switch v := v.(*ProvisionResource); i { case 0: return &v.state @@ -4251,7 +4251,7 @@ func file_tfplugin5_proto_init() { return nil } } - file_tfplugin5_proto_msgTypes[20].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin5_proto_msgTypes[20].Exporter = func(v any, i int) any { switch v := v.(*AttributePath_Step); i { case 0: return &v.state @@ -4263,7 +4263,7 @@ func file_tfplugin5_proto_init() { return nil } } - file_tfplugin5_proto_msgTypes[21].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin5_proto_msgTypes[21].Exporter = func(v any, i int) any { switch v := v.(*Stop_Request); i { case 0: return &v.state @@ -4275,7 +4275,7 @@ func file_tfplugin5_proto_init() { return nil } } - file_tfplugin5_proto_msgTypes[22].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin5_proto_msgTypes[22].Exporter = func(v any, i int) any { switch v := v.(*Stop_Response); i { case 0: return &v.state @@ -4287,7 +4287,7 @@ func file_tfplugin5_proto_init() { return nil } } - file_tfplugin5_proto_msgTypes[24].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin5_proto_msgTypes[24].Exporter = func(v any, i int) any { switch v := v.(*Schema_Block); i { case 0: return &v.state @@ -4299,7 +4299,7 @@ func file_tfplugin5_proto_init() { return nil } } - file_tfplugin5_proto_msgTypes[25].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin5_proto_msgTypes[25].Exporter = func(v any, i int) any { switch v := v.(*Schema_Attribute); i { case 0: return &v.state @@ -4311,7 +4311,7 @@ func file_tfplugin5_proto_init() { return nil } } - file_tfplugin5_proto_msgTypes[26].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin5_proto_msgTypes[26].Exporter = func(v any, i int) any { switch v := v.(*Schema_NestedBlock); i { case 0: return &v.state @@ -4323,7 +4323,7 @@ func file_tfplugin5_proto_init() { return nil } } - file_tfplugin5_proto_msgTypes[27].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin5_proto_msgTypes[27].Exporter = func(v any, i int) any { switch v := v.(*GetProviderSchema_Request); i { case 0: return &v.state @@ -4335,7 +4335,7 @@ func file_tfplugin5_proto_init() { return nil } } - file_tfplugin5_proto_msgTypes[28].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin5_proto_msgTypes[28].Exporter = func(v any, i int) any { switch v := v.(*GetProviderSchema_Response); i { case 0: return &v.state @@ -4347,7 +4347,7 @@ func file_tfplugin5_proto_init() { return nil } } - file_tfplugin5_proto_msgTypes[29].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin5_proto_msgTypes[29].Exporter = func(v any, i int) any { switch v := v.(*GetProviderSchema_ServerCapabilities); i { case 0: return &v.state @@ -4359,7 +4359,7 @@ func file_tfplugin5_proto_init() { return nil } } - file_tfplugin5_proto_msgTypes[32].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin5_proto_msgTypes[32].Exporter = func(v any, i int) any { switch v := v.(*PrepareProviderConfig_Request); i { case 0: return &v.state @@ -4371,7 +4371,7 @@ func file_tfplugin5_proto_init() { return nil } } - file_tfplugin5_proto_msgTypes[33].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin5_proto_msgTypes[33].Exporter = func(v any, i int) any { switch v := v.(*PrepareProviderConfig_Response); i { case 0: return &v.state @@ -4383,7 +4383,7 @@ func file_tfplugin5_proto_init() { return nil } } - file_tfplugin5_proto_msgTypes[34].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin5_proto_msgTypes[34].Exporter = func(v any, i int) any { switch v := v.(*UpgradeResourceState_Request); i { case 0: return &v.state @@ -4395,7 +4395,7 @@ func file_tfplugin5_proto_init() { return nil } } - file_tfplugin5_proto_msgTypes[35].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin5_proto_msgTypes[35].Exporter = func(v any, i int) any { switch v := v.(*UpgradeResourceState_Response); i { case 0: return &v.state @@ -4407,7 +4407,7 @@ func file_tfplugin5_proto_init() { return nil } } - file_tfplugin5_proto_msgTypes[36].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin5_proto_msgTypes[36].Exporter = func(v any, i int) any { switch v := v.(*ValidateResourceTypeConfig_Request); i { case 0: return &v.state @@ -4419,7 +4419,7 @@ func file_tfplugin5_proto_init() { return nil } } - file_tfplugin5_proto_msgTypes[37].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin5_proto_msgTypes[37].Exporter = func(v any, i int) any { switch v := v.(*ValidateResourceTypeConfig_Response); i { case 0: return &v.state @@ -4431,7 +4431,7 @@ func file_tfplugin5_proto_init() { return nil } } - file_tfplugin5_proto_msgTypes[38].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin5_proto_msgTypes[38].Exporter = func(v any, i int) any { switch v := v.(*ValidateDataSourceConfig_Request); i { case 0: return &v.state @@ -4443,7 +4443,7 @@ func file_tfplugin5_proto_init() { return nil } } - file_tfplugin5_proto_msgTypes[39].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin5_proto_msgTypes[39].Exporter = func(v any, i int) any { switch v := v.(*ValidateDataSourceConfig_Response); i { case 0: return &v.state @@ -4455,7 +4455,7 @@ func file_tfplugin5_proto_init() { return nil } } - file_tfplugin5_proto_msgTypes[40].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin5_proto_msgTypes[40].Exporter = func(v any, i int) any { switch v := v.(*Configure_Request); i { case 0: return &v.state @@ -4467,7 +4467,7 @@ func file_tfplugin5_proto_init() { return nil } } - file_tfplugin5_proto_msgTypes[41].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin5_proto_msgTypes[41].Exporter = func(v any, i int) any { switch v := v.(*Configure_Response); i { case 0: return &v.state @@ -4479,7 +4479,7 @@ func file_tfplugin5_proto_init() { return nil } } - file_tfplugin5_proto_msgTypes[42].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin5_proto_msgTypes[42].Exporter = func(v any, i int) any { switch v := v.(*ReadResource_Request); i { case 0: return &v.state @@ -4491,7 +4491,7 @@ func file_tfplugin5_proto_init() { return nil } } - file_tfplugin5_proto_msgTypes[43].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin5_proto_msgTypes[43].Exporter = func(v any, i int) any { switch v := v.(*ReadResource_Response); i { case 0: return &v.state @@ -4503,7 +4503,7 @@ func file_tfplugin5_proto_init() { return nil } } - file_tfplugin5_proto_msgTypes[44].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin5_proto_msgTypes[44].Exporter = func(v any, i int) any { switch v := v.(*PlanResourceChange_Request); i { case 0: return &v.state @@ -4515,7 +4515,7 @@ func file_tfplugin5_proto_init() { return nil } } - file_tfplugin5_proto_msgTypes[45].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin5_proto_msgTypes[45].Exporter = func(v any, i int) any { switch v := v.(*PlanResourceChange_Response); i { case 0: return &v.state @@ -4527,7 +4527,7 @@ func file_tfplugin5_proto_init() { return nil } } - file_tfplugin5_proto_msgTypes[46].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin5_proto_msgTypes[46].Exporter = func(v any, i int) any { switch v := v.(*ApplyResourceChange_Request); i { case 0: return &v.state @@ -4539,7 +4539,7 @@ func file_tfplugin5_proto_init() { return nil } } - file_tfplugin5_proto_msgTypes[47].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin5_proto_msgTypes[47].Exporter = func(v any, i int) any { switch v := v.(*ApplyResourceChange_Response); i { case 0: return &v.state @@ -4551,7 +4551,7 @@ func file_tfplugin5_proto_init() { return nil } } - file_tfplugin5_proto_msgTypes[48].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin5_proto_msgTypes[48].Exporter = func(v any, i int) any { switch v := v.(*ImportResourceState_Request); i { case 0: return &v.state @@ -4563,7 +4563,7 @@ func file_tfplugin5_proto_init() { return nil } } - file_tfplugin5_proto_msgTypes[49].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin5_proto_msgTypes[49].Exporter = func(v any, i int) any { switch v := v.(*ImportResourceState_ImportedResource); i { case 0: return &v.state @@ -4575,7 +4575,7 @@ func file_tfplugin5_proto_init() { return nil } } - file_tfplugin5_proto_msgTypes[50].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin5_proto_msgTypes[50].Exporter = func(v any, i int) any { switch v := v.(*ImportResourceState_Response); i { case 0: return &v.state @@ -4587,7 +4587,7 @@ func file_tfplugin5_proto_init() { return nil } } - file_tfplugin5_proto_msgTypes[51].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin5_proto_msgTypes[51].Exporter = func(v any, i int) any { switch v := v.(*ReadDataSource_Request); i { case 0: return &v.state @@ -4599,7 +4599,7 @@ func file_tfplugin5_proto_init() { return nil } } - file_tfplugin5_proto_msgTypes[52].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin5_proto_msgTypes[52].Exporter = func(v any, i int) any { switch v := v.(*ReadDataSource_Response); i { case 0: return &v.state @@ -4611,7 +4611,7 @@ func file_tfplugin5_proto_init() { return nil } } - file_tfplugin5_proto_msgTypes[53].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin5_proto_msgTypes[53].Exporter = func(v any, i int) any { switch v := v.(*GetProvisionerSchema_Request); i { case 0: return &v.state @@ -4623,7 +4623,7 @@ func file_tfplugin5_proto_init() { return nil } } - file_tfplugin5_proto_msgTypes[54].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin5_proto_msgTypes[54].Exporter = func(v any, i int) any { switch v := v.(*GetProvisionerSchema_Response); i { case 0: return &v.state @@ -4635,7 +4635,7 @@ func file_tfplugin5_proto_init() { return nil } } - file_tfplugin5_proto_msgTypes[55].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin5_proto_msgTypes[55].Exporter = func(v any, i int) any { switch v := v.(*ValidateProvisionerConfig_Request); i { case 0: return &v.state @@ -4647,7 +4647,7 @@ func file_tfplugin5_proto_init() { return nil } } - file_tfplugin5_proto_msgTypes[56].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin5_proto_msgTypes[56].Exporter = func(v any, i int) any { switch v := v.(*ValidateProvisionerConfig_Response); i { case 0: return &v.state @@ -4659,7 +4659,7 @@ func file_tfplugin5_proto_init() { return nil } } - file_tfplugin5_proto_msgTypes[57].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin5_proto_msgTypes[57].Exporter = func(v any, i int) any { switch v := v.(*ProvisionResource_Request); i { case 0: return &v.state @@ -4671,7 +4671,7 @@ func file_tfplugin5_proto_init() { return nil } } - file_tfplugin5_proto_msgTypes[58].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin5_proto_msgTypes[58].Exporter = func(v any, i int) any { switch v := v.(*ProvisionResource_Response); i { case 0: return &v.state @@ -4684,7 +4684,7 @@ func file_tfplugin5_proto_init() { } } } - file_tfplugin5_proto_msgTypes[20].OneofWrappers = []interface{}{ + file_tfplugin5_proto_msgTypes[20].OneofWrappers = []any{ (*AttributePath_Step_AttributeName)(nil), (*AttributePath_Step_ElementKeyString)(nil), (*AttributePath_Step_ElementKeyInt)(nil), @@ -4921,7 +4921,7 @@ func RegisterProviderServer(s *grpc.Server, srv ProviderServer) { s.RegisterService(&_Provider_serviceDesc, srv) } -func _Provider_GetSchema_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Provider_GetSchema_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(GetProviderSchema_Request) if err := dec(in); err != nil { return nil, err @@ -4933,13 +4933,13 @@ func _Provider_GetSchema_Handler(srv interface{}, ctx context.Context, dec func( Server: srv, FullMethod: "/tfplugin5.Provider/GetSchema", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(ProviderServer).GetSchema(ctx, req.(*GetProviderSchema_Request)) } return interceptor(ctx, in, info, handler) } -func _Provider_PrepareProviderConfig_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Provider_PrepareProviderConfig_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(PrepareProviderConfig_Request) if err := dec(in); err != nil { return nil, err @@ -4951,13 +4951,13 @@ func _Provider_PrepareProviderConfig_Handler(srv interface{}, ctx context.Contex Server: srv, FullMethod: "/tfplugin5.Provider/PrepareProviderConfig", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(ProviderServer).PrepareProviderConfig(ctx, req.(*PrepareProviderConfig_Request)) } return interceptor(ctx, in, info, handler) } -func _Provider_ValidateResourceTypeConfig_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Provider_ValidateResourceTypeConfig_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(ValidateResourceTypeConfig_Request) if err := dec(in); err != nil { return nil, err @@ -4969,13 +4969,13 @@ func _Provider_ValidateResourceTypeConfig_Handler(srv interface{}, ctx context.C Server: srv, FullMethod: "/tfplugin5.Provider/ValidateResourceTypeConfig", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(ProviderServer).ValidateResourceTypeConfig(ctx, req.(*ValidateResourceTypeConfig_Request)) } return interceptor(ctx, in, info, handler) } -func _Provider_ValidateDataSourceConfig_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Provider_ValidateDataSourceConfig_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(ValidateDataSourceConfig_Request) if err := dec(in); err != nil { return nil, err @@ -4987,13 +4987,13 @@ func _Provider_ValidateDataSourceConfig_Handler(srv interface{}, ctx context.Con Server: srv, FullMethod: "/tfplugin5.Provider/ValidateDataSourceConfig", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(ProviderServer).ValidateDataSourceConfig(ctx, req.(*ValidateDataSourceConfig_Request)) } return interceptor(ctx, in, info, handler) } -func _Provider_UpgradeResourceState_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Provider_UpgradeResourceState_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(UpgradeResourceState_Request) if err := dec(in); err != nil { return nil, err @@ -5005,13 +5005,13 @@ func _Provider_UpgradeResourceState_Handler(srv interface{}, ctx context.Context Server: srv, FullMethod: "/tfplugin5.Provider/UpgradeResourceState", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(ProviderServer).UpgradeResourceState(ctx, req.(*UpgradeResourceState_Request)) } return interceptor(ctx, in, info, handler) } -func _Provider_Configure_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Provider_Configure_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(Configure_Request) if err := dec(in); err != nil { return nil, err @@ -5023,13 +5023,13 @@ func _Provider_Configure_Handler(srv interface{}, ctx context.Context, dec func( Server: srv, FullMethod: "/tfplugin5.Provider/Configure", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(ProviderServer).Configure(ctx, req.(*Configure_Request)) } return interceptor(ctx, in, info, handler) } -func _Provider_ReadResource_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Provider_ReadResource_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(ReadResource_Request) if err := dec(in); err != nil { return nil, err @@ -5041,13 +5041,13 @@ func _Provider_ReadResource_Handler(srv interface{}, ctx context.Context, dec fu Server: srv, FullMethod: "/tfplugin5.Provider/ReadResource", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(ProviderServer).ReadResource(ctx, req.(*ReadResource_Request)) } return interceptor(ctx, in, info, handler) } -func _Provider_PlanResourceChange_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Provider_PlanResourceChange_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(PlanResourceChange_Request) if err := dec(in); err != nil { return nil, err @@ -5059,13 +5059,13 @@ func _Provider_PlanResourceChange_Handler(srv interface{}, ctx context.Context, Server: srv, FullMethod: "/tfplugin5.Provider/PlanResourceChange", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(ProviderServer).PlanResourceChange(ctx, req.(*PlanResourceChange_Request)) } return interceptor(ctx, in, info, handler) } -func _Provider_ApplyResourceChange_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Provider_ApplyResourceChange_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(ApplyResourceChange_Request) if err := dec(in); err != nil { return nil, err @@ -5077,13 +5077,13 @@ func _Provider_ApplyResourceChange_Handler(srv interface{}, ctx context.Context, Server: srv, FullMethod: "/tfplugin5.Provider/ApplyResourceChange", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(ProviderServer).ApplyResourceChange(ctx, req.(*ApplyResourceChange_Request)) } return interceptor(ctx, in, info, handler) } -func _Provider_ImportResourceState_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Provider_ImportResourceState_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(ImportResourceState_Request) if err := dec(in); err != nil { return nil, err @@ -5095,13 +5095,13 @@ func _Provider_ImportResourceState_Handler(srv interface{}, ctx context.Context, Server: srv, FullMethod: "/tfplugin5.Provider/ImportResourceState", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(ProviderServer).ImportResourceState(ctx, req.(*ImportResourceState_Request)) } return interceptor(ctx, in, info, handler) } -func _Provider_ReadDataSource_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Provider_ReadDataSource_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(ReadDataSource_Request) if err := dec(in); err != nil { return nil, err @@ -5113,13 +5113,13 @@ func _Provider_ReadDataSource_Handler(srv interface{}, ctx context.Context, dec Server: srv, FullMethod: "/tfplugin5.Provider/ReadDataSource", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(ProviderServer).ReadDataSource(ctx, req.(*ReadDataSource_Request)) } return interceptor(ctx, in, info, handler) } -func _Provider_Stop_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Provider_Stop_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(Stop_Request) if err := dec(in); err != nil { return nil, err @@ -5131,7 +5131,7 @@ func _Provider_Stop_Handler(srv interface{}, ctx context.Context, dec func(inter Server: srv, FullMethod: "/tfplugin5.Provider/Stop", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(ProviderServer).Stop(ctx, req.(*Stop_Request)) } return interceptor(ctx, in, info, handler) @@ -5300,7 +5300,7 @@ func RegisterProvisionerServer(s *grpc.Server, srv ProvisionerServer) { s.RegisterService(&_Provisioner_serviceDesc, srv) } -func _Provisioner_GetSchema_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Provisioner_GetSchema_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(GetProvisionerSchema_Request) if err := dec(in); err != nil { return nil, err @@ -5312,13 +5312,13 @@ func _Provisioner_GetSchema_Handler(srv interface{}, ctx context.Context, dec fu Server: srv, FullMethod: "/tfplugin5.Provisioner/GetSchema", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(ProvisionerServer).GetSchema(ctx, req.(*GetProvisionerSchema_Request)) } return interceptor(ctx, in, info, handler) } -func _Provisioner_ValidateProvisionerConfig_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Provisioner_ValidateProvisionerConfig_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(ValidateProvisionerConfig_Request) if err := dec(in); err != nil { return nil, err @@ -5330,13 +5330,13 @@ func _Provisioner_ValidateProvisionerConfig_Handler(srv interface{}, ctx context Server: srv, FullMethod: "/tfplugin5.Provisioner/ValidateProvisionerConfig", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(ProvisionerServer).ValidateProvisionerConfig(ctx, req.(*ValidateProvisionerConfig_Request)) } return interceptor(ctx, in, info, handler) } -func _Provisioner_ProvisionResource_Handler(srv interface{}, stream grpc.ServerStream) error { +func _Provisioner_ProvisionResource_Handler(srv any, stream grpc.ServerStream) error { m := new(ProvisionResource_Request) if err := stream.RecvMsg(m); err != nil { return err @@ -5357,7 +5357,7 @@ func (x *provisionerProvisionResourceServer) Send(m *ProvisionResource_Response) return x.ServerStream.SendMsg(m) } -func _Provisioner_Stop_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Provisioner_Stop_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(Stop_Request) if err := dec(in); err != nil { return nil, err @@ -5369,7 +5369,7 @@ func _Provisioner_Stop_Handler(srv interface{}, ctx context.Context, dec func(in Server: srv, FullMethod: "/tfplugin5.Provisioner/Stop", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(ProvisionerServer).Stop(ctx, req.(*Stop_Request)) } return interceptor(ctx, in, info, handler) diff --git a/staging/terraform/tfplugin6/tfplugin6.pb.go b/staging/terraform/tfplugin6/tfplugin6.pb.go index 96ffacc..a4323d9 100644 --- a/staging/terraform/tfplugin6/tfplugin6.pb.go +++ b/staging/terraform/tfplugin6/tfplugin6.pb.go @@ -3523,7 +3523,7 @@ func file_tfplugin6_proto_rawDescGZIP() []byte { var file_tfplugin6_proto_enumTypes = make([]protoimpl.EnumInfo, 4) var file_tfplugin6_proto_msgTypes = make([]protoimpl.MessageInfo, 51) -var file_tfplugin6_proto_goTypes = []interface{}{ +var file_tfplugin6_proto_goTypes = []any{ (StringKind)(0), // 0: tfplugin6.StringKind (Diagnostic_Severity)(0), // 1: tfplugin6.Diagnostic.Severity (Schema_NestedBlock_NestingMode)(0), // 2: tfplugin6.Schema.NestedBlock.NestingMode @@ -3675,7 +3675,7 @@ func file_tfplugin6_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_tfplugin6_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin6_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*DynamicValue); i { case 0: return &v.state @@ -3687,7 +3687,7 @@ func file_tfplugin6_proto_init() { return nil } } - file_tfplugin6_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin6_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*Diagnostic); i { case 0: return &v.state @@ -3699,7 +3699,7 @@ func file_tfplugin6_proto_init() { return nil } } - file_tfplugin6_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin6_proto_msgTypes[2].Exporter = func(v any, i int) any { switch v := v.(*AttributePath); i { case 0: return &v.state @@ -3711,7 +3711,7 @@ func file_tfplugin6_proto_init() { return nil } } - file_tfplugin6_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin6_proto_msgTypes[3].Exporter = func(v any, i int) any { switch v := v.(*StopProvider); i { case 0: return &v.state @@ -3723,7 +3723,7 @@ func file_tfplugin6_proto_init() { return nil } } - file_tfplugin6_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin6_proto_msgTypes[4].Exporter = func(v any, i int) any { switch v := v.(*RawState); i { case 0: return &v.state @@ -3735,7 +3735,7 @@ func file_tfplugin6_proto_init() { return nil } } - file_tfplugin6_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin6_proto_msgTypes[5].Exporter = func(v any, i int) any { switch v := v.(*Schema); i { case 0: return &v.state @@ -3747,7 +3747,7 @@ func file_tfplugin6_proto_init() { return nil } } - file_tfplugin6_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin6_proto_msgTypes[6].Exporter = func(v any, i int) any { switch v := v.(*GetProviderSchema); i { case 0: return &v.state @@ -3759,7 +3759,7 @@ func file_tfplugin6_proto_init() { return nil } } - file_tfplugin6_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin6_proto_msgTypes[7].Exporter = func(v any, i int) any { switch v := v.(*ValidateProviderConfig); i { case 0: return &v.state @@ -3771,7 +3771,7 @@ func file_tfplugin6_proto_init() { return nil } } - file_tfplugin6_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin6_proto_msgTypes[8].Exporter = func(v any, i int) any { switch v := v.(*UpgradeResourceState); i { case 0: return &v.state @@ -3783,7 +3783,7 @@ func file_tfplugin6_proto_init() { return nil } } - file_tfplugin6_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin6_proto_msgTypes[9].Exporter = func(v any, i int) any { switch v := v.(*ValidateResourceConfig); i { case 0: return &v.state @@ -3795,7 +3795,7 @@ func file_tfplugin6_proto_init() { return nil } } - file_tfplugin6_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin6_proto_msgTypes[10].Exporter = func(v any, i int) any { switch v := v.(*ValidateDataResourceConfig); i { case 0: return &v.state @@ -3807,7 +3807,7 @@ func file_tfplugin6_proto_init() { return nil } } - file_tfplugin6_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin6_proto_msgTypes[11].Exporter = func(v any, i int) any { switch v := v.(*ConfigureProvider); i { case 0: return &v.state @@ -3819,7 +3819,7 @@ func file_tfplugin6_proto_init() { return nil } } - file_tfplugin6_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin6_proto_msgTypes[12].Exporter = func(v any, i int) any { switch v := v.(*ReadResource); i { case 0: return &v.state @@ -3831,7 +3831,7 @@ func file_tfplugin6_proto_init() { return nil } } - file_tfplugin6_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin6_proto_msgTypes[13].Exporter = func(v any, i int) any { switch v := v.(*PlanResourceChange); i { case 0: return &v.state @@ -3843,7 +3843,7 @@ func file_tfplugin6_proto_init() { return nil } } - file_tfplugin6_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin6_proto_msgTypes[14].Exporter = func(v any, i int) any { switch v := v.(*ApplyResourceChange); i { case 0: return &v.state @@ -3855,7 +3855,7 @@ func file_tfplugin6_proto_init() { return nil } } - file_tfplugin6_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin6_proto_msgTypes[15].Exporter = func(v any, i int) any { switch v := v.(*ImportResourceState); i { case 0: return &v.state @@ -3867,7 +3867,7 @@ func file_tfplugin6_proto_init() { return nil } } - file_tfplugin6_proto_msgTypes[16].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin6_proto_msgTypes[16].Exporter = func(v any, i int) any { switch v := v.(*ReadDataSource); i { case 0: return &v.state @@ -3879,7 +3879,7 @@ func file_tfplugin6_proto_init() { return nil } } - file_tfplugin6_proto_msgTypes[17].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin6_proto_msgTypes[17].Exporter = func(v any, i int) any { switch v := v.(*AttributePath_Step); i { case 0: return &v.state @@ -3891,7 +3891,7 @@ func file_tfplugin6_proto_init() { return nil } } - file_tfplugin6_proto_msgTypes[18].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin6_proto_msgTypes[18].Exporter = func(v any, i int) any { switch v := v.(*StopProvider_Request); i { case 0: return &v.state @@ -3903,7 +3903,7 @@ func file_tfplugin6_proto_init() { return nil } } - file_tfplugin6_proto_msgTypes[19].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin6_proto_msgTypes[19].Exporter = func(v any, i int) any { switch v := v.(*StopProvider_Response); i { case 0: return &v.state @@ -3915,7 +3915,7 @@ func file_tfplugin6_proto_init() { return nil } } - file_tfplugin6_proto_msgTypes[21].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin6_proto_msgTypes[21].Exporter = func(v any, i int) any { switch v := v.(*Schema_Block); i { case 0: return &v.state @@ -3927,7 +3927,7 @@ func file_tfplugin6_proto_init() { return nil } } - file_tfplugin6_proto_msgTypes[22].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin6_proto_msgTypes[22].Exporter = func(v any, i int) any { switch v := v.(*Schema_Attribute); i { case 0: return &v.state @@ -3939,7 +3939,7 @@ func file_tfplugin6_proto_init() { return nil } } - file_tfplugin6_proto_msgTypes[23].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin6_proto_msgTypes[23].Exporter = func(v any, i int) any { switch v := v.(*Schema_NestedBlock); i { case 0: return &v.state @@ -3951,7 +3951,7 @@ func file_tfplugin6_proto_init() { return nil } } - file_tfplugin6_proto_msgTypes[24].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin6_proto_msgTypes[24].Exporter = func(v any, i int) any { switch v := v.(*Schema_Object); i { case 0: return &v.state @@ -3963,7 +3963,7 @@ func file_tfplugin6_proto_init() { return nil } } - file_tfplugin6_proto_msgTypes[25].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin6_proto_msgTypes[25].Exporter = func(v any, i int) any { switch v := v.(*GetProviderSchema_Request); i { case 0: return &v.state @@ -3975,7 +3975,7 @@ func file_tfplugin6_proto_init() { return nil } } - file_tfplugin6_proto_msgTypes[26].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin6_proto_msgTypes[26].Exporter = func(v any, i int) any { switch v := v.(*GetProviderSchema_Response); i { case 0: return &v.state @@ -3987,7 +3987,7 @@ func file_tfplugin6_proto_init() { return nil } } - file_tfplugin6_proto_msgTypes[27].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin6_proto_msgTypes[27].Exporter = func(v any, i int) any { switch v := v.(*GetProviderSchema_ServerCapabilities); i { case 0: return &v.state @@ -3999,7 +3999,7 @@ func file_tfplugin6_proto_init() { return nil } } - file_tfplugin6_proto_msgTypes[30].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin6_proto_msgTypes[30].Exporter = func(v any, i int) any { switch v := v.(*ValidateProviderConfig_Request); i { case 0: return &v.state @@ -4011,7 +4011,7 @@ func file_tfplugin6_proto_init() { return nil } } - file_tfplugin6_proto_msgTypes[31].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin6_proto_msgTypes[31].Exporter = func(v any, i int) any { switch v := v.(*ValidateProviderConfig_Response); i { case 0: return &v.state @@ -4023,7 +4023,7 @@ func file_tfplugin6_proto_init() { return nil } } - file_tfplugin6_proto_msgTypes[32].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin6_proto_msgTypes[32].Exporter = func(v any, i int) any { switch v := v.(*UpgradeResourceState_Request); i { case 0: return &v.state @@ -4035,7 +4035,7 @@ func file_tfplugin6_proto_init() { return nil } } - file_tfplugin6_proto_msgTypes[33].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin6_proto_msgTypes[33].Exporter = func(v any, i int) any { switch v := v.(*UpgradeResourceState_Response); i { case 0: return &v.state @@ -4047,7 +4047,7 @@ func file_tfplugin6_proto_init() { return nil } } - file_tfplugin6_proto_msgTypes[34].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin6_proto_msgTypes[34].Exporter = func(v any, i int) any { switch v := v.(*ValidateResourceConfig_Request); i { case 0: return &v.state @@ -4059,7 +4059,7 @@ func file_tfplugin6_proto_init() { return nil } } - file_tfplugin6_proto_msgTypes[35].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin6_proto_msgTypes[35].Exporter = func(v any, i int) any { switch v := v.(*ValidateResourceConfig_Response); i { case 0: return &v.state @@ -4071,7 +4071,7 @@ func file_tfplugin6_proto_init() { return nil } } - file_tfplugin6_proto_msgTypes[36].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin6_proto_msgTypes[36].Exporter = func(v any, i int) any { switch v := v.(*ValidateDataResourceConfig_Request); i { case 0: return &v.state @@ -4083,7 +4083,7 @@ func file_tfplugin6_proto_init() { return nil } } - file_tfplugin6_proto_msgTypes[37].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin6_proto_msgTypes[37].Exporter = func(v any, i int) any { switch v := v.(*ValidateDataResourceConfig_Response); i { case 0: return &v.state @@ -4095,7 +4095,7 @@ func file_tfplugin6_proto_init() { return nil } } - file_tfplugin6_proto_msgTypes[38].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin6_proto_msgTypes[38].Exporter = func(v any, i int) any { switch v := v.(*ConfigureProvider_Request); i { case 0: return &v.state @@ -4107,7 +4107,7 @@ func file_tfplugin6_proto_init() { return nil } } - file_tfplugin6_proto_msgTypes[39].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin6_proto_msgTypes[39].Exporter = func(v any, i int) any { switch v := v.(*ConfigureProvider_Response); i { case 0: return &v.state @@ -4119,7 +4119,7 @@ func file_tfplugin6_proto_init() { return nil } } - file_tfplugin6_proto_msgTypes[40].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin6_proto_msgTypes[40].Exporter = func(v any, i int) any { switch v := v.(*ReadResource_Request); i { case 0: return &v.state @@ -4131,7 +4131,7 @@ func file_tfplugin6_proto_init() { return nil } } - file_tfplugin6_proto_msgTypes[41].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin6_proto_msgTypes[41].Exporter = func(v any, i int) any { switch v := v.(*ReadResource_Response); i { case 0: return &v.state @@ -4143,7 +4143,7 @@ func file_tfplugin6_proto_init() { return nil } } - file_tfplugin6_proto_msgTypes[42].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin6_proto_msgTypes[42].Exporter = func(v any, i int) any { switch v := v.(*PlanResourceChange_Request); i { case 0: return &v.state @@ -4155,7 +4155,7 @@ func file_tfplugin6_proto_init() { return nil } } - file_tfplugin6_proto_msgTypes[43].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin6_proto_msgTypes[43].Exporter = func(v any, i int) any { switch v := v.(*PlanResourceChange_Response); i { case 0: return &v.state @@ -4167,7 +4167,7 @@ func file_tfplugin6_proto_init() { return nil } } - file_tfplugin6_proto_msgTypes[44].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin6_proto_msgTypes[44].Exporter = func(v any, i int) any { switch v := v.(*ApplyResourceChange_Request); i { case 0: return &v.state @@ -4179,7 +4179,7 @@ func file_tfplugin6_proto_init() { return nil } } - file_tfplugin6_proto_msgTypes[45].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin6_proto_msgTypes[45].Exporter = func(v any, i int) any { switch v := v.(*ApplyResourceChange_Response); i { case 0: return &v.state @@ -4191,7 +4191,7 @@ func file_tfplugin6_proto_init() { return nil } } - file_tfplugin6_proto_msgTypes[46].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin6_proto_msgTypes[46].Exporter = func(v any, i int) any { switch v := v.(*ImportResourceState_Request); i { case 0: return &v.state @@ -4203,7 +4203,7 @@ func file_tfplugin6_proto_init() { return nil } } - file_tfplugin6_proto_msgTypes[47].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin6_proto_msgTypes[47].Exporter = func(v any, i int) any { switch v := v.(*ImportResourceState_ImportedResource); i { case 0: return &v.state @@ -4215,7 +4215,7 @@ func file_tfplugin6_proto_init() { return nil } } - file_tfplugin6_proto_msgTypes[48].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin6_proto_msgTypes[48].Exporter = func(v any, i int) any { switch v := v.(*ImportResourceState_Response); i { case 0: return &v.state @@ -4227,7 +4227,7 @@ func file_tfplugin6_proto_init() { return nil } } - file_tfplugin6_proto_msgTypes[49].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin6_proto_msgTypes[49].Exporter = func(v any, i int) any { switch v := v.(*ReadDataSource_Request); i { case 0: return &v.state @@ -4239,7 +4239,7 @@ func file_tfplugin6_proto_init() { return nil } } - file_tfplugin6_proto_msgTypes[50].Exporter = func(v interface{}, i int) interface{} { + file_tfplugin6_proto_msgTypes[50].Exporter = func(v any, i int) any { switch v := v.(*ReadDataSource_Response); i { case 0: return &v.state @@ -4252,7 +4252,7 @@ func file_tfplugin6_proto_init() { } } } - file_tfplugin6_proto_msgTypes[17].OneofWrappers = []interface{}{ + file_tfplugin6_proto_msgTypes[17].OneofWrappers = []any{ (*AttributePath_Step_AttributeName)(nil), (*AttributePath_Step_ElementKeyString)(nil), (*AttributePath_Step_ElementKeyInt)(nil), @@ -4489,7 +4489,7 @@ func RegisterProviderServer(s *grpc.Server, srv ProviderServer) { s.RegisterService(&_Provider_serviceDesc, srv) } -func _Provider_GetProviderSchema_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Provider_GetProviderSchema_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(GetProviderSchema_Request) if err := dec(in); err != nil { return nil, err @@ -4501,13 +4501,13 @@ func _Provider_GetProviderSchema_Handler(srv interface{}, ctx context.Context, d Server: srv, FullMethod: "/tfplugin6.Provider/GetProviderSchema", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(ProviderServer).GetProviderSchema(ctx, req.(*GetProviderSchema_Request)) } return interceptor(ctx, in, info, handler) } -func _Provider_ValidateProviderConfig_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Provider_ValidateProviderConfig_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(ValidateProviderConfig_Request) if err := dec(in); err != nil { return nil, err @@ -4519,13 +4519,13 @@ func _Provider_ValidateProviderConfig_Handler(srv interface{}, ctx context.Conte Server: srv, FullMethod: "/tfplugin6.Provider/ValidateProviderConfig", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(ProviderServer).ValidateProviderConfig(ctx, req.(*ValidateProviderConfig_Request)) } return interceptor(ctx, in, info, handler) } -func _Provider_ValidateResourceConfig_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Provider_ValidateResourceConfig_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(ValidateResourceConfig_Request) if err := dec(in); err != nil { return nil, err @@ -4537,13 +4537,13 @@ func _Provider_ValidateResourceConfig_Handler(srv interface{}, ctx context.Conte Server: srv, FullMethod: "/tfplugin6.Provider/ValidateResourceConfig", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(ProviderServer).ValidateResourceConfig(ctx, req.(*ValidateResourceConfig_Request)) } return interceptor(ctx, in, info, handler) } -func _Provider_ValidateDataResourceConfig_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Provider_ValidateDataResourceConfig_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(ValidateDataResourceConfig_Request) if err := dec(in); err != nil { return nil, err @@ -4555,13 +4555,13 @@ func _Provider_ValidateDataResourceConfig_Handler(srv interface{}, ctx context.C Server: srv, FullMethod: "/tfplugin6.Provider/ValidateDataResourceConfig", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(ProviderServer).ValidateDataResourceConfig(ctx, req.(*ValidateDataResourceConfig_Request)) } return interceptor(ctx, in, info, handler) } -func _Provider_UpgradeResourceState_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Provider_UpgradeResourceState_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(UpgradeResourceState_Request) if err := dec(in); err != nil { return nil, err @@ -4573,13 +4573,13 @@ func _Provider_UpgradeResourceState_Handler(srv interface{}, ctx context.Context Server: srv, FullMethod: "/tfplugin6.Provider/UpgradeResourceState", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(ProviderServer).UpgradeResourceState(ctx, req.(*UpgradeResourceState_Request)) } return interceptor(ctx, in, info, handler) } -func _Provider_ConfigureProvider_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Provider_ConfigureProvider_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(ConfigureProvider_Request) if err := dec(in); err != nil { return nil, err @@ -4591,13 +4591,13 @@ func _Provider_ConfigureProvider_Handler(srv interface{}, ctx context.Context, d Server: srv, FullMethod: "/tfplugin6.Provider/ConfigureProvider", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(ProviderServer).ConfigureProvider(ctx, req.(*ConfigureProvider_Request)) } return interceptor(ctx, in, info, handler) } -func _Provider_ReadResource_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Provider_ReadResource_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(ReadResource_Request) if err := dec(in); err != nil { return nil, err @@ -4609,13 +4609,13 @@ func _Provider_ReadResource_Handler(srv interface{}, ctx context.Context, dec fu Server: srv, FullMethod: "/tfplugin6.Provider/ReadResource", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(ProviderServer).ReadResource(ctx, req.(*ReadResource_Request)) } return interceptor(ctx, in, info, handler) } -func _Provider_PlanResourceChange_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Provider_PlanResourceChange_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(PlanResourceChange_Request) if err := dec(in); err != nil { return nil, err @@ -4627,13 +4627,13 @@ func _Provider_PlanResourceChange_Handler(srv interface{}, ctx context.Context, Server: srv, FullMethod: "/tfplugin6.Provider/PlanResourceChange", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(ProviderServer).PlanResourceChange(ctx, req.(*PlanResourceChange_Request)) } return interceptor(ctx, in, info, handler) } -func _Provider_ApplyResourceChange_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Provider_ApplyResourceChange_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(ApplyResourceChange_Request) if err := dec(in); err != nil { return nil, err @@ -4645,13 +4645,13 @@ func _Provider_ApplyResourceChange_Handler(srv interface{}, ctx context.Context, Server: srv, FullMethod: "/tfplugin6.Provider/ApplyResourceChange", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(ProviderServer).ApplyResourceChange(ctx, req.(*ApplyResourceChange_Request)) } return interceptor(ctx, in, info, handler) } -func _Provider_ImportResourceState_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Provider_ImportResourceState_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(ImportResourceState_Request) if err := dec(in); err != nil { return nil, err @@ -4663,13 +4663,13 @@ func _Provider_ImportResourceState_Handler(srv interface{}, ctx context.Context, Server: srv, FullMethod: "/tfplugin6.Provider/ImportResourceState", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(ProviderServer).ImportResourceState(ctx, req.(*ImportResourceState_Request)) } return interceptor(ctx, in, info, handler) } -func _Provider_ReadDataSource_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Provider_ReadDataSource_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(ReadDataSource_Request) if err := dec(in); err != nil { return nil, err @@ -4681,13 +4681,13 @@ func _Provider_ReadDataSource_Handler(srv interface{}, ctx context.Context, dec Server: srv, FullMethod: "/tfplugin6.Provider/ReadDataSource", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(ProviderServer).ReadDataSource(ctx, req.(*ReadDataSource_Request)) } return interceptor(ctx, in, info, handler) } -func _Provider_StopProvider_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Provider_StopProvider_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) { in := new(StopProvider_Request) if err := dec(in); err != nil { return nil, err @@ -4699,7 +4699,7 @@ func _Provider_StopProvider_Handler(srv interface{}, ctx context.Context, dec fu Server: srv, FullMethod: "/tfplugin6.Provider/StopProvider", } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { + handler := func(ctx context.Context, req any) (any, error) { return srv.(ProviderServer).StopProvider(ctx, req.(*StopProvider_Request)) } return interceptor(ctx, in, info, handler)