From 0f790f73424b3f412f1b1fa054d987907a43375b Mon Sep 17 00:00:00 2001 From: Toby Brain Date: Sat, 5 Oct 2024 11:14:11 +1000 Subject: [PATCH 1/2] Use go-elasticsearch v8 --- docs/data-sources/elasticsearch_indices.md | 1 - docs/resources/elasticsearch_index.md | 1 - go.mod | 8 +++++++- go.sum | 19 +++++++++++++++++-- internal/clients/api_client.go | 2 +- internal/clients/config/base.go | 2 +- internal/clients/config/client.go | 2 +- internal/clients/config/debug.go | 4 ++-- internal/clients/config/elasticsearch.go | 2 +- internal/clients/elasticsearch/index.go | 8 ++------ internal/clients/elasticsearch/logstash.go | 2 +- internal/clients/elasticsearch/transform.go | 4 ++-- internal/elasticsearch/index/index/create.go | 19 ------------------- internal/elasticsearch/index/index/models.go | 2 -- .../elasticsearch/index/index/models_test.go | 2 -- internal/elasticsearch/index/index/schema.go | 8 -------- .../elasticsearch/index/indices/models.go | 1 - .../elasticsearch/index/indices/schema.go | 5 ----- .../elasticsearch/logstash/pipeline_test.go | 2 +- internal/models/models.go | 1 - internal/utils/utils.go | 2 +- 21 files changed, 37 insertions(+), 60 deletions(-) diff --git a/docs/data-sources/elasticsearch_indices.md b/docs/data-sources/elasticsearch_indices.md index c5407e3c0..36ad08c9d 100644 --- a/docs/data-sources/elasticsearch_indices.md +++ b/docs/data-sources/elasticsearch_indices.md @@ -63,7 +63,6 @@ Optional: - `final_pipeline` (String) Final ingest pipeline for the index. Indexing requests will fail if the final pipeline is set and the pipeline does not exist. The final pipeline always runs after the request pipeline (if specified) and the default pipeline (if it exists). The special pipeline name _none indicates no ingest pipeline will run. - `gc_deletes` (String) The length of time that a deleted document's version number remains available for further versioned operations. - `highlight_max_analyzed_offset` (Number) The maximum number of characters that will be analyzed for a highlight request. -- `include_type_name` (Boolean) If true, a mapping type is expected in the body of mappings. Defaults to false. Supported for Elasticsearch 7.x. - `indexing_slowlog_level` (String) Set which logging level to use for the search slow log, can be: `warn`, `info`, `debug`, `trace` - `indexing_slowlog_source` (String) Set the number of characters of the `_source` to include in the slowlog lines, `false` or `0` will skip logging the source entirely and setting it to `true` will log the entire source regardless of size. The original `_source` is reformatted by default to make sure that it fits on a single log line. - `indexing_slowlog_threshold_index_debug` (String) Set the cutoff for shard level slow search logging of slow searches for indexing queries, in time units, e.g. `2s` diff --git a/docs/resources/elasticsearch_index.md b/docs/resources/elasticsearch_index.md index 7ba49d99e..a6b775744 100644 --- a/docs/resources/elasticsearch_index.md +++ b/docs/resources/elasticsearch_index.md @@ -79,7 +79,6 @@ resource "elasticstack_elasticsearch_index" "my_index" { - `final_pipeline` (String) Final ingest pipeline for the index. Indexing requests will fail if the final pipeline is set and the pipeline does not exist. The final pipeline always runs after the request pipeline (if specified) and the default pipeline (if it exists). The special pipeline name _none indicates no ingest pipeline will run. - `gc_deletes` (String) The length of time that a deleted document's version number remains available for further versioned operations. - `highlight_max_analyzed_offset` (Number) The maximum number of characters that will be analyzed for a highlight request. -- `include_type_name` (Boolean) If true, a mapping type is expected in the body of mappings. Defaults to false. Supported for Elasticsearch 7.x. - `indexing_slowlog_level` (String) Set which logging level to use for the search slow log, can be: `warn`, `info`, `debug`, `trace` - `indexing_slowlog_source` (String) Set the number of characters of the `_source` to include in the slowlog lines, `false` or `0` will skip logging the source entirely and setting it to `true` will log the entire source regardless of size. The original `_source` is reformatted by default to make sure that it fits on a single log line. - `indexing_slowlog_threshold_index_debug` (String) Set the cutoff for shard level slow search logging of slow searches for indexing queries, in time units, e.g. `2s` diff --git a/go.mod b/go.mod index b3e07d65e..3a6f4f920 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,8 @@ toolchain go1.23.1 require ( github.com/disaster37/go-kibana-rest/v8 v8.5.0 - github.com/elastic/go-elasticsearch/v7 v7.17.10 + github.com/elastic/elastic-transport-go/v8 v8.6.0 + github.com/elastic/go-elasticsearch/v8 v8.15.0 github.com/google/gofuzz v1.2.0 github.com/google/uuid v1.6.0 github.com/hashicorp/go-cty v1.4.1-0.20200723130312-85980079f637 @@ -33,6 +34,8 @@ require ( github.com/cloudflare/circl v1.3.9 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/fatih/color v1.17.0 // indirect + github.com/go-logr/logr v1.4.1 // indirect + github.com/go-logr/stdr v1.2.2 // indirect github.com/go-resty/resty/v2 v2.15.3 // indirect github.com/go-test/deep v1.0.8 // indirect github.com/golang/protobuf v1.5.4 // indirect @@ -68,6 +71,9 @@ require ( github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect github.com/zclconf/go-cty v1.15.0 // indirect + go.opentelemetry.io/otel v1.24.0 // indirect + go.opentelemetry.io/otel/metric v1.24.0 // indirect + go.opentelemetry.io/otel/trace v1.24.0 // indirect golang.org/x/crypto v0.25.0 // indirect golang.org/x/mod v0.19.0 // indirect golang.org/x/net v0.27.0 // indirect diff --git a/go.sum b/go.sum index 83bae50b8..cb2ae4950 100644 --- a/go.sum +++ b/go.sum @@ -23,8 +23,10 @@ github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxG github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/elastic/go-elasticsearch/v7 v7.17.10 h1:TCQ8i4PmIJuBunvBS6bwT2ybzVFxxUhhltAs3Gyu1yo= -github.com/elastic/go-elasticsearch/v7 v7.17.10/go.mod h1:OJ4wdbtDNk5g503kvlHLyErCgQwwzmDtaFC4XyOxXA4= +github.com/elastic/elastic-transport-go/v8 v8.6.0 h1:Y2S/FBjx1LlCv5m6pWAF2kDJAHoSjSRSJCApolgfthA= +github.com/elastic/elastic-transport-go/v8 v8.6.0/go.mod h1:YLHer5cj0csTzNFXoNQ8qhtGY1GTvSqPnKWKaqQE3Hk= +github.com/elastic/go-elasticsearch/v8 v8.15.0 h1:IZyJhe7t7WI3NEFdcHnf6IJXqpRf+8S8QWLtZYYyBYk= +github.com/elastic/go-elasticsearch/v8 v8.15.0/go.mod h1:HCON3zj4btpqs2N1jjsAy4a/fiAul+YBP00mBH4xik8= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= @@ -36,6 +38,11 @@ github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+ github.com/go-git/go-billy/v5 v5.5.0/go.mod h1:hmexnoNsr2SJU1Ju67OaNz5ASJY3+sHgFRpCtpDCKow= github.com/go-git/go-git/v5 v5.12.0 h1:7Md+ndsjrzZxbddRDZjF14qK+NN56sy6wkqaVrjZtys= github.com/go-git/go-git/v5 v5.12.0/go.mod h1:FTM9VKtnI2m65hNI/TenDDDnUf2Q9FHnXYjuz9i5OEY= +github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= +github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-resty/resty/v2 v2.15.3 h1:bqff+hcqAflpiF591hhJzNdkRsFhlB96CYfBwSFvql8= github.com/go-resty/resty/v2 v2.15.3/go.mod h1:0fHAoK7JoBy/Ch36N8VFeMsK7xQOHhvWaC3iOktwmIU= github.com/go-test/deep v1.0.8 h1:TDsG77qcSprGbC6vTN8OuXp5g+J+b5Pcguhf7Zt61VM= @@ -186,6 +193,14 @@ github.com/zclconf/go-cty v1.15.0 h1:tTCRWxsexYUmtt/wVxgDClUe+uQusuI443uL6e+5sXQ github.com/zclconf/go-cty v1.15.0/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940 h1:4r45xpDWB6ZMSMNJFMOjqrGHynW3DIBuR2H9j0ug+Mo= github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940/go.mod h1:CmBdvvj3nqzfzJ6nTCIwDTPZ56aVGvDrmztiO5g3qrM= +go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo= +go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo= +go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI= +go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco= +go.opentelemetry.io/otel/sdk v1.21.0 h1:FTt8qirL1EysG6sTQRZ5TokkU8d0ugCj8htOgThZXQ8= +go.opentelemetry.io/otel/sdk v1.21.0/go.mod h1:Nna6Yv7PWTdgJHVRD9hIYywQBRx7pbox6nwBnZIxl/E= +go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= +go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU= go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= diff --git a/internal/clients/api_client.go b/internal/clients/api_client.go index 3f9865d9d..35f3721ac 100644 --- a/internal/clients/api_client.go +++ b/internal/clients/api_client.go @@ -9,7 +9,7 @@ import ( "strings" "github.com/disaster37/go-kibana-rest/v8" - "github.com/elastic/go-elasticsearch/v7" + "github.com/elastic/go-elasticsearch/v8" "github.com/elastic/terraform-provider-elasticstack/generated/alerting" "github.com/elastic/terraform-provider-elasticstack/generated/connectors" "github.com/elastic/terraform-provider-elasticstack/generated/data_views" diff --git a/internal/clients/config/base.go b/internal/clients/config/base.go index 89f42a56b..9751b7c10 100644 --- a/internal/clients/config/base.go +++ b/internal/clients/config/base.go @@ -5,7 +5,7 @@ import ( "net/http" "os" - "github.com/elastic/go-elasticsearch/v7" + "github.com/elastic/go-elasticsearch/v8" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) diff --git a/internal/clients/config/client.go b/internal/clients/config/client.go index 83723d840..6e93010c1 100644 --- a/internal/clients/config/client.go +++ b/internal/clients/config/client.go @@ -2,7 +2,7 @@ package config import ( "github.com/disaster37/go-kibana-rest/v8" - "github.com/elastic/go-elasticsearch/v7" + "github.com/elastic/go-elasticsearch/v8" "github.com/elastic/terraform-provider-elasticstack/internal/clients/fleet" ) diff --git a/internal/clients/config/debug.go b/internal/clients/config/debug.go index 6c69ff2ff..09cc37b26 100644 --- a/internal/clients/config/debug.go +++ b/internal/clients/config/debug.go @@ -7,7 +7,7 @@ import ( "net/http/httputil" "time" - "github.com/elastic/go-elasticsearch/v7/estransport" + "github.com/elastic/elastic-transport-go/v8/elastictransport" "github.com/elastic/terraform-provider-elasticstack/internal/utils" "github.com/hashicorp/terraform-plugin-log/tflog" ) @@ -22,7 +22,7 @@ const logRespMsg = `%s API Response for [%s] Details: %s -----------------------------------------------------` -var _ estransport.Logger = &debugLogger{} +var _ elastictransport.Logger = &debugLogger{} type debugLogger struct { Name string diff --git a/internal/clients/config/elasticsearch.go b/internal/clients/config/elasticsearch.go index 6e68f1222..958fb6c8b 100644 --- a/internal/clients/config/elasticsearch.go +++ b/internal/clients/config/elasticsearch.go @@ -9,7 +9,7 @@ import ( "strconv" "strings" - "github.com/elastic/go-elasticsearch/v7" + "github.com/elastic/go-elasticsearch/v8" fwdiags "github.com/hashicorp/terraform-plugin-framework/diag" sdkdiags "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/logging" diff --git a/internal/clients/elasticsearch/index.go b/internal/clients/elasticsearch/index.go index 9f0fc46ee..f26864158 100644 --- a/internal/clients/elasticsearch/index.go +++ b/internal/clients/elasticsearch/index.go @@ -8,7 +8,7 @@ import ( "net/http" "strings" - "github.com/elastic/go-elasticsearch/v7/esapi" + "github.com/elastic/go-elasticsearch/v8/esapi" "github.com/elastic/terraform-provider-elasticstack/internal/clients" "github.com/elastic/terraform-provider-elasticstack/internal/models" "github.com/elastic/terraform-provider-elasticstack/internal/utils" @@ -268,9 +268,6 @@ func PutIndex(ctx context.Context, apiClient *clients.ApiClient, index *models.I esClient.Indices.Create.WithMasterTimeout(params.MasterTimeout), esClient.Indices.Create.WithTimeout(params.Timeout), } - if params.IncludeTypeName { - opts = append(opts, esClient.Indices.Create.WithIncludeTypeName(params.IncludeTypeName)) - } res, err := esClient.Indices.Create( index.Name, opts..., @@ -425,8 +422,7 @@ func UpdateIndexMappings(ctx context.Context, apiClient *clients.ApiClient, inde fwdiags.NewErrorDiagnostic(err.Error(), err.Error()), } } - req := esClient.Indices.PutMapping.WithIndex(index) - res, err := esClient.Indices.PutMapping(strings.NewReader(mappings), req, esClient.Indices.PutMapping.WithContext(ctx)) + res, err := esClient.Indices.PutMapping([]string{index}, strings.NewReader(mappings), esClient.Indices.PutMapping.WithContext(ctx)) if err != nil { return fwdiags.Diagnostics{ fwdiags.NewErrorDiagnostic(err.Error(), err.Error()), diff --git a/internal/clients/elasticsearch/logstash.go b/internal/clients/elasticsearch/logstash.go index b0b01120a..0addad880 100644 --- a/internal/clients/elasticsearch/logstash.go +++ b/internal/clients/elasticsearch/logstash.go @@ -41,7 +41,7 @@ func GetLogstashPipeline(ctx context.Context, apiClient *clients.ApiClient, pipe if err != nil { return nil, diag.FromErr(err) } - res, err := esClient.LogstashGetPipeline(pipelineID, esClient.LogstashGetPipeline.WithContext(ctx)) + res, err := esClient.LogstashGetPipeline(esClient.LogstashGetPipeline.WithDocumentID(pipelineID), esClient.LogstashGetPipeline.WithContext(ctx)) if err != nil { return nil, diag.FromErr(err) } diff --git a/internal/clients/elasticsearch/transform.go b/internal/clients/elasticsearch/transform.go index f50417e6b..7ca596564 100644 --- a/internal/clients/elasticsearch/transform.go +++ b/internal/clients/elasticsearch/transform.go @@ -8,8 +8,8 @@ import ( "net/http" "time" - "github.com/elastic/go-elasticsearch/v7" - "github.com/elastic/go-elasticsearch/v7/esapi" + "github.com/elastic/go-elasticsearch/v8" + "github.com/elastic/go-elasticsearch/v8/esapi" "github.com/elastic/terraform-provider-elasticstack/internal/clients" "github.com/elastic/terraform-provider-elasticstack/internal/models" "github.com/elastic/terraform-provider-elasticstack/internal/utils" diff --git a/internal/elasticsearch/index/index/create.go b/internal/elasticsearch/index/index/create.go index 5e8aa652f..00e2967f7 100644 --- a/internal/elasticsearch/index/index/create.go +++ b/internal/elasticsearch/index/index/create.go @@ -2,19 +2,14 @@ package index import ( "context" - "fmt" "github.com/elastic/terraform-provider-elasticstack/internal/clients" "github.com/elastic/terraform-provider-elasticstack/internal/clients/elasticsearch" "github.com/elastic/terraform-provider-elasticstack/internal/utils" - "github.com/hashicorp/go-version" - "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-framework/types" ) -var includeTypeNameMinUnsupportedVersion = version.Must(version.NewVersion("8.0.0")) - func (r Resource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { var planModel tfModel resp.Diagnostics.Append(req.Plan.Get(ctx, &planModel)...) @@ -49,20 +44,6 @@ func (r Resource) Create(ctx context.Context, req resource.CreateRequest, resp * } params := planModel.toPutIndexParams(serverFlavor) - serverVersion, sdkDiags := client.ServerVersion(ctx) - if sdkDiags.HasError() { - resp.Diagnostics.Append(utils.FrameworkDiagsFromSDK(sdkDiags)...) - return - } - - if params.IncludeTypeName && serverVersion.GreaterThanOrEqual(includeTypeNameMinUnsupportedVersion) { - resp.Diagnostics.AddAttributeError( - path.Root("include_type_name"), - "'include_type_name' field is only supported for Elasticsearch v7.x", - fmt.Sprintf("'include_type_name' field is only supported for Elasticsearch v7.x. Got %s", serverVersion), - ) - return - } resp.Diagnostics.Append(elasticsearch.PutIndex(ctx, client, &apiModel, ¶ms)...) if resp.Diagnostics.HasError() { diff --git a/internal/elasticsearch/index/index/models.go b/internal/elasticsearch/index/index/models.go index bc3c20573..2d81155d5 100644 --- a/internal/elasticsearch/index/index/models.go +++ b/internal/elasticsearch/index/index/models.go @@ -148,7 +148,6 @@ type tfModel struct { Mappings jsontypes.Normalized `tfsdk:"mappings"` SettingsRaw jsontypes.Normalized `tfsdk:"settings_raw"` DeletionProtection types.Bool `tfsdk:"deletion_protection"` - IncludeTypeName types.Bool `tfsdk:"include_type_name"` WaitForActiveShards types.String `tfsdk:"wait_for_active_shards"` MasterTimeout customtypes.Duration `tfsdk:"master_timeout"` Timeout customtypes.Duration `tfsdk:"timeout"` @@ -293,7 +292,6 @@ func (model tfModel) toPutIndexParams(serverFlavor string) models.PutIndexParams if serverFlavor != "serverless" { params.WaitForActiveShards = model.WaitForActiveShards.ValueString() - params.IncludeTypeName = model.IncludeTypeName.ValueBool() } return params diff --git a/internal/elasticsearch/index/index/models_test.go b/internal/elasticsearch/index/index/models_test.go index 0845ca8b5..c81d9bbc0 100644 --- a/internal/elasticsearch/index/index/models_test.go +++ b/internal/elasticsearch/index/index/models_test.go @@ -359,13 +359,11 @@ func Test_tfModel_toPutIndexParams(t *testing.T) { MasterTimeout: customtypes.NewDurationValue(expectedParams.MasterTimeout.String()), Timeout: customtypes.NewDurationValue(expectedParams.Timeout.String()), WaitForActiveShards: basetypes.NewStringValue(expectedParams.WaitForActiveShards), - IncludeTypeName: basetypes.NewBoolValue(expectedParams.IncludeTypeName), } flavor := "not_serverless" if isServerless { flavor = "serverless" - expectedParams.IncludeTypeName = false expectedParams.WaitForActiveShards = "" } diff --git a/internal/elasticsearch/index/index/schema.go b/internal/elasticsearch/index/index/schema.go index 115ea335b..3c9264373 100644 --- a/internal/elasticsearch/index/index/schema.go +++ b/internal/elasticsearch/index/index/schema.go @@ -480,14 +480,6 @@ func getSchema() schema.Schema { planmodifiers.BoolUseDefaultIfUnknown(true), }, }, - "include_type_name": schema.BoolAttribute{ - Description: "If true, a mapping type is expected in the body of mappings. Defaults to false. Supported for Elasticsearch 7.x.", - Optional: true, - Computed: true, - PlanModifiers: []planmodifier.Bool{ - planmodifiers.BoolUseDefaultIfUnknown(false), - }, - }, "wait_for_active_shards": schema.StringAttribute{ Description: "The number of shard copies that must be active before proceeding with the operation. Set to `all` or any positive integer up to the total number of shards in the index (number_of_replicas+1). Default: `1`, the primary shard. This value is ignored when running against Serverless projects.", Optional: true, diff --git a/internal/elasticsearch/index/indices/models.go b/internal/elasticsearch/index/indices/models.go index bd735ffdc..e548edef3 100644 --- a/internal/elasticsearch/index/indices/models.go +++ b/internal/elasticsearch/index/indices/models.go @@ -149,7 +149,6 @@ type indexTfModel struct { AnalysisFilter jsontypes.Normalized `tfsdk:"analysis_filter"` AnalysisNormalizer jsontypes.Normalized `tfsdk:"analysis_normalizer"` DeletionProtection types.Bool `tfsdk:"deletion_protection"` - IncludeTypeName types.Bool `tfsdk:"include_type_name"` WaitForActiveShards types.String `tfsdk:"wait_for_active_shards"` MasterTimeout customtypes.Duration `tfsdk:"master_timeout"` Timeout customtypes.Duration `tfsdk:"timeout"` diff --git a/internal/elasticsearch/index/indices/schema.go b/internal/elasticsearch/index/indices/schema.go index a5f6bd85c..17ba20a30 100644 --- a/internal/elasticsearch/index/indices/schema.go +++ b/internal/elasticsearch/index/indices/schema.go @@ -330,11 +330,6 @@ func getSchema() schema.Schema { Computed: true, Description: "Whether to allow Terraform to destroy the index. Unless this field is set to false in Terraform state, a terraform destroy or terraform apply command that deletes the instance will fail.", }, - "include_type_name": schema.BoolAttribute{ - Description: "If true, a mapping type is expected in the body of mappings. Defaults to false. Supported for Elasticsearch 7.x.", - Optional: true, - Computed: true, - }, "wait_for_active_shards": schema.StringAttribute{ Description: "The number of shard copies that must be active before proceeding with the operation. Set to `all` or any positive integer up to the total number of shards in the index (number_of_replicas+1). Default: `1`, the primary shard. This value is ignored when running against Serverless projects.", Optional: true, diff --git a/internal/elasticsearch/logstash/pipeline_test.go b/internal/elasticsearch/logstash/pipeline_test.go index 61dc3f4cc..8cf0346f4 100644 --- a/internal/elasticsearch/logstash/pipeline_test.go +++ b/internal/elasticsearch/logstash/pipeline_test.go @@ -176,7 +176,7 @@ func checkResourceLogstashPipelineDestroy(s *terraform.State) error { if err != nil { return err } - res, err := esClient.LogstashGetPipeline(compId.ResourceId) + res, err := esClient.LogstashGetPipeline(esClient.LogstashGetPipeline.WithDocumentID(compId.ResourceId)) if err != nil { return err } diff --git a/internal/models/models.go b/internal/models/models.go index 67b083975..b6f84dd6e 100644 --- a/internal/models/models.go +++ b/internal/models/models.go @@ -290,7 +290,6 @@ type PutIndexParams struct { WaitForActiveShards string MasterTimeout time.Duration Timeout time.Duration - IncludeTypeName bool // IncludeTypeName is supported only in v7.x } type IndexAlias struct { diff --git a/internal/utils/utils.go b/internal/utils/utils.go index 99d77365e..8368617c6 100644 --- a/internal/utils/utils.go +++ b/internal/utils/utils.go @@ -11,7 +11,7 @@ import ( "strings" "time" - "github.com/elastic/go-elasticsearch/v7/esapi" + "github.com/elastic/go-elasticsearch/v8/esapi" providerSchema "github.com/elastic/terraform-provider-elasticstack/internal/schema" "github.com/hashicorp/terraform-plugin-framework/diag" fwdiag "github.com/hashicorp/terraform-plugin-framework/diag" From 4a370c0888900299e7a5c0421120a5983608b559 Mon Sep 17 00:00:00 2001 From: Toby Brain Date: Sat, 5 Oct 2024 13:25:58 +1000 Subject: [PATCH 2/2] Changelog --- CHANGELOG.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f6c786c45..546ac5c84 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,14 @@ ## [Unreleased] +### Breaking changes + +- Remove support for specifying `include_type_name` from the `elasticstack_elasticsearch_index` resource. This parameter has been deprecated from 7.0, with indices restricted to a single type since 6.0. ([#832](https://github.com/elastic/terraform-provider-elasticstack/pull/832)) + +### Changes + - Fix secret handling `elasticstack_fleet_integration_policy` resource. ([#821](https://github.com/elastic/terraform-provider-elasticstack/pull/821)) -- Fix merge values for `elasticstack_kibana_synthetics_monitor` monitor locations ([#823](https://github.com/elastic/terraform-provider-elasticstack/pull/823) +- Fix merge values for `elasticstack_kibana_synthetics_monitor` monitor locations ([#823](https://github.com/elastic/terraform-provider-elasticstack/pull/823)) +- Migrate to a v8 Elasticsearch client ([#832](https://github.com/elastic/terraform-provider-elasticstack/pull/832)) ## [0.11.8] - 2024-10-02