From cb49160a823c27b670357d0c0686cbf00e43d4e4 Mon Sep 17 00:00:00 2001 From: 1gtm <1gtm@appscode.com> Date: Sat, 27 Apr 2024 11:09:16 +0000 Subject: [PATCH] Prepare for release v0.45.0 ProductLine: KubeDB Release: v2024.4.27 Release-tracker: https://github.com/kubedb/CHANGELOG/pull/89 Signed-off-by: 1gtm <1gtm@appscode.com> --- go.mod | 10 +- go.sum | 54 +- .../opensearch-go/v2/.gitignore | 2 + .../opensearch-go/v2/ADMINS.md | 17 +- .../opensearch-go/v2/CHANGELOG.md | 49 +- .../opensearch-go/v2/CODEOWNERS | 1 - .../opensearch-go/v2/CODE_OF_CONDUCT.md | 29 +- .../opensearch-go/v2/COMPATIBILITY.md | 15 +- .../opensearch-go/v2/CONTRIBUTING.md | 7 +- .../opensearch-go/v2/DEVELOPER_GUIDE.md | 56 +- .../opensearch-go/v2/MAINTAINERS.md | 23 +- .../opensearch-go/v2/Makefile | 38 +- .../opensearch-go/v2/README.md | 32 +- .../opensearch-go/v2/RELEASING.md | 8 +- .../opensearch-go/v2/SECURITY.md | 2 +- .../opensearch-go/v2/USER_GUIDE.md | 88 +- .../v2/internal/version/version.go | 2 +- .../opensearch-go/v2/opensearchapi/api._.go | 38 +- .../v2/opensearchapi/api.bulk.go | 14 +- .../v2/opensearchapi/api.delete_by_query.go | 14 +- .../v2/opensearchapi/api.exists.go | 16 +- .../v2/opensearchapi/api.exists_source.go | 16 +- .../v2/opensearchapi/api.explain.go | 16 +- .../opensearch-go/v2/opensearchapi/api.get.go | 16 +- .../v2/opensearchapi/api.get_source.go | 16 +- .../api.indices.create_datastream.go | 177 + .../api.indices.delete_datastream.go | 203 + .../api.indices.get_datastream.go | 198 + .../api.indices.get_datastream_stats.go | 199 + .../v2/opensearchapi/api.info.go | 29 +- .../v2/opensearchapi/api.mget.go | 14 +- .../opensearchapi/api.pointintime.create.go | 256 ++ .../opensearchapi/api.pointintime.delete.go | 237 ++ .../v2/opensearchapi/api.pointintime.get.go | 209 + .../v2/opensearchapi/api.search.go | 14 +- .../v2/opensearchapi/api.snapshot.delete.go | 10 +- .../v2/opensearchapi/api.update.go | 16 +- .../v2/opensearchapi/api.update_by_query.go | 14 +- .../v2/opensearchtransport/logger.go | 8 +- .../opensearchtransport.go | 15 +- .../github.com/redis/go-redis/v9/.gitignore | 3 + .../redis/go-redis/v9/CONTRIBUTING.md | 101 + vendor/github.com/redis/go-redis/v9/Makefile | 9 +- vendor/github.com/redis/go-redis/v9/README.md | 97 +- .../redis/go-redis/v9/acl_commands.go | 35 + .../redis/go-redis/v9/bitmap_commands.go | 163 + .../redis/go-redis/v9/cluster_commands.go | 285 +- .../github.com/redis/go-redis/v9/command.go | 353 +- .../github.com/redis/go-redis/v9/commands.go | 3649 +---------------- vendor/github.com/redis/go-redis/v9/error.go | 7 +- .../redis/go-redis/v9/gears_commands.go | 149 + .../redis/go-redis/v9/generic_commands.go | 384 ++ .../redis/go-redis/v9/geo_commands.go | 155 + .../redis/go-redis/v9/hash_commands.go | 174 + .../redis/go-redis/v9/hyperloglog_commands.go | 42 + .../go-redis/v9/internal/hscan/structmap.go | 6 +- .../go-redis/v9/internal/pool/conn_check.go | 1 - .../v9/internal/pool/conn_check_dummy.go | 1 - .../redis/go-redis/v9/internal/pool/pool.go | 22 +- .../go-redis/v9/internal/proto/writer.go | 31 + .../redis/go-redis/v9/internal/util.go | 20 + .../redis/go-redis/v9/internal/util/safe.go | 1 - .../redis/go-redis/v9/internal/util/type.go | 5 + .../redis/go-redis/v9/internal/util/unsafe.go | 1 - vendor/github.com/redis/go-redis/v9/json.go | 599 +++ .../redis/go-redis/v9/list_commands.go | 289 ++ .../github.com/redis/go-redis/v9/options.go | 15 +- .../go-redis/v9/{cluster.go => osscluster.go} | 66 +- .../redis/go-redis/v9/osscluster_commands.go | 109 + .../github.com/redis/go-redis/v9/package.json | 8 - .../redis/go-redis/v9/probabilistic.go | 1429 +++++++ vendor/github.com/redis/go-redis/v9/pubsub.go | 4 +- .../redis/go-redis/v9/pubsub_commands.go | 76 + vendor/github.com/redis/go-redis/v9/redis.go | 25 + vendor/github.com/redis/go-redis/v9/ring.go | 41 +- .../redis/go-redis/v9/scripting_commands.go | 215 + .../github.com/redis/go-redis/v9/sentinel.go | 30 +- .../redis/go-redis/v9/set_commands.go | 217 + .../redis/go-redis/v9/sortedset_commands.go | 772 ++++ .../redis/go-redis/v9/stream_commands.go | 438 ++ .../redis/go-redis/v9/string_commands.go | 303 ++ .../redis/go-redis/v9/timeseries_commands.go | 922 +++++ .../github.com/redis/go-redis/v9/universal.go | 16 + .../github.com/redis/go-redis/v9/version.go | 2 +- vendor/golang.org/x/sync/errgroup/errgroup.go | 3 + .../autoscaling/v1alpha1/mongodb_webhook.go | 22 + .../autoscaling/v1alpha1/openapi_generated.go | 86 + .../apis/autoscaling/v1alpha1/type.go | 26 +- .../autoscaling/v1alpha1/webhook_helpers.go | 91 +- .../v1alpha1/zz_generated.deepcopy.go | 88 +- ...g.kubedb.com_elasticsearchautoscalers.yaml | 216 + ...toscaling.kubedb.com_kafkaautoscalers.yaml | 54 + ...scaling.kubedb.com_mariadbautoscalers.yaml | 18 + ...scaling.kubedb.com_mongodbautoscalers.yaml | 90 + ...toscaling.kubedb.com_mysqlautoscalers.yaml | 18 + ...g.kubedb.com_perconaxtradbautoscalers.yaml | 18 + ...caling.kubedb.com_postgresautoscalers.yaml | 18 + ...caling.kubedb.com_rabbitmqautoscalers.yaml | 18 + ...toscaling.kubedb.com_redisautoscalers.yaml | 54 + vendor/modules.txt | 10 +- 100 files changed, 10311 insertions(+), 3967 deletions(-) delete mode 100644 vendor/github.com/opensearch-project/opensearch-go/v2/CODEOWNERS create mode 100644 vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.indices.create_datastream.go create mode 100644 vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.indices.delete_datastream.go create mode 100644 vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.indices.get_datastream.go create mode 100644 vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.indices.get_datastream_stats.go create mode 100644 vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.pointintime.create.go create mode 100644 vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.pointintime.delete.go create mode 100644 vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.pointintime.get.go create mode 100644 vendor/github.com/redis/go-redis/v9/CONTRIBUTING.md create mode 100644 vendor/github.com/redis/go-redis/v9/acl_commands.go create mode 100644 vendor/github.com/redis/go-redis/v9/bitmap_commands.go create mode 100644 vendor/github.com/redis/go-redis/v9/gears_commands.go create mode 100644 vendor/github.com/redis/go-redis/v9/generic_commands.go create mode 100644 vendor/github.com/redis/go-redis/v9/geo_commands.go create mode 100644 vendor/github.com/redis/go-redis/v9/hash_commands.go create mode 100644 vendor/github.com/redis/go-redis/v9/hyperloglog_commands.go create mode 100644 vendor/github.com/redis/go-redis/v9/internal/util/type.go create mode 100644 vendor/github.com/redis/go-redis/v9/json.go create mode 100644 vendor/github.com/redis/go-redis/v9/list_commands.go rename vendor/github.com/redis/go-redis/v9/{cluster.go => osscluster.go} (96%) create mode 100644 vendor/github.com/redis/go-redis/v9/osscluster_commands.go delete mode 100644 vendor/github.com/redis/go-redis/v9/package.json create mode 100644 vendor/github.com/redis/go-redis/v9/probabilistic.go create mode 100644 vendor/github.com/redis/go-redis/v9/pubsub_commands.go create mode 100644 vendor/github.com/redis/go-redis/v9/scripting_commands.go create mode 100644 vendor/github.com/redis/go-redis/v9/set_commands.go create mode 100644 vendor/github.com/redis/go-redis/v9/sortedset_commands.go create mode 100644 vendor/github.com/redis/go-redis/v9/stream_commands.go create mode 100644 vendor/github.com/redis/go-redis/v9/string_commands.go create mode 100644 vendor/github.com/redis/go-redis/v9/timeseries_commands.go diff --git a/go.mod b/go.mod index 84353f97e..4eff60bf8 100644 --- a/go.mod +++ b/go.mod @@ -29,8 +29,8 @@ require ( kmodules.xyz/client-go v0.29.13 kmodules.xyz/custom-resources v0.29.1 kmodules.xyz/monitoring-agent-api v0.29.0 - kubedb.dev/apimachinery v0.45.0 - kubedb.dev/db-client-go v0.0.14 + kubedb.dev/apimachinery v0.45.1 + kubedb.dev/db-client-go v0.0.15 sigs.k8s.io/controller-runtime v0.17.2 sigs.k8s.io/yaml v1.4.0 stash.appscode.dev/apimachinery v0.34.0 @@ -96,14 +96,14 @@ require ( github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect github.com/onsi/gomega v1.31.1 // indirect github.com/opensearch-project/opensearch-go v1.1.0 // indirect - github.com/opensearch-project/opensearch-go/v2 v2.2.0 // indirect + github.com/opensearch-project/opensearch-go/v2 v2.3.0 // indirect github.com/peterbourgon/diskv v2.0.1+incompatible // indirect github.com/pkg/errors v0.9.1 // indirect github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.71.2 // indirect github.com/prometheus-operator/prometheus-operator/pkg/client v0.70.0 // indirect github.com/prometheus/client_model v0.5.0 // indirect github.com/prometheus/procfs v0.12.0 // indirect - github.com/redis/go-redis/v9 v9.0.5 // indirect + github.com/redis/go-redis/v9 v9.5.1 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/sergi/go-diff v1.2.0 // indirect github.com/spf13/pflag v1.0.5 // indirect @@ -115,7 +115,7 @@ require ( golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect golang.org/x/net v0.23.0 // indirect golang.org/x/oauth2 v0.15.0 // indirect - golang.org/x/sync v0.5.0 // indirect + golang.org/x/sync v0.6.0 // indirect golang.org/x/sys v0.18.0 // indirect golang.org/x/term v0.18.0 // indirect golang.org/x/time v0.5.0 // indirect diff --git a/go.sum b/go.sum index 45f179cff..d6c3ebb39 100644 --- a/go.sum +++ b/go.sum @@ -28,18 +28,18 @@ github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= github.com/aws/aws-sdk-go v1.42.27/go.mod h1:OGr6lGMAKGlG9CVrYnWYDKIyb829c6EVBRjxqjmPepc= -github.com/aws/aws-sdk-go v1.44.180/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= -github.com/aws/aws-sdk-go-v2 v1.17.3/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= -github.com/aws/aws-sdk-go-v2/config v1.18.8/go.mod h1:5XCmmyutmzzgkpk/6NYTjeWb6lgo9N170m1j6pQkIBs= -github.com/aws/aws-sdk-go-v2/credentials v1.13.8/go.mod h1:lVa4OHbvgjVot4gmh1uouF1ubgexSCN92P6CJQpT0t8= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.21/go.mod h1:ugwW57Z5Z48bpvUyZuaPy4Kv+vEfJWnIrky7RmkBvJg= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.27/go.mod h1:a1/UpzeyBBerajpnP5nGZa9mGzsBn5cOKxm6NWQsvoI= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.21/go.mod h1:+Gxn8jYn5k9ebfHEqlhrMirFjSW0v0C9fI+KN5vk2kE= -github.com/aws/aws-sdk-go-v2/internal/ini v1.3.28/go.mod h1:yRZVr/iT0AqyHeep00SZ4YfBAKojXz08w3XMBscdi0c= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.21/go.mod h1:lRToEJsn+DRA9lW4O9L9+/3hjTkUzlzyzHqn8MTds5k= -github.com/aws/aws-sdk-go-v2/service/sso v1.12.0/go.mod h1:wo/B7uUm/7zw/dWhBJ4FXuw1sySU5lyIhVg1Bu2yL9A= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.0/go.mod h1:TZSH7xLO7+phDtViY/KUp9WGCJMQkLJ/VpgkTFd5gh8= -github.com/aws/aws-sdk-go-v2/service/sts v1.18.0/go.mod h1:+lGbb3+1ugwKrNTWcf2RT05Xmp543B06zDFTwiTLp7I= +github.com/aws/aws-sdk-go v1.44.263/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= +github.com/aws/aws-sdk-go-v2 v1.18.0/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= +github.com/aws/aws-sdk-go-v2/config v1.18.25/go.mod h1:dZnYpD5wTW/dQF0rRNLVypB396zWCcPiBIvdvSWHEg4= +github.com/aws/aws-sdk-go-v2/credentials v1.13.24/go.mod h1:jYPYi99wUOPIFi0rhiOvXeSEReVOzBqFNOX5bXYoG2o= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.3/go.mod h1:4Q0UFP0YJf0NrsEuEYHpM9fTSEVnD16Z3uyEF7J9JGM= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.33/go.mod h1:7i0PF1ME/2eUPFcjkVIwq+DOygHEoK92t5cDqNgYbIw= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.27/go.mod h1:UrHnn3QV/d0pBZ6QBAEQcqFLf8FAzLmoUfPVIueOvoM= +github.com/aws/aws-sdk-go-v2/internal/ini v1.3.34/go.mod h1:Etz2dj6UHYuw+Xw830KfzCfWGMzqvUTCjUj5b76GVDc= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.27/go.mod h1:EOwBD4J4S5qYszS5/3DpkejfuK+Z5/1uzICfPaZLtqw= +github.com/aws/aws-sdk-go-v2/service/sso v1.12.10/go.mod h1:ouy2P4z6sJN70fR3ka3wD3Ro3KezSxU6eKGQI2+2fjI= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.10/go.mod h1:AFvkxc8xfBe8XA+5St5XIHHrQQtkxqrRincx4hmMHOk= +github.com/aws/aws-sdk-go-v2/service/sts v1.19.0/go.mod h1:BgQOMsg8av8jset59jelyPW7NoZcZXLVpDsXunGDrk8= github.com/aws/smithy-go v1.13.5/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= @@ -49,10 +49,10 @@ github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kB github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84= github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM= github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ= -github.com/bsm/ginkgo/v2 v2.7.0 h1:ItPMPH90RbmZJt5GtkcNvIRuGEdwlBItdNVoyzaNQao= -github.com/bsm/ginkgo/v2 v2.7.0/go.mod h1:AiKlXPm7ItEHNc/2+OkrNG4E0ITzojb9/xWzvQ9XZ9w= -github.com/bsm/gomega v1.26.0 h1:LhQm+AFcgV2M0WyKroMASzAzCAJVpAxQXv4SaI9a69Y= -github.com/bsm/gomega v1.26.0/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0= +github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs= +github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c= +github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA= +github.com/bsm/gomega v1.27.10/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cert-manager/cert-manager v1.13.3 h1:3R4G0RI7K0OkTZhWlVOC5SGZMYa2NwqmQJoyKydrz/M= github.com/cert-manager/cert-manager v1.13.3/go.mod h1:BM2+Pt/NmSv1Zr25/MHv6BgIEF9IUxA1xAjp80qkxgc= @@ -326,8 +326,8 @@ github.com/onsi/gomega v1.31.1 h1:KYppCUK+bUgAZwHOu7EXVBKyQA6ILvOESHkn/tgoqvo= github.com/onsi/gomega v1.31.1/go.mod h1:y40C95dwAD1Nz36SsEnxvfFe8FFfNxzI5eJ0EYGyAy0= github.com/opensearch-project/opensearch-go v1.1.0 h1:eG5sh3843bbU1itPRjA9QXbxcg8LaZ+DjEzQH9aLN3M= github.com/opensearch-project/opensearch-go v1.1.0/go.mod h1:+6/XHCuTH+fwsMJikZEWsucZ4eZMma3zNSeLrTtVGbo= -github.com/opensearch-project/opensearch-go/v2 v2.2.0 h1:6RicCBiqboSVtLMjSiKgVQIsND4I3sxELg9uwWe/TKM= -github.com/opensearch-project/opensearch-go/v2 v2.2.0/go.mod h1:R8NTTQMmfSRsmZdfEn2o9ZSuSXn0WTHPYhzgl7LCFLY= +github.com/opensearch-project/opensearch-go/v2 v2.3.0 h1:nQIEMr+A92CkhHrZgUhcfsrZjibvB3APXf2a1VwCmMQ= +github.com/opensearch-project/opensearch-go/v2 v2.3.0/go.mod h1:8LDr9FCgUTVoT+5ESjc2+iaZuldqE+23Iq0r1XeNue8= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/peterbourgon/diskv v2.0.1+incompatible h1:UBdAOUP5p4RWqPBg048CAvpKN+vxiaj6gdUUzhl4XmI= @@ -362,8 +362,8 @@ github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7z github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= -github.com/redis/go-redis/v9 v9.0.5 h1:CuQcn5HIEeK7BgElubPP8CGtE0KakrnbBSTLjathl5o= -github.com/redis/go-redis/v9 v9.0.5/go.mod h1:WqMKv5vnQbRuZstUwxQI195wHy+t4PuXDOjzMvcuQHk= +github.com/redis/go-redis/v9 v9.5.1 h1:H1X4D3yHPaYrkL5X06Wh6xNVM/pX0Ft4RV0vMGvLBh8= +github.com/redis/go-redis/v9 v9.5.1/go.mod h1:hdY0cQFCN4fnSYT6TkisLufl/4W5UIXyv0b/CLO2V2M= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= @@ -404,6 +404,7 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= @@ -492,6 +493,7 @@ golang.org/x/net v0.0.0-20211216030914-fe4d6282115f/go.mod h1:9nx3DQGgdP8bBQD5qx golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= @@ -510,8 +512,8 @@ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE= -golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= +golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -732,10 +734,10 @@ kmodules.xyz/prober v0.29.0 h1:Ex7m4F9rH7uWNNJlLgP63ROOM+nUATJkC2L5OQ7nwMg= kmodules.xyz/prober v0.29.0/go.mod h1:UtK+HKyI1lFLEKX+HFLyOCVju6TO93zv3kwGpzqmKOo= kmodules.xyz/resource-metadata v0.18.2 h1:rfyq0Wnzx/2OiWGFbHTRp9cVvr2KI8xOCyy7gUVytm4= kmodules.xyz/resource-metadata v0.18.2/go.mod h1:Vb2bFCOX4uz2TsRRMzTkUqFWWOjJ261lY8Hs2HWgzh4= -kubedb.dev/apimachinery v0.45.0 h1:Oo4moYX6SC03pIMmdnBd0kJMPp+MwojFyBmZd/5QJX4= -kubedb.dev/apimachinery v0.45.0/go.mod h1:mVmsjSF2KmJzFrIx0rZo9KWee/zUcYmw8OqgcuvR2TA= -kubedb.dev/db-client-go v0.0.14 h1:wB/lei/ZnJi+wdN2gqIMqpNNkQFkmp2lziDA24JqC0I= -kubedb.dev/db-client-go v0.0.14/go.mod h1:XmjhrQQ2KjWsm4lPU0vKoHqKMawVO/5qxsytVs2zeg4= +kubedb.dev/apimachinery v0.45.1 h1:J5hzWF5tXeI6uwTwz9Uyi0CJdLB2CCmUvoFMngKRnas= +kubedb.dev/apimachinery v0.45.1/go.mod h1:mVmsjSF2KmJzFrIx0rZo9KWee/zUcYmw8OqgcuvR2TA= +kubedb.dev/db-client-go v0.0.15 h1:ktUw9CxLzncZl0P7kGMG3gMfgltnaLrXqnf4qk6W5cU= +kubedb.dev/db-client-go v0.0.15/go.mod h1:OcmkFT4b5OlFVUeoZrpcL6LWfy/y5LG8ncVNWPbvjJA= kubeops.dev/petset v0.0.5 h1:VVXi39JhjondlbHyZ98z0MLp6VCmiCMinL59K48Y2zA= kubeops.dev/petset v0.0.5/go.mod h1:ijtKT1HlAht2vBEZj5LW7C00XEs3B0d1VdCQgd5V4cA= kubeops.dev/sidekick v0.0.5 h1:HFeAVomGJmSmbnxoNiT+uP97IjgCY17zG4RtPUlzVZs= diff --git a/vendor/github.com/opensearch-project/opensearch-go/v2/.gitignore b/vendor/github.com/opensearch-project/opensearch-go/v2/.gitignore index c21189ca9..8c2fd150a 100644 --- a/vendor/github.com/opensearch-project/opensearch-go/v2/.gitignore +++ b/vendor/github.com/opensearch-project/opensearch-go/v2/.gitignore @@ -5,3 +5,5 @@ tmp/ .idea .vscode bin/ + +.DS_Store \ No newline at end of file diff --git a/vendor/github.com/opensearch-project/opensearch-go/v2/ADMINS.md b/vendor/github.com/opensearch-project/opensearch-go/v2/ADMINS.md index 302ead52f..f9220c93b 100644 --- a/vendor/github.com/opensearch-project/opensearch-go/v2/ADMINS.md +++ b/vendor/github.com/opensearch-project/opensearch-go/v2/ADMINS.md @@ -4,19 +4,20 @@ - [Prioritize Security](#prioritize-security) - [Enforce Code of Conduct](#enforce-code-of-conduct) - [Adopt Organizational Best Practices](#adopt-organizational-best-practices) + ## Overview This document explains who the admins are (see below), what they do in this repo, and how they should be doing it. If you're interested in becoming a maintainer, see [MAINTAINERS](MAINTAINERS.md). If you're interested in contributing, see [CONTRIBUTING](CONTRIBUTING.md). ## Current Admins -| Admin | GitHub ID | Affiliation | -| -------------------------| --------------------------------------- | ----------- | -| Charlotte | [CEHENKLE](https://github.com/CEHENKLE) | Amazon | -| Henri Yandell | [hyandell](https://github.com/hyandell) | Amazon | -| Jack Mazanec | [jmazanec15](https://github.com/jmazanec15) | Amazon | -| Vamshi Vijay Nakkirtha | [vamshin](https://github.com/vamshin) | Amazon | -| Vijayan Balasubramanian | [VijayanB](https://github.com/VijayanB) | Amazon | +| Admin | GitHub ID | Affiliation | +| --- | --- | --- | +| Charlotte | [CEHENKLE](https://github.com/CEHENKLE) | Amazon | +| Henri Yandell | [hyandell](https://github.com/hyandell) | Amazon | +| Jack Mazanec | [jmazanec15](https://github.com/jmazanec15) | Amazon | +| Vamshi Vijay Nakkirtha | [vamshin](https://github.com/vamshin) | Amazon | +| Vijayan Balasubramanian | [VijayanB](https://github.com/VijayanB) | Amazon | ## Admin Responsibilities @@ -34,4 +35,4 @@ Act on [CODE_OF_CONDUCT](CODE_OF_CONDUCT.md) violations by revoking access, and ### Adopt Organizational Best Practices -Adopt organizational best practices, work in the open, and collaborate with other admins by opening issues before making process changes. Prefer consistency, and avoid diverging from practices in the opensearch-project organization. \ No newline at end of file +Adopt organizational best practices, work in the open, and collaborate with other admins by opening issues before making process changes. Prefer consistency, and avoid diverging from practices in the opensearch-project organization. diff --git a/vendor/github.com/opensearch-project/opensearch-go/v2/CHANGELOG.md b/vendor/github.com/opensearch-project/opensearch-go/v2/CHANGELOG.md index 163f453b7..dbb6ea11b 100644 --- a/vendor/github.com/opensearch-project/opensearch-go/v2/CHANGELOG.md +++ b/vendor/github.com/opensearch-project/opensearch-go/v2/CHANGELOG.md @@ -1,34 +1,53 @@ # CHANGELOG + Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ## [Unreleased] + ### Dependencies -- Bumps `github.com/aws/aws-sdk-go-v2` from 1.17.1 to 1.17.3 -- Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.17.10 to 1.18.8 -- Bumps `github.com/aws/aws-sdk-go` from 1.44.176 to 1.44.180 -- Bumps `github.com/aws/aws-sdk-go` from 1.44.132 to 1.44.180 + +- Bumps `github.com/aws/aws-sdk-go` from 1.44.180 to 1.44.263 +- Bumps `github.com/aws/aws-sdk-go-v2` from 1.17.4 to 1.18.0 +- Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.8 to 1.18.25 +- Bumps `github.com/stretchr/testify` from 1.8.1 to 1.8.2 ### Added -- Github workflow for changelog verification ([#172](https://github.com/opensearch-project/opensearch-go/pull/172)) -- Add Go Documentation link for the client ([#182](https://github.com/opensearch-project/opensearch-go/pull/182)) -- Support for Amazon OpenSearch Serverless ([#216](https://github.com/opensearch-project/opensearch-go/pull/216)) -### Dependencies -- Bumps `github.com/stretchr/testify` from 1.8.0 to 1.8.1 -- Bumps `github.com/aws/aws-sdk-go` from 1.44.45 to 1.44.132 +- Adds implementation of Data Streams API ([#257](https://github.com/opensearch-project/opensearch-go/pull/257)) +- Adds Point In Time API ([#253](https://github.com/opensearch-project/opensearch-go/pull/253)) +- Adds InfoResp type ([#253](https://github.com/opensearch-project/opensearch-go/pull/253)) +- Adds markdown linter ([#261](https://github.com/opensearch-project/opensearch-go/pull/261)) +- Adds testcases to check upsert functionality ([#269](https://github.com/opensearch-project/opensearch-go/pull/269)) +- Adds @Jakob3xD to co-maintainers ([#270](https://github.com/opensearch-project/opensearch-go/pull/270)) +- Adds dynamic type to \_source field ([#285](https://github.com/opensearch-project/opensearch-go/pull/285)) +- Adds testcases for Document API ([#285](https://github.com/opensearch-project/opensearch-go/pull/285)) +- Adds `index_lifecycle` guide ([#287](https://github.com/opensearch-project/opensearch-go/pull/287)) +- Adds `bulk` guide ([#292](https://github.com/opensearch-project/opensearch-go/pull/292)) +- Adds `search` guide ([#291](https://github.com/opensearch-project/opensearch-go/pull/291)) +- Adds `document_lifecycle` guide ([#290](https://github.com/opensearch-project/opensearch-go/pull/290)) +- Adds `index_template` guide ([#289](https://github.com/opensearch-project/opensearch-go/pull/289)) +- Adds `advanced_index_actions` guide ([#288](https://github.com/opensearch-project/opensearch-go/pull/288)) +- Adds testcases to check UpdateByQuery functionality ([#304](https://github.com/opensearch-project/opensearch-go/pull/304)) +- Adds additional timeout after cluster start ([#303](https://github.com/opensearch-project/opensearch-go/pull/303)) +- Adds docker healthcheck to auto restart the container ([#315](https://github.com/opensearch-project/opensearch-go/pull/315)) ### Changed +- Uses `[]string` instead of `string` in `SnapshotDeleteRequest` ([#237](https://github.com/opensearch-project/opensearch-go/pull/237)) +- Removes the need for double error checking ([#246](https://github.com/opensearch-project/opensearch-go/pull/246)) +- Updates workflows to reduce CI time, consolidate OpenSearch versions, update compatibility matrix ([#242](https://github.com/opensearch-project/opensearch-go/pull/242)) +- Moved @svencowart to emeritus maintainers ([#270](https://github.com/opensearch-project/opensearch-go/pull/270)) +- Read, close and replace the http Reponse Body ([#300](https://github.com/opensearch-project/opensearch-go/pull/300)) + ### Deprecated ### Removed -- Remove info call before performing every request ([#219](https://github.com/opensearch-project/opensearch-go/pull/219)) ### Fixed - - Renamed the sequence number struct tag to if_seq_no to fix optimistic concurrency control ([#166](https://github.com/opensearch-project/opensearch-go/pull/166)) - - Fix `RetryOnConflict` on bulk indexer ([#215](https://github.com/opensearch-project/opensearch-go/pull/215)) -### Security +- Corrects curl logging to emit the correct URL destination ([#101](https://github.com/opensearch-project/opensearch-go/pull/101)) +- Corrects handling of errors without an error response body ([#286](https://github.com/opensearch-project/opensearch-go/pull/286)) +### Security -[Unreleased]: https://github.com/opensearch-project/opensearch-go/compare/2.1...HEAD +[Unreleased]: https://github.com/opensearch-project/opensearch-go/compare/v2.2.0...HEAD \ No newline at end of file diff --git a/vendor/github.com/opensearch-project/opensearch-go/v2/CODEOWNERS b/vendor/github.com/opensearch-project/opensearch-go/v2/CODEOWNERS deleted file mode 100644 index 1ad1147a3..000000000 --- a/vendor/github.com/opensearch-project/opensearch-go/v2/CODEOWNERS +++ /dev/null @@ -1 +0,0 @@ -@jmazanec15 @vamshin @VijayanB @svencowart @VachaShah diff --git a/vendor/github.com/opensearch-project/opensearch-go/v2/CODE_OF_CONDUCT.md b/vendor/github.com/opensearch-project/opensearch-go/v2/CODE_OF_CONDUCT.md index 997bae660..c5efd05f7 100644 --- a/vendor/github.com/opensearch-project/opensearch-go/v2/CODE_OF_CONDUCT.md +++ b/vendor/github.com/opensearch-project/opensearch-go/v2/CODE_OF_CONDUCT.md @@ -1,25 +1,22 @@ - This code of conduct applies to all spaces provided by the OpenSource project including in code, documentation, issue trackers, mailing lists, chat channels, wikis, blogs, social media and any other communication channels used by the project. - **Our open source communities endeavor to:** -* Be Inclusive: We are committed to being a community where everyone can join and contribute. This means using inclusive and welcoming language. -* Be Welcoming: We are committed to maintaining a safe space for everyone to be able to contribute. -* Be Respectful: We are committed to encouraging differing viewpoints, accepting constructive criticism and work collaboratively towards decisions that help the project grow. Disrespectful and unacceptable behavior will not be tolerated. -* Be Collaborative: We are committed to supporting what is best for our community and users. When we build anything for the benefit of the project, we should document the work we do and communicate to others on how this affects their work. - +- Be Inclusive: We are committed to being a community where everyone can join and contribute. This means using inclusive and welcoming language. +- Be Welcoming: We are committed to maintaining a safe space for everyone to be able to contribute. +- Be Respectful: We are committed to encouraging differing viewpoints, accepting constructive criticism and work collaboratively towards decisions that help the project grow. Disrespectful and unacceptable behavior will not be tolerated. +- Be Collaborative: We are committed to supporting what is best for our community and users. When we build anything for the benefit of the project, we should document the work we do and communicate to others on how this affects their work. **Our Responsibility. As contributors, members, or bystanders we each individually have the responsibility to behave professionally and respectfully at all times. Disrespectful and unacceptable behaviors include, but are not limited to:** -* The use of violent threats, abusive, discriminatory, or derogatory language; -* Offensive comments related to gender, gender identity and expression, sexual orientation, disability, mental illness, race, political or religious affiliation; -* Posting of sexually explicit or violent content; -* The use of sexualized language and unwelcome sexual attention or advances; -* Public or private harassment of any kind; -* Publishing private information, such as physical or electronic address, without permission; -* Other conduct which could reasonably be considered inappropriate in a professional setting; -* Advocating for or encouraging any of the above behaviors. -* Enforcement and Reporting Code of Conduct Issues: +- The use of violent threats, abusive, discriminatory, or derogatory language; +- Offensive comments related to gender, gender identity and expression, sexual orientation, disability, mental illness, race, political or religious affiliation; +- Posting of sexually explicit or violent content; +- The use of sexualized language and unwelcome sexual attention or advances; +- Public or private harassment of any kind; +- Publishing private information, such as physical or electronic address, without permission; +- Other conduct which could reasonably be considered inappropriate in a professional setting; +- Advocating for or encouraging any of the above behaviors. +- Enforcement and Reporting Code of Conduct Issues: Instances of abusive, harassing, or otherwise unacceptable behavior may be reported. [Contact us](mailto:opensource-codeofconduct@amazon.com). All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. diff --git a/vendor/github.com/opensearch-project/opensearch-go/v2/COMPATIBILITY.md b/vendor/github.com/opensearch-project/opensearch-go/v2/COMPATIBILITY.md index e89a053bc..30e771f7e 100644 --- a/vendor/github.com/opensearch-project/opensearch-go/v2/COMPATIBILITY.md +++ b/vendor/github.com/opensearch-project/opensearch-go/v2/COMPATIBILITY.md @@ -6,13 +6,14 @@ The below matrix shows the compatibility of the [`opensearch-go`](https://pkg.go.dev/github.com/opensearch-project/opensearch-go) with versions of [`OpenSearch`](https://opensearch.org/downloads.html#opensearch). | Client Version | OpenSearch Version | -| --- | --- | -| 1.0.0 | 1.0.0-1.0.1 | -| 1.1.0 | 1.1.0-1.3.1 | -| 2.0.0 | 2.0.0-2.1.0 | -| 2.0.1 | 2.0.0-2.1.0 | -| 2.1.0 | 2.0.0-2.2.0 | +| -------------- | ------------------ | +| 1.0.0 | 1.0.0-1.0.1 | +| 1.1.0 | 1.1.0-1.3.1 | +| 2.0.0 | 2.0.0-2.1.0 | +| 2.0.1 | 2.0.0-2.1.0 | +| 2.1.0 | 2.0.0-2.5.0 | +| 2.2.0 | 2.0.0-2.5.0 | ## Upgrading -Major versions of OpenSearch introduce breaking changes that require careful upgrades of the client. While `opensearch-go-client` 2.0.0 works against the latest OpenSearch 1.x, certain deprecated features removed in OpenSearch 2.0 have also been removed from the client. Please refer to the [OpenSearch documentation](https://opensearch.org/docs/latest/clients/index/) for more information. \ No newline at end of file +Major versions of OpenSearch introduce breaking changes that require careful upgrades of the client. While `opensearch-go-client` 2.0.0 works against the latest OpenSearch 1.x, certain deprecated features removed in OpenSearch 2.0 have also been removed from the client. Please refer to the [OpenSearch documentation](https://opensearch.org/docs/latest/clients/index/) for more information. diff --git a/vendor/github.com/opensearch-project/opensearch-go/v2/CONTRIBUTING.md b/vendor/github.com/opensearch-project/opensearch-go/v2/CONTRIBUTING.md index 58e16eb76..e7b0764fd 100644 --- a/vendor/github.com/opensearch-project/opensearch-go/v2/CONTRIBUTING.md +++ b/vendor/github.com/opensearch-project/opensearch-go/v2/CONTRIBUTING.md @@ -17,7 +17,7 @@ OpenSearch is a community project that is built and maintained by people just li 1. **When in doubt, open an issue** - For almost any type of contribution, the first step is opening an issue. Even if you think you already know what the solution is, writing down a description of the problem you're trying to solve will help everyone get context when they review your pull request. If it's truly a trivial change (e.g. spelling error), you can skip this step -- but as the subject says, when it doubt, [open an issue](https://github.com/opensearch-project/opensearch-go/issues/new/choose). -2. **Only submit your own work** (or work you have sufficient rights to submit) - Please make sure that any code or documentation you submit is your work or you have the rights to submit. We respect the intellectual property rights of others, and as part of contributing, we'll ask you to sign your contribution with a "Developer Certificate of Origin" (DCO) that states you have the rights to submit this work and you understand we'll use your contribution. There's more information about this topic in the [DCO section](#developer-certificate-of-origin). +2. **Only submit your own work** (or work you have sufficient rights to submit) - Please make sure that any code or documentation you submit is your work or you have the rights to submit. We respect the intellectual property rights of others, and as part of contributing, we'll ask you to sign your contribution with a "Developer Certificate of Origin" (DCO) that states you have the rights to submit this work and you understand we'll use your contribution. There's more information about this topic in the [DCO section](#developer-certificate-of-origin). ## Ways to Contribute @@ -35,7 +35,6 @@ If you've upgraded to the latest version and you can't find it in our open issue If you've thought of a way that OpenSearch could be better, we want to hear about it. We track feature requests using GitHub, so please feel free to open an issue which describes the feature you would like to see, why you need it, and how it should work. - ### Contributing Code As with other types of contributions, the first step is to [open an issue on GitHub](https://github.com/opensearch-project/opensearch-go/issues/new/choose). Opening an issue before you make changes makes sure that someone else isn't already working on that particular problem. It also lets us all work together to find the right approach before you spend a bunch of time on a PR. So again, when in doubt, open an issue. @@ -75,7 +74,7 @@ By making a contribution to this project, I certify that: sign-off) is maintained indefinitely and may be redistributed consistent with this project or the open source license(s) involved. - ``` +``` We require that every contribution to OpenSearch is signed with a Developer Certificate of Origin. Additionally, please use your real name. We do not accept anonymous contributors nor those utilizing pseudonyms. @@ -93,12 +92,12 @@ OpenSearch-go maintains a version specific changelog by enforcing a change to th The changes are curated by version, with the changes to the main branch added chronologically to the `Unreleased` version. Each version has corresponding sections which list out the category of the change - `Added`, `Changed`, `Deprecated`, `Removed`, `Fixed`, `Security`. - ### Adding Changes As a contributor, you must ensure that every pull request has its changes listed out within the corresponding version and appropriate section of the [CHANGELOG](CHANGELOG.md) file. Adding in the change is a two step process - + 1. Add your changes to the corresponding section within the CHANGELOG file with dummy pull request information, publish the PR. 2. Update the entry for your change in [`CHANGELOG.md`](CHANGELOG.md) and make sure that you reference the pull request there. diff --git a/vendor/github.com/opensearch-project/opensearch-go/v2/DEVELOPER_GUIDE.md b/vendor/github.com/opensearch-project/opensearch-go/v2/DEVELOPER_GUIDE.md index e762490e2..b0a897e21 100644 --- a/vendor/github.com/opensearch-project/opensearch-go/v2/DEVELOPER_GUIDE.md +++ b/vendor/github.com/opensearch-project/opensearch-go/v2/DEVELOPER_GUIDE.md @@ -4,53 +4,67 @@ - [Install Prerequisites](#install-prerequisites) - [Go 1.11](#go-111) - [Docker](#docker) + - [Windows](#windows) - [Unit Testing](#unit-testing) - [Integration Testing](#integration-testing) - [Execute integration tests from your terminal](#execute-integration-tests-from-your-terminal) + - [Lint](#lint) + - [Markdown lint](#markdown-lint) - [Use an Editor](#use-an-editor) - [GoLand](#goland) + # Developer Guide -So you want to contribute code to the OpenSearch Go Client? Excellent! We're glad you're here. Here's what you need to do: +So you want to contribute code to the OpenSearch Go Client? Excellent! We're glad you're here. Here's what you need to do: ## Getting Started ### Git Clone OpenSearch Go Client Repository -Fork [opensearch-project/opensearch-go](https://github.com/opensearch-project/opensearch-go) and clone locally, -e.g. `git clone https://github.com/[your username]/opensearch-go.git`. +Fork [opensearch-project/opensearch-go](https://github.com/opensearch-project/opensearch-go) and clone locally, e.g. `git clone https://github.com/[your username]/opensearch-go.git`. ### Install Prerequisites #### Go 1.11 + OpenSearch Go Client builds using [Go](https://golang.org/doc/install) 1.11 at a minimum. #### Docker [Docker](https://docs.docker.com/install/) is required for building some OpenSearch artifacts and executing integration tests. +#### Windows + +To build the project on Windows, use [WSL2](https://learn.microsoft.com/en-us/windows/wsl/install), the compatibility layer for running Linux applications. + +Install ```make``` +``` +sudo apt install make +``` + ### Unit Testing + Go has a simple tool for running tests, and we simplified it further by creating this make command: - ``` + +``` make test-unit ``` - + Individual unit tests can be run with the following command: + ``` cd folder-path/to/test; -go test -v -run TestName; +go test -v -run TestName; ``` ### Integration Testing -In order to test opensearch-go client, you need a running OpenSearch cluster. You can use Docker to accomplish this. -The [Docker Compose file](.ci/opensearch/docker-compose.yml) supports the ability to run integration tests for the project in local environments. -If you have not installed docker-compose, you can install it from this [link](https://docs.docker.com/compose/install/). -In order to differentiate unit tests from integration tests, Go has a built-in mechanism for allowing you to logically separate your tests -with [build tags](https://pkg.go.dev/cmd/go#hdr-Build_constraints). The build tag needs to be placed as close to the top of the file as possible, and must have a blank line beneath it. -Hence, create all integration tests with build tag 'integration'. +In order to test opensearch-go client, you need a running OpenSearch cluster. You can use Docker to accomplish this. The [Docker Compose file](.ci/opensearch/docker-compose.yml) supports the ability to run integration tests for the project in local environments. If you have not installed docker-compose, you can install it from this [link](https://docs.docker.com/compose/install/). + +In order to differentiate unit tests from integration tests, Go has a built-in mechanism for allowing you to logically separate your tests with [build tags](https://pkg.go.dev/cmd/go#hdr-Build_constraints). The build tag needs to be placed as close to the top of the file as possible, and must have a blank line beneath it. Hence, create all integration tests with build tag 'integration'. #### Execute integration tests from your terminal + 1. Run below command to start containers. By default, it will launch latest OpenSearch cluster. ``` make cluster.build cluster.start @@ -63,14 +77,26 @@ Hence, create all integration tests with build tag 'integration'. ``` make cluster.stop cluster.clean ``` + +## Lint + +To keep all the code in a certain uniform format, it was decided to use some writing rules. If you wrote something wrong, it's okay, you can simply run the script to check the necessary files, and optionally format the content. But keep in mind that all these checks are repeated on the pipeline, so it's better to check locally. + +### Markdown lint + +To check the markdown files, run the following command: + +``` +make lint.markdown +``` + ## Use an Editor ### GoLand + You can import the OpenSearch project into GoLand as follows: 1. Select **File | Open** 2. In the subsequent dialog navigate to the ~/go/src/opensearch-go and click **Open** -After you have opened your project, you need to specify the location of the Go SDK. -You can either specify a local path to the SDK or download it. To set the Go SDK, navigate to **Go | GOROOT** and -set accordingly. +After you have opened your project, you need to specify the location of the Go SDK. You can either specify a local path to the SDK or download it. To set the Go SDK, navigate to **Go | GOROOT** and set accordingly. diff --git a/vendor/github.com/opensearch-project/opensearch-go/v2/MAINTAINERS.md b/vendor/github.com/opensearch-project/opensearch-go/v2/MAINTAINERS.md index 9f4480b19..e68e93297 100644 --- a/vendor/github.com/opensearch-project/opensearch-go/v2/MAINTAINERS.md +++ b/vendor/github.com/opensearch-project/opensearch-go/v2/MAINTAINERS.md @@ -4,17 +4,18 @@ This document contains a list of maintainers in this repo. See [opensearch-proje ## Current Maintainers -| Maintainer | GitHub ID | Affiliation | -| ----------------------- | ------------------------------------------- | ----------- | -| Daniel Doubrovkine | [dblock](https://github.com/dblock) | Amazon | -| Vijayan Balasubramanian | [VijayanB](https://github.com/VijayanB) | Amazon | -| Sven Cowart | [svencowart](https://github.com/svencowart) | | -| Vacha Shah | [VachaShah](https://github.com/VachaShah) | Amazon | +| Maintainer | GitHub ID | Affiliation | +| --- | --- | --- | +| Daniel Doubrovkine | [dblock](https://github.com/dblock) | Amazon | +| Jakob Hahn | [Jakob3xD](https://github.com/Jakob3xD) | Hetzner Online GmbH | +| Vacha Shah | [VachaShah](https://github.com/VachaShah) | Amazon | +| Vijayan Balasubramanian | [VijayanB](https://github.com/VijayanB) | Amazon | ## Emeritus -| Maintainer | GitHub ID | Affiliation | -| ----------------------- | ------------------------------------------- | ----------- | -| Jack Mazanec | [jmazanec15](https://github.com/jmazanec15) | Amazon | -| Vamshi Vijay Nakkirtha | [vamshin](https://github.com/vamshin) | Amazon | -| Rob Cowart | [robcowart](https://github.com/robcowart) | ElastiFlow | +| Maintainer | GitHub ID | Affiliation | +| --- | --- | --- | +| Jack Mazanec | [jmazanec15](https://github.com/jmazanec15) | Amazon | +| Rob Cowart | [robcowart](https://github.com/robcowart) | ElastiFlow | +| Sven Cowart | [svencowart](https://github.com/svencowart) | | +| Vamshi Vijay Nakkirtha | [vamshin](https://github.com/vamshin) | Amazon | diff --git a/vendor/github.com/opensearch-project/opensearch-go/v2/Makefile b/vendor/github.com/opensearch-project/opensearch-go/v2/Makefile index 2548e4a95..137db3fd3 100644 --- a/vendor/github.com/opensearch-project/opensearch-go/v2/Makefile +++ b/vendor/github.com/opensearch-project/opensearch-go/v2/Makefile @@ -66,6 +66,42 @@ lint: ## Run lint on the package cd "internal/build/" && go mod tidy && go mod download && go vet ./...; \ } +package := "prettier" +lint.markdown: + @printf "\033[2m→ Checking node installed...\033[0m\n" + if type node > /dev/null 2>&1 && which node > /dev/null 2>&1 ; then \ + node -v; \ + echo -e "\033[33m Node is installed, continue...\033[0m\n"; \ + else \ + echo -e "\033[31m Please install node\033[0m\n"; \ + exit 1; \ + fi + @printf "\033[2m→ Checking npm installed...\033[0m\n" + if type npm > /dev/null 2>&1 && which npm > /dev/null 2>&1 ; then \ + npm -v; \ + echo -e "\033[33m NPM is installed, continue...\033[0m\n"; \ + else \ + echo -e "\033[31m Please install npm\033[0m\n"; \ + exit 1; \ + fi + @printf "\033[2m→ Checking $(package) installed...\033[0m\n" + if [ `npm list -g | grep -c $(package)` -eq 0 -o ! -d node_module ]; then \ + echo -e "\033[33m Installing $(package)...\033[0m"; \ + npm install -g $(package) --no-shrinkwrap; \ + fi + @printf "\033[2m→ Running markdown lint...\033[0m\n" + if npx $(package) --prose-wrap never --check **/*.md; [[ $$? -ne 0 ]]; then \ + echo -e "\033[32m→ Found invalid files. Want to auto-format invalid files? (y/n) \033[0m"; \ + read RESP; \ + if [[ $$RESP = "y" || $$RESP = "Y" ]]; then \ + echo -e "\033[33m Formatting...\033[0m"; \ + npx $(package) --prose-wrap never --write **/*.md; \ + echo -e "\033[34m \nAll invalid files are formatted\033[0m"; \ + else \ + echo -e "\033[33m Unfortunately you are cancelled auto fixing. But we will definitely fix it in the pipeline\033[0m"; \ + fi \ + fi + backport: ## Backport one or more commits from main into version branches ifeq ($(origin commits), undefined) @@ -157,7 +193,6 @@ cluster.build: cluster.start: docker-compose --project-directory .ci/opensearch up -d ; - sleep 20; cluster.stop: docker-compose --project-directory .ci/opensearch down ; @@ -196,3 +231,4 @@ help: ## Display help .DEFAULT_GOAL := help .PHONY: help backport cluster cluster.clean coverage godoc lint release test test-bench test-integ test-unit linters linters.install +.SILENT: lint.markdown diff --git a/vendor/github.com/opensearch-project/opensearch-go/v2/README.md b/vendor/github.com/opensearch-project/opensearch-go/v2/README.md index 92a4bc0b1..bd0260fc6 100644 --- a/vendor/github.com/opensearch-project/opensearch-go/v2/README.md +++ b/vendor/github.com/opensearch-project/opensearch-go/v2/README.md @@ -1,10 +1,4 @@ -[![Go Reference](https://pkg.go.dev/badge/github.com/opensearch-project/opensearch-go.svg)](https://pkg.go.dev/github.com/opensearch-project/opensearch-go/v2) -[![Build](https://github.com/opensearch-project/opensearch-go/actions/workflows/lint.yml/badge.svg)](https://github.com/opensearch-project/opensearch-go/actions/workflows/lint.yml) -[![Unit](https://github.com/opensearch-project/opensearch-go/actions/workflows/test-unit.yml/badge.svg)](https://github.com/opensearch-project/opensearch-go/actions/workflows/test-unit.yml) -[![Integration](https://github.com/opensearch-project/opensearch-go/actions/workflows/test-integration.yml/badge.svg)](https://github.com/opensearch-project/opensearch-go/actions/workflows/test-integration.yml) -[![codecov](https://codecov.io/gh/opensearch-project/opensearch-go/branch/main/graph/badge.svg?token=MI9g3KYHVx)](https://codecov.io/gh/opensearch-project/opensearch-go) -[![Chat](https://img.shields.io/badge/chat-on%20forums-blue)](https://discuss.opendistrocommunity.dev/c/clients/) -![PRs welcome!](https://img.shields.io/badge/PRs-welcome!-success) +[![Go Reference](https://pkg.go.dev/badge/github.com/opensearch-project/opensearch-go.svg)](https://pkg.go.dev/github.com/opensearch-project/opensearch-go/v2) [![Build](https://github.com/opensearch-project/opensearch-go/actions/workflows/lint.yml/badge.svg)](https://github.com/opensearch-project/opensearch-go/actions/workflows/lint.yml) [![Unit](https://github.com/opensearch-project/opensearch-go/actions/workflows/test-unit.yml/badge.svg)](https://github.com/opensearch-project/opensearch-go/actions/workflows/test-unit.yml) [![Integration](https://github.com/opensearch-project/opensearch-go/actions/workflows/test-integration.yml/badge.svg)](https://github.com/opensearch-project/opensearch-go/actions/workflows/test-integration.yml) [![codecov](https://codecov.io/gh/opensearch-project/opensearch-go/branch/main/graph/badge.svg?token=MI9g3KYHVx)](https://codecov.io/gh/opensearch-project/opensearch-go) [![Chat](https://img.shields.io/badge/chat-on%20forums-blue)](https://discuss.opendistrocommunity.dev/c/clients/) ![PRs welcome!](https://img.shields.io/badge/PRs-welcome!-success) ![OpenSearch logo](OpenSearch.svg) @@ -22,18 +16,18 @@ OpenSearch Go Client ## Project Resources -* [Project Website](https://opensearch.org/) -* [Developer Guide](DEVELOPER_GUIDE.md) -* [User Guide](USER_GUIDE.md) -* [Documentation](https://opensearch.org/docs/latest/clients/go/) -* [API Documentation](https://pkg.go.dev/github.com/opensearch-project/opensearch-go/v2) -* Need help? Try [Forums](https://discuss.opendistrocommunity.dev/c/clients/) -* [Project Principles](https://opensearch.org/#principles) -* [Contributing to OpenSearch](CONTRIBUTING.md) -* [Maintainer Responsibilities](MAINTAINERS.md) -* [Release Management](RELEASING.md) -* [Admin Responsibilities](ADMINS.md) -* [Security](SECURITY.md) +- [Project Website](https://opensearch.org/) +- [Developer Guide](DEVELOPER_GUIDE.md) +- [User Guide](USER_GUIDE.md) +- [Documentation](https://opensearch.org/docs/latest/clients/go/) +- [API Documentation](https://pkg.go.dev/github.com/opensearch-project/opensearch-go/v2) +- Need help? Try [Forums](https://discuss.opendistrocommunity.dev/c/clients/) +- [Project Principles](https://opensearch.org/#principles) +- [Contributing to OpenSearch](CONTRIBUTING.md) +- [Maintainer Responsibilities](MAINTAINERS.md) +- [Release Management](RELEASING.md) +- [Admin Responsibilities](ADMINS.md) +- [Security](SECURITY.md) ## Code of Conduct diff --git a/vendor/github.com/opensearch-project/opensearch-go/v2/RELEASING.md b/vendor/github.com/opensearch-project/opensearch-go/v2/RELEASING.md index 1d6ad9e55..7d9053df0 100644 --- a/vendor/github.com/opensearch-project/opensearch-go/v2/RELEASING.md +++ b/vendor/github.com/opensearch-project/opensearch-go/v2/RELEASING.md @@ -15,9 +15,9 @@ This document explains the release strategy for artifacts in this organization. Given the current major release of 1.0, projects in this organization maintain the following active branches. -* **main**: The next _major_ release. This is the branch where all merges take place and code moves fast. -* **1.x**: The next _minor_ release. Once a change is merged into `main`, decide whether to backport it to `1.x`. -* **1.0**: The _current_ release. In between minor releases, only hotfixes (e.g. security) are backported to `1.0`. +- **main**: The next _major_ release. This is the branch where all merges take place and code moves fast. +- **1.x**: The next _minor_ release. Once a change is merged into `main`, decide whether to backport it to `1.x`. +- **1.0**: The _current_ release. In between minor releases, only hotfixes (e.g. security) are backported to `1.0`. Label PRs with the next major version label (e.g. `2.0.0`) and merge changes into `main`. Label PRs that you believe need to be backported as `1.x` and `1.0`. Backport PRs by checking out the versioned branch, cherry-pick changes and open a PR against each target backport branch. @@ -33,4 +33,4 @@ Repositories create consistent release labels, such as `v1.0.0`, `v1.1.0` and `v The release process is standard across repositories in this org and is run by a release manager volunteering from amongst [MAINTAINERS](MAINTAINERS.md). -1. Create a tag, e.g. `v2.1.0`, and push it to the GitHub repo. This makes the new version available on https://pkg.go.dev/github.com/opensearch-project/opensearch-go/v2. \ No newline at end of file +1. Create a tag, e.g. `v2.1.0`, and push it to the GitHub repo. This makes the new version available on https://pkg.go.dev/github.com/opensearch-project/opensearch-go/v2. diff --git a/vendor/github.com/opensearch-project/opensearch-go/v2/SECURITY.md b/vendor/github.com/opensearch-project/opensearch-go/v2/SECURITY.md index 0b85ca04e..b862921043 100644 --- a/vendor/github.com/opensearch-project/opensearch-go/v2/SECURITY.md +++ b/vendor/github.com/opensearch-project/opensearch-go/v2/SECURITY.md @@ -1,3 +1,3 @@ ## Reporting a Vulnerability -If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/) or directly via email to aws-security@amazon.com. Please do **not** create a public GitHub issue. \ No newline at end of file +If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/) or directly via email to aws-security@amazon.com. Please do **not** create a public GitHub issue. diff --git a/vendor/github.com/opensearch-project/opensearch-go/v2/USER_GUIDE.md b/vendor/github.com/opensearch-project/opensearch-go/v2/USER_GUIDE.md index 7cf07b49b..9b5b92175 100644 --- a/vendor/github.com/opensearch-project/opensearch-go/v2/USER_GUIDE.md +++ b/vendor/github.com/opensearch-project/opensearch-go/v2/USER_GUIDE.md @@ -1,15 +1,15 @@ - [User Guide](#user-guide) - [Example](#example) - [Amazon OpenSearch Service](#amazon-opensearch-service) - - [AWS SDK V1](#aws-sdk-v1) - - [AWS SDK V2](#aws-sdk-v2) + - [AWS SDK v1](#aws-sdk-v1) + - [AWS SDK v2](#aws-sdk-v2) + - [Guides by Topic](#guides-by-topic) # User Guide ## Example -In the example below, we create a client, an index with non-default settings, insert a document to the index, -search for the document, delete the document and finally delete the index. +In the example below, we create a client, an index with non-default settings, insert a document to the index, search for the document, delete the document and finally delete the index. ```go package main @@ -140,28 +140,19 @@ func main() { ## Amazon OpenSearch Service -Before starting, we strongly recommend reading the full AWS documentation regarding using IAM credentials to sign -requests to OpenSearch APIs. -See [Identity and Access Management in Amazon OpenSearch Service.](https://docs.aws.amazon.com/opensearch-service/latest/developerguide/ac.html) +Before starting, we strongly recommend reading the full AWS documentation regarding using IAM credentials to sign requests to OpenSearch APIs. See [Identity and Access Management in Amazon OpenSearch Service.](https://docs.aws.amazon.com/opensearch-service/latest/developerguide/ac.html) -> Even if you configure a completely open resource-based access policy, all requests to the OpenSearch Service -> configuration API must be signed. If your policies specify IAM users or roles, requests to the OpenSearch APIs also -> must -> be signed using AWS Signature Version 4. +> Even if you configure a completely open resource-based access policy, all requests to the OpenSearch Service configuration API must be signed. If your policies specify IAM users or roles, requests to the OpenSearch APIs also must be signed using AWS Signature Version 4. > -See [Managed Domains signing-service requests.](https://docs.aws.amazon.com/opensearch-service/latest/developerguide/ac.html#managedomains-signing-service-requests) +> See [Managed Domains signing-service requests.](https://docs.aws.amazon.com/opensearch-service/latest/developerguide/ac.html#managedomains-signing-service-requests) -Depending on the version of AWS SDK used, import the v1 or v2 request signer from `signer/aws` or `signer/awsv2` -respectively. -Both signers are equivalent in their functionality, they provide AWS Signature Version 4 (SigV4). +Depending on the version of AWS SDK used, import the v1 or v2 request signer from `signer/aws` or `signer/awsv2` respectively. Both signers are equivalent in their functionality, they provide AWS Signature Version 4 (SigV4). -To read more about SigV4 -see [Signature Version 4 signing process](https://docs.aws.amazon.com/general/latest/gr/signature-version-4.html) +To read more about SigV4 see [Signature Version 4 signing process](https://docs.aws.amazon.com/general/latest/gr/signature-version-4.html) -Here are some Go samples that show how to sign each OpenSearch request and automatically search for AWS credentials from -the ~/.aws folder or environment variables: +Here are some Go samples that show how to sign each OpenSearch request and automatically search for AWS credentials from the ~/.aws folder or environment variables: -#### AWS SDK V1 +### AWS SDK v1 ```go package main @@ -184,44 +175,47 @@ func main() { // Create an AWS request Signer and load AWS configuration using default config folder or env vars. // See https://docs.aws.amazon.com/opensearch-service/latest/developerguide/request-signing.html#request-signing-go - signer, err := requestsigner.NewSigner(session.Options{SharedConfigState: session.SharedConfigEnable}) + signer, err := requestsigner.NewSignerWithService( + session.Options{SharedConfigState: session.SharedConfigEnable}, + requestsigner.OpenSearchService, // Use requestsigner.OpenSearchServerless for Amazon OpenSearch Serverless. + ) if err != nil { - log.Fatal(err) // Do not log.fatal in a production ready app. + log.Fatalf("failed to create signer: %v", err) // Do not log.fatal in a production ready app. } - // Create an opensearch client and use the request-signer + // Create an opensearch client and use the request-signer. client, err := opensearch.NewClient(opensearch.Config{ Addresses: []string{endpoint}, Signer: signer, }) if err != nil { - log.Fatal("client creation err", err) + log.Fatalf("failed to create new opensearch client: %v", err) } ping := opensearchapi.PingRequest{} resp, err := ping.Do(ctx, client) if err != nil { - log.Fatal(err) + log.Fatalf("failed to ping: %v", err) } defer resp.Body.Close() if resp.IsError() { - log.Println("ping response status ", resp.Status()) + log.Printf("ping response status: %q", resp.Status()) respBody, err := io.ReadAll(resp.Body) if err != nil { - log.Fatal("response body read err", err) + log.Fatalf("failed to read response body body: %v", err) } - log.Fatal("ping resp body", respBody) + log.Fatalf("ping resp body: %s", respBody) } log.Println("PING OK") } ``` -#### AWS SDK V2 +### AWS SDK v2 Use the AWS SDK v2 for Go to authenticate with Amazon OpenSearch service. @@ -231,6 +225,7 @@ package main import ( "context" "log" + "strings" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/config" @@ -251,25 +246,25 @@ func main() { ), ) if err != nil { - log.Fatal(err) // Do not log.fatal in a production ready app. + log.Fatalf("failed to load aws configuraiton: %v", err) // Do not log.fatal in a production ready app. } // Create an AWS request Signer and load AWS configuration using default config folder or env vars. - signer, err := requestsigner.NewSignerWithService(awsCfg, "es") // "aoss" for Amazon OpenSearch Serverless + signer, err := requestsigner.NewSignerWithService(awsCfg, "es") // Use "aoss" for Amazon OpenSearch Serverless if err != nil { - log.Fatal(err) // Do not log.fatal in a production ready app. + log.Fatalf("failed to create signer: %v", err) } - // Create an opensearch client and use the request-signer + // Create an opensearch client and use the request-signer. client, err := opensearch.NewClient(opensearch.Config{ Addresses: []string{endpoint}, Signer: signer, }) if err != nil { - log.Fatal("client creation err", err) + log.Fatalf("failed to create new opensearch client: %v", err) } - indexName = "go-test-index" + indexName := "go-test-index" // Define index mapping. mapping := strings.NewReader(`{ @@ -279,7 +274,7 @@ func main() { } } }`) - + // Create an index with non-default settings. createIndex := opensearchapi.IndicesCreateRequest{ Index: indexName, @@ -287,11 +282,9 @@ func main() { } createIndexResponse, err := createIndex.Do(context.Background(), client) if err != nil { - log.Println("Error ", err.Error()) - log.Println("failed to create index ", err) - log.Fatal("create response body read err", err) + log.Fatalf("failed to create index: %v", err) } - log.Println(createIndexResponse) + log.Printf("created index: %#v", createIndexResponse) // Delete previously created index. deleteIndex := opensearchapi.IndicesDeleteRequest{ @@ -300,10 +293,9 @@ func main() { deleteIndexResponse, err := deleteIndex.Do(context.Background(), client) if err != nil { - log.Println("failed to delete index ", err) - log.Fatal("delete index response body read err", err) + log.Fatalf("failed to delete index: %v", err) } - log.Println("deleting index", deleteIndexResponse) + log.Printf("deleted index: %#v", deleteIndexResponse) } func getCredentialProvider(accessKey, secretAccessKey, token string) aws.CredentialsProviderFunc { @@ -318,3 +310,13 @@ func getCredentialProvider(accessKey, secretAccessKey, token string) aws.Credent } ``` + +## Guides by Topic + +- [Index Lifecycle](guides/index_lifecycle.md) +- [Document Lifecycle](guides/document_lifecycle.md) +- [Search](guides/search.md) +- [Bulk](guides/bulk.md) +- [Advanced Index Actions](guides/advanced_index_actions.md) +- [Index Templates](guides/index_template.md) +- [Data Streams](guides/data_streams.md) \ No newline at end of file diff --git a/vendor/github.com/opensearch-project/opensearch-go/v2/internal/version/version.go b/vendor/github.com/opensearch-project/opensearch-go/v2/internal/version/version.go index fb3f8c713..9f2c81802 100644 --- a/vendor/github.com/opensearch-project/opensearch-go/v2/internal/version/version.go +++ b/vendor/github.com/opensearch-project/opensearch-go/v2/internal/version/version.go @@ -28,4 +28,4 @@ package version // Client returns the client version as a string. // -const Client = "2.2.0" +const Client = "2.3.0" diff --git a/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api._.go b/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api._.go index 5382f0088..961aa212a 100644 --- a/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api._.go +++ b/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api._.go @@ -27,16 +27,16 @@ package opensearchapi // API contains the OpenSearch APIs -// type API struct { - Cat *Cat - Cluster *Cluster - Indices *Indices - Ingest *Ingest - Nodes *Nodes - Remote *Remote - Snapshot *Snapshot - Tasks *Tasks + Cat *Cat + Cluster *Cluster + Indices *Indices + Ingest *Ingest + Nodes *Nodes + Remote *Remote + Snapshot *Snapshot + Tasks *Tasks + PointInTime *PointInTime Bulk Bulk ClearScroll ClearScroll @@ -136,10 +136,12 @@ type Indices struct { Clone IndicesClone Close IndicesClose Create IndicesCreate + CreateDataStream IndicesCreateDataStream DeleteAlias IndicesDeleteAlias DeleteIndexTemplate IndicesDeleteIndexTemplate Delete IndicesDelete DeleteTemplate IndicesDeleteTemplate + DeleteDataStream IndicesDeleteDataStream DiskUsage IndicesDiskUsage ExistsAlias IndicesExistsAlias ExistsIndexTemplate IndicesExistsIndexTemplate @@ -155,6 +157,8 @@ type Indices struct { Get IndicesGet GetSettings IndicesGetSettings GetTemplate IndicesGetTemplate + GetDataStream IndicesGetDataStream + GetDataStreamStats IndicesGetDataStreamStats GetUpgrade IndicesGetUpgrade Open IndicesOpen PutAlias IndicesPutAlias @@ -222,6 +226,13 @@ type Tasks struct { List TasksList } +// PointInTime contains the Point In Time APIs +type PointInTime struct { + Create PointInTimeCreate + Delete PointInTimeDelete + Get PointInTimeGet +} + // New creates new API func New(t Transport) *API { return &API{ @@ -314,10 +325,12 @@ func New(t Transport) *API { Clone: newIndicesCloneFunc(t), Close: newIndicesCloseFunc(t), Create: newIndicesCreateFunc(t), + CreateDataStream: newIndicesCreateDataStreamFunc(t), DeleteAlias: newIndicesDeleteAliasFunc(t), DeleteIndexTemplate: newIndicesDeleteIndexTemplateFunc(t), Delete: newIndicesDeleteFunc(t), DeleteTemplate: newIndicesDeleteTemplateFunc(t), + DeleteDataStream: newIndicesDeleteDataStreamFunc(t), DiskUsage: newIndicesDiskUsageFunc(t), ExistsAlias: newIndicesExistsAliasFunc(t), ExistsIndexTemplate: newIndicesExistsIndexTemplateFunc(t), @@ -333,6 +346,8 @@ func New(t Transport) *API { Get: newIndicesGetFunc(t), GetSettings: newIndicesGetSettingsFunc(t), GetTemplate: newIndicesGetTemplateFunc(t), + GetDataStream: newIndicesGetDataStreamFunc(t), + GetDataStreamStats: newIndicesGetDataStreamStatsFunc(t), GetUpgrade: newIndicesGetUpgradeFunc(t), Open: newIndicesOpenFunc(t), PutAlias: newIndicesPutAliasFunc(t), @@ -388,5 +403,10 @@ func New(t Transport) *API { Get: newTasksGetFunc(t), List: newTasksListFunc(t), }, + PointInTime: &PointInTime{ + Create: newPointInTimeCreateFunc(t), + Delete: newPointInTimeDeleteFunc(t), + Get: newPointInTimeGetFunc(t), + }, } } diff --git a/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.bulk.go b/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.bulk.go index c104f0df5..2fef3fa51 100644 --- a/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.bulk.go +++ b/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.bulk.go @@ -55,7 +55,7 @@ type Bulk func(body io.Reader, o ...func(*BulkRequest)) (*Response, error) // BulkRequest configures the Bulk API request. // type BulkRequest struct { - Index string + Index string Body io.Reader @@ -63,7 +63,7 @@ type BulkRequest struct { Refresh string RequireAlias *bool Routing string - Source []string + Source interface{} SourceExcludes []string SourceIncludes []string Timeout time.Duration @@ -116,8 +116,12 @@ func (r BulkRequest) Do(ctx context.Context, transport Transport) (*Response, er params["routing"] = r.Routing } - if len(r.Source) > 0 { - params["_source"] = strings.Join(r.Source, ",") + if source, ok := r.Source.(bool); ok { + params["_source"] = strconv.FormatBool(source) + } else if source, ok := r.Source.(string); ok && source != "" { + params["_source"] = source + } else if sources, ok := r.Source.([]string); ok && len(sources) > 0 { + params["_source"] = strings.Join(sources, ",") } if len(r.SourceExcludes) > 0 { @@ -249,7 +253,7 @@ func (f Bulk) WithRouting(v string) func(*BulkRequest) { // WithSource - true or false to return the _source field or not, or default list of fields to return, can be overridden on each sub-request. // -func (f Bulk) WithSource(v ...string) func(*BulkRequest) { +func (f Bulk) WithSource(v interface{}) func(*BulkRequest) { return func(r *BulkRequest) { r.Source = v } diff --git a/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.delete_by_query.go b/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.delete_by_query.go index 371378ae7..bd1d68d9f 100644 --- a/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.delete_by_query.go +++ b/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.delete_by_query.go @@ -56,7 +56,7 @@ type DeleteByQuery func(index []string, body io.Reader, o ...func(*DeleteByQuery // DeleteByQueryRequest configures the Delete By Query API request. // type DeleteByQueryRequest struct { - Index []string + Index []string Body io.Reader @@ -84,7 +84,7 @@ type DeleteByQueryRequest struct { Size *int Slices interface{} Sort []string - Source []string + Source interface{} SourceExcludes []string SourceIncludes []string Stats []string @@ -219,8 +219,12 @@ func (r DeleteByQueryRequest) Do(ctx context.Context, transport Transport) (*Res params["sort"] = strings.Join(r.Sort, ",") } - if len(r.Source) > 0 { - params["_source"] = strings.Join(r.Source, ",") + if source, ok := r.Source.(bool); ok { + params["_source"] = strconv.FormatBool(source) + } else if source, ok := r.Source.(string); ok && source != "" { + params["_source"] = source + } else if sources, ok := r.Source.([]string); ok && len(sources) > 0 { + params["_source"] = strings.Join(sources, ",") } if len(r.SourceExcludes) > 0 { @@ -520,7 +524,7 @@ func (f DeleteByQuery) WithSort(v ...string) func(*DeleteByQueryRequest) { // WithSource - true or false to return the _source field or not, or a list of fields to return. // -func (f DeleteByQuery) WithSource(v ...string) func(*DeleteByQueryRequest) { +func (f DeleteByQuery) WithSource(v interface{}) func(*DeleteByQueryRequest) { return func(r *DeleteByQueryRequest) { r.Source = v } diff --git a/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.exists.go b/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.exists.go index ab53f422d..cd229761c 100644 --- a/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.exists.go +++ b/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.exists.go @@ -53,14 +53,14 @@ type Exists func(index string, id string, o ...func(*ExistsRequest)) (*Response, // ExistsRequest configures the Exists API request. // type ExistsRequest struct { - Index string - DocumentID string + Index string + DocumentID string Preference string Realtime *bool Refresh *bool Routing string - Source []string + Source interface{} SourceExcludes []string SourceIncludes []string StoredFields []string @@ -113,8 +113,12 @@ func (r ExistsRequest) Do(ctx context.Context, transport Transport) (*Response, params["routing"] = r.Routing } - if len(r.Source) > 0 { - params["_source"] = strings.Join(r.Source, ",") + if source, ok := r.Source.(bool); ok { + params["_source"] = strconv.FormatBool(source) + } else if source, ok := r.Source.(string); ok && source != "" { + params["_source"] = source + } else if sources, ok := r.Source.([]string); ok && len(sources) > 0 { + params["_source"] = strings.Join(sources, ",") } if len(r.SourceExcludes) > 0 { @@ -238,7 +242,7 @@ func (f Exists) WithRouting(v string) func(*ExistsRequest) { // WithSource - true or false to return the _source field or not, or a list of fields to return. // -func (f Exists) WithSource(v ...string) func(*ExistsRequest) { +func (f Exists) WithSource(v interface{}) func(*ExistsRequest) { return func(r *ExistsRequest) { r.Source = v } diff --git a/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.exists_source.go b/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.exists_source.go index d154faf0e..6b5eba2cc 100644 --- a/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.exists_source.go +++ b/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.exists_source.go @@ -53,14 +53,14 @@ type ExistsSource func(index string, id string, o ...func(*ExistsSourceRequest)) // ExistsSourceRequest configures the Exists Source API request. // type ExistsSourceRequest struct { - Index string - DocumentID string + Index string + DocumentID string Preference string Realtime *bool Refresh *bool Routing string - Source []string + Source interface{} SourceExcludes []string SourceIncludes []string Version *int @@ -113,8 +113,12 @@ func (r ExistsSourceRequest) Do(ctx context.Context, transport Transport) (*Resp params["routing"] = r.Routing } - if len(r.Source) > 0 { - params["_source"] = strings.Join(r.Source, ",") + if source, ok := r.Source.(bool); ok { + params["_source"] = strconv.FormatBool(source) + } else if source, ok := r.Source.(string); ok && source != "" { + params["_source"] = source + } else if sources, ok := r.Source.([]string); ok && len(sources) > 0 { + params["_source"] = strings.Join(sources, ",") } if len(r.SourceExcludes) > 0 { @@ -234,7 +238,7 @@ func (f ExistsSource) WithRouting(v string) func(*ExistsSourceRequest) { // WithSource - true or false to return the _source field or not, or a list of fields to return. // -func (f ExistsSource) WithSource(v ...string) func(*ExistsSourceRequest) { +func (f ExistsSource) WithSource(v interface{}) func(*ExistsSourceRequest) { return func(r *ExistsSourceRequest) { r.Source = v } diff --git a/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.explain.go b/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.explain.go index ea80deaa7..f3891dc12 100644 --- a/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.explain.go +++ b/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.explain.go @@ -54,8 +54,8 @@ type Explain func(index string, id string, o ...func(*ExplainRequest)) (*Respons // ExplainRequest configures the Explain API request. // type ExplainRequest struct { - Index string - DocumentID string + Index string + DocumentID string Body io.Reader @@ -67,7 +67,7 @@ type ExplainRequest struct { Preference string Query string Routing string - Source []string + Source interface{} SourceExcludes []string SourceIncludes []string StoredFields []string @@ -135,8 +135,12 @@ func (r ExplainRequest) Do(ctx context.Context, transport Transport) (*Response, params["routing"] = r.Routing } - if len(r.Source) > 0 { - params["_source"] = strings.Join(r.Source, ",") + if source, ok := r.Source.(bool); ok { + params["_source"] = strconv.FormatBool(source) + } else if source, ok := r.Source.(string); ok && source != "" { + params["_source"] = source + } else if sources, ok := r.Source.([]string); ok && len(sources) > 0 { + params["_source"] = strings.Join(sources, ",") } if len(r.SourceExcludes) > 0 { @@ -296,7 +300,7 @@ func (f Explain) WithRouting(v string) func(*ExplainRequest) { // WithSource - true or false to return the _source field or not, or a list of fields to return. // -func (f Explain) WithSource(v ...string) func(*ExplainRequest) { +func (f Explain) WithSource(v interface{}) func(*ExplainRequest) { return func(r *ExplainRequest) { r.Source = v } diff --git a/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.get.go b/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.get.go index 36612f9b7..0360d3e20 100644 --- a/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.get.go +++ b/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.get.go @@ -53,14 +53,14 @@ type Get func(index string, id string, o ...func(*GetRequest)) (*Response, error // GetRequest configures the Get API request. // type GetRequest struct { - Index string - DocumentID string + Index string + DocumentID string Preference string Realtime *bool Refresh *bool Routing string - Source []string + Source interface{} SourceExcludes []string SourceIncludes []string StoredFields []string @@ -113,8 +113,12 @@ func (r GetRequest) Do(ctx context.Context, transport Transport) (*Response, err params["routing"] = r.Routing } - if len(r.Source) > 0 { - params["_source"] = strings.Join(r.Source, ",") + if source, ok := r.Source.(bool); ok { + params["_source"] = strconv.FormatBool(source) + } else if source, ok := r.Source.(string); ok && source != "" { + params["_source"] = source + } else if sources, ok := r.Source.([]string); ok && len(sources) > 0 { + params["_source"] = strings.Join(sources, ",") } if len(r.SourceExcludes) > 0 { @@ -238,7 +242,7 @@ func (f Get) WithRouting(v string) func(*GetRequest) { // WithSource - true or false to return the _source field or not, or a list of fields to return. // -func (f Get) WithSource(v ...string) func(*GetRequest) { +func (f Get) WithSource(v interface{}) func(*GetRequest) { return func(r *GetRequest) { r.Source = v } diff --git a/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.get_source.go b/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.get_source.go index 9a7dc1215..f9525f933 100644 --- a/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.get_source.go +++ b/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.get_source.go @@ -53,14 +53,14 @@ type GetSource func(index string, id string, o ...func(*GetSourceRequest)) (*Res // GetSourceRequest configures the Get Source API request. // type GetSourceRequest struct { - Index string - DocumentID string + Index string + DocumentID string Preference string Realtime *bool Refresh *bool Routing string - Source []string + Source interface{} SourceExcludes []string SourceIncludes []string Version *int @@ -113,8 +113,12 @@ func (r GetSourceRequest) Do(ctx context.Context, transport Transport) (*Respons params["routing"] = r.Routing } - if len(r.Source) > 0 { - params["_source"] = strings.Join(r.Source, ",") + if source, ok := r.Source.(bool); ok { + params["_source"] = strconv.FormatBool(source) + } else if source, ok := r.Source.(string); ok && source != "" { + params["_source"] = source + } else if sources, ok := r.Source.([]string); ok && len(sources) > 0 { + params["_source"] = strings.Join(sources, ",") } if len(r.SourceExcludes) > 0 { @@ -234,7 +238,7 @@ func (f GetSource) WithRouting(v string) func(*GetSourceRequest) { // WithSource - true or false to return the _source field or not, or a list of fields to return. // -func (f GetSource) WithSource(v ...string) func(*GetSourceRequest) { +func (f GetSource) WithSource(v interface{}) func(*GetSourceRequest) { return func(r *GetSourceRequest) { r.Source = v } diff --git a/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.indices.create_datastream.go b/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.indices.create_datastream.go new file mode 100644 index 000000000..d7094b356 --- /dev/null +++ b/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.indices.create_datastream.go @@ -0,0 +1,177 @@ +// SPDX-License-Identifier: Apache-2.0 +// +// The OpenSearch Contributors require contributions made to +// this file be licensed under the Apache-2.0 license or a +// compatible open source license. +// +// Modifications Copyright OpenSearch Contributors. See +// GitHub history for details. + +package opensearchapi + +import ( + "context" + "net/http" + "strings" +) + +func newIndicesCreateDataStreamFunc(t Transport) IndicesCreateDataStream { + return func(name string, o ...func(*IndicesCreateDataStreamRequest)) (*Response, error) { + var r = IndicesCreateDataStreamRequest{Name: name} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesCreateDataStream creates a data stream. +type IndicesCreateDataStream func(index string, o ...func(*IndicesCreateDataStreamRequest)) (*Response, error) + +// IndicesCreateDataStreamRequest configures the Indices Create Data Stream API request. +type IndicesCreateDataStreamRequest struct { + Name string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do execute the request and returns response or error. +func (r IndicesCreateDataStreamRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "PUT" + + path.Grow(1 + len("_data_stream") + 1 + len(r.Name)) + path.WriteString("/_data_stream/") + path.WriteString(r.Name) + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesCreateDataStream) WithContext(v context.Context) func(*IndicesCreateDataStreamRequest) { + return func(r *IndicesCreateDataStreamRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesCreateDataStream) WithPretty() func(*IndicesCreateDataStreamRequest) { + return func(r *IndicesCreateDataStreamRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesCreateDataStream) WithHuman() func(*IndicesCreateDataStreamRequest) { + return func(r *IndicesCreateDataStreamRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesCreateDataStream) WithErrorTrace() func(*IndicesCreateDataStreamRequest) { + return func(r *IndicesCreateDataStreamRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesCreateDataStream) WithFilterPath(v ...string) func(*IndicesCreateDataStreamRequest) { + return func(r *IndicesCreateDataStreamRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesCreateDataStream) WithHeader(h map[string]string) func(*IndicesCreateDataStreamRequest) { + return func(r *IndicesCreateDataStreamRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesCreateDataStream) WithOpaqueID(s string) func(*IndicesCreateDataStreamRequest) { + return func(r *IndicesCreateDataStreamRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.indices.delete_datastream.go b/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.indices.delete_datastream.go new file mode 100644 index 000000000..958d46b3d --- /dev/null +++ b/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.indices.delete_datastream.go @@ -0,0 +1,203 @@ +// SPDX-License-Identifier: Apache-2.0 +// +// The OpenSearch Contributors require contributions made to +// this file be licensed under the Apache-2.0 license or a +// compatible open source license. +// +// Modifications Copyright OpenSearch Contributors. See +// GitHub history for details. + +package opensearchapi + +import ( + "context" + "net/http" + "strings" + "time" +) + +func newIndicesDeleteDataStreamFunc(t Transport) IndicesDeleteDataStream { + return func(name string, o ...func(*IndicesDeleteDataStreamRequest)) (*Response, error) { + var r = IndicesDeleteDataStreamRequest{Name: name} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesDeleteDataStream deletes the backing indices of a data stream and then deletes the data stream itself. +type IndicesDeleteDataStream func(name string, o ...func(*IndicesDeleteDataStreamRequest)) (*Response, error) + +// IndicesDeleteDataStreamRequest configures the Data Stream Delete Template API request. +type IndicesDeleteDataStreamRequest struct { + Name string + + ClusterManagerTimeout time.Duration + Timeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do execute the request and returns response or error. +func (r IndicesDeleteDataStreamRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "DELETE" + + path.Grow(1 + len("_data_stream") + 1 + len(r.Name)) + path.WriteString("/_data_stream/") + path.WriteString(r.Name) + + params = make(map[string]string) + + if r.ClusterManagerTimeout != 0 { + params["cluster_manager_timeout"] = formatDuration(r.ClusterManagerTimeout) + } + + if r.Timeout != 0 { + params["timeout"] = formatDuration(r.Timeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesDeleteDataStream) WithContext(v context.Context) func(*IndicesDeleteDataStreamRequest) { + return func(r *IndicesDeleteDataStreamRequest) { + r.ctx = v + } +} + +// WithClusterManagerTimeout - explicit operation timeout for connection to cluster-manager node. +func (f IndicesDeleteDataStream) WithClusterManagerTimeout(v time.Duration) func(*IndicesDeleteDataStreamRequest) { + return func(r *IndicesDeleteDataStreamRequest) { + r.ClusterManagerTimeout = v + } +} + +// WithTimeout - explicit operation timeout. +func (f IndicesDeleteDataStream) WithTimeout(v time.Duration) func(*IndicesDeleteDataStreamRequest) { + return func(r *IndicesDeleteDataStreamRequest) { + r.Timeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesDeleteDataStream) WithPretty() func(*IndicesDeleteDataStreamRequest) { + return func(r *IndicesDeleteDataStreamRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesDeleteDataStream) WithHuman() func(*IndicesDeleteDataStreamRequest) { + return func(r *IndicesDeleteDataStreamRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesDeleteDataStream) WithErrorTrace() func(*IndicesDeleteDataStreamRequest) { + return func(r *IndicesDeleteDataStreamRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesDeleteDataStream) WithFilterPath(v ...string) func(*IndicesDeleteDataStreamRequest) { + return func(r *IndicesDeleteDataStreamRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesDeleteDataStream) WithHeader(h map[string]string) func(*IndicesDeleteDataStreamRequest) { + return func(r *IndicesDeleteDataStreamRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesDeleteDataStream) WithOpaqueID(s string) func(*IndicesDeleteDataStreamRequest) { + return func(r *IndicesDeleteDataStreamRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.indices.get_datastream.go b/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.indices.get_datastream.go new file mode 100644 index 000000000..7facf8b76 --- /dev/null +++ b/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.indices.get_datastream.go @@ -0,0 +1,198 @@ +// SPDX-License-Identifier: Apache-2.0 +// +// The OpenSearch Contributors require contributions made to +// this file be licensed under the Apache-2.0 license or a +// compatible open source license. +// +// Modifications Copyright OpenSearch Contributors. See +// GitHub history for details. + +package opensearchapi + +import ( + "context" + "net/http" + "strings" + "time" +) + +func newIndicesGetDataStreamFunc(t Transport) IndicesGetDataStream { + return func(o ...func(*IndicesGetDataStreamRequest)) (*Response, error) { + var r = IndicesGetDataStreamRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesGetDataStream returns a data stream specific information if Name parameter is passed. Otherwise, returns all data streams. +type IndicesGetDataStream func(o ...func(*IndicesGetDataStreamRequest)) (*Response, error) + +// IndicesGetDataStreamRequest configures the Indices Get Data Stream API request. +type IndicesGetDataStreamRequest struct { + Name string + + ClusterManagerTimeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do execute the request and returns response or error. +func (r IndicesGetDataStreamRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_data_stream") + 1 + len(r.Name)) + path.WriteString("/_data_stream/") + path.WriteString(r.Name) + + params = make(map[string]string) + + if r.ClusterManagerTimeout != 0 { + params["cluster_manager_timeout"] = formatDuration(r.ClusterManagerTimeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesGetDataStream) WithContext(v context.Context) func(*IndicesGetDataStreamRequest) { + return func(r *IndicesGetDataStreamRequest) { + r.ctx = v + } +} + +// WithName - the comma separated names of the index templates. +func (f IndicesGetDataStream) WithName(v string) func(*IndicesGetDataStreamRequest) { + return func(r *IndicesGetDataStreamRequest) { + r.Name = v + } +} + +// WithClusterManagerTimeout - explicit operation timeout for connection to cluster-manager node. +func (f IndicesGetDataStream) WithClusterManagerTimeout(v time.Duration) func(*IndicesGetDataStreamRequest) { + return func(r *IndicesGetDataStreamRequest) { + r.ClusterManagerTimeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesGetDataStream) WithPretty() func(*IndicesGetDataStreamRequest) { + return func(r *IndicesGetDataStreamRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesGetDataStream) WithHuman() func(*IndicesGetDataStreamRequest) { + return func(r *IndicesGetDataStreamRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesGetDataStream) WithErrorTrace() func(*IndicesGetDataStreamRequest) { + return func(r *IndicesGetDataStreamRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesGetDataStream) WithFilterPath(v ...string) func(*IndicesGetDataStreamRequest) { + return func(r *IndicesGetDataStreamRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesGetDataStream) WithHeader(h map[string]string) func(*IndicesGetDataStreamRequest) { + return func(r *IndicesGetDataStreamRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesGetDataStream) WithOpaqueID(s string) func(*IndicesGetDataStreamRequest) { + return func(r *IndicesGetDataStreamRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.indices.get_datastream_stats.go b/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.indices.get_datastream_stats.go new file mode 100644 index 000000000..4bc2e933c --- /dev/null +++ b/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.indices.get_datastream_stats.go @@ -0,0 +1,199 @@ +// SPDX-License-Identifier: Apache-2.0 +// +// The OpenSearch Contributors require contributions made to +// this file be licensed under the Apache-2.0 license or a +// compatible open source license. +// +// Modifications Copyright OpenSearch Contributors. See +// GitHub history for details. + +package opensearchapi + +import ( + "context" + "net/http" + "strings" + "time" +) + +func newIndicesGetDataStreamStatsFunc(t Transport) IndicesGetDataStreamStats { + return func(o ...func(*IndicesGetDataStreamStatsRequest)) (*Response, error) { + var r = IndicesGetDataStreamStatsRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// IndicesGetDataStreamStats returns a more insights about the data stream. +type IndicesGetDataStreamStats func(o ...func(*IndicesGetDataStreamStatsRequest)) (*Response, error) + +// IndicesGetDataStreamStatsRequest configures the Indices Get Data Stream Stats API request. +type IndicesGetDataStreamStatsRequest struct { + Name string + + ClusterManagerTimeout time.Duration + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// Do execute the request and returns response or error. +func (r IndicesGetDataStreamStatsRequest) Do(ctx context.Context, transport Transport) (*Response, error) { + var ( + method string + path strings.Builder + params map[string]string + ) + + method = "GET" + + path.Grow(1 + len("_data_stream") + 1 + len(r.Name) + 1 + len("_stats")) + path.WriteString("/_data_stream/") + path.WriteString(r.Name) + path.WriteString("/_stats") + + params = make(map[string]string) + + if r.ClusterManagerTimeout != 0 { + params["cluster_manager_timeout"] = formatDuration(r.ClusterManagerTimeout) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + return &response, nil +} + +// WithContext sets the request context. +func (f IndicesGetDataStreamStats) WithContext(v context.Context) func(*IndicesGetDataStreamStatsRequest) { + return func(r *IndicesGetDataStreamStatsRequest) { + r.ctx = v + } +} + +// WithName - the comma separated names of the index templates. +func (f IndicesGetDataStreamStats) WithName(v string) func(*IndicesGetDataStreamStatsRequest) { + return func(r *IndicesGetDataStreamStatsRequest) { + r.Name = v + } +} + +// WithClusterManagerTimeout - explicit operation timeout for connection to cluster-manager node. +func (f IndicesGetDataStreamStats) WithClusterManagerTimeout(v time.Duration) func(*IndicesGetDataStreamStatsRequest) { + return func(r *IndicesGetDataStreamStatsRequest) { + r.ClusterManagerTimeout = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f IndicesGetDataStreamStats) WithPretty() func(*IndicesGetDataStreamStatsRequest) { + return func(r *IndicesGetDataStreamStatsRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f IndicesGetDataStreamStats) WithHuman() func(*IndicesGetDataStreamStatsRequest) { + return func(r *IndicesGetDataStreamStatsRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f IndicesGetDataStreamStats) WithErrorTrace() func(*IndicesGetDataStreamStatsRequest) { + return func(r *IndicesGetDataStreamStatsRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f IndicesGetDataStreamStats) WithFilterPath(v ...string) func(*IndicesGetDataStreamStatsRequest) { + return func(r *IndicesGetDataStreamStatsRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f IndicesGetDataStreamStats) WithHeader(h map[string]string) func(*IndicesGetDataStreamStatsRequest) { + return func(r *IndicesGetDataStreamStatsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f IndicesGetDataStreamStats) WithOpaqueID(s string) func(*IndicesGetDataStreamStatsRequest) { + return func(r *IndicesGetDataStreamStatsRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.info.go b/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.info.go index c506a52fa..a16f7918c 100644 --- a/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.info.go +++ b/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.info.go @@ -45,12 +45,9 @@ func newInfoFunc(t Transport) Info { // ----- API Definition ------------------------------------------------------- // Info returns basic information about the cluster. -// -// type Info func(o ...func(*InfoRequest)) (*Response, error) // InfoRequest configures the Info API request. -// type InfoRequest struct { Pretty bool Human bool @@ -62,8 +59,26 @@ type InfoRequest struct { ctx context.Context } +// InfoResp is a custom type to parse the Info Reponse +type InfoResp struct { + Name string `json:"name"` + ClusterName string `json:"cluster_name"` + ClusterUUID string `json:"cluster_uuid"` + Version struct { + Distribution string `json:"distribution"` + Number string `json:"number"` + BuildType string `json:"build_type"` + BuildHash string `json:"build_hash"` + BuildDate string `json:"build_date"` + BuildSnapshot bool `json:"build_snapshot"` + LuceneVersion string `json:"lucene_version"` + MinimumWireCompatibilityVersion string `json:"minimum_wire_compatibility_version"` + MinimumIndexCompatibilityVersion string `json:"minimum_index_compatibility_version"` + } `json:"version"` + Tagline string `json:"tagline"` +} + // Do executes the request and returns response or error. -// func (r InfoRequest) Do(ctx context.Context, transport Transport) (*Response, error) { var ( method string @@ -138,7 +153,6 @@ func (r InfoRequest) Do(ctx context.Context, transport Transport) (*Response, er } // WithContext sets the request context. -// func (f Info) WithContext(v context.Context) func(*InfoRequest) { return func(r *InfoRequest) { r.ctx = v @@ -146,7 +160,6 @@ func (f Info) WithContext(v context.Context) func(*InfoRequest) { } // WithHuman makes statistical values human-readable. -// func (f Info) WithHuman() func(*InfoRequest) { return func(r *InfoRequest) { r.Human = true @@ -154,7 +167,6 @@ func (f Info) WithHuman() func(*InfoRequest) { } // WithErrorTrace includes the stack trace for errors in the response body. -// func (f Info) WithErrorTrace() func(*InfoRequest) { return func(r *InfoRequest) { r.ErrorTrace = true @@ -162,7 +174,6 @@ func (f Info) WithErrorTrace() func(*InfoRequest) { } // WithFilterPath filters the properties of the response body. -// func (f Info) WithFilterPath(v ...string) func(*InfoRequest) { return func(r *InfoRequest) { r.FilterPath = v @@ -170,7 +181,6 @@ func (f Info) WithFilterPath(v ...string) func(*InfoRequest) { } // WithHeader adds the headers to the HTTP request. -// func (f Info) WithHeader(h map[string]string) func(*InfoRequest) { return func(r *InfoRequest) { if r.Header == nil { @@ -183,7 +193,6 @@ func (f Info) WithHeader(h map[string]string) func(*InfoRequest) { } // WithOpaqueID adds the X-Opaque-Id header to the HTTP request. -// func (f Info) WithOpaqueID(s string) func(*InfoRequest) { return func(r *InfoRequest) { if r.Header == nil { diff --git a/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.mget.go b/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.mget.go index 4d3848419..5a04ca471 100644 --- a/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.mget.go +++ b/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.mget.go @@ -54,7 +54,7 @@ type Mget func(body io.Reader, o ...func(*MgetRequest)) (*Response, error) // MgetRequest configures the Mget API request. // type MgetRequest struct { - Index string + Index string Body io.Reader @@ -62,7 +62,7 @@ type MgetRequest struct { Realtime *bool Refresh *bool Routing string - Source []string + Source interface{} SourceExcludes []string SourceIncludes []string StoredFields []string @@ -114,8 +114,12 @@ func (r MgetRequest) Do(ctx context.Context, transport Transport) (*Response, er params["routing"] = r.Routing } - if len(r.Source) > 0 { - params["_source"] = strings.Join(r.Source, ",") + if source, ok := r.Source.(bool); ok { + params["_source"] = strconv.FormatBool(source) + } else if source, ok := r.Source.(string); ok && source != "" { + params["_source"] = source + } else if sources, ok := r.Source.([]string); ok && len(sources) > 0 { + params["_source"] = strings.Join(sources, ",") } if len(r.SourceExcludes) > 0 { @@ -243,7 +247,7 @@ func (f Mget) WithRouting(v string) func(*MgetRequest) { // WithSource - true or false to return the _source field or not, or a list of fields to return. // -func (f Mget) WithSource(v ...string) func(*MgetRequest) { +func (f Mget) WithSource(v interface{}) func(*MgetRequest) { return func(r *MgetRequest) { r.Source = v } diff --git a/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.pointintime.create.go b/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.pointintime.create.go new file mode 100644 index 000000000..8a787ea34 --- /dev/null +++ b/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.pointintime.create.go @@ -0,0 +1,256 @@ +// SPDX-License-Identifier: Apache-2.0 +// +// The OpenSearch Contributors require contributions made to +// this file be licensed under the Apache-2.0 license or a +// compatible open source license. +// +// Modifications Copyright OpenSearch Contributors. See +// GitHub history for details. + +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package opensearchapi + +import ( + "context" + "encoding/json" + "net/http" + "strings" + "time" +) + +func newPointInTimeCreateFunc(t Transport) PointInTimeCreate { + return func(o ...func(*PointInTimeCreateRequest)) (*Response, *PointInTimeCreateResp, error) { + var r = PointInTimeCreateRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// PointInTimeCreate let you create a pit for searching with pagination +type PointInTimeCreate func(o ...func(*PointInTimeCreateRequest)) (*Response, *PointInTimeCreateResp, error) + +// PointInTimeCreateRequest configures the Point In Time Create API request. +type PointInTimeCreateRequest struct { + Index []string + + KeepAlive time.Duration + Preference string + Routing string + ExpandWildcards string + AllowPartialPitCreation bool + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// PointInTimeCreateResp is a custom type to parse the Point In Time Create Reponse +type PointInTimeCreateResp struct { + PitID string `json:"pit_id"` + Shards struct { + Total int `json:"total"` + Successful int `json:"successful"` + Skipped int `json:"skipped"` + Failed int `json:"failed"` + } `json:"_shards"` + CreationTime int `json:"creation_time"` +} + +// Do executes the request and returns response, PointInTimeCreateResp and error. +func (r PointInTimeCreateRequest) Do(ctx context.Context, transport Transport) (*Response, *PointInTimeCreateResp, error) { + var ( + path strings.Builder + params map[string]string + + data PointInTimeCreateResp + ) + method := "POST" + + path.Grow(1 + len(strings.Join(r.Index, ",")) + len("/_search/point_in_time")) + path.WriteString("/") + path.WriteString(strings.Join(r.Index, ",")) + path.WriteString("/_search/point_in_time") + + params = make(map[string]string) + + if r.KeepAlive != 0 { + params["keep_alive"] = formatDuration(r.KeepAlive) + } + + if r.Preference != "" { + params["preference"] = r.Preference + } + + if r.Routing != "" { + params["routing"] = r.Routing + } + + if r.ExpandWildcards != "" { + params["expand_wildcards"] = r.ExpandWildcards + } + + if r.AllowPartialPitCreation { + params["allow_partial_pit_creation"] = "true" + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + if len(r.FilterPath) != 0 { + return &response, nil, nil + } + + if err := json.NewDecoder(response.Body).Decode(&data); err != nil { + return &response, nil, err + } + return &response, &data, nil +} + +// WithIndex - a list of index names to search; use _all to perform the operation on all indices. +func (f PointInTimeCreate) WithIndex(v ...string) func(*PointInTimeCreateRequest) { + return func(r *PointInTimeCreateRequest) { + r.Index = v + } +} + +// WithContext sets the request context. +func (f PointInTimeCreate) WithContext(v context.Context) func(*PointInTimeCreateRequest) { + return func(r *PointInTimeCreateRequest) { + r.ctx = v + } +} + +// WithKeepAlive - specify the amount of time to keep the PIT. +func (f PointInTimeCreate) WithKeepAlive(v time.Duration) func(*PointInTimeCreateRequest) { + return func(r *PointInTimeCreateRequest) { + r.KeepAlive = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f PointInTimeCreate) WithPretty() func(*PointInTimeCreateRequest) { + return func(r *PointInTimeCreateRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f PointInTimeCreate) WithHuman() func(*PointInTimeCreateRequest) { + return func(r *PointInTimeCreateRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f PointInTimeCreate) WithErrorTrace() func(*PointInTimeCreateRequest) { + return func(r *PointInTimeCreateRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f PointInTimeCreate) WithFilterPath(v ...string) func(*PointInTimeCreateRequest) { + return func(r *PointInTimeCreateRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f PointInTimeCreate) WithHeader(h map[string]string) func(*PointInTimeCreateRequest) { + return func(r *PointInTimeCreateRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f PointInTimeCreate) WithOpaqueID(s string) func(*PointInTimeCreateRequest) { + return func(r *PointInTimeCreateRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.pointintime.delete.go b/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.pointintime.delete.go new file mode 100644 index 000000000..bdc4c881b --- /dev/null +++ b/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.pointintime.delete.go @@ -0,0 +1,237 @@ +// SPDX-License-Identifier: Apache-2.0 +// +// The OpenSearch Contributors require contributions made to +// this file be licensed under the Apache-2.0 license or a +// compatible open source license. +// +// Modifications Copyright OpenSearch Contributors. See +// GitHub history for details. + +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package opensearchapi + +import ( + "bytes" + "context" + "encoding/json" + "io" + "net/http" + "strings" +) + +func newPointInTimeDeleteFunc(t Transport) PointInTimeDelete { + return func(o ...func(*PointInTimeDeleteRequest)) (*Response, *PointInTimeDeleteResp, error) { + var r = PointInTimeDeleteRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// PointInTimeDelete lets you delete pits used for searching with pagination +type PointInTimeDelete func(o ...func(*PointInTimeDeleteRequest)) (*Response, *PointInTimeDeleteResp, error) + +// PointInTimeDeleteRequest configures the Point In Time Delete API request. +type PointInTimeDeleteRequest struct { + PitID []string + + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// PointInTimeDeleteRequestBody is used to from the delete request body +type PointInTimeDeleteRequestBody struct { + PitID []string `json:"pit_id"` +} + +// PointInTimeDeleteResp is a custom type to parse the Point In Time Delete Reponse +type PointInTimeDeleteResp struct { + Pits []struct { + PitID string `json:"pit_id"` + Successful bool `json:"successful"` + } `json:"pits"` +} + +// Do executes the request and returns response or error. +func (r PointInTimeDeleteRequest) Do(ctx context.Context, transport Transport) (*Response, *PointInTimeDeleteResp, error) { + var ( + path strings.Builder + params map[string]string + body io.Reader + + data PointInTimeDeleteResp + ) + method := "DELETE" + + path.Grow(len("/_search/point_in_time")) + path.WriteString("/_search/point_in_time") + + params = make(map[string]string) + + if len(r.PitID) > 0 { + bodyStruct := PointInTimeDeleteRequestBody{PitID: r.PitID} + bodyJSON, err := json.Marshal(bodyStruct) + if err != nil { + return nil, nil, err + } + body = bytes.NewBuffer(bodyJSON) + } + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), body) + if err != nil { + return nil, nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if body != nil { + req.Header[headerContentType] = headerContentTypeJSON + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + if len(r.FilterPath) != 0 { + return &response, nil, nil + } + + if err := json.NewDecoder(response.Body).Decode(&data); err != nil { + return &response, nil, err + } + return &response, &data, nil +} + +// WithPitID sets the Pit to delete. +func (f PointInTimeDelete) WithPitID(v ...string) func(*PointInTimeDeleteRequest) { + return func(r *PointInTimeDeleteRequest) { + r.PitID = v + } +} + +// WithContext sets the request context. +func (f PointInTimeDelete) WithContext(v context.Context) func(*PointInTimeDeleteRequest) { + return func(r *PointInTimeDeleteRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f PointInTimeDelete) WithPretty() func(*PointInTimeDeleteRequest) { + return func(r *PointInTimeDeleteRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f PointInTimeDelete) WithHuman() func(*PointInTimeDeleteRequest) { + return func(r *PointInTimeDeleteRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f PointInTimeDelete) WithErrorTrace() func(*PointInTimeDeleteRequest) { + return func(r *PointInTimeDeleteRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f PointInTimeDelete) WithFilterPath(v ...string) func(*PointInTimeDeleteRequest) { + return func(r *PointInTimeDeleteRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f PointInTimeDelete) WithHeader(h map[string]string) func(*PointInTimeDeleteRequest) { + return func(r *PointInTimeDeleteRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f PointInTimeDelete) WithOpaqueID(s string) func(*PointInTimeDeleteRequest) { + return func(r *PointInTimeDeleteRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.pointintime.get.go b/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.pointintime.get.go new file mode 100644 index 000000000..5bb002086 --- /dev/null +++ b/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.pointintime.get.go @@ -0,0 +1,209 @@ +// SPDX-License-Identifier: Apache-2.0 +// +// The OpenSearch Contributors require contributions made to +// this file be licensed under the Apache-2.0 license or a +// compatible open source license. +// +// Modifications Copyright OpenSearch Contributors. See +// GitHub history for details. + +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package opensearchapi + +import ( + "context" + "encoding/json" + "net/http" + "strings" + "time" +) + +func newPointInTimeGetFunc(t Transport) PointInTimeGet { + return func(o ...func(*PointInTimeGetRequest)) (*Response, *PointInTimeGetResp, error) { + var r = PointInTimeGetRequest{} + for _, f := range o { + f(&r) + } + return r.Do(r.ctx, t) + } +} + +// ----- API Definition ------------------------------------------------------- + +// PointInTimeGet lets you get all existing pits +type PointInTimeGet func(o ...func(*PointInTimeGetRequest)) (*Response, *PointInTimeGetResp, error) + +// PointInTimeGetRequest configures the Point In Time Get API request. +type PointInTimeGetRequest struct { + Pretty bool + Human bool + ErrorTrace bool + FilterPath []string + + Header http.Header + + ctx context.Context +} + +// PointInTimeGetResp is a custom type to parse the Point In Time Get Reponse +type PointInTimeGetResp struct { + Pits []struct { + PitID string `json:"pit_id"` + CreationTime int `json:"creation_time"` + KeepAlive time.Duration `json:"keep_alive"` + } `json:"pits"` +} + +// Do executes the request and returns response or error. +func (r PointInTimeGetRequest) Do(ctx context.Context, transport Transport) (*Response, *PointInTimeGetResp, error) { + var ( + path strings.Builder + params map[string]string + + data PointInTimeGetResp + ) + method := "GET" + + path.Grow(len("/_search/point_in_time/_all")) + path.WriteString("/_search/point_in_time/_all") + + params = make(map[string]string) + + if r.Pretty { + params["pretty"] = "true" + } + + if r.Human { + params["human"] = "true" + } + + if r.ErrorTrace { + params["error_trace"] = "true" + } + + if len(r.FilterPath) > 0 { + params["filter_path"] = strings.Join(r.FilterPath, ",") + } + + req, err := newRequest(method, path.String(), nil) + if err != nil { + return nil, nil, err + } + + if len(params) > 0 { + q := req.URL.Query() + for k, v := range params { + q.Set(k, v) + } + req.URL.RawQuery = q.Encode() + } + + if len(r.Header) > 0 { + if len(req.Header) == 0 { + req.Header = r.Header + } else { + for k, vv := range r.Header { + for _, v := range vv { + req.Header.Add(k, v) + } + } + } + } + + if ctx != nil { + req = req.WithContext(ctx) + } + + res, err := transport.Perform(req) + if err != nil { + return nil, nil, err + } + + response := Response{ + StatusCode: res.StatusCode, + Body: res.Body, + Header: res.Header, + } + + if len(r.FilterPath) != 0 { + return &response, nil, nil + } + + if err := json.NewDecoder(response.Body).Decode(&data); err != nil { + return &response, nil, err + } + return &response, &data, nil +} + +// WithContext sets the request context. +func (f PointInTimeGet) WithContext(v context.Context) func(*PointInTimeGetRequest) { + return func(r *PointInTimeGetRequest) { + r.ctx = v + } +} + +// WithPretty makes the response body pretty-printed. +func (f PointInTimeGet) WithPretty() func(*PointInTimeGetRequest) { + return func(r *PointInTimeGetRequest) { + r.Pretty = true + } +} + +// WithHuman makes statistical values human-readable. +func (f PointInTimeGet) WithHuman() func(*PointInTimeGetRequest) { + return func(r *PointInTimeGetRequest) { + r.Human = true + } +} + +// WithErrorTrace includes the stack trace for errors in the response body. +func (f PointInTimeGet) WithErrorTrace() func(*PointInTimeGetRequest) { + return func(r *PointInTimeGetRequest) { + r.ErrorTrace = true + } +} + +// WithFilterPath filters the properties of the response body. +func (f PointInTimeGet) WithFilterPath(v ...string) func(*PointInTimeGetRequest) { + return func(r *PointInTimeGetRequest) { + r.FilterPath = v + } +} + +// WithHeader adds the headers to the HTTP request. +func (f PointInTimeGet) WithHeader(h map[string]string) func(*PointInTimeGetRequest) { + return func(r *PointInTimeGetRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + for k, v := range h { + r.Header.Add(k, v) + } + } +} + +// WithOpaqueID adds the X-Opaque-Id header to the HTTP request. +func (f PointInTimeGet) WithOpaqueID(s string) func(*PointInTimeGetRequest) { + return func(r *PointInTimeGetRequest) { + if r.Header == nil { + r.Header = make(http.Header) + } + r.Header.Set("X-Opaque-Id", s) + } +} diff --git a/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.search.go b/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.search.go index 8179578d7..d0451d818 100644 --- a/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.search.go +++ b/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.search.go @@ -56,7 +56,7 @@ type Search func(o ...func(*SearchRequest)) (*Response, error) // SearchRequest configures the Search API request. // type SearchRequest struct { - Index []string + Index []string Body io.Reader @@ -88,7 +88,7 @@ type SearchRequest struct { SeqNoPrimaryTerm *bool Size *int Sort []string - Source []string + Source interface{} SourceExcludes []string SourceIncludes []string Stats []string @@ -247,8 +247,12 @@ func (r SearchRequest) Do(ctx context.Context, transport Transport) (*Response, params["sort"] = strings.Join(r.Sort, ",") } - if len(r.Source) > 0 { - params["_source"] = strings.Join(r.Source, ",") + if source, ok := r.Source.(bool); ok { + params["_source"] = strconv.FormatBool(source) + } else if source, ok := r.Source.(string); ok && source != "" { + params["_source"] = source + } else if sources, ok := r.Source.([]string); ok && len(sources) > 0 { + params["_source"] = strings.Join(sources, ",") } if len(r.SourceExcludes) > 0 { @@ -620,7 +624,7 @@ func (f Search) WithSort(v ...string) func(*SearchRequest) { // WithSource - true or false to return the _source field or not, or a list of fields to return. // -func (f Search) WithSource(v ...string) func(*SearchRequest) { +func (f Search) WithSource(v interface{}) func(*SearchRequest) { return func(r *SearchRequest) { r.Source = v } diff --git a/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.snapshot.delete.go b/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.snapshot.delete.go index 376fcdb9e..6a136e1b2 100644 --- a/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.snapshot.delete.go +++ b/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.snapshot.delete.go @@ -34,7 +34,7 @@ import ( ) func newSnapshotDeleteFunc(t Transport) SnapshotDelete { - return func(repository string, snapshot string, o ...func(*SnapshotDeleteRequest)) (*Response, error) { + return func(repository string, snapshot []string, o ...func(*SnapshotDeleteRequest)) (*Response, error) { var r = SnapshotDeleteRequest{Repository: repository, Snapshot: snapshot} for _, f := range o { f(&r) @@ -48,13 +48,13 @@ func newSnapshotDeleteFunc(t Transport) SnapshotDelete { // SnapshotDelete deletes a snapshot. // // -type SnapshotDelete func(repository string, snapshot string, o ...func(*SnapshotDeleteRequest)) (*Response, error) +type SnapshotDelete func(repository string, snapshot []string, o ...func(*SnapshotDeleteRequest)) (*Response, error) // SnapshotDeleteRequest configures the Snapshot Delete API request. // type SnapshotDeleteRequest struct { Repository string - Snapshot string + Snapshot []string MasterTimeout time.Duration ClusterManagerTimeout time.Duration @@ -80,13 +80,13 @@ func (r SnapshotDeleteRequest) Do(ctx context.Context, transport Transport) (*Re method = "DELETE" - path.Grow(1 + len("_snapshot") + 1 + len(r.Repository) + 1 + len(r.Snapshot)) + path.Grow(1 + len("_snapshot") + 1 + len(r.Repository) + 1 + len(strings.Join(r.Snapshot, ","))) path.WriteString("/") path.WriteString("_snapshot") path.WriteString("/") path.WriteString(r.Repository) path.WriteString("/") - path.WriteString(r.Snapshot) + path.WriteString(strings.Join(r.Snapshot, ",")) params = make(map[string]string) diff --git a/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.update.go b/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.update.go index 59263fb20..6f02b88cf 100644 --- a/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.update.go +++ b/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.update.go @@ -55,8 +55,8 @@ type Update func(index string, id string, body io.Reader, o ...func(*UpdateReque // UpdateRequest configures the Update API request. // type UpdateRequest struct { - Index string - DocumentID string + Index string + DocumentID string Body io.Reader @@ -67,7 +67,7 @@ type UpdateRequest struct { RequireAlias *bool RetryOnConflict *int Routing string - Source []string + Source interface{} SourceExcludes []string SourceIncludes []string Timeout time.Duration @@ -132,8 +132,12 @@ func (r UpdateRequest) Do(ctx context.Context, transport Transport) (*Response, params["routing"] = r.Routing } - if len(r.Source) > 0 { - params["_source"] = strings.Join(r.Source, ",") + if source, ok := r.Source.(bool); ok { + params["_source"] = strconv.FormatBool(source) + } else if source, ok := r.Source.(string); ok && source != "" { + params["_source"] = source + } else if sources, ok := r.Source.([]string); ok && len(sources) > 0 { + params["_source"] = strings.Join(sources, ",") } if len(r.SourceExcludes) > 0 { @@ -281,7 +285,7 @@ func (f Update) WithRouting(v string) func(*UpdateRequest) { // WithSource - true or false to return the _source field or not, or a list of fields to return. // -func (f Update) WithSource(v ...string) func(*UpdateRequest) { +func (f Update) WithSource(v interface{}) func(*UpdateRequest) { return func(r *UpdateRequest) { r.Source = v } diff --git a/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.update_by_query.go b/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.update_by_query.go index 4f5d5c51a..07ab5af17 100644 --- a/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.update_by_query.go +++ b/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchapi/api.update_by_query.go @@ -57,7 +57,7 @@ type UpdateByQuery func(index []string, o ...func(*UpdateByQueryRequest)) (*Resp // UpdateByQueryRequest configures the Update By Query API request. // type UpdateByQueryRequest struct { - Index []string + Index []string Body io.Reader @@ -86,7 +86,7 @@ type UpdateByQueryRequest struct { Size *int Slices interface{} Sort []string - Source []string + Source interface{} SourceExcludes []string SourceIncludes []string Stats []string @@ -226,8 +226,12 @@ func (r UpdateByQueryRequest) Do(ctx context.Context, transport Transport) (*Res params["sort"] = strings.Join(r.Sort, ",") } - if len(r.Source) > 0 { - params["_source"] = strings.Join(r.Source, ",") + if source, ok := r.Source.(bool); ok { + params["_source"] = strconv.FormatBool(source) + } else if source, ok := r.Source.(string); ok && source != "" { + params["_source"] = source + } else if sources, ok := r.Source.([]string); ok && len(sources) > 0 { + params["_source"] = strings.Join(sources, ",") } if len(r.SourceExcludes) > 0 { @@ -547,7 +551,7 @@ func (f UpdateByQuery) WithSort(v ...string) func(*UpdateByQueryRequest) { // WithSource - true or false to return the _source field or not, or a list of fields to return. // -func (f UpdateByQuery) WithSource(v ...string) func(*UpdateByQueryRequest) { +func (f UpdateByQuery) WithSource(v interface{}) func(*UpdateByQueryRequest) { return func(r *UpdateByQueryRequest) { r.Source = v } diff --git a/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchtransport/logger.go b/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchtransport/logger.go index 223b0165d..f089e9e63 100644 --- a/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchtransport/logger.go +++ b/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchtransport/logger.go @@ -248,8 +248,12 @@ func (l *CurlLogger) LogRoundTrip(req *http.Request, res *http.Response, err err } } - b.WriteString(" 'http://localhost:9200") - b.WriteString(req.URL.Path) + // If by some oddity we end up with a nil req.URL, we handle it gracefully. + if req.URL == nil { + b.WriteString(" '") + } else { + b.WriteString(fmt.Sprintf(" '%s://%s%s", req.URL.Scheme, req.URL.Host, req.URL.Path)) + } b.WriteString("?pretty") if query != "" { fmt.Fprintf(&b, "&%s", query) diff --git a/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchtransport/opensearchtransport.go b/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchtransport/opensearchtransport.go index 491a9b785..fe8e450f4 100644 --- a/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchtransport/opensearchtransport.go +++ b/vendor/github.com/opensearch-project/opensearch-go/v2/opensearchtransport/opensearchtransport.go @@ -75,13 +75,11 @@ func init() { } // Interface defines the interface for HTTP client. -// type Interface interface { Perform(*http.Request) (*http.Response, error) } // Config represents the configuration of HTTP client. -// type Config struct { URLs []*url.URL Username string @@ -113,7 +111,6 @@ type Config struct { } // Client represents the HTTP client. -// type Client struct { sync.Mutex @@ -146,7 +143,6 @@ type Client struct { // New creates new transport client. // // http.DefaultTransport will be used if no transport is passed in the configuration. -// func New(cfg Config) (*Client, error) { if cfg.Transport == nil { cfg.Transport = http.DefaultTransport @@ -235,7 +231,6 @@ func New(cfg Config) (*Client, error) { } // Perform executes the request and returns a response or error. -// func (c *Client) Perform(req *http.Request) (*http.Response, error) { var ( res *http.Response @@ -407,14 +402,20 @@ func (c *Client) Perform(req *http.Request) (*http.Response, error) { time.Sleep(c.retryBackoff(i + 1)) } } + // Read, close and replace the http reponse body to close the connection + if res != nil && res.Body != nil { + body, err := io.ReadAll(res.Body) + res.Body.Close() + if err == nil { + res.Body = io.NopCloser(bytes.NewReader(body)) + } + } // TODO(karmi): Wrap error return res, err } // URLs returns a list of transport URLs. -// -// func (c *Client) URLs() []*url.URL { return c.pool.URLs() } diff --git a/vendor/github.com/redis/go-redis/v9/.gitignore b/vendor/github.com/redis/go-redis/v9/.gitignore index dc322f9be..6f868895b 100644 --- a/vendor/github.com/redis/go-redis/v9/.gitignore +++ b/vendor/github.com/redis/go-redis/v9/.gitignore @@ -1,3 +1,6 @@ *.rdb testdata/* .idea/ +.DS_Store +*.tar.gz +*.dic \ No newline at end of file diff --git a/vendor/github.com/redis/go-redis/v9/CONTRIBUTING.md b/vendor/github.com/redis/go-redis/v9/CONTRIBUTING.md new file mode 100644 index 000000000..90030b89f --- /dev/null +++ b/vendor/github.com/redis/go-redis/v9/CONTRIBUTING.md @@ -0,0 +1,101 @@ +# Contributing + +## Introduction + +We appreciate your interest in considering contributing to go-redis. +Community contributions mean a lot to us. + +## Contributions we need + +You may already know how you'd like to contribute, whether it's a fix for a bug you +encountered, or a new feature your team wants to use. + +If you don't know where to start, consider improving +documentation, bug triaging, and writing tutorials are all examples of +helpful contributions that mean less work for you. + +## Your First Contribution + +Unsure where to begin contributing? You can start by looking through +[help-wanted +issues](https://github.com/redis/go-redis/issues?q=is%3Aopen+is%3Aissue+label%3ahelp-wanted). + +Never contributed to open source before? Here are a couple of friendly +tutorials: + +- +- + +## Getting Started + +Here's how to get started with your code contribution: + +1. Create your own fork of go-redis +2. Do the changes in your fork +3. If you need a development environment, run `make test`. Note: this clones and builds the latest release of [redis](https://redis.io). You also need a redis-stack-server docker, in order to run the capabilities tests. This can be started by running: + ```docker run -p 6379:6379 -it redis/redis-stack-server:edge``` +4. While developing, make sure the tests pass by running `make tests` +5. If you like the change and think the project could use it, send a + pull request + +To see what else is part of the automation, run `invoke -l` + +## Testing + +Call `make test` to run all tests, including linters. + +Continuous Integration uses these same wrappers to run all of these +tests against multiple versions of python. Feel free to test your +changes against all the go versions supported, as declared by the +[build.yml](./.github/workflows/build.yml) file. + +### Troubleshooting + +If you get any errors when running `make test`, make sure +that you are using supported versions of Docker and go. + +## How to Report a Bug + +### Security Vulnerabilities + +**NOTE**: If you find a security vulnerability, do NOT open an issue. +Email [Redis Open Source ()](mailto:oss@redis.com) instead. + +In order to determine whether you are dealing with a security issue, ask +yourself these two questions: + +- Can I access something that's not mine, or something I shouldn't + have access to? +- Can I disable something for other people? + +If the answer to either of those two questions are *yes*, then you're +probably dealing with a security issue. Note that even if you answer +*no* to both questions, you may still be dealing with a security +issue, so if you're unsure, just email [us](mailto:oss@redis.com). + +### Everything Else + +When filing an issue, make sure to answer these five questions: + +1. What version of go-redis are you using? +2. What version of redis are you using? +3. What did you do? +4. What did you expect to see? +5. What did you see instead? + +## Suggest a feature or enhancement + +If you'd like to contribute a new feature, make sure you check our +issue list to see if someone has already proposed it. Work may already +be underway on the feature you want or we may have rejected a +feature like it already. + +If you don't see anything, open a new issue that describes the feature +you would like and how it should work. + +## Code review process + +The core team regularly looks at pull requests. We will provide +feedback as soon as possible. After receiving our feedback, please respond +within two weeks. After that time, we may close your PR if it isn't +showing any activity. diff --git a/vendor/github.com/redis/go-redis/v9/Makefile b/vendor/github.com/redis/go-redis/v9/Makefile index 285f65dd5..dc2fe780a 100644 --- a/vendor/github.com/redis/go-redis/v9/Makefile +++ b/vendor/github.com/redis/go-redis/v9/Makefile @@ -19,17 +19,20 @@ testdeps: testdata/redis/src/redis-server bench: testdeps go test ./... -test.run=NONE -test.bench=. -test.benchmem -.PHONY: all test testdeps bench +.PHONY: all test testdeps bench fmt + +build: + go build . testdata/redis: mkdir -p $@ - wget -qO- https://download.redis.io/releases/redis-7.2-rc1.tar.gz | tar xvz --strip-components=1 -C $@ + wget -qO- https://download.redis.io/releases/redis-7.2.1.tar.gz | tar xvz --strip-components=1 -C $@ testdata/redis/src/redis-server: testdata/redis cd $< && make all fmt: - gofmt -w -s ./ + gofumpt -w ./ goimports -w -local github.com/redis/go-redis ./ go_mod_tidy: diff --git a/vendor/github.com/redis/go-redis/v9/README.md b/vendor/github.com/redis/go-redis/v9/README.md index 36d60fd4e..043d3f0e6 100644 --- a/vendor/github.com/redis/go-redis/v9/README.md +++ b/vendor/github.com/redis/go-redis/v9/README.md @@ -10,8 +10,22 @@ > use it to monitor applications and set up automatic alerts to receive notifications via email, > Slack, Telegram, and others. > -> See [OpenTelemetry](example/otel) example which demonstrates how you can use Uptrace to monitor -> go-redis. +> See [OpenTelemetry](https://github.com/redis/go-redis/tree/master/example/otel) example which +> demonstrates how you can use Uptrace to monitor go-redis. + +## How do I Redis? + +[Learn for free at Redis University](https://university.redis.com/) + +[Build faster with the Redis Launchpad](https://launchpad.redis.com/) + +[Try the Redis Cloud](https://redis.com/try-free/) + +[Dive in developer tutorials](https://developer.redis.com/) + +[Join the Redis community](https://redis.com/community/) + +[Work at Redis](https://redis.com/company/careers/jobs/) ## Documentation @@ -37,8 +51,8 @@ key value NoSQL database that uses RocksDB as storage engine and is compatible w ## Features -- Redis 3 commands except QUIT, MONITOR, and SYNC. -- Automatic connection pooling with +- Redis commands except QUIT and SYNC. +- Automatic connection pooling. - [Pub/Sub](https://redis.uptrace.dev/guide/go-redis-pubsub.html). - [Pipelines and transactions](https://redis.uptrace.dev/guide/go-redis-pipelines.html). - [Scripting](https://redis.uptrace.dev/guide/lua-scripting.html). @@ -46,6 +60,7 @@ key value NoSQL database that uses RocksDB as storage engine and is compatible w - [Redis Cluster](https://redis.uptrace.dev/guide/go-redis-cluster.html). - [Redis Ring](https://redis.uptrace.dev/guide/ring.html). - [Redis Performance Monitoring](https://redis.uptrace.dev/guide/redis-performance-monitoring.html). +- [Redis Probabilistic [RedisStack]](https://redis.io/docs/data-types/probabilistic/) ## Installation @@ -68,8 +83,9 @@ go get github.com/redis/go-redis/v9 ```go import ( "context" - "github.com/redis/go-redis/v9" "fmt" + + "github.com/redis/go-redis/v9" ) var ctx = context.Background() @@ -105,6 +121,74 @@ func ExampleClient() { } ``` +The above can be modified to specify the version of the RESP protocol by adding the `protocol` +option to the `Options` struct: + +```go + rdb := redis.NewClient(&redis.Options{ + Addr: "localhost:6379", + Password: "", // no password set + DB: 0, // use default DB + Protocol: 3, // specify 2 for RESP 2 or 3 for RESP 3 + }) + +``` + +### Connecting via a redis url + +go-redis also supports connecting via the +[redis uri specification](https://github.com/redis/redis-specifications/tree/master/uri/redis.txt). +The example below demonstrates how the connection can easily be configured using a string, adhering +to this specification. + +```go +import ( + "context" + "fmt" + + "github.com/redis/go-redis/v9" +) + +func ExampleClient() *redis.Client { + url := "redis://user:password@localhost:6379/0?protocol=3" + opts, err := redis.ParseURL(url) + if err != nil { + panic(err) + } + + return redis.NewClient(opts) +} + +``` + + +### Advanced Configuration + +go-redis supports extending the client identification phase to allow projects to send their own custom client identification. + +#### Default Client Identification + +By default, go-redis automatically sends the client library name and version during the connection process. This feature is available in redis-server as of version 7.2. As a result, the command is "fire and forget", meaning it should fail silently, in the case that the redis server does not support this feature. + +#### Disabling Identity Verification + +When connection identity verification is not required or needs to be explicitly disabled, a `DisableIndentity` configuration option exists. In V10 of this library, `DisableIndentity` will become `DisableIdentity` in order to fix the associated typo. + +To disable verification, set the `DisableIndentity` option to `true` in the Redis client options: + +```go +rdb := redis.NewClient(&redis.Options{ + Addr: "localhost:6379", + Password: "", + DB: 0, + DisableIndentity: true, // Disable set-info on connect +}) +``` + +## Contributing + +Please see [out contributing guidelines](CONTRIBUTING.md) to help us improve this library! + ## Look and feel Some corner cases: @@ -167,7 +251,8 @@ Lastly, run: go test ``` -Another option is to run your specific tests with an already running redis. The example below, tests against a redis running on port 9999.: +Another option is to run your specific tests with an already running redis. The example below, tests +against a redis running on port 9999.: ```shell REDIS_PORT=9999 go test diff --git a/vendor/github.com/redis/go-redis/v9/acl_commands.go b/vendor/github.com/redis/go-redis/v9/acl_commands.go new file mode 100644 index 000000000..06847be2e --- /dev/null +++ b/vendor/github.com/redis/go-redis/v9/acl_commands.go @@ -0,0 +1,35 @@ +package redis + +import "context" + +type ACLCmdable interface { + ACLDryRun(ctx context.Context, username string, command ...interface{}) *StringCmd + ACLLog(ctx context.Context, count int64) *ACLLogCmd + ACLLogReset(ctx context.Context) *StatusCmd +} + +func (c cmdable) ACLDryRun(ctx context.Context, username string, command ...interface{}) *StringCmd { + args := make([]interface{}, 0, 3+len(command)) + args = append(args, "acl", "dryrun", username) + args = append(args, command...) + cmd := NewStringCmd(ctx, args...) + _ = c(ctx, cmd) + return cmd +} + +func (c cmdable) ACLLog(ctx context.Context, count int64) *ACLLogCmd { + args := make([]interface{}, 0, 3) + args = append(args, "acl", "log") + if count > 0 { + args = append(args, count) + } + cmd := NewACLLogCmd(ctx, args...) + _ = c(ctx, cmd) + return cmd +} + +func (c cmdable) ACLLogReset(ctx context.Context) *StatusCmd { + cmd := NewStatusCmd(ctx, "acl", "log", "reset") + _ = c(ctx, cmd) + return cmd +} diff --git a/vendor/github.com/redis/go-redis/v9/bitmap_commands.go b/vendor/github.com/redis/go-redis/v9/bitmap_commands.go new file mode 100644 index 000000000..d9fc50dce --- /dev/null +++ b/vendor/github.com/redis/go-redis/v9/bitmap_commands.go @@ -0,0 +1,163 @@ +package redis + +import ( + "context" + "errors" +) + +type BitMapCmdable interface { + GetBit(ctx context.Context, key string, offset int64) *IntCmd + SetBit(ctx context.Context, key string, offset int64, value int) *IntCmd + BitCount(ctx context.Context, key string, bitCount *BitCount) *IntCmd + BitOpAnd(ctx context.Context, destKey string, keys ...string) *IntCmd + BitOpOr(ctx context.Context, destKey string, keys ...string) *IntCmd + BitOpXor(ctx context.Context, destKey string, keys ...string) *IntCmd + BitOpNot(ctx context.Context, destKey string, key string) *IntCmd + BitPos(ctx context.Context, key string, bit int64, pos ...int64) *IntCmd + BitPosSpan(ctx context.Context, key string, bit int8, start, end int64, span string) *IntCmd + BitField(ctx context.Context, key string, values ...interface{}) *IntSliceCmd +} + +func (c cmdable) GetBit(ctx context.Context, key string, offset int64) *IntCmd { + cmd := NewIntCmd(ctx, "getbit", key, offset) + _ = c(ctx, cmd) + return cmd +} + +func (c cmdable) SetBit(ctx context.Context, key string, offset int64, value int) *IntCmd { + cmd := NewIntCmd( + ctx, + "setbit", + key, + offset, + value, + ) + _ = c(ctx, cmd) + return cmd +} + +type BitCount struct { + Start, End int64 + Unit string // BYTE(default) | BIT +} + +const BitCountIndexByte string = "BYTE" +const BitCountIndexBit string = "BIT" + +func (c cmdable) BitCount(ctx context.Context, key string, bitCount *BitCount) *IntCmd { + args := []interface{}{"bitcount", key} + if bitCount != nil { + if bitCount.Unit == "" { + bitCount.Unit = "BYTE" + } + if bitCount.Unit != BitCountIndexByte && bitCount.Unit != BitCountIndexBit { + cmd := NewIntCmd(ctx) + cmd.SetErr(errors.New("redis: invalid bitcount index")) + return cmd + } + args = append( + args, + bitCount.Start, + bitCount.End, + string(bitCount.Unit), + ) + } + cmd := NewIntCmd(ctx, args...) + _ = c(ctx, cmd) + return cmd +} + +func (c cmdable) bitOp(ctx context.Context, op, destKey string, keys ...string) *IntCmd { + args := make([]interface{}, 3+len(keys)) + args[0] = "bitop" + args[1] = op + args[2] = destKey + for i, key := range keys { + args[3+i] = key + } + cmd := NewIntCmd(ctx, args...) + _ = c(ctx, cmd) + return cmd +} + +func (c cmdable) BitOpAnd(ctx context.Context, destKey string, keys ...string) *IntCmd { + return c.bitOp(ctx, "and", destKey, keys...) +} + +func (c cmdable) BitOpOr(ctx context.Context, destKey string, keys ...string) *IntCmd { + return c.bitOp(ctx, "or", destKey, keys...) +} + +func (c cmdable) BitOpXor(ctx context.Context, destKey string, keys ...string) *IntCmd { + return c.bitOp(ctx, "xor", destKey, keys...) +} + +func (c cmdable) BitOpNot(ctx context.Context, destKey string, key string) *IntCmd { + return c.bitOp(ctx, "not", destKey, key) +} + +// BitPos is an API before Redis version 7.0, cmd: bitpos key bit start end +// if you need the `byte | bit` parameter, please use `BitPosSpan`. +func (c cmdable) BitPos(ctx context.Context, key string, bit int64, pos ...int64) *IntCmd { + args := make([]interface{}, 3+len(pos)) + args[0] = "bitpos" + args[1] = key + args[2] = bit + switch len(pos) { + case 0: + case 1: + args[3] = pos[0] + case 2: + args[3] = pos[0] + args[4] = pos[1] + default: + panic("too many arguments") + } + cmd := NewIntCmd(ctx, args...) + _ = c(ctx, cmd) + return cmd +} + +// BitPosSpan supports the `byte | bit` parameters in redis version 7.0, +// the bitpos command defaults to using byte type for the `start-end` range, +// which means it counts in bytes from start to end. you can set the value +// of "span" to determine the type of `start-end`. +// span = "bit", cmd: bitpos key bit start end bit +// span = "byte", cmd: bitpos key bit start end byte +func (c cmdable) BitPosSpan(ctx context.Context, key string, bit int8, start, end int64, span string) *IntCmd { + cmd := NewIntCmd(ctx, "bitpos", key, bit, start, end, span) + _ = c(ctx, cmd) + return cmd +} + +// BitField accepts multiple values: +// - BitField("set", "i1", "offset1", "value1","cmd2", "type2", "offset2", "value2") +// - BitField([]string{"cmd1", "type1", "offset1", "value1","cmd2", "type2", "offset2", "value2"}) +// - BitField([]interface{}{"cmd1", "type1", "offset1", "value1","cmd2", "type2", "offset2", "value2"}) +func (c cmdable) BitField(ctx context.Context, key string, values ...interface{}) *IntSliceCmd { + args := make([]interface{}, 2, 2+len(values)) + args[0] = "bitfield" + args[1] = key + args = appendArgs(args, values) + cmd := NewIntSliceCmd(ctx, args...) + _ = c(ctx, cmd) + return cmd +} + +// BitFieldRO - Read-only variant of the BITFIELD command. +// It is like the original BITFIELD but only accepts GET subcommand and can safely be used in read-only replicas. +// - BitFieldRO(ctx, key, "", "", "","") +func (c cmdable) BitFieldRO(ctx context.Context, key string, values ...interface{}) *IntSliceCmd { + args := make([]interface{}, 2, 2+len(values)) + args[0] = "BITFIELD_RO" + args[1] = key + if len(values)%2 != 0 { + panic("BitFieldRO: invalid number of arguments, must be even") + } + for i := 0; i < len(values); i += 2 { + args = append(args, "GET", values[i], values[i+1]) + } + cmd := NewIntSliceCmd(ctx, args...) + _ = c(ctx, cmd) + return cmd +} diff --git a/vendor/github.com/redis/go-redis/v9/cluster_commands.go b/vendor/github.com/redis/go-redis/v9/cluster_commands.go index b13f8e7e9..0caf0977a 100644 --- a/vendor/github.com/redis/go-redis/v9/cluster_commands.go +++ b/vendor/github.com/redis/go-redis/v9/cluster_commands.go @@ -1,109 +1,192 @@ package redis -import ( - "context" - "sync" - "sync/atomic" -) - -func (c *ClusterClient) DBSize(ctx context.Context) *IntCmd { - cmd := NewIntCmd(ctx, "dbsize") - _ = c.withProcessHook(ctx, cmd, func(ctx context.Context, _ Cmder) error { - var size int64 - err := c.ForEachMaster(ctx, func(ctx context.Context, master *Client) error { - n, err := master.DBSize(ctx).Result() - if err != nil { - return err - } - atomic.AddInt64(&size, n) - return nil - }) - if err != nil { - cmd.SetErr(err) - } else { - cmd.val = size - } - return nil - }) - return cmd -} - -func (c *ClusterClient) ScriptLoad(ctx context.Context, script string) *StringCmd { - cmd := NewStringCmd(ctx, "script", "load", script) - _ = c.withProcessHook(ctx, cmd, func(ctx context.Context, _ Cmder) error { - var mu sync.Mutex - err := c.ForEachShard(ctx, func(ctx context.Context, shard *Client) error { - val, err := shard.ScriptLoad(ctx, script).Result() - if err != nil { - return err - } - - mu.Lock() - if cmd.Val() == "" { - cmd.val = val - } - mu.Unlock() - - return nil - }) - if err != nil { - cmd.SetErr(err) - } - return nil - }) - return cmd -} - -func (c *ClusterClient) ScriptFlush(ctx context.Context) *StatusCmd { - cmd := NewStatusCmd(ctx, "script", "flush") - _ = c.withProcessHook(ctx, cmd, func(ctx context.Context, _ Cmder) error { - err := c.ForEachShard(ctx, func(ctx context.Context, shard *Client) error { - return shard.ScriptFlush(ctx).Err() - }) - if err != nil { - cmd.SetErr(err) - } - return nil - }) - return cmd -} - -func (c *ClusterClient) ScriptExists(ctx context.Context, hashes ...string) *BoolSliceCmd { - args := make([]interface{}, 2+len(hashes)) - args[0] = "script" - args[1] = "exists" - for i, hash := range hashes { - args[2+i] = hash +import "context" + +type ClusterCmdable interface { + ClusterMyShardID(ctx context.Context) *StringCmd + ClusterSlots(ctx context.Context) *ClusterSlotsCmd + ClusterShards(ctx context.Context) *ClusterShardsCmd + ClusterLinks(ctx context.Context) *ClusterLinksCmd + ClusterNodes(ctx context.Context) *StringCmd + ClusterMeet(ctx context.Context, host, port string) *StatusCmd + ClusterForget(ctx context.Context, nodeID string) *StatusCmd + ClusterReplicate(ctx context.Context, nodeID string) *StatusCmd + ClusterResetSoft(ctx context.Context) *StatusCmd + ClusterResetHard(ctx context.Context) *StatusCmd + ClusterInfo(ctx context.Context) *StringCmd + ClusterKeySlot(ctx context.Context, key string) *IntCmd + ClusterGetKeysInSlot(ctx context.Context, slot int, count int) *StringSliceCmd + ClusterCountFailureReports(ctx context.Context, nodeID string) *IntCmd + ClusterCountKeysInSlot(ctx context.Context, slot int) *IntCmd + ClusterDelSlots(ctx context.Context, slots ...int) *StatusCmd + ClusterDelSlotsRange(ctx context.Context, min, max int) *StatusCmd + ClusterSaveConfig(ctx context.Context) *StatusCmd + ClusterSlaves(ctx context.Context, nodeID string) *StringSliceCmd + ClusterFailover(ctx context.Context) *StatusCmd + ClusterAddSlots(ctx context.Context, slots ...int) *StatusCmd + ClusterAddSlotsRange(ctx context.Context, min, max int) *StatusCmd + ReadOnly(ctx context.Context) *StatusCmd + ReadWrite(ctx context.Context) *StatusCmd +} + +func (c cmdable) ClusterMyShardID(ctx context.Context) *StringCmd { + cmd := NewStringCmd(ctx, "cluster", "myshardid") + _ = c(ctx, cmd) + return cmd +} + +func (c cmdable) ClusterSlots(ctx context.Context) *ClusterSlotsCmd { + cmd := NewClusterSlotsCmd(ctx, "cluster", "slots") + _ = c(ctx, cmd) + return cmd +} + +func (c cmdable) ClusterShards(ctx context.Context) *ClusterShardsCmd { + cmd := NewClusterShardsCmd(ctx, "cluster", "shards") + _ = c(ctx, cmd) + return cmd +} + +func (c cmdable) ClusterLinks(ctx context.Context) *ClusterLinksCmd { + cmd := NewClusterLinksCmd(ctx, "cluster", "links") + _ = c(ctx, cmd) + return cmd +} + +func (c cmdable) ClusterNodes(ctx context.Context) *StringCmd { + cmd := NewStringCmd(ctx, "cluster", "nodes") + _ = c(ctx, cmd) + return cmd +} + +func (c cmdable) ClusterMeet(ctx context.Context, host, port string) *StatusCmd { + cmd := NewStatusCmd(ctx, "cluster", "meet", host, port) + _ = c(ctx, cmd) + return cmd +} + +func (c cmdable) ClusterForget(ctx context.Context, nodeID string) *StatusCmd { + cmd := NewStatusCmd(ctx, "cluster", "forget", nodeID) + _ = c(ctx, cmd) + return cmd +} + +func (c cmdable) ClusterReplicate(ctx context.Context, nodeID string) *StatusCmd { + cmd := NewStatusCmd(ctx, "cluster", "replicate", nodeID) + _ = c(ctx, cmd) + return cmd +} + +func (c cmdable) ClusterResetSoft(ctx context.Context) *StatusCmd { + cmd := NewStatusCmd(ctx, "cluster", "reset", "soft") + _ = c(ctx, cmd) + return cmd +} + +func (c cmdable) ClusterResetHard(ctx context.Context) *StatusCmd { + cmd := NewStatusCmd(ctx, "cluster", "reset", "hard") + _ = c(ctx, cmd) + return cmd +} + +func (c cmdable) ClusterInfo(ctx context.Context) *StringCmd { + cmd := NewStringCmd(ctx, "cluster", "info") + _ = c(ctx, cmd) + return cmd +} + +func (c cmdable) ClusterKeySlot(ctx context.Context, key string) *IntCmd { + cmd := NewIntCmd(ctx, "cluster", "keyslot", key) + _ = c(ctx, cmd) + return cmd +} + +func (c cmdable) ClusterGetKeysInSlot(ctx context.Context, slot int, count int) *StringSliceCmd { + cmd := NewStringSliceCmd(ctx, "cluster", "getkeysinslot", slot, count) + _ = c(ctx, cmd) + return cmd +} + +func (c cmdable) ClusterCountFailureReports(ctx context.Context, nodeID string) *IntCmd { + cmd := NewIntCmd(ctx, "cluster", "count-failure-reports", nodeID) + _ = c(ctx, cmd) + return cmd +} + +func (c cmdable) ClusterCountKeysInSlot(ctx context.Context, slot int) *IntCmd { + cmd := NewIntCmd(ctx, "cluster", "countkeysinslot", slot) + _ = c(ctx, cmd) + return cmd +} + +func (c cmdable) ClusterDelSlots(ctx context.Context, slots ...int) *StatusCmd { + args := make([]interface{}, 2+len(slots)) + args[0] = "cluster" + args[1] = "delslots" + for i, slot := range slots { + args[2+i] = slot } - cmd := NewBoolSliceCmd(ctx, args...) + cmd := NewStatusCmd(ctx, args...) + _ = c(ctx, cmd) + return cmd +} - result := make([]bool, len(hashes)) - for i := range result { - result[i] = true +func (c cmdable) ClusterDelSlotsRange(ctx context.Context, min, max int) *StatusCmd { + size := max - min + 1 + slots := make([]int, size) + for i := 0; i < size; i++ { + slots[i] = min + i } + return c.ClusterDelSlots(ctx, slots...) +} + +func (c cmdable) ClusterSaveConfig(ctx context.Context) *StatusCmd { + cmd := NewStatusCmd(ctx, "cluster", "saveconfig") + _ = c(ctx, cmd) + return cmd +} + +func (c cmdable) ClusterSlaves(ctx context.Context, nodeID string) *StringSliceCmd { + cmd := NewStringSliceCmd(ctx, "cluster", "slaves", nodeID) + _ = c(ctx, cmd) + return cmd +} + +func (c cmdable) ClusterFailover(ctx context.Context) *StatusCmd { + cmd := NewStatusCmd(ctx, "cluster", "failover") + _ = c(ctx, cmd) + return cmd +} + +func (c cmdable) ClusterAddSlots(ctx context.Context, slots ...int) *StatusCmd { + args := make([]interface{}, 2+len(slots)) + args[0] = "cluster" + args[1] = "addslots" + for i, num := range slots { + args[2+i] = num + } + cmd := NewStatusCmd(ctx, args...) + _ = c(ctx, cmd) + return cmd +} + +func (c cmdable) ClusterAddSlotsRange(ctx context.Context, min, max int) *StatusCmd { + size := max - min + 1 + slots := make([]int, size) + for i := 0; i < size; i++ { + slots[i] = min + i + } + return c.ClusterAddSlots(ctx, slots...) +} + +func (c cmdable) ReadOnly(ctx context.Context) *StatusCmd { + cmd := NewStatusCmd(ctx, "readonly") + _ = c(ctx, cmd) + return cmd +} - _ = c.withProcessHook(ctx, cmd, func(ctx context.Context, _ Cmder) error { - var mu sync.Mutex - err := c.ForEachShard(ctx, func(ctx context.Context, shard *Client) error { - val, err := shard.ScriptExists(ctx, hashes...).Result() - if err != nil { - return err - } - - mu.Lock() - for i, v := range val { - result[i] = result[i] && v - } - mu.Unlock() - - return nil - }) - if err != nil { - cmd.SetErr(err) - } else { - cmd.val = result - } - return nil - }) +func (c cmdable) ReadWrite(ctx context.Context) *StatusCmd { + cmd := NewStatusCmd(ctx, "readwrite") + _ = c(ctx, cmd) return cmd } diff --git a/vendor/github.com/redis/go-redis/v9/command.go b/vendor/github.com/redis/go-redis/v9/command.go index f10e7365d..9fb9a8310 100644 --- a/vendor/github.com/redis/go-redis/v9/command.go +++ b/vendor/github.com/redis/go-redis/v9/command.go @@ -1,11 +1,14 @@ package redis import ( + "bufio" "context" "fmt" "net" + "regexp" "strconv" "strings" + "sync" "time" "github.com/redis/go-redis/v9/internal" @@ -15,10 +18,22 @@ import ( ) type Cmder interface { + // command name. + // e.g. "set k v ex 10" -> "set", "cluster info" -> "cluster". Name() string + + // full command name. + // e.g. "set k v ex 10" -> "set", "cluster info" -> "cluster info". FullName() string + + // all args of the command. + // e.g. "set k v ex 10" -> "[set k v ex 10]". Args() []interface{} + + // format request and response string. + // e.g. "set k v ex 10" -> "set k v ex 10: OK", "get k" -> "get k: v". String() string + stringArg(int) string firstKeyPos() int8 SetFirstKeyPos(int8) @@ -60,7 +75,7 @@ func writeCmd(wr *proto.Writer, cmd Cmder) error { return wr.WriteArgs(cmd.Args()) } -func cmdFirstKeyPos(cmd Cmder, info *CommandInfo) int { +func cmdFirstKeyPos(cmd Cmder) int { if pos := cmd.firstKeyPos(); pos != 0 { return int(pos) } @@ -80,10 +95,6 @@ func cmdFirstKeyPos(cmd Cmder, info *CommandInfo) int { return 2 } } - - if info != nil { - return int(info.FirstKeyPos) - } return 1 } @@ -340,6 +351,8 @@ func (cmd *Cmd) Bool() (bool, error) { func toBool(val interface{}) (bool, error) { switch val := val.(type) { + case bool: + return val, nil case int64: return val != 0, nil case string: @@ -841,7 +854,7 @@ func (cmd *StringCmd) Val() string { } func (cmd *StringCmd) Result() (string, error) { - return cmd.Val(), cmd.err + return cmd.val, cmd.err } func (cmd *StringCmd) Bytes() ([]byte, error) { @@ -945,7 +958,7 @@ func (cmd *FloatCmd) Val() float64 { } func (cmd *FloatCmd) Result() (float64, error) { - return cmd.Val(), cmd.Err() + return cmd.val, cmd.err } func (cmd *FloatCmd) String() string { @@ -1040,7 +1053,7 @@ func (cmd *StringSliceCmd) Val() []string { } func (cmd *StringSliceCmd) Result() ([]string, error) { - return cmd.Val(), cmd.Err() + return cmd.val, cmd.err } func (cmd *StringSliceCmd) String() string { @@ -1349,6 +1362,65 @@ func (cmd *MapStringIntCmd) readReply(rd *proto.Reader) error { return nil } +// ------------------------------------------------------------------------------ +type MapStringSliceInterfaceCmd struct { + baseCmd + val map[string][]interface{} +} + +func NewMapStringSliceInterfaceCmd(ctx context.Context, args ...interface{}) *MapStringSliceInterfaceCmd { + return &MapStringSliceInterfaceCmd{ + baseCmd: baseCmd{ + ctx: ctx, + args: args, + }, + } +} + +func (cmd *MapStringSliceInterfaceCmd) String() string { + return cmdString(cmd, cmd.val) +} + +func (cmd *MapStringSliceInterfaceCmd) SetVal(val map[string][]interface{}) { + cmd.val = val +} + +func (cmd *MapStringSliceInterfaceCmd) Result() (map[string][]interface{}, error) { + return cmd.val, cmd.err +} + +func (cmd *MapStringSliceInterfaceCmd) Val() map[string][]interface{} { + return cmd.val +} + +func (cmd *MapStringSliceInterfaceCmd) readReply(rd *proto.Reader) (err error) { + n, err := rd.ReadMapLen() + if err != nil { + return err + } + cmd.val = make(map[string][]interface{}, n) + for i := 0; i < n; i++ { + k, err := rd.ReadString() + if err != nil { + return err + } + nn, err := rd.ReadArrayLen() + if err != nil { + return err + } + cmd.val[k] = make([]interface{}, nn) + for j := 0; j < nn; j++ { + value, err := rd.ReadReply() + if err != nil { + return err + } + cmd.val[k][j] = value + } + } + + return nil +} + //------------------------------------------------------------------------------ type StringStructMapCmd struct { @@ -2643,7 +2715,7 @@ func (cmd *ZWithKeyCmd) Val() *ZWithKey { } func (cmd *ZWithKeyCmd) Result() (*ZWithKey, error) { - return cmd.Val(), cmd.Err() + return cmd.val, cmd.err } func (cmd *ZWithKeyCmd) String() string { @@ -2781,7 +2853,7 @@ func (cmd *ClusterSlotsCmd) Val() []ClusterSlot { } func (cmd *ClusterSlotsCmd) Result() ([]ClusterSlot, error) { - return cmd.Val(), cmd.Err() + return cmd.val, cmd.err } func (cmd *ClusterSlotsCmd) String() string { @@ -3241,7 +3313,7 @@ func (cmd *GeoPosCmd) Val() []*GeoPos { } func (cmd *GeoPosCmd) Result() ([]*GeoPos, error) { - return cmd.Val(), cmd.Err() + return cmd.val, cmd.err } func (cmd *GeoPosCmd) String() string { @@ -3322,7 +3394,7 @@ func (cmd *CommandsInfoCmd) Val() map[string]*CommandInfo { } func (cmd *CommandsInfoCmd) Result() (map[string]*CommandInfo, error) { - return cmd.Val(), cmd.Err() + return cmd.val, cmd.err } func (cmd *CommandsInfoCmd) String() string { @@ -3512,7 +3584,7 @@ func (cmd *SlowLogCmd) Val() []SlowLog { } func (cmd *SlowLogCmd) Result() ([]SlowLog, error) { - return cmd.Val(), cmd.Err() + return cmd.val, cmd.err } func (cmd *SlowLogCmd) String() string { @@ -3611,7 +3683,7 @@ func (cmd *MapStringInterfaceCmd) Val() map[string]interface{} { } func (cmd *MapStringInterfaceCmd) Result() (map[string]interface{}, error) { - return cmd.Val(), cmd.Err() + return cmd.val, cmd.err } func (cmd *MapStringInterfaceCmd) String() string { @@ -3675,7 +3747,7 @@ func (cmd *MapStringStringSliceCmd) Val() []map[string]string { } func (cmd *MapStringStringSliceCmd) Result() ([]map[string]string, error) { - return cmd.Val(), cmd.Err() + return cmd.val, cmd.err } func (cmd *MapStringStringSliceCmd) String() string { @@ -3711,6 +3783,71 @@ func (cmd *MapStringStringSliceCmd) readReply(rd *proto.Reader) error { return nil } +//----------------------------------------------------------------------- + +type MapStringInterfaceSliceCmd struct { + baseCmd + + val []map[string]interface{} +} + +var _ Cmder = (*MapStringInterfaceSliceCmd)(nil) + +func NewMapStringInterfaceSliceCmd(ctx context.Context, args ...interface{}) *MapStringInterfaceSliceCmd { + return &MapStringInterfaceSliceCmd{ + baseCmd: baseCmd{ + ctx: ctx, + args: args, + }, + } +} + +func (cmd *MapStringInterfaceSliceCmd) SetVal(val []map[string]interface{}) { + cmd.val = val +} + +func (cmd *MapStringInterfaceSliceCmd) Val() []map[string]interface{} { + return cmd.val +} + +func (cmd *MapStringInterfaceSliceCmd) Result() ([]map[string]interface{}, error) { + return cmd.val, cmd.err +} + +func (cmd *MapStringInterfaceSliceCmd) String() string { + return cmdString(cmd, cmd.val) +} + +func (cmd *MapStringInterfaceSliceCmd) readReply(rd *proto.Reader) error { + n, err := rd.ReadArrayLen() + if err != nil { + return err + } + + cmd.val = make([]map[string]interface{}, n) + for i := 0; i < n; i++ { + nn, err := rd.ReadMapLen() + if err != nil { + return err + } + cmd.val[i] = make(map[string]interface{}, nn) + for f := 0; f < nn; f++ { + k, err := rd.ReadString() + if err != nil { + return err + } + v, err := rd.ReadReply() + if err != nil { + if err != Nil { + return err + } + } + cmd.val[i][k] = v + } + } + return nil +} + //------------------------------------------------------------------------------ type KeyValuesCmd struct { @@ -4198,7 +4335,6 @@ func (cmd *FunctionStatsCmd) readDuration(rd *proto.Reader) (time.Duration, erro } func (cmd *FunctionStatsCmd) readCommand(rd *proto.Reader) ([]string, error) { - n, err := rd.ReadArrayLen() if err != nil { return nil, err @@ -4215,6 +4351,7 @@ func (cmd *FunctionStatsCmd) readCommand(rd *proto.Reader) ([]string, error) { return command, nil } + func (cmd *FunctionStatsCmd) readRunningScripts(rd *proto.Reader) ([]RunningScript, bool, error) { n, err := rd.ReadArrayLen() if err != nil { @@ -4524,7 +4661,7 @@ func (cmd *ClusterLinksCmd) Val() []ClusterLink { } func (cmd *ClusterLinksCmd) Result() ([]ClusterLink, error) { - return cmd.Val(), cmd.Err() + return cmd.val, cmd.err } func (cmd *ClusterLinksCmd) String() string { @@ -4626,7 +4763,7 @@ func (cmd *ClusterShardsCmd) Val() []ClusterShard { } func (cmd *ClusterShardsCmd) Result() ([]ClusterShard, error) { - return cmd.Val(), cmd.Err() + return cmd.val, cmd.err } func (cmd *ClusterShardsCmd) String() string { @@ -5099,7 +5236,7 @@ func (cmd *ACLLogCmd) Val() []*ACLLogEntry { } func (cmd *ACLLogCmd) Result() ([]*ACLLogEntry, error) { - return cmd.Val(), cmd.Err() + return cmd.val, cmd.err } func (cmd *ACLLogCmd) String() string { @@ -5166,3 +5303,181 @@ func (cmd *ACLLogCmd) readReply(rd *proto.Reader) error { return nil } + +// LibraryInfo holds the library info. +type LibraryInfo struct { + LibName *string + LibVer *string +} + +// WithLibraryName returns a valid LibraryInfo with library name only. +func WithLibraryName(libName string) LibraryInfo { + return LibraryInfo{LibName: &libName} +} + +// WithLibraryVersion returns a valid LibraryInfo with library version only. +func WithLibraryVersion(libVer string) LibraryInfo { + return LibraryInfo{LibVer: &libVer} +} + +// ------------------------------------------- + +type InfoCmd struct { + baseCmd + val map[string]map[string]string +} + +var _ Cmder = (*InfoCmd)(nil) + +func NewInfoCmd(ctx context.Context, args ...interface{}) *InfoCmd { + return &InfoCmd{ + baseCmd: baseCmd{ + ctx: ctx, + args: args, + }, + } +} + +func (cmd *InfoCmd) SetVal(val map[string]map[string]string) { + cmd.val = val +} + +func (cmd *InfoCmd) Val() map[string]map[string]string { + return cmd.val +} + +func (cmd *InfoCmd) Result() (map[string]map[string]string, error) { + return cmd.val, cmd.err +} + +func (cmd *InfoCmd) String() string { + return cmdString(cmd, cmd.val) +} + +func (cmd *InfoCmd) readReply(rd *proto.Reader) error { + val, err := rd.ReadString() + if err != nil { + return err + } + + section := "" + scanner := bufio.NewScanner(strings.NewReader(val)) + moduleRe := regexp.MustCompile(`module:name=(.+?),(.+)$`) + + for scanner.Scan() { + line := scanner.Text() + if strings.HasPrefix(line, "#") { + if cmd.val == nil { + cmd.val = make(map[string]map[string]string) + } + section = strings.TrimPrefix(line, "# ") + cmd.val[section] = make(map[string]string) + } else if line != "" { + if section == "Modules" { + kv := moduleRe.FindStringSubmatch(line) + if len(kv) == 3 { + cmd.val[section][kv[1]] = kv[2] + } + } else { + kv := strings.SplitN(line, ":", 2) + if len(kv) == 2 { + cmd.val[section][kv[0]] = kv[1] + } + } + } + } + + return nil +} + +func (cmd *InfoCmd) Item(section, key string) string { + if cmd.val == nil { + return "" + } else if cmd.val[section] == nil { + return "" + } else { + return cmd.val[section][key] + } +} + +type MonitorStatus int + +const ( + monitorStatusIdle MonitorStatus = iota + monitorStatusStart + monitorStatusStop +) + +type MonitorCmd struct { + baseCmd + ch chan string + status MonitorStatus + mu sync.Mutex +} + +func newMonitorCmd(ctx context.Context, ch chan string) *MonitorCmd { + return &MonitorCmd{ + baseCmd: baseCmd{ + ctx: ctx, + args: []interface{}{"monitor"}, + }, + ch: ch, + status: monitorStatusIdle, + mu: sync.Mutex{}, + } +} + +func (cmd *MonitorCmd) String() string { + return cmdString(cmd, nil) +} + +func (cmd *MonitorCmd) readReply(rd *proto.Reader) error { + ctx, cancel := context.WithCancel(cmd.ctx) + go func(ctx context.Context) { + for { + select { + case <-ctx.Done(): + return + default: + err := cmd.readMonitor(rd, cancel) + if err != nil { + cmd.err = err + return + } + } + } + }(ctx) + return nil +} + +func (cmd *MonitorCmd) readMonitor(rd *proto.Reader, cancel context.CancelFunc) error { + for { + cmd.mu.Lock() + st := cmd.status + cmd.mu.Unlock() + if pk, _ := rd.Peek(1); len(pk) != 0 && st == monitorStatusStart { + line, err := rd.ReadString() + if err != nil { + return err + } + cmd.ch <- line + } + if st == monitorStatusStop { + cancel() + break + } + } + return nil +} + +func (cmd *MonitorCmd) Start() { + cmd.mu.Lock() + defer cmd.mu.Unlock() + cmd.status = monitorStatusStart +} + +func (cmd *MonitorCmd) Stop() { + cmd.mu.Lock() + defer cmd.mu.Unlock() + cmd.status = monitorStatusStop +} diff --git a/vendor/github.com/redis/go-redis/v9/commands.go b/vendor/github.com/redis/go-redis/v9/commands.go index 34f4d2c22..db5959446 100644 --- a/vendor/github.com/redis/go-redis/v9/commands.go +++ b/vendor/github.com/redis/go-redis/v9/commands.go @@ -4,9 +4,11 @@ import ( "context" "encoding" "errors" + "fmt" "io" "net" "reflect" + "runtime" "strings" "time" @@ -170,234 +172,7 @@ type Cmdable interface { Echo(ctx context.Context, message interface{}) *StringCmd Ping(ctx context.Context) *StatusCmd Quit(ctx context.Context) *StatusCmd - Del(ctx context.Context, keys ...string) *IntCmd Unlink(ctx context.Context, keys ...string) *IntCmd - Dump(ctx context.Context, key string) *StringCmd - Exists(ctx context.Context, keys ...string) *IntCmd - Expire(ctx context.Context, key string, expiration time.Duration) *BoolCmd - ExpireAt(ctx context.Context, key string, tm time.Time) *BoolCmd - ExpireTime(ctx context.Context, key string) *DurationCmd - ExpireNX(ctx context.Context, key string, expiration time.Duration) *BoolCmd - ExpireXX(ctx context.Context, key string, expiration time.Duration) *BoolCmd - ExpireGT(ctx context.Context, key string, expiration time.Duration) *BoolCmd - ExpireLT(ctx context.Context, key string, expiration time.Duration) *BoolCmd - Keys(ctx context.Context, pattern string) *StringSliceCmd - Migrate(ctx context.Context, host, port, key string, db int, timeout time.Duration) *StatusCmd - Move(ctx context.Context, key string, db int) *BoolCmd - ObjectRefCount(ctx context.Context, key string) *IntCmd - ObjectEncoding(ctx context.Context, key string) *StringCmd - ObjectIdleTime(ctx context.Context, key string) *DurationCmd - Persist(ctx context.Context, key string) *BoolCmd - PExpire(ctx context.Context, key string, expiration time.Duration) *BoolCmd - PExpireAt(ctx context.Context, key string, tm time.Time) *BoolCmd - PExpireTime(ctx context.Context, key string) *DurationCmd - PTTL(ctx context.Context, key string) *DurationCmd - RandomKey(ctx context.Context) *StringCmd - Rename(ctx context.Context, key, newkey string) *StatusCmd - RenameNX(ctx context.Context, key, newkey string) *BoolCmd - Restore(ctx context.Context, key string, ttl time.Duration, value string) *StatusCmd - RestoreReplace(ctx context.Context, key string, ttl time.Duration, value string) *StatusCmd - Sort(ctx context.Context, key string, sort *Sort) *StringSliceCmd - SortRO(ctx context.Context, key string, sort *Sort) *StringSliceCmd - SortStore(ctx context.Context, key, store string, sort *Sort) *IntCmd - SortInterfaces(ctx context.Context, key string, sort *Sort) *SliceCmd - Touch(ctx context.Context, keys ...string) *IntCmd - TTL(ctx context.Context, key string) *DurationCmd - Type(ctx context.Context, key string) *StatusCmd - Append(ctx context.Context, key, value string) *IntCmd - Decr(ctx context.Context, key string) *IntCmd - DecrBy(ctx context.Context, key string, decrement int64) *IntCmd - Get(ctx context.Context, key string) *StringCmd - GetRange(ctx context.Context, key string, start, end int64) *StringCmd - GetSet(ctx context.Context, key string, value interface{}) *StringCmd - GetEx(ctx context.Context, key string, expiration time.Duration) *StringCmd - GetDel(ctx context.Context, key string) *StringCmd - Incr(ctx context.Context, key string) *IntCmd - IncrBy(ctx context.Context, key string, value int64) *IntCmd - IncrByFloat(ctx context.Context, key string, value float64) *FloatCmd - MGet(ctx context.Context, keys ...string) *SliceCmd - MSet(ctx context.Context, values ...interface{}) *StatusCmd - MSetNX(ctx context.Context, values ...interface{}) *BoolCmd - Set(ctx context.Context, key string, value interface{}, expiration time.Duration) *StatusCmd - SetArgs(ctx context.Context, key string, value interface{}, a SetArgs) *StatusCmd - SetEx(ctx context.Context, key string, value interface{}, expiration time.Duration) *StatusCmd - SetNX(ctx context.Context, key string, value interface{}, expiration time.Duration) *BoolCmd - SetXX(ctx context.Context, key string, value interface{}, expiration time.Duration) *BoolCmd - SetRange(ctx context.Context, key string, offset int64, value string) *IntCmd - StrLen(ctx context.Context, key string) *IntCmd - Copy(ctx context.Context, sourceKey string, destKey string, db int, replace bool) *IntCmd - - GetBit(ctx context.Context, key string, offset int64) *IntCmd - SetBit(ctx context.Context, key string, offset int64, value int) *IntCmd - BitCount(ctx context.Context, key string, bitCount *BitCount) *IntCmd - BitOpAnd(ctx context.Context, destKey string, keys ...string) *IntCmd - BitOpOr(ctx context.Context, destKey string, keys ...string) *IntCmd - BitOpXor(ctx context.Context, destKey string, keys ...string) *IntCmd - BitOpNot(ctx context.Context, destKey string, key string) *IntCmd - BitPos(ctx context.Context, key string, bit int64, pos ...int64) *IntCmd - BitPosSpan(ctx context.Context, key string, bit int8, start, end int64, span string) *IntCmd - BitField(ctx context.Context, key string, args ...interface{}) *IntSliceCmd - - Scan(ctx context.Context, cursor uint64, match string, count int64) *ScanCmd - ScanType(ctx context.Context, cursor uint64, match string, count int64, keyType string) *ScanCmd - SScan(ctx context.Context, key string, cursor uint64, match string, count int64) *ScanCmd - HScan(ctx context.Context, key string, cursor uint64, match string, count int64) *ScanCmd - ZScan(ctx context.Context, key string, cursor uint64, match string, count int64) *ScanCmd - - HDel(ctx context.Context, key string, fields ...string) *IntCmd - HExists(ctx context.Context, key, field string) *BoolCmd - HGet(ctx context.Context, key, field string) *StringCmd - HGetAll(ctx context.Context, key string) *MapStringStringCmd - HIncrBy(ctx context.Context, key, field string, incr int64) *IntCmd - HIncrByFloat(ctx context.Context, key, field string, incr float64) *FloatCmd - HKeys(ctx context.Context, key string) *StringSliceCmd - HLen(ctx context.Context, key string) *IntCmd - HMGet(ctx context.Context, key string, fields ...string) *SliceCmd - HSet(ctx context.Context, key string, values ...interface{}) *IntCmd - HMSet(ctx context.Context, key string, values ...interface{}) *BoolCmd - HSetNX(ctx context.Context, key, field string, value interface{}) *BoolCmd - HVals(ctx context.Context, key string) *StringSliceCmd - HRandField(ctx context.Context, key string, count int) *StringSliceCmd - HRandFieldWithValues(ctx context.Context, key string, count int) *KeyValueSliceCmd - - BLPop(ctx context.Context, timeout time.Duration, keys ...string) *StringSliceCmd - BLMPop(ctx context.Context, timeout time.Duration, direction string, count int64, keys ...string) *KeyValuesCmd - BRPop(ctx context.Context, timeout time.Duration, keys ...string) *StringSliceCmd - BRPopLPush(ctx context.Context, source, destination string, timeout time.Duration) *StringCmd - LCS(ctx context.Context, q *LCSQuery) *LCSCmd - LIndex(ctx context.Context, key string, index int64) *StringCmd - LInsert(ctx context.Context, key, op string, pivot, value interface{}) *IntCmd - LInsertBefore(ctx context.Context, key string, pivot, value interface{}) *IntCmd - LInsertAfter(ctx context.Context, key string, pivot, value interface{}) *IntCmd - LLen(ctx context.Context, key string) *IntCmd - LMPop(ctx context.Context, direction string, count int64, keys ...string) *KeyValuesCmd - LPop(ctx context.Context, key string) *StringCmd - LPopCount(ctx context.Context, key string, count int) *StringSliceCmd - LPos(ctx context.Context, key string, value string, args LPosArgs) *IntCmd - LPosCount(ctx context.Context, key string, value string, count int64, args LPosArgs) *IntSliceCmd - LPush(ctx context.Context, key string, values ...interface{}) *IntCmd - LPushX(ctx context.Context, key string, values ...interface{}) *IntCmd - LRange(ctx context.Context, key string, start, stop int64) *StringSliceCmd - LRem(ctx context.Context, key string, count int64, value interface{}) *IntCmd - LSet(ctx context.Context, key string, index int64, value interface{}) *StatusCmd - LTrim(ctx context.Context, key string, start, stop int64) *StatusCmd - RPop(ctx context.Context, key string) *StringCmd - RPopCount(ctx context.Context, key string, count int) *StringSliceCmd - RPopLPush(ctx context.Context, source, destination string) *StringCmd - RPush(ctx context.Context, key string, values ...interface{}) *IntCmd - RPushX(ctx context.Context, key string, values ...interface{}) *IntCmd - LMove(ctx context.Context, source, destination, srcpos, destpos string) *StringCmd - BLMove(ctx context.Context, source, destination, srcpos, destpos string, timeout time.Duration) *StringCmd - - SAdd(ctx context.Context, key string, members ...interface{}) *IntCmd - SCard(ctx context.Context, key string) *IntCmd - SDiff(ctx context.Context, keys ...string) *StringSliceCmd - SDiffStore(ctx context.Context, destination string, keys ...string) *IntCmd - SInter(ctx context.Context, keys ...string) *StringSliceCmd - SInterCard(ctx context.Context, limit int64, keys ...string) *IntCmd - SInterStore(ctx context.Context, destination string, keys ...string) *IntCmd - SIsMember(ctx context.Context, key string, member interface{}) *BoolCmd - SMIsMember(ctx context.Context, key string, members ...interface{}) *BoolSliceCmd - SMembers(ctx context.Context, key string) *StringSliceCmd - SMembersMap(ctx context.Context, key string) *StringStructMapCmd - SMove(ctx context.Context, source, destination string, member interface{}) *BoolCmd - SPop(ctx context.Context, key string) *StringCmd - SPopN(ctx context.Context, key string, count int64) *StringSliceCmd - SRandMember(ctx context.Context, key string) *StringCmd - SRandMemberN(ctx context.Context, key string, count int64) *StringSliceCmd - SRem(ctx context.Context, key string, members ...interface{}) *IntCmd - SUnion(ctx context.Context, keys ...string) *StringSliceCmd - SUnionStore(ctx context.Context, destination string, keys ...string) *IntCmd - - XAdd(ctx context.Context, a *XAddArgs) *StringCmd - XDel(ctx context.Context, stream string, ids ...string) *IntCmd - XLen(ctx context.Context, stream string) *IntCmd - XRange(ctx context.Context, stream, start, stop string) *XMessageSliceCmd - XRangeN(ctx context.Context, stream, start, stop string, count int64) *XMessageSliceCmd - XRevRange(ctx context.Context, stream string, start, stop string) *XMessageSliceCmd - XRevRangeN(ctx context.Context, stream string, start, stop string, count int64) *XMessageSliceCmd - XRead(ctx context.Context, a *XReadArgs) *XStreamSliceCmd - XReadStreams(ctx context.Context, streams ...string) *XStreamSliceCmd - XGroupCreate(ctx context.Context, stream, group, start string) *StatusCmd - XGroupCreateMkStream(ctx context.Context, stream, group, start string) *StatusCmd - XGroupSetID(ctx context.Context, stream, group, start string) *StatusCmd - XGroupDestroy(ctx context.Context, stream, group string) *IntCmd - XGroupCreateConsumer(ctx context.Context, stream, group, consumer string) *IntCmd - XGroupDelConsumer(ctx context.Context, stream, group, consumer string) *IntCmd - XReadGroup(ctx context.Context, a *XReadGroupArgs) *XStreamSliceCmd - XAck(ctx context.Context, stream, group string, ids ...string) *IntCmd - XPending(ctx context.Context, stream, group string) *XPendingCmd - XPendingExt(ctx context.Context, a *XPendingExtArgs) *XPendingExtCmd - XClaim(ctx context.Context, a *XClaimArgs) *XMessageSliceCmd - XClaimJustID(ctx context.Context, a *XClaimArgs) *StringSliceCmd - XAutoClaim(ctx context.Context, a *XAutoClaimArgs) *XAutoClaimCmd - XAutoClaimJustID(ctx context.Context, a *XAutoClaimArgs) *XAutoClaimJustIDCmd - XTrimMaxLen(ctx context.Context, key string, maxLen int64) *IntCmd - XTrimMaxLenApprox(ctx context.Context, key string, maxLen, limit int64) *IntCmd - XTrimMinID(ctx context.Context, key string, minID string) *IntCmd - XTrimMinIDApprox(ctx context.Context, key string, minID string, limit int64) *IntCmd - XInfoGroups(ctx context.Context, key string) *XInfoGroupsCmd - XInfoStream(ctx context.Context, key string) *XInfoStreamCmd - XInfoStreamFull(ctx context.Context, key string, count int) *XInfoStreamFullCmd - XInfoConsumers(ctx context.Context, key string, group string) *XInfoConsumersCmd - - BZPopMax(ctx context.Context, timeout time.Duration, keys ...string) *ZWithKeyCmd - BZPopMin(ctx context.Context, timeout time.Duration, keys ...string) *ZWithKeyCmd - BZMPop(ctx context.Context, timeout time.Duration, order string, count int64, keys ...string) *ZSliceWithKeyCmd - - ZAdd(ctx context.Context, key string, members ...Z) *IntCmd - ZAddLT(ctx context.Context, key string, members ...Z) *IntCmd - ZAddGT(ctx context.Context, key string, members ...Z) *IntCmd - ZAddNX(ctx context.Context, key string, members ...Z) *IntCmd - ZAddXX(ctx context.Context, key string, members ...Z) *IntCmd - ZAddArgs(ctx context.Context, key string, args ZAddArgs) *IntCmd - ZAddArgsIncr(ctx context.Context, key string, args ZAddArgs) *FloatCmd - ZCard(ctx context.Context, key string) *IntCmd - ZCount(ctx context.Context, key, min, max string) *IntCmd - ZLexCount(ctx context.Context, key, min, max string) *IntCmd - ZIncrBy(ctx context.Context, key string, increment float64, member string) *FloatCmd - ZInter(ctx context.Context, store *ZStore) *StringSliceCmd - ZInterWithScores(ctx context.Context, store *ZStore) *ZSliceCmd - ZInterCard(ctx context.Context, limit int64, keys ...string) *IntCmd - ZInterStore(ctx context.Context, destination string, store *ZStore) *IntCmd - ZMPop(ctx context.Context, order string, count int64, keys ...string) *ZSliceWithKeyCmd - ZMScore(ctx context.Context, key string, members ...string) *FloatSliceCmd - ZPopMax(ctx context.Context, key string, count ...int64) *ZSliceCmd - ZPopMin(ctx context.Context, key string, count ...int64) *ZSliceCmd - ZRange(ctx context.Context, key string, start, stop int64) *StringSliceCmd - ZRangeWithScores(ctx context.Context, key string, start, stop int64) *ZSliceCmd - ZRangeByScore(ctx context.Context, key string, opt *ZRangeBy) *StringSliceCmd - ZRangeByLex(ctx context.Context, key string, opt *ZRangeBy) *StringSliceCmd - ZRangeByScoreWithScores(ctx context.Context, key string, opt *ZRangeBy) *ZSliceCmd - ZRangeArgs(ctx context.Context, z ZRangeArgs) *StringSliceCmd - ZRangeArgsWithScores(ctx context.Context, z ZRangeArgs) *ZSliceCmd - ZRangeStore(ctx context.Context, dst string, z ZRangeArgs) *IntCmd - ZRank(ctx context.Context, key, member string) *IntCmd - ZRankWithScore(ctx context.Context, key, member string) *RankWithScoreCmd - ZRem(ctx context.Context, key string, members ...interface{}) *IntCmd - ZRemRangeByRank(ctx context.Context, key string, start, stop int64) *IntCmd - ZRemRangeByScore(ctx context.Context, key, min, max string) *IntCmd - ZRemRangeByLex(ctx context.Context, key, min, max string) *IntCmd - ZRevRange(ctx context.Context, key string, start, stop int64) *StringSliceCmd - ZRevRangeWithScores(ctx context.Context, key string, start, stop int64) *ZSliceCmd - ZRevRangeByScore(ctx context.Context, key string, opt *ZRangeBy) *StringSliceCmd - ZRevRangeByLex(ctx context.Context, key string, opt *ZRangeBy) *StringSliceCmd - ZRevRangeByScoreWithScores(ctx context.Context, key string, opt *ZRangeBy) *ZSliceCmd - ZRevRank(ctx context.Context, key, member string) *IntCmd - ZRevRankWithScore(ctx context.Context, key, member string) *RankWithScoreCmd - ZScore(ctx context.Context, key, member string) *FloatCmd - ZUnionStore(ctx context.Context, dest string, store *ZStore) *IntCmd - ZRandMember(ctx context.Context, key string, count int) *StringSliceCmd - ZRandMemberWithScores(ctx context.Context, key string, count int) *ZSliceCmd - ZUnion(ctx context.Context, store ZStore) *StringSliceCmd - ZUnionWithScores(ctx context.Context, store ZStore) *ZSliceCmd - ZDiff(ctx context.Context, keys ...string) *StringSliceCmd - ZDiffWithScores(ctx context.Context, keys ...string) *ZSliceCmd - ZDiffStore(ctx context.Context, destination string, keys ...string) *IntCmd - - PFAdd(ctx context.Context, key string, els ...interface{}) *IntCmd - PFCount(ctx context.Context, keys ...string) *IntCmd - PFMerge(ctx context.Context, dest string, keys ...string) *StatusCmd BgRewriteAOF(ctx context.Context) *StatusCmd BgSave(ctx context.Context) *StatusCmd @@ -429,81 +204,28 @@ type Cmdable interface { SlowLogGet(ctx context.Context, num int64) *SlowLogCmd Time(ctx context.Context) *TimeCmd DebugObject(ctx context.Context, key string) *StringCmd - ReadOnly(ctx context.Context) *StatusCmd - ReadWrite(ctx context.Context) *StatusCmd MemoryUsage(ctx context.Context, key string, samples ...int) *IntCmd - Eval(ctx context.Context, script string, keys []string, args ...interface{}) *Cmd - EvalSha(ctx context.Context, sha1 string, keys []string, args ...interface{}) *Cmd - EvalRO(ctx context.Context, script string, keys []string, args ...interface{}) *Cmd - EvalShaRO(ctx context.Context, sha1 string, keys []string, args ...interface{}) *Cmd - ScriptExists(ctx context.Context, hashes ...string) *BoolSliceCmd - ScriptFlush(ctx context.Context) *StatusCmd - ScriptKill(ctx context.Context) *StatusCmd - ScriptLoad(ctx context.Context, script string) *StringCmd - - FunctionLoad(ctx context.Context, code string) *StringCmd - FunctionLoadReplace(ctx context.Context, code string) *StringCmd - FunctionDelete(ctx context.Context, libName string) *StringCmd - FunctionFlush(ctx context.Context) *StringCmd - FunctionKill(ctx context.Context) *StringCmd - FunctionFlushAsync(ctx context.Context) *StringCmd - FunctionList(ctx context.Context, q FunctionListQuery) *FunctionListCmd - FunctionDump(ctx context.Context) *StringCmd - FunctionRestore(ctx context.Context, libDump string) *StringCmd - FunctionStats(ctx context.Context) *FunctionStatsCmd - FCall(ctx context.Context, function string, keys []string, args ...interface{}) *Cmd - FCallRo(ctx context.Context, function string, keys []string, args ...interface{}) *Cmd - FCallRO(ctx context.Context, function string, keys []string, args ...interface{}) *Cmd - - Publish(ctx context.Context, channel string, message interface{}) *IntCmd - SPublish(ctx context.Context, channel string, message interface{}) *IntCmd - PubSubChannels(ctx context.Context, pattern string) *StringSliceCmd - PubSubNumSub(ctx context.Context, channels ...string) *MapStringIntCmd - PubSubNumPat(ctx context.Context) *IntCmd - PubSubShardChannels(ctx context.Context, pattern string) *StringSliceCmd - PubSubShardNumSub(ctx context.Context, channels ...string) *MapStringIntCmd - - ClusterMyShardID(ctx context.Context) *StringCmd - ClusterSlots(ctx context.Context) *ClusterSlotsCmd - ClusterShards(ctx context.Context) *ClusterShardsCmd - ClusterLinks(ctx context.Context) *ClusterLinksCmd - ClusterNodes(ctx context.Context) *StringCmd - ClusterMeet(ctx context.Context, host, port string) *StatusCmd - ClusterForget(ctx context.Context, nodeID string) *StatusCmd - ClusterReplicate(ctx context.Context, nodeID string) *StatusCmd - ClusterResetSoft(ctx context.Context) *StatusCmd - ClusterResetHard(ctx context.Context) *StatusCmd - ClusterInfo(ctx context.Context) *StringCmd - ClusterKeySlot(ctx context.Context, key string) *IntCmd - ClusterGetKeysInSlot(ctx context.Context, slot int, count int) *StringSliceCmd - ClusterCountFailureReports(ctx context.Context, nodeID string) *IntCmd - ClusterCountKeysInSlot(ctx context.Context, slot int) *IntCmd - ClusterDelSlots(ctx context.Context, slots ...int) *StatusCmd - ClusterDelSlotsRange(ctx context.Context, min, max int) *StatusCmd - ClusterSaveConfig(ctx context.Context) *StatusCmd - ClusterSlaves(ctx context.Context, nodeID string) *StringSliceCmd - ClusterFailover(ctx context.Context) *StatusCmd - ClusterAddSlots(ctx context.Context, slots ...int) *StatusCmd - ClusterAddSlotsRange(ctx context.Context, min, max int) *StatusCmd - - GeoAdd(ctx context.Context, key string, geoLocation ...*GeoLocation) *IntCmd - GeoPos(ctx context.Context, key string, members ...string) *GeoPosCmd - GeoRadius(ctx context.Context, key string, longitude, latitude float64, query *GeoRadiusQuery) *GeoLocationCmd - GeoRadiusStore(ctx context.Context, key string, longitude, latitude float64, query *GeoRadiusQuery) *IntCmd - GeoRadiusByMember(ctx context.Context, key, member string, query *GeoRadiusQuery) *GeoLocationCmd - GeoRadiusByMemberStore(ctx context.Context, key, member string, query *GeoRadiusQuery) *IntCmd - GeoSearch(ctx context.Context, key string, q *GeoSearchQuery) *StringSliceCmd - GeoSearchLocation(ctx context.Context, key string, q *GeoSearchLocationQuery) *GeoSearchLocationCmd - GeoSearchStore(ctx context.Context, key, store string, q *GeoSearchStoreQuery) *IntCmd - GeoDist(ctx context.Context, key string, member1, member2, unit string) *FloatCmd - GeoHash(ctx context.Context, key string, members ...string) *StringSliceCmd - - ACLDryRun(ctx context.Context, username string, command ...interface{}) *StringCmd - ACLLog(ctx context.Context, count int64) *ACLLogCmd - ACLLogReset(ctx context.Context) *StatusCmd - ModuleLoadex(ctx context.Context, conf *ModuleLoadexConfig) *StringCmd + + ACLCmdable + BitMapCmdable + ClusterCmdable + GearsCmdable + GenericCmdable + GeoCmdable + HashCmdable + HyperLogLogCmdable + ListCmdable + ProbabilisticCmdable + PubSubCmdable + ScriptingFunctionsCmdable + SetCmdable + SortedSetCmdable + StringCmdable + StreamCmdable + TimeseriesCmdable + JSONCmdable } type StatefulCmdable interface { @@ -513,6 +235,7 @@ type StatefulCmdable interface { Select(ctx context.Context, index int) *StatusCmd SwapDB(ctx context.Context, index1, index2 int) *StatusCmd ClientSetName(ctx context.Context, name string) *BoolCmd + ClientSetInfo(ctx context.Context, info LibraryInfo) *StatusCmd Hello(ctx context.Context, ver int, username, password, clientName string) *MapStringInterfaceCmd } @@ -551,6 +274,13 @@ func (c cmdable) Wait(ctx context.Context, numSlaves int, timeout time.Duration) return cmd } +func (c cmdable) WaitAOF(ctx context.Context, numLocal, numSlaves int, timeout time.Duration) *IntCmd { + cmd := NewIntCmd(ctx, "waitAOF", numLocal, numSlaves, int(timeout/time.Millisecond)) + cmd.setReadTimeout(timeout) + _ = c(ctx, cmd) + return cmd +} + func (c statefulCmdable) Select(ctx context.Context, index int) *StatusCmd { cmd := NewStatusCmd(ctx, "select", index) _ = c(ctx, cmd) @@ -570,9 +300,40 @@ func (c statefulCmdable) ClientSetName(ctx context.Context, name string) *BoolCm return cmd } +// ClientSetInfo sends a CLIENT SETINFO command with the provided info. +func (c statefulCmdable) ClientSetInfo(ctx context.Context, info LibraryInfo) *StatusCmd { + err := info.Validate() + if err != nil { + panic(err.Error()) + } + + var cmd *StatusCmd + if info.LibName != nil { + libName := fmt.Sprintf("go-redis(%s,%s)", *info.LibName, internal.ReplaceSpaces(runtime.Version())) + cmd = NewStatusCmd(ctx, "client", "setinfo", "LIB-NAME", libName) + } else { + cmd = NewStatusCmd(ctx, "client", "setinfo", "LIB-VER", *info.LibVer) + } + + _ = c(ctx, cmd) + return cmd +} + +// Validate checks if only one field in the struct is non-nil. +func (info LibraryInfo) Validate() error { + if info.LibName != nil && info.LibVer != nil { + return errors.New("both LibName and LibVer cannot be set at the same time") + } + if info.LibName == nil && info.LibVer == nil { + return errors.New("at least one of LibName and LibVer should be set") + } + return nil +} + // Hello Set the resp protocol used. func (c statefulCmdable) Hello(ctx context.Context, - ver int, username, password, clientName string) *MapStringInterfaceCmd { + ver int, username, password, clientName string, +) *MapStringInterfaceCmd { args := make([]interface{}, 0, 7) args = append(args, "hello", ver) if password != "" { @@ -665,3303 +426,293 @@ func (c cmdable) Quit(_ context.Context) *StatusCmd { panic("not implemented") } -func (c cmdable) Del(ctx context.Context, keys ...string) *IntCmd { - args := make([]interface{}, 1+len(keys)) - args[0] = "del" - for i, key := range keys { - args[1+i] = key - } - cmd := NewIntCmd(ctx, args...) +//------------------------------------------------------------------------------ + +func (c cmdable) BgRewriteAOF(ctx context.Context) *StatusCmd { + cmd := NewStatusCmd(ctx, "bgrewriteaof") _ = c(ctx, cmd) return cmd } -func (c cmdable) Unlink(ctx context.Context, keys ...string) *IntCmd { - args := make([]interface{}, 1+len(keys)) - args[0] = "unlink" - for i, key := range keys { - args[1+i] = key - } - cmd := NewIntCmd(ctx, args...) +func (c cmdable) BgSave(ctx context.Context) *StatusCmd { + cmd := NewStatusCmd(ctx, "bgsave") _ = c(ctx, cmd) return cmd } -func (c cmdable) Dump(ctx context.Context, key string) *StringCmd { - cmd := NewStringCmd(ctx, "dump", key) +func (c cmdable) ClientKill(ctx context.Context, ipPort string) *StatusCmd { + cmd := NewStatusCmd(ctx, "client", "kill", ipPort) _ = c(ctx, cmd) return cmd } -func (c cmdable) Exists(ctx context.Context, keys ...string) *IntCmd { - args := make([]interface{}, 1+len(keys)) - args[0] = "exists" +// ClientKillByFilter is new style syntax, while the ClientKill is old +// +// CLIENT KILL