From 8a7997048d18307bd64a6f8058c707d4ba75b20b Mon Sep 17 00:00:00 2001 From: Pascal Hofmann Date: Thu, 15 Sep 2022 11:59:47 +0200 Subject: [PATCH] Update to terraform-plugin-framework 0.12 and fix import order --- ec/acc/acc_prereq.go | 1 + ec/acc/deployment_checks_test.go | 5 +- ec/acc/deployment_destroy_test.go | 3 +- ...ent_elasticsearch_kesytore_destroy_test.go | 3 +- .../deployment_elasticsearch_kesytore_test.go | 3 +- .../deployment_extension_bundle_file_test.go | 3 +- ec/acc/deployment_extension_destroy_test.go | 3 +- .../deployment_failed_upgrade_retry_test.go | 2 +- ec/acc/deployment_sweep_test.go | 3 +- .../deployment_traffic_filter_checks_test.go | 5 +- .../deployment_traffic_filter_destroy_test.go | 3 +- .../deployment_traffic_filter_sweep_test.go | 3 +- .../deployment_with_extension_bundle_test.go | 3 +- .../deploymentdatasource/datasource.go | 39 +++++++---- .../deploymentdatasource/datasource_test.go | 9 ++- .../deploymentdatasource/flatteners_apm.go | 4 +- .../flatteners_apm_test.go | 3 +- .../flatteners_elasticsearch.go | 3 +- .../flatteners_elasticsearch_test.go | 7 +- .../flatteners_enterprise_search.go | 4 +- .../flatteners_enterprise_search_test.go | 7 +- .../flatteners_integrations_server.go | 4 +- .../flatteners_integrations_server_test.go | 7 +- .../deploymentdatasource/flatteners_kibana.go | 4 +- .../flatteners_kibana_test.go | 7 +- .../flatteners_observability.go | 4 +- .../flatteners_observability_test.go | 5 +- .../flatteners_traffic_filter.go | 4 +- .../flatteners_traffic_filter_test.go | 3 +- .../deploymentdatasource/schema.go | 3 +- .../deploymentsdatasource/datasource.go | 44 +++++++----- .../deploymentsdatasource/datasource_test.go | 6 +- .../deploymentsdatasource/expanders.go | 6 +- .../deploymentsdatasource/expanders_test.go | 9 ++- .../deploymentsdatasource/schema.go | 6 +- ec/ecdatasource/stackdatasource/datasource.go | 47 ++++++++----- .../stackdatasource/datasource_test.go | 11 +-- .../stackdatasource/flatteners_apm.go | 4 +- .../stackdatasource/flatteners_apm_test.go | 6 +- .../flatteners_elasticsearch.go | 4 +- .../flatteners_elasticsearch_test.go | 6 +- .../flatteners_enterprise_search.go | 4 +- .../flatteners_enterprise_search_test.go | 6 +- .../stackdatasource/flatteners_kibana.go | 4 +- .../stackdatasource/flatteners_kibana_test.go | 6 +- ec/ecdatasource/stackdatasource/schema.go | 3 +- .../deploymentresource/apm_expanders_test.go | 3 +- .../deploymentresource/apm_flatteners_test.go | 3 +- ec/ecresource/deploymentresource/create.go | 5 +- ec/ecresource/deploymentresource/delete.go | 7 +- .../deploymentresource/delete_test.go | 8 ++- .../elasticsearch_expanders.go | 3 +- .../elasticsearch_expanders_test.go | 5 +- .../elasticsearch_flatteners.go | 3 +- .../elasticsearch_flatteners_test.go | 5 +- .../elasticsearch_remote_cluster_expanders.go | 3 +- ...ticsearch_remote_cluster_expanders_test.go | 5 +- .../enterprise_search_expanders_test.go | 3 +- .../enterprise_search_flatteners_test.go | 3 +- ec/ecresource/deploymentresource/expanders.go | 5 +- .../deploymentresource/expanders_test.go | 5 +- .../deploymentresource/flatteners.go | 5 +- .../deploymentresource/flatteners_test.go | 5 +- ec/ecresource/deploymentresource/import.go | 3 +- .../deploymentresource/import_test.go | 5 +- .../integrations_server_expanders_test.go | 3 +- .../integrations_server_flatteners_test.go | 3 +- .../kibana_expanders_test.go | 3 +- .../kibana_flatteners_test.go | 3 +- .../deploymentresource/observability_test.go | 3 +- ec/ecresource/deploymentresource/read.go | 5 +- ec/ecresource/deploymentresource/read_test.go | 10 +-- .../schema_elasticsearch.go | 3 +- .../stopped_resource_test.go | 3 +- .../deploymentresource/testutil_func.go | 3 +- .../deploymentresource/testutil_func_test.go | 3 +- .../deploymentresource/traffic_filter.go | 3 +- .../deploymentresource/traffic_filter_test.go | 3 +- ec/ecresource/deploymentresource/update.go | 5 +- .../deploymentresource/update_test.go | 3 +- .../update_traffic_rules.go | 3 +- .../elasticsearchkeystoreresource/create.go | 3 +- .../elasticsearchkeystoreresource/delete.go | 3 +- .../expanders.go | 3 +- .../expanders_test.go | 5 +- .../elasticsearchkeystoreresource/read.go | 5 +- .../read_test.go | 5 +- .../elasticsearchkeystoreresource/update.go | 3 +- ec/ecresource/extensionresource/create.go | 5 +- .../extensionresource/create_test.go | 8 ++- ec/ecresource/extensionresource/delete.go | 5 +- .../extensionresource/delete_test.go | 8 ++- ec/ecresource/extensionresource/read.go | 5 +- ec/ecresource/extensionresource/read_test.go | 8 +-- ec/ecresource/extensionresource/update.go | 5 +- .../extensionresource/update_test.go | 10 +-- ec/ecresource/extensionresource/upload.go | 3 +- .../trafficfilterassocresource/create.go | 18 ++++- .../trafficfilterassocresource/delete.go | 18 ++++- .../import_state.go | 5 +- .../trafficfilterassocresource/read.go | 19 ++++- .../resource_test.go | 12 ++-- .../trafficfilterassocresource/schema.go | 34 +++++---- .../trafficfilterassocresource/update.go | 3 +- ec/ecresource/trafficfilterresource/create.go | 5 +- ec/ecresource/trafficfilterresource/delete.go | 5 +- .../trafficfilterresource/delete_test.go | 9 ++- .../trafficfilterresource/expanders.go | 3 +- .../trafficfilterresource/expanders_test.go | 5 +- .../trafficfilterresource/flatteners.go | 3 +- .../trafficfilterresource/flatteners_test.go | 5 +- ec/ecresource/trafficfilterresource/read.go | 5 +- .../trafficfilterresource/read_test.go | 8 ++- ec/ecresource/trafficfilterresource/update.go | 5 +- ec/internal/flatteners/flatten_tags.go | 3 +- ec/internal/flatteners/flatten_tags_test.go | 3 +- ec/internal/planmodifier/default_from_env.go | 5 +- ec/internal/provider.go | 39 ++++------- ec/internal/util/helpers.go | 5 +- ec/internal/util/helpers_test.go | 3 +- ec/internal/util/parsers_test.go | 3 +- ec/internal/util/testutils.go | 3 +- ec/internal/util/traffic_filter_err_test.go | 3 +- ec/internal/validators/knownvalidator.go | 1 + ec/provider.go | 69 +++++++++++-------- ec/provider_config.go | 3 +- ec/provider_config_test.go | 5 +- gen/gen.go | 1 + go.mod | 22 +++--- go.sum | 23 +++++++ 130 files changed, 579 insertions(+), 330 deletions(-) diff --git a/ec/acc/acc_prereq.go b/ec/acc/acc_prereq.go index e079cd6e0..516f07de9 100644 --- a/ec/acc/acc_prereq.go +++ b/ec/acc/acc_prereq.go @@ -29,6 +29,7 @@ import ( "github.com/elastic/cloud-sdk-go/pkg/api" "github.com/elastic/cloud-sdk-go/pkg/auth" + "github.com/elastic/terraform-provider-ec/ec" ) diff --git a/ec/acc/deployment_checks_test.go b/ec/acc/deployment_checks_test.go index 5ae87ad86..c4a4cac96 100644 --- a/ec/acc/deployment_checks_test.go +++ b/ec/acc/deployment_checks_test.go @@ -20,11 +20,12 @@ package acc import ( "fmt" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/elastic/cloud-sdk-go/pkg/api" "github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi" "github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi/deputil" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) func testAccCheckDeploymentExists(name string) resource.TestCheckFunc { diff --git a/ec/acc/deployment_destroy_test.go b/ec/acc/deployment_destroy_test.go index e3817a613..5b70f5eff 100644 --- a/ec/acc/deployment_destroy_test.go +++ b/ec/acc/deployment_destroy_test.go @@ -20,9 +20,10 @@ package acc import ( "fmt" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi" "github.com/elastic/cloud-sdk-go/pkg/multierror" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) func testAccDeploymentDestroy(s *terraform.State) error { diff --git a/ec/acc/deployment_elasticsearch_kesytore_destroy_test.go b/ec/acc/deployment_elasticsearch_kesytore_destroy_test.go index 6a4332355..6dea775b3 100644 --- a/ec/acc/deployment_elasticsearch_kesytore_destroy_test.go +++ b/ec/acc/deployment_elasticsearch_kesytore_destroy_test.go @@ -20,9 +20,10 @@ package acc import ( "fmt" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi/eskeystoreapi" "github.com/elastic/cloud-sdk-go/pkg/multierror" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) func testAccDeploymentElasticsearchKeystoreDestroy(s *terraform.State) error { diff --git a/ec/acc/deployment_elasticsearch_kesytore_test.go b/ec/acc/deployment_elasticsearch_kesytore_test.go index f6d557daa..01a7f9207 100644 --- a/ec/acc/deployment_elasticsearch_kesytore_test.go +++ b/ec/acc/deployment_elasticsearch_kesytore_test.go @@ -21,10 +21,11 @@ import ( "fmt" "testing" - "github.com/elastic/cloud-sdk-go/pkg/multierror" "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/elastic/cloud-sdk-go/pkg/multierror" ) func TestAccDeploymentElasticsearchKeystore_full(t *testing.T) { diff --git a/ec/acc/deployment_extension_bundle_file_test.go b/ec/acc/deployment_extension_bundle_file_test.go index 8c7a267f3..25f8cc789 100644 --- a/ec/acc/deployment_extension_bundle_file_test.go +++ b/ec/acc/deployment_extension_bundle_file_test.go @@ -27,10 +27,11 @@ import ( "path/filepath" "testing" - "github.com/elastic/cloud-sdk-go/pkg/client/extensions" "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/elastic/cloud-sdk-go/pkg/client/extensions" ) func TestAccDeploymentExtension_bundleFile(t *testing.T) { diff --git a/ec/acc/deployment_extension_destroy_test.go b/ec/acc/deployment_extension_destroy_test.go index 140e9f153..a715b506b 100644 --- a/ec/acc/deployment_extension_destroy_test.go +++ b/ec/acc/deployment_extension_destroy_test.go @@ -20,9 +20,10 @@ package acc import ( "fmt" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/elastic/cloud-sdk-go/pkg/api/apierror" "github.com/elastic/cloud-sdk-go/pkg/client/extensions" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) func testAccExtensionDestroy(s *terraform.State) error { diff --git a/ec/acc/deployment_failed_upgrade_retry_test.go b/ec/acc/deployment_failed_upgrade_retry_test.go index df098b665..49d4d0505 100644 --- a/ec/acc/deployment_failed_upgrade_retry_test.go +++ b/ec/acc/deployment_failed_upgrade_retry_test.go @@ -23,7 +23,7 @@ import ( "regexp" "testing" - semver "github.com/blang/semver/v4" + "github.com/blang/semver/v4" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) diff --git a/ec/acc/deployment_sweep_test.go b/ec/acc/deployment_sweep_test.go index 01ab91e65..7909ea688 100644 --- a/ec/acc/deployment_sweep_test.go +++ b/ec/acc/deployment_sweep_test.go @@ -23,6 +23,8 @@ import ( "sync" "time" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/elastic/cloud-sdk-go/pkg/api" "github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi" "github.com/elastic/cloud-sdk-go/pkg/models" @@ -30,7 +32,6 @@ import ( "github.com/elastic/cloud-sdk-go/pkg/plan" "github.com/elastic/cloud-sdk-go/pkg/plan/planutil" "github.com/elastic/cloud-sdk-go/pkg/util/ec" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) func init() { diff --git a/ec/acc/deployment_traffic_filter_checks_test.go b/ec/acc/deployment_traffic_filter_checks_test.go index 5170283da..1e15360d6 100644 --- a/ec/acc/deployment_traffic_filter_checks_test.go +++ b/ec/acc/deployment_traffic_filter_checks_test.go @@ -20,10 +20,11 @@ package acc import ( "fmt" - "github.com/elastic/cloud-sdk-go/pkg/api" - "github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi/trafficfilterapi" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + + "github.com/elastic/cloud-sdk-go/pkg/api" + "github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi/trafficfilterapi" ) func testAccCheckDeploymentTrafficFilterExists(name string) resource.TestCheckFunc { diff --git a/ec/acc/deployment_traffic_filter_destroy_test.go b/ec/acc/deployment_traffic_filter_destroy_test.go index 2297c1888..a9568c0ac 100644 --- a/ec/acc/deployment_traffic_filter_destroy_test.go +++ b/ec/acc/deployment_traffic_filter_destroy_test.go @@ -20,9 +20,10 @@ package acc import ( "fmt" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi/trafficfilterapi" "github.com/elastic/cloud-sdk-go/pkg/multierror" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) func testAccDeploymentTrafficFilterDestroy(s *terraform.State) error { diff --git a/ec/acc/deployment_traffic_filter_sweep_test.go b/ec/acc/deployment_traffic_filter_sweep_test.go index eac607b54..54bd5241d 100644 --- a/ec/acc/deployment_traffic_filter_sweep_test.go +++ b/ec/acc/deployment_traffic_filter_sweep_test.go @@ -21,10 +21,11 @@ import ( "strings" "sync" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/elastic/cloud-sdk-go/pkg/api" "github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi/trafficfilterapi" "github.com/elastic/cloud-sdk-go/pkg/multierror" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) func init() { diff --git a/ec/acc/deployment_with_extension_bundle_test.go b/ec/acc/deployment_with_extension_bundle_test.go index 5c632c9b9..203994f1e 100644 --- a/ec/acc/deployment_with_extension_bundle_test.go +++ b/ec/acc/deployment_with_extension_bundle_test.go @@ -23,10 +23,11 @@ import ( "path/filepath" "testing" - "github.com/elastic/cloud-sdk-go/pkg/multierror" "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/elastic/cloud-sdk-go/pkg/multierror" ) func TestAccDeployment_withExtension(t *testing.T) { diff --git a/ec/ecdatasource/deploymentdatasource/datasource.go b/ec/ecdatasource/deploymentdatasource/datasource.go index 1239f6041..ec5e5b396 100644 --- a/ec/ecdatasource/deploymentdatasource/datasource.go +++ b/ec/ecdatasource/deploymentdatasource/datasource.go @@ -23,9 +23,9 @@ import ( "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/diag" - "github.com/hashicorp/terraform-plugin-framework/provider" "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/elastic/cloud-sdk-go/pkg/api" "github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi" "github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi/deputil" "github.com/elastic/cloud-sdk-go/pkg/models" @@ -35,25 +35,36 @@ import ( "github.com/elastic/terraform-provider-ec/ec/internal/util" ) -var _ provider.DataSourceType = (*DataSourceType)(nil) +var _ datasource.DataSource = &DataSource{} +var _ datasource.DataSourceWithConfigure = &DataSource{} +var _ datasource.DataSourceWithGetSchema = &DataSource{} +var _ datasource.DataSourceWithMetadata = &DataSource{} -type DataSourceType struct{} +type DataSource struct { + client *api.API +} -func (s DataSourceType) NewDataSource(ctx context.Context, in provider.Provider) (datasource.DataSource, diag.Diagnostics) { - p, diags := internal.ConvertProviderType(in) +func (d *DataSource) Configure(ctx context.Context, request datasource.ConfigureRequest, response *datasource.ConfigureResponse) { + client, diags := internal.ConvertProviderData(request.ProviderData) + response.Diagnostics.Append(diags...) + d.client = client +} - return &deploymentDataSource{ - p: p, - }, diags +func (d *DataSource) Metadata(ctx context.Context, request datasource.MetadataRequest, response *datasource.MetadataResponse) { + response.TypeName = request.ProviderTypeName + "_deployment" } -var _ datasource.DataSource = (*deploymentDataSource)(nil) +func (d DataSource) Read(ctx context.Context, request datasource.ReadRequest, response *datasource.ReadResponse) { + // Prevent panic if the provider has not been configured. + if d.client == nil { + response.Diagnostics.AddError( + "Unconfigured API Client", + "Expected configured API client. Please report this issue to the provider developers.", + ) -type deploymentDataSource struct { - p internal.Provider -} + return + } -func (d deploymentDataSource) Read(ctx context.Context, request datasource.ReadRequest, response *datasource.ReadResponse) { var newState modelV0 response.Diagnostics.Append(request.Config.Get(ctx, &newState)...) if response.Diagnostics.HasError() { @@ -61,7 +72,7 @@ func (d deploymentDataSource) Read(ctx context.Context, request datasource.ReadR } res, err := deploymentapi.Get(deploymentapi.GetParams{ - API: d.p.GetClient(), + API: d.client, DeploymentID: newState.ID.Value, QueryParams: deputil.QueryParams{ ShowPlans: true, diff --git a/ec/ecdatasource/deploymentdatasource/datasource_test.go b/ec/ecdatasource/deploymentdatasource/datasource_test.go index 2126b708d..12ea29998 100644 --- a/ec/ecdatasource/deploymentdatasource/datasource_test.go +++ b/ec/ecdatasource/deploymentdatasource/datasource_test.go @@ -19,15 +19,18 @@ package deploymentdatasource import ( "context" - "github.com/elastic/terraform-provider-ec/ec/internal/util" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" - "testing" "github.com/elastic/cloud-sdk-go/pkg/api/mock" "github.com/elastic/cloud-sdk-go/pkg/models" "github.com/elastic/cloud-sdk-go/pkg/util/ec" - "github.com/stretchr/testify/assert" + + "github.com/elastic/terraform-provider-ec/ec/internal/util" ) func Test_modelToState(t *testing.T) { diff --git a/ec/ecdatasource/deploymentdatasource/flatteners_apm.go b/ec/ecdatasource/deploymentdatasource/flatteners_apm.go index 15ad5aaf9..cb5c8c1df 100644 --- a/ec/ecdatasource/deploymentdatasource/flatteners_apm.go +++ b/ec/ecdatasource/deploymentdatasource/flatteners_apm.go @@ -19,11 +19,13 @@ package deploymentdatasource import ( "context" - "github.com/elastic/cloud-sdk-go/pkg/models" + "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/tfsdk" "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/elastic/cloud-sdk-go/pkg/models" + "github.com/elastic/terraform-provider-ec/ec/internal/util" ) diff --git a/ec/ecdatasource/deploymentdatasource/flatteners_apm_test.go b/ec/ecdatasource/deploymentdatasource/flatteners_apm_test.go index 570d696a3..74d4ad6e6 100644 --- a/ec/ecdatasource/deploymentdatasource/flatteners_apm_test.go +++ b/ec/ecdatasource/deploymentdatasource/flatteners_apm_test.go @@ -19,10 +19,11 @@ package deploymentdatasource import ( "context" + "testing" + "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/stretchr/testify/assert" - "testing" "github.com/elastic/cloud-sdk-go/pkg/api/mock" "github.com/elastic/cloud-sdk-go/pkg/models" diff --git a/ec/ecdatasource/deploymentdatasource/flatteners_elasticsearch.go b/ec/ecdatasource/deploymentdatasource/flatteners_elasticsearch.go index e34060acc..a53a55115 100644 --- a/ec/ecdatasource/deploymentdatasource/flatteners_elasticsearch.go +++ b/ec/ecdatasource/deploymentdatasource/flatteners_elasticsearch.go @@ -23,11 +23,12 @@ import ( "fmt" "strconv" - "github.com/elastic/cloud-sdk-go/pkg/models" "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/tfsdk" "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/elastic/cloud-sdk-go/pkg/models" + "github.com/elastic/terraform-provider-ec/ec/internal/util" ) diff --git a/ec/ecdatasource/deploymentdatasource/flatteners_elasticsearch_test.go b/ec/ecdatasource/deploymentdatasource/flatteners_elasticsearch_test.go index 3b8fcee59..cc82267b8 100644 --- a/ec/ecdatasource/deploymentdatasource/flatteners_elasticsearch_test.go +++ b/ec/ecdatasource/deploymentdatasource/flatteners_elasticsearch_test.go @@ -21,12 +21,13 @@ import ( "context" "testing" - "github.com/elastic/cloud-sdk-go/pkg/api/mock" - "github.com/elastic/cloud-sdk-go/pkg/models" - "github.com/elastic/cloud-sdk-go/pkg/util/ec" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/stretchr/testify/assert" + + "github.com/elastic/cloud-sdk-go/pkg/api/mock" + "github.com/elastic/cloud-sdk-go/pkg/models" + "github.com/elastic/cloud-sdk-go/pkg/util/ec" ) func Test_flattenElasticsearchResources(t *testing.T) { diff --git a/ec/ecdatasource/deploymentdatasource/flatteners_enterprise_search.go b/ec/ecdatasource/deploymentdatasource/flatteners_enterprise_search.go index 1fbbb6a59..57236deca 100644 --- a/ec/ecdatasource/deploymentdatasource/flatteners_enterprise_search.go +++ b/ec/ecdatasource/deploymentdatasource/flatteners_enterprise_search.go @@ -19,11 +19,13 @@ package deploymentdatasource import ( "context" - "github.com/elastic/cloud-sdk-go/pkg/models" + "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/tfsdk" "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/elastic/cloud-sdk-go/pkg/models" + "github.com/elastic/terraform-provider-ec/ec/internal/util" ) diff --git a/ec/ecdatasource/deploymentdatasource/flatteners_enterprise_search_test.go b/ec/ecdatasource/deploymentdatasource/flatteners_enterprise_search_test.go index 64baf24e8..ee52d1917 100644 --- a/ec/ecdatasource/deploymentdatasource/flatteners_enterprise_search_test.go +++ b/ec/ecdatasource/deploymentdatasource/flatteners_enterprise_search_test.go @@ -21,12 +21,13 @@ import ( "context" "testing" - "github.com/elastic/cloud-sdk-go/pkg/api/mock" - "github.com/elastic/cloud-sdk-go/pkg/models" - "github.com/elastic/cloud-sdk-go/pkg/util/ec" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/stretchr/testify/assert" + + "github.com/elastic/cloud-sdk-go/pkg/api/mock" + "github.com/elastic/cloud-sdk-go/pkg/models" + "github.com/elastic/cloud-sdk-go/pkg/util/ec" ) func Test_flattenEnterpriseSearchResource(t *testing.T) { diff --git a/ec/ecdatasource/deploymentdatasource/flatteners_integrations_server.go b/ec/ecdatasource/deploymentdatasource/flatteners_integrations_server.go index 57b8ec910..c66a9a829 100644 --- a/ec/ecdatasource/deploymentdatasource/flatteners_integrations_server.go +++ b/ec/ecdatasource/deploymentdatasource/flatteners_integrations_server.go @@ -19,11 +19,13 @@ package deploymentdatasource import ( "context" - "github.com/elastic/cloud-sdk-go/pkg/models" + "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/tfsdk" "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/elastic/cloud-sdk-go/pkg/models" + "github.com/elastic/terraform-provider-ec/ec/internal/util" ) diff --git a/ec/ecdatasource/deploymentdatasource/flatteners_integrations_server_test.go b/ec/ecdatasource/deploymentdatasource/flatteners_integrations_server_test.go index 7fff8dbff..59afa71dd 100644 --- a/ec/ecdatasource/deploymentdatasource/flatteners_integrations_server_test.go +++ b/ec/ecdatasource/deploymentdatasource/flatteners_integrations_server_test.go @@ -21,12 +21,13 @@ import ( "context" "testing" - "github.com/elastic/cloud-sdk-go/pkg/api/mock" - "github.com/elastic/cloud-sdk-go/pkg/models" - "github.com/elastic/cloud-sdk-go/pkg/util/ec" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/stretchr/testify/assert" + + "github.com/elastic/cloud-sdk-go/pkg/api/mock" + "github.com/elastic/cloud-sdk-go/pkg/models" + "github.com/elastic/cloud-sdk-go/pkg/util/ec" ) func Test_flattenIntegrationsServerResource(t *testing.T) { diff --git a/ec/ecdatasource/deploymentdatasource/flatteners_kibana.go b/ec/ecdatasource/deploymentdatasource/flatteners_kibana.go index 3c27f808f..1c7bcc46f 100644 --- a/ec/ecdatasource/deploymentdatasource/flatteners_kibana.go +++ b/ec/ecdatasource/deploymentdatasource/flatteners_kibana.go @@ -19,11 +19,13 @@ package deploymentdatasource import ( "context" - "github.com/elastic/cloud-sdk-go/pkg/models" + "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/tfsdk" "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/elastic/cloud-sdk-go/pkg/models" + "github.com/elastic/terraform-provider-ec/ec/internal/util" ) diff --git a/ec/ecdatasource/deploymentdatasource/flatteners_kibana_test.go b/ec/ecdatasource/deploymentdatasource/flatteners_kibana_test.go index 2faea9f6a..97b52cc24 100644 --- a/ec/ecdatasource/deploymentdatasource/flatteners_kibana_test.go +++ b/ec/ecdatasource/deploymentdatasource/flatteners_kibana_test.go @@ -21,12 +21,13 @@ import ( "context" "testing" - "github.com/elastic/cloud-sdk-go/pkg/api/mock" - "github.com/elastic/cloud-sdk-go/pkg/models" - "github.com/elastic/cloud-sdk-go/pkg/util/ec" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/stretchr/testify/assert" + + "github.com/elastic/cloud-sdk-go/pkg/api/mock" + "github.com/elastic/cloud-sdk-go/pkg/models" + "github.com/elastic/cloud-sdk-go/pkg/util/ec" ) func Test_flattenKibanaResources(t *testing.T) { diff --git a/ec/ecdatasource/deploymentdatasource/flatteners_observability.go b/ec/ecdatasource/deploymentdatasource/flatteners_observability.go index 507ba7607..f00735f15 100644 --- a/ec/ecdatasource/deploymentdatasource/flatteners_observability.go +++ b/ec/ecdatasource/deploymentdatasource/flatteners_observability.go @@ -19,10 +19,12 @@ package deploymentdatasource import ( "context" - "github.com/elastic/cloud-sdk-go/pkg/models" + "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/tfsdk" "github.com/hashicorp/terraform-plugin-framework/types" + + "github.com/elastic/cloud-sdk-go/pkg/models" ) // flattenObservability parses a deployment's observability settings. diff --git a/ec/ecdatasource/deploymentdatasource/flatteners_observability_test.go b/ec/ecdatasource/deploymentdatasource/flatteners_observability_test.go index 4da04c60c..2e7330655 100644 --- a/ec/ecdatasource/deploymentdatasource/flatteners_observability_test.go +++ b/ec/ecdatasource/deploymentdatasource/flatteners_observability_test.go @@ -21,10 +21,11 @@ import ( "context" "testing" - "github.com/elastic/cloud-sdk-go/pkg/api/mock" - "github.com/elastic/cloud-sdk-go/pkg/models" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/stretchr/testify/assert" + + "github.com/elastic/cloud-sdk-go/pkg/api/mock" + "github.com/elastic/cloud-sdk-go/pkg/models" ) func TestFlattenObservability(t *testing.T) { diff --git a/ec/ecdatasource/deploymentdatasource/flatteners_traffic_filter.go b/ec/ecdatasource/deploymentdatasource/flatteners_traffic_filter.go index 51851accc..eb16bb770 100644 --- a/ec/ecdatasource/deploymentdatasource/flatteners_traffic_filter.go +++ b/ec/ecdatasource/deploymentdatasource/flatteners_traffic_filter.go @@ -19,10 +19,12 @@ package deploymentdatasource import ( "context" - "github.com/elastic/cloud-sdk-go/pkg/models" + "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/tfsdk" "github.com/hashicorp/terraform-plugin-framework/types" + + "github.com/elastic/cloud-sdk-go/pkg/models" ) // flattenTrafficFiltering parses a deployment's traffic filtering settings. diff --git a/ec/ecdatasource/deploymentdatasource/flatteners_traffic_filter_test.go b/ec/ecdatasource/deploymentdatasource/flatteners_traffic_filter_test.go index aa7a81d33..9cfc22c2f 100644 --- a/ec/ecdatasource/deploymentdatasource/flatteners_traffic_filter_test.go +++ b/ec/ecdatasource/deploymentdatasource/flatteners_traffic_filter_test.go @@ -21,8 +21,9 @@ import ( "context" "testing" - "github.com/elastic/cloud-sdk-go/pkg/models" "github.com/stretchr/testify/assert" + + "github.com/elastic/cloud-sdk-go/pkg/models" ) func Test_flattenTrafficFiltering(t *testing.T) { diff --git a/ec/ecdatasource/deploymentdatasource/schema.go b/ec/ecdatasource/deploymentdatasource/schema.go index 53d2fc73d..f77b0f1b4 100644 --- a/ec/ecdatasource/deploymentdatasource/schema.go +++ b/ec/ecdatasource/deploymentdatasource/schema.go @@ -19,12 +19,13 @@ package deploymentdatasource import ( "context" + "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/tfsdk" "github.com/hashicorp/terraform-plugin-framework/types" ) -func (s DataSourceType) GetSchema(ctx context.Context) (tfsdk.Schema, diag.Diagnostics) { +func (d *DataSource) GetSchema(ctx context.Context) (tfsdk.Schema, diag.Diagnostics) { return tfsdk.Schema{ Attributes: map[string]tfsdk.Attribute{ "alias": { diff --git a/ec/ecdatasource/deploymentsdatasource/datasource.go b/ec/ecdatasource/deploymentsdatasource/datasource.go index 7f4b6b64c..08139b485 100644 --- a/ec/ecdatasource/deploymentsdatasource/datasource.go +++ b/ec/ecdatasource/deploymentsdatasource/datasource.go @@ -22,37 +22,49 @@ import ( "fmt" "strconv" - "github.com/elastic/terraform-provider-ec/ec/internal" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/diag" - "github.com/hashicorp/terraform-plugin-framework/provider" "github.com/hashicorp/terraform-plugin-framework/tfsdk" "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/elastic/cloud-sdk-go/pkg/api" "github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi" "github.com/elastic/cloud-sdk-go/pkg/models" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + + "github.com/elastic/terraform-provider-ec/ec/internal" ) -var _ provider.DataSourceType = (*DataSourceType)(nil) +var _ datasource.DataSource = &DataSource{} +var _ datasource.DataSourceWithConfigure = &DataSource{} +var _ datasource.DataSourceWithGetSchema = &DataSource{} +var _ datasource.DataSourceWithMetadata = &DataSource{} -type DataSourceType struct{} +type DataSource struct { + client *api.API +} -func (s DataSourceType) NewDataSource(ctx context.Context, in provider.Provider) (datasource.DataSource, diag.Diagnostics) { - p, diags := internal.ConvertProviderType(in) +func (d *DataSource) Configure(ctx context.Context, request datasource.ConfigureRequest, response *datasource.ConfigureResponse) { + client, diags := internal.ConvertProviderData(request.ProviderData) + response.Diagnostics.Append(diags...) + d.client = client +} - return &deploymentsDataSource{ - p: p, - }, diags +func (d *DataSource) Metadata(ctx context.Context, request datasource.MetadataRequest, response *datasource.MetadataResponse) { + response.TypeName = request.ProviderTypeName + "_deployments" } -var _ datasource.DataSource = (*deploymentsDataSource)(nil) +func (d DataSource) Read(ctx context.Context, request datasource.ReadRequest, response *datasource.ReadResponse) { + // Prevent panic if the provider has not been configured. + if d.client == nil { + response.Diagnostics.AddError( + "Unconfigured API Client", + "Expected configured API client. Please report this issue to the provider developers.", + ) -type deploymentsDataSource struct { - p internal.Provider -} + return + } -func (d deploymentsDataSource) Read(ctx context.Context, request datasource.ReadRequest, response *datasource.ReadResponse) { var newState modelV0 response.Diagnostics.Append(request.Config.Get(ctx, &newState)...) if response.Diagnostics.HasError() { @@ -66,7 +78,7 @@ func (d deploymentsDataSource) Read(ctx context.Context, request datasource.Read } res, err := deploymentapi.Search(deploymentapi.SearchParams{ - API: d.p.GetClient(), + API: d.client, Request: query, }) if err != nil { diff --git a/ec/ecdatasource/deploymentsdatasource/datasource_test.go b/ec/ecdatasource/deploymentsdatasource/datasource_test.go index 25eaa0f78..23b4e2db4 100644 --- a/ec/ecdatasource/deploymentsdatasource/datasource_test.go +++ b/ec/ecdatasource/deploymentsdatasource/datasource_test.go @@ -19,13 +19,15 @@ package deploymentsdatasource import ( "context" + "testing" + "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" - "testing" + + "github.com/stretchr/testify/assert" "github.com/elastic/cloud-sdk-go/pkg/models" "github.com/elastic/cloud-sdk-go/pkg/util/ec" - "github.com/stretchr/testify/assert" ) func Test_modelToState(t *testing.T) { diff --git a/ec/ecdatasource/deploymentsdatasource/expanders.go b/ec/ecdatasource/deploymentsdatasource/expanders.go index 96f401c5c..635883ab8 100644 --- a/ec/ecdatasource/deploymentsdatasource/expanders.go +++ b/ec/ecdatasource/deploymentsdatasource/expanders.go @@ -20,11 +20,13 @@ package deploymentsdatasource import ( "context" "fmt" + + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/elastic/cloud-sdk-go/pkg/models" "github.com/elastic/cloud-sdk-go/pkg/util" "github.com/elastic/cloud-sdk-go/pkg/util/ec" - "github.com/hashicorp/terraform-plugin-framework/diag" - "github.com/hashicorp/terraform-plugin-framework/types" ) // expandFilters expands all filters into a search request model diff --git a/ec/ecdatasource/deploymentsdatasource/expanders_test.go b/ec/ecdatasource/deploymentsdatasource/expanders_test.go index 6727be188..8ddb20da5 100644 --- a/ec/ecdatasource/deploymentsdatasource/expanders_test.go +++ b/ec/ecdatasource/deploymentsdatasource/expanders_test.go @@ -20,15 +20,18 @@ package deploymentsdatasource import ( "context" "encoding/json" - "github.com/elastic/terraform-provider-ec/ec/internal/util" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/types" - "testing" "github.com/elastic/cloud-sdk-go/pkg/models" "github.com/elastic/cloud-sdk-go/pkg/util/ec" - "github.com/stretchr/testify/assert" + + "github.com/elastic/terraform-provider-ec/ec/internal/util" ) func Test_expandFilters(t *testing.T) { diff --git a/ec/ecdatasource/deploymentsdatasource/schema.go b/ec/ecdatasource/deploymentsdatasource/schema.go index 7275db68b..c633e0f98 100644 --- a/ec/ecdatasource/deploymentsdatasource/schema.go +++ b/ec/ecdatasource/deploymentsdatasource/schema.go @@ -19,14 +19,16 @@ package deploymentsdatasource import ( "context" - "github.com/elastic/terraform-provider-ec/ec/internal/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/tfsdk" "github.com/hashicorp/terraform-plugin-framework/types" + + "github.com/elastic/terraform-provider-ec/ec/internal/planmodifier" ) -func (s DataSourceType) GetSchema(ctx context.Context) (tfsdk.Schema, diag.Diagnostics) { +func (d *DataSource) GetSchema(ctx context.Context) (tfsdk.Schema, diag.Diagnostics) { return tfsdk.Schema{ Attributes: map[string]tfsdk.Attribute{ "name_prefix": { diff --git a/ec/ecdatasource/stackdatasource/datasource.go b/ec/ecdatasource/stackdatasource/datasource.go index 200c72f71..22a312ac3 100644 --- a/ec/ecdatasource/stackdatasource/datasource.go +++ b/ec/ecdatasource/stackdatasource/datasource.go @@ -22,35 +22,48 @@ import ( "fmt" "regexp" - "github.com/elastic/cloud-sdk-go/pkg/api/stackapi" - "github.com/elastic/cloud-sdk-go/pkg/models" - "github.com/elastic/terraform-provider-ec/ec/internal" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/diag" - "github.com/hashicorp/terraform-plugin-framework/provider" "github.com/hashicorp/terraform-plugin-framework/tfsdk" "github.com/hashicorp/terraform-plugin-framework/types" -) -var _ provider.DataSourceType = (*DataSourceType)(nil) + "github.com/elastic/cloud-sdk-go/pkg/api" + "github.com/elastic/cloud-sdk-go/pkg/api/stackapi" + "github.com/elastic/cloud-sdk-go/pkg/models" -type DataSourceType struct{} + "github.com/elastic/terraform-provider-ec/ec/internal" +) -func (s DataSourceType) NewDataSource(ctx context.Context, in provider.Provider) (datasource.DataSource, diag.Diagnostics) { - p, diags := internal.ConvertProviderType(in) +var _ datasource.DataSource = &DataSource{} +var _ datasource.DataSourceWithConfigure = &DataSource{} +var _ datasource.DataSourceWithGetSchema = &DataSource{} +var _ datasource.DataSourceWithMetadata = &DataSource{} - return &stackDataSource{ - p: p, - }, diags +type DataSource struct { + client *api.API } -var _ datasource.DataSource = (*stackDataSource)(nil) +func (d *DataSource) Configure(ctx context.Context, request datasource.ConfigureRequest, response *datasource.ConfigureResponse) { + client, diags := internal.ConvertProviderData(request.ProviderData) + response.Diagnostics.Append(diags...) + d.client = client +} -type stackDataSource struct { - p internal.Provider +func (d *DataSource) Metadata(ctx context.Context, request datasource.MetadataRequest, response *datasource.MetadataResponse) { + response.TypeName = request.ProviderTypeName + "_stack" } -func (d stackDataSource) Read(ctx context.Context, request datasource.ReadRequest, response *datasource.ReadResponse) { +func (d DataSource) Read(ctx context.Context, request datasource.ReadRequest, response *datasource.ReadResponse) { + // Prevent panic if the provider has not been configured. + if d.client == nil { + response.Diagnostics.AddError( + "Unconfigured API Client", + "Expected configured API client. Please report this issue to the provider developers.", + ) + + return + } + var newState modelV0 response.Diagnostics.Append(request.Config.Get(ctx, &newState)...) if response.Diagnostics.HasError() { @@ -58,7 +71,7 @@ func (d stackDataSource) Read(ctx context.Context, request datasource.ReadReques } res, err := stackapi.List(stackapi.ListParams{ - API: d.p.GetClient(), + API: d.client, Region: newState.Region.Value, }) if err != nil { diff --git a/ec/ecdatasource/stackdatasource/datasource_test.go b/ec/ecdatasource/stackdatasource/datasource_test.go index f031550ef..23755534e 100644 --- a/ec/ecdatasource/stackdatasource/datasource_test.go +++ b/ec/ecdatasource/stackdatasource/datasource_test.go @@ -21,15 +21,18 @@ import ( "context" "errors" "fmt" - "github.com/elastic/terraform-provider-ec/ec/internal/util" - "github.com/hashicorp/terraform-plugin-framework/attr" - "github.com/hashicorp/terraform-plugin-framework/types" "regexp/syntax" "testing" + "github.com/stretchr/testify/assert" + + "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/elastic/cloud-sdk-go/pkg/models" "github.com/elastic/cloud-sdk-go/pkg/util/ec" - "github.com/stretchr/testify/assert" + + "github.com/elastic/terraform-provider-ec/ec/internal/util" ) func Test_modelToState(t *testing.T) { diff --git a/ec/ecdatasource/stackdatasource/flatteners_apm.go b/ec/ecdatasource/stackdatasource/flatteners_apm.go index 68b3b9f78..194017cbf 100644 --- a/ec/ecdatasource/stackdatasource/flatteners_apm.go +++ b/ec/ecdatasource/stackdatasource/flatteners_apm.go @@ -19,10 +19,12 @@ package stackdatasource import ( "context" - "github.com/elastic/cloud-sdk-go/pkg/models" + "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/tfsdk" "github.com/hashicorp/terraform-plugin-framework/types" + + "github.com/elastic/cloud-sdk-go/pkg/models" ) // flattenStackVersionApmConfig takes a StackVersionApmConfigs and flattens it. diff --git a/ec/ecdatasource/stackdatasource/flatteners_apm_test.go b/ec/ecdatasource/stackdatasource/flatteners_apm_test.go index e12515e61..b55ae794a 100644 --- a/ec/ecdatasource/stackdatasource/flatteners_apm_test.go +++ b/ec/ecdatasource/stackdatasource/flatteners_apm_test.go @@ -19,13 +19,15 @@ package stackdatasource import ( "context" - "github.com/elastic/terraform-provider-ec/ec/internal/util" + "testing" + "github.com/hashicorp/terraform-plugin-framework/types" "github.com/stretchr/testify/assert" - "testing" "github.com/elastic/cloud-sdk-go/pkg/models" "github.com/elastic/cloud-sdk-go/pkg/util/ec" + + "github.com/elastic/terraform-provider-ec/ec/internal/util" ) func Test_flattenApmResource(t *testing.T) { diff --git a/ec/ecdatasource/stackdatasource/flatteners_elasticsearch.go b/ec/ecdatasource/stackdatasource/flatteners_elasticsearch.go index 39e2908a3..15026a434 100644 --- a/ec/ecdatasource/stackdatasource/flatteners_elasticsearch.go +++ b/ec/ecdatasource/stackdatasource/flatteners_elasticsearch.go @@ -19,10 +19,12 @@ package stackdatasource import ( "context" - "github.com/elastic/cloud-sdk-go/pkg/models" + "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/tfsdk" "github.com/hashicorp/terraform-plugin-framework/types" + + "github.com/elastic/cloud-sdk-go/pkg/models" ) // flattenStackVersionElasticsearchConfig takes a StackVersionElasticsearchConfig and flattens it. diff --git a/ec/ecdatasource/stackdatasource/flatteners_elasticsearch_test.go b/ec/ecdatasource/stackdatasource/flatteners_elasticsearch_test.go index 6643db967..75a6b95f5 100644 --- a/ec/ecdatasource/stackdatasource/flatteners_elasticsearch_test.go +++ b/ec/ecdatasource/stackdatasource/flatteners_elasticsearch_test.go @@ -19,13 +19,15 @@ package stackdatasource import ( "context" - "github.com/elastic/terraform-provider-ec/ec/internal/util" + "testing" + "github.com/hashicorp/terraform-plugin-framework/types" "github.com/stretchr/testify/assert" - "testing" "github.com/elastic/cloud-sdk-go/pkg/models" "github.com/elastic/cloud-sdk-go/pkg/util/ec" + + "github.com/elastic/terraform-provider-ec/ec/internal/util" ) func Test_flattenElasticsearchResource(t *testing.T) { diff --git a/ec/ecdatasource/stackdatasource/flatteners_enterprise_search.go b/ec/ecdatasource/stackdatasource/flatteners_enterprise_search.go index fb34b449b..614ad8e17 100644 --- a/ec/ecdatasource/stackdatasource/flatteners_enterprise_search.go +++ b/ec/ecdatasource/stackdatasource/flatteners_enterprise_search.go @@ -19,10 +19,12 @@ package stackdatasource import ( "context" - "github.com/elastic/cloud-sdk-go/pkg/models" + "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/tfsdk" "github.com/hashicorp/terraform-plugin-framework/types" + + "github.com/elastic/cloud-sdk-go/pkg/models" ) // flattenStackVersionEnterpriseSearchConfig takes a StackVersionEnterpriseSearchConfig and flattens it. diff --git a/ec/ecdatasource/stackdatasource/flatteners_enterprise_search_test.go b/ec/ecdatasource/stackdatasource/flatteners_enterprise_search_test.go index a781c3284..426ee8b5e 100644 --- a/ec/ecdatasource/stackdatasource/flatteners_enterprise_search_test.go +++ b/ec/ecdatasource/stackdatasource/flatteners_enterprise_search_test.go @@ -19,13 +19,15 @@ package stackdatasource import ( "context" - "github.com/elastic/terraform-provider-ec/ec/internal/util" + "testing" + "github.com/hashicorp/terraform-plugin-framework/types" "github.com/stretchr/testify/assert" - "testing" "github.com/elastic/cloud-sdk-go/pkg/models" "github.com/elastic/cloud-sdk-go/pkg/util/ec" + + "github.com/elastic/terraform-provider-ec/ec/internal/util" ) func Test_flattenEnterpriseSearchResources(t *testing.T) { diff --git a/ec/ecdatasource/stackdatasource/flatteners_kibana.go b/ec/ecdatasource/stackdatasource/flatteners_kibana.go index 63dfe6680..31060b7f8 100644 --- a/ec/ecdatasource/stackdatasource/flatteners_kibana.go +++ b/ec/ecdatasource/stackdatasource/flatteners_kibana.go @@ -19,10 +19,12 @@ package stackdatasource import ( "context" - "github.com/elastic/cloud-sdk-go/pkg/models" + "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/tfsdk" "github.com/hashicorp/terraform-plugin-framework/types" + + "github.com/elastic/cloud-sdk-go/pkg/models" ) // flattenStackVersionKibanaConfig takes a StackVersionKibanaConfig and flattens it. diff --git a/ec/ecdatasource/stackdatasource/flatteners_kibana_test.go b/ec/ecdatasource/stackdatasource/flatteners_kibana_test.go index b9ca34ec8..78083a172 100644 --- a/ec/ecdatasource/stackdatasource/flatteners_kibana_test.go +++ b/ec/ecdatasource/stackdatasource/flatteners_kibana_test.go @@ -19,13 +19,15 @@ package stackdatasource import ( "context" - "github.com/elastic/terraform-provider-ec/ec/internal/util" + "testing" + "github.com/hashicorp/terraform-plugin-framework/types" "github.com/stretchr/testify/assert" - "testing" "github.com/elastic/cloud-sdk-go/pkg/models" "github.com/elastic/cloud-sdk-go/pkg/util/ec" + + "github.com/elastic/terraform-provider-ec/ec/internal/util" ) func Test_flattenKibanaResources(t *testing.T) { diff --git a/ec/ecdatasource/stackdatasource/schema.go b/ec/ecdatasource/stackdatasource/schema.go index df15bc0dd..9be8f45d9 100644 --- a/ec/ecdatasource/stackdatasource/schema.go +++ b/ec/ecdatasource/stackdatasource/schema.go @@ -19,13 +19,14 @@ package stackdatasource import ( "context" + "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/tfsdk" "github.com/hashicorp/terraform-plugin-framework/types" ) -func (s DataSourceType) GetSchema(ctx context.Context) (tfsdk.Schema, diag.Diagnostics) { +func (d *DataSource) GetSchema(ctx context.Context) (tfsdk.Schema, diag.Diagnostics) { return tfsdk.Schema{ Attributes: map[string]tfsdk.Attribute{ "version_regex": { diff --git a/ec/ecresource/deploymentresource/apm_expanders_test.go b/ec/ecresource/deploymentresource/apm_expanders_test.go index f77d83982..4ecefabe7 100644 --- a/ec/ecresource/deploymentresource/apm_expanders_test.go +++ b/ec/ecresource/deploymentresource/apm_expanders_test.go @@ -21,10 +21,11 @@ import ( "errors" "testing" + "github.com/stretchr/testify/assert" + "github.com/elastic/cloud-sdk-go/pkg/api/mock" "github.com/elastic/cloud-sdk-go/pkg/models" "github.com/elastic/cloud-sdk-go/pkg/util/ec" - "github.com/stretchr/testify/assert" ) func Test_expandApmResources(t *testing.T) { diff --git a/ec/ecresource/deploymentresource/apm_flatteners_test.go b/ec/ecresource/deploymentresource/apm_flatteners_test.go index 68a07428a..94441116b 100644 --- a/ec/ecresource/deploymentresource/apm_flatteners_test.go +++ b/ec/ecresource/deploymentresource/apm_flatteners_test.go @@ -20,10 +20,11 @@ package deploymentresource import ( "testing" + "github.com/stretchr/testify/assert" + "github.com/elastic/cloud-sdk-go/pkg/api/mock" "github.com/elastic/cloud-sdk-go/pkg/models" "github.com/elastic/cloud-sdk-go/pkg/util/ec" - "github.com/stretchr/testify/assert" ) func Test_flattenApmResource(t *testing.T) { diff --git a/ec/ecresource/deploymentresource/create.go b/ec/ecresource/deploymentresource/create.go index e8690d32c..26dfc6377 100644 --- a/ec/ecresource/deploymentresource/create.go +++ b/ec/ecresource/deploymentresource/create.go @@ -21,11 +21,12 @@ import ( "context" "fmt" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/elastic/cloud-sdk-go/pkg/api" "github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi" "github.com/elastic/cloud-sdk-go/pkg/multierror" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) // createResource will createResource a new deployment from the specified settings. diff --git a/ec/ecresource/deploymentresource/delete.go b/ec/ecresource/deploymentresource/delete.go index 8a8a63c97..8ee3c4253 100644 --- a/ec/ecresource/deploymentresource/delete.go +++ b/ec/ecresource/deploymentresource/delete.go @@ -22,13 +22,14 @@ import ( "errors" "strings" + "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/elastic/cloud-sdk-go/pkg/api" "github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi" "github.com/elastic/cloud-sdk-go/pkg/client/deployments" "github.com/elastic/cloud-sdk-go/pkg/multierror" - "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" ) // Delete shuts down and deletes the remote deployment retrying up to 3 times diff --git a/ec/ecresource/deploymentresource/delete_test.go b/ec/ecresource/deploymentresource/delete_test.go index 7dba42c31..b06b1cd0e 100644 --- a/ec/ecresource/deploymentresource/delete_test.go +++ b/ec/ecresource/deploymentresource/delete_test.go @@ -22,12 +22,14 @@ import ( "errors" "testing" + "github.com/stretchr/testify/assert" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/elastic/cloud-sdk-go/pkg/api" "github.com/elastic/cloud-sdk-go/pkg/api/mock" "github.com/elastic/cloud-sdk-go/pkg/multierror" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/stretchr/testify/assert" "github.com/elastic/terraform-provider-ec/ec/internal/util" ) diff --git a/ec/ecresource/deploymentresource/elasticsearch_expanders.go b/ec/ecresource/deploymentresource/elasticsearch_expanders.go index 67c59ef3d..6b3854042 100644 --- a/ec/ecresource/deploymentresource/elasticsearch_expanders.go +++ b/ec/ecresource/deploymentresource/elasticsearch_expanders.go @@ -24,10 +24,11 @@ import ( "strconv" "strings" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi/deploymentsize" "github.com/elastic/cloud-sdk-go/pkg/models" "github.com/elastic/cloud-sdk-go/pkg/util/ec" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/elastic/terraform-provider-ec/ec/internal/util" ) diff --git a/ec/ecresource/deploymentresource/elasticsearch_expanders_test.go b/ec/ecresource/deploymentresource/elasticsearch_expanders_test.go index b30edf8c8..e2f966947 100644 --- a/ec/ecresource/deploymentresource/elasticsearch_expanders_test.go +++ b/ec/ecresource/deploymentresource/elasticsearch_expanders_test.go @@ -21,11 +21,12 @@ import ( "errors" "testing" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/stretchr/testify/assert" + "github.com/elastic/cloud-sdk-go/pkg/api/mock" "github.com/elastic/cloud-sdk-go/pkg/models" "github.com/elastic/cloud-sdk-go/pkg/util/ec" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/stretchr/testify/assert" ) func Test_expandEsResource(t *testing.T) { diff --git a/ec/ecresource/deploymentresource/elasticsearch_flatteners.go b/ec/ecresource/deploymentresource/elasticsearch_flatteners.go index 512edc7d5..538caf172 100644 --- a/ec/ecresource/deploymentresource/elasticsearch_flatteners.go +++ b/ec/ecresource/deploymentresource/elasticsearch_flatteners.go @@ -24,9 +24,10 @@ import ( "sort" "strconv" - "github.com/elastic/cloud-sdk-go/pkg/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/elastic/cloud-sdk-go/pkg/models" + "github.com/elastic/terraform-provider-ec/ec/internal/util" ) diff --git a/ec/ecresource/deploymentresource/elasticsearch_flatteners_test.go b/ec/ecresource/deploymentresource/elasticsearch_flatteners_test.go index 33302f76c..2d0f0c992 100644 --- a/ec/ecresource/deploymentresource/elasticsearch_flatteners_test.go +++ b/ec/ecresource/deploymentresource/elasticsearch_flatteners_test.go @@ -20,11 +20,12 @@ package deploymentresource import ( "testing" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/stretchr/testify/assert" + "github.com/elastic/cloud-sdk-go/pkg/api/mock" "github.com/elastic/cloud-sdk-go/pkg/models" "github.com/elastic/cloud-sdk-go/pkg/util/ec" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/stretchr/testify/assert" ) func Test_flattenEsResource(t *testing.T) { diff --git a/ec/ecresource/deploymentresource/elasticsearch_remote_cluster_expanders.go b/ec/ecresource/deploymentresource/elasticsearch_remote_cluster_expanders.go index be2f2535a..7d01f7782 100644 --- a/ec/ecresource/deploymentresource/elasticsearch_remote_cluster_expanders.go +++ b/ec/ecresource/deploymentresource/elasticsearch_remote_cluster_expanders.go @@ -18,11 +18,12 @@ package deploymentresource import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/elastic/cloud-sdk-go/pkg/api" "github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi/esremoteclustersapi" "github.com/elastic/cloud-sdk-go/pkg/models" "github.com/elastic/cloud-sdk-go/pkg/util/ec" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) func handleRemoteClusters(d *schema.ResourceData, client *api.API) error { diff --git a/ec/ecresource/deploymentresource/elasticsearch_remote_cluster_expanders_test.go b/ec/ecresource/deploymentresource/elasticsearch_remote_cluster_expanders_test.go index a79adaaee..c069aa03b 100644 --- a/ec/ecresource/deploymentresource/elasticsearch_remote_cluster_expanders_test.go +++ b/ec/ecresource/deploymentresource/elasticsearch_remote_cluster_expanders_test.go @@ -20,12 +20,13 @@ package deploymentresource import ( "testing" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/stretchr/testify/assert" + "github.com/elastic/cloud-sdk-go/pkg/api" "github.com/elastic/cloud-sdk-go/pkg/api/mock" "github.com/elastic/cloud-sdk-go/pkg/models" "github.com/elastic/cloud-sdk-go/pkg/util/ec" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/stretchr/testify/assert" "github.com/elastic/terraform-provider-ec/ec/internal/util" ) diff --git a/ec/ecresource/deploymentresource/enterprise_search_expanders_test.go b/ec/ecresource/deploymentresource/enterprise_search_expanders_test.go index 3385c6526..b70375a4f 100644 --- a/ec/ecresource/deploymentresource/enterprise_search_expanders_test.go +++ b/ec/ecresource/deploymentresource/enterprise_search_expanders_test.go @@ -21,10 +21,11 @@ import ( "errors" "testing" + "github.com/stretchr/testify/assert" + "github.com/elastic/cloud-sdk-go/pkg/api/mock" "github.com/elastic/cloud-sdk-go/pkg/models" "github.com/elastic/cloud-sdk-go/pkg/util/ec" - "github.com/stretchr/testify/assert" ) func Test_expandEssResources(t *testing.T) { diff --git a/ec/ecresource/deploymentresource/enterprise_search_flatteners_test.go b/ec/ecresource/deploymentresource/enterprise_search_flatteners_test.go index eb70eb6c7..69d725de7 100644 --- a/ec/ecresource/deploymentresource/enterprise_search_flatteners_test.go +++ b/ec/ecresource/deploymentresource/enterprise_search_flatteners_test.go @@ -20,10 +20,11 @@ package deploymentresource import ( "testing" + "github.com/stretchr/testify/assert" + "github.com/elastic/cloud-sdk-go/pkg/api/mock" "github.com/elastic/cloud-sdk-go/pkg/models" "github.com/elastic/cloud-sdk-go/pkg/util/ec" - "github.com/stretchr/testify/assert" ) func Test_flattenEssResource(t *testing.T) { diff --git a/ec/ecresource/deploymentresource/expanders.go b/ec/ecresource/deploymentresource/expanders.go index 1f4048179..108fb7e9d 100644 --- a/ec/ecresource/deploymentresource/expanders.go +++ b/ec/ecresource/deploymentresource/expanders.go @@ -21,13 +21,14 @@ import ( "fmt" "sort" - semver "github.com/blang/semver/v4" + "github.com/blang/semver/v4" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/elastic/cloud-sdk-go/pkg/api" "github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi/deptemplateapi" "github.com/elastic/cloud-sdk-go/pkg/models" "github.com/elastic/cloud-sdk-go/pkg/multierror" "github.com/elastic/cloud-sdk-go/pkg/util/ec" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/elastic/terraform-provider-ec/ec/internal/util" ) diff --git a/ec/ecresource/deploymentresource/expanders_test.go b/ec/ecresource/deploymentresource/expanders_test.go index 9e60fe7ee..51d07c2f6 100644 --- a/ec/ecresource/deploymentresource/expanders_test.go +++ b/ec/ecresource/deploymentresource/expanders_test.go @@ -24,13 +24,14 @@ import ( "os" "testing" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/stretchr/testify/assert" + "github.com/elastic/cloud-sdk-go/pkg/api" "github.com/elastic/cloud-sdk-go/pkg/api/mock" "github.com/elastic/cloud-sdk-go/pkg/models" "github.com/elastic/cloud-sdk-go/pkg/multierror" "github.com/elastic/cloud-sdk-go/pkg/util/ec" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/stretchr/testify/assert" "github.com/elastic/terraform-provider-ec/ec/internal/util" ) diff --git a/ec/ecresource/deploymentresource/flatteners.go b/ec/ecresource/deploymentresource/flatteners.go index 86c6cbaaf..91aa467d0 100644 --- a/ec/ecresource/deploymentresource/flatteners.go +++ b/ec/ecresource/deploymentresource/flatteners.go @@ -22,10 +22,11 @@ import ( "fmt" "strings" - semver "github.com/blang/semver/v4" + "github.com/blang/semver/v4" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/elastic/cloud-sdk-go/pkg/models" "github.com/elastic/cloud-sdk-go/pkg/multierror" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/elastic/terraform-provider-ec/ec/internal/util" ) diff --git a/ec/ecresource/deploymentresource/flatteners_test.go b/ec/ecresource/deploymentresource/flatteners_test.go index 8b4400fb8..b268cd67a 100644 --- a/ec/ecresource/deploymentresource/flatteners_test.go +++ b/ec/ecresource/deploymentresource/flatteners_test.go @@ -21,11 +21,12 @@ import ( "errors" "testing" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/stretchr/testify/assert" + "github.com/elastic/cloud-sdk-go/pkg/api/mock" "github.com/elastic/cloud-sdk-go/pkg/models" "github.com/elastic/cloud-sdk-go/pkg/util/ec" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/stretchr/testify/assert" "github.com/elastic/terraform-provider-ec/ec/internal/util" ) diff --git a/ec/ecresource/deploymentresource/import.go b/ec/ecresource/deploymentresource/import.go index f685cfa9d..a12a7762e 100644 --- a/ec/ecresource/deploymentresource/import.go +++ b/ec/ecresource/deploymentresource/import.go @@ -22,7 +22,8 @@ import ( "errors" "fmt" - semver "github.com/blang/semver/v4" + "github.com/blang/semver/v4" + "github.com/elastic/cloud-sdk-go/pkg/api" "github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi" "github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi/deputil" diff --git a/ec/ecresource/deploymentresource/import_test.go b/ec/ecresource/deploymentresource/import_test.go index f8e631ff0..6766e7ebb 100644 --- a/ec/ecresource/deploymentresource/import_test.go +++ b/ec/ecresource/deploymentresource/import_test.go @@ -22,11 +22,12 @@ import ( "errors" "testing" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/stretchr/testify/assert" + "github.com/elastic/cloud-sdk-go/pkg/api" "github.com/elastic/cloud-sdk-go/pkg/api/mock" "github.com/elastic/cloud-sdk-go/pkg/models" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/stretchr/testify/assert" "github.com/elastic/terraform-provider-ec/ec/internal/util" ) diff --git a/ec/ecresource/deploymentresource/integrations_server_expanders_test.go b/ec/ecresource/deploymentresource/integrations_server_expanders_test.go index 90f3acdf3..76d2b84b2 100644 --- a/ec/ecresource/deploymentresource/integrations_server_expanders_test.go +++ b/ec/ecresource/deploymentresource/integrations_server_expanders_test.go @@ -21,10 +21,11 @@ import ( "errors" "testing" + "github.com/stretchr/testify/assert" + "github.com/elastic/cloud-sdk-go/pkg/api/mock" "github.com/elastic/cloud-sdk-go/pkg/models" "github.com/elastic/cloud-sdk-go/pkg/util/ec" - "github.com/stretchr/testify/assert" ) func Test_expandIntegrationsServerResources(t *testing.T) { diff --git a/ec/ecresource/deploymentresource/integrations_server_flatteners_test.go b/ec/ecresource/deploymentresource/integrations_server_flatteners_test.go index 9ae0ec20c..3791ae26d 100644 --- a/ec/ecresource/deploymentresource/integrations_server_flatteners_test.go +++ b/ec/ecresource/deploymentresource/integrations_server_flatteners_test.go @@ -20,10 +20,11 @@ package deploymentresource import ( "testing" + "github.com/stretchr/testify/assert" + "github.com/elastic/cloud-sdk-go/pkg/api/mock" "github.com/elastic/cloud-sdk-go/pkg/models" "github.com/elastic/cloud-sdk-go/pkg/util/ec" - "github.com/stretchr/testify/assert" ) func Test_flattenIntegrationsServerResource(t *testing.T) { diff --git a/ec/ecresource/deploymentresource/kibana_expanders_test.go b/ec/ecresource/deploymentresource/kibana_expanders_test.go index 66115f3fc..02a0a8f17 100644 --- a/ec/ecresource/deploymentresource/kibana_expanders_test.go +++ b/ec/ecresource/deploymentresource/kibana_expanders_test.go @@ -21,10 +21,11 @@ import ( "errors" "testing" + "github.com/stretchr/testify/assert" + "github.com/elastic/cloud-sdk-go/pkg/api/mock" "github.com/elastic/cloud-sdk-go/pkg/models" "github.com/elastic/cloud-sdk-go/pkg/util/ec" - "github.com/stretchr/testify/assert" ) func Test_expandKibanaResources(t *testing.T) { diff --git a/ec/ecresource/deploymentresource/kibana_flatteners_test.go b/ec/ecresource/deploymentresource/kibana_flatteners_test.go index 48b1a105a..0cd409805 100644 --- a/ec/ecresource/deploymentresource/kibana_flatteners_test.go +++ b/ec/ecresource/deploymentresource/kibana_flatteners_test.go @@ -20,10 +20,11 @@ package deploymentresource import ( "testing" + "github.com/stretchr/testify/assert" + "github.com/elastic/cloud-sdk-go/pkg/api/mock" "github.com/elastic/cloud-sdk-go/pkg/models" "github.com/elastic/cloud-sdk-go/pkg/util/ec" - "github.com/stretchr/testify/assert" ) func Test_flattenKibanaResources(t *testing.T) { diff --git a/ec/ecresource/deploymentresource/observability_test.go b/ec/ecresource/deploymentresource/observability_test.go index 96ab053fb..f7119f4ab 100644 --- a/ec/ecresource/deploymentresource/observability_test.go +++ b/ec/ecresource/deploymentresource/observability_test.go @@ -20,11 +20,12 @@ package deploymentresource import ( "testing" + "github.com/stretchr/testify/assert" + "github.com/elastic/cloud-sdk-go/pkg/api" "github.com/elastic/cloud-sdk-go/pkg/api/mock" "github.com/elastic/cloud-sdk-go/pkg/models" "github.com/elastic/cloud-sdk-go/pkg/util/ec" - "github.com/stretchr/testify/assert" ) func TestFlattenObservability(t *testing.T) { diff --git a/ec/ecresource/deploymentresource/read.go b/ec/ecresource/deploymentresource/read.go index 088645d88..8b0145df3 100644 --- a/ec/ecresource/deploymentresource/read.go +++ b/ec/ecresource/deploymentresource/read.go @@ -21,6 +21,9 @@ import ( "context" "errors" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/elastic/cloud-sdk-go/pkg/api" "github.com/elastic/cloud-sdk-go/pkg/api/apierror" "github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi" @@ -29,8 +32,6 @@ import ( "github.com/elastic/cloud-sdk-go/pkg/client/deployments" "github.com/elastic/cloud-sdk-go/pkg/models" "github.com/elastic/cloud-sdk-go/pkg/multierror" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) // Read queries the remote deployment state and updates the local state. diff --git a/ec/ecresource/deploymentresource/read_test.go b/ec/ecresource/deploymentresource/read_test.go index afdf2f1b4..b54ff5523 100644 --- a/ec/ecresource/deploymentresource/read_test.go +++ b/ec/ecresource/deploymentresource/read_test.go @@ -21,16 +21,18 @@ import ( "context" "testing" + "github.com/go-openapi/runtime" + "github.com/stretchr/testify/assert" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/elastic/cloud-sdk-go/pkg/api" "github.com/elastic/cloud-sdk-go/pkg/api/apierror" "github.com/elastic/cloud-sdk-go/pkg/api/mock" "github.com/elastic/cloud-sdk-go/pkg/client/deployments" "github.com/elastic/cloud-sdk-go/pkg/models" "github.com/elastic/cloud-sdk-go/pkg/util/ec" - "github.com/go-openapi/runtime" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/stretchr/testify/assert" "github.com/elastic/terraform-provider-ec/ec/internal/util" ) diff --git a/ec/ecresource/deploymentresource/schema_elasticsearch.go b/ec/ecresource/deploymentresource/schema_elasticsearch.go index 0a460fd45..5bd75ff94 100644 --- a/ec/ecresource/deploymentresource/schema_elasticsearch.go +++ b/ec/ecresource/deploymentresource/schema_elasticsearch.go @@ -23,9 +23,10 @@ import ( "strconv" "strings" - "github.com/elastic/cloud-sdk-go/pkg/util/slice" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" + + "github.com/elastic/cloud-sdk-go/pkg/util/slice" ) func newElasticsearchResource() *schema.Resource { diff --git a/ec/ecresource/deploymentresource/stopped_resource_test.go b/ec/ecresource/deploymentresource/stopped_resource_test.go index 6b987a49f..bd2bb0ae3 100644 --- a/ec/ecresource/deploymentresource/stopped_resource_test.go +++ b/ec/ecresource/deploymentresource/stopped_resource_test.go @@ -20,9 +20,10 @@ package deploymentresource import ( "testing" + "github.com/stretchr/testify/assert" + "github.com/elastic/cloud-sdk-go/pkg/models" "github.com/elastic/cloud-sdk-go/pkg/util/ec" - "github.com/stretchr/testify/assert" ) func Test_isApmResourceStopped(t *testing.T) { diff --git a/ec/ecresource/deploymentresource/testutil_func.go b/ec/ecresource/deploymentresource/testutil_func.go index c81799e72..bcaae5251 100644 --- a/ec/ecresource/deploymentresource/testutil_func.go +++ b/ec/ecresource/deploymentresource/testutil_func.go @@ -23,8 +23,9 @@ import ( "os" "testing" - "github.com/elastic/cloud-sdk-go/pkg/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + + "github.com/elastic/cloud-sdk-go/pkg/models" ) // parseDeploymentTemplate is a test helper which parse a file by path and diff --git a/ec/ecresource/deploymentresource/testutil_func_test.go b/ec/ecresource/deploymentresource/testutil_func_test.go index 1d07eff67..e9210f5ba 100644 --- a/ec/ecresource/deploymentresource/testutil_func_test.go +++ b/ec/ecresource/deploymentresource/testutil_func_test.go @@ -21,9 +21,10 @@ import ( "os" "testing" + "github.com/stretchr/testify/assert" + "github.com/elastic/cloud-sdk-go/pkg/models" "github.com/elastic/cloud-sdk-go/pkg/util/ec" - "github.com/stretchr/testify/assert" ) func Test_parseDeploymentTemplate(t *testing.T) { diff --git a/ec/ecresource/deploymentresource/traffic_filter.go b/ec/ecresource/deploymentresource/traffic_filter.go index 835bab808..a2c1f0c58 100644 --- a/ec/ecresource/deploymentresource/traffic_filter.go +++ b/ec/ecresource/deploymentresource/traffic_filter.go @@ -18,9 +18,10 @@ package deploymentresource import ( - "github.com/elastic/cloud-sdk-go/pkg/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/elastic/cloud-sdk-go/pkg/models" + "github.com/elastic/terraform-provider-ec/ec/internal/util" ) diff --git a/ec/ecresource/deploymentresource/traffic_filter_test.go b/ec/ecresource/deploymentresource/traffic_filter_test.go index 36ace0b6a..506cc762e 100644 --- a/ec/ecresource/deploymentresource/traffic_filter_test.go +++ b/ec/ecresource/deploymentresource/traffic_filter_test.go @@ -20,9 +20,10 @@ package deploymentresource import ( "testing" - "github.com/elastic/cloud-sdk-go/pkg/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/stretchr/testify/assert" + + "github.com/elastic/cloud-sdk-go/pkg/models" ) func TestParseTrafficFiltering(t *testing.T) { diff --git a/ec/ecresource/deploymentresource/update.go b/ec/ecresource/deploymentresource/update.go index 26f33ab53..9fae24ab6 100644 --- a/ec/ecresource/deploymentresource/update.go +++ b/ec/ecresource/deploymentresource/update.go @@ -21,11 +21,12 @@ import ( "context" "strings" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/elastic/cloud-sdk-go/pkg/api" "github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi" "github.com/elastic/cloud-sdk-go/pkg/multierror" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) // Update syncs the remote state with the local. diff --git a/ec/ecresource/deploymentresource/update_test.go b/ec/ecresource/deploymentresource/update_test.go index e0d6c9d4a..92d205cdf 100644 --- a/ec/ecresource/deploymentresource/update_test.go +++ b/ec/ecresource/deploymentresource/update_test.go @@ -20,10 +20,11 @@ package deploymentresource import ( "testing" - "github.com/elastic/cloud-sdk-go/pkg/api/mock" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/stretchr/testify/assert" + "github.com/elastic/cloud-sdk-go/pkg/api/mock" + "github.com/elastic/terraform-provider-ec/ec/internal/util" ) diff --git a/ec/ecresource/deploymentresource/update_traffic_rules.go b/ec/ecresource/deploymentresource/update_traffic_rules.go index 3bf66d60b..f39d47c83 100644 --- a/ec/ecresource/deploymentresource/update_traffic_rules.go +++ b/ec/ecresource/deploymentresource/update_traffic_rules.go @@ -18,9 +18,10 @@ package deploymentresource import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/elastic/cloud-sdk-go/pkg/api" "github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi/trafficfilterapi" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/elastic/terraform-provider-ec/ec/internal/util" ) diff --git a/ec/ecresource/elasticsearchkeystoreresource/create.go b/ec/ecresource/elasticsearchkeystoreresource/create.go index bade94c14..0ac5dc644 100644 --- a/ec/ecresource/elasticsearchkeystoreresource/create.go +++ b/ec/ecresource/elasticsearchkeystoreresource/create.go @@ -22,10 +22,11 @@ import ( "strconv" "strings" - "github.com/elastic/cloud-sdk-go/pkg/api" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/elastic/cloud-sdk-go/pkg/api" + "github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi/eskeystoreapi" ) diff --git a/ec/ecresource/elasticsearchkeystoreresource/delete.go b/ec/ecresource/elasticsearchkeystoreresource/delete.go index b6c6d7e63..ae951e4bc 100644 --- a/ec/ecresource/elasticsearchkeystoreresource/delete.go +++ b/ec/ecresource/elasticsearchkeystoreresource/delete.go @@ -20,10 +20,11 @@ package elasticsearchkeystoreresource import ( "context" - "github.com/elastic/cloud-sdk-go/pkg/api" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/elastic/cloud-sdk-go/pkg/api" + "github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi/eskeystoreapi" ) diff --git a/ec/ecresource/elasticsearchkeystoreresource/expanders.go b/ec/ecresource/elasticsearchkeystoreresource/expanders.go index 9ed695f8b..74dd423e2 100644 --- a/ec/ecresource/elasticsearchkeystoreresource/expanders.go +++ b/ec/ecresource/elasticsearchkeystoreresource/expanders.go @@ -20,9 +20,10 @@ package elasticsearchkeystoreresource import ( "encoding/json" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/elastic/cloud-sdk-go/pkg/models" "github.com/elastic/cloud-sdk-go/pkg/util/ec" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) func expandModel(d *schema.ResourceData) *models.KeystoreContents { diff --git a/ec/ecresource/elasticsearchkeystoreresource/expanders_test.go b/ec/ecresource/elasticsearchkeystoreresource/expanders_test.go index a1ebe37f8..6cc4a12cb 100644 --- a/ec/ecresource/elasticsearchkeystoreresource/expanders_test.go +++ b/ec/ecresource/elasticsearchkeystoreresource/expanders_test.go @@ -20,11 +20,12 @@ package elasticsearchkeystoreresource import ( "testing" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/stretchr/testify/assert" + "github.com/elastic/cloud-sdk-go/pkg/api/mock" "github.com/elastic/cloud-sdk-go/pkg/models" "github.com/elastic/cloud-sdk-go/pkg/util/ec" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/stretchr/testify/assert" ) func Test_expandModel(t *testing.T) { diff --git a/ec/ecresource/elasticsearchkeystoreresource/read.go b/ec/ecresource/elasticsearchkeystoreresource/read.go index beec83b44..a6710b384 100644 --- a/ec/ecresource/elasticsearchkeystoreresource/read.go +++ b/ec/ecresource/elasticsearchkeystoreresource/read.go @@ -20,11 +20,12 @@ package elasticsearchkeystoreresource import ( "context" - "github.com/elastic/cloud-sdk-go/pkg/api" - "github.com/elastic/cloud-sdk-go/pkg/models" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/elastic/cloud-sdk-go/pkg/api" + "github.com/elastic/cloud-sdk-go/pkg/models" + "github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi/eskeystoreapi" ) diff --git a/ec/ecresource/elasticsearchkeystoreresource/read_test.go b/ec/ecresource/elasticsearchkeystoreresource/read_test.go index e8b568d9e..2791e43ca 100644 --- a/ec/ecresource/elasticsearchkeystoreresource/read_test.go +++ b/ec/ecresource/elasticsearchkeystoreresource/read_test.go @@ -20,11 +20,12 @@ package elasticsearchkeystoreresource import ( "testing" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/stretchr/testify/assert" + "github.com/elastic/cloud-sdk-go/pkg/api/mock" "github.com/elastic/cloud-sdk-go/pkg/models" "github.com/elastic/cloud-sdk-go/pkg/util/ec" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/stretchr/testify/assert" ) func Test_modelToState(t *testing.T) { diff --git a/ec/ecresource/elasticsearchkeystoreresource/update.go b/ec/ecresource/elasticsearchkeystoreresource/update.go index 2cc190a5e..46873b645 100644 --- a/ec/ecresource/elasticsearchkeystoreresource/update.go +++ b/ec/ecresource/elasticsearchkeystoreresource/update.go @@ -20,10 +20,11 @@ package elasticsearchkeystoreresource import ( "context" - "github.com/elastic/cloud-sdk-go/pkg/api" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/elastic/cloud-sdk-go/pkg/api" + "github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi/eskeystoreapi" ) diff --git a/ec/ecresource/extensionresource/create.go b/ec/ecresource/extensionresource/create.go index cd5421e6c..159a47062 100644 --- a/ec/ecresource/extensionresource/create.go +++ b/ec/ecresource/extensionresource/create.go @@ -20,12 +20,13 @@ package extensionresource import ( "context" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/elastic/cloud-sdk-go/pkg/api" "github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi/extensionapi" "github.com/elastic/cloud-sdk-go/pkg/models" "github.com/elastic/cloud-sdk-go/pkg/multierror" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) // createResource will create a new deployment extension diff --git a/ec/ecresource/extensionresource/create_test.go b/ec/ecresource/extensionresource/create_test.go index 2c33b134f..78e527871 100644 --- a/ec/ecresource/extensionresource/create_test.go +++ b/ec/ecresource/extensionresource/create_test.go @@ -21,11 +21,13 @@ import ( "context" "testing" - "github.com/elastic/cloud-sdk-go/pkg/api" - "github.com/elastic/cloud-sdk-go/pkg/api/mock" + "github.com/stretchr/testify/assert" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/stretchr/testify/assert" + + "github.com/elastic/cloud-sdk-go/pkg/api" + "github.com/elastic/cloud-sdk-go/pkg/api/mock" "github.com/elastic/terraform-provider-ec/ec/internal/util" ) diff --git a/ec/ecresource/extensionresource/delete.go b/ec/ecresource/extensionresource/delete.go index d8ab87ba1..07152fa9c 100644 --- a/ec/ecresource/extensionresource/delete.go +++ b/ec/ecresource/extensionresource/delete.go @@ -21,11 +21,12 @@ import ( "context" "errors" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/elastic/cloud-sdk-go/pkg/api" "github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi/extensionapi" "github.com/elastic/cloud-sdk-go/pkg/client/extensions" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) func deleteResource(_ context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { diff --git a/ec/ecresource/extensionresource/delete_test.go b/ec/ecresource/extensionresource/delete_test.go index b8f2af718..3e5c615b4 100644 --- a/ec/ecresource/extensionresource/delete_test.go +++ b/ec/ecresource/extensionresource/delete_test.go @@ -21,11 +21,13 @@ import ( "context" "testing" - "github.com/elastic/cloud-sdk-go/pkg/api" - "github.com/elastic/cloud-sdk-go/pkg/api/mock" + "github.com/stretchr/testify/assert" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/stretchr/testify/assert" + + "github.com/elastic/cloud-sdk-go/pkg/api" + "github.com/elastic/cloud-sdk-go/pkg/api/mock" "github.com/elastic/terraform-provider-ec/ec/internal/util" ) diff --git a/ec/ecresource/extensionresource/read.go b/ec/ecresource/extensionresource/read.go index 146d5c6bb..05624fc4f 100644 --- a/ec/ecresource/extensionresource/read.go +++ b/ec/ecresource/extensionresource/read.go @@ -21,13 +21,14 @@ import ( "context" "errors" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/elastic/cloud-sdk-go/pkg/api" "github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi/extensionapi" "github.com/elastic/cloud-sdk-go/pkg/client/extensions" "github.com/elastic/cloud-sdk-go/pkg/models" "github.com/elastic/cloud-sdk-go/pkg/multierror" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) func readResource(_ context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { diff --git a/ec/ecresource/extensionresource/read_test.go b/ec/ecresource/extensionresource/read_test.go index ae45c80a7..827518986 100644 --- a/ec/ecresource/extensionresource/read_test.go +++ b/ec/ecresource/extensionresource/read_test.go @@ -22,15 +22,15 @@ import ( "testing" "github.com/go-openapi/strfmt" + "github.com/stretchr/testify/assert" - "github.com/elastic/cloud-sdk-go/pkg/util/ec" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/elastic/cloud-sdk-go/pkg/api" "github.com/elastic/cloud-sdk-go/pkg/api/mock" "github.com/elastic/cloud-sdk-go/pkg/models" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/stretchr/testify/assert" + "github.com/elastic/cloud-sdk-go/pkg/util/ec" "github.com/elastic/terraform-provider-ec/ec/internal/util" ) diff --git a/ec/ecresource/extensionresource/update.go b/ec/ecresource/extensionresource/update.go index cc2161f15..613f0a780 100644 --- a/ec/ecresource/extensionresource/update.go +++ b/ec/ecresource/extensionresource/update.go @@ -20,12 +20,13 @@ package extensionresource import ( "context" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/elastic/cloud-sdk-go/pkg/api" "github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi/extensionapi" "github.com/elastic/cloud-sdk-go/pkg/models" "github.com/elastic/cloud-sdk-go/pkg/multierror" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) func updateResource(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { diff --git a/ec/ecresource/extensionresource/update_test.go b/ec/ecresource/extensionresource/update_test.go index 0970a0322..6c42b610f 100644 --- a/ec/ecresource/extensionresource/update_test.go +++ b/ec/ecresource/extensionresource/update_test.go @@ -21,14 +21,16 @@ import ( "context" "testing" + "github.com/go-openapi/strfmt" + "github.com/stretchr/testify/assert" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/elastic/cloud-sdk-go/pkg/api" "github.com/elastic/cloud-sdk-go/pkg/api/mock" "github.com/elastic/cloud-sdk-go/pkg/models" "github.com/elastic/cloud-sdk-go/pkg/util/ec" - "github.com/go-openapi/strfmt" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/stretchr/testify/assert" "github.com/elastic/terraform-provider-ec/ec/internal/util" ) diff --git a/ec/ecresource/extensionresource/upload.go b/ec/ecresource/extensionresource/upload.go index 18fc7ebbb..d05851575 100644 --- a/ec/ecresource/extensionresource/upload.go +++ b/ec/ecresource/extensionresource/upload.go @@ -20,10 +20,11 @@ package extensionresource import ( "os" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/elastic/cloud-sdk-go/pkg/api" "github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi/extensionapi" "github.com/elastic/cloud-sdk-go/pkg/multierror" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) func uploadExtension(client *api.API, d *schema.ResourceData) error { diff --git a/ec/ecresource/trafficfilterassocresource/create.go b/ec/ecresource/trafficfilterassocresource/create.go index 7c2946995..3046ab256 100644 --- a/ec/ecresource/trafficfilterassocresource/create.go +++ b/ec/ecresource/trafficfilterassocresource/create.go @@ -20,12 +20,24 @@ package trafficfilterassocresource import ( "context" "fmt" - "github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi/trafficfilterapi" + "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-framework/types" + + "github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi/trafficfilterapi" ) -func (t trafficFilterAssocResource) Create(ctx context.Context, request resource.CreateRequest, response *resource.CreateResponse) { +func (r Resource) Create(ctx context.Context, request resource.CreateRequest, response *resource.CreateResponse) { + // Prevent panic if the provider has not been configured. + if r.client == nil { + response.Diagnostics.AddError( + "Unconfigured API Client", + "Expected configured API client. Please report this issue to the provider developers.", + ) + + return + } + var newState modelV0 diags := request.Plan.Get(ctx, &newState) @@ -35,7 +47,7 @@ func (t trafficFilterAssocResource) Create(ctx context.Context, request resource } if err := trafficfilterapi.CreateAssociation(trafficfilterapi.CreateAssociationParams{ - API: t.provider.GetClient(), + API: r.client, ID: newState.TrafficFilterID.Value, EntityID: newState.DeploymentID.Value, EntityType: entityTypeDeployment, diff --git a/ec/ecresource/trafficfilterassocresource/delete.go b/ec/ecresource/trafficfilterassocresource/delete.go index 8d4103b55..0f2b2233d 100644 --- a/ec/ecresource/trafficfilterassocresource/delete.go +++ b/ec/ecresource/trafficfilterassocresource/delete.go @@ -20,12 +20,24 @@ package trafficfilterassocresource import ( "context" "errors" + + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi/trafficfilterapi" "github.com/elastic/cloud-sdk-go/pkg/client/deployments_traffic_filter" - "github.com/hashicorp/terraform-plugin-framework/resource" ) -func (t trafficFilterAssocResource) Delete(ctx context.Context, request resource.DeleteRequest, response *resource.DeleteResponse) { +func (r Resource) Delete(ctx context.Context, request resource.DeleteRequest, response *resource.DeleteResponse) { + // Prevent panic if the provider has not been configured. + if r.client == nil { + response.Diagnostics.AddError( + "Unconfigured API Client", + "Expected configured API client. Please report this issue to the provider developers.", + ) + + return + } + var state modelV0 diags := request.State.Get(ctx, &state) @@ -35,7 +47,7 @@ func (t trafficFilterAssocResource) Delete(ctx context.Context, request resource } if err := trafficfilterapi.DeleteAssociation(trafficfilterapi.DeleteAssociationParams{ - API: t.provider.GetClient(), + API: r.client, ID: state.TrafficFilterID.Value, EntityID: state.DeploymentID.Value, EntityType: entityTypeDeployment, diff --git a/ec/ecresource/trafficfilterassocresource/import_state.go b/ec/ecresource/trafficfilterassocresource/import_state.go index 22d8c3e30..1c1c3cb1d 100644 --- a/ec/ecresource/trafficfilterassocresource/import_state.go +++ b/ec/ecresource/trafficfilterassocresource/import_state.go @@ -20,12 +20,13 @@ package trafficfilterassocresource import ( "context" "fmt" + "strings" + "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource" - "strings" ) -func (t trafficFilterAssocResource) ImportState(ctx context.Context, request resource.ImportStateRequest, response *resource.ImportStateResponse) { +func (r Resource) ImportState(ctx context.Context, request resource.ImportStateRequest, response *resource.ImportStateResponse) { idParts := strings.Split(request.ID, ",") if len(idParts) != 2 || idParts[0] == "" || idParts[1] == "" { diff --git a/ec/ecresource/trafficfilterassocresource/read.go b/ec/ecresource/trafficfilterassocresource/read.go index 31a901b1e..633f34be3 100644 --- a/ec/ecresource/trafficfilterassocresource/read.go +++ b/ec/ecresource/trafficfilterassocresource/read.go @@ -19,12 +19,25 @@ package trafficfilterassocresource import ( "context" + + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi/trafficfilterapi" + "github.com/elastic/terraform-provider-ec/ec/internal/util" - "github.com/hashicorp/terraform-plugin-framework/resource" ) -func (t trafficFilterAssocResource) Read(ctx context.Context, request resource.ReadRequest, response *resource.ReadResponse) { +func (r Resource) Read(ctx context.Context, request resource.ReadRequest, response *resource.ReadResponse) { + // Prevent panic if the provider has not been configured. + if r.client == nil { + response.Diagnostics.AddError( + "Unconfigured API Client", + "Expected configured API client. Please report this issue to the provider developers.", + ) + + return + } + var state modelV0 diags := request.State.Get(ctx, &state) @@ -34,7 +47,7 @@ func (t trafficFilterAssocResource) Read(ctx context.Context, request resource.R } res, err := trafficfilterapi.Get(trafficfilterapi.GetParams{ - API: t.provider.GetClient(), + API: r.client, ID: state.TrafficFilterID.Value, IncludeAssociations: true, }) diff --git a/ec/ecresource/trafficfilterassocresource/resource_test.go b/ec/ecresource/trafficfilterassocresource/resource_test.go index 8b64425d3..ca254494e 100644 --- a/ec/ecresource/trafficfilterassocresource/resource_test.go +++ b/ec/ecresource/trafficfilterassocresource/resource_test.go @@ -18,16 +18,18 @@ package trafficfilterassocresource_test import ( - "github.com/elastic/cloud-sdk-go/pkg/api" - "github.com/elastic/cloud-sdk-go/pkg/api/mock" - "github.com/elastic/terraform-provider-ec/ec" - "github.com/hashicorp/terraform-plugin-framework/providerserver" - "github.com/hashicorp/terraform-plugin-go/tfprotov5" "net/url" "regexp" "testing" + "github.com/hashicorp/terraform-plugin-framework/providerserver" + "github.com/hashicorp/terraform-plugin-go/tfprotov5" r "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + + "github.com/elastic/cloud-sdk-go/pkg/api" + "github.com/elastic/cloud-sdk-go/pkg/api/mock" + + "github.com/elastic/terraform-provider-ec/ec" ) func TestResourceTrafficFilterAssoc(t *testing.T) { diff --git a/ec/ecresource/trafficfilterassocresource/schema.go b/ec/ecresource/trafficfilterassocresource/schema.go index bd0460d84..84f1e3f7e 100644 --- a/ec/ecresource/trafficfilterassocresource/schema.go +++ b/ec/ecresource/trafficfilterassocresource/schema.go @@ -19,25 +19,29 @@ package trafficfilterassocresource import ( "context" - "github.com/elastic/terraform-provider-ec/ec/internal" + "github.com/hashicorp/terraform-plugin-framework/diag" - tpfprovider "github.com/hashicorp/terraform-plugin-framework/provider" "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-framework/tfsdk" "github.com/hashicorp/terraform-plugin-framework/types" + + "github.com/elastic/cloud-sdk-go/pkg/api" + + "github.com/elastic/terraform-provider-ec/ec/internal" ) // Ensure provider defined types fully satisfy framework interfaces -var _ tpfprovider.ResourceType = ResourceType{} -var _ resource.Resource = trafficFilterAssocResource{} - -var _ resource.ResourceWithImportState = trafficFilterAssocResource{} +var _ resource.Resource = &Resource{} +var _ resource.ResourceWithConfigure = &Resource{} +var _ resource.ResourceWithGetSchema = &Resource{} +var _ resource.ResourceWithImportState = &Resource{} +var _ resource.ResourceWithMetadata = &Resource{} type ResourceType struct{} const entityTypeDeployment = "deployment" -func (t ResourceType) GetSchema(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { +func (r *Resource) GetSchema(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return tfsdk.Schema{ Attributes: map[string]tfsdk.Attribute{ "deployment_id": { @@ -66,16 +70,18 @@ func (t ResourceType) GetSchema(_ context.Context) (tfsdk.Schema, diag.Diagnosti }, nil } -func (t ResourceType) NewResource(_ context.Context, provider tpfprovider.Provider) (resource.Resource, diag.Diagnostics) { - p, diags := internal.ConvertProviderType(provider) +type Resource struct { + client *api.API +} - return &trafficFilterAssocResource{ - provider: p, - }, diags +func (r *Resource) Configure(ctx context.Context, request resource.ConfigureRequest, response *resource.ConfigureResponse) { + client, diags := internal.ConvertProviderData(request.ProviderData) + response.Diagnostics.Append(diags...) + r.client = client } -type trafficFilterAssocResource struct { - provider internal.Provider +func (r *Resource) Metadata(ctx context.Context, request resource.MetadataRequest, response *resource.MetadataResponse) { + response.TypeName = request.ProviderTypeName + "_deployment_traffic_filter_association" } type modelV0 struct { diff --git a/ec/ecresource/trafficfilterassocresource/update.go b/ec/ecresource/trafficfilterassocresource/update.go index b5a2017c5..e99403fcf 100644 --- a/ec/ecresource/trafficfilterassocresource/update.go +++ b/ec/ecresource/trafficfilterassocresource/update.go @@ -19,9 +19,10 @@ package trafficfilterassocresource import ( "context" + "github.com/hashicorp/terraform-plugin-framework/resource" ) -func (t trafficFilterAssocResource) Update(ctx context.Context, request resource.UpdateRequest, response *resource.UpdateResponse) { +func (r Resource) Update(ctx context.Context, request resource.UpdateRequest, response *resource.UpdateResponse) { panic("ec_deployment_traffic_filter_association resources can not be updated!") } diff --git a/ec/ecresource/trafficfilterresource/create.go b/ec/ecresource/trafficfilterresource/create.go index 6beed518d..0e535b7bc 100644 --- a/ec/ecresource/trafficfilterresource/create.go +++ b/ec/ecresource/trafficfilterresource/create.go @@ -20,10 +20,11 @@ package trafficfilterresource import ( "context" - "github.com/elastic/cloud-sdk-go/pkg/api" - "github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi/trafficfilterapi" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + + "github.com/elastic/cloud-sdk-go/pkg/api" + "github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi/trafficfilterapi" ) // Create will create a new deployment traffic filter ruleset diff --git a/ec/ecresource/trafficfilterresource/delete.go b/ec/ecresource/trafficfilterresource/delete.go index cb675f052..5723eace8 100644 --- a/ec/ecresource/trafficfilterresource/delete.go +++ b/ec/ecresource/trafficfilterresource/delete.go @@ -21,11 +21,12 @@ import ( "context" "errors" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/elastic/cloud-sdk-go/pkg/api" "github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi/trafficfilterapi" "github.com/elastic/cloud-sdk-go/pkg/client/deployments_traffic_filter" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/elastic/terraform-provider-ec/ec/internal/util" ) diff --git a/ec/ecresource/trafficfilterresource/delete_test.go b/ec/ecresource/trafficfilterresource/delete_test.go index c03db81eb..451835014 100644 --- a/ec/ecresource/trafficfilterresource/delete_test.go +++ b/ec/ecresource/trafficfilterresource/delete_test.go @@ -21,14 +21,17 @@ import ( "context" "testing" + "github.com/stretchr/testify/assert" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/elastic/cloud-sdk-go/pkg/api" "github.com/elastic/cloud-sdk-go/pkg/api/mock" "github.com/elastic/cloud-sdk-go/pkg/models" "github.com/elastic/cloud-sdk-go/pkg/util/ec" + "github.com/elastic/terraform-provider-ec/ec/internal/util" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/stretchr/testify/assert" ) func Test_delete(t *testing.T) { diff --git a/ec/ecresource/trafficfilterresource/expanders.go b/ec/ecresource/trafficfilterresource/expanders.go index 9e7d7eb8d..2cb57a10e 100644 --- a/ec/ecresource/trafficfilterresource/expanders.go +++ b/ec/ecresource/trafficfilterresource/expanders.go @@ -18,9 +18,10 @@ package trafficfilterresource import ( + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/elastic/cloud-sdk-go/pkg/models" "github.com/elastic/cloud-sdk-go/pkg/util/ec" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) func expandModel(d *schema.ResourceData) *models.TrafficFilterRulesetRequest { diff --git a/ec/ecresource/trafficfilterresource/expanders_test.go b/ec/ecresource/trafficfilterresource/expanders_test.go index 5189ed213..9fb1746c7 100644 --- a/ec/ecresource/trafficfilterresource/expanders_test.go +++ b/ec/ecresource/trafficfilterresource/expanders_test.go @@ -20,11 +20,12 @@ package trafficfilterresource import ( "testing" - "github.com/elastic/cloud-sdk-go/pkg/models" - "github.com/elastic/cloud-sdk-go/pkg/util/ec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/stretchr/testify/assert" + "github.com/elastic/cloud-sdk-go/pkg/models" + "github.com/elastic/cloud-sdk-go/pkg/util/ec" + "github.com/elastic/terraform-provider-ec/ec/internal/util" ) diff --git a/ec/ecresource/trafficfilterresource/flatteners.go b/ec/ecresource/trafficfilterresource/flatteners.go index 5f2d4615d..2950da74b 100644 --- a/ec/ecresource/trafficfilterresource/flatteners.go +++ b/ec/ecresource/trafficfilterresource/flatteners.go @@ -18,8 +18,9 @@ package trafficfilterresource import ( - "github.com/elastic/cloud-sdk-go/pkg/models" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + + "github.com/elastic/cloud-sdk-go/pkg/models" ) func modelToState(d *schema.ResourceData, res *models.TrafficFilterRulesetInfo) error { diff --git a/ec/ecresource/trafficfilterresource/flatteners_test.go b/ec/ecresource/trafficfilterresource/flatteners_test.go index c660cdd56..a85e52f4f 100644 --- a/ec/ecresource/trafficfilterresource/flatteners_test.go +++ b/ec/ecresource/trafficfilterresource/flatteners_test.go @@ -20,11 +20,12 @@ package trafficfilterresource import ( "testing" - "github.com/elastic/cloud-sdk-go/pkg/models" - "github.com/elastic/cloud-sdk-go/pkg/util/ec" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/stretchr/testify/assert" + "github.com/elastic/cloud-sdk-go/pkg/models" + "github.com/elastic/cloud-sdk-go/pkg/util/ec" + "github.com/elastic/terraform-provider-ec/ec/internal/util" ) diff --git a/ec/ecresource/trafficfilterresource/read.go b/ec/ecresource/trafficfilterresource/read.go index f249a4f52..1570508b9 100644 --- a/ec/ecresource/trafficfilterresource/read.go +++ b/ec/ecresource/trafficfilterresource/read.go @@ -20,11 +20,12 @@ package trafficfilterresource import ( "context" - "github.com/elastic/cloud-sdk-go/pkg/api" - "github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi/trafficfilterapi" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/elastic/cloud-sdk-go/pkg/api" + "github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi/trafficfilterapi" + "github.com/elastic/terraform-provider-ec/ec/internal/util" ) diff --git a/ec/ecresource/trafficfilterresource/read_test.go b/ec/ecresource/trafficfilterresource/read_test.go index 6b563ade2..ec765c9a5 100644 --- a/ec/ecresource/trafficfilterresource/read_test.go +++ b/ec/ecresource/trafficfilterresource/read_test.go @@ -21,11 +21,13 @@ import ( "context" "testing" - "github.com/elastic/cloud-sdk-go/pkg/api" - "github.com/elastic/cloud-sdk-go/pkg/api/mock" + "github.com/stretchr/testify/assert" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/stretchr/testify/assert" + + "github.com/elastic/cloud-sdk-go/pkg/api" + "github.com/elastic/cloud-sdk-go/pkg/api/mock" "github.com/elastic/terraform-provider-ec/ec/internal/util" ) diff --git a/ec/ecresource/trafficfilterresource/update.go b/ec/ecresource/trafficfilterresource/update.go index 21cb4b3b6..c5b3d87cf 100644 --- a/ec/ecresource/trafficfilterresource/update.go +++ b/ec/ecresource/trafficfilterresource/update.go @@ -20,10 +20,11 @@ package trafficfilterresource import ( "context" - "github.com/elastic/cloud-sdk-go/pkg/api" - "github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi/trafficfilterapi" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + + "github.com/elastic/cloud-sdk-go/pkg/api" + "github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi/trafficfilterapi" ) // Update will update an existing deployment traffic filter ruleset diff --git a/ec/internal/flatteners/flatten_tags.go b/ec/internal/flatteners/flatten_tags.go index 57d05c01e..bc455ad8c 100644 --- a/ec/internal/flatteners/flatten_tags.go +++ b/ec/internal/flatteners/flatten_tags.go @@ -18,9 +18,10 @@ package flatteners import ( - "github.com/elastic/cloud-sdk-go/pkg/models" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" + + "github.com/elastic/cloud-sdk-go/pkg/models" ) // flattenTags takes in Deployment Metadata resource models and returns its diff --git a/ec/internal/flatteners/flatten_tags_test.go b/ec/internal/flatteners/flatten_tags_test.go index 9b28f6f85..6775d6b04 100644 --- a/ec/internal/flatteners/flatten_tags_test.go +++ b/ec/internal/flatteners/flatten_tags_test.go @@ -21,9 +21,10 @@ import ( "context" "testing" + "github.com/stretchr/testify/assert" + "github.com/elastic/cloud-sdk-go/pkg/models" "github.com/elastic/cloud-sdk-go/pkg/util/ec" - "github.com/stretchr/testify/assert" ) func TestFlattenTags(t *testing.T) { diff --git a/ec/internal/planmodifier/default_from_env.go b/ec/internal/planmodifier/default_from_env.go index 77b2fd3cc..8a3dcd526 100644 --- a/ec/internal/planmodifier/default_from_env.go +++ b/ec/internal/planmodifier/default_from_env.go @@ -20,10 +20,11 @@ package planmodifier import ( "context" "fmt" - "github.com/elastic/terraform-provider-ec/ec/internal/util" - "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-framework/tfsdk" + "github.com/hashicorp/terraform-plugin-framework/types" + + "github.com/elastic/terraform-provider-ec/ec/internal/util" ) // defaultFromEnvAttributePlanModifier specifies a default value (attr.Value) for an attribute. diff --git a/ec/internal/provider.go b/ec/internal/provider.go index ce0e3f6aa..1345c510e 100644 --- a/ec/internal/provider.go +++ b/ec/internal/provider.go @@ -20,42 +20,27 @@ package internal import ( "fmt" - "github.com/elastic/cloud-sdk-go/pkg/api" "github.com/hashicorp/terraform-plugin-framework/diag" - "github.com/hashicorp/terraform-plugin-framework/provider" -) -// Provider is an interface required to avoid import cycles in datasource / resource packages -type Provider interface { - provider.Provider - GetClient() *api.API -} + "github.com/elastic/cloud-sdk-go/pkg/api" +) -// ConvertProviderType is a helper function for NewResource and NewDataSource -// implementations to associate the concrete provider type. Alternatively, -// this helper can be skipped and the provider type can be directly type -// asserted (e.g. provider: in.(*provider)), however using this can prevent -// potential panics. -func ConvertProviderType(in provider.Provider) (Provider, diag.Diagnostics) { +// ConvertProviderData is a helper function for DataSource.Configure and Resource.Configure implementations +func ConvertProviderData(providerData any) (*api.API, diag.Diagnostics) { var diags diag.Diagnostics - p, ok := in.(Provider) + if providerData == nil { + return nil, diags + } + client, ok := providerData.(*api.API) if !ok { diags.AddError( - "Unexpected Provider Instance Type", - fmt.Sprintf("While creating the data source or resource, an unexpected provider type (%T) was received. This is always a bug in the provider code and should be reported to the provider developers.", p), + "Unexpected Provider Data", + fmt.Sprintf("Expected *api.API, got: %T. Please report this issue to the provider developers.", providerData), ) - return p, diags - } - if p == nil { - diags.AddError( - "Unexpected Provider Instance Type", - "While creating the data source or resource, an unexpected empty provider instance was received. This is always a bug in the provider code and should be reported to the provider developers.", - ) - return p, diags + return nil, diags } - - return p, diags + return client, diags } diff --git a/ec/internal/util/helpers.go b/ec/internal/util/helpers.go index d00952da5..4abc5b5c7 100644 --- a/ec/internal/util/helpers.go +++ b/ec/internal/util/helpers.go @@ -19,11 +19,12 @@ package util import ( "fmt" + "os" + "strconv" + "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "os" - "strconv" "github.com/elastic/cloud-sdk-go/pkg/models" ) diff --git a/ec/internal/util/helpers_test.go b/ec/internal/util/helpers_test.go index d07d5f897..bee83a1e5 100644 --- a/ec/internal/util/helpers_test.go +++ b/ec/internal/util/helpers_test.go @@ -20,9 +20,10 @@ package util import ( "testing" + "github.com/stretchr/testify/assert" + "github.com/elastic/cloud-sdk-go/pkg/models" "github.com/elastic/cloud-sdk-go/pkg/util/ec" - "github.com/stretchr/testify/assert" ) func TestFlattenClusterEndpoint(t *testing.T) { diff --git a/ec/internal/util/parsers_test.go b/ec/internal/util/parsers_test.go index 317b50755..2f8f3c1a5 100644 --- a/ec/internal/util/parsers_test.go +++ b/ec/internal/util/parsers_test.go @@ -21,9 +21,10 @@ import ( "errors" "testing" + "github.com/stretchr/testify/assert" + "github.com/elastic/cloud-sdk-go/pkg/models" "github.com/elastic/cloud-sdk-go/pkg/util/ec" - "github.com/stretchr/testify/assert" ) func TestMemoryToState(t *testing.T) { diff --git a/ec/internal/util/testutils.go b/ec/internal/util/testutils.go index b55318c56..ee5e5491f 100644 --- a/ec/internal/util/testutils.go +++ b/ec/internal/util/testutils.go @@ -22,9 +22,10 @@ import ( "errors" "testing" - "github.com/elastic/cloud-sdk-go/pkg/multierror" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + + "github.com/elastic/cloud-sdk-go/pkg/multierror" ) // ResDataParams holds the raw configuration for NewResourceData to consume diff --git a/ec/internal/util/traffic_filter_err_test.go b/ec/internal/util/traffic_filter_err_test.go index 5da4e4f5a..5ac31a5b4 100644 --- a/ec/internal/util/traffic_filter_err_test.go +++ b/ec/internal/util/traffic_filter_err_test.go @@ -20,9 +20,10 @@ package util import ( "testing" + "github.com/go-openapi/runtime" + "github.com/elastic/cloud-sdk-go/pkg/api/apierror" "github.com/elastic/cloud-sdk-go/pkg/client/deployments_traffic_filter" - "github.com/go-openapi/runtime" ) func TestTrafficFilterNotFound(t *testing.T) { diff --git a/ec/internal/validators/knownvalidator.go b/ec/internal/validators/knownvalidator.go index 129c93506..8ef7bf0c0 100644 --- a/ec/internal/validators/knownvalidator.go +++ b/ec/internal/validators/knownvalidator.go @@ -19,6 +19,7 @@ package validators import ( "context" + "github.com/hashicorp/terraform-plugin-framework/tfsdk" ) diff --git a/ec/provider.go b/ec/provider.go index c613f2c9d..afffa4176 100644 --- a/ec/provider.go +++ b/ec/provider.go @@ -22,6 +22,18 @@ import ( "fmt" "time" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/provider" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/tfsdk" + "github.com/hashicorp/terraform-plugin-framework/types" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" + + "github.com/elastic/cloud-sdk-go/pkg/api" + "github.com/elastic/terraform-provider-ec/ec/ecdatasource/deploymentdatasource" "github.com/elastic/terraform-provider-ec/ec/ecdatasource/deploymentsdatasource" "github.com/elastic/terraform-provider-ec/ec/ecdatasource/stackdatasource" @@ -30,18 +42,9 @@ import ( "github.com/elastic/terraform-provider-ec/ec/ecresource/extensionresource" "github.com/elastic/terraform-provider-ec/ec/ecresource/trafficfilterassocresource" "github.com/elastic/terraform-provider-ec/ec/ecresource/trafficfilterresource" - "github.com/elastic/terraform-provider-ec/ec/internal" "github.com/elastic/terraform-provider-ec/ec/internal/planmodifier" "github.com/elastic/terraform-provider-ec/ec/internal/util" "github.com/elastic/terraform-provider-ec/ec/internal/validators" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" - - "github.com/elastic/cloud-sdk-go/pkg/api" - "github.com/hashicorp/terraform-plugin-framework/diag" - "github.com/hashicorp/terraform-plugin-framework/provider" - "github.com/hashicorp/terraform-plugin-framework/tfsdk" - "github.com/hashicorp/terraform-plugin-framework/types" ) const ( @@ -146,17 +149,34 @@ func ProviderWithClient(client *api.API, version string) provider.Provider { return &Provider{client: client, version: version} } -var _ internal.Provider = (*Provider)(nil) - -func (p *Provider) GetClient() *api.API { - return p.client -} +var _ provider.Provider = (*Provider)(nil) +var _ provider.ProviderWithMetadata = (*Provider)(nil) +var _ provider.ProviderWithDataSources = (*Provider)(nil) +var _ provider.ProviderWithResources = (*Provider)(nil) type Provider struct { version string client *api.API } +func (p *Provider) Metadata(ctx context.Context, request provider.MetadataRequest, response *provider.MetadataResponse) { + response.TypeName = "ec" +} + +func (p *Provider) DataSources(ctx context.Context) []func() datasource.DataSource { + return []func() datasource.DataSource{ + func() datasource.DataSource { return &deploymentdatasource.DataSource{} }, + func() datasource.DataSource { return &deploymentsdatasource.DataSource{} }, + func() datasource.DataSource { return &stackdatasource.DataSource{} }, + } +} + +func (p *Provider) Resources(ctx context.Context) []func() resource.Resource { + return []func() resource.Resource{ + func() resource.Resource { return &trafficfilterassocresource.Resource{} }, + } +} + func (p *Provider) GetSchema(context.Context) (tfsdk.Schema, diag.Diagnostics) { var diags diag.Diagnostics @@ -229,6 +249,9 @@ type providerData struct { func (p *Provider) Configure(ctx context.Context, req provider.ConfigureRequest, res *provider.ConfigureResponse) { if p.client != nil { + // Required for unit tests, because a mock client is pre-created there. + res.DataSourceData = p.client + res.ResourceData = p.client return } @@ -345,7 +368,7 @@ func (p *Provider) Configure(ctx context.Context, req provider.ConfigureRequest, return } - p.client, err = api.NewAPI(cfg) + client, err := api.NewAPI(cfg) if err != nil { res.Diagnostics.AddWarning( "Unable to create api Client config", @@ -353,18 +376,8 @@ func (p *Provider) Configure(ctx context.Context, req provider.ConfigureRequest, ) return } -} - -func (p *Provider) GetResources(_ context.Context) (map[string]provider.ResourceType, diag.Diagnostics) { - return map[string]provider.ResourceType{ - "ec_deployment_traffic_filter_association": trafficfilterassocresource.ResourceType{}, - }, nil -} -func (p *Provider) GetDataSources(_ context.Context) (map[string]provider.DataSourceType, diag.Diagnostics) { - return map[string]provider.DataSourceType{ - "ec_stack": stackdatasource.DataSourceType{}, - "ec_deployment": deploymentdatasource.DataSourceType{}, - "ec_deployments": deploymentsdatasource.DataSourceType{}, - }, nil + p.client = client + res.DataSourceData = client + res.ResourceData = client } diff --git a/ec/provider_config.go b/ec/provider_config.go index 6e8969fd5..1be54bfab 100644 --- a/ec/provider_config.go +++ b/ec/provider_config.go @@ -24,12 +24,13 @@ import ( "os" "time" - "github.com/elastic/terraform-provider-ec/ec/internal/util" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/elastic/cloud-sdk-go/pkg/api" "github.com/elastic/cloud-sdk-go/pkg/auth" + + "github.com/elastic/terraform-provider-ec/ec/internal/util" ) const ( diff --git a/ec/provider_config_test.go b/ec/provider_config_test.go index 2419f828b..5a0dffa94 100644 --- a/ec/provider_config_test.go +++ b/ec/provider_config_test.go @@ -26,11 +26,12 @@ import ( "syscall" "testing" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/stretchr/testify/assert" + "github.com/elastic/cloud-sdk-go/pkg/api" "github.com/elastic/cloud-sdk-go/pkg/auth" "github.com/elastic/cloud-sdk-go/pkg/multierror" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/stretchr/testify/assert" "github.com/elastic/terraform-provider-ec/ec/internal/util" ) diff --git a/gen/gen.go b/gen/gen.go index 68f6ae362..b533af753 100644 --- a/gen/gen.go +++ b/gen/gen.go @@ -17,6 +17,7 @@ // This program generates ec/version.go. It can be invoked by running // make generate +//go:build ignore // +build ignore package main diff --git a/go.mod b/go.mod index 2eb44e9e5..3097048ac 100644 --- a/go.mod +++ b/go.mod @@ -8,13 +8,13 @@ require ( github.com/elastic/cloud-sdk-go v1.10.0 github.com/go-openapi/runtime v0.24.1 github.com/go-openapi/strfmt v0.21.3 - github.com/hashicorp/terraform-plugin-framework v0.11.1 + github.com/hashicorp/terraform-plugin-framework v0.12.0 github.com/hashicorp/terraform-plugin-go v0.14.0 github.com/hashicorp/terraform-plugin-log v0.7.0 github.com/hashicorp/terraform-plugin-mux v0.7.0 - github.com/hashicorp/terraform-plugin-sdk/v2 v2.21.0 + github.com/hashicorp/terraform-plugin-sdk/v2 v2.22.0 github.com/stretchr/testify v1.8.0 - golang.org/x/exp v0.0.0-20220827204233-334a2380cb91 + golang.org/x/exp v0.0.0-20220914170420-dc92f8653013 ) require ( @@ -33,7 +33,7 @@ require ( github.com/go-openapi/swag v0.22.3 // indirect github.com/go-openapi/validate v0.22.0 // indirect github.com/golang/protobuf v1.5.2 // indirect - github.com/google/go-cmp v0.5.8 // indirect + github.com/google/go-cmp v0.5.9 // indirect 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 @@ -44,9 +44,9 @@ require ( github.com/hashicorp/go-uuid v1.0.3 // indirect github.com/hashicorp/go-version v1.6.0 // indirect github.com/hashicorp/hc-install v0.4.0 // indirect - github.com/hashicorp/hcl/v2 v2.13.0 // indirect + github.com/hashicorp/hcl/v2 v2.14.0 // indirect github.com/hashicorp/logutils v1.0.0 // indirect - github.com/hashicorp/terraform-exec v0.17.2 // indirect + github.com/hashicorp/terraform-exec v0.17.3 // indirect github.com/hashicorp/terraform-json v0.14.0 // indirect github.com/hashicorp/terraform-registry-address v0.0.0-20220623143253-7d51757b572c // indirect github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 // indirect @@ -68,13 +68,13 @@ require ( github.com/vmihailenco/msgpack/v4 v4.3.12 // indirect github.com/vmihailenco/tagparser v0.1.2 // indirect github.com/zclconf/go-cty v1.11.0 // indirect - go.mongodb.org/mongo-driver v1.10.1 // indirect - golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d // indirect - golang.org/x/net v0.0.0-20220826154423-83b083e8dc8b // indirect - golang.org/x/sys v0.0.0-20220829200755-d48e67d00261 // indirect + go.mongodb.org/mongo-driver v1.10.2 // indirect + golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 // indirect + golang.org/x/net v0.0.0-20220909164309-bea034e7d591 // indirect + golang.org/x/sys v0.0.0-20220913175220-63ea55921009 // indirect golang.org/x/text v0.3.7 // indirect google.golang.org/appengine v1.6.7 // indirect - google.golang.org/genproto v0.0.0-20220829175752-36a9c930ecbf // indirect + google.golang.org/genproto v0.0.0-20220914210030-581e60b4ef85 // indirect google.golang.org/grpc v1.49.0 // indirect google.golang.org/protobuf v1.28.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect diff --git a/go.sum b/go.sum index c4c8cf567..005fd4fa8 100644 --- a/go.sum +++ b/go.sum @@ -18,6 +18,7 @@ github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYU github.com/apparentlymart/go-cidr v1.1.0 h1:2mAhrMoF+nhXqxTzSZMUzDHkLjmIHC+Zzn4tdgBZjnU= github.com/apparentlymart/go-cidr v1.1.0/go.mod h1:EBcsNrHc3zQeuaeCeCtQruQm+n9/YjEn/vI25Lg7Gwc= github.com/apparentlymart/go-dump v0.0.0-20190214190832-042adf3cf4a0 h1:MzVXffFUye+ZcSR6opIgz9Co7WcDx6ZcY+RjfFHoA0I= +github.com/apparentlymart/go-textseg v1.0.0 h1:rRmlIsPEEhUTIKQb7T++Nz/A5Q6C9IuX2wFoYVvnCs0= github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/Nj9VFpLOpjS5yuumk= github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJEynmyUenKwP++x/+DdGV/Ec= github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw= @@ -220,6 +221,8 @@ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y= @@ -251,14 +254,20 @@ github.com/hashicorp/hc-install v0.4.0 h1:cZkRFr1WVa0Ty6x5fTvL1TuO1flul231rWkGH9 github.com/hashicorp/hc-install v0.4.0/go.mod h1:5d155H8EC5ewegao9A4PUTMNPZaq+TbOzkJJZ4vrXeI= github.com/hashicorp/hcl/v2 v2.13.0 h1:0Apadu1w6M11dyGFxWnmhhcMjkbAiKCv7G1r/2QgCNc= github.com/hashicorp/hcl/v2 v2.13.0/go.mod h1:e4z5nxYlWNPdDSNYX+ph14EvWYMFm3eP0zIUqPc2jr0= +github.com/hashicorp/hcl/v2 v2.14.0 h1:jX6+Q38Ly9zaAJlAjnFVyeNSNCKKW8D0wvyg7vij5Wc= +github.com/hashicorp/hcl/v2 v2.14.0/go.mod h1:e4z5nxYlWNPdDSNYX+ph14EvWYMFm3eP0zIUqPc2jr0= github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= github.com/hashicorp/terraform-exec v0.17.2 h1:EU7i3Fh7vDUI9nNRdMATCEfnm9axzTnad8zszYZ73Go= github.com/hashicorp/terraform-exec v0.17.2/go.mod h1:tuIbsL2l4MlwwIZx9HPM+LOV9vVyEfBYu2GsO1uH3/8= +github.com/hashicorp/terraform-exec v0.17.3 h1:MX14Kvnka/oWGmIkyuyvL6POx25ZmKrjlaclkx3eErU= +github.com/hashicorp/terraform-exec v0.17.3/go.mod h1:+NELG0EqQekJzhvikkeQsOAZpsw0cv/03rbeQJqscAI= github.com/hashicorp/terraform-json v0.14.0 h1:sh9iZ1Y8IFJLx+xQiKHGud6/TSUCM0N8e17dKDpqV7s= github.com/hashicorp/terraform-json v0.14.0/go.mod h1:5A9HIWPkk4e5aeeXIBbkcOvaZbIYnAIkEyqP2pNSckM= github.com/hashicorp/terraform-plugin-framework v0.11.1 h1:rq8f+TLDO4tJu+n9mMYlDrcRoIdrg0gTUvV2Jr0Ya24= github.com/hashicorp/terraform-plugin-framework v0.11.1/go.mod h1:GENReHOz6GEt8Jk3UN94vk8BdC6irEHFgN3Z9HPhPUU= +github.com/hashicorp/terraform-plugin-framework v0.12.0 h1:Bk3l5MQUaZoo5eplr+u1FomYqGS564e8Tp3rutnCfYg= +github.com/hashicorp/terraform-plugin-framework v0.12.0/go.mod h1:wcZdk4+Uef6Ng+BiBJjGAcIPlIs5bhlEV/TA1k6Xkq8= github.com/hashicorp/terraform-plugin-go v0.14.0 h1:ttnSlS8bz3ZPYbMb84DpcPhY4F5DsQtcAS7cHo8uvP4= github.com/hashicorp/terraform-plugin-go v0.14.0/go.mod h1:2nNCBeRLaenyQEi78xrGrs9hMbulveqG/zDMQSvVJTE= github.com/hashicorp/terraform-plugin-log v0.7.0 h1:SDxJUyT8TwN4l5b5/VkiTIaQgY6R+Y2BQ0sRZftGKQs= @@ -267,6 +276,8 @@ github.com/hashicorp/terraform-plugin-mux v0.7.0 h1:wRbSYzg+v2sn5Mdee0UKm4YTt4wJ github.com/hashicorp/terraform-plugin-mux v0.7.0/go.mod h1:Ae30Mc5lz4d1awtiCbHP0YyvgBeiQ00Q1nAq0U3lb+I= github.com/hashicorp/terraform-plugin-sdk/v2 v2.21.0 h1:eIJjFlI4k6BMso6Wq/bq56U0RukXc4JbwJJ8Oze2/tg= github.com/hashicorp/terraform-plugin-sdk/v2 v2.21.0/go.mod h1:mYPs/uchNcBq7AclQv9QUtSf9iNcfp1Ag21jqTlDf2M= +github.com/hashicorp/terraform-plugin-sdk/v2 v2.22.0 h1:MzfNfrheTt24xbEbA4npUSbX3GYu4xjXS7czcpJFyQY= +github.com/hashicorp/terraform-plugin-sdk/v2 v2.22.0/go.mod h1:q1XKSxXg9nDmhV0IvNZNZxe3gcTAHzMqrjs8wX1acng= github.com/hashicorp/terraform-registry-address v0.0.0-20220623143253-7d51757b572c h1:D8aRO6+mTqHfLsK/BC3j5OAoogv1WLRWzY1AaTo3rBg= github.com/hashicorp/terraform-registry-address v0.0.0-20220623143253-7d51757b572c/go.mod h1:Wn3Na71knbXc1G8Lh+yu/dQWWJeFQEpDeJMtWMtlmNI= github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 h1:HKLsbzeOsfXmKNpr3GiT18XAblV0BjCbzL8KQAMZGa0= @@ -428,6 +439,8 @@ go.mongodb.org/mongo-driver v1.8.3/go.mod h1:0sQWfOeY63QTntERDJJ/0SuKK0T1uVSgKCu go.mongodb.org/mongo-driver v1.10.0/go.mod h1:wsihk0Kdgv8Kqu1Anit4sfK+22vSFbUrAVEYRhCXrA8= go.mongodb.org/mongo-driver v1.10.1 h1:NujsPveKwHaWuKUer/ceo9DzEe7HIj1SlJ6uvXZG0S4= go.mongodb.org/mongo-driver v1.10.1/go.mod h1:z4XpeoU6w+9Vht+jAFyLgVrD+jGSQQe0+CBWFHNiHt8= +go.mongodb.org/mongo-driver v1.10.2 h1:4Wk3cnqOrQCn0P92L3/mmurMxzdvWWs5J9jinAVKD+k= +go.mongodb.org/mongo-driver v1.10.2/go.mod h1:z4XpeoU6w+9Vht+jAFyLgVrD+jGSQQe0+CBWFHNiHt8= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= @@ -444,8 +457,12 @@ golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d h1:sK3txAijHtOK88l68nt020reeT1ZdKLIYetKl95FzVY= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 h1:Y/gsMcFOcR+6S6f3YeMKl5g+dZMEWqcz5Czj/GWYbkM= +golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20220827204233-334a2380cb91 h1:tnebWN09GYg9OLPss1KXj8txwZc6X6uMr6VFdcGNbHw= golang.org/x/exp v0.0.0-20220827204233-334a2380cb91/go.mod h1:cyybsKvd6eL0RnXn6p/Grxp8F5bW7iYuBgsNCOHpMYE= +golang.org/x/exp v0.0.0-20220914170420-dc92f8653013 h1:ZjglnWxEUdPyXl4o/j4T89SRCI+4X6NW6185PNLEOF4= +golang.org/x/exp v0.0.0-20220914170420-dc92f8653013/go.mod h1:cyybsKvd6eL0RnXn6p/Grxp8F5bW7iYuBgsNCOHpMYE= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180811021610-c39426892332/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181005035420-146acd28ed58/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -473,6 +490,8 @@ golang.org/x/net v0.0.0-20211216030914-fe4d6282115f/go.mod h1:9nx3DQGgdP8bBQD5qx golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220826154423-83b083e8dc8b h1:ZmngSVLe/wycRns9MKikG9OWIEjGcGAkacif7oYQaUY= golang.org/x/net v0.0.0-20220826154423-83b083e8dc8b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= +golang.org/x/net v0.0.0-20220909164309-bea034e7d591 h1:D0B/7al0LLrVC8aWF4+oxpv/m8bc7ViFfVS8/gXGdqI= +golang.org/x/net v0.0.0-20220909164309-bea034e7d591/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -512,6 +531,8 @@ golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220829200755-d48e67d00261 h1:v6hYoSR9T5oet+pMXwUWkbiVqx/63mlHjefrHmxwfeY= golang.org/x/sys v0.0.0-20220829200755-d48e67d00261/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220913175220-63ea55921009 h1:PuvuRMeLWqsf/ZdT1UUZz0syhioyv1mzuFZsXs4fvhw= +golang.org/x/sys v0.0.0-20220913175220-63ea55921009/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY= @@ -541,6 +562,8 @@ google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6 google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/genproto v0.0.0-20220829175752-36a9c930ecbf h1:Q5xNKbTSFwkuaaGaR7CMcXEM5sy19KYdUU8iF8/iRC0= google.golang.org/genproto v0.0.0-20220829175752-36a9c930ecbf/go.mod h1:dbqgFATTzChvnt+ujMdZwITVAJHFtfyN1qUhDqEiIlk= +google.golang.org/genproto v0.0.0-20220914210030-581e60b4ef85 h1:lkYqfLZL9+9C+SltHOTeOHL6uueWYYkGp5NoeOZQsis= +google.golang.org/genproto v0.0.0-20220914210030-581e60b4ef85/go.mod h1:0Nb8Qy+Sk5eDzHnzlStwW3itdNaWoZA5XeSG+R3JHSo= google.golang.org/grpc v1.49.0 h1:WTLtQzmQori5FUH25Pq4WT22oCsv8USpQ+F6rqtsmxw= google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=