diff --git a/.golangci.yml b/.golangci.yml index 104cf923ce..f94c70575a 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -152,6 +152,13 @@ linters: - common-false-positives - legacy - std-error-handling + rules: + # go-elasticsearch v9 keeps the legacy Config/NewClient API fully + # functional. Fleet Server still relies on that API while the option-based + # client configuration is migrated separately. + - linters: + - staticcheck + text: "SA1019: elasticsearch\\.(Config|NewClient) is deprecated" # Which file paths to exclude: they will be analyzed, but issues from them won't be reported. # "/" will be replaced by the current OS file path separator to properly work on Windows. # Default: [] diff --git a/NOTICE-fips.txt b/NOTICE-fips.txt index e754c10ace..369fee56e6 100644 --- a/NOTICE-fips.txt +++ b/NOTICE-fips.txt @@ -1082,12 +1082,12 @@ Contents of probable licence file $GOMODCACHE/github.com/elastic/elastic-agent-s -------------------------------------------------------------------------------- -Dependency : github.com/elastic/go-elasticsearch/v8 -Version: v8.19.6 +Dependency : github.com/elastic/go-elasticsearch/v9 +Version: v9.5.0 Licence type (autodetected): Apache-2.0 -------------------------------------------------------------------------------- -Contents of probable licence file $GOMODCACHE/github.com/elastic/go-elasticsearch/v8@v8.19.6/LICENSE: +Contents of probable licence file $GOMODCACHE/github.com/elastic/go-elasticsearch/v9@v9.5.0/LICENSE: Apache License Version 2.0, January 2004 diff --git a/NOTICE.txt b/NOTICE.txt index 40c75e78f6..333bc66765 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -1082,12 +1082,12 @@ Contents of probable licence file $GOMODCACHE/github.com/elastic/elastic-agent-s -------------------------------------------------------------------------------- -Dependency : github.com/elastic/go-elasticsearch/v8 -Version: v8.19.6 +Dependency : github.com/elastic/go-elasticsearch/v9 +Version: v9.5.0 Licence type (autodetected): Apache-2.0 -------------------------------------------------------------------------------- -Contents of probable licence file $GOMODCACHE/github.com/elastic/go-elasticsearch/v8@v8.19.6/LICENSE: +Contents of probable licence file $GOMODCACHE/github.com/elastic/go-elasticsearch/v9@v9.5.0/LICENSE: Apache License Version 2.0, January 2004 diff --git a/go.mod b/go.mod index a2e3effe2d..6b9f2947f4 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/elastic/elastic-agent-client/v7 v7.18.1 github.com/elastic/elastic-agent-libs v0.46.2 github.com/elastic/elastic-agent-system-metrics v0.14.4 - github.com/elastic/go-elasticsearch/v8 v8.19.6 + github.com/elastic/go-elasticsearch/v9 v9.5.0 github.com/elastic/go-ucfg v0.9.1 github.com/fxamacker/cbor/v2 v2.9.2 github.com/go-chi/chi/v5 v5.3.1 diff --git a/go.sum b/go.sum index a4c8954a78..547ce97fc7 100644 --- a/go.sum +++ b/go.sum @@ -43,8 +43,8 @@ github.com/elastic/elastic-agent-system-metrics v0.14.4 h1:XGGepNVOxhtfJmanQsgqC github.com/elastic/elastic-agent-system-metrics v0.14.4/go.mod h1:NyNMrdqMfznb/Zy8EmIAHlJpX6HuRlNW+bBL9UN7WQY= github.com/elastic/elastic-transport-go/v8 v8.9.0 h1:KeT/2P54F0xS0S8Y3Pf+tFDg4HmBgReQMB+BMz8dDAs= github.com/elastic/elastic-transport-go/v8 v8.9.0/go.mod h1:ssMTvNS2hwf7CaiGsRRsx4gQHFZ/jS/DkLcISxekWzc= -github.com/elastic/go-elasticsearch/v8 v8.19.6 h1:4qa7ecJkr5rLsoHKIVGbaqcFt2o57CnOHQJi9Pts/rk= -github.com/elastic/go-elasticsearch/v8 v8.19.6/go.mod h1:jeWebApE1oFEW/hKZqx/IRYmP/aa2+WMJkOfk+AduSI= +github.com/elastic/go-elasticsearch/v9 v9.5.0 h1:ye9pnajcrSE2Fra0Q++nJsi09p2dJTaN6YXKz7LL7WU= +github.com/elastic/go-elasticsearch/v9 v9.5.0/go.mod h1:EbZnYlTlbhNqRt98YW+QSM2SEKplN5o8J+G6d9STOVo= github.com/elastic/go-structform v0.0.12 h1:HXpzlAKyej8T7LobqKDThUw7BMhwV6Db24VwxNtgxCs= github.com/elastic/go-structform v0.0.12/go.mod h1:CZWf9aIRYY5SuKSmOhtXScE5uQiLZNqAFnwKR4OrIM4= github.com/elastic/go-sysinfo v1.15.1 h1:zBmTnFEXxIQ3iwcQuk7MzaUotmKRp3OabbbWM8TdzIQ= diff --git a/internal/pkg/api/handleFileDelivery.go b/internal/pkg/api/handleFileDelivery.go index b49681cfd1..bdc63aab8f 100644 --- a/internal/pkg/api/handleFileDelivery.go +++ b/internal/pkg/api/handleFileDelivery.go @@ -22,7 +22,7 @@ import ( "github.com/elastic/fleet-server/v7/internal/pkg/file" "github.com/elastic/fleet-server/v7/internal/pkg/file/delivery" "github.com/elastic/fleet-server/v7/internal/pkg/model" - "github.com/elastic/go-elasticsearch/v8" + "github.com/elastic/go-elasticsearch/v9" ) var ( diff --git a/internal/pkg/api/handleUpload.go b/internal/pkg/api/handleUpload.go index dbc533dd40..1c9ee825d6 100644 --- a/internal/pkg/api/handleUpload.go +++ b/internal/pkg/api/handleUpload.go @@ -27,7 +27,7 @@ import ( "github.com/elastic/fleet-server/v7/internal/pkg/file/cbor" "github.com/elastic/fleet-server/v7/internal/pkg/file/uploader" "github.com/elastic/fleet-server/v7/internal/pkg/model" - "github.com/elastic/go-elasticsearch/v8" + "github.com/elastic/go-elasticsearch/v9" ) const ( diff --git a/internal/pkg/api/handleUpload_test.go b/internal/pkg/api/handleUpload_test.go index c7a11933fc..89378b5b4f 100644 --- a/internal/pkg/api/handleUpload_test.go +++ b/internal/pkg/api/handleUpload_test.go @@ -31,7 +31,7 @@ import ( "github.com/elastic/fleet-server/v7/internal/pkg/file/uploader" "github.com/elastic/fleet-server/v7/internal/pkg/model" itesting "github.com/elastic/fleet-server/v7/internal/pkg/testing" - "github.com/elastic/go-elasticsearch/v8" + "github.com/elastic/go-elasticsearch/v9" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" diff --git a/internal/pkg/apikey/apikey.go b/internal/pkg/apikey/apikey.go index 0c4fee17e7..198b56c0f3 100644 --- a/internal/pkg/apikey/apikey.go +++ b/internal/pkg/apikey/apikey.go @@ -15,8 +15,8 @@ import ( "strings" "unicode/utf8" - "github.com/elastic/go-elasticsearch/v8" - "github.com/elastic/go-elasticsearch/v8/esapi" + "github.com/elastic/go-elasticsearch/v9" + "github.com/elastic/go-elasticsearch/v9/esapi" ) const ( diff --git a/internal/pkg/apikey/apikey_integration_test.go b/internal/pkg/apikey/apikey_integration_test.go index 42f24a4545..5e1a1b6e4a 100644 --- a/internal/pkg/apikey/apikey_integration_test.go +++ b/internal/pkg/apikey/apikey_integration_test.go @@ -12,7 +12,7 @@ import ( testlog "github.com/elastic/fleet-server/v7/internal/pkg/testing/log" - "github.com/elastic/go-elasticsearch/v8" + "github.com/elastic/go-elasticsearch/v9" "github.com/gofrs/uuid/v5" "github.com/google/go-cmp/cmp" ) diff --git a/internal/pkg/apikey/auth.go b/internal/pkg/apikey/auth.go index af05e0ecd0..37c23c5766 100644 --- a/internal/pkg/apikey/auth.go +++ b/internal/pkg/apikey/auth.go @@ -11,8 +11,8 @@ import ( "fmt" "net/http" - "github.com/elastic/go-elasticsearch/v8" - "github.com/elastic/go-elasticsearch/v8/esapi" + "github.com/elastic/go-elasticsearch/v9" + "github.com/elastic/go-elasticsearch/v9/esapi" "github.com/elastic/fleet-server/v7/internal/pkg/es" ) diff --git a/internal/pkg/apikey/auth_test.go b/internal/pkg/apikey/auth_test.go index 797db557d5..44ebb472e5 100644 --- a/internal/pkg/apikey/auth_test.go +++ b/internal/pkg/apikey/auth_test.go @@ -12,7 +12,7 @@ import ( "testing" "github.com/elastic/fleet-server/v7/internal/pkg/testing/esutil" - "github.com/elastic/go-elasticsearch/v8" + "github.com/elastic/go-elasticsearch/v9" "github.com/stretchr/testify/assert" ) diff --git a/internal/pkg/apikey/create.go b/internal/pkg/apikey/create.go index dc5d333f5f..0cc9f825c9 100644 --- a/internal/pkg/apikey/create.go +++ b/internal/pkg/apikey/create.go @@ -10,8 +10,8 @@ import ( "encoding/json" "fmt" - "github.com/elastic/go-elasticsearch/v8" - "github.com/elastic/go-elasticsearch/v8/esapi" + "github.com/elastic/go-elasticsearch/v9" + "github.com/elastic/go-elasticsearch/v9/esapi" "github.com/elastic/fleet-server/v7/internal/pkg/es" ) diff --git a/internal/pkg/apikey/invalidate.go b/internal/pkg/apikey/invalidate.go index cbd651ad97..0479ab6832 100644 --- a/internal/pkg/apikey/invalidate.go +++ b/internal/pkg/apikey/invalidate.go @@ -10,8 +10,8 @@ import ( "encoding/json" "fmt" - "github.com/elastic/go-elasticsearch/v8" - "github.com/elastic/go-elasticsearch/v8/esapi" + "github.com/elastic/go-elasticsearch/v9" + "github.com/elastic/go-elasticsearch/v9/esapi" "github.com/elastic/fleet-server/v7/internal/pkg/es" ) diff --git a/internal/pkg/bulk/engine.go b/internal/pkg/bulk/engine.go index d5723255d6..8e8cd3a0c6 100644 --- a/internal/pkg/bulk/engine.go +++ b/internal/pkg/bulk/engine.go @@ -29,8 +29,8 @@ import ( "go.elastic.co/apm/v2" "golang.org/x/sync/semaphore" - "github.com/elastic/go-elasticsearch/v8" - "github.com/elastic/go-elasticsearch/v8/esapi" + "github.com/elastic/go-elasticsearch/v9" + "github.com/elastic/go-elasticsearch/v9/esapi" ) type APIKey = apikey.APIKey diff --git a/internal/pkg/bulk/helpers.go b/internal/pkg/bulk/helpers.go index a5dda37ec4..2b9f5c68ac 100644 --- a/internal/pkg/bulk/helpers.go +++ b/internal/pkg/bulk/helpers.go @@ -10,7 +10,7 @@ import ( "io" "github.com/elastic/fleet-server/v7/internal/pkg/es" - "github.com/elastic/go-elasticsearch/v8/esapi" + "github.com/elastic/go-elasticsearch/v9/esapi" "github.com/rs/zerolog" ) diff --git a/internal/pkg/bulk/opApiKey.go b/internal/pkg/bulk/opApiKey.go index f831d5d81b..723e0befba 100644 --- a/internal/pkg/bulk/opApiKey.go +++ b/internal/pkg/bulk/opApiKey.go @@ -12,7 +12,7 @@ import ( "math" "github.com/elastic/fleet-server/v7/internal/pkg/apikey" - "github.com/elastic/go-elasticsearch/v8/esapi" + "github.com/elastic/go-elasticsearch/v9/esapi" "github.com/rs/zerolog" "go.elastic.co/apm/v2" ) diff --git a/internal/pkg/bulk/opBulk.go b/internal/pkg/bulk/opBulk.go index 437b743a15..e332d532dd 100644 --- a/internal/pkg/bulk/opBulk.go +++ b/internal/pkg/bulk/opBulk.go @@ -11,7 +11,7 @@ import ( "fmt" "time" - "github.com/elastic/go-elasticsearch/v8/esapi" + "github.com/elastic/go-elasticsearch/v9/esapi" "github.com/mailru/easyjson" "github.com/rs/zerolog" "go.elastic.co/apm/v2" diff --git a/internal/pkg/bulk/opRead.go b/internal/pkg/bulk/opRead.go index d7a17bd4c3..7b1b00c1f9 100644 --- a/internal/pkg/bulk/opRead.go +++ b/internal/pkg/bulk/opRead.go @@ -10,7 +10,7 @@ import ( "fmt" "time" - "github.com/elastic/go-elasticsearch/v8/esapi" + "github.com/elastic/go-elasticsearch/v9/esapi" "github.com/mailru/easyjson" "github.com/rs/zerolog" "go.elastic.co/apm/v2" diff --git a/internal/pkg/bulk/opSearch.go b/internal/pkg/bulk/opSearch.go index 6ed83b6576..5e67061abf 100644 --- a/internal/pkg/bulk/opSearch.go +++ b/internal/pkg/bulk/opSearch.go @@ -13,7 +13,7 @@ import ( "github.com/elastic/fleet-server/v7/internal/pkg/es" "github.com/elastic/fleet-server/v7/internal/pkg/sqn" - "github.com/elastic/go-elasticsearch/v8/esapi" + "github.com/elastic/go-elasticsearch/v9/esapi" "github.com/mailru/easyjson" "github.com/rs/zerolog" "go.elastic.co/apm/v2" diff --git a/internal/pkg/bulk/secret.go b/internal/pkg/bulk/secret.go index 1110912263..8a00f356ed 100644 --- a/internal/pkg/bulk/secret.go +++ b/internal/pkg/bulk/secret.go @@ -13,7 +13,7 @@ import ( "io" "net/http" - "github.com/elastic/go-elasticsearch/v8" + "github.com/elastic/go-elasticsearch/v9" "go.elastic.co/apm/v2" ) diff --git a/internal/pkg/bulk/secret_limit_test.go b/internal/pkg/bulk/secret_limit_test.go index 24a62d7dae..7d20bf0a74 100644 --- a/internal/pkg/bulk/secret_limit_test.go +++ b/internal/pkg/bulk/secret_limit_test.go @@ -15,7 +15,7 @@ import ( "testing" "time" - "github.com/elastic/go-elasticsearch/v8" + "github.com/elastic/go-elasticsearch/v9" "github.com/stretchr/testify/require" ) diff --git a/internal/pkg/bulk/secret_test.go b/internal/pkg/bulk/secret_test.go index ec20035984..b12a6a73f7 100644 --- a/internal/pkg/bulk/secret_test.go +++ b/internal/pkg/bulk/secret_test.go @@ -11,7 +11,7 @@ import ( "strings" "testing" - "github.com/elastic/go-elasticsearch/v8" + "github.com/elastic/go-elasticsearch/v9" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/internal/pkg/bulk/setup_test.go b/internal/pkg/bulk/setup_test.go index 0af0eaa6d1..feca15cb5b 100644 --- a/internal/pkg/bulk/setup_test.go +++ b/internal/pkg/bulk/setup_test.go @@ -15,7 +15,7 @@ import ( "time" "github.com/Pallinder/go-randomdata" - "github.com/elastic/go-elasticsearch/v8" + "github.com/elastic/go-elasticsearch/v9" "github.com/elastic/go-ucfg/yaml" "github.com/rs/xid" diff --git a/internal/pkg/checkin/bulk.go b/internal/pkg/checkin/bulk.go index 3be9d94188..32810a86c9 100644 --- a/internal/pkg/checkin/bulk.go +++ b/internal/pkg/checkin/bulk.go @@ -20,8 +20,8 @@ import ( "github.com/rs/zerolog" - estypes "github.com/elastic/go-elasticsearch/v8/typedapi/types" - "github.com/elastic/go-elasticsearch/v8/typedapi/types/enums/scriptlanguage" + estypes "github.com/elastic/go-elasticsearch/v9/typedapi/types" + "github.com/elastic/go-elasticsearch/v9/typedapi/types/enums/scriptlanguage" ) const defaultFlushInterval = 10 * time.Second diff --git a/internal/pkg/config/output.go b/internal/pkg/config/output.go index 277f41a477..27681c0196 100644 --- a/internal/pkg/config/output.go +++ b/internal/pkg/config/output.go @@ -22,7 +22,7 @@ import ( "github.com/elastic/elastic-agent-libs/transport/tlscommon" "github.com/elastic/fleet-server/v7/internal/pkg/logger/zap" - "github.com/elastic/go-elasticsearch/v8" + "github.com/elastic/go-elasticsearch/v9" "github.com/rs/zerolog" ) @@ -261,13 +261,13 @@ func (c *Elasticsearch) DiagRequests(ctx context.Context) []byte { hostURL, err := makeURL(c.Protocol, "", host, 9200) if err != nil { zerolog.Ctx(ctx).Warn().Err(err).Str("host", host).Msg("Unable to transform host to url.URL") - res.WriteString(fmt.Sprintf("Unable to transform host %q to url.URL: %v\n", host, err)) + fmt.Fprintf(&res, "Unable to transform host %q to url.URL: %v\n", host, err) continue } req, err := http.NewRequestWithContext(ctx, http.MethodGet, hostURL, nil) if err != nil { zerolog.Ctx(ctx).Warn().Err(err).Str("host", host).Msg("Unable to create request to host") - res.WriteString(fmt.Sprintf("Unable to create request to host %q: %v\n", host, err)) + fmt.Fprintf(&res, "Unable to create request to host %q: %v\n", host, err) continue } req.Header = headers.Clone() diff --git a/internal/pkg/config/output_test.go b/internal/pkg/config/output_test.go index 566340fbbd..c41690fc1c 100644 --- a/internal/pkg/config/output_test.go +++ b/internal/pkg/config/output_test.go @@ -25,7 +25,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/elastic/go-elasticsearch/v8" + "github.com/elastic/go-elasticsearch/v9" "github.com/elastic/elastic-agent-libs/transport/tlscommon" ) diff --git a/internal/pkg/dl/migration.go b/internal/pkg/dl/migration.go index 5f39b2d6c2..13fedfd369 100644 --- a/internal/pkg/dl/migration.go +++ b/internal/pkg/dl/migration.go @@ -12,7 +12,7 @@ import ( "net/http" "time" - "github.com/elastic/go-elasticsearch/v8/esapi" + "github.com/elastic/go-elasticsearch/v9/esapi" "github.com/rs/zerolog" "github.com/elastic/fleet-server/v7/internal/pkg/bulk" diff --git a/internal/pkg/es/client.go b/internal/pkg/es/client.go index 420721ad4b..0dff6fd78f 100644 --- a/internal/pkg/es/client.go +++ b/internal/pkg/es/client.go @@ -22,7 +22,7 @@ import ( "github.com/rs/zerolog" backoff "github.com/cenkalti/backoff/v7" - "github.com/elastic/go-elasticsearch/v8" + "github.com/elastic/go-elasticsearch/v9" ) const ( diff --git a/internal/pkg/es/client_test.go b/internal/pkg/es/client_test.go index c677a5dec4..a2cc88eb4d 100644 --- a/internal/pkg/es/client_test.go +++ b/internal/pkg/es/client_test.go @@ -24,7 +24,7 @@ import ( "github.com/elastic/fleet-server/v7/internal/pkg/testing/certs" "github.com/stretchr/testify/require" - "github.com/elastic/go-elasticsearch/v8" + "github.com/elastic/go-elasticsearch/v9" ) var enabled bool = true diff --git a/internal/pkg/es/delete.go b/internal/pkg/es/delete.go index 54014c6e4f..4f1cb8a2ce 100644 --- a/internal/pkg/es/delete.go +++ b/internal/pkg/es/delete.go @@ -8,7 +8,7 @@ import ( "context" "encoding/json" - "github.com/elastic/go-elasticsearch/v8" + "github.com/elastic/go-elasticsearch/v9" ) func DeleteIndices(ctx context.Context, es *elasticsearch.Client, indices []string) error { diff --git a/internal/pkg/es/info.go b/internal/pkg/es/info.go index 99de8c1e29..a0aa924088 100644 --- a/internal/pkg/es/info.go +++ b/internal/pkg/es/info.go @@ -9,7 +9,7 @@ import ( "encoding/json" "strings" - "github.com/elastic/go-elasticsearch/v8" + "github.com/elastic/go-elasticsearch/v9" ) type versionInfo struct { diff --git a/internal/pkg/file/delivery/delivery.go b/internal/pkg/file/delivery/delivery.go index 715bbfd911..ffbbc96de3 100644 --- a/internal/pkg/file/delivery/delivery.go +++ b/internal/pkg/file/delivery/delivery.go @@ -15,7 +15,7 @@ import ( "github.com/elastic/fleet-server/v7/internal/pkg/bulk" "github.com/elastic/fleet-server/v7/internal/pkg/file" "github.com/elastic/fleet-server/v7/internal/pkg/file/cbor" - "github.com/elastic/go-elasticsearch/v8" + "github.com/elastic/go-elasticsearch/v9" "github.com/rs/zerolog" "go.elastic.co/apm/v2" ) diff --git a/internal/pkg/file/delivery/delivery_test.go b/internal/pkg/file/delivery/delivery_test.go index 4bbbb0bdf8..c6a47b4be6 100644 --- a/internal/pkg/file/delivery/delivery_test.go +++ b/internal/pkg/file/delivery/delivery_test.go @@ -20,7 +20,7 @@ import ( "github.com/elastic/fleet-server/v7/internal/pkg/es" "github.com/elastic/fleet-server/v7/internal/pkg/file" itesting "github.com/elastic/fleet-server/v7/internal/pkg/testing" - "github.com/elastic/go-elasticsearch/v8" + "github.com/elastic/go-elasticsearch/v9" "github.com/rs/zerolog" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" diff --git a/internal/pkg/file/delivery/es.go b/internal/pkg/file/delivery/es.go index 78bc66c16a..1b96ae903c 100644 --- a/internal/pkg/file/delivery/es.go +++ b/internal/pkg/file/delivery/es.go @@ -14,8 +14,8 @@ import ( "github.com/elastic/fleet-server/v7/internal/pkg/dsl" "github.com/elastic/fleet-server/v7/internal/pkg/es" "github.com/elastic/fleet-server/v7/internal/pkg/file" - "github.com/elastic/go-elasticsearch/v8" - "github.com/elastic/go-elasticsearch/v8/esapi" + "github.com/elastic/go-elasticsearch/v9" + "github.com/elastic/go-elasticsearch/v9/esapi" "go.elastic.co/apm/v2" ) diff --git a/internal/pkg/file/uploader/es.go b/internal/pkg/file/uploader/es.go index 5c85340c9f..45407e0f23 100644 --- a/internal/pkg/file/uploader/es.go +++ b/internal/pkg/file/uploader/es.go @@ -16,8 +16,8 @@ import ( "github.com/elastic/fleet-server/v7/internal/pkg/es" "github.com/elastic/fleet-server/v7/internal/pkg/file" "github.com/elastic/fleet-server/v7/internal/pkg/file/cbor" - "github.com/elastic/go-elasticsearch/v8" - "github.com/elastic/go-elasticsearch/v8/esapi" + "github.com/elastic/go-elasticsearch/v9" + "github.com/elastic/go-elasticsearch/v9/esapi" "github.com/rs/zerolog" "go.elastic.co/apm/v2" ) diff --git a/internal/pkg/file/uploader/upload.go b/internal/pkg/file/uploader/upload.go index 6732a184d0..8c2880d0b8 100644 --- a/internal/pkg/file/uploader/upload.go +++ b/internal/pkg/file/uploader/upload.go @@ -15,7 +15,7 @@ import ( "github.com/elastic/fleet-server/v7/internal/pkg/bulk" "github.com/elastic/fleet-server/v7/internal/pkg/cache" "github.com/elastic/fleet-server/v7/internal/pkg/file" - "github.com/elastic/go-elasticsearch/v8" + "github.com/elastic/go-elasticsearch/v9" "github.com/gofrs/uuid/v5" "go.elastic.co/apm/v2" ) diff --git a/internal/pkg/gcheckpt/checkpoint.go b/internal/pkg/gcheckpt/checkpoint.go index 6f0fc1164b..fe57447f1a 100644 --- a/internal/pkg/gcheckpt/checkpoint.go +++ b/internal/pkg/gcheckpt/checkpoint.go @@ -18,8 +18,8 @@ import ( esh "github.com/elastic/fleet-server/v7/internal/pkg/es" "github.com/elastic/fleet-server/v7/internal/pkg/sqn" - "github.com/elastic/go-elasticsearch/v8" - "github.com/elastic/go-elasticsearch/v8/esapi" + "github.com/elastic/go-elasticsearch/v9" + "github.com/elastic/go-elasticsearch/v9/esapi" ) var ErrGlobalCheckpoint = errors.New("global checkpoint error") diff --git a/internal/pkg/monitor/monitor.go b/internal/pkg/monitor/monitor.go index e37e7f5e13..342eda4d2d 100644 --- a/internal/pkg/monitor/monitor.go +++ b/internal/pkg/monitor/monitor.go @@ -24,7 +24,7 @@ import ( "github.com/rs/zerolog" "go.elastic.co/apm/v2" - "github.com/elastic/go-elasticsearch/v8" + "github.com/elastic/go-elasticsearch/v9" ) const ( @@ -101,7 +101,7 @@ type simpleMonitorT struct { } // Option is a functional configuration option. -type Option func(SimpleMonitor) +type Option func(*simpleMonitorT) // NewSimple creates new SimpleMonitor. func NewSimple(index string, esCli, monCli *elasticsearch.Client, opts ...Option) (SimpleMonitor, error) { @@ -139,43 +139,43 @@ func NewSimple(index string, esCli, monCli *elasticsearch.Client, opts ...Option // WithFetchSize sets the fetch size of the monitor. func WithFetchSize(fetchSize int) Option { - return func(m SimpleMonitor) { + return func(m *simpleMonitorT) { if fetchSize > 0 { - m.(*simpleMonitorT).fetchSize = fetchSize + m.fetchSize = fetchSize } } } // WithPollTimeout sets the global checkpoint polling timeout func WithPollTimeout(to time.Duration) Option { - return func(m SimpleMonitor) { - m.(*simpleMonitorT).pollTimeout = to + return func(m *simpleMonitorT) { + m.pollTimeout = to } } // WithExpiration adds the expiration field to the monitor query. func WithExpiration(withExpiration bool) Option { - return func(m SimpleMonitor) { - m.(*simpleMonitorT).withExpiration = withExpiration + return func(m *simpleMonitorT) { + m.withExpiration = withExpiration } } // WithReadyChan allows to pass the channel that will signal when monitor is ready. func WithReadyChan(readyCh chan error) Option { - return func(m SimpleMonitor) { - m.(*simpleMonitorT).readyCh = readyCh + return func(m *simpleMonitorT) { + m.readyCh = readyCh } } func WithAPMTracer(tracer *apm.Tracer) Option { - return func(m SimpleMonitor) { - m.(*simpleMonitorT).tracer = tracer + return func(m *simpleMonitorT) { + m.tracer = tracer } } func WithDebounceTime(dur time.Duration) Option { - return func(m SimpleMonitor) { - m.(*simpleMonitorT).debounceTime = dur + return func(m *simpleMonitorT) { + m.debounceTime = dur } } @@ -418,8 +418,8 @@ func (m *simpleMonitorT) search(ctx context.Context, tmpl *dsl.Tmpl, params map[ res, err := m.esCli.FleetSearch( m.index, + bytes.NewBuffer(query), m.esCli.FleetSearch.WithContext(ctx), - m.esCli.FleetSearch.WithBody(bytes.NewBuffer(query)), m.esCli.FleetSearch.WithWaitForCheckpoints(seqNos.String()), ) if err != nil { diff --git a/internal/pkg/monitor/subscription_monitor.go b/internal/pkg/monitor/subscription_monitor.go index eda62894f4..7535b6a932 100644 --- a/internal/pkg/monitor/subscription_monitor.go +++ b/internal/pkg/monitor/subscription_monitor.go @@ -14,7 +14,7 @@ import ( "github.com/elastic/fleet-server/v7/internal/pkg/sqn" "github.com/rs/zerolog" - "github.com/elastic/go-elasticsearch/v8" + "github.com/elastic/go-elasticsearch/v9" "golang.org/x/sync/errgroup" ) diff --git a/internal/pkg/server/fleet_integration_test.go b/internal/pkg/server/fleet_integration_test.go index b34d9b1587..012a8d9dc6 100644 --- a/internal/pkg/server/fleet_integration_test.go +++ b/internal/pkg/server/fleet_integration_test.go @@ -33,7 +33,7 @@ import ( "golang.org/x/sync/errgroup" "github.com/elastic/elastic-agent-client/v7/pkg/client" - "github.com/elastic/go-elasticsearch/v8" + "github.com/elastic/go-elasticsearch/v9" "github.com/elastic/fleet-server/v7/internal/pkg/api" "github.com/elastic/fleet-server/v7/internal/pkg/apikey" @@ -436,9 +436,8 @@ func TestServerUnauthorized(t *testing.T) { srv.buildURL(agentID, "acks"), } - allurls := []string{ - srv.buildURL("", "enroll"), - } + allurls := make([]string, 0, 1+len(agenturls)) + allurls = append(allurls, srv.buildURL("", "enroll")) allurls = append(allurls, agenturls...) // Expecting no authorization header error diff --git a/internal/pkg/server/fleet_secrets_integration_test.go b/internal/pkg/server/fleet_secrets_integration_test.go index 96c71a512e..928d095d7c 100644 --- a/internal/pkg/server/fleet_secrets_integration_test.go +++ b/internal/pkg/server/fleet_secrets_integration_test.go @@ -22,7 +22,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/elastic/go-elasticsearch/v8" + "github.com/elastic/go-elasticsearch/v9" "github.com/elastic/fleet-server/v7/internal/pkg/api" "github.com/elastic/fleet-server/v7/internal/pkg/apikey" diff --git a/internal/pkg/server/otel_policy_secrets_integration_test.go b/internal/pkg/server/otel_policy_secrets_integration_test.go index 95ca09324b..3a5659dbf7 100644 --- a/internal/pkg/server/otel_policy_secrets_integration_test.go +++ b/internal/pkg/server/otel_policy_secrets_integration_test.go @@ -20,7 +20,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/elastic/go-elasticsearch/v8" + "github.com/elastic/go-elasticsearch/v9" "github.com/elastic/fleet-server/v7/internal/pkg/api" "github.com/elastic/fleet-server/v7/internal/pkg/apikey" diff --git a/internal/pkg/testing/bulk.go b/internal/pkg/testing/bulk.go index f890b7b16b..8a5b6bb778 100644 --- a/internal/pkg/testing/bulk.go +++ b/internal/pkg/testing/bulk.go @@ -7,7 +7,7 @@ package testing import ( "context" - "github.com/elastic/go-elasticsearch/v8" + "github.com/elastic/go-elasticsearch/v9" "github.com/rs/zerolog" "github.com/stretchr/testify/mock" "go.elastic.co/apm/v2" diff --git a/internal/pkg/testing/esutil/bootstrap.go b/internal/pkg/testing/esutil/bootstrap.go index c5bf60f001..f2e446869c 100644 --- a/internal/pkg/testing/esutil/bootstrap.go +++ b/internal/pkg/testing/esutil/bootstrap.go @@ -7,7 +7,7 @@ package esutil import ( "context" - "github.com/elastic/go-elasticsearch/v8" + "github.com/elastic/go-elasticsearch/v9" ) // EnsureIndex sets up the index if it doesn't exist. It's utilized for integration tests at the moment. diff --git a/internal/pkg/testing/esutil/client.go b/internal/pkg/testing/esutil/client.go index 5fbbdc33ae..7e636fbc4c 100644 --- a/internal/pkg/testing/esutil/client.go +++ b/internal/pkg/testing/esutil/client.go @@ -10,7 +10,7 @@ import ( "strings" "testing" - "github.com/elastic/go-elasticsearch/v8" + "github.com/elastic/go-elasticsearch/v9" "github.com/stretchr/testify/require" ) diff --git a/internal/pkg/testing/esutil/datastream.go b/internal/pkg/testing/esutil/datastream.go index 7fb1fb61fa..442f60cc68 100644 --- a/internal/pkg/testing/esutil/datastream.go +++ b/internal/pkg/testing/esutil/datastream.go @@ -12,7 +12,7 @@ import ( "github.com/rs/zerolog" - "github.com/elastic/go-elasticsearch/v8" + "github.com/elastic/go-elasticsearch/v9" ) func CreateDatastream(ctx context.Context, cli *elasticsearch.Client, name string) error { diff --git a/internal/pkg/testing/esutil/esutil.go b/internal/pkg/testing/esutil/esutil.go index e4a5949846..77f76be0f3 100644 --- a/internal/pkg/testing/esutil/esutil.go +++ b/internal/pkg/testing/esutil/esutil.go @@ -14,7 +14,7 @@ import ( "github.com/rs/zerolog" - "github.com/elastic/go-elasticsearch/v8/esapi" + "github.com/elastic/go-elasticsearch/v9/esapi" ) const ( diff --git a/internal/pkg/testing/esutil/ilm.go b/internal/pkg/testing/esutil/ilm.go index 817b0d2866..6ffad67b0a 100644 --- a/internal/pkg/testing/esutil/ilm.go +++ b/internal/pkg/testing/esutil/ilm.go @@ -14,7 +14,7 @@ import ( "github.com/rs/zerolog" - "github.com/elastic/go-elasticsearch/v8" + "github.com/elastic/go-elasticsearch/v9" ) // Can be cleaner but it's temporary bootstrap until it's moved to the elasticseach system index plugin @@ -150,8 +150,9 @@ func createILMPolicy(ctx context.Context, cli *elasticsearch.Client, name string // in that case let's just create the ILM policy zerolog.Ctx(ctx).Debug().Str("policy", policy).Str("body", body).Msg("Creating ILM policy") - res, err := cli.ILM.PutLifecycle(policy, - cli.ILM.PutLifecycle.WithBody(strings.NewReader(body)), + res, err := cli.ILM.PutLifecycle( + strings.NewReader(body), + policy, cli.ILM.PutLifecycle.WithContext(ctx), ) if err != nil { diff --git a/internal/pkg/testing/esutil/index.go b/internal/pkg/testing/esutil/index.go index 8164c603e5..777d454ec1 100644 --- a/internal/pkg/testing/esutil/index.go +++ b/internal/pkg/testing/esutil/index.go @@ -12,7 +12,7 @@ import ( "github.com/rs/zerolog" - "github.com/elastic/go-elasticsearch/v8" + "github.com/elastic/go-elasticsearch/v9" ) func CreateIndex(ctx context.Context, cli *elasticsearch.Client, name string) error { diff --git a/internal/pkg/testing/esutil/template.go b/internal/pkg/testing/esutil/template.go index 93db2585f0..8f2221d198 100644 --- a/internal/pkg/testing/esutil/template.go +++ b/internal/pkg/testing/esutil/template.go @@ -14,7 +14,7 @@ import ( "github.com/rs/zerolog" - "github.com/elastic/go-elasticsearch/v8" + "github.com/elastic/go-elasticsearch/v9" ) const ( diff --git a/internal/pkg/testing/setup.go b/internal/pkg/testing/setup.go index f011691484..b2113e2725 100644 --- a/internal/pkg/testing/setup.go +++ b/internal/pkg/testing/setup.go @@ -13,7 +13,7 @@ import ( "errors" "testing" - "github.com/elastic/go-elasticsearch/v8" + "github.com/elastic/go-elasticsearch/v9" "github.com/elastic/go-ucfg/yaml" "github.com/rs/xid" @@ -109,9 +109,9 @@ func CleanIndex(ctx context.Context, t *testing.T, bulker bulk.Bulk, index strin cli := bulker.Client() - res, err := cli.API.DeleteByQuery([]string{index}, bytes.NewReader(query), - cli.API.DeleteByQuery.WithContext(ctx), - cli.API.DeleteByQuery.WithRefresh(true), + res, err := cli.DeleteByQuery([]string{index}, bytes.NewReader(query), + cli.DeleteByQuery.WithContext(ctx), + cli.DeleteByQuery.WithRefresh(true), ) if err != nil { t.Fatalf("could not clean index %s, DeleteByQuery failed: %v", diff --git a/internal/pkg/ver/check.go b/internal/pkg/ver/check.go index ec4eb263b8..c2fc4d9bd9 100644 --- a/internal/pkg/ver/check.go +++ b/internal/pkg/ver/check.go @@ -19,7 +19,7 @@ import ( "github.com/hashicorp/go-version" - "github.com/elastic/go-elasticsearch/v8" + "github.com/elastic/go-elasticsearch/v9" ) // Variables to define errors when comparing versions.