diff --git a/aws/resource_instance_profile.go b/aws/resource_instance_profile.go index 04ba23b0a5..1c2cb21dbb 100644 --- a/aws/resource_instance_profile.go +++ b/aws/resource_instance_profile.go @@ -12,8 +12,8 @@ import ( "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" ) // InstanceProfileInfo contains the ARN for aws instance profiles diff --git a/clusters/clusters_api.go b/clusters/clusters_api.go index b4728e871a..d47cfb6090 100644 --- a/clusters/clusters_api.go +++ b/clusters/clusters_api.go @@ -14,8 +14,8 @@ import ( "github.com/databricks/databricks-sdk-go/service/compute" "github.com/databricks/terraform-provider-databricks/common" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" ) // AutoScale is a struct the describes auto scaling for clusters diff --git a/commands/commands.go b/commands/commands.go index f9ec78df3c..a3d6070b48 100644 --- a/commands/commands.go +++ b/commands/commands.go @@ -10,7 +10,7 @@ import ( "github.com/databricks/terraform-provider-databricks/clusters" "github.com/databricks/terraform-provider-databricks/common" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" ) // Command is the struct that contains what the 1.2 api returns for the commands api diff --git a/go.mod b/go.mod index 2665debd98..40a4bd7940 100644 --- a/go.mod +++ b/go.mod @@ -13,6 +13,7 @@ require ( github.com/hashicorp/terraform-plugin-log v0.9.0 github.com/hashicorp/terraform-plugin-mux v0.16.0 github.com/hashicorp/terraform-plugin-sdk/v2 v2.34.0 + github.com/hashicorp/terraform-plugin-testing v1.10.0 github.com/stretchr/testify v1.9.0 github.com/zclconf/go-cty v1.15.0 golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 @@ -41,12 +42,13 @@ require ( github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-checkpoint v0.5.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect - github.com/hashicorp/go-hclog v1.5.0 // indirect + github.com/hashicorp/go-hclog v1.6.3 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/hashicorp/go-plugin v1.6.0 // indirect + github.com/hashicorp/go-retryablehttp v0.7.7 // indirect github.com/hashicorp/go-uuid v1.0.3 // indirect - github.com/hashicorp/go-version v1.6.0 // indirect - github.com/hashicorp/hc-install v0.6.4 // indirect + github.com/hashicorp/go-version v1.7.0 // indirect + github.com/hashicorp/hc-install v0.8.0 // indirect github.com/hashicorp/logutils v1.0.0 // indirect github.com/hashicorp/terraform-exec v0.21.0 // indirect github.com/hashicorp/terraform-json v0.22.1 // indirect @@ -71,13 +73,13 @@ require ( go.opentelemetry.io/otel v1.24.0 // indirect go.opentelemetry.io/otel/metric v1.24.0 // indirect go.opentelemetry.io/otel/trace v1.24.0 // indirect - golang.org/x/crypto v0.24.0 // indirect + golang.org/x/crypto v0.26.0 // indirect golang.org/x/mod v0.19.0 // indirect golang.org/x/net v0.26.0 // indirect golang.org/x/oauth2 v0.20.0 // indirect - golang.org/x/sync v0.7.0 // indirect - golang.org/x/sys v0.21.0 // indirect - golang.org/x/text v0.16.0 // indirect + golang.org/x/sync v0.8.0 // indirect + golang.org/x/sys v0.23.0 // indirect + golang.org/x/text v0.17.0 // indirect golang.org/x/time v0.5.0 // indirect golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect google.golang.org/api v0.182.0 // indirect diff --git a/go.sum b/go.sum index 677d582981..6eb1b4559f 100644 --- a/go.sum +++ b/go.sum @@ -107,19 +107,21 @@ github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9n github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 h1:1/D3zfFHttUKaCaGKZ/dR2roBXv0vKbSCnssIldfQdI= github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320/go.mod h1:EiZBMaudVLy8fmjf9Npq1dq9RalhveqZG5w/yz3mHWs= -github.com/hashicorp/go-hclog v1.5.0 h1:bI2ocEMgcVlz55Oj1xZNBsVi900c7II+fWDyV9o+13c= -github.com/hashicorp/go-hclog v1.5.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= +github.com/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB11/k= +github.com/hashicorp/go-hclog v1.6.3/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= github.com/hashicorp/go-plugin v1.6.0 h1:wgd4KxHJTVGGqWBq4QPB1i5BZNEx9BR8+OFmHDmTk8A= github.com/hashicorp/go-plugin v1.6.0/go.mod h1:lBS5MtSSBZk0SHc66KACcjjlU6WzEVP/8pwz68aMkCI= +github.com/hashicorp/go-retryablehttp v0.7.7 h1:C8hUCYzor8PIfXHa4UrZkU4VvK8o9ISHxT2Q8+VepXU= +github.com/hashicorp/go-retryablehttp v0.7.7/go.mod h1:pkQpWZeYWskR+D1tR2O5OcBFOxfA7DoAO6xtkuQnHTk= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek= -github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/hc-install v0.6.4 h1:QLqlM56/+SIIGvGcfFiwMY3z5WGXT066suo/v9Km8e0= -github.com/hashicorp/hc-install v0.6.4/go.mod h1:05LWLy8TD842OtgcfBbOT0WMoInBMUSHjmDx10zuBIA= +github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY= +github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +github.com/hashicorp/hc-install v0.8.0 h1:LdpZeXkZYMQhoKPCecJHlKvUkQFixN/nvyR1CdfOLjI= +github.com/hashicorp/hc-install v0.8.0/go.mod h1:+MwJYjDfCruSD/udvBmRB22Nlkwwkwf5sAB6uTIhSaU= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hashicorp/hcl/v2 v2.22.0 h1:hkZ3nCtqeJsDhPRFz5EA9iwcG1hNWGePOTw6oyul12M= @@ -140,6 +142,8 @@ github.com/hashicorp/terraform-plugin-mux v0.16.0 h1:RCzXHGDYwUwwqfYYWJKBFaS3fQs github.com/hashicorp/terraform-plugin-mux v0.16.0/go.mod h1:PF79mAsPc8CpusXPfEVa4X8PtkB+ngWoiUClMrNZlYo= github.com/hashicorp/terraform-plugin-sdk/v2 v2.34.0 h1:kJiWGx2kiQVo97Y5IOGR4EMcZ8DtMswHhUuFibsCQQE= github.com/hashicorp/terraform-plugin-sdk/v2 v2.34.0/go.mod h1:sl/UoabMc37HA6ICVMmGO+/0wofkVIRxf+BMb/dnoIg= +github.com/hashicorp/terraform-plugin-testing v1.10.0 h1:2+tmRNhvnfE4Bs8rB6v58S/VpqzGC6RCh9Y8ujdn+aw= +github.com/hashicorp/terraform-plugin-testing v1.10.0/go.mod h1:iWRW3+loP33WMch2P/TEyCxxct/ZEcCGMquSLSCVsrc= github.com/hashicorp/terraform-registry-address v0.2.3 h1:2TAiKJ1A3MAkZlH1YI/aTVcLZRu7JseiXNRHbOAyoTI= github.com/hashicorp/terraform-registry-address v0.2.3/go.mod h1:lFHA76T8jfQteVfT7caREqguFrW3c4MFSPhZB7HHgUM= github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S52uzrw4x0jKQ= @@ -227,8 +231,8 @@ go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI= -golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM= +golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw= +golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 h1:LfspQV/FYTatPTr/3HzIcmiUFH7PGP+OQ6mgDYo3yuQ= golang.org/x/exp v0.0.0-20240222234643-814bf88cf225/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc= @@ -256,8 +260,8 @@ golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= -golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= +golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -273,19 +277,19 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= -golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.23.0 h1:YfKFowiIMvtgl1UERQoTPPToxltDeZfbj4H7dVUCwmM= +golang.org/x/sys v0.23.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.21.0 h1:WVXCp+/EBEHOj53Rvu+7KiT/iElMrO8ACK16SMZ3jaA= -golang.org/x/term v0.21.0/go.mod h1:ooXLefLobQVslOqselCNF4SxFAaoS6KujMbsGzSDmX0= +golang.org/x/term v0.23.0 h1:F6D4vR+EHoL9/sWAWgAR1H2DcHr4PareCbAaCo1RpuU= +golang.org/x/term v0.23.0/go.mod h1:DgV24QBUrK6jhZXl+20l6UWznPlwAHm1Q1mGHtydmSk= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= -golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= -golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= +golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= diff --git a/internal/acceptance/account_rule_set_test.go b/internal/acceptance/account_rule_set_test.go index a8ee45c536..c95e70d139 100644 --- a/internal/acceptance/account_rule_set_test.go +++ b/internal/acceptance/account_rule_set_test.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/databricks/databricks-sdk-go/service/iam" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/stretchr/testify/assert" "github.com/databricks/terraform-provider-databricks/common" diff --git a/internal/acceptance/dashboard_test.go b/internal/acceptance/dashboard_test.go index bf67339315..bb56147cdd 100644 --- a/internal/acceptance/dashboard_test.go +++ b/internal/acceptance/dashboard_test.go @@ -10,7 +10,7 @@ import ( "github.com/databricks/databricks-sdk-go/service/dashboards" "github.com/databricks/terraform-provider-databricks/common" "github.com/databricks/terraform-provider-databricks/qa" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/internal/acceptance/data_aws_crossaccount_policy_test.go b/internal/acceptance/data_aws_crossaccount_policy_test.go index 233d5d0e3b..76e263ff7f 100644 --- a/internal/acceptance/data_aws_crossaccount_policy_test.go +++ b/internal/acceptance/data_aws_crossaccount_policy_test.go @@ -4,7 +4,7 @@ import ( "fmt" "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/hashicorp/terraform-plugin-testing/terraform" ) func TestMwsAccDataSourceAwsCrossaccountPolicy(t *testing.T) { diff --git a/internal/acceptance/data_catalog_test.go b/internal/acceptance/data_catalog_test.go index e2e3d00bea..591eacc162 100644 --- a/internal/acceptance/data_catalog_test.go +++ b/internal/acceptance/data_catalog_test.go @@ -3,7 +3,7 @@ package acceptance import ( "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/stretchr/testify/require" ) diff --git a/internal/acceptance/data_current_config_test.go b/internal/acceptance/data_current_config_test.go index 1d4296d7da..84a1f0fe98 100644 --- a/internal/acceptance/data_current_config_test.go +++ b/internal/acceptance/data_current_config_test.go @@ -3,7 +3,7 @@ package acceptance import ( "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/internal/acceptance/data_current_metastore_test.go b/internal/acceptance/data_current_metastore_test.go index c8885b03a7..363154b1d3 100644 --- a/internal/acceptance/data_current_metastore_test.go +++ b/internal/acceptance/data_current_metastore_test.go @@ -4,7 +4,7 @@ import ( "fmt" "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/hashicorp/terraform-plugin-testing/terraform" ) func TestUcAccDataSourceCurrentMetastore(t *testing.T) { diff --git a/internal/acceptance/data_external_locations_test.go b/internal/acceptance/data_external_locations_test.go index 21a9c807c2..eb42a96af2 100644 --- a/internal/acceptance/data_external_locations_test.go +++ b/internal/acceptance/data_external_locations_test.go @@ -4,7 +4,7 @@ import ( "fmt" "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/hashicorp/terraform-plugin-testing/terraform" ) func TestUcAccDataSourceExternalLocations(t *testing.T) { diff --git a/internal/acceptance/data_group_test.go b/internal/acceptance/data_group_test.go index 154ed2bb42..8713f82fd9 100644 --- a/internal/acceptance/data_group_test.go +++ b/internal/acceptance/data_group_test.go @@ -3,7 +3,7 @@ package acceptance import ( "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/internal/acceptance/data_job_test.go b/internal/acceptance/data_job_test.go index 2918ff3a26..9ca495ad98 100755 --- a/internal/acceptance/data_job_test.go +++ b/internal/acceptance/data_job_test.go @@ -53,10 +53,6 @@ func TestAccDataSourceJob(t *testing.T) { data "databricks_job" "this" { job_name = databricks_job.this.name - } - - output "cluster_workers" { - value = data.databricks_job.this.job_settings }`, }) } diff --git a/internal/acceptance/data_metastore_test.go b/internal/acceptance/data_metastore_test.go index 247fd54b02..b823890ae5 100644 --- a/internal/acceptance/data_metastore_test.go +++ b/internal/acceptance/data_metastore_test.go @@ -4,7 +4,7 @@ import ( "fmt" "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/hashicorp/terraform-plugin-testing/terraform" ) func TestUcAccDataSourceMetastore(t *testing.T) { diff --git a/internal/acceptance/data_metastores_test.go b/internal/acceptance/data_metastores_test.go index af6c30ff17..436a9f687c 100644 --- a/internal/acceptance/data_metastores_test.go +++ b/internal/acceptance/data_metastores_test.go @@ -4,7 +4,7 @@ import ( "fmt" "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/hashicorp/terraform-plugin-testing/terraform" ) func TestUcAccDataSourceMetastores(t *testing.T) { diff --git a/internal/acceptance/data_mlflow_experiment_test.go b/internal/acceptance/data_mlflow_experiment_test.go index bceff60b77..c2d0571877 100644 --- a/internal/acceptance/data_mlflow_experiment_test.go +++ b/internal/acceptance/data_mlflow_experiment_test.go @@ -4,7 +4,7 @@ import ( "fmt" "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/hashicorp/terraform-plugin-testing/terraform" ) func TestAccDataSourceMlflowExperiment(t *testing.T) { diff --git a/internal/acceptance/data_mlflow_model_test.go b/internal/acceptance/data_mlflow_model_test.go index ebf9cb6834..8e5d3aa9b2 100644 --- a/internal/acceptance/data_mlflow_model_test.go +++ b/internal/acceptance/data_mlflow_model_test.go @@ -4,7 +4,7 @@ import ( "fmt" "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/hashicorp/terraform-plugin-testing/terraform" ) func TestAccDataMlflowModel(t *testing.T) { diff --git a/internal/acceptance/data_mws_credentials_test.go b/internal/acceptance/data_mws_credentials_test.go index 29da69dd07..882a889566 100755 --- a/internal/acceptance/data_mws_credentials_test.go +++ b/internal/acceptance/data_mws_credentials_test.go @@ -4,7 +4,7 @@ import ( "fmt" "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/hashicorp/terraform-plugin-testing/terraform" ) func TestAccDataSourceMwsCredentials(t *testing.T) { diff --git a/internal/acceptance/data_mws_workspaces_test.go b/internal/acceptance/data_mws_workspaces_test.go index 75d9c12184..d3a39b7e6b 100755 --- a/internal/acceptance/data_mws_workspaces_test.go +++ b/internal/acceptance/data_mws_workspaces_test.go @@ -3,7 +3,7 @@ package acceptance import ( "fmt" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/hashicorp/terraform-plugin-testing/terraform" "testing" ) diff --git a/internal/acceptance/data_pipelines_test.go b/internal/acceptance/data_pipelines_test.go index 3fb946ac60..fc194dc0d5 100755 --- a/internal/acceptance/data_pipelines_test.go +++ b/internal/acceptance/data_pipelines_test.go @@ -3,7 +3,7 @@ package acceptance import ( "fmt" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/hashicorp/terraform-plugin-testing/terraform" "testing" ) diff --git a/internal/acceptance/data_schema_test.go b/internal/acceptance/data_schema_test.go index f72919a85f..4024d6c40e 100644 --- a/internal/acceptance/data_schema_test.go +++ b/internal/acceptance/data_schema_test.go @@ -3,7 +3,7 @@ package acceptance import ( "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/stretchr/testify/require" ) diff --git a/internal/acceptance/data_schemas_test.go b/internal/acceptance/data_schemas_test.go index 04cec2a4df..6258d0a07e 100755 --- a/internal/acceptance/data_schemas_test.go +++ b/internal/acceptance/data_schemas_test.go @@ -3,7 +3,7 @@ package acceptance import ( "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/internal/acceptance/data_shares_test.go b/internal/acceptance/data_shares_test.go index d749314422..9f7d940132 100644 --- a/internal/acceptance/data_shares_test.go +++ b/internal/acceptance/data_shares_test.go @@ -4,7 +4,7 @@ import ( "strconv" "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/internal/acceptance/data_storage_credential_test.go b/internal/acceptance/data_storage_credential_test.go index 3c77462d9c..a6f39d8d53 100755 --- a/internal/acceptance/data_storage_credential_test.go +++ b/internal/acceptance/data_storage_credential_test.go @@ -4,7 +4,7 @@ import ( "fmt" "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/stretchr/testify/require" ) diff --git a/internal/acceptance/data_storage_credentials_test.go b/internal/acceptance/data_storage_credentials_test.go index 43a5d3781d..e29f388acf 100644 --- a/internal/acceptance/data_storage_credentials_test.go +++ b/internal/acceptance/data_storage_credentials_test.go @@ -4,7 +4,7 @@ import ( "fmt" "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/hashicorp/terraform-plugin-testing/terraform" ) func TestUcAccDataSourceStorageCredentials(t *testing.T) { diff --git a/internal/acceptance/data_table_test.go b/internal/acceptance/data_table_test.go index 377edbd24f..2167c7ac7e 100644 --- a/internal/acceptance/data_table_test.go +++ b/internal/acceptance/data_table_test.go @@ -3,7 +3,7 @@ package acceptance import ( "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/stretchr/testify/require" ) diff --git a/internal/acceptance/data_tables_test.go b/internal/acceptance/data_tables_test.go index 3e8069b961..4057828af7 100644 --- a/internal/acceptance/data_tables_test.go +++ b/internal/acceptance/data_tables_test.go @@ -4,7 +4,7 @@ import ( "strconv" "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/internal/acceptance/data_user_test.go b/internal/acceptance/data_user_test.go index 66a3deab2e..fc46bf1ad3 100644 --- a/internal/acceptance/data_user_test.go +++ b/internal/acceptance/data_user_test.go @@ -3,7 +3,7 @@ package acceptance import ( "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/internal/acceptance/data_volume_test.go b/internal/acceptance/data_volume_test.go index f9d1ae7033..8f65c44f2e 100644 --- a/internal/acceptance/data_volume_test.go +++ b/internal/acceptance/data_volume_test.go @@ -3,7 +3,7 @@ package acceptance import ( "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/stretchr/testify/require" ) diff --git a/internal/acceptance/data_volumes_test.go b/internal/acceptance/data_volumes_test.go index 1aafe87862..af15dad148 100644 --- a/internal/acceptance/data_volumes_test.go +++ b/internal/acceptance/data_volumes_test.go @@ -4,7 +4,7 @@ import ( "strconv" "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/internal/acceptance/default_namespace_test.go b/internal/acceptance/default_namespace_test.go index d8de427f3c..83476fbecd 100644 --- a/internal/acceptance/default_namespace_test.go +++ b/internal/acceptance/default_namespace_test.go @@ -8,7 +8,7 @@ import ( "github.com/databricks/databricks-sdk-go/apierr" "github.com/databricks/databricks-sdk-go/service/settings" "github.com/databricks/terraform-provider-databricks/common" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/internal/acceptance/entitlements_test.go b/internal/acceptance/entitlements_test.go index 7ab2414b23..49d5c2a88a 100644 --- a/internal/acceptance/entitlements_test.go +++ b/internal/acceptance/entitlements_test.go @@ -8,7 +8,7 @@ import ( "github.com/databricks/databricks-sdk-go" "github.com/databricks/databricks-sdk-go/logger" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/stretchr/testify/assert" ) diff --git a/internal/acceptance/file_test.go b/internal/acceptance/file_test.go index 4d9c7c41ec..d821d05b73 100644 --- a/internal/acceptance/file_test.go +++ b/internal/acceptance/file_test.go @@ -293,7 +293,7 @@ func TestUcAccFileUpdateServerChange(t *testing.T) { path = "/Volumes/${databricks_volume.this.catalog_name}/${databricks_volume.this.schema_name}/${databricks_volume.this.name}/abcde" }`, // We are modifying the resource during the check stage, which causes the TF validation to fail. Ignoring the error. - ExpectError: regexp.MustCompile(` the plan was not empty`), + ExpectError: regexp.MustCompile(` the refresh plan was not empty.`), Check: resourceCheck("databricks_file.this", func(ctx context.Context, client *common.DatabricksClient, id string) error { w, err := client.WorkspaceClient() if err != nil { diff --git a/internal/acceptance/group_test.go b/internal/acceptance/group_test.go index f1e6abeb53..95ead635cf 100644 --- a/internal/acceptance/group_test.go +++ b/internal/acceptance/group_test.go @@ -9,7 +9,7 @@ import ( "github.com/databricks/terraform-provider-databricks/qa" "github.com/databricks/terraform-provider-databricks/scim" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" "testing" ) diff --git a/internal/acceptance/init_test.go b/internal/acceptance/init_test.go index 01fdc90c56..9bcbb8efab 100644 --- a/internal/acceptance/init_test.go +++ b/internal/acceptance/init_test.go @@ -21,12 +21,12 @@ import ( "github.com/databricks/databricks-sdk-go/logger" "github.com/databricks/terraform-provider-databricks/commands" "github.com/databricks/terraform-provider-databricks/common" - "github.com/databricks/terraform-provider-databricks/internal/providers/sdkv2" + "github.com/databricks/terraform-provider-databricks/internal/providers" dbproviderlogger "github.com/databricks/terraform-provider-databricks/logger" "github.com/databricks/terraform-provider-databricks/qa" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/hashicorp/terraform-plugin-go/tfprotov6" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/terraform" ) func init() { @@ -76,7 +76,7 @@ type step struct { PreventPostDestroyRefresh bool ImportState bool ImportStateVerify bool - ProviderFactories map[string]func() (*schema.Provider, error) + ProtoV6ProviderFactories map[string]func() (tfprotov6.ProviderServer, error) } func createUuid() string { @@ -138,7 +138,13 @@ func run(t *testing.T, steps []step) { t.Skip("Acceptance tests skipped unless env 'CLOUD_ENV' is set") } t.Parallel() - provider := sdkv2.DatabricksProvider() + protoV6ProviderFactories := map[string]func() (tfprotov6.ProviderServer, error){ + "databricks": func() (tfprotov6.ProviderServer, error) { + ctx := context.Background() + + return providers.GetProviderServer(ctx) + }, + } cwd, err := os.Getwd() if err != nil { t.Skip(err.Error()) @@ -164,13 +170,9 @@ func run(t *testing.T, steps []step) { thisStep := s stepCheck := thisStep.Check stepPreConfig := s.PreConfig - providerFactories := map[string]func() (*schema.Provider, error){ - "databricks": func() (*schema.Provider, error) { - return provider, nil - }, - } - if thisStep.ProviderFactories != nil { - providerFactories = thisStep.ProviderFactories + providerFactoryForStep := protoV6ProviderFactories + if thisStep.ProtoV6ProviderFactories != nil { + providerFactoryForStep = thisStep.ProtoV6ProviderFactories } ts = append(ts, resource.TestStep{ PreConfig: func() { @@ -194,25 +196,8 @@ func run(t *testing.T, steps []step) { ImportState: s.ImportState, ImportStateVerify: s.ImportStateVerify, ExpectError: s.ExpectError, - ProviderFactories: providerFactories, + ProtoV6ProviderFactories: providerFactoryForStep, Check: func(state *terraform.State) error { - // get configured client from provider - client := provider.Meta().(*common.DatabricksClient) - - // Default check for all runs. Asserts that the read operation succeeds. - for n, is := range state.RootModule().Resources { - p := strings.Split(n, ".") - - // Skip data resources. - if p[0] == "data" { - continue - } - r := provider.ResourcesMap[p[0]] - dia := r.ReadContext(ctx, r.Data(is.Primary), client) - if dia != nil { - return fmt.Errorf("%v", dia) - } - } if stepCheck != nil { return stepCheck(state) } diff --git a/internal/acceptance/model_serving_test.go b/internal/acceptance/model_serving_test.go index 2204d57fdb..f0bafb7368 100644 --- a/internal/acceptance/model_serving_test.go +++ b/internal/acceptance/model_serving_test.go @@ -4,7 +4,7 @@ import ( "fmt" "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-testing/helper/acctest" ) func TestAccModelServing(t *testing.T) { diff --git a/internal/acceptance/mounts_test.go b/internal/acceptance/mounts_test.go index f872a0af77..0a7270563c 100644 --- a/internal/acceptance/mounts_test.go +++ b/internal/acceptance/mounts_test.go @@ -8,7 +8,7 @@ import ( "golang.org/x/exp/maps" "github.com/databricks/databricks-sdk-go" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/internal/acceptance/mws_workspaces_test.go b/internal/acceptance/mws_workspaces_test.go index 08e60f9842..4dddcd146c 100644 --- a/internal/acceptance/mws_workspaces_test.go +++ b/internal/acceptance/mws_workspaces_test.go @@ -11,11 +11,13 @@ import ( "github.com/databricks/databricks-sdk-go" "github.com/databricks/databricks-sdk-go/logger" "github.com/databricks/terraform-provider-databricks/common" + "github.com/databricks/terraform-provider-databricks/internal/providers" "github.com/databricks/terraform-provider-databricks/internal/providers/sdkv2" "github.com/databricks/terraform-provider-databricks/tokens" + "github.com/hashicorp/terraform-plugin-go/tfprotov6" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/stretchr/testify/assert" ) @@ -367,9 +369,9 @@ func TestMwsAccAwsChangeToServicePrincipal(t *testing.T) { ` var pr *schema.Provider - providerFactory := map[string]func() (*schema.Provider, error){ - "databricks": func() (*schema.Provider, error) { - return pr, nil + providerFactory := map[string]func() (tfprotov6.ProviderServer, error){ + "databricks": func() (tfprotov6.ProviderServer, error) { + return providers.GetProviderServer(context.Background(), providers.WithSdkV2Provider(pr)) }, } accountLevel(t, step{ @@ -412,17 +414,17 @@ func TestMwsAccAwsChangeToServicePrincipal(t *testing.T) { }, }, step{ // Tolerate existing token - Template: workspaceTemplate(`token { comment = "Test {var.STICKY_RANDOM}" }`) + servicePrincipal, - ProviderFactories: providerFactory, + Template: workspaceTemplate(`token { comment = "Test {var.STICKY_RANDOM}" }`) + servicePrincipal, + ProtoV6ProviderFactories: providerFactory, }, step{ // Allow the token to be removed - Template: workspaceTemplate(``) + servicePrincipal, - ProviderFactories: providerFactory, + Template: workspaceTemplate(``) + servicePrincipal, + ProtoV6ProviderFactories: providerFactory, }, step{ // Fail when adding the token back - Template: workspaceTemplate(`token { comment = "Test {var.STICKY_RANDOM}" }`) + servicePrincipal, - ProviderFactories: providerFactory, - ExpectError: regexp.MustCompile(`cannot create token: the principal used by Databricks \(client ID .*\) is not authorized to create a token in this workspace`), + Template: workspaceTemplate(`token { comment = "Test {var.STICKY_RANDOM}" }`) + servicePrincipal, + ProtoV6ProviderFactories: providerFactory, + ExpectError: regexp.MustCompile(`cannot create token: the principal used by Databricks \(client ID .*\) is not authorized to create a token in this workspace`), }, step{ // Use the original provider for a final step to clean up the newly created service principal Template: workspaceTemplate(``) + servicePrincipal, diff --git a/internal/acceptance/notification_destination_test.go b/internal/acceptance/notification_destination_test.go index c2648a579e..309ed39d5e 100644 --- a/internal/acceptance/notification_destination_test.go +++ b/internal/acceptance/notification_destination_test.go @@ -7,7 +7,7 @@ import ( "github.com/databricks/databricks-sdk-go/service/settings" "github.com/databricks/terraform-provider-databricks/common" "github.com/databricks/terraform-provider-databricks/qa" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/internal/acceptance/permissions_test.go b/internal/acceptance/permissions_test.go index e3f7cd46f9..788340d606 100644 --- a/internal/acceptance/permissions_test.go +++ b/internal/acceptance/permissions_test.go @@ -10,9 +10,9 @@ import ( "github.com/databricks/terraform-provider-databricks/common" "github.com/databricks/terraform-provider-databricks/permissions" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/hashicorp/terraform-plugin-testing/helper/acctest" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/internal/acceptance/restrict_workspace_admins_test.go b/internal/acceptance/restrict_workspace_admins_test.go index b6c4efb9ae..3f6f7b4edd 100644 --- a/internal/acceptance/restrict_workspace_admins_test.go +++ b/internal/acceptance/restrict_workspace_admins_test.go @@ -8,7 +8,7 @@ import ( "github.com/databricks/databricks-sdk-go/apierr" "github.com/databricks/databricks-sdk-go/service/settings" "github.com/databricks/terraform-provider-databricks/common" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/internal/acceptance/secret_acl_test.go b/internal/acceptance/secret_acl_test.go index 789e6e47aa..cec49c6c95 100644 --- a/internal/acceptance/secret_acl_test.go +++ b/internal/acceptance/secret_acl_test.go @@ -7,7 +7,7 @@ import ( "github.com/databricks/databricks-sdk-go" "github.com/databricks/terraform-provider-databricks/common" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/internal/acceptance/secret_scope_test.go b/internal/acceptance/secret_scope_test.go index f05161c71e..f743317822 100644 --- a/internal/acceptance/secret_scope_test.go +++ b/internal/acceptance/secret_scope_test.go @@ -11,7 +11,7 @@ import ( "github.com/databricks/terraform-provider-databricks/common" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/internal/acceptance/service_principal_test.go b/internal/acceptance/service_principal_test.go index 6b07276c83..b1acad6b95 100644 --- a/internal/acceptance/service_principal_test.go +++ b/internal/acceptance/service_principal_test.go @@ -8,7 +8,7 @@ import ( "github.com/databricks/databricks-sdk-go" "github.com/databricks/databricks-sdk-go/apierr" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/hashicorp/terraform-plugin-testing/terraform" ) const azureSpn = `resource "databricks_service_principal" "this" { diff --git a/internal/acceptance/sql_endpoint_test.go b/internal/acceptance/sql_endpoint_test.go index ace170ff66..53496e8f2b 100644 --- a/internal/acceptance/sql_endpoint_test.go +++ b/internal/acceptance/sql_endpoint_test.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/databricks/databricks-sdk-go" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/internal/acceptance/sql_global_config_test.go b/internal/acceptance/sql_global_config_test.go index 00b7674c00..6bea052860 100644 --- a/internal/acceptance/sql_global_config_test.go +++ b/internal/acceptance/sql_global_config_test.go @@ -9,7 +9,7 @@ import ( "github.com/databricks/databricks-sdk-go/qa/lock" "github.com/databricks/databricks-sdk-go/qa/lock/core" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/internal/acceptance/tf_provider_test.go b/internal/acceptance/tf_provider_test.go index 7f29105137..44d0d53d2e 100644 --- a/internal/acceptance/tf_provider_test.go +++ b/internal/acceptance/tf_provider_test.go @@ -4,8 +4,8 @@ import ( "testing" "github.com/databricks/terraform-provider-databricks/internal/providers/sdkv2" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" ) func noOpProvider() *schema.Provider { diff --git a/internal/acceptance/user_test.go b/internal/acceptance/user_test.go index 2e59a5fa3e..9368bb88bf 100644 --- a/internal/acceptance/user_test.go +++ b/internal/acceptance/user_test.go @@ -13,8 +13,8 @@ import ( "github.com/databricks/databricks-sdk-go/service/iam" "github.com/databricks/terraform-provider-databricks/qa" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/terraform" ) // https://github.com/databricks/terraform-provider-databricks/issues/1097 diff --git a/internal/acceptance/vector_search_test.go b/internal/acceptance/vector_search_test.go index 83ca521efc..084891c5d0 100644 --- a/internal/acceptance/vector_search_test.go +++ b/internal/acceptance/vector_search_test.go @@ -4,7 +4,7 @@ import ( "fmt" "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-testing/helper/acctest" ) func TestUcAccVectorSearchEndpoint(t *testing.T) { diff --git a/internal/acceptance/workspace_conf_test.go b/internal/acceptance/workspace_conf_test.go index e2e23c7221..5e91bcb285 100644 --- a/internal/acceptance/workspace_conf_test.go +++ b/internal/acceptance/workspace_conf_test.go @@ -7,7 +7,7 @@ import ( "github.com/databricks/databricks-sdk-go" "github.com/databricks/databricks-sdk-go/service/settings" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/internal/providers/providers.go b/internal/providers/providers.go index a439c02471..681df6f74d 100644 --- a/internal/providers/providers.go +++ b/internal/providers/providers.go @@ -9,12 +9,38 @@ import ( "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw" "github.com/databricks/terraform-provider-databricks/internal/providers/sdkv2" + "github.com/hashicorp/terraform-plugin-framework/provider" "github.com/hashicorp/terraform-plugin-framework/providerserver" "github.com/hashicorp/terraform-plugin-go/tfprotov6" "github.com/hashicorp/terraform-plugin-mux/tf5to6server" "github.com/hashicorp/terraform-plugin-mux/tf6muxserver" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) +type serverOptions struct { + sdkV2Provider *schema.Provider + pluginFrameworkProvider provider.Provider +} + +// ServerOption is a common interface for overriding providers in GetProviderServer functino call. +type ServerOption interface { + Apply(*serverOptions) +} + +type sdkV2ProviderOption struct { + sdkV2Provider *schema.Provider +} + +func (o *sdkV2ProviderOption) Apply(options *serverOptions) { + options.sdkV2Provider = o.sdkV2Provider +} + +// WithSdkV2Provider allows overriding the SDKv2 provider used when creating a Terraform provider with muxing. +// This is typically used in acceptance test for a test step to have a custom provider override. +func WithSdkV2Provider(sdkV2Provider *schema.Provider) ServerOption { + return &sdkV2ProviderOption{sdkV2Provider: sdkV2Provider} +} + // GetProviderServer initializes and returns a Terraform Protocol v6 ProviderServer. // The function begins by initializing the Databricks provider using the SDK plugin // and then upgrades this provider to be compatible with Terraform's Protocol v6 using @@ -23,8 +49,23 @@ import ( // implementations are then combined using a multiplexing server, which allows multiple // Protocol v6 providers to be served together. The function returns the multiplexed // ProviderServer, or an error if any part of the process fails. -func GetProviderServer(ctx context.Context) (tfprotov6.ProviderServer, error) { - sdkPluginProvider := sdkv2.DatabricksProvider() +// +// GetProviderServer constructs the Databricks Terraform provider server. By default, it combines the default +// SDKv2-based provider and the default plugin framework-based provider using muxing. +// The providers used by the muxed server can be overridden using ServerOptions. +func GetProviderServer(ctx context.Context, options ...ServerOption) (tfprotov6.ProviderServer, error) { + serverOptions := serverOptions{} + for _, o := range options { + o.Apply(&serverOptions) + } + sdkPluginProvider := serverOptions.sdkV2Provider + if sdkPluginProvider == nil { + sdkPluginProvider = sdkv2.DatabricksProvider() + } + pluginFrameworkProvider := serverOptions.pluginFrameworkProvider + if pluginFrameworkProvider == nil { + pluginFrameworkProvider = pluginfw.GetDatabricksProviderPluginFramework() + } upgradedSdkPluginProvider, err := tf5to6server.UpgradeServer( context.Background(), @@ -33,9 +74,6 @@ func GetProviderServer(ctx context.Context) (tfprotov6.ProviderServer, error) { if err != nil { log.Fatal(err) } - - pluginFrameworkProvider := pluginfw.GetDatabricksProviderPluginFramework() - providers := []func() tfprotov6.ProviderServer{ func() tfprotov6.ProviderServer { return upgradedSdkPluginProvider diff --git a/jobs/resource_job.go b/jobs/resource_job.go index fd497a8d54..4f00e3bc95 100644 --- a/jobs/resource_job.go +++ b/jobs/resource_job.go @@ -14,9 +14,9 @@ import ( "github.com/databricks/databricks-sdk-go/service/compute" "github.com/databricks/databricks-sdk-go/service/jobs" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/databricks/databricks-sdk-go/apierr" "github.com/databricks/terraform-provider-databricks/clusters" diff --git a/libraries/libraries_api_sdk.go b/libraries/libraries_api_sdk.go index 09a8531d03..8d2af22af1 100644 --- a/libraries/libraries_api_sdk.go +++ b/libraries/libraries_api_sdk.go @@ -11,7 +11,7 @@ import ( "github.com/databricks/databricks-sdk-go" "github.com/databricks/databricks-sdk-go/apierr" "github.com/databricks/databricks-sdk-go/service/compute" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" ) // Given a compute.Wait struct, returns library statuses based on the input parameter. diff --git a/mws/resource_mws_networks.go b/mws/resource_mws_networks.go index 56cb98bb98..757f132ef4 100644 --- a/mws/resource_mws_networks.go +++ b/mws/resource_mws_networks.go @@ -9,9 +9,9 @@ import ( "github.com/databricks/databricks-sdk-go/apierr" "github.com/databricks/terraform-provider-databricks/common" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" ) // NewNetworksAPI creates MWSNetworksAPI instance from provider meta diff --git a/mws/resource_mws_vpc_endpoint.go b/mws/resource_mws_vpc_endpoint.go index fd10d8cfaf..5160b540c7 100644 --- a/mws/resource_mws_vpc_endpoint.go +++ b/mws/resource_mws_vpc_endpoint.go @@ -8,8 +8,8 @@ import ( "github.com/databricks/terraform-provider-databricks/common" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" ) // NewVPCEndpointAPI creates VPCEndpointAPI instance from provider meta diff --git a/mws/resource_mws_workspaces.go b/mws/resource_mws_workspaces.go index 73c5d40aa4..1d59b2950d 100644 --- a/mws/resource_mws_workspaces.go +++ b/mws/resource_mws_workspaces.go @@ -19,8 +19,8 @@ import ( "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-log/tflog" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" ) // DefaultProvisionTimeout is the amount of minutes terraform will wait diff --git a/qa/testing.go b/qa/testing.go index 7194975d06..045c100c1f 100644 --- a/qa/testing.go +++ b/qa/testing.go @@ -26,9 +26,9 @@ import ( "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/hcl" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require"