From b193a18f6dd448359b8fb71d6dd060415b0d12e7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 24 Feb 2023 15:12:58 -0800 Subject: [PATCH 01/84] Bump github.com/aws/aws-sdk-go from 1.44.195 to 1.44.205 (#235) * Bump github.com/aws/aws-sdk-go from 1.44.195 to 1.44.205 Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.44.195 to 1.44.205. - [Release notes](https://github.com/aws/aws-sdk-go/releases) - [Commits](https://github.com/aws/aws-sdk-go/compare/v1.44.195...v1.44.205) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Update changelog Signed-off-by: dependabot[bot] --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] --- CHANGELOG.md | 5 +++-- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e9ea23..76c36a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,8 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.9 to 1.18.12 - Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.8 to 1.18.10 - Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.17.10 to 1.18.9 -- Bumps `github.com/aws/aws-sdk-go` from 1.44.185 to 1.44.195 +- Bumps `github.com/aws/aws-sdk-go` from 1.44.195 to 1.44.205 +- Bumps `github.com/aws/aws-sdk-go` from 1.44.185 to 1.44.205 - Bumps `github.com/aws/aws-sdk-go` from 1.44.180 to 1.44.195 - Bumps `github.com/aws/aws-sdk-go` from 1.44.176 to 1.44.185 - Bumps `github.com/aws/aws-sdk-go` from 1.44.132 to 1.44.180 @@ -37,4 +38,4 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Security -[Unreleased]: https://github.com/opensearch-project/opensearch-go/compare/2.1...HEAD +[Unreleased]: https://github.com/opensearch-project/opensearch-go/compare/2.1...HEAD \ No newline at end of file diff --git a/go.mod b/go.mod index e279b7b..6d1967d 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/opensearch-project/opensearch-go/v2 go 1.15 require ( - github.com/aws/aws-sdk-go v1.44.195 + github.com/aws/aws-sdk-go v1.44.205 github.com/aws/aws-sdk-go-v2 v1.17.4 github.com/aws/aws-sdk-go-v2/config v1.18.12 github.com/stretchr/testify v1.8.1 diff --git a/go.sum b/go.sum index f78cdd8..8bf4b57 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/aws/aws-sdk-go v1.44.195 h1:d5xFL0N83Fpsq2LFiHgtBUHknCRUPGHdOlCWt/jtOJs= -github.com/aws/aws-sdk-go v1.44.195/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= +github.com/aws/aws-sdk-go v1.44.205 h1:q23NJXgLPIuBMn4zaluWWz57HPP5z7Ut8ZtK1D3N9bs= +github.com/aws/aws-sdk-go v1.44.205/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go-v2 v1.17.4 h1:wyC6p9Yfq6V2y98wfDsj6OnNQa4w2BLGCLIxzNhwOGY= github.com/aws/aws-sdk-go-v2 v1.17.4/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= github.com/aws/aws-sdk-go-v2/config v1.18.12 h1:fKs/I4wccmfrNRO9rdrbMO1NgLxct6H9rNMiPdBxHWw= From 90a636480e1f02477832a923f4bfc12b4015ee9d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 24 Feb 2023 15:37:17 -0800 Subject: [PATCH 02/84] Bump github.com/aws/aws-sdk-go-v2 from 1.17.4 to 1.17.5 (#234) * Bump github.com/aws/aws-sdk-go-v2 from 1.17.4 to 1.17.5 Bumps [github.com/aws/aws-sdk-go-v2](https://github.com/aws/aws-sdk-go-v2) from 1.17.4 to 1.17.5. - [Release notes](https://github.com/aws/aws-sdk-go-v2/releases) - [Changelog](https://github.com/aws/aws-sdk-go-v2/blob/main/CHANGELOG.md) - [Commits](https://github.com/aws/aws-sdk-go-v2/compare/v1.17.4...v1.17.5) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go-v2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Update changelog Signed-off-by: dependabot[bot] --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] --- CHANGELOG.md | 2 +- go.mod | 2 +- go.sum | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 76c36a3..501cbfe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ 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` from 1.17.1 to 1.17.5 - Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.10 to 1.18.12 - Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.9 to 1.18.12 - Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.8 to 1.18.10 diff --git a/go.mod b/go.mod index 6d1967d..36e7dd3 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.15 require ( github.com/aws/aws-sdk-go v1.44.205 - github.com/aws/aws-sdk-go-v2 v1.17.4 + github.com/aws/aws-sdk-go-v2 v1.17.5 github.com/aws/aws-sdk-go-v2/config v1.18.12 github.com/stretchr/testify v1.8.1 ) diff --git a/go.sum b/go.sum index 8bf4b57..b27d196 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,8 @@ github.com/aws/aws-sdk-go v1.44.205 h1:q23NJXgLPIuBMn4zaluWWz57HPP5z7Ut8ZtK1D3N9bs= github.com/aws/aws-sdk-go v1.44.205/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= -github.com/aws/aws-sdk-go-v2 v1.17.4 h1:wyC6p9Yfq6V2y98wfDsj6OnNQa4w2BLGCLIxzNhwOGY= github.com/aws/aws-sdk-go-v2 v1.17.4/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= +github.com/aws/aws-sdk-go-v2 v1.17.5 h1:TzCUW1Nq4H8Xscph5M/skINUitxM5UBAyvm2s7XBzL4= +github.com/aws/aws-sdk-go-v2 v1.17.5/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= github.com/aws/aws-sdk-go-v2/config v1.18.12 h1:fKs/I4wccmfrNRO9rdrbMO1NgLxct6H9rNMiPdBxHWw= github.com/aws/aws-sdk-go-v2/config v1.18.12/go.mod h1:J36fOhj1LQBr+O4hJCiT8FwVvieeoSGOtPuvhKlsNu8= github.com/aws/aws-sdk-go-v2/credentials v1.13.12 h1:Cb+HhuEnV19zHRaYYVglwvdHGMJWbdsyP4oHhw04xws= From 84ac518a48dc73b89454a2f9be73eaa7b7ff5300 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 24 Feb 2023 15:44:39 -0800 Subject: [PATCH 03/84] Bump golang.org/x/crypto in /internal/build (#239) Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.0.0-20210921155107-089bfa567519 to 0.1.0. - [Release notes](https://github.com/golang/crypto/releases) - [Commits](https://github.com/golang/crypto/commits/v0.1.0) --- updated-dependencies: - dependency-name: golang.org/x/crypto dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- internal/build/go.mod | 2 +- internal/build/go.sum | 29 +++++++++++++++-------------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/internal/build/go.mod b/internal/build/go.mod index bed96b5..33f9a80 100644 --- a/internal/build/go.mod +++ b/internal/build/go.mod @@ -9,7 +9,7 @@ require ( github.com/kr/pretty v0.1.0 // indirect github.com/opensearch-project/opensearch-go/v2 v2.2.0 github.com/spf13/cobra v1.6.1 - golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 + golang.org/x/crypto v0.1.0 golang.org/x/tools v0.1.12 gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect gopkg.in/yaml.v2 v2.4.0 diff --git a/internal/build/go.sum b/internal/build/go.sum index c15c19d..f6348f6 100644 --- a/internal/build/go.sum +++ b/internal/build/go.sum @@ -7,19 +7,19 @@ github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721/go.mod h1:QO9JBo github.com/alecthomas/kong v0.2.4/go.mod h1:kQOmtJgV+Lb4aj+I2LEn40cbtawdWJ9Y8QLq+lElKxE= github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897 h1:p9Sln00KOTlrYkxI1zYWl1QLnEqAqEARBEYa8FQnQcY= github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897/go.mod h1:xTS7Pm1pD1mvyM075QCDSRqH6qRLXylzS24ZTpRiSzQ= -github.com/aws/aws-sdk-go v1.44.132/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= -github.com/aws/aws-sdk-go-v2 v1.17.1/go.mod h1:JLnGeGONAyi2lWXI1p0PCIOIy333JMVK1U7Hf0aRFLw= -github.com/aws/aws-sdk-go-v2/config v1.17.10/go.mod h1:/4np+UiJJKpWHN7Q+LZvqXYgyjgeXm5+lLfDI6TPZao= -github.com/aws/aws-sdk-go-v2/credentials v1.12.23/go.mod h1:0awX9iRr/+UO7OwRQFpV1hNtXxOVuehpjVEzrIAYNcA= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.19/go.mod h1:VihW95zQpeKQWVPGkwT+2+WJNQV8UXFfMTWdU6VErL8= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.25/go.mod h1:Zb29PYkf42vVYQY6pvSyJCJcFHlPIiY+YKdPtwnvMkY= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.19/go.mod h1:6Q0546uHDp421okhmmGfbxzq2hBqbXFNpi4k+Q1JnQA= -github.com/aws/aws-sdk-go-v2/internal/ini v1.3.26/go.mod h1:Y2OJ+P+MC1u1VKnavT+PshiEuGPyh/7DqxoDNij4/bg= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.19/go.mod h1:02CP6iuYP+IVnBX5HULVdSAku/85eHB2Y9EsFhrkEwU= -github.com/aws/aws-sdk-go-v2/service/sso v1.11.25/go.mod h1:IARHuzTXmj1C0KS35vboR0FeJ89OkEy1M9mWbK2ifCI= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.13.8/go.mod h1:er2JHN+kBY6FcMfcBBKNGCT3CarImmdFzishsqBmSRI= -github.com/aws/aws-sdk-go-v2/service/sts v1.17.1/go.mod h1:bXcN3koeVYiJcdDU89n3kCYILob7Y34AeLopUbZgLT4= -github.com/aws/smithy-go v1.13.4/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= +github.com/aws/aws-sdk-go v1.44.205/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= +github.com/aws/aws-sdk-go-v2 v1.17.4/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= +github.com/aws/aws-sdk-go-v2/config v1.18.12/go.mod h1:J36fOhj1LQBr+O4hJCiT8FwVvieeoSGOtPuvhKlsNu8= +github.com/aws/aws-sdk-go-v2/credentials v1.13.12/go.mod h1:37HG2MBroXK3jXfxVGtbM2J48ra2+Ltu+tmwr/jO0KA= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.22/go.mod h1:YGSIJyQ6D6FjKMQh16hVFSIUD54L4F7zTGePqYMYYJU= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.28/go.mod h1:3lwChorpIM/BhImY/hy+Z6jekmN92cXGPI1QJasVPYY= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.22/go.mod h1:EqK7gVrIGAHyZItrD1D8B0ilgwMD1GiWAmbU4u/JHNk= +github.com/aws/aws-sdk-go-v2/internal/ini v1.3.29/go.mod h1:TwuqRBGzxjQJIwH16/fOZodwXt2Zxa9/cwJC5ke4j7s= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.22/go.mod h1:xt0Au8yPIwYXf/GYPy/vl4K3CgwhfQMYbrH7DlUUIws= +github.com/aws/aws-sdk-go-v2/service/sso v1.12.1/go.mod h1:IgV8l3sj22nQDd5qcAGY0WenwCzCphqdbFOpfktZPrI= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.1/go.mod h1:O1YSOg3aekZibh2SngvCRRG+cRHKKlYgxf/JBF/Kr/k= +github.com/aws/aws-sdk-go-v2/service/sts v1.18.3/go.mod h1:b+psTJn33Q4qGoDaM7ZiOVVG8uVjGI6HaZ8WBHdgDgU= +github.com/aws/smithy-go v1.13.5/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964 h1:y5HC9v93H5EPKqaS1UYVg1uYah5Xf51mBfIoWehClUQ= github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964/go.mod h1:Xd9hchkHSWYkEqJwUGisez3G1QY8Ryz0sdWrLPMGjLk= @@ -63,8 +63,9 @@ github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKs github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 h1:7I4JAnoQBe7ZtJcBaYHi5UtiO8tQHbUSXxL+pnGRANg= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.1.0 h1:MDRAIl0xIo9Io2xV565hzXHw3zVseKrJKodhohM5CjU= +golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= From 16933497fa158740fc52fc5452ca286306a3d2ff Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 24 Feb 2023 16:04:44 -0800 Subject: [PATCH 04/84] Bump github.com/aws/aws-sdk-go-v2/config from 1.18.12 to 1.18.15 (#241) * Bump github.com/aws/aws-sdk-go-v2/config from 1.18.12 to 1.18.15 Bumps [github.com/aws/aws-sdk-go-v2/config](https://github.com/aws/aws-sdk-go-v2) from 1.18.12 to 1.18.15. - [Release notes](https://github.com/aws/aws-sdk-go-v2/releases) - [Changelog](https://github.com/aws/aws-sdk-go-v2/blob/main/CHANGELOG.md) - [Commits](https://github.com/aws/aws-sdk-go-v2/compare/config/v1.18.12...config/v1.18.15) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go-v2/config dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Update changelog Signed-off-by: dependabot[bot] --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] --- CHANGELOG.md | 2 +- go.mod | 2 +- go.sum | 41 ++++++++++++++++++++--------------------- 3 files changed, 22 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 501cbfe..0f73792 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ 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.5 -- Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.10 to 1.18.12 +- Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.10 to 1.18.15 - Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.9 to 1.18.12 - Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.8 to 1.18.10 - Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.17.10 to 1.18.9 diff --git a/go.mod b/go.mod index 36e7dd3..be83511 100644 --- a/go.mod +++ b/go.mod @@ -5,6 +5,6 @@ go 1.15 require ( github.com/aws/aws-sdk-go v1.44.205 github.com/aws/aws-sdk-go-v2 v1.17.5 - github.com/aws/aws-sdk-go-v2/config v1.18.12 + github.com/aws/aws-sdk-go-v2/config v1.18.15 github.com/stretchr/testify v1.8.1 ) diff --git a/go.sum b/go.sum index b27d196..ee385e4 100644 --- a/go.sum +++ b/go.sum @@ -1,28 +1,27 @@ github.com/aws/aws-sdk-go v1.44.205 h1:q23NJXgLPIuBMn4zaluWWz57HPP5z7Ut8ZtK1D3N9bs= github.com/aws/aws-sdk-go v1.44.205/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= -github.com/aws/aws-sdk-go-v2 v1.17.4/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= github.com/aws/aws-sdk-go-v2 v1.17.5 h1:TzCUW1Nq4H8Xscph5M/skINUitxM5UBAyvm2s7XBzL4= github.com/aws/aws-sdk-go-v2 v1.17.5/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= -github.com/aws/aws-sdk-go-v2/config v1.18.12 h1:fKs/I4wccmfrNRO9rdrbMO1NgLxct6H9rNMiPdBxHWw= -github.com/aws/aws-sdk-go-v2/config v1.18.12/go.mod h1:J36fOhj1LQBr+O4hJCiT8FwVvieeoSGOtPuvhKlsNu8= -github.com/aws/aws-sdk-go-v2/credentials v1.13.12 h1:Cb+HhuEnV19zHRaYYVglwvdHGMJWbdsyP4oHhw04xws= -github.com/aws/aws-sdk-go-v2/credentials v1.13.12/go.mod h1:37HG2MBroXK3jXfxVGtbM2J48ra2+Ltu+tmwr/jO0KA= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.22 h1:3aMfcTmoXtTZnaT86QlVaYh+BRMbvrrmZwIQ5jWqCZQ= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.22/go.mod h1:YGSIJyQ6D6FjKMQh16hVFSIUD54L4F7zTGePqYMYYJU= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.28 h1:r+XwaCLpIvCKjBIYy/HVZujQS9tsz5ohHG3ZIe0wKoE= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.28/go.mod h1:3lwChorpIM/BhImY/hy+Z6jekmN92cXGPI1QJasVPYY= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.22 h1:7AwGYXDdqRQYsluvKFmWoqpcOQJ4bH634SkYf3FNj/A= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.22/go.mod h1:EqK7gVrIGAHyZItrD1D8B0ilgwMD1GiWAmbU4u/JHNk= -github.com/aws/aws-sdk-go-v2/internal/ini v1.3.29 h1:J4xhFd6zHhdF9jPP0FQJ6WknzBboGMBNjKOv4iTuw4A= -github.com/aws/aws-sdk-go-v2/internal/ini v1.3.29/go.mod h1:TwuqRBGzxjQJIwH16/fOZodwXt2Zxa9/cwJC5ke4j7s= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.22 h1:LjFQf8hFuMO22HkV5VWGLBvmCLBCLPivUAmpdpnp4Vs= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.22/go.mod h1:xt0Au8yPIwYXf/GYPy/vl4K3CgwhfQMYbrH7DlUUIws= -github.com/aws/aws-sdk-go-v2/service/sso v1.12.1 h1:lQKN/LNa3qqu2cDOQZybP7oL4nMGGiFqob0jZJaR8/4= -github.com/aws/aws-sdk-go-v2/service/sso v1.12.1/go.mod h1:IgV8l3sj22nQDd5qcAGY0WenwCzCphqdbFOpfktZPrI= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.1 h1:0bLhH6DRAqox+g0LatcjGKjjhU6Eudyys6HB6DJVPj8= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.1/go.mod h1:O1YSOg3aekZibh2SngvCRRG+cRHKKlYgxf/JBF/Kr/k= -github.com/aws/aws-sdk-go-v2/service/sts v1.18.3 h1:s49mSnsBZEXjfGBkRfmK+nPqzT7Lt3+t2SmAKNyHblw= -github.com/aws/aws-sdk-go-v2/service/sts v1.18.3/go.mod h1:b+psTJn33Q4qGoDaM7ZiOVVG8uVjGI6HaZ8WBHdgDgU= +github.com/aws/aws-sdk-go-v2/config v1.18.15 h1:509yMO0pJUGUugBP2H9FOFyV+7Mz7sRR+snfDN5W4NY= +github.com/aws/aws-sdk-go-v2/config v1.18.15/go.mod h1:vS0tddZqpE8cD9CyW0/kITHF5Bq2QasW9Y1DFHD//O0= +github.com/aws/aws-sdk-go-v2/credentials v1.13.15 h1:0rZQIi6deJFjOEgHI9HI2eZcLPPEGQPictX66oRFLL8= +github.com/aws/aws-sdk-go-v2/credentials v1.13.15/go.mod h1:vRMLMD3/rXU+o6j2MW5YefrGMBmdTvkLLGqFwMLBHQc= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.23 h1:Kbiv9PGnQfG/imNI4L/heyUXvzKmcWSBeDvkrQz5pFc= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.23/go.mod h1:mOtmAg65GT1HIL/HT/PynwPbS+UG0BgCZ6vhkPqnxWo= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.29 h1:9/aKwwus0TQxppPXFmf010DFrE+ssSbzroLVYINA+xE= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.29/go.mod h1:Dip3sIGv485+xerzVv24emnjX5Sg88utCL8fwGmCeWg= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.23 h1:b/Vn141DBuLVgXbhRWIrl9g+ww7G+ScV5SzniWR13jQ= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.23/go.mod h1:mr6c4cHC+S/MMkrjtSlG4QA36kOznDep+0fga5L/fGQ= +github.com/aws/aws-sdk-go-v2/internal/ini v1.3.30 h1:IVx9L7YFhpPq0tTnGo8u8TpluFu7nAn9X3sUDMb11c0= +github.com/aws/aws-sdk-go-v2/internal/ini v1.3.30/go.mod h1:vsbq62AOBwQ1LJ/GWKFxX8beUEYeRp/Agitrxee2/qM= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.23 h1:QoOybhwRfciWUBbZ0gp9S7XaDnCuSTeK/fySB99V1ls= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.23/go.mod h1:9uPh+Hrz2Vn6oMnQYiUi/zbh3ovbnQk19YKINkQny44= +github.com/aws/aws-sdk-go-v2/service/sso v1.12.4 h1:qJdM48OOLl1FBSzI7ZrA1ZfLwOyCYqkXV5lko1hYDBw= +github.com/aws/aws-sdk-go-v2/service/sso v1.12.4/go.mod h1:jtLIhd+V+lft6ktxpItycqHqiVXrPIRjWIsFIlzMriw= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.4 h1:YRkWXQveFb0tFC0TLktmmhGsOcCgLwvq88MC2al47AA= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.4/go.mod h1:zVwRrfdSmbRZWkUkWjOItY7SOalnFnq/Yg2LVPqDjwc= +github.com/aws/aws-sdk-go-v2/service/sts v1.18.5 h1:L1600eLr0YvTT7gNh3Ni24yGI7NSHkq9Gp62vijPRCs= +github.com/aws/aws-sdk-go-v2/service/sts v1.18.5/go.mod h1:1mKZHLLpDMHTNSYPJ7qrcnCQdHCWsNQaT0xRvq2u80s= github.com/aws/smithy-go v1.13.5 h1:hgz0X/DX0dGqTYpGALqXJoRKRj5oQ7150i5FdTePzO8= github.com/aws/smithy-go v1.13.5/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= From 2802f9ee7bbdf5a6898cb6575002dac96dfa2f27 Mon Sep 17 00:00:00 2001 From: Vacha Shah Date: Fri, 24 Feb 2023 17:13:57 -0800 Subject: [PATCH 05/84] Workflow improvements (#242) * Adding workflow improvements Signed-off-by: Vacha Shah * Updating compatibility matrix Signed-off-by: Vacha Shah * Fixing lint and adding changelog Signed-off-by: Vacha Shah * Merging from main Signed-off-by: Vacha Shah * Adding logs for integration workflow Signed-off-by: Vacha Shah --------- Signed-off-by: Vacha Shah --- .github/workflows/license.yml | 2 +- .github/workflows/links.yml | 2 +- .github/workflows/lint.yml | 7 +- .github/workflows/test-compatibility.yml | 20 ++---- .../workflows/test-integration-unreleased.yml | 66 ++++++++++++------- .github/workflows/test-integration.yml | 8 +-- .github/workflows/test-unit-tip.yml | 2 +- .github/workflows/test-unit.yml | 8 +-- CHANGELOG.md | 1 + CODEOWNERS | 1 - COMPATIBILITY.md | 3 +- go.mod | 1 + go.sum | 8 ++- internal/build/go.sum | 30 +++++---- 14 files changed, 91 insertions(+), 68 deletions(-) delete mode 100644 CODEOWNERS diff --git a/.github/workflows/license.yml b/.github/workflows/license.yml index 8d916ba..991990a 100644 --- a/.github/workflows/license.yml +++ b/.github/workflows/license.yml @@ -8,7 +8,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Check license headers run: | diff --git a/.github/workflows/links.yml b/.github/workflows/links.yml index 60042e4..a0dbc72 100644 --- a/.github/workflows/links.yml +++ b/.github/workflows/links.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: lychee Link Checker id: lychee uses: lycheeverse/lychee-action@v1.0.8 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index b4a2bfc..ed6e387 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -16,13 +16,12 @@ jobs: name: Lint runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: { fetch-depth: 1 } - uses: actions/setup-go@v2 - with: - go-version: 1.17 + with: { go-version: '1.x' } - name: Install dependencies - run: go get -u golang.org/x/lint/golint + run: go install golang.org/x/lint/golint@latest env: GOBIN: ${{ env.GOROOT }}/bin shell: bash diff --git a/.github/workflows/test-compatibility.yml b/.github/workflows/test-compatibility.yml index 7502d61..0c48fce 100644 --- a/.github/workflows/test-compatibility.yml +++ b/.github/workflows/test-compatibility.yml @@ -11,25 +11,19 @@ jobs: secured: ["true", "false"] entry: - { opensearch_version: 1.1.0 } - - { opensearch_version: 1.2.0 } - - { opensearch_version: 1.2.1 } - - { opensearch_version: 1.2.2 } - - { opensearch_version: 1.2.3 } - { opensearch_version: 1.2.4 } - - { opensearch_version: 1.3.0 } - - { opensearch_version: 1.3.1 } - - { opensearch_version: 1.3.2 } - - { opensearch_version: 1.3.3 } - - { opensearch_version: 1.3.4 } - - { opensearch_version: 2.0.0 } + - { opensearch_version: 1.3.8 } - { opensearch_version: 2.0.1 } - { opensearch_version: 2.1.0 } - - { opensearch_version: 2.2.0 } + - { opensearch_version: 2.2.1 } + - { opensearch_version: 2.3.0 } + - { opensearch_version: 2.4.1 } + - { opensearch_version: 2.5.0 } steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: { fetch-depth: 1 } - - uses: actions/setup-go@v2.1.3 + - uses: actions/setup-go@v3 with: { go-version: '1.x' } - run: go version diff --git a/.github/workflows/test-integration-unreleased.yml b/.github/workflows/test-integration-unreleased.yml index 87c1fc2..05c6799 100644 --- a/.github/workflows/test-integration-unreleased.yml +++ b/.github/workflows/test-integration-unreleased.yml @@ -14,43 +14,63 @@ jobs: strategy: fail-fast: false matrix: - entry: - - { opensearch_ref: '1.x' } - - { opensearch_ref: '2.0' } - - { opensearch_ref: '2.x' } - - { opensearch_ref: 'main' } + opensearch_ref: [ '1.x', '2.x', 'main' ] steps: - name: Checkout OpenSearch - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: repository: opensearch-project/OpenSearch ref: ${{ matrix.entry.opensearch_ref }} path: opensearch + - name: Get OpenSearch branch top + id: get-key + working-directory: opensearch + run: echo key=`git log -1 --format='%H'` >> $GITHUB_OUTPUT + + - name: Restore cached build + id: cache-restore + uses: actions/cache/restore@v3 + with: + path: opensearch/distribution/archives/linux-tar/build/distributions + key: ${{ steps.get-key.outputs.key }} + - name: Assemble OpenSearch + if: steps.cache-restore.outputs.cache-hit != 'true' + working-directory: opensearch + run: ./gradlew :distribution:archives:linux-tar:assemble + + - name: Save cached build + if: steps.cache-restore.outputs.cache-hit != 'true' + uses: actions/cache/save@v3 + with: + path: opensearch/distribution/archives/linux-tar/build/distributions + key: ${{ steps.get-key.outputs.key }} + + - name: Run OpenSearch + working-directory: opensearch/distribution/archives/linux-tar/build/distributions run: | - cd opensearch - ./gradlew assemble - # This step runs the docker image generated during gradle assemble in OpenSearch. It is tagged as opensearch:test. - # Reference: https://github.com/opensearch-project/OpenSearch/blob/2.0/distribution/docker/build.gradle#L190 - - name: Run Docker Image - run: | - docker run -p 9200:9200 -p 9600:9600 -d -e "discovery.type=single-node" -e "bootstrap.memory_lock=true" opensearch:test - sleep 90 + tar xf opensearch-min-* + ./opensearch-*/bin/opensearch & + for attempt in {1..20}; do sleep 5; if curl -s localhost:9200; then echo '=====> ready'; break; fi; echo '=====> waiting...'; done - name: Checkout Go Client - uses: actions/checkout@v2 + uses: actions/checkout@v3 + with: + path: go-client - name: Setup Go - uses: actions/setup-go@v2.1.3 + uses: actions/setup-go@v3 with: { go-version: '1.x' } - - name: Increase system limits - run: | - sudo swapoff -a - sudo sysctl -w vm.swappiness=1 - sudo sysctl -w fs.file-max=262144 - sudo sysctl -w vm.max_map_count=262144 - - name: Integration test + working-directory: go-client run: make test-integ race=true + + - name: Save server logs + if: failure() + uses: actions/upload-artifact@v3 + with: + name: opensearch-logs-${{ matrix.opensearch_ref }}-go-${{ matrix.python-version }} + path: | + opensearch/distribution/archives/linux-tar/build/distributions/**/logs/* diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index e576c70..6a7c7f9 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -16,9 +16,9 @@ jobs: name: Tests runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: { fetch-depth: 1 } - - uses: actions/setup-go@v2.1.3 + - uses: actions/setup-go@v3 with: { go-version: '1.x' } - run: go version - name: Increase system limits @@ -43,9 +43,9 @@ jobs: env: SECURE_INTEGRATION: true steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: { fetch-depth: 1 } - - uses: actions/setup-go@v2.1.3 + - uses: actions/setup-go@v3 with: { go-version: '1.x' } - run: go version - name: Increase system limits diff --git a/.github/workflows/test-unit-tip.yml b/.github/workflows/test-unit-tip.yml index 8dc4fb5..14d9e2b 100644 --- a/.github/workflows/test-unit-tip.yml +++ b/.github/workflows/test-unit-tip.yml @@ -35,7 +35,7 @@ jobs: bash make.bash echo "GOROOT=$GOROOT" >> $GITHUB_ENV echo "$GOROOT/bin" >> $GITHUB_PATH - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: { fetch-depth: 1 } - run: go version - run: make test-unit race=true diff --git a/.github/workflows/test-unit.yml b/.github/workflows/test-unit.yml index 6c3fcf1..e5f4904 100644 --- a/.github/workflows/test-unit.yml +++ b/.github/workflows/test-unit.yml @@ -21,9 +21,9 @@ jobs: go: ['1.x'] fail-fast: false steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: { fetch-depth: 1 } - - uses: actions/setup-go@v2.1.3 + - uses: actions/setup-go@v3 with: { go-version: "${{ matrix.go }}" } - run: go version - run: make test-unit race=true @@ -37,9 +37,9 @@ jobs: name: Benchmarks runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: { fetch-depth: 1 } - - uses: actions/setup-go@v2.1.3 + - uses: actions/setup-go@v3 with: { go-version: '1.x' } - run: go version - run: make test-bench diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f73792..43ab32f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Bumps `github.com/aws/aws-sdk-go` from 1.44.45 to 1.44.132 ### Changed +- Workflow improvements ([#242](https://github.com/opensearch-project/opensearch-go/pull/242)) ### Deprecated diff --git a/CODEOWNERS b/CODEOWNERS deleted file mode 100644 index 1ad1147..0000000 --- a/CODEOWNERS +++ /dev/null @@ -1 +0,0 @@ -@jmazanec15 @vamshin @VijayanB @svencowart @VachaShah diff --git a/COMPATIBILITY.md b/COMPATIBILITY.md index e89a053..a774d34 100644 --- a/COMPATIBILITY.md +++ b/COMPATIBILITY.md @@ -11,7 +11,8 @@ The below matrix shows the compatibility of the [`opensearch-go`](https://pkg.go | 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 | +| 2.1.0 | 2.0.0-2.5.0 | +| 2.2.0 | 2.0.0-2.5.0 | ## Upgrading diff --git a/go.mod b/go.mod index be83511..67ceb9d 100644 --- a/go.mod +++ b/go.mod @@ -7,4 +7,5 @@ require ( github.com/aws/aws-sdk-go-v2 v1.17.5 github.com/aws/aws-sdk-go-v2/config v1.18.15 github.com/stretchr/testify v1.8.1 + golang.org/x/net v0.7.0 // indirect ) diff --git a/go.sum b/go.sum index ee385e4..1911fa7 100644 --- a/go.sum +++ b/go.sum @@ -50,8 +50,9 @@ golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91 golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.1.0 h1:hZ/3BUoy5aId7sCpA/Tc5lt8DkFgdVS2onTpJsZ/fl0= golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= +golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -60,14 +61,17 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= diff --git a/internal/build/go.sum b/internal/build/go.sum index f6348f6..6522dd9 100644 --- a/internal/build/go.sum +++ b/internal/build/go.sum @@ -8,17 +8,17 @@ github.com/alecthomas/kong v0.2.4/go.mod h1:kQOmtJgV+Lb4aj+I2LEn40cbtawdWJ9Y8QLq github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897 h1:p9Sln00KOTlrYkxI1zYWl1QLnEqAqEARBEYa8FQnQcY= github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897/go.mod h1:xTS7Pm1pD1mvyM075QCDSRqH6qRLXylzS24ZTpRiSzQ= github.com/aws/aws-sdk-go v1.44.205/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= -github.com/aws/aws-sdk-go-v2 v1.17.4/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= -github.com/aws/aws-sdk-go-v2/config v1.18.12/go.mod h1:J36fOhj1LQBr+O4hJCiT8FwVvieeoSGOtPuvhKlsNu8= -github.com/aws/aws-sdk-go-v2/credentials v1.13.12/go.mod h1:37HG2MBroXK3jXfxVGtbM2J48ra2+Ltu+tmwr/jO0KA= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.22/go.mod h1:YGSIJyQ6D6FjKMQh16hVFSIUD54L4F7zTGePqYMYYJU= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.28/go.mod h1:3lwChorpIM/BhImY/hy+Z6jekmN92cXGPI1QJasVPYY= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.22/go.mod h1:EqK7gVrIGAHyZItrD1D8B0ilgwMD1GiWAmbU4u/JHNk= -github.com/aws/aws-sdk-go-v2/internal/ini v1.3.29/go.mod h1:TwuqRBGzxjQJIwH16/fOZodwXt2Zxa9/cwJC5ke4j7s= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.22/go.mod h1:xt0Au8yPIwYXf/GYPy/vl4K3CgwhfQMYbrH7DlUUIws= -github.com/aws/aws-sdk-go-v2/service/sso v1.12.1/go.mod h1:IgV8l3sj22nQDd5qcAGY0WenwCzCphqdbFOpfktZPrI= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.1/go.mod h1:O1YSOg3aekZibh2SngvCRRG+cRHKKlYgxf/JBF/Kr/k= -github.com/aws/aws-sdk-go-v2/service/sts v1.18.3/go.mod h1:b+psTJn33Q4qGoDaM7ZiOVVG8uVjGI6HaZ8WBHdgDgU= +github.com/aws/aws-sdk-go-v2 v1.17.5/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= +github.com/aws/aws-sdk-go-v2/config v1.18.15/go.mod h1:vS0tddZqpE8cD9CyW0/kITHF5Bq2QasW9Y1DFHD//O0= +github.com/aws/aws-sdk-go-v2/credentials v1.13.15/go.mod h1:vRMLMD3/rXU+o6j2MW5YefrGMBmdTvkLLGqFwMLBHQc= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.23/go.mod h1:mOtmAg65GT1HIL/HT/PynwPbS+UG0BgCZ6vhkPqnxWo= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.29/go.mod h1:Dip3sIGv485+xerzVv24emnjX5Sg88utCL8fwGmCeWg= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.23/go.mod h1:mr6c4cHC+S/MMkrjtSlG4QA36kOznDep+0fga5L/fGQ= +github.com/aws/aws-sdk-go-v2/internal/ini v1.3.30/go.mod h1:vsbq62AOBwQ1LJ/GWKFxX8beUEYeRp/Agitrxee2/qM= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.23/go.mod h1:9uPh+Hrz2Vn6oMnQYiUi/zbh3ovbnQk19YKINkQny44= +github.com/aws/aws-sdk-go-v2/service/sso v1.12.4/go.mod h1:jtLIhd+V+lft6ktxpItycqHqiVXrPIRjWIsFIlzMriw= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.4/go.mod h1:zVwRrfdSmbRZWkUkWjOItY7SOalnFnq/Yg2LVPqDjwc= +github.com/aws/aws-sdk-go-v2/service/sts v1.18.5/go.mod h1:1mKZHLLpDMHTNSYPJ7qrcnCQdHCWsNQaT0xRvq2u80s= github.com/aws/smithy-go v1.13.5/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964 h1:y5HC9v93H5EPKqaS1UYVg1uYah5Xf51mBfIoWehClUQ= @@ -72,6 +72,7 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= 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.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -82,16 +83,19 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.1.0 h1:g6Z6vPFA9dYBAF7DWcH6sCcOntplXsDKcliusYijMlw= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.5.0 h1:n2a8QNdAb0sZNpU9R1ALUXBbY+w51fCQDN+7EdxNBsY= +golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12 h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU= From c13c7cb49775679c5beaf730e96be222550c0e9c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 28 Feb 2023 11:10:32 -0800 Subject: [PATCH 06/84] Bump github.com/aws/aws-sdk-go from 1.44.205 to 1.44.210 (#245) * Bump github.com/aws/aws-sdk-go from 1.44.205 to 1.44.210 Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.44.205 to 1.44.210. - [Release notes](https://github.com/aws/aws-sdk-go/releases) - [Commits](https://github.com/aws/aws-sdk-go/compare/v1.44.205...v1.44.210) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Update changelog Signed-off-by: dependabot[bot] --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] --- CHANGELOG.md | 2 +- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 43ab32f..c15aca8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.9 to 1.18.12 - Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.8 to 1.18.10 - Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.17.10 to 1.18.9 -- Bumps `github.com/aws/aws-sdk-go` from 1.44.195 to 1.44.205 +- Bumps `github.com/aws/aws-sdk-go` from 1.44.195 to 1.44.210 - Bumps `github.com/aws/aws-sdk-go` from 1.44.185 to 1.44.205 - Bumps `github.com/aws/aws-sdk-go` from 1.44.180 to 1.44.195 - Bumps `github.com/aws/aws-sdk-go` from 1.44.176 to 1.44.185 diff --git a/go.mod b/go.mod index 67ceb9d..3f3d4ca 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/opensearch-project/opensearch-go/v2 go 1.15 require ( - github.com/aws/aws-sdk-go v1.44.205 + github.com/aws/aws-sdk-go v1.44.210 github.com/aws/aws-sdk-go-v2 v1.17.5 github.com/aws/aws-sdk-go-v2/config v1.18.15 github.com/stretchr/testify v1.8.1 diff --git a/go.sum b/go.sum index 1911fa7..2355728 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/aws/aws-sdk-go v1.44.205 h1:q23NJXgLPIuBMn4zaluWWz57HPP5z7Ut8ZtK1D3N9bs= -github.com/aws/aws-sdk-go v1.44.205/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= +github.com/aws/aws-sdk-go v1.44.210 h1:/cqRMHSSgzLEKILIDGwhaX2hiIpyRurw7MRy6aaSufg= +github.com/aws/aws-sdk-go v1.44.210/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go-v2 v1.17.5 h1:TzCUW1Nq4H8Xscph5M/skINUitxM5UBAyvm2s7XBzL4= github.com/aws/aws-sdk-go-v2 v1.17.5/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= github.com/aws/aws-sdk-go-v2/config v1.18.15 h1:509yMO0pJUGUugBP2H9FOFyV+7Mz7sRR+snfDN5W4NY= From 3e065d17641a53adc27f76e37c989fd5e1df2c5f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 28 Feb 2023 11:50:32 -0800 Subject: [PATCH 07/84] Bump github.com/stretchr/testify from 1.8.1 to 1.8.2 (#244) * Bump github.com/stretchr/testify from 1.8.1 to 1.8.2 Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.8.1 to 1.8.2. - [Release notes](https://github.com/stretchr/testify/releases) - [Commits](https://github.com/stretchr/testify/compare/v1.8.1...v1.8.2) --- updated-dependencies: - dependency-name: github.com/stretchr/testify dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Update changelog Signed-off-by: dependabot[bot] --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] --- CHANGELOG.md | 1 + go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c15aca8..267e1c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Bumps `github.com/aws/aws-sdk-go` from 1.44.180 to 1.44.195 - Bumps `github.com/aws/aws-sdk-go` from 1.44.176 to 1.44.185 - Bumps `github.com/aws/aws-sdk-go` from 1.44.132 to 1.44.180 +- 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)) diff --git a/go.mod b/go.mod index 3f3d4ca..4bfb988 100644 --- a/go.mod +++ b/go.mod @@ -6,6 +6,6 @@ require ( github.com/aws/aws-sdk-go v1.44.210 github.com/aws/aws-sdk-go-v2 v1.17.5 github.com/aws/aws-sdk-go-v2/config v1.18.15 - github.com/stretchr/testify v1.8.1 + github.com/stretchr/testify v1.8.2 golang.org/x/net v0.7.0 // indirect ) diff --git a/go.sum b/go.sum index 2355728..b23e785 100644 --- a/go.sum +++ b/go.sum @@ -41,8 +41,8 @@ github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSS github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= 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 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= -github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= +github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= From f43c325042e1bd1c1d73a27610d5fd2927ea2ec8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 Mar 2023 23:01:00 -0700 Subject: [PATCH 08/84] Bump github.com/aws/aws-sdk-go-v2 from 1.17.5 to 1.17.6 (#248) * Bump github.com/aws/aws-sdk-go-v2 from 1.17.5 to 1.17.6 Bumps [github.com/aws/aws-sdk-go-v2](https://github.com/aws/aws-sdk-go-v2) from 1.17.5 to 1.17.6. - [Release notes](https://github.com/aws/aws-sdk-go-v2/releases) - [Changelog](https://github.com/aws/aws-sdk-go-v2/blob/main/CHANGELOG.md) - [Commits](https://github.com/aws/aws-sdk-go-v2/compare/v1.17.5...v1.17.6) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go-v2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Update changelog Signed-off-by: dependabot[bot] --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] --- CHANGELOG.md | 2 +- go.mod | 2 +- go.sum | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 267e1c5..d17eaa6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ 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.5 +- Bumps `github.com/aws/aws-sdk-go-v2` from 1.17.1 to 1.17.6 - Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.10 to 1.18.15 - Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.9 to 1.18.12 - Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.8 to 1.18.10 diff --git a/go.mod b/go.mod index 4bfb988..e8cec14 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.15 require ( github.com/aws/aws-sdk-go v1.44.210 - github.com/aws/aws-sdk-go-v2 v1.17.5 + github.com/aws/aws-sdk-go-v2 v1.17.6 github.com/aws/aws-sdk-go-v2/config v1.18.15 github.com/stretchr/testify v1.8.2 golang.org/x/net v0.7.0 // indirect diff --git a/go.sum b/go.sum index b23e785..2123266 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,8 @@ github.com/aws/aws-sdk-go v1.44.210 h1:/cqRMHSSgzLEKILIDGwhaX2hiIpyRurw7MRy6aaSufg= github.com/aws/aws-sdk-go v1.44.210/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= -github.com/aws/aws-sdk-go-v2 v1.17.5 h1:TzCUW1Nq4H8Xscph5M/skINUitxM5UBAyvm2s7XBzL4= github.com/aws/aws-sdk-go-v2 v1.17.5/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= +github.com/aws/aws-sdk-go-v2 v1.17.6 h1:Y773UK7OBqhzi5VDXMi1zVGsoj+CVHs2eaC2bDsLwi0= +github.com/aws/aws-sdk-go-v2 v1.17.6/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= github.com/aws/aws-sdk-go-v2/config v1.18.15 h1:509yMO0pJUGUugBP2H9FOFyV+7Mz7sRR+snfDN5W4NY= github.com/aws/aws-sdk-go-v2/config v1.18.15/go.mod h1:vS0tddZqpE8cD9CyW0/kITHF5Bq2QasW9Y1DFHD//O0= github.com/aws/aws-sdk-go-v2/credentials v1.13.15 h1:0rZQIi6deJFjOEgHI9HI2eZcLPPEGQPictX66oRFLL8= From 4bb45390599aa970ebd32a4ad3f672333eccd014 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 Mar 2023 23:22:39 -0700 Subject: [PATCH 09/84] Bump github.com/aws/aws-sdk-go-v2/config from 1.18.15 to 1.18.18 (#254) * Bump github.com/aws/aws-sdk-go-v2/config from 1.18.15 to 1.18.18 Bumps [github.com/aws/aws-sdk-go-v2/config](https://github.com/aws/aws-sdk-go-v2) from 1.18.15 to 1.18.18. - [Release notes](https://github.com/aws/aws-sdk-go-v2/releases) - [Changelog](https://github.com/aws/aws-sdk-go-v2/blob/main/CHANGELOG.md) - [Commits](https://github.com/aws/aws-sdk-go-v2/compare/config/v1.18.15...config/v1.18.18) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go-v2/config dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Update changelog Signed-off-by: dependabot[bot] --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] --- CHANGELOG.md | 2 +- go.mod | 2 +- go.sum | 41 ++++++++++++++++++++--------------------- 3 files changed, 22 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d17eaa6..0d30a2a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ 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.6 -- Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.10 to 1.18.15 +- Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.10 to 1.18.18 - Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.9 to 1.18.12 - Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.8 to 1.18.10 - Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.17.10 to 1.18.9 diff --git a/go.mod b/go.mod index e8cec14..186812b 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.15 require ( github.com/aws/aws-sdk-go v1.44.210 github.com/aws/aws-sdk-go-v2 v1.17.6 - github.com/aws/aws-sdk-go-v2/config v1.18.15 + github.com/aws/aws-sdk-go-v2/config v1.18.18 github.com/stretchr/testify v1.8.2 golang.org/x/net v0.7.0 // indirect ) diff --git a/go.sum b/go.sum index 2123266..5135e97 100644 --- a/go.sum +++ b/go.sum @@ -1,28 +1,27 @@ github.com/aws/aws-sdk-go v1.44.210 h1:/cqRMHSSgzLEKILIDGwhaX2hiIpyRurw7MRy6aaSufg= github.com/aws/aws-sdk-go v1.44.210/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= -github.com/aws/aws-sdk-go-v2 v1.17.5/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= github.com/aws/aws-sdk-go-v2 v1.17.6 h1:Y773UK7OBqhzi5VDXMi1zVGsoj+CVHs2eaC2bDsLwi0= github.com/aws/aws-sdk-go-v2 v1.17.6/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= -github.com/aws/aws-sdk-go-v2/config v1.18.15 h1:509yMO0pJUGUugBP2H9FOFyV+7Mz7sRR+snfDN5W4NY= -github.com/aws/aws-sdk-go-v2/config v1.18.15/go.mod h1:vS0tddZqpE8cD9CyW0/kITHF5Bq2QasW9Y1DFHD//O0= -github.com/aws/aws-sdk-go-v2/credentials v1.13.15 h1:0rZQIi6deJFjOEgHI9HI2eZcLPPEGQPictX66oRFLL8= -github.com/aws/aws-sdk-go-v2/credentials v1.13.15/go.mod h1:vRMLMD3/rXU+o6j2MW5YefrGMBmdTvkLLGqFwMLBHQc= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.23 h1:Kbiv9PGnQfG/imNI4L/heyUXvzKmcWSBeDvkrQz5pFc= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.23/go.mod h1:mOtmAg65GT1HIL/HT/PynwPbS+UG0BgCZ6vhkPqnxWo= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.29 h1:9/aKwwus0TQxppPXFmf010DFrE+ssSbzroLVYINA+xE= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.29/go.mod h1:Dip3sIGv485+xerzVv24emnjX5Sg88utCL8fwGmCeWg= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.23 h1:b/Vn141DBuLVgXbhRWIrl9g+ww7G+ScV5SzniWR13jQ= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.23/go.mod h1:mr6c4cHC+S/MMkrjtSlG4QA36kOznDep+0fga5L/fGQ= -github.com/aws/aws-sdk-go-v2/internal/ini v1.3.30 h1:IVx9L7YFhpPq0tTnGo8u8TpluFu7nAn9X3sUDMb11c0= -github.com/aws/aws-sdk-go-v2/internal/ini v1.3.30/go.mod h1:vsbq62AOBwQ1LJ/GWKFxX8beUEYeRp/Agitrxee2/qM= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.23 h1:QoOybhwRfciWUBbZ0gp9S7XaDnCuSTeK/fySB99V1ls= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.23/go.mod h1:9uPh+Hrz2Vn6oMnQYiUi/zbh3ovbnQk19YKINkQny44= -github.com/aws/aws-sdk-go-v2/service/sso v1.12.4 h1:qJdM48OOLl1FBSzI7ZrA1ZfLwOyCYqkXV5lko1hYDBw= -github.com/aws/aws-sdk-go-v2/service/sso v1.12.4/go.mod h1:jtLIhd+V+lft6ktxpItycqHqiVXrPIRjWIsFIlzMriw= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.4 h1:YRkWXQveFb0tFC0TLktmmhGsOcCgLwvq88MC2al47AA= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.4/go.mod h1:zVwRrfdSmbRZWkUkWjOItY7SOalnFnq/Yg2LVPqDjwc= -github.com/aws/aws-sdk-go-v2/service/sts v1.18.5 h1:L1600eLr0YvTT7gNh3Ni24yGI7NSHkq9Gp62vijPRCs= -github.com/aws/aws-sdk-go-v2/service/sts v1.18.5/go.mod h1:1mKZHLLpDMHTNSYPJ7qrcnCQdHCWsNQaT0xRvq2u80s= +github.com/aws/aws-sdk-go-v2/config v1.18.18 h1:/ePABXvXl3ESlzUGnkkvvNnRFw3Gh13dyqaq0Qo3JcU= +github.com/aws/aws-sdk-go-v2/config v1.18.18/go.mod h1:Lj3E7XcxJnxMa+AYo89YiL68s1cFJRGduChynYU67VA= +github.com/aws/aws-sdk-go-v2/credentials v1.13.17 h1:IubQO/RNeIVKF5Jy77w/LfUvmmCxTnk2TP1UZZIMiF4= +github.com/aws/aws-sdk-go-v2/credentials v1.13.17/go.mod h1:K9xeFo1g/YPMguMUD69YpwB4Nyi6W/5wn706xIInJFg= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.0 h1:/2Cb3SK3xVOQA7Xfr5nCWCo5H3UiNINtsVvVdk8sQqA= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.0/go.mod h1:neYVaeKr5eT7BzwULuG2YbLhzWZ22lpjKdCybR7AXrQ= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.30 h1:y+8n9AGDjikyXoMBTRaHHHSaFEB8267ykmvyPodJfys= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.30/go.mod h1:LUBAO3zNXQjoONBKn/kR1y0Q4cj/D02Ts0uHYjcCQLM= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.24 h1:r+Kv+SEJquhAZXaJ7G4u44cIwXV3f8K+N482NNAzJZA= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.24/go.mod h1:gAuCezX/gob6BSMbItsSlMb6WZGV7K2+fWOvk8xBSto= +github.com/aws/aws-sdk-go-v2/internal/ini v1.3.31 h1:hf+Vhp5WtTdcSdE+yEcUz8L73sAzN0R+0jQv+Z51/mI= +github.com/aws/aws-sdk-go-v2/internal/ini v1.3.31/go.mod h1:5zUjguZfG5qjhG9/wqmuyHRyUftl2B5Cp6NNxNC6kRA= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.24 h1:c5qGfdbCHav6viBwiyDns3OXqhqAbGjfIB4uVu2ayhk= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.24/go.mod h1:HMA4FZG6fyib+NDo5bpIxX1EhYjrAOveZJY2YR0xrNE= +github.com/aws/aws-sdk-go-v2/service/sso v1.12.5 h1:bdKIX6SVF3nc3xJFw6Nf0igzS6Ff/louGq8Z6VP/3Hs= +github.com/aws/aws-sdk-go-v2/service/sso v1.12.5/go.mod h1:vuWiaDB30M/QTC+lI3Wj6S/zb7tpUK2MSYgy3Guh2L0= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.5 h1:xLPZMyuZ4GuqRCIec/zWuIhRFPXh2UOJdLXBSi64ZWQ= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.5/go.mod h1:QjxpHmCwAg0ESGtPQnLIVp7SedTOBMYy+Slr3IfMKeI= +github.com/aws/aws-sdk-go-v2/service/sts v1.18.6 h1:rIFn5J3yDoeuKCE9sESXqM5POTAhOP1du3bv/qTL+tE= +github.com/aws/aws-sdk-go-v2/service/sts v1.18.6/go.mod h1:48WJ9l3dwP0GSHWGc5sFGGlCkuA82Mc2xnw+T6Q8aDw= github.com/aws/smithy-go v1.13.5 h1:hgz0X/DX0dGqTYpGALqXJoRKRj5oQ7150i5FdTePzO8= github.com/aws/smithy-go v1.13.5/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= From efe6d62ff3cb6fcaaa59f0f151f77d193da2924a Mon Sep 17 00:00:00 2001 From: Harrison Jones Date: Tue, 21 Mar 2023 15:31:11 -0400 Subject: [PATCH 10/84] Update signer v1 example for AOSS (#259) - Updated SDK v1 signer - Updated user guide - Update changelog Signed-off-by: Harrison Jones --- CHANGELOG.md | 2 +- USER_GUIDE.md | 43 +++++++++---------- signer/aws/aws.go | 67 ++++++++++++++++++++++-------- signer/aws/aws_test.go | 93 +++++++++++++++++++++++++++++------------- 4 files changed, 137 insertions(+), 68 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d30a2a..45ec089 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,7 +18,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### 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)) +- Support for Amazon OpenSearch Serverless ([#216](https://github.com/opensearch-project/opensearch-go/pull/216), [#259](https://github.com/opensearch-project/opensearch-go/pull/259)) ### Dependencies - Bumps `github.com/stretchr/testify` from 1.8.0 to 1.8.1 diff --git a/USER_GUIDE.md b/USER_GUIDE.md index 7cf07b4..faaf1e3 100644 --- a/USER_GUIDE.md +++ b/USER_GUIDE.md @@ -184,37 +184,40 @@ 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") @@ -231,6 +234,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 +255,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(`{ @@ -287,11 +291,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 +302,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 { diff --git a/signer/aws/aws.go b/signer/aws/aws.go index 42abc33..3df651e 100644 --- a/signer/aws/aws.go +++ b/signer/aws/aws.go @@ -11,6 +11,8 @@ package aws import ( "bytes" + "crypto/sha256" + "encoding/hex" "errors" "fmt" "io" @@ -22,28 +24,34 @@ import ( v4 "github.com/aws/aws-sdk-go/aws/signer/v4" ) -// OpenSearchService AWS OpenSearchService Name +// OpenSearchService Amazon OpenSearch Service Name const OpenSearchService = "es" -// Signer is a interface that will implement opensearchtransport.Signer +// OpenSearchServerless Amazon OpenSearch Serverless Name +const OpenSearchServerless = "aoss" + +const emptyBodySHA256 = "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824" + +// Signer is an interface that will implement opensearchtransport.Signer type Signer struct { session session.Session service string } -// NewSigner returns an instance of Signer for AWS OpenSearchService +// NewSigner returns an instance of Signer for configured for Amazon OpenSearch Service. +// Use NewSignerWithService to configure it for another service such as Amazon OpenSearch Serverless. func NewSigner(opts session.Options) (*Signer, error) { return NewSignerWithService(opts, OpenSearchService) } -// NewSignerWithService returns an instance of Signer for given service +// NewSignerWithService returns an instance of Signer for a given service. func NewSignerWithService(opts session.Options, service string) (*Signer, error) { if len(strings.TrimSpace(service)) < 1 { return nil, errors.New("service cannot be empty") } awsSession, err := session.NewSessionWithOptions(opts) if err != nil { - return nil, fmt.Errorf("failed to get session from given option %v due to %s", opts, err) + return nil, fmt.Errorf("failed to get session from given options %v: %v", opts, err) } return &Signer{ session: *awsSession, @@ -51,25 +59,50 @@ func NewSignerWithService(opts session.Options, service string) (*Signer, error) }, nil } -// SignRequest signs the request using SigV4 +// SignRequest signs the request using SigV4. func (s Signer) SignRequest(req *http.Request) error { - signer := v4.NewSigner(s.session.Config.Credentials) - return sign(req, s.session.Config.Region, s.service, signer) - + return sign(req, s.session.Config.Region, s.service, v4.NewSigner(s.session.Config.Credentials)) } -func sign(req *http.Request, region *string, serviceName string, signer *v4.Signer) (err error) { +func sign(req *http.Request, region *string, serviceName string, signer *v4.Signer) error { if region == nil || len(*region) == 0 { return fmt.Errorf("aws region cannot be empty") } - if req.Body == nil { - _, err = signer.Sign(req, nil, serviceName, *region, time.Now().UTC()) - return + + var body io.ReadSeeker + var contentSha256Hash = emptyBodySHA256 + + if req.Body != nil { + b, err := io.ReadAll(req.Body) + if err != nil { + return fmt.Errorf("failed to read request body: %v", err) + } + body = bytes.NewReader(b) + hash, err := hexEncodedSha256(b) + if err != nil { + return fmt.Errorf("failed to calculate hash of request body: %v", err) + } + contentSha256Hash = hash } - buf, err := io.ReadAll(req.Body) - if err != nil { + // Add the "X-Amz-Content-Sha256" header as required by Amazon OpenSearch Serverless. + req.Header.Set("X-Amz-Content-Sha256", contentSha256Hash) + + if _, err := signer.Sign(req, body, serviceName, *region, time.Now().UTC()); err != nil { return err } - _, err = signer.Sign(req, bytes.NewReader(buf), serviceName, *region, time.Now().UTC()) - return + + return nil +} + +func hexEncodedSha256(b []byte) (string, error) { + hasher := sha256.New() + + _, err := hasher.Write(b) + if err != nil { + return "", fmt.Errorf("failed to write: %v", err) + } + + digest := hasher.Sum(nil) + + return hex.EncodeToString(digest), nil } diff --git a/signer/aws/aws_test.go b/signer/aws/aws_test.go index 3c049af..48ef4d8 100644 --- a/signer/aws/aws_test.go +++ b/signer/aws/aws_test.go @@ -11,26 +11,29 @@ package aws import ( "bytes" + "errors" + "io" "net/http" - "os" "testing" "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/aws/credentials" + "github.com/aws/aws-sdk-go/aws/session" "github.com/stretchr/testify/assert" ) +func TestConstants(t *testing.T) { + assert.Equal(t, "es", OpenSearchService) + assert.Equal(t, "aoss", OpenSearchServerless) + assert.Equal(t, "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824", emptyBodySHA256) +} + func TestV4Signer(t *testing.T) { + t.Run("sign request failed due to no region found", func(t *testing.T) { req, err := http.NewRequest(http.MethodGet, "https://localhost:9200", nil) assert.NoError(t, err) - region := os.Getenv("AWS_REGION") - os.Setenv("AWS_REGION", "") - defer func() { - os.Setenv("AWS_REGION", region) - }() + sessionOptions := session.Options{ Config: aws.Config{ Credentials: credentials.NewStaticCredentials("AKID", "SECRET_KEY", "TOKEN"), @@ -38,19 +41,15 @@ func TestV4Signer(t *testing.T) { } signer, err := NewSigner(sessionOptions) assert.NoError(t, err) - err = signer.SignRequest(req) - assert.EqualErrorf( - t, err, "aws region cannot be empty", "unexpected error") + err = signer.SignRequest(req) + assert.EqualError(t, err, "aws region cannot be empty") }) + t.Run("sign request success", func(t *testing.T) { req, err := http.NewRequest(http.MethodGet, "https://localhost:9200", nil) assert.NoError(t, err) - region := os.Getenv("AWS_REGION") - os.Setenv("AWS_REGION", "us-west-2") - defer func() { - os.Setenv("AWS_REGION", region) - }() + sessionOptions := session.Options{ Config: aws.Config{ Region: aws.String("us-west-2"), @@ -59,11 +58,14 @@ func TestV4Signer(t *testing.T) { } signer, err := NewSigner(sessionOptions) assert.NoError(t, err) + err = signer.SignRequest(req) assert.NoError(t, err) + q := req.Header assert.NotEmpty(t, q.Get("Authorization")) assert.NotEmpty(t, q.Get("X-Amz-Date")) + assert.Equal(t, "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824", q.Get("X-Amz-Content-Sha256")) }) t.Run("sign request success with body", func(t *testing.T) { @@ -71,11 +73,7 @@ func TestV4Signer(t *testing.T) { http.MethodPost, "https://localhost:9200", bytes.NewBuffer([]byte(`some data`))) assert.NoError(t, err) - region := os.Getenv("AWS_REGION") - os.Setenv("AWS_REGION", "us-west-2") - defer func() { - os.Setenv("AWS_REGION", region) - }() + sessionOptions := session.Options{ Config: aws.Config{ Region: aws.String("us-west-2"), @@ -84,39 +82,41 @@ func TestV4Signer(t *testing.T) { } signer, err := NewSigner(sessionOptions) assert.NoError(t, err) + err = signer.SignRequest(req) assert.NoError(t, err) + q := req.Header assert.NotEmpty(t, q.Get("Authorization")) assert.NotEmpty(t, q.Get("X-Amz-Date")) + assert.Equal(t, "1307990e6ba5ca145eb35e99182a9bec46531bc54ddf656a602c780fa0240dee", q.Get("X-Amz-Content-Sha256")) }) - t.Run("sign request success with body for other AWS Services", func(t *testing.T) { + t.Run("sign request success with body for OpenSearch Service Serverless", func(t *testing.T) { req, err := http.NewRequest( http.MethodPost, "https://localhost:9200", bytes.NewBuffer([]byte(`some data`))) assert.NoError(t, err) - region := os.Getenv("AWS_REGION") - os.Setenv("AWS_REGION", "us-west-2") - defer func() { - os.Setenv("AWS_REGION", region) - }() + sessionOptions := session.Options{ Config: aws.Config{ Region: aws.String("us-west-2"), Credentials: credentials.NewStaticCredentials("AKID", "SECRET_KEY", "TOKEN"), }, } - signer, err := NewSignerWithService(sessionOptions, "ec") + signer, err := NewSignerWithService(sessionOptions, OpenSearchServerless) assert.NoError(t, err) + err = signer.SignRequest(req) assert.NoError(t, err) + q := req.Header assert.NotEmpty(t, q.Get("Authorization")) assert.NotEmpty(t, q.Get("X-Amz-Date")) + assert.Equal(t, "1307990e6ba5ca145eb35e99182a9bec46531bc54ddf656a602c780fa0240dee", q.Get("X-Amz-Content-Sha256")) }) - t.Run("sign request failed due to invalid service", func(t *testing.T) { + t.Run("new signer failed due to empty service", func(t *testing.T) { sessionOptions := session.Options{ Config: aws.Config{ Region: aws.String("us-west-2"), @@ -125,6 +125,41 @@ func TestV4Signer(t *testing.T) { } _, err := NewSignerWithService(sessionOptions, "") assert.EqualError(t, err, "service cannot be empty") + }) + t.Run("new signer failed due to blank service", func(t *testing.T) { + sessionOptions := session.Options{ + Config: aws.Config{ + Region: aws.String("us-west-2"), + Credentials: credentials.NewStaticCredentials("AKID", "SECRET_KEY", "TOKEN"), + }, + } + _, err := NewSignerWithService(sessionOptions, " ") + assert.EqualError(t, err, "service cannot be empty") + }) + + t.Run("sign request failed due to invalid body", func(t *testing.T) { + req, err := http.NewRequest(http.MethodPost, "https://localhost:9200", nil) + assert.NoError(t, err) + + req.Body = io.NopCloser(brokenReader("boom")) + + sessionOptions := session.Options{ + Config: aws.Config{ + Region: aws.String("us-west-2"), + Credentials: credentials.NewStaticCredentials("AKID", "SECRET_KEY", "TOKEN"), + }, + } + signer, err := NewSigner(sessionOptions) + assert.NoError(t, err) + + err = signer.SignRequest(req) + assert.EqualError(t, err, "failed to read request body: boom") }) } + +type brokenReader string + +func (br brokenReader) Read([]byte) (int, error) { + return 0, errors.New(string(br)) +} From 6bcda6033d2b8d2cedebd9f32c36842c20ba38e6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 21 Mar 2023 15:31:52 -0400 Subject: [PATCH 11/84] Bump github.com/aws/aws-sdk-go from 1.44.210 to 1.44.225 (#255) * Bump github.com/aws/aws-sdk-go from 1.44.210 to 1.44.225 Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.44.210 to 1.44.225. - [Release notes](https://github.com/aws/aws-sdk-go/releases) - [Commits](https://github.com/aws/aws-sdk-go/compare/v1.44.210...v1.44.225) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Update changelog Signed-off-by: dependabot[bot] --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] --- CHANGELOG.md | 2 +- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 45ec089..6bfcdfc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.9 to 1.18.12 - Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.8 to 1.18.10 - Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.17.10 to 1.18.9 -- Bumps `github.com/aws/aws-sdk-go` from 1.44.195 to 1.44.210 +- Bumps `github.com/aws/aws-sdk-go` from 1.44.195 to 1.44.225 - Bumps `github.com/aws/aws-sdk-go` from 1.44.185 to 1.44.205 - Bumps `github.com/aws/aws-sdk-go` from 1.44.180 to 1.44.195 - Bumps `github.com/aws/aws-sdk-go` from 1.44.176 to 1.44.185 diff --git a/go.mod b/go.mod index 186812b..fcaf1ec 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/opensearch-project/opensearch-go/v2 go 1.15 require ( - github.com/aws/aws-sdk-go v1.44.210 + github.com/aws/aws-sdk-go v1.44.225 github.com/aws/aws-sdk-go-v2 v1.17.6 github.com/aws/aws-sdk-go-v2/config v1.18.18 github.com/stretchr/testify v1.8.2 diff --git a/go.sum b/go.sum index 5135e97..64b0c33 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/aws/aws-sdk-go v1.44.210 h1:/cqRMHSSgzLEKILIDGwhaX2hiIpyRurw7MRy6aaSufg= -github.com/aws/aws-sdk-go v1.44.210/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= +github.com/aws/aws-sdk-go v1.44.225 h1:JNJpUg+M1cm4jtKnyex//Mw1Rv8QN/kWT3dtr+oLdW4= +github.com/aws/aws-sdk-go v1.44.225/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go-v2 v1.17.6 h1:Y773UK7OBqhzi5VDXMi1zVGsoj+CVHs2eaC2bDsLwi0= github.com/aws/aws-sdk-go-v2 v1.17.6/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= github.com/aws/aws-sdk-go-v2/config v1.18.18 h1:/ePABXvXl3ESlzUGnkkvvNnRFw3Gh13dyqaq0Qo3JcU= From 5c627687cee0c9c1809db34ad279413428f5f244 Mon Sep 17 00:00:00 2001 From: Harrison Jones Date: Wed, 22 Mar 2023 14:12:33 -0400 Subject: [PATCH 12/84] Format markdown files with prettier 2.8.6 (#258) - Ran `npx prettier -w *.md` and committed the results. Signed-off-by: Harrison Jones --- ADMINS.md | 17 +++++++++-------- CHANGELOG.md | 17 ++++++++++++----- CODE_OF_CONDUCT.md | 29 +++++++++++++---------------- COMPATIBILITY.md | 16 ++++++++-------- CONTRIBUTING.md | 7 +++---- DEVELOPER_GUIDE.md | 21 +++++++++++++++------ MAINTAINERS.md | 10 +++++----- README.md | 24 ++++++++++++------------ RELEASING.md | 8 ++++---- SECURITY.md | 2 +- USER_GUIDE.md | 10 ++++------ 11 files changed, 86 insertions(+), 75 deletions(-) diff --git a/ADMINS.md b/ADMINS.md index 302ead5..1ec1f9e 100644 --- a/ADMINS.md +++ b/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/CHANGELOG.md b/CHANGELOG.md index 6bfcdfc..e30940e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,11 @@ # 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.6 - Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.10 to 1.18.18 - Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.9 to 1.18.12 @@ -16,28 +19,32 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - 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), [#259](https://github.com/opensearch-project/opensearch-go/pull/259)) ### 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 ### Changed + - Workflow improvements ([#242](https://github.com/opensearch-project/opensearch-go/pull/242)) ### 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)) - - Correct curl logging to emit the correct URL destination ([#101](https://github.com/opensearch-project/opensearch-go/pull/101)) -### Security +- 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)) +- Correct curl logging to emit the correct URL destination ([#101](https://github.com/opensearch-project/opensearch-go/pull/101)) +### Security -[Unreleased]: https://github.com/opensearch-project/opensearch-go/compare/2.1...HEAD \ No newline at end of file +[Unreleased]: https://github.com/opensearch-project/opensearch-go/compare/2.1...HEAD diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 997bae6..c5efd05 100644 --- a/CODE_OF_CONDUCT.md +++ b/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/COMPATIBILITY.md b/COMPATIBILITY.md index a774d34..30e771f 100644 --- a/COMPATIBILITY.md +++ b/COMPATIBILITY.md @@ -6,14 +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.5.0 | -| 2.2.0 | 2.0.0-2.5.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/CONTRIBUTING.md b/CONTRIBUTING.md index 58e16eb..e7b0764 100644 --- a/CONTRIBUTING.md +++ b/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/DEVELOPER_GUIDE.md b/DEVELOPER_GUIDE.md index e762490..c4279a2 100644 --- a/DEVELOPER_GUIDE.md +++ b/DEVELOPER_GUIDE.md @@ -9,9 +9,10 @@ - [Execute integration tests from your terminal](#execute-integration-tests-from-your-terminal) - [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 @@ -23,6 +24,7 @@ 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 @@ -30,19 +32,23 @@ OpenSearch Go Client builds using [Go](https://golang.org/doc/install) 1.11 at a [Docker](https://docs.docker.com/install/) is required for building some OpenSearch artifacts and executing integration tests. ### 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. + +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/). @@ -51,6 +57,7 @@ with [build tags](https://pkg.go.dev/cmd/go#hdr-Build_constraints). The build ta 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 +70,16 @@ Hence, create all integration tests with build tag 'integration'. ``` make cluster.stop cluster.clean ``` + ## 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 +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/MAINTAINERS.md b/MAINTAINERS.md index 9f4480b..a4718d3 100644 --- a/MAINTAINERS.md +++ b/MAINTAINERS.md @@ -13,8 +13,8 @@ This document contains a list of maintainers in this repo. See [opensearch-proje ## 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 | +| Vamshi Vijay Nakkirtha | [vamshin](https://github.com/vamshin) | Amazon | +| Rob Cowart | [robcowart](https://github.com/robcowart) | ElastiFlow | diff --git a/README.md b/README.md index 92a4bc0..8161dfd 100644 --- a/README.md +++ b/README.md @@ -22,18 +22,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/RELEASING.md b/RELEASING.md index 1d6ad9e..7d9053d 100644 --- a/RELEASING.md +++ b/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/SECURITY.md b/SECURITY.md index 0b85ca0..b862921 100644 --- a/SECURITY.md +++ b/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/USER_GUIDE.md b/USER_GUIDE.md index faaf1e3..58cd71c 100644 --- a/USER_GUIDE.md +++ b/USER_GUIDE.md @@ -1,8 +1,6 @@ - [User Guide](#user-guide) - - [Example](#example) - - [Amazon OpenSearch Service](#amazon-opensearch-service) - - [AWS SDK V1](#aws-sdk-v1) - - [AWS SDK V2](#aws-sdk-v2) + - [Example](#example) + - [Amazon OpenSearch Service](#amazon-opensearch-service) - [AWS SDK V1](#aws-sdk-v1) - [AWS SDK V2](#aws-sdk-v2) # User Guide @@ -149,7 +147,7 @@ See [Identity and Access Management in Amazon OpenSearch Service.](https://docs. > 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. @@ -283,7 +281,7 @@ func main() { } } }`) - + // Create an index with non-default settings. createIndex := opensearchapi.IndicesCreateRequest{ Index: indexName, From 8d3cf4dd6e872f5c9fc50408ca74dc7c06e9b490 Mon Sep 17 00:00:00 2001 From: Jakob Date: Wed, 22 Mar 2023 19:28:08 +0100 Subject: [PATCH 13/84] Draft: Add Err() function to Response for detailed errors (#246) * opensearchapi: Add Error type Signed-off-by: Jakob Hahn * opensearchapi: Add Err() function to response Signed-off-by: Jakob Hahn * opensearchapi: Remove unneded IsError check Signed-off-by: Jakob Hahn * opensearchapi: Add tests for reponse.Err() function Signed-off-by: Jakob Hahn * opensearchutil: Remove unneded IsError() check Signed-off-by: Jakob Hahn * USER_GUIDE: Remove IsError check, improve example, add error.As example Signed-off-by: Jakob Hahn * opensearchapi: Check reponse body for errors in all api types Signed-off-by: Jakob Hahn * Update CHANGELOG.md Signed-off-by: Jakob Hahn * opensearchapi: Adjust benchmarks to not brake on wanted Response Errors Signed-off-by: Jakob Hahn * Add UPGRADING.md Signed-off-by: Jakob Hahn --------- Signed-off-by: Jakob Hahn Co-authored-by: Daniel (dB.) Doubrovkine --- CHANGELOG.md | 2 + UPGRADING.md | 33 ++++++++ USER_GUIDE.md | 84 +++++++++++-------- opensearchapi/api.bulk.go | 2 +- opensearchapi/api.cat.aliases.go | 2 +- opensearchapi/api.cat.allocation.go | 2 +- opensearchapi/api.cat.cluster_manager.go | 2 +- opensearchapi/api.cat.count.go | 2 +- opensearchapi/api.cat.fielddata.go | 2 +- opensearchapi/api.cat.health.go | 2 +- opensearchapi/api.cat.help.go | 2 +- opensearchapi/api.cat.indices.go | 2 +- opensearchapi/api.cat.master.go | 2 +- opensearchapi/api.cat.nodeattrs.go | 2 +- opensearchapi/api.cat.nodes.go | 2 +- opensearchapi/api.cat.pending_tasks.go | 2 +- opensearchapi/api.cat.plugins.go | 2 +- opensearchapi/api.cat.recovery.go | 2 +- opensearchapi/api.cat.repositories.go | 2 +- opensearchapi/api.cat.segments.go | 2 +- opensearchapi/api.cat.shards.go | 2 +- opensearchapi/api.cat.snapshots.go | 2 +- opensearchapi/api.cat.tasks.go | 2 +- opensearchapi/api.cat.templates.go | 2 +- opensearchapi/api.cat.thread_pool.go | 2 +- opensearchapi/api.clear_scroll.go | 2 +- .../api.cluster.allocation_explain.go | 2 +- .../api.cluster.delete_component_template.go | 2 +- ...cluster.delete_voting_config_exclusions.go | 2 +- .../api.cluster.exists_component_template.go | 2 +- .../api.cluster.get_component_template.go | 2 +- opensearchapi/api.cluster.get_settings.go | 2 +- opensearchapi/api.cluster.health.go | 2 +- opensearchapi/api.cluster.pending_tasks.go | 2 +- ...i.cluster.post_voting_config_exclusions.go | 2 +- .../api.cluster.put_component_template.go | 2 +- opensearchapi/api.cluster.put_settings.go | 2 +- opensearchapi/api.cluster.remote_info.go | 2 +- opensearchapi/api.cluster.reroute.go | 2 +- opensearchapi/api.cluster.state.go | 2 +- opensearchapi/api.cluster.stats.go | 2 +- opensearchapi/api.count.go | 2 +- opensearchapi/api.create.go | 2 +- ....dangling_indices.delete_dangling_index.go | 2 +- ....dangling_indices.import_dangling_index.go | 2 +- ....dangling_indices.list_dangling_indices.go | 2 +- opensearchapi/api.delete.go | 2 +- opensearchapi/api.delete_by_query.go | 2 +- .../api.delete_by_query_rethrottle.go | 2 +- opensearchapi/api.delete_script.go | 2 +- opensearchapi/api.exists.go | 2 +- opensearchapi/api.exists_source.go | 2 +- opensearchapi/api.explain.go | 2 +- opensearchapi/api.field_caps.go | 2 +- opensearchapi/api.get.go | 2 +- opensearchapi/api.get_script.go | 2 +- opensearchapi/api.get_script_context.go | 2 +- opensearchapi/api.get_script_languages.go | 2 +- opensearchapi/api.get_source.go | 2 +- opensearchapi/api.index.go | 2 +- opensearchapi/api.indices.add_block.go | 2 +- opensearchapi/api.indices.analyze.go | 2 +- opensearchapi/api.indices.clear_cache.go | 2 +- opensearchapi/api.indices.clone.go | 2 +- opensearchapi/api.indices.close.go | 2 +- opensearchapi/api.indices.create.go | 2 +- opensearchapi/api.indices.delete.go | 2 +- opensearchapi/api.indices.delete_alias.go | 2 +- .../api.indices.delete_index_template.go | 2 +- opensearchapi/api.indices.delete_template.go | 2 +- opensearchapi/api.indices.disk_usage.go | 2 +- opensearchapi/api.indices.exists.go | 2 +- opensearchapi/api.indices.exists_alias.go | 2 +- .../api.indices.exists_index_template.go | 2 +- opensearchapi/api.indices.exists_template.go | 2 +- .../api.indices.field_usage_stats.go | 2 +- opensearchapi/api.indices.flush.go | 2 +- opensearchapi/api.indices.forcemerge.go | 2 +- opensearchapi/api.indices.get.go | 2 +- opensearchapi/api.indices.get_alias.go | 2 +- .../api.indices.get_field_mapping.go | 2 +- .../api.indices.get_index_template.go | 2 +- opensearchapi/api.indices.get_mapping.go | 2 +- opensearchapi/api.indices.get_settings.go | 2 +- opensearchapi/api.indices.get_template.go | 2 +- opensearchapi/api.indices.get_upgrade.go | 2 +- opensearchapi/api.indices.open.go | 2 +- opensearchapi/api.indices.put_alias.go | 2 +- .../api.indices.put_index_template.go | 2 +- opensearchapi/api.indices.put_mapping.go | 2 +- opensearchapi/api.indices.put_settings.go | 2 +- opensearchapi/api.indices.put_template.go | 2 +- opensearchapi/api.indices.recovery.go | 2 +- opensearchapi/api.indices.refresh.go | 2 +- opensearchapi/api.indices.resolve_index.go | 2 +- opensearchapi/api.indices.rollover.go | 2 +- opensearchapi/api.indices.segments.go | 2 +- opensearchapi/api.indices.shard_stores.go | 2 +- opensearchapi/api.indices.shrink.go | 2 +- .../api.indices.simulate_index_template.go | 2 +- .../api.indices.simulate_template.go | 2 +- opensearchapi/api.indices.split.go | 2 +- opensearchapi/api.indices.stats.go | 2 +- opensearchapi/api.indices.update_aliases.go | 2 +- opensearchapi/api.indices.upgrade.go | 2 +- opensearchapi/api.indices.validate_query.go | 2 +- opensearchapi/api.info.go | 2 +- opensearchapi/api.ingest.delete_pipeline.go | 2 +- opensearchapi/api.ingest.get_pipeline.go | 2 +- opensearchapi/api.ingest.processor_grok.go | 2 +- opensearchapi/api.ingest.put_pipeline.go | 2 +- opensearchapi/api.ingest.simulate.go | 2 +- opensearchapi/api.mget.go | 2 +- opensearchapi/api.msearch.go | 2 +- opensearchapi/api.msearch_template.go | 2 +- opensearchapi/api.mtermvectors.go | 2 +- opensearchapi/api.nodes.hot_threads.go | 2 +- opensearchapi/api.nodes.info.go | 2 +- .../api.nodes.reload_secure_settings.go | 2 +- opensearchapi/api.nodes.stats.go | 2 +- opensearchapi/api.nodes.usage.go | 2 +- opensearchapi/api.ping.go | 2 +- opensearchapi/api.put_script.go | 2 +- opensearchapi/api.rank_eval.go | 2 +- opensearchapi/api.reindex.go | 2 +- opensearchapi/api.reindex_rethrottle.go | 2 +- opensearchapi/api.render_search_template.go | 2 +- opensearchapi/api.scripts_painless_execute.go | 2 +- opensearchapi/api.scroll.go | 2 +- opensearchapi/api.search.go | 2 +- opensearchapi/api.search_shards.go | 2 +- opensearchapi/api.search_template.go | 2 +- .../api.snapshot.cleanup_repository.go | 2 +- opensearchapi/api.snapshot.clone.go | 2 +- opensearchapi/api.snapshot.create.go | 2 +- .../api.snapshot.create_repository.go | 2 +- opensearchapi/api.snapshot.delete.go | 2 +- .../api.snapshot.delete_repository.go | 2 +- opensearchapi/api.snapshot.get.go | 2 +- opensearchapi/api.snapshot.get_repository.go | 2 +- opensearchapi/api.snapshot.restore.go | 2 +- opensearchapi/api.snapshot.status.go | 2 +- .../api.snapshot.verify_repository.go | 2 +- opensearchapi/api.tasks.cancel.go | 2 +- opensearchapi/api.tasks.get.go | 2 +- opensearchapi/api.tasks.list.go | 2 +- opensearchapi/api.terms_enum.go | 2 +- opensearchapi/api.termvectors.go | 2 +- opensearchapi/api.update.go | 2 +- opensearchapi/api.update_by_query.go | 2 +- .../api.update_by_query_rethrottle.go | 2 +- opensearchapi/opensearchapi.error.go | 53 ++++++++++++ opensearchapi/opensearchapi.response.go | 27 ++++-- opensearchapi/opensearchapi_benchmark_test.go | 11 ++- .../opensearchapi_integration_test.go | 29 +------ .../opensearchapi_response_internal_test.go | 55 ++++++++++++ .../json_reader_integration_test.go | 9 +- 157 files changed, 374 insertions(+), 225 deletions(-) create mode 100644 UPGRADING.md create mode 100644 opensearchapi/opensearchapi.error.go diff --git a/CHANGELOG.md b/CHANGELOG.md index e30940e..836c2ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - 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), [#259](https://github.com/opensearch-project/opensearch-go/pull/259)) +- Add Err() function to Response for detailed errors ([#246](https://github.com/opensearch-project/opensearch-go/pull/246)) ### Dependencies @@ -32,6 +33,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Changed - Workflow improvements ([#242](https://github.com/opensearch-project/opensearch-go/pull/242)) +- Opensearchapi check the response for errors ([#246](https://github.com/opensearch-project/opensearch-go/pull/246)) ### Deprecated diff --git a/UPGRADING.md b/UPGRADING.md new file mode 100644 index 0000000..48dc981 --- /dev/null +++ b/UPGRADING.md @@ -0,0 +1,33 @@ +- [Upgrading Opensearch GO Client](#upgrading-opensearch-go-client) + - [Upgraading to >= 3.0.0](#upgrading-to->=-3.0.0) + - [opensearchapi](#opensearchapi-error-handling) + +# Upgrading Opensearch GO Client + +## Upgrading to >= 3.0.0 + +### opensearchapi error handling +With opensearch-go >= 3.0.0 opensearchapi responses are now checked for errors. +Prior versions only returned an error if the request failed to execute. For example if the client can't reach the server or the TLS handshake failed. +With opensearch-go >= 3.0.0 each opensearchapi requests will return an error if the response http status code is > 299. +The error can be parsed into the new opensearchapi.Error type by using `errors.As` to match for exceptions and get a more detailed view. See the example below. + +```go + createIndex := opensearchapi.IndicesCreateRequest{ + Index: IndexName, + Body: mapping, + } + ctx := context.Background() + var opensearchError *opensearchapi.Error + createIndexResponse, err := createIndex.Do(ctx, client) + // Load err into opensearchapi.Error to access the fields and tolerate if the index already exists + if err != nil { + if errors.As(err, &opensearchError) { + if opensearchError.Err.Type != "resource_already_exists_exception" { + return err + } + } else { + return err + } + } +``` diff --git a/USER_GUIDE.md b/USER_GUIDE.md index 58cd71c..7680ed5 100644 --- a/USER_GUIDE.md +++ b/USER_GUIDE.md @@ -13,19 +13,28 @@ search for the document, delete the document and finally delete the index. package main import ( - "os" "context" "crypto/tls" + "errors" "fmt" - opensearch "github.com/opensearch-project/opensearch-go/v2" - opensearchapi "github.com/opensearch-project/opensearch-go/v2/opensearchapi" "net/http" + "os" "strings" + + opensearch "github.com/opensearch-project/opensearch-go/v2" + opensearchapi "github.com/opensearch-project/opensearch-go/v2/opensearchapi" ) const IndexName = "go-test-index1" func main() { + if err := example(); err != nil { + fmt.Println(fmt.Sprintf("Error: %s", err)) + os.Exit(1) + } +} + +func example() error { // Initialize the client with SSL/TLS enabled. client, err := opensearch.NewClient(opensearch.Config{ @@ -37,8 +46,7 @@ func main() { Password: "admin", }) if err != nil { - fmt.Println("cannot initialize", err) - os.Exit(1) + return err } // Print OpenSearch version information on console. @@ -58,10 +66,18 @@ func main() { Index: IndexName, Body: mapping, } - createIndexResponse, err := createIndex.Do(context.Background(), client) + ctx := context.Background() + var opensearchError *opensearchapi.Error + createIndexResponse, err := createIndex.Do(ctx, client) + // Load err into opensearchapi.Error to access the fields and tolerate if the index already exists if err != nil { - fmt.Println("failed to create index ", err) - os.Exit(1) + if errors.As(err, &opensearchError) { + if opensearchError.Err.Type != "resource_already_exists_exception" { + return err + } + } else { + return err + } } fmt.Println(createIndexResponse) @@ -78,10 +94,9 @@ func main() { DocumentID: docId, Body: document, } - insertResponse, err := req.Do(context.Background(), client) + insertResponse, err := req.Do(ctx, client) if err != nil { - fmt.Println("failed to insert document ", err) - os.Exit(1) + return err } fmt.Println(insertResponse) @@ -100,23 +115,21 @@ func main() { Body: content, } - searchResponse, err := search.Do(context.Background(), client) + searchResponse, err := search.Do(ctx, client) if err != nil { - fmt.Println("failed to search document ", err) - os.Exit(1) + return err } fmt.Println(searchResponse) // Delete the document. - delete := opensearchapi.DeleteRequest{ + deleteReq := opensearchapi.DeleteRequest{ Index: IndexName, DocumentID: docId, } - deleteResponse, err := delete.Do(context.Background(), client) + deleteResponse, err := deleteReq.Do(ctx, client) if err != nil { - fmt.Println("failed to delete document ", err) - os.Exit(1) + return err } fmt.Println("deleting document") fmt.Println(deleteResponse) @@ -126,14 +139,26 @@ func main() { Index: []string{IndexName}, } - deleteIndexResponse, err := deleteIndex.Do(context.Background(), client) + deleteIndexResponse, err := deleteIndex.Do(ctx, client) if err != nil { - fmt.Println("failed to delete index ", err) - os.Exit(1) + return err } fmt.Println("deleting index", deleteIndexResponse) -} + // Try to delete the index again which failes as it does not exist + // Load err into opensearchapi.Error to access the fields and tolerate if the index is missing + _, err = deleteIndex.Do(ctx, client) + if err != nil { + if errors.As(err, &opensearchError) { + if opensearchError.Err.Type != "index_not_found_exception" { + return err + } + } else { + return err + } + } + return nil +} ``` ## Amazon OpenSearch Service @@ -207,17 +232,6 @@ func main() { } defer resp.Body.Close() - if resp.IsError() { - log.Printf("ping response status: %q", resp.Status()) - - respBody, err := io.ReadAll(resp.Body) - if err != nil { - log.Fatalf("failed to read response body body: %v", err) - } - - log.Fatalf("ping resp body: %s", respBody) - } - log.Println("PING OK") } ``` @@ -287,7 +301,7 @@ func main() { Index: indexName, Body: mapping, } - createIndexResponse, err := createIndex.Do(context.Background(), client) + createIndexResponse, err := createIndex.Do(ctx, client) if err != nil { log.Fatalf("failed to create index: %v", err) } @@ -298,7 +312,7 @@ func main() { Index: []string{indexName}, } - deleteIndexResponse, err := deleteIndex.Do(context.Background(), client) + deleteIndexResponse, err := deleteIndex.Do(ctx, client) if err != nil { log.Fatalf("failed to delete index: %v", err) } diff --git a/opensearchapi/api.bulk.go b/opensearchapi/api.bulk.go index c104f0d..261deb0 100644 --- a/opensearchapi/api.bulk.go +++ b/opensearchapi/api.bulk.go @@ -196,7 +196,7 @@ func (r BulkRequest) Do(ctx context.Context, transport Transport) (*Response, er Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.cat.aliases.go b/opensearchapi/api.cat.aliases.go index 22cb459..608a13c 100644 --- a/opensearchapi/api.cat.aliases.go +++ b/opensearchapi/api.cat.aliases.go @@ -180,7 +180,7 @@ func (r CatAliasesRequest) Do(ctx context.Context, transport Transport) (*Respon Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.cat.allocation.go b/opensearchapi/api.cat.allocation.go index e15739f..ff76b99 100644 --- a/opensearchapi/api.cat.allocation.go +++ b/opensearchapi/api.cat.allocation.go @@ -192,7 +192,7 @@ func (r CatAllocationRequest) Do(ctx context.Context, transport Transport) (*Res Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.cat.cluster_manager.go b/opensearchapi/api.cat.cluster_manager.go index bf8aeaa..1483478 100644 --- a/opensearchapi/api.cat.cluster_manager.go +++ b/opensearchapi/api.cat.cluster_manager.go @@ -156,7 +156,7 @@ func (r CatClusterManagerRequest) Do(ctx context.Context, transport Transport) ( Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.cat.count.go b/opensearchapi/api.cat.count.go index f56f6bc..1991e0d 100644 --- a/opensearchapi/api.cat.count.go +++ b/opensearchapi/api.cat.count.go @@ -171,7 +171,7 @@ func (r CatCountRequest) Do(ctx context.Context, transport Transport) (*Response Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.cat.fielddata.go b/opensearchapi/api.cat.fielddata.go index 931c354..897512e 100644 --- a/opensearchapi/api.cat.fielddata.go +++ b/opensearchapi/api.cat.fielddata.go @@ -180,7 +180,7 @@ func (r CatFielddataRequest) Do(ctx context.Context, transport Transport) (*Resp Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.cat.health.go b/opensearchapi/api.cat.health.go index 3b32976..cadbe67 100644 --- a/opensearchapi/api.cat.health.go +++ b/opensearchapi/api.cat.health.go @@ -172,7 +172,7 @@ func (r CatHealthRequest) Do(ctx context.Context, transport Transport) (*Respons Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.cat.help.go b/opensearchapi/api.cat.help.go index 4663cfd..1489e23 100644 --- a/opensearchapi/api.cat.help.go +++ b/opensearchapi/api.cat.help.go @@ -146,7 +146,7 @@ func (r CatHelpRequest) Do(ctx context.Context, transport Transport) (*Response, Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.cat.indices.go b/opensearchapi/api.cat.indices.go index 5c051b4..71b2c33 100644 --- a/opensearchapi/api.cat.indices.go +++ b/opensearchapi/api.cat.indices.go @@ -216,7 +216,7 @@ func (r CatIndicesRequest) Do(ctx context.Context, transport Transport) (*Respon Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.cat.master.go b/opensearchapi/api.cat.master.go index 9fd681b..cea90de 100644 --- a/opensearchapi/api.cat.master.go +++ b/opensearchapi/api.cat.master.go @@ -175,7 +175,7 @@ func (r CatMasterRequest) Do(ctx context.Context, transport Transport) (*Respons Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.cat.nodeattrs.go b/opensearchapi/api.cat.nodeattrs.go index a6fe516..7468b35 100644 --- a/opensearchapi/api.cat.nodeattrs.go +++ b/opensearchapi/api.cat.nodeattrs.go @@ -177,7 +177,7 @@ func (r CatNodeattrsRequest) Do(ctx context.Context, transport Transport) (*Resp Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.cat.nodes.go b/opensearchapi/api.cat.nodes.go index dd39e83..90d7703 100644 --- a/opensearchapi/api.cat.nodes.go +++ b/opensearchapi/api.cat.nodes.go @@ -197,7 +197,7 @@ func (r CatNodesRequest) Do(ctx context.Context, transport Transport) (*Response Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.cat.pending_tasks.go b/opensearchapi/api.cat.pending_tasks.go index e662651..992dae7 100644 --- a/opensearchapi/api.cat.pending_tasks.go +++ b/opensearchapi/api.cat.pending_tasks.go @@ -182,7 +182,7 @@ func (r CatPendingTasksRequest) Do(ctx context.Context, transport Transport) (*R Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.cat.plugins.go b/opensearchapi/api.cat.plugins.go index 3805a20..bc8b1e6 100644 --- a/opensearchapi/api.cat.plugins.go +++ b/opensearchapi/api.cat.plugins.go @@ -182,7 +182,7 @@ func (r CatPluginsRequest) Do(ctx context.Context, transport Transport) (*Respon Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.cat.recovery.go b/opensearchapi/api.cat.recovery.go index 1ab1758..5db0841 100644 --- a/opensearchapi/api.cat.recovery.go +++ b/opensearchapi/api.cat.recovery.go @@ -194,7 +194,7 @@ func (r CatRecoveryRequest) Do(ctx context.Context, transport Transport) (*Respo Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.cat.repositories.go b/opensearchapi/api.cat.repositories.go index d249335..c7057a9 100644 --- a/opensearchapi/api.cat.repositories.go +++ b/opensearchapi/api.cat.repositories.go @@ -177,7 +177,7 @@ func (r CatRepositoriesRequest) Do(ctx context.Context, transport Transport) (*R Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.cat.segments.go b/opensearchapi/api.cat.segments.go index 1ee4ab8..aed566e 100644 --- a/opensearchapi/api.cat.segments.go +++ b/opensearchapi/api.cat.segments.go @@ -175,7 +175,7 @@ func (r CatSegmentsRequest) Do(ctx context.Context, transport Transport) (*Respo Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.cat.shards.go b/opensearchapi/api.cat.shards.go index 2320451..9d65493 100644 --- a/opensearchapi/api.cat.shards.go +++ b/opensearchapi/api.cat.shards.go @@ -196,7 +196,7 @@ func (r CatShardsRequest) Do(ctx context.Context, transport Transport) (*Respons Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.cat.snapshots.go b/opensearchapi/api.cat.snapshots.go index 08d680a..1c8e402 100644 --- a/opensearchapi/api.cat.snapshots.go +++ b/opensearchapi/api.cat.snapshots.go @@ -191,7 +191,7 @@ func (r CatSnapshotsRequest) Do(ctx context.Context, transport Transport) (*Resp Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.cat.tasks.go b/opensearchapi/api.cat.tasks.go index 32412b7..3592808 100644 --- a/opensearchapi/api.cat.tasks.go +++ b/opensearchapi/api.cat.tasks.go @@ -186,7 +186,7 @@ func (r CatTasksRequest) Do(ctx context.Context, transport Transport) (*Response Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.cat.templates.go b/opensearchapi/api.cat.templates.go index 0f0f75e..c4d343e 100644 --- a/opensearchapi/api.cat.templates.go +++ b/opensearchapi/api.cat.templates.go @@ -186,7 +186,7 @@ func (r CatTemplatesRequest) Do(ctx context.Context, transport Transport) (*Resp Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.cat.thread_pool.go b/opensearchapi/api.cat.thread_pool.go index a3e572f..fb1ea0d 100644 --- a/opensearchapi/api.cat.thread_pool.go +++ b/opensearchapi/api.cat.thread_pool.go @@ -192,7 +192,7 @@ func (r CatThreadPoolRequest) Do(ctx context.Context, transport Transport) (*Res Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.clear_scroll.go b/opensearchapi/api.clear_scroll.go index c205171..4fe1660 100644 --- a/opensearchapi/api.clear_scroll.go +++ b/opensearchapi/api.clear_scroll.go @@ -150,7 +150,7 @@ func (r ClearScrollRequest) Do(ctx context.Context, transport Transport) (*Respo Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.cluster.allocation_explain.go b/opensearchapi/api.cluster.allocation_explain.go index 7da7ce7..089f13b 100644 --- a/opensearchapi/api.cluster.allocation_explain.go +++ b/opensearchapi/api.cluster.allocation_explain.go @@ -153,7 +153,7 @@ func (r ClusterAllocationExplainRequest) Do(ctx context.Context, transport Trans Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.cluster.delete_component_template.go b/opensearchapi/api.cluster.delete_component_template.go index f7e8d38..4078486 100644 --- a/opensearchapi/api.cluster.delete_component_template.go +++ b/opensearchapi/api.cluster.delete_component_template.go @@ -156,7 +156,7 @@ func (r ClusterDeleteComponentTemplateRequest) Do(ctx context.Context, transport Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.cluster.delete_voting_config_exclusions.go b/opensearchapi/api.cluster.delete_voting_config_exclusions.go index 046b080..dcc7d88 100644 --- a/opensearchapi/api.cluster.delete_voting_config_exclusions.go +++ b/opensearchapi/api.cluster.delete_voting_config_exclusions.go @@ -141,7 +141,7 @@ func (r ClusterDeleteVotingConfigExclusionsRequest) Do(ctx context.Context, tran Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.cluster.exists_component_template.go b/opensearchapi/api.cluster.exists_component_template.go index 36c951c..d1fb93b 100644 --- a/opensearchapi/api.cluster.exists_component_template.go +++ b/opensearchapi/api.cluster.exists_component_template.go @@ -157,7 +157,7 @@ func (r ClusterExistsComponentTemplateRequest) Do(ctx context.Context, transport Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.cluster.get_component_template.go b/opensearchapi/api.cluster.get_component_template.go index 9e97ce8..b883b8f 100644 --- a/opensearchapi/api.cluster.get_component_template.go +++ b/opensearchapi/api.cluster.get_component_template.go @@ -159,7 +159,7 @@ func (r ClusterGetComponentTemplateRequest) Do(ctx context.Context, transport Tr Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.cluster.get_settings.go b/opensearchapi/api.cluster.get_settings.go index bdf565f..fd0608f 100644 --- a/opensearchapi/api.cluster.get_settings.go +++ b/opensearchapi/api.cluster.get_settings.go @@ -162,7 +162,7 @@ func (r ClusterGetSettingsRequest) Do(ctx context.Context, transport Transport) Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.cluster.health.go b/opensearchapi/api.cluster.health.go index 4cdc833..05869c5 100644 --- a/opensearchapi/api.cluster.health.go +++ b/opensearchapi/api.cluster.health.go @@ -206,7 +206,7 @@ func (r ClusterHealthRequest) Do(ctx context.Context, transport Transport) (*Res Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.cluster.pending_tasks.go b/opensearchapi/api.cluster.pending_tasks.go index 9039cc2..4004065 100644 --- a/opensearchapi/api.cluster.pending_tasks.go +++ b/opensearchapi/api.cluster.pending_tasks.go @@ -153,7 +153,7 @@ func (r ClusterPendingTasksRequest) Do(ctx context.Context, transport Transport) Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.cluster.post_voting_config_exclusions.go b/opensearchapi/api.cluster.post_voting_config_exclusions.go index 63692fc..dcc341b 100644 --- a/opensearchapi/api.cluster.post_voting_config_exclusions.go +++ b/opensearchapi/api.cluster.post_voting_config_exclusions.go @@ -151,7 +151,7 @@ func (r ClusterPostVotingConfigExclusionsRequest) Do(ctx context.Context, transp Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.cluster.put_component_template.go b/opensearchapi/api.cluster.put_component_template.go index ac12663..1b003d6 100644 --- a/opensearchapi/api.cluster.put_component_template.go +++ b/opensearchapi/api.cluster.put_component_template.go @@ -169,7 +169,7 @@ func (r ClusterPutComponentTemplateRequest) Do(ctx context.Context, transport Tr Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.cluster.put_settings.go b/opensearchapi/api.cluster.put_settings.go index a898de3..ed01b6f 100644 --- a/opensearchapi/api.cluster.put_settings.go +++ b/opensearchapi/api.cluster.put_settings.go @@ -164,7 +164,7 @@ func (r ClusterPutSettingsRequest) Do(ctx context.Context, transport Transport) Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.cluster.remote_info.go b/opensearchapi/api.cluster.remote_info.go index c35166b..5e1fc95 100644 --- a/opensearchapi/api.cluster.remote_info.go +++ b/opensearchapi/api.cluster.remote_info.go @@ -134,7 +134,7 @@ func (r ClusterRemoteInfoRequest) Do(ctx context.Context, transport Transport) ( Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.cluster.reroute.go b/opensearchapi/api.cluster.reroute.go index a5d0be0..a0f3d1b 100644 --- a/opensearchapi/api.cluster.reroute.go +++ b/opensearchapi/api.cluster.reroute.go @@ -179,7 +179,7 @@ func (r ClusterRerouteRequest) Do(ctx context.Context, transport Transport) (*Re Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.cluster.state.go b/opensearchapi/api.cluster.state.go index 211c39e..520a901 100644 --- a/opensearchapi/api.cluster.state.go +++ b/opensearchapi/api.cluster.state.go @@ -197,7 +197,7 @@ func (r ClusterStateRequest) Do(ctx context.Context, transport Transport) (*Resp Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.cluster.stats.go b/opensearchapi/api.cluster.stats.go index a400678..f76d38f 100644 --- a/opensearchapi/api.cluster.stats.go +++ b/opensearchapi/api.cluster.stats.go @@ -158,7 +158,7 @@ func (r ClusterStatsRequest) Do(ctx context.Context, transport Transport) (*Resp Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.count.go b/opensearchapi/api.count.go index 8f17475..b38aff0 100644 --- a/opensearchapi/api.count.go +++ b/opensearchapi/api.count.go @@ -220,7 +220,7 @@ func (r CountRequest) Do(ctx context.Context, transport Transport) (*Response, e Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.create.go b/opensearchapi/api.create.go index c247307..f86efa9 100644 --- a/opensearchapi/api.create.go +++ b/opensearchapi/api.create.go @@ -189,7 +189,7 @@ func (r CreateRequest) Do(ctx context.Context, transport Transport) (*Response, Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.dangling_indices.delete_dangling_index.go b/opensearchapi/api.dangling_indices.delete_dangling_index.go index 33c4588..c5c5ee1 100644 --- a/opensearchapi/api.dangling_indices.delete_dangling_index.go +++ b/opensearchapi/api.dangling_indices.delete_dangling_index.go @@ -162,7 +162,7 @@ func (r DanglingIndicesDeleteDanglingIndexRequest) Do(ctx context.Context, trans Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.dangling_indices.import_dangling_index.go b/opensearchapi/api.dangling_indices.import_dangling_index.go index e251b43..a7cba7d 100644 --- a/opensearchapi/api.dangling_indices.import_dangling_index.go +++ b/opensearchapi/api.dangling_indices.import_dangling_index.go @@ -162,7 +162,7 @@ func (r DanglingIndicesImportDanglingIndexRequest) Do(ctx context.Context, trans Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.dangling_indices.list_dangling_indices.go b/opensearchapi/api.dangling_indices.list_dangling_indices.go index a452377..f54af68 100644 --- a/opensearchapi/api.dangling_indices.list_dangling_indices.go +++ b/opensearchapi/api.dangling_indices.list_dangling_indices.go @@ -134,7 +134,7 @@ func (r DanglingIndicesListDanglingIndicesRequest) Do(ctx context.Context, trans Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.delete.go b/opensearchapi/api.delete.go index f3a9040..f264453 100644 --- a/opensearchapi/api.delete.go +++ b/opensearchapi/api.delete.go @@ -184,7 +184,7 @@ func (r DeleteRequest) Do(ctx context.Context, transport Transport) (*Response, Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.delete_by_query.go b/opensearchapi/api.delete_by_query.go index 371378a..0e9509b 100644 --- a/opensearchapi/api.delete_by_query.go +++ b/opensearchapi/api.delete_by_query.go @@ -315,7 +315,7 @@ func (r DeleteByQueryRequest) Do(ctx context.Context, transport Transport) (*Res Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.delete_by_query_rethrottle.go b/opensearchapi/api.delete_by_query_rethrottle.go index befdf5a..63f9886 100644 --- a/opensearchapi/api.delete_by_query_rethrottle.go +++ b/opensearchapi/api.delete_by_query_rethrottle.go @@ -148,7 +148,7 @@ func (r DeleteByQueryRethrottleRequest) Do(ctx context.Context, transport Transp Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.delete_script.go b/opensearchapi/api.delete_script.go index 3f8e385..af1a031 100644 --- a/opensearchapi/api.delete_script.go +++ b/opensearchapi/api.delete_script.go @@ -156,7 +156,7 @@ func (r DeleteScriptRequest) Do(ctx context.Context, transport Transport) (*Resp Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.exists.go b/opensearchapi/api.exists.go index ab53f42..7f2eb1b 100644 --- a/opensearchapi/api.exists.go +++ b/opensearchapi/api.exists.go @@ -193,7 +193,7 @@ func (r ExistsRequest) Do(ctx context.Context, transport Transport) (*Response, Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.exists_source.go b/opensearchapi/api.exists_source.go index d154faf..0ae58dc 100644 --- a/opensearchapi/api.exists_source.go +++ b/opensearchapi/api.exists_source.go @@ -189,7 +189,7 @@ func (r ExistsSourceRequest) Do(ctx context.Context, transport Transport) (*Resp Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.explain.go b/opensearchapi/api.explain.go index ea80dea..0d7440b 100644 --- a/opensearchapi/api.explain.go +++ b/opensearchapi/api.explain.go @@ -211,7 +211,7 @@ func (r ExplainRequest) Do(ctx context.Context, transport Transport) (*Response, Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.field_caps.go b/opensearchapi/api.field_caps.go index 5dfedc8..2ab0d86 100644 --- a/opensearchapi/api.field_caps.go +++ b/opensearchapi/api.field_caps.go @@ -175,7 +175,7 @@ func (r FieldCapsRequest) Do(ctx context.Context, transport Transport) (*Respons Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.get.go b/opensearchapi/api.get.go index 36612f9..4f3ba38 100644 --- a/opensearchapi/api.get.go +++ b/opensearchapi/api.get.go @@ -193,7 +193,7 @@ func (r GetRequest) Do(ctx context.Context, transport Transport) (*Response, err Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.get_script.go b/opensearchapi/api.get_script.go index 9a8be7f..759a90c 100644 --- a/opensearchapi/api.get_script.go +++ b/opensearchapi/api.get_script.go @@ -151,7 +151,7 @@ func (r GetScriptRequest) Do(ctx context.Context, transport Transport) (*Respons Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.get_script_context.go b/opensearchapi/api.get_script_context.go index 769a3d0..6b04e18 100644 --- a/opensearchapi/api.get_script_context.go +++ b/opensearchapi/api.get_script_context.go @@ -136,7 +136,7 @@ func (r GetScriptContextRequest) Do(ctx context.Context, transport Transport) (* Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.get_script_languages.go b/opensearchapi/api.get_script_languages.go index 647bc8e..919beaf 100644 --- a/opensearchapi/api.get_script_languages.go +++ b/opensearchapi/api.get_script_languages.go @@ -136,7 +136,7 @@ func (r GetScriptLanguagesRequest) Do(ctx context.Context, transport Transport) Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.get_source.go b/opensearchapi/api.get_source.go index 9a7dc12..42341db 100644 --- a/opensearchapi/api.get_source.go +++ b/opensearchapi/api.get_source.go @@ -189,7 +189,7 @@ func (r GetSourceRequest) Do(ctx context.Context, transport Transport) (*Respons Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.index.go b/opensearchapi/api.index.go index 2f7c049..b4044ee 100644 --- a/opensearchapi/api.index.go +++ b/opensearchapi/api.index.go @@ -212,7 +212,7 @@ func (r IndexRequest) Do(ctx context.Context, transport Transport) (*Response, e Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.add_block.go b/opensearchapi/api.indices.add_block.go index 59ee03c..5a8705b 100644 --- a/opensearchapi/api.indices.add_block.go +++ b/opensearchapi/api.indices.add_block.go @@ -176,7 +176,7 @@ func (r IndicesAddBlockRequest) Do(ctx context.Context, transport Transport) (*R Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.analyze.go b/opensearchapi/api.indices.analyze.go index e3f039d..cd8029d 100644 --- a/opensearchapi/api.indices.analyze.go +++ b/opensearchapi/api.indices.analyze.go @@ -152,7 +152,7 @@ func (r IndicesAnalyzeRequest) Do(ctx context.Context, transport Transport) (*Re Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.clear_cache.go b/opensearchapi/api.indices.clear_cache.go index f3ce8ce..dd62c87 100644 --- a/opensearchapi/api.indices.clear_cache.go +++ b/opensearchapi/api.indices.clear_cache.go @@ -184,7 +184,7 @@ func (r IndicesClearCacheRequest) Do(ctx context.Context, transport Transport) ( Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.clone.go b/opensearchapi/api.indices.clone.go index ce98843..2c1bce0 100644 --- a/opensearchapi/api.indices.clone.go +++ b/opensearchapi/api.indices.clone.go @@ -172,7 +172,7 @@ func (r IndicesCloneRequest) Do(ctx context.Context, transport Transport) (*Resp Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.close.go b/opensearchapi/api.indices.close.go index 830b104..9ed4e2a 100644 --- a/opensearchapi/api.indices.close.go +++ b/opensearchapi/api.indices.close.go @@ -177,7 +177,7 @@ func (r IndicesCloseRequest) Do(ctx context.Context, transport Transport) (*Resp Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.create.go b/opensearchapi/api.indices.create.go index 93b4aac..bee47ff 100644 --- a/opensearchapi/api.indices.create.go +++ b/opensearchapi/api.indices.create.go @@ -166,7 +166,7 @@ func (r IndicesCreateRequest) Do(ctx context.Context, transport Transport) (*Res Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.delete.go b/opensearchapi/api.indices.delete.go index 92544be..96ffaa6 100644 --- a/opensearchapi/api.indices.delete.go +++ b/opensearchapi/api.indices.delete.go @@ -170,7 +170,7 @@ func (r IndicesDeleteRequest) Do(ctx context.Context, transport Transport) (*Res Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.delete_alias.go b/opensearchapi/api.indices.delete_alias.go index ee8dcd6..069e4e0 100644 --- a/opensearchapi/api.indices.delete_alias.go +++ b/opensearchapi/api.indices.delete_alias.go @@ -160,7 +160,7 @@ func (r IndicesDeleteAliasRequest) Do(ctx context.Context, transport Transport) Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.delete_index_template.go b/opensearchapi/api.indices.delete_index_template.go index 777e101..82a60a0 100644 --- a/opensearchapi/api.indices.delete_index_template.go +++ b/opensearchapi/api.indices.delete_index_template.go @@ -156,7 +156,7 @@ func (r IndicesDeleteIndexTemplateRequest) Do(ctx context.Context, transport Tra Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.delete_template.go b/opensearchapi/api.indices.delete_template.go index 7a9b2ca..f789c9a 100644 --- a/opensearchapi/api.indices.delete_template.go +++ b/opensearchapi/api.indices.delete_template.go @@ -156,7 +156,7 @@ func (r IndicesDeleteTemplateRequest) Do(ctx context.Context, transport Transpor Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.disk_usage.go b/opensearchapi/api.indices.disk_usage.go index da3ac56..b3c12c9 100644 --- a/opensearchapi/api.indices.disk_usage.go +++ b/opensearchapi/api.indices.disk_usage.go @@ -168,7 +168,7 @@ func (r IndicesDiskUsageRequest) Do(ctx context.Context, transport Transport) (* Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.exists.go b/opensearchapi/api.indices.exists.go index 70f6d04..fc3fd29 100644 --- a/opensearchapi/api.indices.exists.go +++ b/opensearchapi/api.indices.exists.go @@ -169,7 +169,7 @@ func (r IndicesExistsRequest) Do(ctx context.Context, transport Transport) (*Res Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.exists_alias.go b/opensearchapi/api.indices.exists_alias.go index a878227..6302004 100644 --- a/opensearchapi/api.indices.exists_alias.go +++ b/opensearchapi/api.indices.exists_alias.go @@ -167,7 +167,7 @@ func (r IndicesExistsAliasRequest) Do(ctx context.Context, transport Transport) Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.exists_index_template.go b/opensearchapi/api.indices.exists_index_template.go index 901f0fe..bcc501f 100644 --- a/opensearchapi/api.indices.exists_index_template.go +++ b/opensearchapi/api.indices.exists_index_template.go @@ -162,7 +162,7 @@ func (r IndicesExistsIndexTemplateRequest) Do(ctx context.Context, transport Tra Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.exists_template.go b/opensearchapi/api.indices.exists_template.go index 89e6049..096c977 100644 --- a/opensearchapi/api.indices.exists_template.go +++ b/opensearchapi/api.indices.exists_template.go @@ -162,7 +162,7 @@ func (r IndicesExistsTemplateRequest) Do(ctx context.Context, transport Transpor Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.field_usage_stats.go b/opensearchapi/api.indices.field_usage_stats.go index d4a8130..24577e3 100644 --- a/opensearchapi/api.indices.field_usage_stats.go +++ b/opensearchapi/api.indices.field_usage_stats.go @@ -163,7 +163,7 @@ func (r IndicesFieldUsageStatsRequest) Do(ctx context.Context, transport Transpo Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.flush.go b/opensearchapi/api.indices.flush.go index 347d474..be820c8 100644 --- a/opensearchapi/api.indices.flush.go +++ b/opensearchapi/api.indices.flush.go @@ -168,7 +168,7 @@ func (r IndicesFlushRequest) Do(ctx context.Context, transport Transport) (*Resp Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.forcemerge.go b/opensearchapi/api.indices.forcemerge.go index 712cb6d..7fcd4ca 100644 --- a/opensearchapi/api.indices.forcemerge.go +++ b/opensearchapi/api.indices.forcemerge.go @@ -173,7 +173,7 @@ func (r IndicesForcemergeRequest) Do(ctx context.Context, transport Transport) ( Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.get.go b/opensearchapi/api.indices.get.go index 86b2574..e9819bc 100644 --- a/opensearchapi/api.indices.get.go +++ b/opensearchapi/api.indices.get.go @@ -180,7 +180,7 @@ func (r IndicesGetRequest) Do(ctx context.Context, transport Transport) (*Respon Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.get_alias.go b/opensearchapi/api.indices.get_alias.go index 420b2fa..38d4dcf 100644 --- a/opensearchapi/api.indices.get_alias.go +++ b/opensearchapi/api.indices.get_alias.go @@ -169,7 +169,7 @@ func (r IndicesGetAliasRequest) Do(ctx context.Context, transport Transport) (*R Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.get_field_mapping.go b/opensearchapi/api.indices.get_field_mapping.go index 911b519..fb161ea 100644 --- a/opensearchapi/api.indices.get_field_mapping.go +++ b/opensearchapi/api.indices.get_field_mapping.go @@ -174,7 +174,7 @@ func (r IndicesGetFieldMappingRequest) Do(ctx context.Context, transport Transpo Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.get_index_template.go b/opensearchapi/api.indices.get_index_template.go index c17e15e..6ad2168 100644 --- a/opensearchapi/api.indices.get_index_template.go +++ b/opensearchapi/api.indices.get_index_template.go @@ -164,7 +164,7 @@ func (r IndicesGetIndexTemplateRequest) Do(ctx context.Context, transport Transp Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.get_mapping.go b/opensearchapi/api.indices.get_mapping.go index c407a8e..716640d 100644 --- a/opensearchapi/api.indices.get_mapping.go +++ b/opensearchapi/api.indices.get_mapping.go @@ -173,7 +173,7 @@ func (r IndicesGetMappingRequest) Do(ctx context.Context, transport Transport) ( Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.get_settings.go b/opensearchapi/api.indices.get_settings.go index 816202c..d97b110 100644 --- a/opensearchapi/api.indices.get_settings.go +++ b/opensearchapi/api.indices.get_settings.go @@ -190,7 +190,7 @@ func (r IndicesGetSettingsRequest) Do(ctx context.Context, transport Transport) Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.get_template.go b/opensearchapi/api.indices.get_template.go index 67eb151..a7d3862 100644 --- a/opensearchapi/api.indices.get_template.go +++ b/opensearchapi/api.indices.get_template.go @@ -164,7 +164,7 @@ func (r IndicesGetTemplateRequest) Do(ctx context.Context, transport Transport) Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.get_upgrade.go b/opensearchapi/api.indices.get_upgrade.go index b18843d..04fb222 100644 --- a/opensearchapi/api.indices.get_upgrade.go +++ b/opensearchapi/api.indices.get_upgrade.go @@ -158,7 +158,7 @@ func (r IndicesGetUpgradeRequest) Do(ctx context.Context, transport Transport) ( Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.open.go b/opensearchapi/api.indices.open.go index a020f3e..e444d34 100644 --- a/opensearchapi/api.indices.open.go +++ b/opensearchapi/api.indices.open.go @@ -177,7 +177,7 @@ func (r IndicesOpenRequest) Do(ctx context.Context, transport Transport) (*Respo Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.put_alias.go b/opensearchapi/api.indices.put_alias.go index bf0a9a0..f0504be 100644 --- a/opensearchapi/api.indices.put_alias.go +++ b/opensearchapi/api.indices.put_alias.go @@ -167,7 +167,7 @@ func (r IndicesPutAliasRequest) Do(ctx context.Context, transport Transport) (*R Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.put_index_template.go b/opensearchapi/api.indices.put_index_template.go index e34c6c7..2ce8837 100644 --- a/opensearchapi/api.indices.put_index_template.go +++ b/opensearchapi/api.indices.put_index_template.go @@ -169,7 +169,7 @@ func (r IndicesPutIndexTemplateRequest) Do(ctx context.Context, transport Transp Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.put_mapping.go b/opensearchapi/api.indices.put_mapping.go index e7d721c..d1f09c3 100644 --- a/opensearchapi/api.indices.put_mapping.go +++ b/opensearchapi/api.indices.put_mapping.go @@ -186,7 +186,7 @@ func (r IndicesPutMappingRequest) Do(ctx context.Context, transport Transport) ( Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.put_settings.go b/opensearchapi/api.indices.put_settings.go index 711dd61..370fa31 100644 --- a/opensearchapi/api.indices.put_settings.go +++ b/opensearchapi/api.indices.put_settings.go @@ -191,7 +191,7 @@ func (r IndicesPutSettingsRequest) Do(ctx context.Context, transport Transport) Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.put_template.go b/opensearchapi/api.indices.put_template.go index 34a3a6b..2329a34 100644 --- a/opensearchapi/api.indices.put_template.go +++ b/opensearchapi/api.indices.put_template.go @@ -169,7 +169,7 @@ func (r IndicesPutTemplateRequest) Do(ctx context.Context, transport Transport) Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.recovery.go b/opensearchapi/api.indices.recovery.go index af634d6..c0e636a 100644 --- a/opensearchapi/api.indices.recovery.go +++ b/opensearchapi/api.indices.recovery.go @@ -153,7 +153,7 @@ func (r IndicesRecoveryRequest) Do(ctx context.Context, transport Transport) (*R Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.refresh.go b/opensearchapi/api.indices.refresh.go index f666309..4cd2dc6 100644 --- a/opensearchapi/api.indices.refresh.go +++ b/opensearchapi/api.indices.refresh.go @@ -158,7 +158,7 @@ func (r IndicesRefreshRequest) Do(ctx context.Context, transport Transport) (*Re Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.resolve_index.go b/opensearchapi/api.indices.resolve_index.go index 1411d98..2678e0f 100644 --- a/opensearchapi/api.indices.resolve_index.go +++ b/opensearchapi/api.indices.resolve_index.go @@ -149,7 +149,7 @@ func (r IndicesResolveIndexRequest) Do(ctx context.Context, transport Transport) Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.rollover.go b/opensearchapi/api.indices.rollover.go index 4c3f8c3..3b291b4 100644 --- a/opensearchapi/api.indices.rollover.go +++ b/opensearchapi/api.indices.rollover.go @@ -180,7 +180,7 @@ func (r IndicesRolloverRequest) Do(ctx context.Context, transport Transport) (*R Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.segments.go b/opensearchapi/api.indices.segments.go index 60367e3..0ac2723 100644 --- a/opensearchapi/api.indices.segments.go +++ b/opensearchapi/api.indices.segments.go @@ -163,7 +163,7 @@ func (r IndicesSegmentsRequest) Do(ctx context.Context, transport Transport) (*R Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.shard_stores.go b/opensearchapi/api.indices.shard_stores.go index 181c0bc..8e6bb57 100644 --- a/opensearchapi/api.indices.shard_stores.go +++ b/opensearchapi/api.indices.shard_stores.go @@ -163,7 +163,7 @@ func (r IndicesShardStoresRequest) Do(ctx context.Context, transport Transport) Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.shrink.go b/opensearchapi/api.indices.shrink.go index 11763b3..685cf6b 100644 --- a/opensearchapi/api.indices.shrink.go +++ b/opensearchapi/api.indices.shrink.go @@ -178,7 +178,7 @@ func (r IndicesShrinkRequest) Do(ctx context.Context, transport Transport) (*Res Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.simulate_index_template.go b/opensearchapi/api.indices.simulate_index_template.go index 770f1d9..2912ffd 100644 --- a/opensearchapi/api.indices.simulate_index_template.go +++ b/opensearchapi/api.indices.simulate_index_template.go @@ -171,7 +171,7 @@ func (r IndicesSimulateIndexTemplateRequest) Do(ctx context.Context, transport T Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.simulate_template.go b/opensearchapi/api.indices.simulate_template.go index 9808f2c..aeb5738 100644 --- a/opensearchapi/api.indices.simulate_template.go +++ b/opensearchapi/api.indices.simulate_template.go @@ -173,7 +173,7 @@ func (r IndicesSimulateTemplateRequest) Do(ctx context.Context, transport Transp Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.split.go b/opensearchapi/api.indices.split.go index af2c351..49ea6c5 100644 --- a/opensearchapi/api.indices.split.go +++ b/opensearchapi/api.indices.split.go @@ -178,7 +178,7 @@ func (r IndicesSplitRequest) Do(ctx context.Context, transport Transport) (*Resp Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.stats.go b/opensearchapi/api.indices.stats.go index 38065bd..27b55d5 100644 --- a/opensearchapi/api.indices.stats.go +++ b/opensearchapi/api.indices.stats.go @@ -199,7 +199,7 @@ func (r IndicesStatsRequest) Do(ctx context.Context, transport Transport) (*Resp Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.update_aliases.go b/opensearchapi/api.indices.update_aliases.go index cc6cd34..9f3bb77 100644 --- a/opensearchapi/api.indices.update_aliases.go +++ b/opensearchapi/api.indices.update_aliases.go @@ -158,7 +158,7 @@ func (r IndicesUpdateAliasesRequest) Do(ctx context.Context, transport Transport Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.upgrade.go b/opensearchapi/api.indices.upgrade.go index bf8550a..e505b6f 100644 --- a/opensearchapi/api.indices.upgrade.go +++ b/opensearchapi/api.indices.upgrade.go @@ -168,7 +168,7 @@ func (r IndicesUpgradeRequest) Do(ctx context.Context, transport Transport) (*Re Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.indices.validate_query.go b/opensearchapi/api.indices.validate_query.go index 8550dcd..db19a59 100644 --- a/opensearchapi/api.indices.validate_query.go +++ b/opensearchapi/api.indices.validate_query.go @@ -212,7 +212,7 @@ func (r IndicesValidateQueryRequest) Do(ctx context.Context, transport Transport Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.info.go b/opensearchapi/api.info.go index c506a52..77bb5e1 100644 --- a/opensearchapi/api.info.go +++ b/opensearchapi/api.info.go @@ -134,7 +134,7 @@ func (r InfoRequest) Do(ctx context.Context, transport Transport) (*Response, er Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.ingest.delete_pipeline.go b/opensearchapi/api.ingest.delete_pipeline.go index beeebe3..1e8dd1e 100644 --- a/opensearchapi/api.ingest.delete_pipeline.go +++ b/opensearchapi/api.ingest.delete_pipeline.go @@ -158,7 +158,7 @@ func (r IngestDeletePipelineRequest) Do(ctx context.Context, transport Transport Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.ingest.get_pipeline.go b/opensearchapi/api.ingest.get_pipeline.go index b0f3bae..bbfd417 100644 --- a/opensearchapi/api.ingest.get_pipeline.go +++ b/opensearchapi/api.ingest.get_pipeline.go @@ -161,7 +161,7 @@ func (r IngestGetPipelineRequest) Do(ctx context.Context, transport Transport) ( Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.ingest.processor_grok.go b/opensearchapi/api.ingest.processor_grok.go index 978dbee..af506ab 100644 --- a/opensearchapi/api.ingest.processor_grok.go +++ b/opensearchapi/api.ingest.processor_grok.go @@ -134,7 +134,7 @@ func (r IngestProcessorGrokRequest) Do(ctx context.Context, transport Transport) Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.ingest.put_pipeline.go b/opensearchapi/api.ingest.put_pipeline.go index d8343f3..5a0bea0 100644 --- a/opensearchapi/api.ingest.put_pipeline.go +++ b/opensearchapi/api.ingest.put_pipeline.go @@ -165,7 +165,7 @@ func (r IngestPutPipelineRequest) Do(ctx context.Context, transport Transport) ( Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.ingest.simulate.go b/opensearchapi/api.ingest.simulate.go index 682b8d3..926d019 100644 --- a/opensearchapi/api.ingest.simulate.go +++ b/opensearchapi/api.ingest.simulate.go @@ -159,7 +159,7 @@ func (r IngestSimulateRequest) Do(ctx context.Context, transport Transport) (*Re Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.mget.go b/opensearchapi/api.mget.go index 4d38484..6555a65 100644 --- a/opensearchapi/api.mget.go +++ b/opensearchapi/api.mget.go @@ -190,7 +190,7 @@ func (r MgetRequest) Do(ctx context.Context, transport Transport) (*Response, er Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.msearch.go b/opensearchapi/api.msearch.go index 9ad3bfa..edbf7e3 100644 --- a/opensearchapi/api.msearch.go +++ b/opensearchapi/api.msearch.go @@ -185,7 +185,7 @@ func (r MsearchRequest) Do(ctx context.Context, transport Transport) (*Response, Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.msearch_template.go b/opensearchapi/api.msearch_template.go index 51a0913..ea73c4e 100644 --- a/opensearchapi/api.msearch_template.go +++ b/opensearchapi/api.msearch_template.go @@ -177,7 +177,7 @@ func (r MsearchTemplateRequest) Do(ctx context.Context, transport Transport) (*R Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.mtermvectors.go b/opensearchapi/api.mtermvectors.go index ba92431..181d01f 100644 --- a/opensearchapi/api.mtermvectors.go +++ b/opensearchapi/api.mtermvectors.go @@ -210,7 +210,7 @@ func (r MtermvectorsRequest) Do(ctx context.Context, transport Transport) (*Resp Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.nodes.hot_threads.go b/opensearchapi/api.nodes.hot_threads.go index d9aaee6..d70906e 100644 --- a/opensearchapi/api.nodes.hot_threads.go +++ b/opensearchapi/api.nodes.hot_threads.go @@ -173,7 +173,7 @@ func (r NodesHotThreadsRequest) Do(ctx context.Context, transport Transport) (*R Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.nodes.info.go b/opensearchapi/api.nodes.info.go index 39b9297..02f6043 100644 --- a/opensearchapi/api.nodes.info.go +++ b/opensearchapi/api.nodes.info.go @@ -159,7 +159,7 @@ func (r NodesInfoRequest) Do(ctx context.Context, transport Transport) (*Respons Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.nodes.reload_secure_settings.go b/opensearchapi/api.nodes.reload_secure_settings.go index 9030f02..e210ba0 100644 --- a/opensearchapi/api.nodes.reload_secure_settings.go +++ b/opensearchapi/api.nodes.reload_secure_settings.go @@ -157,7 +157,7 @@ func (r NodesReloadSecureSettingsRequest) Do(ctx context.Context, transport Tran Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.nodes.stats.go b/opensearchapi/api.nodes.stats.go index 6021814..80899e1 100644 --- a/opensearchapi/api.nodes.stats.go +++ b/opensearchapi/api.nodes.stats.go @@ -201,7 +201,7 @@ func (r NodesStatsRequest) Do(ctx context.Context, transport Transport) (*Respon Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.nodes.usage.go b/opensearchapi/api.nodes.usage.go index 25db932..0d2d896 100644 --- a/opensearchapi/api.nodes.usage.go +++ b/opensearchapi/api.nodes.usage.go @@ -155,7 +155,7 @@ func (r NodesUsageRequest) Do(ctx context.Context, transport Transport) (*Respon Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.ping.go b/opensearchapi/api.ping.go index f30ef61..b80ed16 100644 --- a/opensearchapi/api.ping.go +++ b/opensearchapi/api.ping.go @@ -134,7 +134,7 @@ func (r PingRequest) Do(ctx context.Context, transport Transport) (*Response, er Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.put_script.go b/opensearchapi/api.put_script.go index 48a1f67..c8dea2d 100644 --- a/opensearchapi/api.put_script.go +++ b/opensearchapi/api.put_script.go @@ -173,7 +173,7 @@ func (r PutScriptRequest) Do(ctx context.Context, transport Transport) (*Respons Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.rank_eval.go b/opensearchapi/api.rank_eval.go index 68a819e..94489a2 100644 --- a/opensearchapi/api.rank_eval.go +++ b/opensearchapi/api.rank_eval.go @@ -172,7 +172,7 @@ func (r RankEvalRequest) Do(ctx context.Context, transport Transport) (*Response Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.reindex.go b/opensearchapi/api.reindex.go index 2311ecb..0bccd51 100644 --- a/opensearchapi/api.reindex.go +++ b/opensearchapi/api.reindex.go @@ -187,7 +187,7 @@ func (r ReindexRequest) Do(ctx context.Context, transport Transport) (*Response, Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.reindex_rethrottle.go b/opensearchapi/api.reindex_rethrottle.go index f51b414..bc4fb55 100644 --- a/opensearchapi/api.reindex_rethrottle.go +++ b/opensearchapi/api.reindex_rethrottle.go @@ -148,7 +148,7 @@ func (r ReindexRethrottleRequest) Do(ctx context.Context, transport Transport) ( Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.render_search_template.go b/opensearchapi/api.render_search_template.go index d5ddfdb..02a293a 100644 --- a/opensearchapi/api.render_search_template.go +++ b/opensearchapi/api.render_search_template.go @@ -150,7 +150,7 @@ func (r RenderSearchTemplateRequest) Do(ctx context.Context, transport Transport Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.scripts_painless_execute.go b/opensearchapi/api.scripts_painless_execute.go index 818954d..2c26c3d 100644 --- a/opensearchapi/api.scripts_painless_execute.go +++ b/opensearchapi/api.scripts_painless_execute.go @@ -143,7 +143,7 @@ func (r ScriptsPainlessExecuteRequest) Do(ctx context.Context, transport Transpo Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.scroll.go b/opensearchapi/api.scroll.go index 3298281..f6b5e28 100644 --- a/opensearchapi/api.scroll.go +++ b/opensearchapi/api.scroll.go @@ -160,7 +160,7 @@ func (r ScrollRequest) Do(ctx context.Context, transport Transport) (*Response, Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.search.go b/opensearchapi/api.search.go index 8179578..9797e54 100644 --- a/opensearchapi/api.search.go +++ b/opensearchapi/api.search.go @@ -367,7 +367,7 @@ func (r SearchRequest) Do(ctx context.Context, transport Transport) (*Response, Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.search_shards.go b/opensearchapi/api.search_shards.go index 43d1e21..2e8bc30 100644 --- a/opensearchapi/api.search_shards.go +++ b/opensearchapi/api.search_shards.go @@ -173,7 +173,7 @@ func (r SearchShardsRequest) Do(ctx context.Context, transport Transport) (*Resp Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.search_template.go b/opensearchapi/api.search_template.go index 2edb1d1..376950b 100644 --- a/opensearchapi/api.search_template.go +++ b/opensearchapi/api.search_template.go @@ -218,7 +218,7 @@ func (r SearchTemplateRequest) Do(ctx context.Context, transport Transport) (*Re Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.snapshot.cleanup_repository.go b/opensearchapi/api.snapshot.cleanup_repository.go index c04785e..319c152 100644 --- a/opensearchapi/api.snapshot.cleanup_repository.go +++ b/opensearchapi/api.snapshot.cleanup_repository.go @@ -158,7 +158,7 @@ func (r SnapshotCleanupRepositoryRequest) Do(ctx context.Context, transport Tran Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.snapshot.clone.go b/opensearchapi/api.snapshot.clone.go index 2642eab..a8ade0c 100644 --- a/opensearchapi/api.snapshot.clone.go +++ b/opensearchapi/api.snapshot.clone.go @@ -166,7 +166,7 @@ func (r SnapshotCloneRequest) Do(ctx context.Context, transport Transport) (*Res Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.snapshot.create.go b/opensearchapi/api.snapshot.create.go index a6adc9d..b29a9dd 100644 --- a/opensearchapi/api.snapshot.create.go +++ b/opensearchapi/api.snapshot.create.go @@ -167,7 +167,7 @@ func (r SnapshotCreateRequest) Do(ctx context.Context, transport Transport) (*Re Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.snapshot.create_repository.go b/opensearchapi/api.snapshot.create_repository.go index cfbf684..ab2a116 100644 --- a/opensearchapi/api.snapshot.create_repository.go +++ b/opensearchapi/api.snapshot.create_repository.go @@ -169,7 +169,7 @@ func (r SnapshotCreateRepositoryRequest) Do(ctx context.Context, transport Trans Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.snapshot.delete.go b/opensearchapi/api.snapshot.delete.go index 376fcdb..dcceef7 100644 --- a/opensearchapi/api.snapshot.delete.go +++ b/opensearchapi/api.snapshot.delete.go @@ -154,7 +154,7 @@ func (r SnapshotDeleteRequest) Do(ctx context.Context, transport Transport) (*Re Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.snapshot.delete_repository.go b/opensearchapi/api.snapshot.delete_repository.go index a9d919f..7aaa3c7 100644 --- a/opensearchapi/api.snapshot.delete_repository.go +++ b/opensearchapi/api.snapshot.delete_repository.go @@ -156,7 +156,7 @@ func (r SnapshotDeleteRepositoryRequest) Do(ctx context.Context, transport Trans Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.snapshot.get.go b/opensearchapi/api.snapshot.get.go index 5a5b0e1..8cdb685 100644 --- a/opensearchapi/api.snapshot.get.go +++ b/opensearchapi/api.snapshot.get.go @@ -175,7 +175,7 @@ func (r SnapshotGetRequest) Do(ctx context.Context, transport Transport) (*Respo Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.snapshot.get_repository.go b/opensearchapi/api.snapshot.get_repository.go index 3ad81f4..0466a90 100644 --- a/opensearchapi/api.snapshot.get_repository.go +++ b/opensearchapi/api.snapshot.get_repository.go @@ -159,7 +159,7 @@ func (r SnapshotGetRepositoryRequest) Do(ctx context.Context, transport Transpor Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.snapshot.restore.go b/opensearchapi/api.snapshot.restore.go index 56823d5..46eb158 100644 --- a/opensearchapi/api.snapshot.restore.go +++ b/opensearchapi/api.snapshot.restore.go @@ -169,7 +169,7 @@ func (r SnapshotRestoreRequest) Do(ctx context.Context, transport Transport) (*R Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.snapshot.status.go b/opensearchapi/api.snapshot.status.go index b44e97b..ee3be0e 100644 --- a/opensearchapi/api.snapshot.status.go +++ b/opensearchapi/api.snapshot.status.go @@ -166,7 +166,7 @@ func (r SnapshotStatusRequest) Do(ctx context.Context, transport Transport) (*Re Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.snapshot.verify_repository.go b/opensearchapi/api.snapshot.verify_repository.go index cfd7152..0d37d25 100644 --- a/opensearchapi/api.snapshot.verify_repository.go +++ b/opensearchapi/api.snapshot.verify_repository.go @@ -158,7 +158,7 @@ func (r SnapshotVerifyRepositoryRequest) Do(ctx context.Context, transport Trans Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.tasks.cancel.go b/opensearchapi/api.tasks.cancel.go index 5996a4b..7007249 100644 --- a/opensearchapi/api.tasks.cancel.go +++ b/opensearchapi/api.tasks.cancel.go @@ -167,7 +167,7 @@ func (r TasksCancelRequest) Do(ctx context.Context, transport Transport) (*Respo Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.tasks.get.go b/opensearchapi/api.tasks.get.go index 42d00b4..e415b22 100644 --- a/opensearchapi/api.tasks.get.go +++ b/opensearchapi/api.tasks.get.go @@ -154,7 +154,7 @@ func (r TasksGetRequest) Do(ctx context.Context, transport Transport) (*Response Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.tasks.list.go b/opensearchapi/api.tasks.list.go index a0ffaad..061aea7 100644 --- a/opensearchapi/api.tasks.list.go +++ b/opensearchapi/api.tasks.list.go @@ -174,7 +174,7 @@ func (r TasksListRequest) Do(ctx context.Context, transport Transport) (*Respons Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.terms_enum.go b/opensearchapi/api.terms_enum.go index f671d3d..83735ac 100644 --- a/opensearchapi/api.terms_enum.go +++ b/opensearchapi/api.terms_enum.go @@ -148,7 +148,7 @@ func (r TermsEnumRequest) Do(ctx context.Context, transport Transport) (*Respons Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.termvectors.go b/opensearchapi/api.termvectors.go index 7b1fefd..d670880 100644 --- a/opensearchapi/api.termvectors.go +++ b/opensearchapi/api.termvectors.go @@ -208,7 +208,7 @@ func (r TermvectorsRequest) Do(ctx context.Context, transport Transport) (*Respo Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.update.go b/opensearchapi/api.update.go index 59263fb..6144260 100644 --- a/opensearchapi/api.update.go +++ b/opensearchapi/api.update.go @@ -212,7 +212,7 @@ func (r UpdateRequest) Do(ctx context.Context, transport Transport) (*Response, Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.update_by_query.go b/opensearchapi/api.update_by_query.go index 4f5d5c5..22d30be 100644 --- a/opensearchapi/api.update_by_query.go +++ b/opensearchapi/api.update_by_query.go @@ -326,7 +326,7 @@ func (r UpdateByQueryRequest) Do(ctx context.Context, transport Transport) (*Res Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/api.update_by_query_rethrottle.go b/opensearchapi/api.update_by_query_rethrottle.go index 2bf5d50..9cc0939 100644 --- a/opensearchapi/api.update_by_query_rethrottle.go +++ b/opensearchapi/api.update_by_query_rethrottle.go @@ -148,7 +148,7 @@ func (r UpdateByQueryRethrottleRequest) Do(ctx context.Context, transport Transp Header: res.Header, } - return &response, nil + return &response, response.Err() } // WithContext sets the request context. diff --git a/opensearchapi/opensearchapi.error.go b/opensearchapi/opensearchapi.error.go new file mode 100644 index 0000000..cfaa155 --- /dev/null +++ b/opensearchapi/opensearchapi.error.go @@ -0,0 +1,53 @@ +// 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 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 "fmt" + +// Error represents the API error response. +type Error struct { + Err Err `json:"error"` + Status int `json:"status"` +} + +// Err represents the error of an API error response +type Err struct { + RootCause []RootCause `json:"root_cause"` + Type string `json:"type"` + Reason string `json:"reason"` + Index string `json:"index,omitempty"` + IndexUUID string `json:"index_uudi,omitempty"` +} + +// RootCause represents the root_cause of an API error response +type RootCause struct { + Type string `json:"type"` + Reason string `json:"reason"` + Index string `json:"index,omitempty"` + IndexUUID string `json:"index_uudi,omitempty"` +} + +// Error returns a string. +func (e *Error) Error() string { + return fmt.Sprintf("error: %s, status: %d", e.Err, e.Status) +} diff --git a/opensearchapi/opensearchapi.response.go b/opensearchapi/opensearchapi.response.go index a0cb074..d4344ee 100644 --- a/opensearchapi/opensearchapi.response.go +++ b/opensearchapi/opensearchapi.response.go @@ -28,6 +28,7 @@ package opensearchapi import ( "bytes" + "encoding/json" "fmt" "io" "io/ioutil" @@ -37,7 +38,6 @@ import ( ) // Response represents the API response. -// type Response struct { StatusCode int Header http.Header @@ -47,7 +47,6 @@ type Response struct { // String returns the response as a string. // // The intended usage is for testing or debugging only. -// func (r *Response) String() string { var ( out = new(bytes.Buffer) @@ -84,7 +83,6 @@ func (r *Response) String() string { } // Status returns the response status as a string. -// func (r *Response) Status() string { var b strings.Builder if r != nil { @@ -96,19 +94,36 @@ func (r *Response) Status() string { } // IsError returns true when the response status indicates failure. -// func (r *Response) IsError() bool { return r.StatusCode > 299 } // Warnings returns the deprecation warnings from response headers. -// func (r *Response) Warnings() []string { return r.Header["Warning"] } // HasWarnings returns true when the response headers contain deprecation warnings. -// func (r *Response) HasWarnings() bool { return len(r.Warnings()) > 0 } + +// Err returns an error when the response status indicates failures. +func (r *Response) Err() error { + if r.IsError() { + if r.Body == nil { + return fmt.Errorf(r.Status()) + } + body, err := io.ReadAll(r.Body) + if err != nil { + return fmt.Errorf(r.Status()) + } + var e *Error + err = json.Unmarshal(body, &e) + if err == nil { + return e + } + return fmt.Errorf("status: %d, error: %s", r.StatusCode, string(body)) + } + return nil +} diff --git a/opensearchapi/opensearchapi_benchmark_test.go b/opensearchapi/opensearchapi_benchmark_test.go index 2462760..5b90955 100644 --- a/opensearchapi/opensearchapi_benchmark_test.go +++ b/opensearchapi/opensearchapi_benchmark_test.go @@ -28,6 +28,7 @@ package opensearchapi_test import ( "context" + "errors" "io/ioutil" "net/http" "strconv" @@ -277,7 +278,10 @@ func BenchmarkAPI(b *testing.B) { _, err := fakeClientWithError.Search(fakeClientWithError.Search.WithContext(context.Background()), fakeClientWithError.Search.WithBody(body)) if err != nil { - b.Errorf("Unexpected error when getting a response: %s", err) + var opensearchError *opensearchapi.Error + if !errors.As(err, &opensearchError) { + b.Errorf("Unexpected error when getting a response: %s", err) + } } } }) @@ -301,7 +305,10 @@ func BenchmarkAPI(b *testing.B) { for i := 0; i < b.N; i++ { req := opensearchapi.SearchRequest{Body: body} if _, err := req.Do(context.Background(), fakeClientWithError); err != nil { - b.Errorf("Unexpected error when getting a response: %s", err) + var opensearchError *opensearchapi.Error + if !errors.As(err, &opensearchError) { + b.Errorf("Unexpected error when getting a response: %s", err) + } } } }) diff --git a/opensearchapi/opensearchapi_integration_test.go b/opensearchapi/opensearchapi_integration_test.go index 218ce86..8690b11 100644 --- a/opensearchapi/opensearchapi_integration_test.go +++ b/opensearchapi/opensearchapi_integration_test.go @@ -24,6 +24,7 @@ // specific language governing permissions and limitations // under the License. +//go:build integration // +build integration package opensearchapi_test @@ -54,10 +55,6 @@ func TestAPI(t *testing.T) { } defer res.Body.Close() - if res.IsError() { - t.Fatalf("Error response: %s", res.String()) - } - var d map[string]interface{} err = json.NewDecoder(res.Body).Decode(&d) if err != nil { @@ -78,10 +75,6 @@ func TestAPI(t *testing.T) { } defer res.Body.Close() - if res.IsError() { - t.Fatalf("Error response: %s", res.String()) - } - if !strings.HasPrefix(res.String(), "[200 OK] ---") { t.Errorf("Unexpected response body: doesn't start with '[200 OK] ---'; %s", res.String()) } @@ -121,10 +114,7 @@ func TestAPI(t *testing.T) { if err != nil { t.Fatalf("Failed to index data: %s", err) } - res.Body.Close() - if res.IsError() { - t.Fatalf("Failed to index data: %s", res.Status()) - } + defer res.Body.Close() // Launch reindexing task with wait_for_completion=false // @@ -136,9 +126,6 @@ func TestAPI(t *testing.T) { if err != nil { t.Fatalf("Failed to reindex: %s", err) } - if res.IsError() { - t.Fatalf("Failed to reindex: %s", res.Status()) - } time.Sleep(10 * time.Millisecond) res, err = client.Tasks.List(client.Tasks.List.WithPretty()) @@ -146,9 +133,6 @@ func TestAPI(t *testing.T) { t.Fatalf("ERROR: %s", err) } res.Body.Close() - if res.IsError() { - t.Fatalf("Failed to get tasks: %s", res.Status()) - } // Get the list of tasks // @@ -158,10 +142,6 @@ func TestAPI(t *testing.T) { } defer res.Body.Close() - if res.IsError() { - t.Fatalf("Failed to get tasks: %s", res.Status()) - } - type task struct { Node string ID int @@ -206,10 +186,7 @@ func TestAPI(t *testing.T) { if err != nil { t.Fatalf("ERROR: %s", err) } - res.Body.Close() - if res.IsError() { - t.Fatalf("Failed to cancel task: %s", res) - } + defer res.Body.Close() } } } diff --git a/opensearchapi/opensearchapi_response_internal_test.go b/opensearchapi/opensearchapi_response_internal_test.go index 80c786f..57fd6a9 100644 --- a/opensearchapi/opensearchapi_response_internal_test.go +++ b/opensearchapi/opensearchapi_response_internal_test.go @@ -24,12 +24,14 @@ // specific language governing permissions and limitations // under the License. +//go:build !integration // +build !integration package opensearchapi import ( "errors" + "io" "io/ioutil" "net/http" "strings" @@ -103,6 +105,59 @@ func TestAPIResponse(t *testing.T) { } }) + t.Run("Error", func(t *testing.T) { + res = &Response{StatusCode: 201} + + if err := res.Err(); err != nil { + t.Errorf("Unexpected error for response: %s", res.Status()) + } + + res = &Response{StatusCode: 403} + + if err := res.Err(); err == nil { + t.Errorf("Expected error for response: %s", res.Status()) + } + + res = &Response{ + StatusCode: 400, + Body: io.NopCloser( + strings.NewReader(` + { + "error":{ + "root_cause":[{ + "type":"resource_already_exists_exception", + "reason":"index [test/HU2mN_RMRXGcS38j3yV-VQ] already exists", + "index":"test", + "index_uuid":"HU2mN_RMRXGcS38j3yV-VQ" + }], + "type":"resource_already_exists_exception", + "reason":"index [test/HU2mN_RMRXGcS38j3yV-VQ] already exists", + "index":"test", + "index_uuid":"HU2mN_RMRXGcS38j3yV-VQ" + }, + "status":400 + }`)), + } + + err := res.Err() + if err == nil { + t.Errorf("Expected error for response: %s", res.Status()) + } + var errTest *Error + if !errors.As(err, &errTest) { + t.Errorf("Expected error to be of type opensearchapi.Error: %T", err) + } + if errTest.Status != 400 || + errTest.Err.Reason != "index [test/HU2mN_RMRXGcS38j3yV-VQ] already exists" || + errTest.Err.Type != "resource_already_exists_exception" || + len(errTest.Err.RootCause) != 1 || + errTest.Err.RootCause[0].Type != "resource_already_exists_exception" || + errTest.Err.RootCause[0].Reason != "index [test/HU2mN_RMRXGcS38j3yV-VQ] already exists" { + + t.Errorf("Reponse Error was not parsed correctly") + } + }) + t.Run("Warnings", func(t *testing.T) { hdr := http.Header{} hdr.Add("Warning", "Foo 1") diff --git a/opensearchutil/json_reader_integration_test.go b/opensearchutil/json_reader_integration_test.go index 389626a..3e87133 100644 --- a/opensearchutil/json_reader_integration_test.go +++ b/opensearchutil/json_reader_integration_test.go @@ -24,6 +24,7 @@ // specific language governing permissions and limitations // under the License. +//go:build integration // +build integration package opensearchutil_test @@ -61,10 +62,6 @@ func TestJSONReaderIntegration(t *testing.T) { } defer res.Body.Close() - if res.IsError() { - t.Fatalf("Error response: %s", res.String()) - } - query := map[string]interface{}{ "query": map[string]interface{}{ "match": map[string]interface{}{ @@ -83,10 +80,6 @@ func TestJSONReaderIntegration(t *testing.T) { } defer res.Body.Close() - if res.IsError() { - t.Errorf("Error response: %s", res) - } - if !strings.Contains(res.String(), "Foo Bar") { t.Errorf("Unexpected response: %s", res) } From 8c4dbc6ca648db62f6277149244dad7ad6bed254 Mon Sep 17 00:00:00 2001 From: Rakhat <51375666+zethuman@users.noreply.github.com> Date: Thu, 23 Mar 2023 00:28:26 +0600 Subject: [PATCH 14/84] Add operations with data streams (#257) * Add operations with data streams Signed-off-by: Rakhat Zhuman * Add tests and filled user guid / changelog Signed-off-by: Rakhat Zhuman * Changed data stream tests to integration Signed-off-by: Rakhat Zhuman --------- Signed-off-by: Rakhat Zhuman Co-authored-by: Daniel (dB.) Doubrovkine --- CHANGELOG.md | 1 + USER_GUIDE.md | 175 ++++++++++++++- opensearchapi/api._.go | 8 + .../api.indices.create_datastream.go | 177 +++++++++++++++ opensearchapi/api.indices.datastream_test.go | 186 ++++++++++++++++ .../api.indices.delete_datastream.go | 203 ++++++++++++++++++ opensearchapi/api.indices.get_datastream.go | 198 +++++++++++++++++ .../api.indices.get_datastream_stats.go | 199 +++++++++++++++++ 8 files changed, 1145 insertions(+), 2 deletions(-) create mode 100644 opensearchapi/api.indices.create_datastream.go create mode 100644 opensearchapi/api.indices.datastream_test.go create mode 100644 opensearchapi/api.indices.delete_datastream.go create mode 100644 opensearchapi/api.indices.get_datastream.go create mode 100644 opensearchapi/api.indices.get_datastream_stats.go diff --git a/CHANGELOG.md b/CHANGELOG.md index 836c2ba..ddb9905 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - 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)) +- Add implementation of Data Streams API ([#257](https://github.com/opensearch-project/opensearch-go/pull/257) - Support for Amazon OpenSearch Serverless ([#216](https://github.com/opensearch-project/opensearch-go/pull/216), [#259](https://github.com/opensearch-project/opensearch-go/pull/259)) - Add Err() function to Response for detailed errors ([#246](https://github.com/opensearch-project/opensearch-go/pull/246)) diff --git a/USER_GUIDE.md b/USER_GUIDE.md index 7680ed5..db4a128 100644 --- a/USER_GUIDE.md +++ b/USER_GUIDE.md @@ -1,6 +1,14 @@ - [User Guide](#user-guide) - - [Example](#example) - - [Amazon OpenSearch Service](#amazon-opensearch-service) - [AWS SDK V1](#aws-sdk-v1) - [AWS SDK V2](#aws-sdk-v2) + - [Example](#example) + - [Amazon OpenSearch Service](#amazon-opensearch-service) + - [AWS SDK V1](#aws-sdk-v1) + - [AWS SDK V2](#aws-sdk-v2) + - [Data Streams API](#data-streams-api) + - [Create Data Stream](#create-data-streams) + - [Delete Data Stream](#delete-data-streams) + - [Get All Data Streams](#get-data-streams) + - [Get Specific Data Stream](#get-specific-data-streams) + - [Get Specific Data Stream Stats](#get-specific-data-streams-stats) # User Guide @@ -331,3 +339,166 @@ func getCredentialProvider(accessKey, secretAccessKey, token string) aws.Credent } ``` + +## Data Streams API + +### Create Data Streams + + - Create new client +``` +client, err := opensearch.NewDefaultClient() +if err != nil { + panic(err) +} +``` + + - Create template index + +``` +iPut := opensearchapi.IndicesPutIndexTemplateRequest{ + Name: "demo-data-template", + Pretty: true, + Human: true, + ErrorTrace: true, + Body: strings.NewReader(`{"index_patterns": ["demo-*"], "data_stream": {}, "priority": 100} }`), +} +iPutResponse, err := iPut.Do(context.Background(), client) +``` + + - Prepare request object +``` +es := opensearchapi.IndicesCreateDataStreamRequest{ + Name: "demo-name", + Human: true, + Pretty: true, + ErrorTrace: true, + Header: map[string][]string{ + "Content-Type": {"application/json"}, + }, +} +``` + + - Execute request +``` +res, err := es.Do(context.TODO(), client) +if err != nil { + // do not panic in production code + panic(err) +} +``` + + - Try to read response +``` +defer res.Body.Close() +body, err := ioutil.ReadAll(res.Body) +if err != nil { + // do not panic in production code + panic(err) +} + +fmt.Println("Response Status Code: ", res.StatusCode) +fmt.Println("Response Headers: ", res.Header) +fmt.Println("Response Body: ", string(body)) +``` + + - Successfully created data stream +``` +Response Status Code: 200 +Response Headers: map[Content-Length:[28] Content-Type:[application/json; charset=UTF-8]] +Response Body: {"acknowledged" : true} +``` + +### Delete Data Streams + + - Create new client as previous example + - Prepare request object +``` +opensearchapi.IndicesDeleteDataStreamRequest{ + Name: "demo-name", + Pretty: true, + Human: true, + ErrorTrace: true, + Header: map[string][]string{ + "Content-Type": {"application/json"}, + }, +} +``` +- Execute request as previous example +- Try to read response as previous example +- Successfully deleted data stream +``` +Response Status Code: 200 +Response Headers: map[Content-Length:[28] Content-Type:[application/json; charset=UTF-8]] +Response Body: {"acknowledged" : true} +``` + +### Get All Data Streams + +- Create new client as previous example +- Prepare request object +``` +r := opensearchapi.IndicesGetDataStreamRequest{ + Pretty: true, + Human: true, + ErrorTrace: true, + Header: map[string][]string{ + "Content-Type": {"application/json"}, + }, +} +``` +- Execute request as previous example +- Try to read response as previous example +- Successfully retrieved data streams +``` +Response Status Code: 200 +Response Headers: map[Content-Length:[28] Content-Type:[application/json; charset=UTF-8]] +Response Body: {"data_streams":[{"name":"demo-name","timestamp_field":{"name":"@timestamp"},"indices":[{"index_name":".ds-demo-2023-03-21-23-33-46-000001","index_uuid":"NnzgqnP0ThS7LOMHJuZ-VQ"}],"generation":1,"status":"YELLOW","template":"demo-data-template"}]} +``` + +### Get Specific Data Stream + +- Create new client as previous example +- Prepare request object +``` +r := opensearchapi.IndicesGetDataStreamRequest{ + Name: "demo-name", + Pretty: true, + Human: true, + ErrorTrace: true, + Header: map[string][]string{ + "Content-Type": {"application/json"}, + }, + } +``` +- Execute request as previous example +- Try to read response as previous example +- Successfully retrieved data stream +``` +Response Status Code: 200 +Response Headers: map[Content-Length:[28] Content-Type:[application/json; charset=UTF-8]] +Response Body: {"data_streams":[{"name":"demo-name","timestamp_field":{"name":"@timestamp"},"indices":[{"index_name":".ds-demo-2023-03-21-23-31-50-000001","index_uuid":"vhsowqdeRFCmr1GgQ7mIsQ"}],"generation":1,"status":"YELLOW","template":"demo-data-template"}]} +``` + +### Get Specific Data Stream Stats + +- Create new client as as previous example +- Prepare request object +``` +r := opensearchapi.IndicesGetDataStreamStatsRequest{ + Name: "demo-name", + Pretty: true, + Human: true, + ErrorTrace: true, + Header: map[string][]string{ + "Content-Type": {"application/json"}, + }, +} +``` +- Execute request as previous example +- Try to read response as previous example +- Successfully retrieved data stream stats +``` +Response Status Code: 200 +Response Headers: map[Content-Length:[28] Content-Type:[application/json; charset=UTF-8]] +Response Body: {"_shards":{"total":2,"successful":1,"failed":0},"data_stream_count":1,"backing_indices":1,"total_store_size":"208b","total_store_size_bytes":208,"data_streams":[{"data_stream":"demo-name","backing_indices":1,"store_size":"208b","store_size_bytes":208,"maximum_timestamp":0}]} +``` \ No newline at end of file diff --git a/opensearchapi/api._.go b/opensearchapi/api._.go index 5382f00..82563f8 100755 --- a/opensearchapi/api._.go +++ b/opensearchapi/api._.go @@ -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 @@ -314,10 +318,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 +339,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), diff --git a/opensearchapi/api.indices.create_datastream.go b/opensearchapi/api.indices.create_datastream.go new file mode 100644 index 0000000..d7094b3 --- /dev/null +++ b/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/opensearchapi/api.indices.datastream_test.go b/opensearchapi/api.indices.datastream_test.go new file mode 100644 index 0000000..2fe9fc8 --- /dev/null +++ b/opensearchapi/api.indices.datastream_test.go @@ -0,0 +1,186 @@ +// 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. + +//go:build integration +// +build integration + +package opensearchapi_test + +import ( + "bytes" + "context" + "encoding/json" + "fmt" + "github.com/opensearch-project/opensearch-go/v2" + "github.com/opensearch-project/opensearch-go/v2/opensearchapi" + "github.com/stretchr/testify/require" + "io/ioutil" + "net/http" + "strings" + "testing" + "time" +) + +type DataStreamRequest interface { + Do(context.Context, opensearchapi.Transport) (*opensearchapi.Response, error) +} + +func TestIndicesDataStreams_Do(t *testing.T) { + name := fmt.Sprintf("demo-%s", time.Now().Format("2006-01-02-15-04-05")) + + tests := []struct { + name string + r DataStreamRequest + want *opensearchapi.Response + wantBody string + wantErr bool + }{ + { + name: "TestIndicesCreateDataStreamRequest_Do", + r: opensearchapi.IndicesCreateDataStreamRequest{ + Name: name, + Pretty: true, + Human: true, + ErrorTrace: true, + Header: map[string][]string{ + "Content-Type": {"application/json"}, + }, + }, + want: &opensearchapi.Response{ + StatusCode: 200, + Header: http.Header{ + "Content-Type": []string{"application/json; charset=UTF-8"}, + }, + }, + wantBody: `{"acknowledged":true}`, + wantErr: false, + }, + { + name: "TestIndicesGetDataStreamRequest_Do", + r: opensearchapi.IndicesGetDataStreamRequest{ + Name: name, + Pretty: true, + Human: true, + ErrorTrace: true, + Header: map[string][]string{ + "Content-Type": {"application/json"}, + }, + }, + want: &opensearchapi.Response{ + StatusCode: 200, + Header: http.Header{ + "Content-Type": []string{"application/json; charset=UTF-8"}, + }, + }, + wantErr: false, + }, + { + name: "TestIndicesGetAllDataStreamsRequest_Do", + r: opensearchapi.IndicesGetDataStreamRequest{ + Pretty: true, + Human: true, + ErrorTrace: true, + Header: map[string][]string{ + "Content-Type": {"application/json"}, + }, + }, + want: &opensearchapi.Response{ + StatusCode: 200, + Header: http.Header{ + "Content-Type": []string{"application/json; charset=UTF-8"}, + }, + }, + wantErr: false, + }, + { + name: "TestIndicesGetStatsDataStreamRequest_Do", + r: opensearchapi.IndicesGetDataStreamStatsRequest{ + Name: name, + Pretty: true, + Human: true, + ErrorTrace: true, + Header: map[string][]string{ + "Content-Type": {"application/json"}, + }, + }, + want: &opensearchapi.Response{ + StatusCode: 200, + Header: http.Header{ + "Content-Type": []string{"application/json; charset=UTF-8"}, + }, + }, + wantBody: fmt.Sprintf(`{"_shards":{"total":2,"successful":1,"failed":0},"data_stream_count":1,"backing_indices":1,"total_store_size":"208b","total_store_size_bytes":208,"data_streams":[{"data_stream":"%s","backing_indices":1,"store_size":"208b","store_size_bytes":208,"maximum_timestamp":0}]}`, name), + wantErr: false, + }, + { + name: "TestIndicesDeleteDataStreamRequest_Do", + r: opensearchapi.IndicesDeleteDataStreamRequest{ + Name: name, + Pretty: true, + Human: true, + ErrorTrace: true, + Header: map[string][]string{ + "Content-Type": {"application/json"}, + }, + }, + want: &opensearchapi.Response{ + StatusCode: 200, + Header: http.Header{ + "Content-Type": []string{"application/json; charset=UTF-8"}, + }, + }, + wantBody: `{"acknowledged":true}`, + wantErr: false, + }, + } + + client, err := opensearch.NewDefaultClient() + require.NoError(t, err) + + iPut := opensearchapi.IndicesPutIndexTemplateRequest{ + Name: fmt.Sprintf("demo-data-template"), + Pretty: true, + Human: true, + ErrorTrace: true, + Body: strings.NewReader(fmt.Sprintf(`{"index_patterns": ["demo-*"], "data_stream": {}, "priority": 100} }`)), + } + + iPutResponse, err := iPut.Do(context.Background(), client) + require.NoError(t, err) + require.Equalf(t, false, iPutResponse.IsError(), + "Error when creating index template: %s", iPutResponse.String()) + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got, err := tt.r.Do(context.Background(), client) + if (err != nil) != tt.wantErr { + t.Errorf("Do() error = %v, wantErr %v", err, tt.wantErr) + return + } + + require.Equalf(t, got.IsError(), tt.wantErr, "Do() got = %v, want %v", got.IsError(), tt.wantErr) + require.Equalf(t, got.StatusCode, tt.want.StatusCode, "Do() got = %v, want %v", got.StatusCode, tt.want.StatusCode) + + if tt.wantBody != "" { + require.Equalf(t, got.Header, tt.want.Header, "Do() got = %v, want %v", got.Header, tt.want.Header) + + defer got.Body.Close() + body, err := ioutil.ReadAll(got.Body) + require.NoError(t, err) + + buffer := new(bytes.Buffer) + if err := json.Compact(buffer, body); err != nil { + fmt.Println(err) + } + + require.Equalf(t, buffer.String(), tt.wantBody, "Do() got = %v, want %v", got.String(), tt.wantBody) + } + }) + } +} diff --git a/opensearchapi/api.indices.delete_datastream.go b/opensearchapi/api.indices.delete_datastream.go new file mode 100644 index 0000000..958d46b --- /dev/null +++ b/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/opensearchapi/api.indices.get_datastream.go b/opensearchapi/api.indices.get_datastream.go new file mode 100644 index 0000000..7facf8b --- /dev/null +++ b/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/opensearchapi/api.indices.get_datastream_stats.go b/opensearchapi/api.indices.get_datastream_stats.go new file mode 100644 index 0000000..4bc2e93 --- /dev/null +++ b/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) + } +} From 2d469d441d2ba3d592eefd2b619895b9eaf9c2ce Mon Sep 17 00:00:00 2001 From: Jakob Date: Thu, 23 Mar 2023 16:19:55 +0100 Subject: [PATCH 15/84] SnapshotDeleteRequest use []string instead of string (#237) * SnapshotDeleteRequest use []string instead of string Signed-off-by: Jakob Hahn * Add opensearchapi snapshot ingegration test Signed-off-by: Jakob Hahn * Add path.repo value to test-integration-unreleased workflow Signed-off-by: Jakob Hahn * Add UPGRADING.md Signed-off-by: Jakob Hahn * opensearchapi: Fix integration test with new error handling Signed-off-by: Jakob Hahn --------- Signed-off-by: Jakob Hahn Co-authored-by: Daniel (dB.) Doubrovkine --- .ci/opensearch/docker-compose.yml | 1 + .../workflows/test-integration-unreleased.yml | 2 +- CHANGELOG.md | 41 +++--- UPGRADING.md | 66 ++++++++-- opensearchapi/api.snapshot.delete.go | 10 +- .../opensearchapi_integration_test.go | 121 ++++++++++++++++++ 6 files changed, 199 insertions(+), 42 deletions(-) diff --git a/.ci/opensearch/docker-compose.yml b/.ci/opensearch/docker-compose.yml index 9fbd391..b27694e 100755 --- a/.ci/opensearch/docker-compose.yml +++ b/.ci/opensearch/docker-compose.yml @@ -12,6 +12,7 @@ services: environment: - discovery.type=single-node - bootstrap.memory_lock=true + - path.repo=/usr/share/opensearch/mnt ports: - "9200:9200" user: opensearch diff --git a/.github/workflows/test-integration-unreleased.yml b/.github/workflows/test-integration-unreleased.yml index 05c6799..3f272d0 100644 --- a/.github/workflows/test-integration-unreleased.yml +++ b/.github/workflows/test-integration-unreleased.yml @@ -51,7 +51,7 @@ jobs: working-directory: opensearch/distribution/archives/linux-tar/build/distributions run: | tar xf opensearch-min-* - ./opensearch-*/bin/opensearch & + ./opensearch-*/bin/opensearch -Epath.repo=/usr/share/opensearch/mnt & for attempt in {1..20}; do sleep 5; if curl -s localhost:9200; then echo '=====> ready'; break; fi; echo '=====> waiting...'; done - name: Checkout Go Client diff --git a/CHANGELOG.md b/CHANGELOG.md index ddb9905..fe9e9ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,47 +6,36 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Dependencies +- Bumps `github.com/aws/aws-sdk-go` from 1.44.45 to 1.44.225 - Bumps `github.com/aws/aws-sdk-go-v2` from 1.17.1 to 1.17.6 -- Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.10 to 1.18.18 -- Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.9 to 1.18.12 -- Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.8 to 1.18.10 -- Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.17.10 to 1.18.9 -- Bumps `github.com/aws/aws-sdk-go` from 1.44.195 to 1.44.225 -- Bumps `github.com/aws/aws-sdk-go` from 1.44.185 to 1.44.205 -- Bumps `github.com/aws/aws-sdk-go` from 1.44.180 to 1.44.195 -- Bumps `github.com/aws/aws-sdk-go` from 1.44.176 to 1.44.185 -- Bumps `github.com/aws/aws-sdk-go` from 1.44.132 to 1.44.180 -- Bumps `github.com/stretchr/testify` from 1.8.1 to 1.8.2 +- Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.8 to 1.18.18 +- Bumps `github.com/stretchr/testify` from 1.8.0 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)) -- Add implementation of Data Streams API ([#257](https://github.com/opensearch-project/opensearch-go/pull/257) -- Support for Amazon OpenSearch Serverless ([#216](https://github.com/opensearch-project/opensearch-go/pull/216), [#259](https://github.com/opensearch-project/opensearch-go/pull/259)) -- Add Err() function to Response for detailed errors ([#246](https://github.com/opensearch-project/opensearch-go/pull/246)) - -### 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 support for Amazon OpenSearch Serverless ([#216](https://github.com/opensearch-project/opensearch-go/pull/216), [#259](https://github.com/opensearch-project/opensearch-go/pull/259)) +- Adds Github workflow for changelog verification ([#172](https://github.com/opensearch-project/opensearch-go/pull/172)) +- Adds Go Documentation link for the client ([#182](https://github.com/opensearch-project/opensearch-go/pull/182)) +- Adds implementation of Data Streams API ([#257](https://github.com/opensearch-project/opensearch-go/pull/257) +- Adds `Err()` function to Response for detailed errors ([#246](https://github.com/opensearch-project/opensearch-go/pull/246)) ### Changed -- Workflow improvements ([#242](https://github.com/opensearch-project/opensearch-go/pull/242)) -- Opensearchapi check the response for errors ([#246](https://github.com/opensearch-project/opensearch-go/pull/246)) +- 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)) ### Deprecated ### Removed -- Remove info call before performing every request ([#219](https://github.com/opensearch-project/opensearch-go/pull/219)) +- Removes 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)) -- Correct curl logging to emit the correct URL destination ([#101](https://github.com/opensearch-project/opensearch-go/pull/101)) +- Renames the sequence number struct tag to `if_seq_no` to fix optimistic concurrency control ([#166](https://github.com/opensearch-project/opensearch-go/pull/166)) +- Fixes `RetryOnConflict` on bulk indexer ([#215](https://github.com/opensearch-project/opensearch-go/pull/215)) +- Corrects curl logging to emit the correct URL destination ([#101](https://github.com/opensearch-project/opensearch-go/pull/101)) ### Security diff --git a/UPGRADING.md b/UPGRADING.md index 48dc981..e0d8661 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -1,25 +1,71 @@ - [Upgrading Opensearch GO Client](#upgrading-opensearch-go-client) - [Upgraading to >= 3.0.0](#upgrading-to->=-3.0.0) + - [opensearchapi](#opensearchapi-snapshot-delete) - [opensearchapi](#opensearchapi-error-handling) # Upgrading Opensearch GO Client ## Upgrading to >= 3.0.0 +### opensearchapi snapshot delete + +`SnapshotDeleteRequest` and `SnapshotDelete` changed the argument `Snapshot` type from `string` to `[]string`. + +Before: + +```go +// If you have a string containing your snapshot +stringSnapshotsToDelete := "snapshot-1,snapshot-2" +reqSnapshots := &opensearchapi.SnapshotDeleteRequest{ + Repository: repo, + Snapshot: stringSnapshotsToDelete, +} + +// If you have a slice of strings containing your snapshot +sliceSnapshotToDelete := []string{"snapshot-1","snapshot-2"} +reqSnapshots := &opensearchapi.SnapshotDeleteRequest{ + Repository: repo, + Snapshot: strings.Join(sliceSnapshotsToDelete, ","), +} +``` + +After: + +```go +// If you have a string containing your snapshots +stringSnapshotsToDelete := strings.Split("snapshot-1,snapshot-2", ",") +reqSnapshots := &opensearchapi.SnapshotDeleteRequest{ + Repository: repo, + Snapshot: stringSnapshotsToDelete, +} + +// If you have a slice of strings containing your snapshots +sliceSnapshotToDelete := []string{"snapshot-1", "snapshot-2"} +reqSnapshots := &opensearchapi.SnapshotDeleteRequest{ + Repository: repo, + Snapshot: sliceSnapshotsToDelete, +``` + ### opensearchapi error handling -With opensearch-go >= 3.0.0 opensearchapi responses are now checked for errors. -Prior versions only returned an error if the request failed to execute. For example if the client can't reach the server or the TLS handshake failed. + +With opensearch-go >= 3.0.0 opensearchapi responses are now checked for errors. Checking for errors twice is no longer needed. + +Prior versions only returned an error if the request failed to execute. For example if the client can't reach the server or the TLS handshake failed. With opensearch-go >= 3.0.0 each opensearchapi requests will return an error if the response http status code is > 299. -The error can be parsed into the new opensearchapi.Error type by using `errors.As` to match for exceptions and get a more detailed view. See the example below. +The error can be parsed into the new `opensearchapi.Error` type by using `errors.As` to match for exceptions and get a more detailed view. + +Example: ```go - createIndex := opensearchapi.IndicesCreateRequest{ - Index: IndexName, - Body: mapping, - } - ctx := context.Background() - var opensearchError *opensearchapi.Error - createIndexResponse, err := createIndex.Do(ctx, client) +createIndex := opensearchapi.IndicesCreateRequest{ + Index: IndexName, + Body: mapping, +} + +ctx := context.Background() +var opensearchError *opensearchapi.Error + +createIndexResponse, err := createIndex.Do(ctx, client) // Load err into opensearchapi.Error to access the fields and tolerate if the index already exists if err != nil { if errors.As(err, &opensearchError) { diff --git a/opensearchapi/api.snapshot.delete.go b/opensearchapi/api.snapshot.delete.go index dcceef7..1d2021a 100644 --- a/opensearchapi/api.snapshot.delete.go +++ b/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/opensearchapi/opensearchapi_integration_test.go b/opensearchapi/opensearchapi_integration_test.go index 8690b11..a4ad291 100644 --- a/opensearchapi/opensearchapi_integration_test.go +++ b/opensearchapi/opensearchapi_integration_test.go @@ -31,7 +31,9 @@ package opensearchapi_test import ( "bytes" + "context" "encoding/json" + "errors" "fmt" "strings" "testing" @@ -192,4 +194,123 @@ func TestAPI(t *testing.T) { } } }) + t.Run("Snapshot", func(t *testing.T) { + // Functio to perform requests + // + opensearchDo := func(ctx context.Context, client *opensearch.Client, req opensearchapi.Request, msg string, t *testing.T) { + _, err := req.Do(ctx, client) + if err != nil { + var opensearchError *opensearchapi.Error + if errors.As(err, &opensearchError) { + if opensearchError.Err.Type == "snapshot_missing_exception" { + return + } + t.Fatalf("Failed to %s: %s", msg, err) + } + } + } + + // Create Client + // + client, err := opensearch.NewDefaultClient() + if err != nil { + t.Fatalf("Error creating the client: %s\n", err) + } + + // Pre Cleanup indices + // + iDeleteReq := &opensearchapi.IndicesDeleteRequest{ + Index: []string{"test", "test_restored"}, + IgnoreUnavailable: opensearchapi.BoolPtr(true), + } + ctx := context.Background() + opensearchDo(ctx, client, iDeleteReq, "index data", t) + + // Index data + // + var buf bytes.Buffer + for j := 1; j <= 1000; j++ { + meta := []byte(fmt.Sprintf(`{ "index" : { "_id" : "%d" } }%s`, j, "\n")) + data := []byte(`{"content":"` + strings.Repeat("ABC", 100) + `"}`) + data = append(data, "\n"...) + + buf.Grow(len(meta) + len(data)) + buf.Write(meta) + buf.Write(data) + } + + bulkReq := &opensearchapi.BulkRequest{ + Body: bytes.NewReader(buf.Bytes()), + Index: "test", + Refresh: "true", + } + opensearchDo(ctx, client, bulkReq, "index data", t) + + // Test Snapshot functions + // + sRepoCreateReq := &opensearchapi.SnapshotCreateRepositoryRequest{ + Body: bytes.NewBufferString(`{"type":"fs","settings":{"location":"/usr/share/opensearch/mnt"}}`), + Repository: "snapshot-test", + } + opensearchDo(ctx, client, sRepoCreateReq, "create Snapshot Repository", t) + + sRepoVerifyReq := &opensearchapi.SnapshotVerifyRepositoryRequest{ + Repository: "snapshot-test", + } + opensearchDo(ctx, client, sRepoVerifyReq, "verify Snapshot Repository", t) + + sDeleteReq := &opensearchapi.SnapshotDeleteRequest{ + Snapshot: []string{"test", "clone-test"}, + Repository: "snapshot-test", + } + opensearchDo(ctx, client, sDeleteReq, "delete Snapshots", t) + + sCreateReq := &opensearchapi.SnapshotCreateRequest{ + Body: bytes.NewBufferString(`{"indices":"test","ignore_unavailable":true,"include_global_state":false,"partial":false}`), + Snapshot: "test", + Repository: "snapshot-test", + WaitForCompletion: opensearchapi.BoolPtr(true), + } + opensearchDo(ctx, client, sCreateReq, "create Snapshot", t) + + sCloneReq := &opensearchapi.SnapshotCloneRequest{ + Body: bytes.NewBufferString(`{"indices":"*"}`), + Snapshot: "test", + TargetSnapshot: "clone-test", + Repository: "snapshot-test", + } + opensearchDo(ctx, client, sCloneReq, "clone Snapshot", t) + + sGetReq := &opensearchapi.SnapshotGetRequest{ + Snapshot: []string{"test", "clone-test"}, + Repository: "snapshot-test", + } + opensearchDo(ctx, client, sGetReq, "get Snapshots", t) + + sStatusReq := &opensearchapi.SnapshotGetRequest{ + Snapshot: []string{"test", "clone-test"}, + Repository: "snapshot-test", + } + opensearchDo(ctx, client, sStatusReq, "get Snapshot status", t) + + sRestoreReq := &opensearchapi.SnapshotRestoreRequest{ + Body: bytes.NewBufferString( + `{ + "indices":"test", + "ignore_unavailable":true, + "include_global_state":false, + "partial":false, + "rename_pattern": "(.+)", + "rename_replacement":"$1_restored" + }`, + ), + Snapshot: "clone-test", + Repository: "snapshot-test", + WaitForCompletion: opensearchapi.BoolPtr(true), + } + opensearchDo(ctx, client, sRestoreReq, "restore Snapshot", t) + + opensearchDo(ctx, client, sDeleteReq, "delete Snapshots", t) + opensearchDo(ctx, client, iDeleteReq, "index data", t) + }) } From 34ed92dad1e3d677775b8424a8a4511fbba31711 Mon Sep 17 00:00:00 2001 From: Jakob Date: Thu, 23 Mar 2023 17:28:04 +0100 Subject: [PATCH 16/84] Upgrade.md: Add before example for error handling (#265) Signed-off-by: Jakob Hahn --- UPGRADING.md | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/UPGRADING.md b/UPGRADING.md index e0d8661..5981282 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -11,7 +11,7 @@ `SnapshotDeleteRequest` and `SnapshotDelete` changed the argument `Snapshot` type from `string` to `[]string`. -Before: +Before 3.0.0: ```go // If you have a string containing your snapshot @@ -29,7 +29,7 @@ reqSnapshots := &opensearchapi.SnapshotDeleteRequest{ } ``` -After: +With 3.0.0: ```go // If you have a string containing your snapshots @@ -54,7 +54,24 @@ Prior versions only returned an error if the request failed to execute. For exam With opensearch-go >= 3.0.0 each opensearchapi requests will return an error if the response http status code is > 299. The error can be parsed into the new `opensearchapi.Error` type by using `errors.As` to match for exceptions and get a more detailed view. -Example: +Before 3.0.0: +```go +createIndex := opensearchapi.IndicesCreateRequest{ + Index: IndexName, + Body: mapping, +} + +ctx := context.Background() +createIndexResp, err := createIndex.Do(ctx, client) +if err != nil { + return err +} +if createIndexResp.IsError() { + fmt.Errorf("Opensearch returned an error. Status: %d", createIndexResp.StatusCode) +} +``` + +With 3.0.0: ```go createIndex := opensearchapi.IndicesCreateRequest{ @@ -66,14 +83,15 @@ ctx := context.Background() var opensearchError *opensearchapi.Error createIndexResponse, err := createIndex.Do(ctx, client) - // Load err into opensearchapi.Error to access the fields and tolerate if the index already exists - if err != nil { - if errors.As(err, &opensearchError) { - if opensearchError.Err.Type != "resource_already_exists_exception" { - return err - } - } else { +// Load err into opensearchapi.Error to access the fields and tolerate if the index already exists +if err != nil { + if errors.As(err, &opensearchError) { + if opensearchError.Err.Type != "resource_already_exists_exception" { return err } + } else { + return err } +} ``` + From 0da56b276d091a91d89cccd8d92a01dfa10b0270 Mon Sep 17 00:00:00 2001 From: Jakob Date: Fri, 24 Mar 2023 15:40:40 +0100 Subject: [PATCH 17/84] Add point in time api (#253) * Add point in time api Signed-off-by: Jakob Hahn * opensearchapi: Add custom response type Signed-off-by: Jakob Hahn * opensearchapi: Add InfoResp type Signed-off-by: Jakob Hahn * opensearchapi: Add Point in Time integration test Signed-off-by: Jakob Hahn * opensearchapi: Update comments for point in time apis Signed-off-by: Jakob Hahn * Update Changelog Signed-off-by: Jakob Hahn --------- Signed-off-by: Jakob Hahn --- CHANGELOG.md | 2 + opensearchapi/api._.go | 30 +- opensearchapi/api.info.go | 29 +- opensearchapi/api.pointintime.create.go | 260 ++++++++++++++++++ opensearchapi/api.pointintime.delete.go | 241 ++++++++++++++++ opensearchapi/api.pointintime.get.go | 213 ++++++++++++++ .../opensearchapi_integration_test.go | 122 ++++++-- 7 files changed, 849 insertions(+), 48 deletions(-) create mode 100644 opensearchapi/api.pointintime.create.go create mode 100644 opensearchapi/api.pointintime.delete.go create mode 100644 opensearchapi/api.pointintime.get.go diff --git a/CHANGELOG.md b/CHANGELOG.md index fe9e9ab..5722b65 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,8 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Adds Go Documentation link for the client ([#182](https://github.com/opensearch-project/opensearch-go/pull/182)) - Adds implementation of Data Streams API ([#257](https://github.com/opensearch-project/opensearch-go/pull/257) - Adds `Err()` function to Response for detailed errors ([#246](https://github.com/opensearch-project/opensearch-go/pull/246)) +- 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)) ### Changed diff --git a/opensearchapi/api._.go b/opensearchapi/api._.go index 82563f8..961aa21 100755 --- a/opensearchapi/api._.go +++ b/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 @@ -226,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{ @@ -396,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/opensearchapi/api.info.go b/opensearchapi/api.info.go index 77bb5e1..995c5e9 100644 --- a/opensearchapi/api.info.go +++ b/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/opensearchapi/api.pointintime.create.go b/opensearchapi/api.pointintime.create.go new file mode 100644 index 0000000..3a251ea --- /dev/null +++ b/opensearchapi/api.pointintime.create.go @@ -0,0 +1,260 @@ +// 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 err = response.Err(); err != nil { + return &response, nil, err + } + + 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/opensearchapi/api.pointintime.delete.go b/opensearchapi/api.pointintime.delete.go new file mode 100644 index 0000000..ede0ec0 --- /dev/null +++ b/opensearchapi/api.pointintime.delete.go @@ -0,0 +1,241 @@ +// 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 err = response.Err(); err != nil { + return &response, nil, err + } + + 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/opensearchapi/api.pointintime.get.go b/opensearchapi/api.pointintime.get.go new file mode 100644 index 0000000..d972380 --- /dev/null +++ b/opensearchapi/api.pointintime.get.go @@ -0,0 +1,213 @@ +// 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 err = response.Err(); err != nil { + return &response, nil, err + } + + 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/opensearchapi/opensearchapi_integration_test.go b/opensearchapi/opensearchapi_integration_test.go index a4ad291..fad24c8 100644 --- a/opensearchapi/opensearchapi_integration_test.go +++ b/opensearchapi/opensearchapi_integration_test.go @@ -43,6 +43,23 @@ import ( "github.com/opensearch-project/opensearch-go/v2/opensearchapi" ) +func createTestIndex(client *opensearch.Client, index string) error { + var buf bytes.Buffer + // Index data + // + for j := 1; j <= 1000; j++ { + meta := []byte(fmt.Sprintf(`{ "index" : { "_id" : "%d" } }%s`, j, "\n")) + data := []byte(`{"content":"` + strings.Repeat("ABC", 100) + `"}`) + data = append(data, "\n"...) + + buf.Grow(len(meta) + len(data)) + buf.Write(meta) + buf.Write(data) + } + _, err := client.Bulk(bytes.NewReader(buf.Bytes()), client.Bulk.WithIndex(index), client.Bulk.WithRefresh("true")) + return err +} + func TestAPI(t *testing.T) { t.Run("Search", func(t *testing.T) { client, err := opensearch.NewDefaultClient() @@ -84,8 +101,6 @@ func TestAPI(t *testing.T) { t.Run("OpaqueID", func(t *testing.T) { var ( - buf bytes.Buffer - res *opensearchapi.Response err error @@ -103,20 +118,10 @@ func TestAPI(t *testing.T) { // Index data // - for j := 1; j <= 1000; j++ { - meta := []byte(fmt.Sprintf(`{ "index" : { "_id" : "%d" } }%s`, j, "\n")) - data := []byte(`{"content":"` + strings.Repeat("ABC", 100) + `"}`) - data = append(data, "\n"...) - - buf.Grow(len(meta) + len(data)) - buf.Write(meta) - buf.Write(data) - } - res, err = client.Bulk(bytes.NewReader(buf.Bytes()), client.Bulk.WithIndex("test"), client.Bulk.WithRefresh("true")) + err = createTestIndex(client, "test") if err != nil { t.Fatalf("Failed to index data: %s", err) } - defer res.Body.Close() // Launch reindexing task with wait_for_completion=false // @@ -228,23 +233,10 @@ func TestAPI(t *testing.T) { // Index data // - var buf bytes.Buffer - for j := 1; j <= 1000; j++ { - meta := []byte(fmt.Sprintf(`{ "index" : { "_id" : "%d" } }%s`, j, "\n")) - data := []byte(`{"content":"` + strings.Repeat("ABC", 100) + `"}`) - data = append(data, "\n"...) - - buf.Grow(len(meta) + len(data)) - buf.Write(meta) - buf.Write(data) - } - - bulkReq := &opensearchapi.BulkRequest{ - Body: bytes.NewReader(buf.Bytes()), - Index: "test", - Refresh: "true", + err = createTestIndex(client, "test") + if err != nil { + t.Fatalf("Failed to index data: %s", err) } - opensearchDo(ctx, client, bulkReq, "index data", t) // Test Snapshot functions // @@ -313,4 +305,76 @@ func TestAPI(t *testing.T) { opensearchDo(ctx, client, sDeleteReq, "delete Snapshots", t) opensearchDo(ctx, client, iDeleteReq, "index data", t) }) + t.Run("Point_in_Time", func(t *testing.T) { + var ( + err error + major, minor int64 + data opensearchapi.InfoResp + ) + index := "test" + + // Create Client + // + client, err := opensearch.NewDefaultClient() + if err != nil { + t.Fatalf("Error creating the client: %s\n", err) + } + + // Skip test if Cluster version is below 2.4.0 + infoResp, err := client.Info() + if err != nil { + t.Fatalf("Error getting the cluster info: %s\n", err) + } + if err = json.NewDecoder(infoResp.Body).Decode(&data); err != nil { + t.Fatalf("Error parsing the cluster info: %s\n", err) + } + major, minor, _, err = opensearch.ParseVersion(data.Version.Number) + if err != nil { + t.Fatalf("Error parsing the cluster version") + } + if major <= 2 && minor < 4 { + return + } + + // Cleanup all existing Pits + // + resp, _, err := client.PointInTime.Delete(client.PointInTime.Delete.WithPitID("_all")) + if err != nil { + if resp != nil && resp.StatusCode != 404 { + t.Fatalf("Failed to Delete all Pits: %s", err) + } + } + + // Index data + // + err = createTestIndex(client, index) + if err != nil { + t.Fatalf("Failed to index data: %s", err) + } + + // Create a Pit + // + keepAlive, _ := time.ParseDuration("5m") + _, pitCreateResp, err := client.PointInTime.Create(client.PointInTime.Create.WithKeepAlive(keepAlive), client.PointInTime.Create.WithIndex(index)) + if err != nil { + t.Fatalf("Failed to create Pit: %s", err) + } + + // Get all Pits + // + _, pitGetResp, err := client.PointInTime.Get() + if err != nil { + t.Fatalf("Failed to get Pits: %s", err) + } + + // Delete the create Pit + // + _, pitDeleteResp, err := client.PointInTime.Delete(client.PointInTime.Delete.WithPitID(pitCreateResp.PitID)) + if err != nil { + t.Fatalf("Failed to delete Pit: %s", err) + } + if (pitCreateResp.PitID != pitGetResp.Pits[0].PitID) || (pitCreateResp.PitID != pitDeleteResp.Pits[0].PitID) { + t.Fatalf("The create Pit does not match the Get Pit or Deleted Pit") + } + }) } From 45fa7f599da2d9a1a203406552e734fcf43a9edc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 Mar 2023 20:02:02 -0700 Subject: [PATCH 18/84] Bump github.com/aws/aws-sdk-go from 1.44.225 to 1.44.230 (#268) * Bump github.com/aws/aws-sdk-go from 1.44.225 to 1.44.230 Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.44.225 to 1.44.230. - [Release notes](https://github.com/aws/aws-sdk-go/releases) - [Commits](https://github.com/aws/aws-sdk-go/compare/v1.44.225...v1.44.230) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Update changelog Signed-off-by: dependabot[bot] --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] --- CHANGELOG.md | 4 ++-- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5722b65..68978b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Dependencies -- Bumps `github.com/aws/aws-sdk-go` from 1.44.45 to 1.44.225 +- Bumps `github.com/aws/aws-sdk-go` from 1.44.45 to 1.44.230 - Bumps `github.com/aws/aws-sdk-go-v2` from 1.17.1 to 1.17.6 - Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.8 to 1.18.18 - Bumps `github.com/stretchr/testify` from 1.8.0 to 1.8.2 @@ -41,4 +41,4 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Security -[Unreleased]: https://github.com/opensearch-project/opensearch-go/compare/2.1...HEAD +[Unreleased]: https://github.com/opensearch-project/opensearch-go/compare/2.1...HEAD \ No newline at end of file diff --git a/go.mod b/go.mod index fcaf1ec..5df9d65 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/opensearch-project/opensearch-go/v2 go 1.15 require ( - github.com/aws/aws-sdk-go v1.44.225 + github.com/aws/aws-sdk-go v1.44.230 github.com/aws/aws-sdk-go-v2 v1.17.6 github.com/aws/aws-sdk-go-v2/config v1.18.18 github.com/stretchr/testify v1.8.2 diff --git a/go.sum b/go.sum index 64b0c33..a0eb9df 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/aws/aws-sdk-go v1.44.225 h1:JNJpUg+M1cm4jtKnyex//Mw1Rv8QN/kWT3dtr+oLdW4= -github.com/aws/aws-sdk-go v1.44.225/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= +github.com/aws/aws-sdk-go v1.44.230 h1:dcn7TjLyx/31I+0XytMGYRxDc756BRUzsSYVcSyKZlk= +github.com/aws/aws-sdk-go v1.44.230/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go-v2 v1.17.6 h1:Y773UK7OBqhzi5VDXMi1zVGsoj+CVHs2eaC2bDsLwi0= github.com/aws/aws-sdk-go-v2 v1.17.6/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= github.com/aws/aws-sdk-go-v2/config v1.18.18 h1:/ePABXvXl3ESlzUGnkkvvNnRFw3Gh13dyqaq0Qo3JcU= From e036fc8ebcbb9838501757e9fc90469b56f3ddff Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 Mar 2023 21:59:11 -0700 Subject: [PATCH 19/84] Bump github.com/aws/aws-sdk-go-v2/config from 1.18.18 to 1.18.19 (#267) * Bump github.com/aws/aws-sdk-go-v2/config from 1.18.18 to 1.18.19 Bumps [github.com/aws/aws-sdk-go-v2/config](https://github.com/aws/aws-sdk-go-v2) from 1.18.18 to 1.18.19. - [Release notes](https://github.com/aws/aws-sdk-go-v2/releases) - [Changelog](https://github.com/aws/aws-sdk-go-v2/blob/main/CHANGELOG.md) - [Commits](https://github.com/aws/aws-sdk-go-v2/compare/config/v1.18.18...config/v1.18.19) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go-v2/config dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Update changelog Signed-off-by: dependabot[bot] --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] --- CHANGELOG.md | 2 +- go.mod | 4 ++-- go.sum | 44 ++++++++++++++++++++++---------------------- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 68978b7..bd082d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Bumps `github.com/aws/aws-sdk-go` from 1.44.45 to 1.44.230 - Bumps `github.com/aws/aws-sdk-go-v2` from 1.17.1 to 1.17.6 -- Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.8 to 1.18.18 +- Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.8 to 1.18.19 - Bumps `github.com/stretchr/testify` from 1.8.0 to 1.8.2 ### Added diff --git a/go.mod b/go.mod index 5df9d65..a7acccb 100644 --- a/go.mod +++ b/go.mod @@ -4,8 +4,8 @@ go 1.15 require ( github.com/aws/aws-sdk-go v1.44.230 - github.com/aws/aws-sdk-go-v2 v1.17.6 - github.com/aws/aws-sdk-go-v2/config v1.18.18 + github.com/aws/aws-sdk-go-v2 v1.17.7 + github.com/aws/aws-sdk-go-v2/config v1.18.19 github.com/stretchr/testify v1.8.2 golang.org/x/net v0.7.0 // indirect ) diff --git a/go.sum b/go.sum index a0eb9df..8bb477a 100644 --- a/go.sum +++ b/go.sum @@ -1,27 +1,27 @@ github.com/aws/aws-sdk-go v1.44.230 h1:dcn7TjLyx/31I+0XytMGYRxDc756BRUzsSYVcSyKZlk= github.com/aws/aws-sdk-go v1.44.230/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= -github.com/aws/aws-sdk-go-v2 v1.17.6 h1:Y773UK7OBqhzi5VDXMi1zVGsoj+CVHs2eaC2bDsLwi0= -github.com/aws/aws-sdk-go-v2 v1.17.6/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= -github.com/aws/aws-sdk-go-v2/config v1.18.18 h1:/ePABXvXl3ESlzUGnkkvvNnRFw3Gh13dyqaq0Qo3JcU= -github.com/aws/aws-sdk-go-v2/config v1.18.18/go.mod h1:Lj3E7XcxJnxMa+AYo89YiL68s1cFJRGduChynYU67VA= -github.com/aws/aws-sdk-go-v2/credentials v1.13.17 h1:IubQO/RNeIVKF5Jy77w/LfUvmmCxTnk2TP1UZZIMiF4= -github.com/aws/aws-sdk-go-v2/credentials v1.13.17/go.mod h1:K9xeFo1g/YPMguMUD69YpwB4Nyi6W/5wn706xIInJFg= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.0 h1:/2Cb3SK3xVOQA7Xfr5nCWCo5H3UiNINtsVvVdk8sQqA= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.0/go.mod h1:neYVaeKr5eT7BzwULuG2YbLhzWZ22lpjKdCybR7AXrQ= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.30 h1:y+8n9AGDjikyXoMBTRaHHHSaFEB8267ykmvyPodJfys= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.30/go.mod h1:LUBAO3zNXQjoONBKn/kR1y0Q4cj/D02Ts0uHYjcCQLM= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.24 h1:r+Kv+SEJquhAZXaJ7G4u44cIwXV3f8K+N482NNAzJZA= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.24/go.mod h1:gAuCezX/gob6BSMbItsSlMb6WZGV7K2+fWOvk8xBSto= -github.com/aws/aws-sdk-go-v2/internal/ini v1.3.31 h1:hf+Vhp5WtTdcSdE+yEcUz8L73sAzN0R+0jQv+Z51/mI= -github.com/aws/aws-sdk-go-v2/internal/ini v1.3.31/go.mod h1:5zUjguZfG5qjhG9/wqmuyHRyUftl2B5Cp6NNxNC6kRA= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.24 h1:c5qGfdbCHav6viBwiyDns3OXqhqAbGjfIB4uVu2ayhk= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.24/go.mod h1:HMA4FZG6fyib+NDo5bpIxX1EhYjrAOveZJY2YR0xrNE= -github.com/aws/aws-sdk-go-v2/service/sso v1.12.5 h1:bdKIX6SVF3nc3xJFw6Nf0igzS6Ff/louGq8Z6VP/3Hs= -github.com/aws/aws-sdk-go-v2/service/sso v1.12.5/go.mod h1:vuWiaDB30M/QTC+lI3Wj6S/zb7tpUK2MSYgy3Guh2L0= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.5 h1:xLPZMyuZ4GuqRCIec/zWuIhRFPXh2UOJdLXBSi64ZWQ= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.5/go.mod h1:QjxpHmCwAg0ESGtPQnLIVp7SedTOBMYy+Slr3IfMKeI= -github.com/aws/aws-sdk-go-v2/service/sts v1.18.6 h1:rIFn5J3yDoeuKCE9sESXqM5POTAhOP1du3bv/qTL+tE= -github.com/aws/aws-sdk-go-v2/service/sts v1.18.6/go.mod h1:48WJ9l3dwP0GSHWGc5sFGGlCkuA82Mc2xnw+T6Q8aDw= +github.com/aws/aws-sdk-go-v2 v1.17.7 h1:CLSjnhJSTSogvqUGhIC6LqFKATMRexcxLZ0i/Nzk9Eg= +github.com/aws/aws-sdk-go-v2 v1.17.7/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= +github.com/aws/aws-sdk-go-v2/config v1.18.19 h1:AqFK6zFNtq4i1EYu+eC7lcKHYnZagMn6SW171la0bGw= +github.com/aws/aws-sdk-go-v2/config v1.18.19/go.mod h1:XvTmGMY8d52ougvakOv1RpiTLPz9dlG/OQHsKU/cMmY= +github.com/aws/aws-sdk-go-v2/credentials v1.13.18 h1:EQMdtHwz0ILTW1hoP+EwuWhwCG1hD6l3+RWFQABET4c= +github.com/aws/aws-sdk-go-v2/credentials v1.13.18/go.mod h1:vnwlwjIe+3XJPBYKu1et30ZPABG3VaXJYr8ryohpIyM= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.1 h1:gt57MN3liKiyGopcqgNzJb2+d9MJaKT/q1OksHNXVE4= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.1/go.mod h1:lfUx8puBRdM5lVVMQlwt2v+ofiG/X6Ms+dy0UkG/kXw= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.31 h1:sJLYcS+eZn5EeNINGHSCRAwUJMFVqklwkH36Vbyai7M= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.31/go.mod h1:QT0BqUvX1Bh2ABdTGnjqEjvjzrCfIniM9Sc8zn9Yndo= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.25 h1:1mnRASEKnkqsntcxHaysxwgVoUUp5dkiB+l3llKnqyg= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.25/go.mod h1:zBHOPwhBc3FlQjQJE/D3IfPWiWaQmT06Vq9aNukDo0k= +github.com/aws/aws-sdk-go-v2/internal/ini v1.3.32 h1:p5luUImdIqywn6JpQsW3tq5GNOxKmOnEpybzPx+d1lk= +github.com/aws/aws-sdk-go-v2/internal/ini v1.3.32/go.mod h1:XGhIBZDEgfqmFIugclZ6FU7v75nHhBDtzuB4xB/tEi4= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.25 h1:5LHn8JQ0qvjD9L9JhMtylnkcw7j05GDZqM9Oin6hpr0= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.25/go.mod h1:/95IA+0lMnzW6XzqYJRpjjsAbKEORVeO0anQqjd2CNU= +github.com/aws/aws-sdk-go-v2/service/sso v1.12.6 h1:5V7DWLBd7wTELVz5bPpwzYy/sikk0gsgZfj40X+l5OI= +github.com/aws/aws-sdk-go-v2/service/sso v1.12.6/go.mod h1:Y1VOmit/Fn6Tz1uFAeCO6Q7M2fmfXSCLeL5INVYsLuY= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.6 h1:B8cauxOH1W1v7rd8RdI/MWnoR4Ze0wIHWrb90qczxj4= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.6/go.mod h1:Lh/bc9XUf8CfOY6Jp5aIkQtN+j1mc+nExc+KXj9jx2s= +github.com/aws/aws-sdk-go-v2/service/sts v1.18.7 h1:bWNgNdRko2x6gqa0blfATqAZKZokPIeM1vfmQt2pnvM= +github.com/aws/aws-sdk-go-v2/service/sts v1.18.7/go.mod h1:JuTnSoeePXmMVe9G8NcjjwgOKEfZ4cOjMuT2IBT/2eI= github.com/aws/smithy-go v1.13.5 h1:hgz0X/DX0dGqTYpGALqXJoRKRj5oQ7150i5FdTePzO8= github.com/aws/smithy-go v1.13.5/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= From 7cc71e4e48532fae96ef09fa00bef5bce20837c7 Mon Sep 17 00:00:00 2001 From: Rakhat <51375666+zethuman@users.noreply.github.com> Date: Mon, 3 Apr 2023 23:50:07 +0600 Subject: [PATCH 20/84] Add testcases to check upsert functionality (#269) Signed-off-by: Rakhat Zhuman --- CHANGELOG.md | 1 + .../bulk_indexer_integration_test.go | 336 +++++++++++------- 2 files changed, 215 insertions(+), 122 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bd082d1..fe4700b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Adds `Err()` function to Response for detailed errors ([#246](https://github.com/opensearch-project/opensearch-go/pull/246)) - 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 testcases to check upsert functionality ([#207](https://github.com/opensearch-project/opensearch-go/issues/207)) ### Changed diff --git a/opensearchutil/bulk_indexer_integration_test.go b/opensearchutil/bulk_indexer_integration_test.go index 3d8d00f..a07677a 100644 --- a/opensearchutil/bulk_indexer_integration_test.go +++ b/opensearchutil/bulk_indexer_integration_test.go @@ -24,6 +24,7 @@ // specific language governing permissions and limitations // under the License. +//go:build integration // +build integration package opensearchutil_test @@ -34,7 +35,6 @@ import ( "os" "strconv" "strings" - "sync/atomic" "testing" "time" @@ -44,158 +44,250 @@ import ( ) func TestBulkIndexerIntegration(t *testing.T) { - body := `{"body":"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat."}` + testRecordCount := uint64(10000) testCases := []struct { name string - CompressRequestBodyEnabled bool + compressRequestBodyEnabled bool + tests []struct { + name string + action string + body string + numItems uint64 + numIndexed uint64 + numCreated uint64 + numUpdated uint64 + numFailed uint64 + } }{ { - name: "Without body compression", - CompressRequestBodyEnabled: false, + name: "With body compression", + compressRequestBodyEnabled: true, + tests: []struct { + name string + action string + body string + numItems uint64 + numIndexed uint64 + numCreated uint64 + numUpdated uint64 + numFailed uint64 + }{ + { + name: "Index", + action: "index", + body: `{"title":"bar"}`, + numItems: testRecordCount, + numIndexed: testRecordCount, + numCreated: 0, + numUpdated: 0, + numFailed: 0, + }, + { + name: "Upsert", + action: "update", + body: `{"doc":{"title":"qwe"}, "doc_as_upsert": true}`, + numItems: testRecordCount, + numIndexed: 0, + numCreated: 0, + numUpdated: testRecordCount, + numFailed: 0, + }, + { + name: "Create", + action: "create", + body: `{"title":"bar"}`, + numItems: testRecordCount, + numIndexed: 0, + numCreated: 0, + numUpdated: 0, + numFailed: testRecordCount, + }, + }, }, { - name: "With body compression", - CompressRequestBodyEnabled: true, + name: "Without body compression", + compressRequestBodyEnabled: false, + tests: []struct { + name string + action string + body string + numItems uint64 + numIndexed uint64 + numCreated uint64 + numUpdated uint64 + numFailed uint64 + }{ + { + name: "Index", + action: "index", + body: `{"title":"bar"}`, + numItems: testRecordCount, + numIndexed: testRecordCount, + numCreated: 0, + numUpdated: 0, + numFailed: 0, + }, + { + name: "Upsert", + action: "update", + body: `{"doc":{"title":"qwe"}, "doc_as_upsert": true}`, + numItems: testRecordCount, + numIndexed: 0, + numCreated: 0, + numUpdated: testRecordCount, + numFailed: 0, + }, + { + name: "Create", + action: "create", + body: `{"title":"bar"}`, + numItems: testRecordCount, + numIndexed: 0, + numCreated: 0, + numUpdated: 0, + numFailed: testRecordCount, + }, + }, }, } - for _, tt := range testCases { - t.Run(tt.name, func(t *testing.T) { - t.Run("Default", func(t *testing.T) { - var countSuccessful uint64 - indexName := "test-bulk-integration" - - client, _ := opensearch.NewClient(opensearch.Config{ - CompressRequestBody: tt.CompressRequestBodyEnabled, - Logger: &opensearchtransport.ColorLogger{Output: os.Stdout}, - }) + for _, c := range testCases { + indexName := "test-bulk-integration" - client.Indices.Delete([]string{indexName}, client.Indices.Delete.WithIgnoreUnavailable(true)) - client.Indices.Create( - indexName, - client.Indices.Create.WithBody(strings.NewReader(`{"settings": {"number_of_shards": 1, "number_of_replicas": 0, "refresh_interval":"5s"}}`)), - client.Indices.Create.WithWaitForActiveShards("1")) + client, _ := opensearch.NewClient(opensearch.Config{ + CompressRequestBody: c.compressRequestBodyEnabled, + Logger: &opensearchtransport.ColorLogger{Output: os.Stdout}, + }) - bi, _ := opensearchutil.NewBulkIndexer(opensearchutil.BulkIndexerConfig{ - Index: indexName, - Client: client, - // FlushBytes: 3e+6, - }) + client.Indices.Delete([]string{indexName}, client.Indices.Delete.WithIgnoreUnavailable(true)) + client.Indices.Create( + indexName, + client.Indices.Create.WithBody(strings.NewReader(`{"settings": {"number_of_shards": 1, "number_of_replicas": 0, "refresh_interval":"5s"}}`)), + client.Indices.Create.WithWaitForActiveShards("1")) - numItems := 100000 - start := time.Now().UTC() - - for i := 1; i <= numItems; i++ { - err := bi.Add(context.Background(), opensearchutil.BulkIndexerItem{ - Action: "index", - DocumentID: strconv.Itoa(i), - Body: strings.NewReader(body), - OnSuccess: func(ctx context.Context, item opensearchutil.BulkIndexerItem, res opensearchutil.BulkIndexerResponseItem) { - atomic.AddUint64(&countSuccessful, 1) - }, + for _, tt := range c.tests { + t.Run(tt.name, func(t *testing.T) { + t.Run(c.name, func(t *testing.T) { + bi, _ := opensearchutil.NewBulkIndexer(opensearchutil.BulkIndexerConfig{ + Index: indexName, + Client: client, + ErrorTrace: true, + Human: true, + Pretty: true, + // FlushBytes: 3e+6, }) - if err != nil { - t.Fatalf("Unexpected error: %s", err) - } - } - if err := bi.Close(context.Background()); err != nil { - t.Errorf("Unexpected error: %s", err) - } + start := time.Now().UTC() - stats := bi.Stats() + for i := 1; i <= int(tt.numItems); i++ { + err := bi.Add(context.Background(), opensearchutil.BulkIndexerItem{ + Index: indexName, + Action: tt.action, + DocumentID: strconv.Itoa(i), + Body: strings.NewReader(tt.body), + }) + if err != nil { + t.Fatalf("Unexpected error: %s", err) + } + } - if stats.NumAdded != uint64(numItems) { - t.Errorf("Unexpected NumAdded: want=%d, got=%d", numItems, stats.NumAdded) - } + if err := bi.Close(context.Background()); err != nil { + t.Errorf("Unexpected error: %s", err) + } - if stats.NumIndexed != uint64(numItems) { - t.Errorf("Unexpected NumIndexed: want=%d, got=%d", numItems, stats.NumIndexed) - } + stats := bi.Stats() - if stats.NumFailed != 0 { - t.Errorf("Unexpected NumFailed: want=0, got=%d", stats.NumFailed) - } + if stats.NumAdded != tt.numItems { + t.Errorf("Unexpected NumAdded: want=%d, got=%d", tt.numItems, stats.NumAdded) + } - if countSuccessful != uint64(numItems) { - t.Errorf("Unexpected countSuccessful: want=%d, got=%d", numItems, countSuccessful) - } + if stats.NumIndexed != tt.numIndexed { + t.Errorf("Unexpected NumIndexed: want=%d, got=%d", tt.numItems, stats.NumIndexed) + } - fmt.Printf(" Added %d documents to indexer. Succeeded: %d. Failed: %d. Requests: %d. Duration: %s (%.0f docs/sec)\n", - stats.NumAdded, - stats.NumFlushed, - stats.NumFailed, - stats.NumRequests, - time.Since(start).Truncate(time.Millisecond), - 1000.0/float64(time.Since(start)/time.Millisecond)*float64(stats.NumFlushed)) - }) + if stats.NumUpdated != tt.numUpdated { + t.Errorf("Unexpected NumUpdated: want=%d, got=%d", tt.numUpdated, stats.NumUpdated) + } - t.Run("Multiple indices", func(t *testing.T) { - client, _ := opensearch.NewClient(opensearch.Config{ - CompressRequestBody: tt.CompressRequestBodyEnabled, - Logger: &opensearchtransport.ColorLogger{Output: os.Stdout}, - }) + if stats.NumCreated != tt.numCreated { + t.Errorf("Unexpected NumCreated: want=%d, got=%d", tt.numCreated, stats.NumCreated) + } - bi, _ := opensearchutil.NewBulkIndexer(opensearchutil.BulkIndexerConfig{ - Index: "test-index-a", - Client: client, + if stats.NumFailed != tt.numFailed { + t.Errorf("Unexpected NumFailed: want=0, got=%d", stats.NumFailed) + } + + fmt.Printf(" Added %d documents to indexer. Succeeded: %d. Failed: %d. Requests: %d. Duration: %s (%.0f docs/sec)\n", + stats.NumAdded, + stats.NumFlushed, + stats.NumFailed, + stats.NumRequests, + time.Since(start).Truncate(time.Millisecond), + 1000.0/float64(time.Since(start)/time.Millisecond)*float64(stats.NumFlushed)) }) - // Default index - for i := 1; i <= 10; i++ { - err := bi.Add(context.Background(), opensearchutil.BulkIndexerItem{ - Action: "index", - DocumentID: strconv.Itoa(i), - Body: strings.NewReader(body), + t.Run("Multiple indices", func(t *testing.T) { + bi, _ := opensearchutil.NewBulkIndexer(opensearchutil.BulkIndexerConfig{ + Index: "test-index-a", + Client: client, }) - if err != nil { - t.Fatalf("Unexpected error: %s", err) + + // Default index + for i := 1; i <= 10; i++ { + err := bi.Add(context.Background(), opensearchutil.BulkIndexerItem{ + Action: "index", + DocumentID: strconv.Itoa(i), + Body: strings.NewReader(tt.body), + }) + if err != nil { + t.Fatalf("Unexpected error: %s", err) + } } - } - - // Index 1 - for i := 1; i <= 10; i++ { - err := bi.Add(context.Background(), opensearchutil.BulkIndexerItem{ - Action: "index", - Index: "test-index-b", - Body: strings.NewReader(body), - }) - if err != nil { - t.Fatalf("Unexpected error: %s", err) + + // Index 1 + for i := 1; i <= 10; i++ { + err := bi.Add(context.Background(), opensearchutil.BulkIndexerItem{ + Action: "index", + Index: "test-index-b", + Body: strings.NewReader(tt.body), + }) + if err != nil { + t.Fatalf("Unexpected error: %s", err) + } } - } - - // Index 2 - for i := 1; i <= 10; i++ { - err := bi.Add(context.Background(), opensearchutil.BulkIndexerItem{ - Action: "index", - Index: "test-index-c", - Body: strings.NewReader(body), - }) + + // Index 2 + for i := 1; i <= 10; i++ { + err := bi.Add(context.Background(), opensearchutil.BulkIndexerItem{ + Action: "index", + Index: "test-index-c", + Body: strings.NewReader(tt.body), + }) + if err != nil { + t.Fatalf("Unexpected error: %s", err) + } + } + + if err := bi.Close(context.Background()); err != nil { + t.Errorf("Unexpected error: %s", err) + } + stats := bi.Stats() + + expectedIndexed := 10 + 10 + 10 + if stats.NumIndexed != uint64(expectedIndexed) { + t.Errorf("Unexpected NumIndexed: want=%d, got=%d", expectedIndexed, stats.NumIndexed) + } + + res, err := client.Indices.Exists([]string{"test-index-a", "test-index-b", "test-index-c"}) if err != nil { t.Fatalf("Unexpected error: %s", err) } - } - - if err := bi.Close(context.Background()); err != nil { - t.Errorf("Unexpected error: %s", err) - } - stats := bi.Stats() - - expectedIndexed := 10 + 10 + 10 - if stats.NumIndexed != uint64(expectedIndexed) { - t.Errorf("Unexpected NumIndexed: want=%d, got=%d", expectedIndexed, stats.NumIndexed) - } - - res, err := client.Indices.Exists([]string{"test-index-a", "test-index-b", "test-index-c"}) - if err != nil { - t.Fatalf("Unexpected error: %s", err) - } - if res.StatusCode != 200 { - t.Errorf("Expected indices to exist, but got a [%s] response", res.Status()) - } + if res.StatusCode != 200 { + t.Errorf("Expected indices to exist, but got a [%s] response", res.Status()) + } + }) }) - }) + } } } From 1554e93e25d520559e240076c4e79266a6dd59b5 Mon Sep 17 00:00:00 2001 From: "Daniel (dB.) Doubrovkine" Date: Mon, 3 Apr 2023 20:11:15 -0400 Subject: [PATCH 21/84] Added @Jakob3xD as a co-maintainer. (#270) Signed-off-by: dblock --- CHANGELOG.md | 2 ++ MAINTAINERS.md | 15 ++++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fe4700b..6e9309d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,12 +21,14 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - 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 testcases to check upsert functionality ([#207](https://github.com/opensearch-project/opensearch-go/issues/207)) +- Added @Jakob3xD to co-maintainers ([#270](https://github.com/opensearch-project/opensearch-go/pull/270)) ### 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)) ### Deprecated diff --git a/MAINTAINERS.md b/MAINTAINERS.md index a4718d3..8a62409 100644 --- a/MAINTAINERS.md +++ b/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 | +| Sven Cowart | [svencowart](https://github.com/svencowart) | | +| Vamshi Vijay Nakkirtha | [vamshin](https://github.com/vamshin) | Amazon | From 516b08d5d40a88d2bdb6587a5295b20d98d9bb1e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Apr 2023 22:41:59 -0700 Subject: [PATCH 22/84] Bump github.com/aws/aws-sdk-go from 1.44.230 to 1.44.235 (#271) * Bump github.com/aws/aws-sdk-go from 1.44.230 to 1.44.235 Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.44.230 to 1.44.235. - [Release notes](https://github.com/aws/aws-sdk-go/releases) - [Commits](https://github.com/aws/aws-sdk-go/compare/v1.44.230...v1.44.235) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Update changelog Signed-off-by: dependabot[bot] --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] --- CHANGELOG.md | 2 +- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e9309d..4718a18 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Dependencies -- Bumps `github.com/aws/aws-sdk-go` from 1.44.45 to 1.44.230 +- Bumps `github.com/aws/aws-sdk-go` from 1.44.45 to 1.44.235 - Bumps `github.com/aws/aws-sdk-go-v2` from 1.17.1 to 1.17.6 - Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.8 to 1.18.19 - Bumps `github.com/stretchr/testify` from 1.8.0 to 1.8.2 diff --git a/go.mod b/go.mod index a7acccb..6062a70 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/opensearch-project/opensearch-go/v2 go 1.15 require ( - github.com/aws/aws-sdk-go v1.44.230 + github.com/aws/aws-sdk-go v1.44.235 github.com/aws/aws-sdk-go-v2 v1.17.7 github.com/aws/aws-sdk-go-v2/config v1.18.19 github.com/stretchr/testify v1.8.2 diff --git a/go.sum b/go.sum index 8bb477a..e9d89d8 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/aws/aws-sdk-go v1.44.230 h1:dcn7TjLyx/31I+0XytMGYRxDc756BRUzsSYVcSyKZlk= -github.com/aws/aws-sdk-go v1.44.230/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= +github.com/aws/aws-sdk-go v1.44.235 h1:5MS1ZW1Pr27mmHFqqjuXYwGMlNTW/g6DqU5ekamPMeU= +github.com/aws/aws-sdk-go v1.44.235/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go-v2 v1.17.7 h1:CLSjnhJSTSogvqUGhIC6LqFKATMRexcxLZ0i/Nzk9Eg= github.com/aws/aws-sdk-go-v2 v1.17.7/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= github.com/aws/aws-sdk-go-v2/config v1.18.19 h1:AqFK6zFNtq4i1EYu+eC7lcKHYnZagMn6SW171la0bGw= From 7cc5fa82a047ddec979d5af2f6f0c4a0d70b583a Mon Sep 17 00:00:00 2001 From: Rakhat <51375666+zethuman@users.noreply.github.com> Date: Tue, 4 Apr 2023 20:03:51 +0600 Subject: [PATCH 23/84] Add markdown linter (#261) * Add linter for markdown files Signed-off-by: Rakhat Zhuman * Updated CHANGELOG.md Signed-off-by: Rakhat Zhuman * Add make-script and update DEVELOPER_GUIDE.md Signed-off-by: Rakhat Zhuman * Updated linter options Signed-off-by: Rakhat Zhuman * Fixed mmarkdown files format Signed-off-by: Rakhat Zhuman --------- Signed-off-by: Rakhat Zhuman --- .github/workflows/lint.yml | 11 ++++++ ADMINS.md | 14 +++---- CHANGELOG.md | 3 +- DEVELOPER_GUIDE.md | 29 ++++++++------ MAINTAINERS.md | 24 ++++++------ Makefile | 37 ++++++++++++++++++ README.md | 8 +--- UPGRADING.md | 12 +++--- USER_GUIDE.md | 77 ++++++++++++++++++++------------------ 9 files changed, 134 insertions(+), 81 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index ed6e387..7422aee 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -27,3 +27,14 @@ jobs: shell: bash - run: go version - run: make lint + + prettify: + name: Prettify + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: { fetch-depth: 1 } + - name: Install dependencies + run: npm i -g npm@8 && npm i -g prettier + - name: Check markdown files + run: prettier --prose-wrap never --check **/*.md diff --git a/ADMINS.md b/ADMINS.md index 1ec1f9e..f9220c9 100644 --- a/ADMINS.md +++ b/ADMINS.md @@ -11,13 +11,13 @@ This document explains who the admins are (see below), what they do in this repo ## 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 diff --git a/CHANGELOG.md b/CHANGELOG.md index 4718a18..5dcc0ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Adds `Err()` function to Response for detailed errors ([#246](https://github.com/opensearch-project/opensearch-go/pull/246)) - 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 ([#207](https://github.com/opensearch-project/opensearch-go/issues/207)) - Added @Jakob3xD to co-maintainers ([#270](https://github.com/opensearch-project/opensearch-go/pull/270)) @@ -44,4 +45,4 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Security -[Unreleased]: https://github.com/opensearch-project/opensearch-go/compare/2.1...HEAD \ No newline at end of file +[Unreleased]: https://github.com/opensearch-project/opensearch-go/compare/2.1...HEAD diff --git a/DEVELOPER_GUIDE.md b/DEVELOPER_GUIDE.md index c4279a2..99eb3ac 100644 --- a/DEVELOPER_GUIDE.md +++ b/DEVELOPER_GUIDE.md @@ -7,6 +7,8 @@ - [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) @@ -18,8 +20,7 @@ So you want to contribute code to the OpenSearch Go Client? Excellent! We're gla ### 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 @@ -48,13 +49,9 @@ 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 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 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 @@ -71,6 +68,18 @@ 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 @@ -80,6 +89,4 @@ 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/MAINTAINERS.md b/MAINTAINERS.md index 8a62409..e68e932 100644 --- a/MAINTAINERS.md +++ b/MAINTAINERS.md @@ -4,18 +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 | -| 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 | +| 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 | -| Rob Cowart | [robcowart](https://github.com/robcowart) | ElastiFlow | -| Sven Cowart | [svencowart](https://github.com/svencowart) | | -| Vamshi Vijay Nakkirtha | [vamshin](https://github.com/vamshin) | Amazon | +| 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/Makefile b/Makefile index 2548e4a..ade9b96 100644 --- a/Makefile +++ b/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) @@ -196,3 +232,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/README.md b/README.md index 8161dfd..bd0260f 100644 --- a/README.md +++ b/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) diff --git a/UPGRADING.md b/UPGRADING.md index 5981282..d09583b 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -1,7 +1,7 @@ - [Upgrading Opensearch GO Client](#upgrading-opensearch-go-client) - - [Upgraading to >= 3.0.0](#upgrading-to->=-3.0.0) - - [opensearchapi](#opensearchapi-snapshot-delete) - - [opensearchapi](#opensearchapi-error-handling) + - [Upgraading to >= 3.0.0](#upgrading-to->=-3.0.0) + - [opensearchapi](#opensearchapi-snapshot-delete) + - [opensearchapi](#opensearchapi-error-handling) # Upgrading Opensearch GO Client @@ -50,11 +50,10 @@ reqSnapshots := &opensearchapi.SnapshotDeleteRequest{ With opensearch-go >= 3.0.0 opensearchapi responses are now checked for errors. Checking for errors twice is no longer needed. -Prior versions only returned an error if the request failed to execute. For example if the client can't reach the server or the TLS handshake failed. -With opensearch-go >= 3.0.0 each opensearchapi requests will return an error if the response http status code is > 299. -The error can be parsed into the new `opensearchapi.Error` type by using `errors.As` to match for exceptions and get a more detailed view. +Prior versions only returned an error if the request failed to execute. For example if the client can't reach the server or the TLS handshake failed. With opensearch-go >= 3.0.0 each opensearchapi requests will return an error if the response http status code is > 299. The error can be parsed into the new `opensearchapi.Error` type by using `errors.As` to match for exceptions and get a more detailed view. Before 3.0.0: + ```go createIndex := opensearchapi.IndicesCreateRequest{ Index: IndexName, @@ -94,4 +93,3 @@ if err != nil { } } ``` - diff --git a/USER_GUIDE.md b/USER_GUIDE.md index db4a128..da129b1 100644 --- a/USER_GUIDE.md +++ b/USER_GUIDE.md @@ -1,21 +1,18 @@ - [User Guide](#user-guide) - - [Example](#example) - - [Amazon OpenSearch Service](#amazon-opensearch-service) - - [AWS SDK V1](#aws-sdk-v1) - - [AWS SDK V2](#aws-sdk-v2) - - [Data Streams API](#data-streams-api) - - [Create Data Stream](#create-data-streams) - - [Delete Data Stream](#delete-data-streams) - - [Get All Data Streams](#get-data-streams) - - [Get Specific Data Stream](#get-specific-data-streams) - - [Get Specific Data Stream Stats](#get-specific-data-streams-stats) + - [Example](#example) + - [Amazon OpenSearch Service](#amazon-opensearch-service) - [AWS SDK V1](#aws-sdk-v1) - [AWS SDK V2](#aws-sdk-v2) + - [Data Streams API](#data-streams-api) + - [Create Data Stream](#create-data-streams) + - [Delete Data Stream](#delete-data-streams) + - [Get All Data Streams](#get-data-streams) + - [Get Specific Data Stream](#get-specific-data-streams) + - [Get Specific Data Stream Stats](#get-specific-data-streams-stats) # 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 @@ -171,26 +168,17 @@ func example() error { ## 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) -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 @@ -344,7 +332,8 @@ func getCredentialProvider(accessKey, secretAccessKey, token string) aws.Credent ### Create Data Streams - - Create new client +- Create new client + ``` client, err := opensearch.NewDefaultClient() if err != nil { @@ -352,7 +341,7 @@ if err != nil { } ``` - - Create template index +- Create template index ``` iPut := opensearchapi.IndicesPutIndexTemplateRequest{ @@ -365,7 +354,8 @@ iPut := opensearchapi.IndicesPutIndexTemplateRequest{ iPutResponse, err := iPut.Do(context.Background(), client) ``` - - Prepare request object +- Prepare request object + ``` es := opensearchapi.IndicesCreateDataStreamRequest{ Name: "demo-name", @@ -378,7 +368,8 @@ es := opensearchapi.IndicesCreateDataStreamRequest{ } ``` - - Execute request +- Execute request + ``` res, err := es.Do(context.TODO(), client) if err != nil { @@ -387,7 +378,8 @@ if err != nil { } ``` - - Try to read response +- Try to read response + ``` defer res.Body.Close() body, err := ioutil.ReadAll(res.Body) @@ -401,7 +393,8 @@ fmt.Println("Response Headers: ", res.Header) fmt.Println("Response Body: ", string(body)) ``` - - Successfully created data stream +- Successfully created data stream + ``` Response Status Code: 200 Response Headers: map[Content-Length:[28] Content-Type:[application/json; charset=UTF-8]] @@ -410,8 +403,9 @@ Response Body: {"acknowledged" : true} ### Delete Data Streams - - Create new client as previous example - - Prepare request object +- Create new client as previous example +- Prepare request object + ``` opensearchapi.IndicesDeleteDataStreamRequest{ Name: "demo-name", @@ -423,9 +417,11 @@ opensearchapi.IndicesDeleteDataStreamRequest{ }, } ``` + - Execute request as previous example - Try to read response as previous example -- Successfully deleted data stream +- Successfully deleted data stream + ``` Response Status Code: 200 Response Headers: map[Content-Length:[28] Content-Type:[application/json; charset=UTF-8]] @@ -436,6 +432,7 @@ Response Body: {"acknowledged" : true} - Create new client as previous example - Prepare request object + ``` r := opensearchapi.IndicesGetDataStreamRequest{ Pretty: true, @@ -446,9 +443,11 @@ r := opensearchapi.IndicesGetDataStreamRequest{ }, } ``` + - Execute request as previous example - Try to read response as previous example - Successfully retrieved data streams + ``` Response Status Code: 200 Response Headers: map[Content-Length:[28] Content-Type:[application/json; charset=UTF-8]] @@ -459,6 +458,7 @@ Response Body: {"data_streams":[{"name":"demo-name","timestamp_field":{"n - Create new client as previous example - Prepare request object + ``` r := opensearchapi.IndicesGetDataStreamRequest{ Name: "demo-name", @@ -470,9 +470,11 @@ r := opensearchapi.IndicesGetDataStreamRequest{ }, } ``` + - Execute request as previous example - Try to read response as previous example - Successfully retrieved data stream + ``` Response Status Code: 200 Response Headers: map[Content-Length:[28] Content-Type:[application/json; charset=UTF-8]] @@ -483,6 +485,7 @@ Response Body: {"data_streams":[{"name":"demo-name","timestamp_field":{"n - Create new client as as previous example - Prepare request object + ``` r := opensearchapi.IndicesGetDataStreamStatsRequest{ Name: "demo-name", @@ -494,11 +497,13 @@ r := opensearchapi.IndicesGetDataStreamStatsRequest{ }, } ``` + - Execute request as previous example - Try to read response as previous example - Successfully retrieved data stream stats + ``` Response Status Code: 200 Response Headers: map[Content-Length:[28] Content-Type:[application/json; charset=UTF-8]] Response Body: {"_shards":{"total":2,"successful":1,"failed":0},"data_stream_count":1,"backing_indices":1,"total_store_size":"208b","total_store_size_bytes":208,"data_streams":[{"data_stream":"demo-name","backing_indices":1,"store_size":"208b","store_size_bytes":208,"maximum_timestamp":0}]} -``` \ No newline at end of file +``` From 8f127f0642b9081937bea2d64260801d26a54563 Mon Sep 17 00:00:00 2001 From: "Daniel (dB.) Doubrovkine" Date: Tue, 4 Apr 2023 13:07:47 -0400 Subject: [PATCH 24/84] Added Jakob3xD to CODEOWNERS, removed @svencowart. (#272) Signed-off-by: dblock --- .github/CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 890116d..d22bb71 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,2 +1,2 @@ # This should match the team set up in https://github.com/orgs/opensearch-project/teams and include any additional contributors -* @dblock @VijayanB @svencowart @VachaShah \ No newline at end of file +* @dblock @VijayanB @VachaShah @Jakob3xD \ No newline at end of file From 926535da9ecb966f5cf7ecb593569aec27f9f9e3 Mon Sep 17 00:00:00 2001 From: Jakob Date: Mon, 10 Apr 2023 23:01:48 +0200 Subject: [PATCH 25/84] opensearchapi: Fix handling of errors without error response body (#286) Signed-off-by: Jakob Hahn --- CHANGELOG.md | 3 +- opensearchapi/opensearchapi.error.go | 2 +- opensearchapi/opensearchapi.response.go | 3 +- .../opensearchapi_response_internal_test.go | 28 ++++++++++++++++--- 4 files changed, 29 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5dcc0ad..2ef5ba9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,7 +22,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - 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 ([#207](https://github.com/opensearch-project/opensearch-go/issues/207)) -- Added @Jakob3xD to co-maintainers ([#270](https://github.com/opensearch-project/opensearch-go/pull/270)) +- Adds @Jakob3xD to co-maintainers ([#270](https://github.com/opensearch-project/opensearch-go/pull/270)) ### Changed @@ -42,6 +42,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Renames the sequence number struct tag to `if_seq_no` to fix optimistic concurrency control ([#166](https://github.com/opensearch-project/opensearch-go/pull/166)) - Fixes `RetryOnConflict` on bulk indexer ([#215](https://github.com/opensearch-project/opensearch-go/pull/215)) - 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 diff --git a/opensearchapi/opensearchapi.error.go b/opensearchapi/opensearchapi.error.go index cfaa155..5c5a305 100644 --- a/opensearchapi/opensearchapi.error.go +++ b/opensearchapi/opensearchapi.error.go @@ -49,5 +49,5 @@ type RootCause struct { // Error returns a string. func (e *Error) Error() string { - return fmt.Sprintf("error: %s, status: %d", e.Err, e.Status) + return fmt.Sprintf("status: %d, type: %s, reason: %s, root_cause: %s", e.Status, e.Err.Type, e.Err.Reason, e.Err.RootCause) } diff --git a/opensearchapi/opensearchapi.response.go b/opensearchapi/opensearchapi.response.go index d4344ee..0f4c561 100644 --- a/opensearchapi/opensearchapi.response.go +++ b/opensearchapi/opensearchapi.response.go @@ -33,6 +33,7 @@ import ( "io" "io/ioutil" "net/http" + "reflect" "strconv" "strings" ) @@ -120,7 +121,7 @@ func (r *Response) Err() error { } var e *Error err = json.Unmarshal(body, &e) - if err == nil { + if err == nil && !reflect.ValueOf(e.Err).IsZero() { return e } return fmt.Errorf("status: %d, error: %s", r.StatusCode, string(body)) diff --git a/opensearchapi/opensearchapi_response_internal_test.go b/opensearchapi/opensearchapi_response_internal_test.go index 57fd6a9..0cdc7c6 100644 --- a/opensearchapi/opensearchapi_response_internal_test.go +++ b/opensearchapi/opensearchapi_response_internal_test.go @@ -46,6 +46,7 @@ func TestAPIResponse(t *testing.T) { var ( body string res *Response + err error ) t.Run("String", func(t *testing.T) { @@ -108,16 +109,36 @@ func TestAPIResponse(t *testing.T) { t.Run("Error", func(t *testing.T) { res = &Response{StatusCode: 201} - if err := res.Err(); err != nil { + if err = res.Err(); err != nil { t.Errorf("Unexpected error for response: %s", res.Status()) } res = &Response{StatusCode: 403} - if err := res.Err(); err == nil { + if err = res.Err(); err == nil { t.Errorf("Expected error for response: %s", res.Status()) } + res = &Response{ + StatusCode: 404, + Body: io.NopCloser( + strings.NewReader(` + { + "_index":"index", + "_id":"2", + "matched":false + }`), + ), + } + err = res.Err() + if err == nil { + t.Errorf("Expected error for response: %s", res.Status()) + } + var errTest *Error + if errors.As(err, &errTest) { + t.Errorf("Expected error NOT to be of type opensearchapi.Error: %T", err) + } + res = &Response{ StatusCode: 400, Body: io.NopCloser( @@ -139,11 +160,10 @@ func TestAPIResponse(t *testing.T) { }`)), } - err := res.Err() + err = res.Err() if err == nil { t.Errorf("Expected error for response: %s", res.Status()) } - var errTest *Error if !errors.As(err, &errTest) { t.Errorf("Expected error to be of type opensearchapi.Error: %T", err) } From dae613e210fc31bf3d69c2a53f0941dc2246ac12 Mon Sep 17 00:00:00 2001 From: Vacha Shah Date: Tue, 11 Apr 2023 13:58:31 -0700 Subject: [PATCH 26/84] Add prettier formatting to dependabot prs (#297) Signed-off-by: Vacha Shah --- .github/workflows/dependabot_pr.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/dependabot_pr.yml b/.github/workflows/dependabot_pr.yml index 3acba18..29898e5 100644 --- a/.github/workflows/dependabot_pr.yml +++ b/.github/workflows/dependabot_pr.yml @@ -33,6 +33,9 @@ jobs: uses: dangoslen/dependabot-changelog-helper@v2 with: version: 'Unreleased' + + - name: Format markdown files with prettier + run: prettier --prose-wrap never --write **/*.md - name: Commit the changes uses: stefanzweifel/git-auto-commit-action@v4 From e8de6f3169ec37840c8c01b1bd0a8b2890117703 Mon Sep 17 00:00:00 2001 From: Jakob Date: Tue, 11 Apr 2023 23:49:27 +0200 Subject: [PATCH 27/84] Install prettier dependency in workflow for dependabot (#299) Signed-off-by: Jakob Hahn --- .github/workflows/dependabot_pr.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/dependabot_pr.yml b/.github/workflows/dependabot_pr.yml index 29898e5..619665e 100644 --- a/.github/workflows/dependabot_pr.yml +++ b/.github/workflows/dependabot_pr.yml @@ -34,6 +34,9 @@ jobs: with: version: 'Unreleased' + - name: Install dependencies + run: npm i -g npm@8 && npm i -g prettier + - name: Format markdown files with prettier run: prettier --prose-wrap never --write **/*.md From ccd4401e3821233f17d01d57d8f7ce641d2a4107 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 11 Apr 2023 15:02:21 -0700 Subject: [PATCH 28/84] Bump github.com/aws/aws-sdk-go from 1.44.235 to 1.44.241 (#298) * Bump github.com/aws/aws-sdk-go from 1.44.235 to 1.44.241 Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.44.235 to 1.44.241. - [Release notes](https://github.com/aws/aws-sdk-go/releases) - [Commits](https://github.com/aws/aws-sdk-go/compare/v1.44.235...v1.44.241) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Update changelog Signed-off-by: dependabot[bot] --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] --- CHANGELOG.md | 2 +- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ef5ba9..b7f39ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Dependencies -- Bumps `github.com/aws/aws-sdk-go` from 1.44.45 to 1.44.235 +- Bumps `github.com/aws/aws-sdk-go` from 1.44.45 to 1.44.241 - Bumps `github.com/aws/aws-sdk-go-v2` from 1.17.1 to 1.17.6 - Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.8 to 1.18.19 - Bumps `github.com/stretchr/testify` from 1.8.0 to 1.8.2 diff --git a/go.mod b/go.mod index 6062a70..db1922d 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/opensearch-project/opensearch-go/v2 go 1.15 require ( - github.com/aws/aws-sdk-go v1.44.235 + github.com/aws/aws-sdk-go v1.44.241 github.com/aws/aws-sdk-go-v2 v1.17.7 github.com/aws/aws-sdk-go-v2/config v1.18.19 github.com/stretchr/testify v1.8.2 diff --git a/go.sum b/go.sum index e9d89d8..cf3a935 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/aws/aws-sdk-go v1.44.235 h1:5MS1ZW1Pr27mmHFqqjuXYwGMlNTW/g6DqU5ekamPMeU= -github.com/aws/aws-sdk-go v1.44.235/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= +github.com/aws/aws-sdk-go v1.44.241 h1:D3KycZq3HjhmjYGzvTcmX/Ztf/KNmsfTmdDuKdnzZKo= +github.com/aws/aws-sdk-go v1.44.241/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go-v2 v1.17.7 h1:CLSjnhJSTSogvqUGhIC6LqFKATMRexcxLZ0i/Nzk9Eg= github.com/aws/aws-sdk-go-v2 v1.17.7/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= github.com/aws/aws-sdk-go-v2/config v1.18.19 h1:AqFK6zFNtq4i1EYu+eC7lcKHYnZagMn6SW171la0bGw= From 486e5e9cffda6401a5f27e22fd62a6fc990e46a0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 11 Apr 2023 15:19:13 -0700 Subject: [PATCH 29/84] Bump github.com/aws/aws-sdk-go-v2/config from 1.18.19 to 1.18.21 (#295) * Bump github.com/aws/aws-sdk-go-v2/config from 1.18.19 to 1.18.21 Bumps [github.com/aws/aws-sdk-go-v2/config](https://github.com/aws/aws-sdk-go-v2) from 1.18.19 to 1.18.21. - [Release notes](https://github.com/aws/aws-sdk-go-v2/releases) - [Changelog](https://github.com/aws/aws-sdk-go-v2/blob/main/CHANGELOG.md) - [Commits](https://github.com/aws/aws-sdk-go-v2/compare/config/v1.18.19...config/v1.18.21) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go-v2/config dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Update changelog Signed-off-by: dependabot[bot] --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] --- CHANGELOG.md | 2 +- go.mod | 4 ++-- go.sum | 44 ++++++++++++++++++++++---------------------- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b7f39ed..b1edbee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Bumps `github.com/aws/aws-sdk-go` from 1.44.45 to 1.44.241 - Bumps `github.com/aws/aws-sdk-go-v2` from 1.17.1 to 1.17.6 -- Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.8 to 1.18.19 +- Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.8 to 1.18.21 - Bumps `github.com/stretchr/testify` from 1.8.0 to 1.8.2 ### Added diff --git a/go.mod b/go.mod index db1922d..7f6d222 100644 --- a/go.mod +++ b/go.mod @@ -4,8 +4,8 @@ go 1.15 require ( github.com/aws/aws-sdk-go v1.44.241 - github.com/aws/aws-sdk-go-v2 v1.17.7 - github.com/aws/aws-sdk-go-v2/config v1.18.19 + github.com/aws/aws-sdk-go-v2 v1.17.8 + github.com/aws/aws-sdk-go-v2/config v1.18.21 github.com/stretchr/testify v1.8.2 golang.org/x/net v0.7.0 // indirect ) diff --git a/go.sum b/go.sum index cf3a935..da831e0 100644 --- a/go.sum +++ b/go.sum @@ -1,27 +1,27 @@ github.com/aws/aws-sdk-go v1.44.241 h1:D3KycZq3HjhmjYGzvTcmX/Ztf/KNmsfTmdDuKdnzZKo= github.com/aws/aws-sdk-go v1.44.241/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= -github.com/aws/aws-sdk-go-v2 v1.17.7 h1:CLSjnhJSTSogvqUGhIC6LqFKATMRexcxLZ0i/Nzk9Eg= -github.com/aws/aws-sdk-go-v2 v1.17.7/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= -github.com/aws/aws-sdk-go-v2/config v1.18.19 h1:AqFK6zFNtq4i1EYu+eC7lcKHYnZagMn6SW171la0bGw= -github.com/aws/aws-sdk-go-v2/config v1.18.19/go.mod h1:XvTmGMY8d52ougvakOv1RpiTLPz9dlG/OQHsKU/cMmY= -github.com/aws/aws-sdk-go-v2/credentials v1.13.18 h1:EQMdtHwz0ILTW1hoP+EwuWhwCG1hD6l3+RWFQABET4c= -github.com/aws/aws-sdk-go-v2/credentials v1.13.18/go.mod h1:vnwlwjIe+3XJPBYKu1et30ZPABG3VaXJYr8ryohpIyM= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.1 h1:gt57MN3liKiyGopcqgNzJb2+d9MJaKT/q1OksHNXVE4= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.1/go.mod h1:lfUx8puBRdM5lVVMQlwt2v+ofiG/X6Ms+dy0UkG/kXw= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.31 h1:sJLYcS+eZn5EeNINGHSCRAwUJMFVqklwkH36Vbyai7M= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.31/go.mod h1:QT0BqUvX1Bh2ABdTGnjqEjvjzrCfIniM9Sc8zn9Yndo= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.25 h1:1mnRASEKnkqsntcxHaysxwgVoUUp5dkiB+l3llKnqyg= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.25/go.mod h1:zBHOPwhBc3FlQjQJE/D3IfPWiWaQmT06Vq9aNukDo0k= -github.com/aws/aws-sdk-go-v2/internal/ini v1.3.32 h1:p5luUImdIqywn6JpQsW3tq5GNOxKmOnEpybzPx+d1lk= -github.com/aws/aws-sdk-go-v2/internal/ini v1.3.32/go.mod h1:XGhIBZDEgfqmFIugclZ6FU7v75nHhBDtzuB4xB/tEi4= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.25 h1:5LHn8JQ0qvjD9L9JhMtylnkcw7j05GDZqM9Oin6hpr0= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.25/go.mod h1:/95IA+0lMnzW6XzqYJRpjjsAbKEORVeO0anQqjd2CNU= -github.com/aws/aws-sdk-go-v2/service/sso v1.12.6 h1:5V7DWLBd7wTELVz5bPpwzYy/sikk0gsgZfj40X+l5OI= -github.com/aws/aws-sdk-go-v2/service/sso v1.12.6/go.mod h1:Y1VOmit/Fn6Tz1uFAeCO6Q7M2fmfXSCLeL5INVYsLuY= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.6 h1:B8cauxOH1W1v7rd8RdI/MWnoR4Ze0wIHWrb90qczxj4= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.6/go.mod h1:Lh/bc9XUf8CfOY6Jp5aIkQtN+j1mc+nExc+KXj9jx2s= -github.com/aws/aws-sdk-go-v2/service/sts v1.18.7 h1:bWNgNdRko2x6gqa0blfATqAZKZokPIeM1vfmQt2pnvM= -github.com/aws/aws-sdk-go-v2/service/sts v1.18.7/go.mod h1:JuTnSoeePXmMVe9G8NcjjwgOKEfZ4cOjMuT2IBT/2eI= +github.com/aws/aws-sdk-go-v2 v1.17.8 h1:GMupCNNI7FARX27L7GjCJM8NgivWbRgpjNI/hOQjFS8= +github.com/aws/aws-sdk-go-v2 v1.17.8/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= +github.com/aws/aws-sdk-go-v2/config v1.18.21 h1:ENTXWKwE8b9YXgQCsruGLhvA9bhg+RqAsL9XEMEsa2c= +github.com/aws/aws-sdk-go-v2/config v1.18.21/go.mod h1:+jPQiVPz1diRnjj6VGqWcLK6EzNmQ42l7J3OqGTLsSY= +github.com/aws/aws-sdk-go-v2/credentials v1.13.20 h1:oZCEFcrMppP/CNiS8myzv9JgOzq2s0d3v3MXYil/mxQ= +github.com/aws/aws-sdk-go-v2/credentials v1.13.20/go.mod h1:xtZnXErtbZ8YGXC3+8WfajpMBn5Ga/3ojZdxHq6iI8o= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.2 h1:jOzQAesnBFDmz93feqKnsTHsXrlwWORNZMFHMV+WLFU= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.2/go.mod h1:cDh1p6XkSGSwSRIArWRc6+UqAQ7x4alQ0QfpVR6f+co= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.32 h1:dpbVNUjczQ8Ae3QKHbpHBpfvaVkRdesxpTOe9pTouhU= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.32/go.mod h1:RudqOgadTWdcS3t/erPQo24pcVEoYyqj/kKW5Vya21I= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.26 h1:QH2kOS3Ht7x+u0gHCh06CXL/h6G8LQJFpZfFBYBNboo= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.26/go.mod h1:vq86l7956VgFr0/FWQ2BWnK07QC3WYsepKzy33qqY5U= +github.com/aws/aws-sdk-go-v2/internal/ini v1.3.33 h1:HbH1VjUgrCdLJ+4lnnuLI4iVNRvBbBELGaJ5f69ClA8= +github.com/aws/aws-sdk-go-v2/internal/ini v1.3.33/go.mod h1:zG2FcwjQarWaqXSCGpgcr3RSjZ6dHGguZSppUL0XR7Q= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.26 h1:uUt4XctZLhl9wBE1L8lobU3bVN8SNUP7T+olb0bWBO4= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.26/go.mod h1:Bd4C/4PkVGubtNe5iMXu5BNnaBi/9t/UsFspPt4ram8= +github.com/aws/aws-sdk-go-v2/service/sso v1.12.8 h1:5cb3D6xb006bPTqEfCNaEA6PPEfBXxxy4NNeX/44kGk= +github.com/aws/aws-sdk-go-v2/service/sso v1.12.8/go.mod h1:GNIveDnP+aE3jujyUSH5aZ/rktsTM5EvtKnCqBZawdw= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.8 h1:NZaj0ngZMzsubWZbrEFSB4rgSQRbFq38Sd6KBxHuOIU= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.8/go.mod h1:44qFP1g7pfd+U+sQHLPalAPKnyfTZjJsYR4xIwsJy5o= +github.com/aws/aws-sdk-go-v2/service/sts v1.18.9 h1:Qf1aWwnsNkyAoqDqmdM3nHwN78XQjec27LjM6b9vyfI= +github.com/aws/aws-sdk-go-v2/service/sts v1.18.9/go.mod h1:yyW88BEPXA2fGFyI2KCcZC3dNpiT0CZAHaF+i656/tQ= github.com/aws/smithy-go v1.13.5 h1:hgz0X/DX0dGqTYpGALqXJoRKRj5oQ7150i5FdTePzO8= github.com/aws/smithy-go v1.13.5/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= From 27a2f093add007e24f198364754d3cf53b9a1812 Mon Sep 17 00:00:00 2001 From: Rakhat <51375666+zethuman@users.noreply.github.com> Date: Sat, 15 Apr 2023 00:29:57 +0600 Subject: [PATCH 30/84] Adds dynamic type to _source field (#285) * Add testcases to check upsert functionality Signed-off-by: Rakhat Zhuman * Changed type of _source field Signed-off-by: Rakhat Zhuman * Fixed changes in CHANGELOG.md Signed-off-by: Rakhat Zhuman * Fixed markdown linter issues Signed-off-by: Rakhat Zhuman * Fixed version conflicts Signed-off-by: Rakhat Zhuman * Changed if constructor Signed-off-by: Rakhat Zhuman * Remove commented part Signed-off-by: Rakhat Zhuman * Update CHANGELOG.md Signed-off-by: Rakhat Zhuman * Add test for explain method Signed-off-by: Rakhat Zhuman --------- Signed-off-by: Rakhat Zhuman --- CHANGELOG.md | 2 + opensearchapi/api.bulk.go | 14 +- opensearchapi/api.delete_by_query.go | 14 +- opensearchapi/api.document_test.go | 334 +++++++++++++++++++++++++++ opensearchapi/api.exists.go | 16 +- opensearchapi/api.exists_source.go | 16 +- opensearchapi/api.explain.go | 16 +- opensearchapi/api.get.go | 16 +- opensearchapi/api.get_source.go | 16 +- opensearchapi/api.mget.go | 14 +- opensearchapi/api.search.go | 14 +- opensearchapi/api.update.go | 16 +- opensearchapi/api.update_by_query.go | 14 +- 13 files changed, 441 insertions(+), 61 deletions(-) create mode 100644 opensearchapi/api.document_test.go diff --git a/CHANGELOG.md b/CHANGELOG.md index b1edbee..4bcfe06 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,8 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Adds markdown linter ([#261](https://github.com/opensearch-project/opensearch-go/pull/261)) - Adds testcases to check upsert functionality ([#207](https://github.com/opensearch-project/opensearch-go/issues/207)) - Adds @Jakob3xD to co-maintainers ([#270](https://github.com/opensearch-project/opensearch-go/pull/270)) +- Adds dynamic type to \_source field ([#158](https://github.com/opensearch-project/opensearch-go/issues/158)) +- Adds testcases for Document API ([#280](https://github.com/opensearch-project/opensearch-go/issues/280)) ### Changed diff --git a/opensearchapi/api.bulk.go b/opensearchapi/api.bulk.go index 261deb0..b19db6a 100644 --- a/opensearchapi/api.bulk.go +++ b/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/opensearchapi/api.delete_by_query.go b/opensearchapi/api.delete_by_query.go index 0e9509b..f5cb183 100644 --- a/opensearchapi/api.delete_by_query.go +++ b/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/opensearchapi/api.document_test.go b/opensearchapi/api.document_test.go new file mode 100644 index 0000000..d9ead2f --- /dev/null +++ b/opensearchapi/api.document_test.go @@ -0,0 +1,334 @@ +// 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. + +//go:build integration +// +build integration + +package opensearchapi_test + +import ( + "bytes" + "context" + "encoding/json" + "fmt" + "github.com/opensearch-project/opensearch-go/v2" + "github.com/opensearch-project/opensearch-go/v2/opensearchapi" + "github.com/stretchr/testify/require" + "io/ioutil" + "net/http" + "regexp" + "strings" + "testing" + "time" +) + +func TestDocumentRequest_Do(t *testing.T) { + index := fmt.Sprintf("index-%s", time.Now().Format("2006-01-02-15-04-05")) + + tests := []struct { + name string + r DataStreamRequest + want *opensearchapi.Response + wantBody string + wantErr bool + refresh bool + }{ + // Create document + { + name: "TestCreateRequest_Do", + r: opensearchapi.CreateRequest{ + Index: index, + DocumentID: "1", + Body: strings.NewReader(`{ "title": "Moneyball", "director": "Bennett Miller", "year": "2011" }`), + }, + want: &opensearchapi.Response{ + StatusCode: 201, + Header: http.Header{ + "Content-Type": []string{"application/json; charset=UTF-8"}, + "Location": []string{fmt.Sprintf("/%s/_doc/1", index)}, + }, + }, + wantBody: fmt.Sprintf(`{"_index":"%s","_id":"1","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":0,"_primary_term":1}`, index), + wantErr: false, + }, + { + name: "TestCreateRequest_Do", + r: opensearchapi.CreateRequest{ + Index: index, + DocumentID: "2", + Body: strings.NewReader(`{ "title": "Tenet", "director": "Christopher Nolan", "year": "2019" }`), + }, + want: &opensearchapi.Response{ + StatusCode: 201, + Header: http.Header{ + "Content-Type": []string{"application/json; charset=UTF-8"}, + "Location": []string{fmt.Sprintf("/%s/_doc/2", index)}, + }, + }, + wantBody: fmt.Sprintf(`{"_index":"%s","_id":"2","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":1,"_primary_term":1}`, index), + wantErr: false, + }, + + // Get document + { + name: "TestGetRequest_Do", + r: opensearchapi.GetRequest{ + Index: index, + DocumentID: "2", + Source: true, + }, + want: &opensearchapi.Response{ + StatusCode: 200, + Header: http.Header{ + "Content-Type": []string{"application/json; charset=UTF-8"}, + }, + }, + wantBody: fmt.Sprintf(`{"_id":"2", "_index":"%s", "_primary_term":1, "_seq_no":1, "_source": {"director":"Christopher Nolan", "title":"Tenet", "year":"2019"}, "_version":1, "found":true}`, index), + wantErr: false, + }, + // Get multiple documents + { + name: "TestMultiGetRequest_Do. Source parameter is a bool and slice of strings", + r: opensearchapi.MgetRequest{ + Index: index, + Body: strings.NewReader(`{ "docs": [ { "_id": "1", "_source": true }, { "_id": "2", "_source": [ "title" ] } ] }`), + // seems to does not work + Source: false, + }, + want: &opensearchapi.Response{ + StatusCode: 200, + Header: http.Header{ + "Content-Type": []string{"application/json; charset=UTF-8"}, + }, + }, + wantBody: fmt.Sprintf(`{ "docs": [ { "_id": "1", "_index": "%s", "_primary_term": 1, "_seq_no": 0, "_source": { "director": "Bennett Miller", "title": "Moneyball", "year": "2011" }, "_version": 1, "found": true }, { "_id": "2", "_index": "%s", "_primary_term": 1, "_seq_no": 1, "_source": {"title":"Tenet"}, "_version": 1, "found": true } ] }`, index, index), + wantErr: false, + }, + // Get source document + { + name: "TestGetSourceRequest_Do. Source parameter is a bool and slice of strings", + r: opensearchapi.GetSourceRequest{ + Index: index, + DocumentID: "2", + }, + want: &opensearchapi.Response{ + StatusCode: 200, + Header: http.Header{ + "Content-Type": []string{"application/json; charset=UTF-8"}, + }, + }, + wantBody: `{"director":"Christopher Nolan", "title":"Tenet", "year":"2019"}`, + wantErr: false, + }, + + // Exists document + { + name: "TestExistsRequest_Do", + r: opensearchapi.ExistsRequest{ + Index: index, + DocumentID: "2", + Source: true, + }, + want: &opensearchapi.Response{ + StatusCode: 200, + Header: http.Header{ + "Content-Type": []string{"application/json; charset=UTF-8"}, + "Content-Length": []string{"189"}, + }, + }, + wantBody: ``, + wantErr: false, + }, + + // Explain document + { + name: "TestExplainRequest_Do", + r: opensearchapi.ExplainRequest{ + Index: index, + DocumentID: "2", + Query: `title: "Tenet"`, + Source: true, + }, + want: &opensearchapi.Response{ + StatusCode: 200, + Header: http.Header{ + "Content-Type": []string{"application/json; charset=UTF-8"}, + }, + }, + wantBody: ``, + wantErr: false, + refresh: true, + }, + + // Search document + { + name: "TestSearchRequest_Do. Source parameter is a slice of strings", + r: opensearchapi.SearchRequest{ + Index: []string{index}, + Body: strings.NewReader(`{ "query": { "match": { "title": "Tenet" } } }`), + Source: true, + }, + want: &opensearchapi.Response{ + StatusCode: 200, + Header: http.Header{ + "Content-Type": []string{"application/json; charset=UTF-8"}, + }, + }, + wantBody: fmt.Sprintf(`{"took":0,"timed_out":false,"_shards":{"total":4,"successful":4,"skipped":0,"failed":0},"hits":{"total":{"value":1,"relation":"eq"},"max_score":0.6931471,"hits":[{"_index":"%s","_id":"2","_score":0.6931471,"_source":{ "title": "Tenet", "director": "Christopher Nolan", "year": "2019" }}]}}`, index), + wantErr: false, + refresh: true, + }, + + // Update document + { + name: "TestUpdateRequest_Do", + r: opensearchapi.UpdateRequest{ + Index: index, + DocumentID: "1", + Body: strings.NewReader(`{ "doc": { "title": "Moneyball", "director": "Bennett", "year": "2012" } }`), + Source: nil, + }, + want: &opensearchapi.Response{ + StatusCode: 200, + Header: http.Header{ + "Content-Type": []string{"application/json; charset=UTF-8"}, + }, + }, + wantBody: fmt.Sprintf(`{"_index":"%s","_id":"1","_version":2,"result":"updated","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":2,"_primary_term":1}`, index), + wantErr: false, + }, + { + name: "TestUpdateRequest_Do. Source parameter is bool", + r: opensearchapi.UpdateRequest{ + Index: index, + DocumentID: "1", + Body: strings.NewReader(`{ "doc": { "title": "Moneyball", "director": "Bennett", "year": "2012" } }`), + Source: true, + }, + want: &opensearchapi.Response{ + StatusCode: 200, + Header: http.Header{ + "Content-Type": []string{"application/json; charset=UTF-8"}, + }, + }, + wantBody: fmt.Sprintf(`{"_index":"%s","_id":"1","_version":2,"result":"noop","_shards":{"total":0,"successful":0,"failed":0},"_seq_no":2,"_primary_term":1,"get":{"_seq_no":2,"_primary_term":1,"found":true,"_source":{"title":"Moneyball","director":"Bennett","year":"2012"}}}`, index), + wantErr: false, + }, + { + name: "TestUpdateRequest_Do. Source parameter is a slice of strings", + r: opensearchapi.UpdateRequest{ + Index: index, + DocumentID: "1", + Body: strings.NewReader(`{ "doc": { "title": "Moneyball", "director": "Bennett", "year": "2012" } }`), + Source: []string{"true"}, + }, + want: &opensearchapi.Response{ + StatusCode: 200, + Header: http.Header{ + "Content-Type": []string{"application/json; charset=UTF-8"}, + }, + }, + wantBody: fmt.Sprintf(`{"_index":"%s","_id":"1","_version":2,"result":"noop","_shards":{"total":0,"successful":0,"failed":0},"_seq_no":2,"_primary_term":1,"get":{"_seq_no":2,"_primary_term":1,"found":true,"_source":{"title":"Moneyball","director":"Bennett","year":"2012"}}}`, index), + wantErr: false, + }, + { + name: "TestUpdateRequest_Do. Source Excludes", + r: opensearchapi.UpdateRequest{ + Index: index, + DocumentID: "1", + Body: strings.NewReader(`{ "doc": { "title": "Moneyball", "director": "Bennett", "year": "2012" } }`), + Source: []string{"true"}, + SourceExcludes: []string{"director"}, + }, + want: &opensearchapi.Response{ + StatusCode: 200, + Header: http.Header{ + "Content-Type": []string{"application/json; charset=UTF-8"}, + }, + }, + wantBody: fmt.Sprintf(`{"_index":"%s","_id":"1","_version":2,"result":"noop","_shards":{"total":0,"successful":0,"failed":0},"_seq_no":2,"_primary_term":1,"get":{"_seq_no":2,"_primary_term":1,"found":true,"_source":{"title":"Moneyball","year":"2012"}}}`, index), + wantErr: false, + }, + + // Bulk document + { + name: "TestBulkRequest_Do.", + r: opensearchapi.BulkRequest{ + Index: index, + Body: strings.NewReader(`{ "index": { "_index": "movies", "_id": "tt1979320" } } +{ "title": "Rush", "year": 2013 } +{ "create": { "_index": "movies", "_id": "tt1392214" } } +{ "title": "Prisoners", "year": 2013 } +{ "update": { "_index": "movies", "_id": "tt0816711" } } +{ "doc" : { "title": "World War Z" } } +`), + Source: []string{"true"}, + }, + want: &opensearchapi.Response{ + StatusCode: 200, + Header: http.Header{ + "Content-Type": []string{"application/json; charset=UTF-8"}, + }, + }, + wantErr: false, + }, + } + + client, err := opensearch.NewDefaultClient() + require.NoError(t, err) + + iCreate := opensearchapi.IndicesCreateRequest{ + Index: index, + Pretty: true, + Human: true, + ErrorTrace: true, + Body: strings.NewReader(fmt.Sprintf(`{"settings": {"index": {"number_of_shards": 4}}}`)), + } + + _, err = iCreate.Do(context.Background(), client) + require.NoError(t, err) + + for _, tt := range tests { + if tt.refresh { + refresh, err := client.Indices.Refresh() + require.NoError(t, err) + t.Logf("response: %+v", refresh) + } + + t.Run(tt.name, func(t *testing.T) { + got, err := tt.r.Do(context.Background(), client) + if (err != nil) != tt.wantErr { + t.Errorf("Do() error = %+v, wantErr %v", err, tt.wantErr) + return + } + + require.Equalf(t, got.StatusCode, tt.want.StatusCode, "Do() got = %v, want %v", got.StatusCode, tt.want.StatusCode) + + if tt.wantBody != "" { + require.Equalf(t, got.Header, tt.want.Header, "Do() got = %v, want %v", got.Header, tt.want.Header) + + defer got.Body.Close() + body, err := ioutil.ReadAll(got.Body) + require.NoError(t, err) + + buffer := new(bytes.Buffer) + err = json.Compact(buffer, body) + require.NoError(t, err) + + // ignore took field, since it is dynamic + took := regexp.MustCompile(`"took":\d+`) + actual := took.ReplaceAllString(buffer.String(), `"took":0`) + // ignore _type field, since it is legacy + actual = strings.ReplaceAll(actual, `"_type":"_doc",`, "") + + require.JSONEqf(t, tt.wantBody, actual, "Do() got = %v, want %v", got.String(), tt.wantBody) + } + }) + } +} diff --git a/opensearchapi/api.exists.go b/opensearchapi/api.exists.go index 7f2eb1b..40aec3c 100644 --- a/opensearchapi/api.exists.go +++ b/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/opensearchapi/api.exists_source.go b/opensearchapi/api.exists_source.go index 0ae58dc..54ce0c2 100644 --- a/opensearchapi/api.exists_source.go +++ b/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/opensearchapi/api.explain.go b/opensearchapi/api.explain.go index 0d7440b..2642628 100644 --- a/opensearchapi/api.explain.go +++ b/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/opensearchapi/api.get.go b/opensearchapi/api.get.go index 4f3ba38..bff13b7 100644 --- a/opensearchapi/api.get.go +++ b/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/opensearchapi/api.get_source.go b/opensearchapi/api.get_source.go index 42341db..459879d 100644 --- a/opensearchapi/api.get_source.go +++ b/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/opensearchapi/api.mget.go b/opensearchapi/api.mget.go index 6555a65..546050f 100644 --- a/opensearchapi/api.mget.go +++ b/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/opensearchapi/api.search.go b/opensearchapi/api.search.go index 9797e54..ca2c592 100644 --- a/opensearchapi/api.search.go +++ b/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/opensearchapi/api.update.go b/opensearchapi/api.update.go index 6144260..f17ea76 100644 --- a/opensearchapi/api.update.go +++ b/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/opensearchapi/api.update_by_query.go b/opensearchapi/api.update_by_query.go index 22d30be..2b61038 100644 --- a/opensearchapi/api.update_by_query.go +++ b/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 } From 399fe1a90209ccfa3859f1710f91e8f0a8ac499e Mon Sep 17 00:00:00 2001 From: Rakhat <51375666+zethuman@users.noreply.github.com> Date: Sat, 15 Apr 2023 01:01:01 +0600 Subject: [PATCH 31/84] [GUIDE] Add index_lifecycle guide (#287) * Added @Jakob3xD as a co-maintainer. (#270) Signed-off-by: dblock Signed-off-by: Rakhat Zhuman * Bump github.com/aws/aws-sdk-go from 1.44.230 to 1.44.235 (#271) * Bump github.com/aws/aws-sdk-go from 1.44.230 to 1.44.235 Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.44.230 to 1.44.235. - [Release notes](https://github.com/aws/aws-sdk-go/releases) - [Commits](https://github.com/aws/aws-sdk-go/compare/v1.44.230...v1.44.235) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Update changelog Signed-off-by: dependabot[bot] --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] Signed-off-by: Rakhat Zhuman * Add markdown linter (#261) * Add linter for markdown files Signed-off-by: Rakhat Zhuman * Updated CHANGELOG.md Signed-off-by: Rakhat Zhuman * Add make-script and update DEVELOPER_GUIDE.md Signed-off-by: Rakhat Zhuman * Updated linter options Signed-off-by: Rakhat Zhuman * Fixed mmarkdown files format Signed-off-by: Rakhat Zhuman --------- Signed-off-by: Rakhat Zhuman * Added Jakob3xD to CODEOWNERS, removed @svencowart. (#272) Signed-off-by: dblock Signed-off-by: Rakhat Zhuman * Add index_lifecycle guide Signed-off-by: Rakhat Zhuman * Updated CHANGELOG.md Signed-off-by: Rakhat Zhuman * opensearchapi: Fix handling of errors without error response body (#286) Signed-off-by: Jakob Hahn Signed-off-by: Rakhat Zhuman * Add bulk guide Signed-off-by: Rakhat Zhuman * Update CHANGELOG.md Signed-off-by: Rakhat Zhuman * Add document_lifecycle guide Signed-off-by: Rakhat Zhuman * Add indent to go code Signed-off-by: Rakhat Zhuman * Add indent to go code Signed-off-by: Rakhat Zhuman --------- Signed-off-by: dblock Signed-off-by: Rakhat Zhuman Signed-off-by: dependabot[bot] Signed-off-by: Jakob Hahn Co-authored-by: Daniel (dB.) Doubrovkine Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] Co-authored-by: Jakob --- CHANGELOG.md | 1 + guides/index_lifecycle.md | 218 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 219 insertions(+) create mode 100644 guides/index_lifecycle.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 4bcfe06..150e2e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Adds @Jakob3xD to co-maintainers ([#270](https://github.com/opensearch-project/opensearch-go/pull/270)) - Adds dynamic type to \_source field ([#158](https://github.com/opensearch-project/opensearch-go/issues/158)) - Adds testcases for Document API ([#280](https://github.com/opensearch-project/opensearch-go/issues/280)) +- Adds `index_lifecycle` guide ([#287](https://github.com/opensearch-project/opensearch-go/pull/287)) ### Changed diff --git a/guides/index_lifecycle.md b/guides/index_lifecycle.md new file mode 100644 index 0000000..b7f06c8 --- /dev/null +++ b/guides/index_lifecycle.md @@ -0,0 +1,218 @@ +# Index Lifecycle + +This guide covers OpenSearch Golang Client API actions for Index Lifecycle. You'll learn how to create, read, update, and delete indices in your OpenSearch cluster. We will also leverage index templates to create default settings and mappings for indices of certain patterns. + +## Setup + +In this guide, we will need an OpenSearch cluster with more than one node. Let's use the sample [docker-compose.yml](https://opensearch.org/samples/docker-compose.yml) to start a cluster with two nodes. The cluster's API will be available at `localhost:9200` with basic authentication enabled with default username and password of `admin:admin`. + +To start the cluster, run the following command: + +```bash + cd /path/to/docker-compose.yml + docker-compose up -d +``` + +Let's create a client instance to access this cluster: + +```go + package main + + import ( + "github.com/opensearch-project/opensearch-go/v2" + "log" + ) + + func main() { + client, err := opensearch.NewDefaultClient() + if err != nil { + log.Printf("error occurred: [%s]", err.Error()) + } + log.Printf("response: [%+v]", client) + } +``` + +## Index API Actions + +### Create a new index + +You can quickly create an index with default settings and mappings by using the `indices.create` API action. The following example creates an index named `paintings` with default settings and mappings: + +```go + paintingsIndex, err := client.Indices.Create("paintings") + if err != nil { + log.Printf("error occurred: [%s]", err.Error()) + } + log.Printf("response: [%+v]", paintingsIndex) +``` + +To specify settings and mappings, you can pass them as the `body` of the request. The following example creates an index named `movies` with custom settings and mappings: + +```go + movies := "movies" + + createMovieIndex, err := client.Indices.Create(movies, + client.Indices.Create.WithBody(strings.NewReader(`{ + "settings": { + "index": { + "number_of_shards": 2, + "number_of_replicas": 1 + } + }, + "mappings": { + "properties": { + "title": { + "type": "text" + }, + "year": { + "type": "integer" + } + } + } + }`), + ), + ) + if err != nil { + log.Printf("error occurred: [%s]", err.Error()) + } + log.Printf("response: [%+v]", createMovieIndex) +``` + +When you create a new document for an index, OpenSearch will automatically create the index if it doesn't exist: + +```go + // return status code 404 Not Found + res, err := client.Indices.Exists([]string{"burner"}) + if err != nil { + log.Printf("error occurred: [%s]", err.Error()) + } + log.Printf("response: [%+v]", res) + + res, err = client.Indices.Create( + "burner", + client.Indices.Create.WithBody(strings.NewReader(`{ "settings": {} }`)), + ) + if err != nil { + log.Printf("error occurred: [%s]", err.Error()) + } + log.Printf("response: [%+v]", res) + + // return status code 200 OK + res, err = client.Indices.Exists([]string{"burner"}) + if err != nil { + log.Printf("error occurred: [%s]", err.Error()) + } + log.Printf("response: [%+v]", res) +``` + +### Update an Index + +You can update an index's settings and mappings by using the `indices.put_settings` and `indices.put_mapping` API actions. + +The following example updates the `movies` index's number of replicas to `0`: + +```go + res, err := client.Indices.PutSettings( + strings.NewReader(`{ "index": { "number_of_replicas": 0} }`), + client.Indices.PutSettings.WithIndex(movies), + ) + if err != nil { + log.Printf("error occurred: [%s]", err.Error()) + } + log.Printf("response: [%+v]", res) +``` + +The following example updates the `movies` index's mappings to add a new field named `director`: + +```go + res, err := client.Indices.PutMapping( + strings.NewReader(`{ "properties": { "director": { "type": "text" } } }`), + client.Indices.PutMapping.WithIndex(movies), + ) + if err != nil { + log.Printf("error occurred: [%s]", err.Error()) + } + log.Printf("response: [%+v]", res) +``` + +### Get Metadata for an Index + +Let's check if the index's settings and mappings have been updated by using the `indices.get` API action: + +```go + res, err := client.Indices.Get([]string{movies}) + if err != nil { + log.Printf("error occurred: [%s]", err.Error()) + } + log.Printf("response: [%+v]", res) +``` + +The response body contains the index's settings and mappings: + +```json +{ + "movies": { + "aliases": {}, + "mappings": { + "properties": { + "director": { + "type": "text" + }, + "title": { + "type": "text" + }, + "year": { + "type": "integer" + } + } + }, + "settings": { + "index": { + "creation_date": "1681033762803", + "number_of_shards": "2", + "number_of_replicas": "1", + "uuid": "n9suHX2wTPG3Mq2y-3Lvdw", + "version": { + "created": "136277827" + }, + "provided_name": "movies" + } + } + } +} +``` + +### Delete an Index + +Let's delete the `movies` index by using the `indices.delete` API action: + +```go + deleteIndexes, err := client.Indices.Delete([]string{movies}) + if err != nil { + log.Printf("error occurred: [%s]", err.Error()) + } + log.Printf("response: [%+v]", deleteIndexes) +``` + +We can also delete multiple indices at once: + +```go + deleteIndexes, err := client.Indices.Delete( + []string{movies, "burner", "paintings"}, + client.Indices.Delete.WithIgnoreUnavailable(true), + ) + if err != nil { + log.Printf("error occurred: [%s]", err.Error()) + } + log.Printf("response: [%+v]", deleteIndexes) +``` + +Notice that we are passing `ignore unavailable` to the request. This tells the client to ignore the `404` error if the index doesn't exist for deletion. Without it, the above `delete` request will throw an error because the `movies` index has already been deleted in the previous example. + +## Cleanup + +All resources created in this guide are automatically deleted when the cluster is stopped. You can stop the cluster by running the following command: + +```bash + docker-compose down -v +``` From b1508bacf57c01b10357ab9464657b6da92c5a94 Mon Sep 17 00:00:00 2001 From: Rakhat <51375666+zethuman@users.noreply.github.com> Date: Sat, 15 Apr 2023 01:04:15 +0600 Subject: [PATCH 32/84] [GUIDE] Add bulk guide (#292) * Add bulk guide Signed-off-by: Rakhat Zhuman * Updated CHANGELOG.md Signed-off-by: Rakhat Zhuman * opensearchapi: Fix handling of errors without error response body (#286) Signed-off-by: Jakob Hahn Signed-off-by: Rakhat Zhuman --------- Signed-off-by: Rakhat Zhuman Signed-off-by: Jakob Hahn Co-authored-by: Jakob Co-authored-by: Daniel (dB.) Doubrovkine --- CHANGELOG.md | 1 + guides/bulk.md | 204 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 205 insertions(+) create mode 100644 guides/bulk.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 150e2e3..ea2d0cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Adds dynamic type to \_source field ([#158](https://github.com/opensearch-project/opensearch-go/issues/158)) - Adds testcases for Document API ([#280](https://github.com/opensearch-project/opensearch-go/issues/280)) - 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)) ### Changed diff --git a/guides/bulk.md b/guides/bulk.md new file mode 100644 index 0000000..dca089c --- /dev/null +++ b/guides/bulk.md @@ -0,0 +1,204 @@ +# Bulk + +In this guide, you'll learn how to use the OpenSearch Golang Client API to perform bulk operations. You'll learn how to index, update, and delete multiple documents in a single request. + +## Setup + +First, create a client instance with the following code: + +```go +package main + +import ( + "github.com/opensearch-project/opensearch-go/v2" + "log" +) + +func main() { + client, err := opensearch.NewDefaultClient() + if err != nil { + log.Printf("error occurred: [%s]", err.Error()) + } + log.Printf("response: [%+v]", client) +} +``` + +Next, create an index named `movies` and another named `books` with the default settings: + +```go +movies := "movies" +books := "books" + +createMovieIndex, err := client.Indices.Create(movies) +if err != nil { + log.Printf("error occurred: [%s]", err.Error()) +} +log.Printf("response: [%+v]", createMovieIndex) + +createBooksIndex, err := client.Indices.Create(books) +if err != nil { + log.Printf("error occurred: [%s]", err.Error()) +} +log.Printf("response: [%+v]", createBooksIndex) +``` + +## Bulk API + +The `bulk` API action allows you to perform document operations in a single request. The body of the request is an array of objects that contains the bulk operations and the target documents to index, create, update, or delete. + +### Indexing multiple documents + +The following code creates two documents in the `movies` index and one document in the `books` index: + +```go + res, err := client.Bulk(strings.NewReader(`{ "index": { "_index": "movies", "_id": 1 } } +{ "title": "Beauty and the Beast", "year": 1991 } +{ "index": { "_index": "movies", "_id": 2 } } +{ "title": "Beauty and the Beast - Live Action", "year": 2017 } +{ "index": { "_index": "books", "_id": 1 } } +{ "title": "The Lion King", "year": 1994 } +`)) + if err != nil { + log.Printf("error occurred: [%s]", err.Error()) + } + log.Printf("response: [%+v]", res) +``` + +### Creating multiple documents + +Similarly, instead of calling the `create` method for each document, you can use the `bulk` API to create multiple documents in a single request. The following code creates three documents in the `movies` index and one in the `books` index: + +```go + res, err = client.Bulk(strings.NewReader(`{ "create": { "_index": "movies" } } +{ "title": "Beauty and the Beast 2", "year": 2030 } +{ "create": { "_index": "movies", "_id": 1 } } +{ "title": "Beauty and the Beast 3", "year": 2031 } +{ "create": { "_index": "movies", "_id": 2 } } +{ "title": "Beauty and the Beast 4", "year": 2049 } +{ "create": { "_index": "books" } } +{ "title": "The Lion King 2", "year": 1998 } +`)) + if err != nil { + log.Printf("error occurred: [%s]", err.Error()) + } + log.Printf("response: [%+v]", res) +``` + +We omit the `_id` for each document and let OpenSearch generate them for us in this example, just like we can with the `create` method. + +### Updating multiple documents + +```go + res, err = client.Bulk(strings.NewReader(`{ "update": { "_index": "movies", "_id": 1 } } +{ "doc": { "year": 1992 } } +{ "update": { "_index": "movies", "_id": 1 } } +{ "doc": { "year": 2018 } } +`)) + if err != nil { + log.Printf("error occurred: [%s]", err.Error()) + } + log.Printf("response: [%+v]", res) +``` + +Note that the updated data is specified in the `doc` with a full or partial JSON document, depending on how much of the document you want to update. + +### Deleting multiple documents + +If the document doesn’t exist, OpenSearch doesn’t return an error, but instead returns not_found under result. Delete actions don’t require documents on the next line + +```go + res, err = client.Bulk(strings.NewReader(`{ "delete": { "_index": "movies", "_id": 1 } } + { "delete": { "_index": "movies", "_id": 2 } } + `)) + if err != nil { + log.Printf("error occurred: [%s]", err.Error()) + } + log.Printf("response: [%+v]", res) +``` + +### Mix and match operations + +You can mix and match the different operations in a single request. The following code creates two documents, updates one document, and deletes another document: + +```go + res, err = client.Bulk(strings.NewReader(`{ "create": { "_index": "movies", "_id": 3 } } +{ "title": "Beauty and the Beast 5", "year": 2050 } +{ "create": { "_index": "movies", "_id": 4 } } +{ "title": "Beauty and the Beast 6", "year": 2051 } +{ "update": { "_index": "movies", "_id": 3 } } +{ "doc": { "year": 2052 } } +{ "delete": { "_index": "movies", "_id": 4 } } +`)) + if err != nil { + log.Printf("error occurred: [%s]", err.Error()) + } + log.Printf("response: [%+v]", res) +``` + +### Handling errors + +The `bulk` API returns an array of responses for each operation in the request body. Each response contains a `status` field that indicates whether the operation was successful or not. If the operation was successful, the `status` field is set to a `2xx` code. Otherwise, the response contains an error message in the `error` field. + +The following code shows how to look for errors in the response: + +```go +type Response struct { + Took int `json:"took"` + Errors bool `json:"errors"` + Items []struct { + Delete struct { + Index string `json:"_index"` + Id string `json:"_id"` + Version int `json:"_version"` + Result string `json:"result"` + Shards struct { + Total int `json:"total"` + Successful int `json:"successful"` + Failed int `json:"failed"` + } `json:"_shards"` + SeqNo int `json:"_seq_no"` + PrimaryTerm int `json:"_primary_term"` + Status int `json:"status"` + } `json:"delete,omitempty"` + } `json:"items"` +} + + res, err = client.Bulk(strings.NewReader(`{ "delete": { "_index": "movies", "_id": 10 } } +`)) + if err != nil { + log.Printf("error occurred: [%s]", err.Error()) + } + + body, err := io.ReadAll(res.Body) + if err != nil { + log.Printf("error occurred: [%s]", err.Error()) + } + + var response Response + if err := json.Unmarshal(body, &response); err != nil { + log.Printf("error occurred: [%s]", err.Error()) + } + + for _, item := range response.Items { + if item.Delete.Status > 299 { + log.Printf("error occurred: [%s]", item.Delete.Result) + } else { + log.Printf("success: [%s]", item.Delete.Result) + } + } +``` + +## Cleanup + +To clean up the resources created in this guide, delete the `movies` and `books` indices: + +```go +deleteIndexes, err := client.Indices.Delete( + []string{movies, books}, + client.Indices.Delete.WithIgnoreUnavailable(true), +) +if err != nil { + log.Printf("error occurred: [%s]", err.Error()) +} +log.Printf("response: [%+v]", deleteIndexes) +``` From 2bc806a0ef82737a942b506fc95e66363d5c0301 Mon Sep 17 00:00:00 2001 From: Rakhat <51375666+zethuman@users.noreply.github.com> Date: Sat, 15 Apr 2023 01:05:41 +0600 Subject: [PATCH 33/84] [GUIDE] Add search guide (#291) * Add search guide Signed-off-by: Rakhat Zhuman * Updated CHANGELOG.md Signed-off-by: Rakhat Zhuman * opensearchapi: Fix handling of errors without error response body (#286) Signed-off-by: Jakob Hahn Signed-off-by: Rakhat Zhuman --------- Signed-off-by: Rakhat Zhuman Signed-off-by: Jakob Hahn Co-authored-by: Jakob Co-authored-by: Daniel (dB.) Doubrovkine --- CHANGELOG.md | 1 + guides/search.md | 197 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 198 insertions(+) create mode 100644 guides/search.md diff --git a/CHANGELOG.md b/CHANGELOG.md index ea2d0cd..21b2d5d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Adds testcases for Document API ([#280](https://github.com/opensearch-project/opensearch-go/issues/280)) - 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)) ### Changed diff --git a/guides/search.md b/guides/search.md new file mode 100644 index 0000000..ae938bc --- /dev/null +++ b/guides/search.md @@ -0,0 +1,197 @@ +# Search + +OpenSearch provides a powerful search API that allows you to search for documents in an index. The search API supports a number of parameters that allow you to customize the search operation. In this guide, we will explore the search API and its parameters. + +# Setup + +Let's start by creating an index and adding some documents to it: + +```go +package main + +import ( + "context" + "fmt" + "github.com/opensearch-project/opensearch-go/v2" + "github.com/opensearch-project/opensearch-go/v2/opensearchapi" + "log" + "strings" +) + +func main() { + client, err := opensearch.NewDefaultClient() + if err != nil { + log.Printf("error occurred: [%s]", err.Error()) + } + log.Printf("response: [%+v]", client) + + movies := "movies" + + // create the index + createMovieIndex, err := client.Indices.Create(movies) + if err != nil { + log.Printf("error occurred: [%s]", err.Error()) + } + log.Printf("response: [%+v]", createMovieIndex) + + for i := 1; i < 11; i++ { + req := opensearchapi.IndexRequest{ + Index: movies, + DocumentID: fmt.Sprintf("%d", i), + Body: strings.NewReader(fmt.Sprintf(`{"title": "The Dark Knight %d", "director": "Christopher Nolan", "year": %d}`, i, 2008+i)), + } + _, err := req.Do(context.Background(), client) + if err != nil { + log.Printf("error occurred: [%s]", err.Error()) + } + } + + req := opensearchapi.IndexRequest{ + Index: movies, + Body: strings.NewReader(`{"title": "The Godfather", "director": "Francis Ford Coppola", "year": 1972}`), + } + _, err = req.Do(context.Background(), client) + if err != nil { + log.Printf("error occurred: [%s]", err.Error()) + } + + req = opensearchapi.IndexRequest{ + Index: movies, + Body: strings.NewReader(`{"title": "The Shawshank Redemption", "director": "Frank Darabont", "year": 1994}`), + } + _, err = req.Do(context.Background(), client) + if err != nil { + log.Printf("error occurred: [%s]", err.Error()) + } + + // refresh the index to make the documents searchable + _, err = client.Indices.Refresh(client.Indices.Refresh.WithIndex(movies)) + if err != nil { + log.Printf("error occurred: [%s]", err.Error()) + } +} +``` + +## Search API + +### Basic Search + +The search API allows you to search for documents in an index. The following example searches for ALL documents in the `movies` index: + +```go +res, err := client.Search( + client.Search.WithIndex(movies), +) +if err != nil { + log.Printf("error occurred: [%s]", err.Error()) +} +log.Printf("response: [%+v]", res) +``` + +You can also search for documents that match a specific query. The following example searches for documents that match the query `dark knight`: + +```go +part, err := client.Search( + client.Search.WithIndex(movies), + client.Search.WithQuery(`title: "dark knight"`), +) +if err != nil { + log.Printf("error occurred: [%s]", err.Error()) +} +log.Printf("response: [%+v]", part) +``` + +OpenSearch query DSL allows you to specify complex queries. Check out the [OpenSearch query DSL documentation](https://opensearch.org/docs/latest/query-dsl/) for more information. + +### Basic Pagination + +The search API allows you to paginate through the search results. The following example searches for documents that match the query `dark knight`, sorted by `year` in ascending order, and returns the first 2 results after skipping the first 5 results: + +```go +sort, err := client.Search( + client.Search.WithIndex(movies), + client.Search.WithSize(2), + client.Search.WithFrom(5), + client.Search.WithSort("year:desc"), + client.Search.WithQuery(`title: "dark knight"`), +) +if err != nil { + log.Printf("error occurred: [%s]", err.Error()) +} +log.Printf("response: [%+v]", sort) +``` + +### Pagination with scroll + +When retrieving large amounts of non-real-time data, you can use the `scroll` parameter to paginate through the search results. + +```go +page1, err := client.Search( + client.Search.WithIndex(movies), + client.Search.WithSize(2), + client.Search.WithQuery(`title: "dark knight"`), + client.Search.WithSort("year:asc"), + client.Search.WithScroll(time.Minute), +) +if err != nil { + log.Printf("error occurred: [%s]", err.Error()) +} +log.Printf("response: [%+v]", page1) +``` + +### Pagination with Point in Time + +The scroll example above has one weakness: if the index is updated while you are scrolling through the results, they will be paginated inconsistently. To avoid this, you should use the "Point in Time" feature. The following example demonstrates how to use the `point_in_time` and `pit_id` parameters to paginate through the search results: + +```go +// create a point in time +_, pit, err := client.PointInTime.Create( + client.PointInTime.Create.WithIndex(movies), + client.PointInTime.Create.WithKeepAlive(time.Minute), +) +if err != nil { + log.Printf("error occurred: [%s]", err.Error()) +} +log.Printf("created pit: [%+v]", pit) + +// run a search query with a pit.id +page1, err := client.Search( + client.Search.WithSize(5), + client.Search.WithBody(strings.NewReader(fmt.Sprintf(`{ "pit": { "id": "%s", "keep_alive": "1m" } }`, pit.PitID))), + client.Search.WithSort("year:asc"), +) +if err != nil { + log.Printf("error occurred: [%s]", err.Error()) +} +log.Printf("response: [%+v]", page1) + +// to get the next set of documents, run the same query with the last document’s sort values as the search_after parameter, keeping the same sort and pit.id. +page2, err := client.Search( + client.Search.WithSize(5), + client.Search.WithBody(strings.NewReader(fmt.Sprintf(`{ "pit": { "id": "%s", "keep_alive": "1m" }, "search_after": [ "1994" ] }`, pit.PitID))), + client.Search.WithSort("year:asc"), +) +if err != nil { + log.Printf("error occurred: [%s]", err.Error()) +} +log.Printf("response: [%+v]", page2) + +// to delete the point in time, run the following query +_, delpits, err := client.PointInTime.Delete(client.PointInTime.Delete.WithPitID(pit.PitID)) +if err != nil { + log.Printf("error occurred: [%s]", err.Error()) +} +log.Printf("deleted pits: [%+v]", delpits) +``` + +Note that a point-in-time is associated with an index or a set of index. So, when performing a search with a point-in-time, you DO NOT specify the index in the search. + +## Cleanup + +```go +deleteIndex, err := client.Indices.Delete([]string{"movies"}) +if err != nil { + log.Printf("Error creating index: %s", err.Error()) +} +log.Printf("response: [%+v]", deleteIndex) +``` From a6b20de3cbcb3eeeb9424d3b01d63ac5ff273f29 Mon Sep 17 00:00:00 2001 From: Rakhat <51375666+zethuman@users.noreply.github.com> Date: Sat, 15 Apr 2023 01:09:49 +0600 Subject: [PATCH 34/84] [GUIDE] Add document_lifecycle guide (#290) --- CHANGELOG.md | 1 + guides/document_lifecycle.md | 282 +++++++++++++++++++++++++++++++++++ 2 files changed, 283 insertions(+) create mode 100644 guides/document_lifecycle.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 21b2d5d..eb7c0bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - 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)) ### Changed diff --git a/guides/document_lifecycle.md b/guides/document_lifecycle.md new file mode 100644 index 0000000..6cfa40a --- /dev/null +++ b/guides/document_lifecycle.md @@ -0,0 +1,282 @@ +# Document Lifecycle + +This guide covers OpenSearch Golang Client API actions for Document Lifecycle. You'll learn how to create, read, update, and delete documents in your OpenSearch cluster. Whether you're new to OpenSearch or an experienced user, this guide provides the information you need to manage your document lifecycle effectively. + +## Setup + +Assuming you have OpenSearch running locally on port 9200, you can create a client instance with the following code: + +```go + package main + + import ( + "github.com/opensearch-project/opensearch-go/v2" + "log" + ) + + func main() { + client, err := opensearch.NewDefaultClient() + if err != nil { + log.Printf("error occurred: [%s]", err.Error()) + } + log.Printf("response: [%+v]", client) + } +``` + +Next, create an index named `movies` with the default settings: + +```go + movies := "movies" + + // delete the indexes if they exist + deleteIndexes, err := client.Indices.Delete( + []string{movies}, + client.Indices.Delete.WithIgnoreUnavailable(true), + ) + if err != nil { + log.Printf("error occurred: [%s]", err.Error()) + } + log.Printf("response: [%+v]", deleteIndexes) + + createMovieIndex, err := client.Indices.Create(movies) + if err != nil { + log.Printf("error occurred: [%s]", err.Error()) + } + log.Printf("response: [%+v]", createMovieIndex) +``` + +## Document API Actions + +### Create a new document with specified ID + +To create a new document, use the `create` or `index` API action. The following code creates two new documents with IDs of `1` and `2`: + +```go + res, err := client.Create(movies, "1", strings.NewReader(`{"title": "Beauty and the Beast", "year": 1991 }`)) + if err != nil { + log.Printf("error occurred: [%s]", err.Error()) + } + log.Printf("response: [%+v]", res) + + res, err = client.Create(movies, "2", strings.NewReader(`{"title": "Beauty and the Beast - Live Action", "year": 2017 }`)) + if err != nil { + log.Printf("error occurred: [%s]", err.Error()) + } + log.Printf("response: [%+v]", res) +``` + +Note that the `create` action is NOT idempotent. If you try to create a document with an ID that already exists, the request will fail: + +```go + res, err = client.Create(movies, "2", strings.NewReader(`{"title": "Just Another Movie" }`)) + if err != nil { + log.Printf("error occurred: [%s]", err.Error()) + } +``` + +The `index` action, on the other hand, is idempotent. If you try to index a document with an existing ID, the request will succeed and overwrite the existing document. Note that no new document will be created in this case. You can think of the `index` action as an upsert: + +```go + res, err = client.Index(movies, strings.NewReader(`{"title": "Updated Title" }`), client.Index.WithDocumentID("2")) + if err != nil { + log.Printf("error occurred: [%s]", err.Error()) + } + log.Printf("response: [%+v]", res) + + res, err = client.Index(movies, strings.NewReader(`{ "title": "The Lion King", "year": 1994}`), client.Index.WithDocumentID("2")) + if err != nil { + log.Printf("error occurred: [%s]", err.Error()) + } + log.Printf("response: [%+v]", res) +``` + +### Create a new document with auto-generated ID + +You can also create a new document with an auto-generated ID by omitting the `id` parameter. The following code creates documents with an auto-generated IDs in the `movies` index: + +```go + res, err = client.Index(movies, strings.NewReader(`{ "title": "The Lion King 2", "year": 1978}`)) + if err != nil { + log.Printf("error occurred: [%s]", err.Error()) + } + log.Printf("response: [%+v]", res) +``` + +In this case, the ID of the created document in the `result` field of the response body: + +```json +{ + "_index": "movies", + "_id": "jfp7ZYcBPWlPSrIHCMga", + "_version": 1, + "result": "created", + "_shards": { + "total": 2, + "successful": 1, + "failed": 0 + }, + "_seq_no": 4, + "_primary_term": 1 +} +``` + +### Get a document + +To get a document, use the `get` API action. The following code gets the document with ID `1` from the `movies` index: + +```go + res, err = client.Get(movies, "1") + if err != nil { + log.Printf("error occurred: [%s]", err.Error()) + } + log.Printf("response: [%+v]", res) + // OUTPUT: {"_index":"movies","_id":"1","_version":1,"_seq_no":0,"_primary_term":1,"found":true,"_source":{"title": "Beauty and the Beast", "year": 1991 }} +``` + +You can also use `_source_include` and `_source_exclude` parameters to specify which fields to include or exclude in the response: + +```go + res, err = client.Get(movies, "1", client.Get.WithSourceIncludes("title")) + if err != nil { + log.Printf("error occurred: [%s]", err.Error()) + } + log.Printf("response: [%+v]", res) + // OUTPUT: {"_index":"movies","_id":"1","_version":1,"_seq_no":0,"_primary_term":1,"found":true,"_source":{"title":"Beauty and the Beast"}} + + res, err = client.Get(movies, "1", client.Get.WithSourceExcludes("title")) + if err != nil { + log.Printf("error occurred: [%s]", err.Error()) + } + log.Printf("response: [%+v]", res) + // OUTPUT: {"_index":"movies","_id":"1","_version":1,"_seq_no":0,"_primary_term":1,"found":true,"_source":{"year":1991}} +``` + +### Get multiple documents + +To get multiple documents, use the `mget` API action: + +```go + res, err = client.Mget(strings.NewReader(`{ "docs": [{ "_id": "1" }, { "_id": "2" }] }`), client.Mget.WithIndex(movies)) + if err != nil { + log.Printf("error occurred: [%s]", err.Error()) + } + log.Printf("response: [%+v]", res) + // OUTPUT: {"docs":[{"_index":"movies","_id":"1","_version":1,"_seq_no":0,"_primary_term":1,"found":true,"_source":{"title": "Beauty and the Beast", "year": 1991 }},{"_index":"movies","_id":"2","_version":3,"_seq_no":3,"_primary_term":1,"found":true,"_source":{ "title": "The Lion King", "year": 1994}}]} +``` + +### Check if a document exists + +To check if a document exists, use the `exists` API action. The following code checks if the document with ID `1` exists in the `movies` index: + +```go + res, err = client.Exists(movies, "1") + if err != nil { + log.Printf("error occurred: [%s]", err.Error()) + } + log.Printf("response: [%+v]", res) +``` + +### Update a document + +To update a document, use the `update` API action. The following code updates the `year` field of the document with ID `1` in the `movies` index: + +```go + res, err = client.Update(movies, "1", strings.NewReader(`{ "doc": { "year": 1995 } }`)) + if err != nil { + log.Printf("error occurred: [%s]", err.Error()) + } + log.Printf("response: [%+v]", res) +``` + +Alternatively, you can use the `script` parameter to update a document using a script. The following code increments the `year` field of the of document with ID `1` by 5 using painless script, the default scripting language in OpenSearch: + +```go + res, err = client.Update(movies, "1", strings.NewReader(`{ "script": { "source": "ctx._source.year += 5" } }`)) + if err != nil { + log.Printf("error occurred: [%s]", err.Error()) + } + log.Printf("response: [%+v]", res) +``` + +Note that while both `update` and `index` actions perform updates, they are not the same. The `update` action is a partial update, while the `index` action is a full update. The `update` action only updates the fields that are specified in the request body, while the `index` action overwrites the entire document with the new document. + +### Update multiple documents by query + +To update documents that match a query, use the `update_by_query` API action. The following code decreases the `year` field of all documents with `year` greater than 2023: + +```go + res, err = client.Indices.Refresh( + client.Indices.Refresh.WithIndex(movies), + ) + if err != nil { + log.Printf("error occurred: [%s]", err.Error()) + } + log.Printf("response: [%+v]", res) + + res, err = client.UpdateByQuery( + []string{movies}, + client.UpdateByQuery.WithQuery("year:<1990"), + client.UpdateByQuery.WithBody( + strings.NewReader(`{"script": { "source": "ctx._source.year -= 1" } }`), + ), + ) + if err != nil { + log.Printf("error occurred: [%s]", err.Error()) + } + log.Printf("response: [%+v]", res) +``` + +Note that the `update_by_query` API action is needed to refresh the index before the query is executed. + +### Delete a document + +To delete a document, use the `delete` API action. The following code deletes the document with ID `1`: + +```go + res, err = client.Delete(movies, "1") + if err != nil { + log.Printf("error occurred: [%s]", err.Error()) + } + log.Printf("response: [%+v]", res) +``` + +### Delete multiple documents by query + +To delete documents that match a query, use the `delete_by_query` API action. The following code deletes all documents with `year` greater than 2023: + +```go + res, err = client.Indices.Refresh( + client.Indices.Refresh.WithIndex(movies), + ) + if err != nil { + log.Printf("error occurred: [%s]", err.Error()) + } + log.Printf("response: [%+v]", res) + + res, err = client.DeleteByQuery( + []string{movies}, + strings.NewReader(`{ "query": { "match": { "title": "The Lion King" } } }`), + client.DeleteByQuery.WithQuery(`title: "The Lion King"`), + ) + if err != nil { + log.Printf("error occurred: [%s]", err.Error()) + } + log.Printf("response: [%+v]", res) +``` + +Note that the `delete_by_query` API action is needed to refresh the index before the query is executed. + +## Cleanup + +To clean up the resources created in this guide, delete the `movies` index: + +```go + deleteIndexes, err := client.Indices.Delete( + []string{movies}, + client.Indices.Delete.WithIgnoreUnavailable(true), + ) + if err != nil { + log.Printf("error occurred: [%s]", err.Error()) + } + log.Printf("response: [%+v]", deleteIndexes) +``` From ed6bbc6fb6434ca8ce088bcf30fca631544e25a2 Mon Sep 17 00:00:00 2001 From: Rakhat <51375666+zethuman@users.noreply.github.com> Date: Sat, 15 Apr 2023 01:11:18 +0600 Subject: [PATCH 35/84] [GUIDE] Add index_template guide (#289) --- CHANGELOG.md | 1 + guides/index_template.md | 262 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 263 insertions(+) create mode 100644 guides/index_template.md diff --git a/CHANGELOG.md b/CHANGELOG.md index eb7c0bd..f83f9f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - 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)) ### Changed diff --git a/guides/index_template.md b/guides/index_template.md new file mode 100644 index 0000000..f9e28a4 --- /dev/null +++ b/guides/index_template.md @@ -0,0 +1,262 @@ +# Index Template + +Index templates are a convenient way to define settings, mappings, and aliases for one or more indices when they are created. In this guide, you'll learn how to create an index template and apply it to an index. + +## Setup + +Assuming you have OpenSearch running locally on port 9200, you can create a client instance with the following code: + +```go +package main + +import ( + "github.com/opensearch-project/opensearch-go/v2" + "log" +) + +func main() { + client, err := opensearch.NewDefaultClient() + if err != nil { + log.Printf("error occurred: [%s]", err.Error()) + } + log.Printf("response: [%+v]", client) +} +``` + +## Index Template API Actions + +### Create an Index Template + +You can create an index template to define default settings and mappings for indices of certain patterns. The following example creates an index template named `books` with default settings and mappings for indices of the `books-*` pattern: + +```go +body := strings.NewReader(`{ + "index_patterns": ["books-*"], + "template": { + "settings": { + "index": { + "number_of_shards": 3, + "number_of_replicas": 0 + } + }, + "mappings": { + "properties": { + "title": { "type": "text" }, + "author": { "type": "text" }, + "published_on": { "type": "date" }, + "pages": { "type": "integer" } + } + } + } +}`) + +res, err := client.Indices.PutIndexTemplate("books", body) +if err != nil { + log.Printf("error occurred: [%s]", err.Error()) +} +log.Printf("response: [%+v]", res) +``` + +Now, when you create an index that matches the `books-*` pattern, OpenSearch will automatically apply the template's settings and mappings to the index. Let's create an index named `books-nonfiction` and verify that its settings and mappings match those of the template: + +```go +res, err = client.Indices.Create("books-nonfiction") +if err != nil { + log.Printf("error occurred: [%s]", err.Error()) +} +log.Printf("response: [%+v]", res) + +// check mappings properties +res, err = client.Indices.Get([]string{"books-nonfiction"}) +if err != nil { + log.Printf("error occurred: [%s]", err.Error()) +} +log.Printf("response: [%+v]", res) +``` + +### Multiple Index Templates + +If multiple index templates match the index's name, OpenSearch will apply the template with the highest priority. The following example creates two index templates named `books-*` and `books-fiction-*` with different settings: + +```go +res, err := client.Indices.PutIndexTemplate("books", strings.NewReader(`{ + "index_patterns": ["books-*"], + "priority": 0, + "template": { + "settings": { + "index": { + "number_of_shards": 3, + "number_of_replicas": 0 + } + } + } +}`)) +if err != nil { + log.Printf("error occurred: [%s]", err.Error()) +} +log.Printf("response: [%+v]", res) + +// higher priority than the `books` template +res, err = client.Indices.PutIndexTemplate("books-fiction", strings.NewReader(`{ + "index_patterns": ["books-fiction-*"], + "priority": 1, + "template": { + "settings": { + "index": { + "number_of_shards": 1, + "number_of_replicas": 1 + } + } + } +}`)) +if err != nil { + log.Printf("error occurred: [%s]", err.Error()) +} +log.Printf("response: [%+v]", res) +``` + +When we create an index named `books-fiction-romance`, OpenSearch will apply the `books-fiction-*` template's settings to the index: + +```go +res, err = client.Indices.Create("books-fiction-romance") +if err != nil { + log.Printf("error occurred: [%s]", err.Error()) +} +log.Printf("response: [%+v]", res) + +res, err = client.Indices.Get([]string{"books-fiction-romance"}) +if err != nil { + log.Printf("error occurred: [%s]", err.Error()) +} +log.Printf("response: [%+v]", res) +``` + +### Composable Index Templates + +Composable index templates are a new type of index template that allow you to define multiple component templates and compose them into a final template. The following example creates a component template named `books_mappings` with default mappings for indices of the `books-*` and `books-fiction-*` patterns: + +```go +// delete index templates if they exist +res, err := client.Indices.DeleteIndexTemplate("books-*") +if err != nil { + log.Printf("error occurred: [%s]", err.Error()) +} +log.Printf("response: [%+v]", res) + +// delete indices if they exist +res, err = client.Indices.Delete([]string{"books-*", "books-fiction-*"}) +if err != nil { + log.Printf("error occurred: [%s]", err.Error()) +} +log.Printf("response: [%+v]", res) + +// Composable Index Templates +res, err = client.Cluster.PutComponentTemplate("books_mappings", strings.NewReader(`{ + "template": { + "mappings": { + "properties": { + "title": { "type": "text" }, + "author": { "type": "text" }, + "published_on": { "type": "date" }, + "pages": { "type": "integer" } + } + } + } +}`)) +if err != nil { + log.Printf("error occurred: [%s]", err.Error()) +} +log.Printf("response: [%+v]", res) + +// use the `books_mappings` component template with priority 0 +res, err = client.Indices.PutIndexTemplate("books", strings.NewReader(`{ + "index_patterns": ["books-*"], + "composed_of": ["books_mappings"], + "priority": 0, + "template": { + "settings": { + "index": { + "number_of_shards": 3, + "number_of_replicas": 0 + } + } + } +}`)) +if err != nil { + log.Printf("error occurred: [%s]", err.Error()) +} +log.Printf("response: [%+v]", res) + +// use the `books_mappings` component template with priority 1 +res, err = client.Indices.PutIndexTemplate("books", strings.NewReader(`{ + "index_patterns": ["books-fiction-*"], + "composed_of": ["books_mappings"], + "priority": 1, + "template": { + "settings": { + "index": { + "number_of_shards": 3, + "number_of_replicas": 0 + } + } + } +}`)) +if err != nil { + log.Printf("error occurred: [%s]", err.Error()) +} +log.Printf("response: [%+v]", res) +``` + +When we create an index named `books-fiction-horror`, OpenSearch will apply the `books-fiction-*` template's settings, and `books_mappings` template mappings to the index: + +```go +res, err = client.Indices.Create("books-fiction-horror") +if err != nil { + log.Printf("error occurred: [%s]", err.Error()) +} +log.Printf("response: [%+v]", res) + +res, err = client.Indices.Get([]string{"books-fiction-horror"}) +if err != nil { + log.Printf("error occurred: [%s]", err.Error()) +} +log.Printf("response: [%+v]", res) +``` + +### Get an Index Template + +You can get an index template with the `get_index_template` API action: + +```go +res, err = client.Indices.GetIndexTemplate( + client.Indices.GetIndexTemplate.WithName("books"), +) +if err != nil { + log.Printf("error occurred: [%s]", err.Error()) +} +log.Printf("response: [%+v]", res) +``` + +### Delete an Index Template + +You can delete an index template with the `delete_template` API action: + +```go +res, err = client.Indices.DeleteIndexTemplate("books") +if err != nil { + log.Printf("error occurred: [%s]", err.Error()) +} +log.Printf("response: [%+v]", res) +``` + +## Cleanup + +Let's delete all resources created in this guide: + +```go +res, err = client.Indices.DeleteIndexTemplate("books-fiction") +if err != nil { + log.Printf("error occurred: [%s]", err.Error()) +} +log.Printf("response: [%+v]", res) +``` From 07fe4f60934cea496852cf7cb17a79cbdb7dde37 Mon Sep 17 00:00:00 2001 From: Rakhat <51375666+zethuman@users.noreply.github.com> Date: Sat, 15 Apr 2023 01:12:55 +0600 Subject: [PATCH 36/84] [GUIDE] Add advanced_index_actions guide (#288) --- CHANGELOG.md | 1 + guides/advanced_index_actions.md | 206 +++++++++++++++++++++++++++++++ 2 files changed, 207 insertions(+) create mode 100644 guides/advanced_index_actions.md diff --git a/CHANGELOG.md b/CHANGELOG.md index f83f9f4..e40bd32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - 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)) ### Changed diff --git a/guides/advanced_index_actions.md b/guides/advanced_index_actions.md new file mode 100644 index 0000000..153753b --- /dev/null +++ b/guides/advanced_index_actions.md @@ -0,0 +1,206 @@ +# Advanced Index Actions + +In this guide, we will look at some advanced index actions that are not covered in the [Index Lifecycle](index_lifecycle.md) guide. + +## Setup + +Let's create a client instance, and an index named `movies`: + +```go +package main + +import ( + "github.com/opensearch-project/opensearch-go/v2" + "log" +) + +func main() { + client, err := opensearch.NewDefaultClient() + if err != nil { + log.Printf("error occurred: [%s]", err.Error()) + } + log.Printf("response: [%+v]", client) +} + +movies := "movies" + +createMovieIndex, err := client.Indices.Create(movies) +if err != nil { +log.Printf("error occurred: [%s]", err.Error()) +} +log.Printf("response: [%+v]", createMovieIndex) +``` + +## API Actions + +### Clear index cache + +You can clear the cache of an index or indices by using the `indices.clear_cache` API action. The following example clears the cache of the `movies` index: + +```go +res, err := client.Indices.ClearCache(client.Indices.ClearCache.WithIndex(movies)) +if err != nil { + log.Printf("error occurred: [%s]", err.Error()) +} +log.Printf("response: [%+v]", res) +``` + +By default, the `indices.clear_cache` API action clears all types of cache. To clear specific types of cache pass the the `query`, `fielddata`, or `request` parameter to the API action: + +```go +res, err := client.Indices.ClearCache( + client.Indices.ClearCache.WithIndex(movies), + client.Indices.ClearCache.WithFielddata(true), + client.Indices.ClearCache.WithRequest(true), + client.Indices.ClearCache.WithQuery(true), +) +if err != nil { + log.Printf("error occurred: [%s]", err.Error()) +} +log.Printf("response: [%+v]", res) +``` + +### Flush index + +Sometimes you might want to flush an index or indices to make sure that all data in the transaction log is persisted to the index. To flush an index or indices use the `indices.flush` API action. The following example flushes the `movies` index: + +```go +res, err := client.Indices.Flush( + client.Indices.Flush.WithIndex(movies), +) +if err != nil { + log.Printf("error occurred: [%s]", err.Error()) +} +log.Printf("response: [%+v]", res) +``` + +### Refresh index + +You can refresh an index or indices to make sure that all changes are available for search. To refresh an index or indices use the `indices.refresh` API action: + +```go +res, err := client.Indices.Refresh( + client.Indices.Refresh.WithIndex(movies), +) +if err != nil { + log.Printf("error occurred: [%s]", err.Error()) +} +log.Printf("response: [%+v]", res) +``` + +### Open/Close index + +You can close an index to prevent read and write operations on the index. A closed index does not have to maintain certain data structures that an opened index require, reducing the memory and disk space required by the index. The following example closes and reopens the `movies` index: + +```go +res, err := client.Indices.Close([]string{movies}) +if err != nil { + log.Printf("error occurred: [%s]", err.Error()) +} +log.Printf("response: [%+v]", res) + +res, err = client.Indices.Open([]string{movies}) +if err != nil { + log.Printf("error occurred: [%s]", err.Error()) +} +log.Printf("response: [%+v]", res) +``` + +### Force merge index + +You can force merge an index or indices to reduce the number of segments in the index. This can be useful if you have a large number of small segments in the index. Merging segments reduces the memory footprint of the index. Do note that this action is resource intensive and it is only recommended for read-only indices. The following example force merges the `movies` index: + +```go +res, err := client.Indices.Forcemerge( + client.Indices.Forcemerge.WithIndex(movies), +) +if err != nil { + log.Printf("error occurred: [%s]", err.Error()) +} +log.Printf("response: [%+v]", res) +``` + +### Clone index + +You can clone an index to create a new index with the same mappings, data, and MOST of the settings. The source index must be in read-only state for cloning. The following example blocks write operations from `movies` index, clones the said index to create a new index named `movies_clone`, then re-enables write: + +```go +res, err := client.Indices.AddBlock([]string{movies}, "write") +if err != nil { + log.Printf("error occurred: [%s]", err.Error()) +} +log.Printf("response: [%+v]", res) + +res, err = client.Indices.Clone(movies, "movies_clone") +if err != nil { + log.Printf("error occurred: [%s]", err.Error()) +} +log.Printf("response: [%+v]", res) + +res, err = client.Indices.PutSettings( + strings.NewReader(`{"index":{"blocks":{"write":false}}}`), + client.Indices.PutSettings.WithIndex(movies), +) +if err != nil { + log.Printf("error occurred: [%s]", err.Error()) +} +log.Printf("response: [%+v]", res) +``` + +### Split index + +You can split an index into another index with more primary shards. The source index must be in read-only state for splitting. The following example create the read-only `books` index with 30 routing shards and 5 shards (which is divisible by 30), splits index into `bigger_books` with 10 shards (which is also divisible by 30), then re-enables write: + +```go +books := "books" + +res, err := client.Indices.Create(books, + client.Indices.Create.WithBody( + strings.NewReader(`{ + "settings": { + "index": { + "number_of_shards": 5, + "number_of_routing_shards": 30, + "blocks": { + "write": true + } + } + } + }`), + ), +) +if err != nil { + log.Printf("error occurred: [%s]", err.Error()) +} +log.Printf("response: [%+v]", res) + +res, err = client.Indices.Split( + books, "bigger_books", + client.Indices.Split.WithBody(strings.NewReader(`{"settings":{"index":{"number_of_shards": 10}}}`))) +if err != nil { + log.Printf("error occurred: [%s]", err.Error()) +} +log.Printf("response: [%+v]", res) + +res, err = client.Indices.PutSettings( + strings.NewReader(`{"index":{"blocks":{"write":false}}}`), + client.Indices.PutSettings.WithIndex(books), +) +if err != nil { + log.Printf("error occurred: [%s]", err.Error()) +} +log.Printf("response: [%+v]", res) +``` + +## Cleanup + +Let's delete all the indices we created in this guide: + +```go +// movies and books are assigned to variables in the previous examples +deleteIndexes, err = client.Indices.Delete([]string{movies, books, "bigger_books", "movies_clone"}) +if err != nil { + log.Printf("error occurred: [%s]", err.Error()) +} +log.Printf("response: [%+v]", deleteIndexes) +``` From 76b7f8cd5c7a21e1da236d5384877e682d8e8f06 Mon Sep 17 00:00:00 2001 From: "Daniel (dB.) Doubrovkine" Date: Fri, 14 Apr 2023 16:11:48 -0400 Subject: [PATCH 37/84] Linked user guides. (#302) Signed-off-by: dblock --- USER_GUIDE.md | 203 +++-------------------------------------- guides/data_streams.md | 179 ++++++++++++++++++++++++++++++++++++ 2 files changed, 194 insertions(+), 188 deletions(-) create mode 100644 guides/data_streams.md diff --git a/USER_GUIDE.md b/USER_GUIDE.md index da129b1..360e57b 100644 --- a/USER_GUIDE.md +++ b/USER_GUIDE.md @@ -1,12 +1,9 @@ - [User Guide](#user-guide) - - [Example](#example) - - [Amazon OpenSearch Service](#amazon-opensearch-service) - [AWS SDK V1](#aws-sdk-v1) - [AWS SDK V2](#aws-sdk-v2) - - [Data Streams API](#data-streams-api) - - [Create Data Stream](#create-data-streams) - - [Delete Data Stream](#delete-data-streams) - - [Get All Data Streams](#get-data-streams) - - [Get Specific Data Stream](#get-specific-data-streams) - - [Get Specific Data Stream Stats](#get-specific-data-streams-stats) + - [Example](#example) + - [Amazon OpenSearch Service](#amazon-opensearch-service) + - [AWS SDK v1](#aws-sdk-v1) + - [AWS SDK v2](#aws-sdk-v2) + - [Guides by Topic](#guides-by-topic) # User Guide @@ -180,7 +177,7 @@ To read more about SigV4 see [Signature Version 4 signing process](https://docs. 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 @@ -232,7 +229,7 @@ func main() { } ``` -#### AWS SDK V2 +### AWS SDK v2 Use the AWS SDK v2 for Go to authenticate with Amazon OpenSearch service. @@ -328,182 +325,12 @@ func getCredentialProvider(accessKey, secretAccessKey, token string) aws.Credent ``` -## Data Streams API +## Guides by Topic -### Create Data Streams - -- Create new client - -``` -client, err := opensearch.NewDefaultClient() -if err != nil { - panic(err) -} -``` - -- Create template index - -``` -iPut := opensearchapi.IndicesPutIndexTemplateRequest{ - Name: "demo-data-template", - Pretty: true, - Human: true, - ErrorTrace: true, - Body: strings.NewReader(`{"index_patterns": ["demo-*"], "data_stream": {}, "priority": 100} }`), -} -iPutResponse, err := iPut.Do(context.Background(), client) -``` - -- Prepare request object - -``` -es := opensearchapi.IndicesCreateDataStreamRequest{ - Name: "demo-name", - Human: true, - Pretty: true, - ErrorTrace: true, - Header: map[string][]string{ - "Content-Type": {"application/json"}, - }, -} -``` - -- Execute request - -``` -res, err := es.Do(context.TODO(), client) -if err != nil { - // do not panic in production code - panic(err) -} -``` - -- Try to read response - -``` -defer res.Body.Close() -body, err := ioutil.ReadAll(res.Body) -if err != nil { - // do not panic in production code - panic(err) -} - -fmt.Println("Response Status Code: ", res.StatusCode) -fmt.Println("Response Headers: ", res.Header) -fmt.Println("Response Body: ", string(body)) -``` - -- Successfully created data stream - -``` -Response Status Code: 200 -Response Headers: map[Content-Length:[28] Content-Type:[application/json; charset=UTF-8]] -Response Body: {"acknowledged" : true} -``` - -### Delete Data Streams - -- Create new client as previous example -- Prepare request object - -``` -opensearchapi.IndicesDeleteDataStreamRequest{ - Name: "demo-name", - Pretty: true, - Human: true, - ErrorTrace: true, - Header: map[string][]string{ - "Content-Type": {"application/json"}, - }, -} -``` - -- Execute request as previous example -- Try to read response as previous example -- Successfully deleted data stream - -``` -Response Status Code: 200 -Response Headers: map[Content-Length:[28] Content-Type:[application/json; charset=UTF-8]] -Response Body: {"acknowledged" : true} -``` - -### Get All Data Streams - -- Create new client as previous example -- Prepare request object - -``` -r := opensearchapi.IndicesGetDataStreamRequest{ - Pretty: true, - Human: true, - ErrorTrace: true, - Header: map[string][]string{ - "Content-Type": {"application/json"}, - }, -} -``` - -- Execute request as previous example -- Try to read response as previous example -- Successfully retrieved data streams - -``` -Response Status Code: 200 -Response Headers: map[Content-Length:[28] Content-Type:[application/json; charset=UTF-8]] -Response Body: {"data_streams":[{"name":"demo-name","timestamp_field":{"name":"@timestamp"},"indices":[{"index_name":".ds-demo-2023-03-21-23-33-46-000001","index_uuid":"NnzgqnP0ThS7LOMHJuZ-VQ"}],"generation":1,"status":"YELLOW","template":"demo-data-template"}]} -``` - -### Get Specific Data Stream - -- Create new client as previous example -- Prepare request object - -``` -r := opensearchapi.IndicesGetDataStreamRequest{ - Name: "demo-name", - Pretty: true, - Human: true, - ErrorTrace: true, - Header: map[string][]string{ - "Content-Type": {"application/json"}, - }, - } -``` - -- Execute request as previous example -- Try to read response as previous example -- Successfully retrieved data stream - -``` -Response Status Code: 200 -Response Headers: map[Content-Length:[28] Content-Type:[application/json; charset=UTF-8]] -Response Body: {"data_streams":[{"name":"demo-name","timestamp_field":{"name":"@timestamp"},"indices":[{"index_name":".ds-demo-2023-03-21-23-31-50-000001","index_uuid":"vhsowqdeRFCmr1GgQ7mIsQ"}],"generation":1,"status":"YELLOW","template":"demo-data-template"}]} -``` - -### Get Specific Data Stream Stats - -- Create new client as as previous example -- Prepare request object - -``` -r := opensearchapi.IndicesGetDataStreamStatsRequest{ - Name: "demo-name", - Pretty: true, - Human: true, - ErrorTrace: true, - Header: map[string][]string{ - "Content-Type": {"application/json"}, - }, -} -``` - -- Execute request as previous example -- Try to read response as previous example -- Successfully retrieved data stream stats - -``` -Response Status Code: 200 -Response Headers: map[Content-Length:[28] Content-Type:[application/json; charset=UTF-8]] -Response Body: {"_shards":{"total":2,"successful":1,"failed":0},"data_stream_count":1,"backing_indices":1,"total_store_size":"208b","total_store_size_bytes":208,"data_streams":[{"data_stream":"demo-name","backing_indices":1,"store_size":"208b","store_size_bytes":208,"maximum_timestamp":0}]} -``` +- [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/guides/data_streams.md b/guides/data_streams.md new file mode 100644 index 0000000..7a10b72 --- /dev/null +++ b/guides/data_streams.md @@ -0,0 +1,179 @@ +## Data Streams API + +### Create Data Streams + +- Create new client + +``` +client, err := opensearch.NewDefaultClient() +if err != nil { + panic(err) +} +``` + +- Create template index + +``` +iPut := opensearchapi.IndicesPutIndexTemplateRequest{ + Name: "demo-data-template", + Pretty: true, + Human: true, + ErrorTrace: true, + Body: strings.NewReader(`{"index_patterns": ["demo-*"], "data_stream": {}, "priority": 100} }`), +} +iPutResponse, err := iPut.Do(context.Background(), client) +``` + +- Prepare request object + +``` +es := opensearchapi.IndicesCreateDataStreamRequest{ + Name: "demo-name", + Human: true, + Pretty: true, + ErrorTrace: true, + Header: map[string][]string{ + "Content-Type": {"application/json"}, + }, +} +``` + +- Execute request + +``` +res, err := es.Do(context.TODO(), client) +if err != nil { + // do not panic in production code + panic(err) +} +``` + +- Try to read response + +``` +defer res.Body.Close() +body, err := ioutil.ReadAll(res.Body) +if err != nil { + // do not panic in production code + panic(err) +} + +fmt.Println("Response Status Code: ", res.StatusCode) +fmt.Println("Response Headers: ", res.Header) +fmt.Println("Response Body: ", string(body)) +``` + +- Successfully created data stream + +``` +Response Status Code: 200 +Response Headers: map[Content-Length:[28] Content-Type:[application/json; charset=UTF-8]] +Response Body: {"acknowledged" : true} +``` + +### Delete Data Streams + +- Create new client as previous example +- Prepare request object + +``` +opensearchapi.IndicesDeleteDataStreamRequest{ + Name: "demo-name", + Pretty: true, + Human: true, + ErrorTrace: true, + Header: map[string][]string{ + "Content-Type": {"application/json"}, + }, +} +``` + +- Execute request as previous example +- Try to read response as previous example +- Successfully deleted data stream + +``` +Response Status Code: 200 +Response Headers: map[Content-Length:[28] Content-Type:[application/json; charset=UTF-8]] +Response Body: {"acknowledged" : true} +``` + +### Get All Data Streams + +- Create new client as previous example +- Prepare request object + +``` +r := opensearchapi.IndicesGetDataStreamRequest{ + Pretty: true, + Human: true, + ErrorTrace: true, + Header: map[string][]string{ + "Content-Type": {"application/json"}, + }, +} +``` + +- Execute request as previous example +- Try to read response as previous example +- Successfully retrieved data streams + +``` +Response Status Code: 200 +Response Headers: map[Content-Length:[28] Content-Type:[application/json; charset=UTF-8]] +Response Body: {"data_streams":[{"name":"demo-name","timestamp_field":{"name":"@timestamp"},"indices":[{"index_name":".ds-demo-2023-03-21-23-33-46-000001","index_uuid":"NnzgqnP0ThS7LOMHJuZ-VQ"}],"generation":1,"status":"YELLOW","template":"demo-data-template"}]} +``` + +### Get Specific Data Stream + +- Create new client as previous example +- Prepare request object + +``` +r := opensearchapi.IndicesGetDataStreamRequest{ + Name: "demo-name", + Pretty: true, + Human: true, + ErrorTrace: true, + Header: map[string][]string{ + "Content-Type": {"application/json"}, + }, + } +``` + +- Execute request as previous example +- Try to read response as previous example +- Successfully retrieved data stream + +``` +Response Status Code: 200 +Response Headers: map[Content-Length:[28] Content-Type:[application/json; charset=UTF-8]] +Response Body: {"data_streams":[{"name":"demo-name","timestamp_field":{"name":"@timestamp"},"indices":[{"index_name":".ds-demo-2023-03-21-23-31-50-000001","index_uuid":"vhsowqdeRFCmr1GgQ7mIsQ"}],"generation":1,"status":"YELLOW","template":"demo-data-template"}]} +``` + +### Get Specific Data Stream Stats + +- Create new client as as previous example +- Prepare request object + +``` +r := opensearchapi.IndicesGetDataStreamStatsRequest{ + Name: "demo-name", + Pretty: true, + Human: true, + ErrorTrace: true, + Header: map[string][]string{ + "Content-Type": {"application/json"}, + }, +} +``` + +- Execute request as previous example +- Try to read response as previous example +- Successfully retrieved data stream stats + +``` +Response Status Code: 200 +Response Headers: map[Content-Length:[28] Content-Type:[application/json; charset=UTF-8]] +Response Body: {"_shards":{"total":2,"successful":1,"failed":0},"data_stream_count":1,"backing_indices":1,"total_store_size":"208b","total_store_size_bytes":208,"data_streams":[{"data_stream":"demo-name","backing_indices":1,"store_size":"208b","store_size_bytes":208,"maximum_timestamp":0}]} +``` From a133a52471b6b73574cee625d3d056717b78f53a Mon Sep 17 00:00:00 2001 From: Rakhat <51375666+zethuman@users.noreply.github.com> Date: Mon, 17 Apr 2023 23:15:23 +0600 Subject: [PATCH 38/84] Add tests to check UpdateRequestByQuery request (#304) * add tests to check UpdateRequestByQuery request Signed-off-by: Rakhat Zhuman * updated CHANGELOG.md Signed-off-by: Rakhat Zhuman --------- Signed-off-by: Rakhat Zhuman --- CHANGELOG.md | 1 + opensearchapi/api.document_test.go | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e40bd32..0aab830 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - 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)) ### Changed diff --git a/opensearchapi/api.document_test.go b/opensearchapi/api.document_test.go index d9ead2f..ec0bf1b 100644 --- a/opensearchapi/api.document_test.go +++ b/opensearchapi/api.document_test.go @@ -255,6 +255,24 @@ func TestDocumentRequest_Do(t *testing.T) { wantBody: fmt.Sprintf(`{"_index":"%s","_id":"1","_version":2,"result":"noop","_shards":{"total":0,"successful":0,"failed":0},"_seq_no":2,"_primary_term":1,"get":{"_seq_no":2,"_primary_term":1,"found":true,"_source":{"title":"Moneyball","year":"2012"}}}`, index), wantErr: false, }, + // Update by query + { + name: "TestUpdateByQueryRequest_Do. Source Excludes", + r: opensearchapi.UpdateByQueryRequest{ + Index: []string{index}, + Query: `title: "Tenet"`, + Body: strings.NewReader(`{ "script" : { "source": "ctx._source.title += params.title", "lang": "painless", "params" : { "title" : "TeneT" } } }`), + }, + want: &opensearchapi.Response{ + StatusCode: 200, + Header: http.Header{ + "Content-Type": []string{"application/json; charset=UTF-8"}, + }, + }, + wantBody: `{"batches":1, "deleted":0, "failures":[], "noops":0, "requests_per_second":-1, "retries":{"bulk":0, "search":0}, "throttled_millis":0, "throttled_until_millis":0, "timed_out":false, "took":0, "total":1, "updated":1, "version_conflicts":0}`, + wantErr: false, + refresh: true, + }, // Bulk document { From d7f9a41d053316d83565b8933efbce996f83eee7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Apr 2023 19:43:32 -0700 Subject: [PATCH 39/84] Bump github.com/aws/aws-sdk-go from 1.44.241 to 1.44.245 (#306) * Bump github.com/aws/aws-sdk-go from 1.44.241 to 1.44.245 Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.44.241 to 1.44.245. - [Release notes](https://github.com/aws/aws-sdk-go/releases) - [Commits](https://github.com/aws/aws-sdk-go/compare/v1.44.241...v1.44.245) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Update changelog Signed-off-by: dependabot[bot] --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] --- CHANGELOG.md | 4 ++-- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0aab830..7430911 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Dependencies -- Bumps `github.com/aws/aws-sdk-go` from 1.44.45 to 1.44.241 +- Bumps `github.com/aws/aws-sdk-go` from 1.44.45 to 1.44.245 - Bumps `github.com/aws/aws-sdk-go-v2` from 1.17.1 to 1.17.6 - Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.8 to 1.18.21 - Bumps `github.com/stretchr/testify` from 1.8.0 to 1.8.2 @@ -55,4 +55,4 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Security -[Unreleased]: https://github.com/opensearch-project/opensearch-go/compare/2.1...HEAD +[Unreleased]: https://github.com/opensearch-project/opensearch-go/compare/2.1...HEAD \ No newline at end of file diff --git a/go.mod b/go.mod index 7f6d222..dc4246c 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/opensearch-project/opensearch-go/v2 go 1.15 require ( - github.com/aws/aws-sdk-go v1.44.241 + github.com/aws/aws-sdk-go v1.44.245 github.com/aws/aws-sdk-go-v2 v1.17.8 github.com/aws/aws-sdk-go-v2/config v1.18.21 github.com/stretchr/testify v1.8.2 diff --git a/go.sum b/go.sum index da831e0..29e9454 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/aws/aws-sdk-go v1.44.241 h1:D3KycZq3HjhmjYGzvTcmX/Ztf/KNmsfTmdDuKdnzZKo= -github.com/aws/aws-sdk-go v1.44.241/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= +github.com/aws/aws-sdk-go v1.44.245 h1:KtY2s4q31/kn33AdV63R5t77mdxsI7rq3YT7Mgo805M= +github.com/aws/aws-sdk-go v1.44.245/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go-v2 v1.17.8 h1:GMupCNNI7FARX27L7GjCJM8NgivWbRgpjNI/hOQjFS8= github.com/aws/aws-sdk-go-v2 v1.17.8/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= github.com/aws/aws-sdk-go-v2/config v1.18.21 h1:ENTXWKwE8b9YXgQCsruGLhvA9bhg+RqAsL9XEMEsa2c= From 174064af808df5c8555aaccc79a4eff8012908f5 Mon Sep 17 00:00:00 2001 From: Niyazbek Torekeldi <78027392+Tokesh@users.noreply.github.com> Date: Mon, 24 Apr 2023 22:49:54 +0600 Subject: [PATCH 40/84] [BUG] Windows compatibility with Makefile #308 (#309) * Added guides for Windows developers Signed-off-by: Niyazbek Torekeldi <78027392+Tokesh@users.noreply.github.com> * fixing misstakes in documentation Signed-off-by: Niyazbek Torekeldi <78027392+Tokesh@users.noreply.github.com> * fixing english misstakes Signed-off-by: Niyazbek Torekeldi <78027392+Tokesh@users.noreply.github.com> --------- Signed-off-by: Niyazbek Torekeldi <78027392+Tokesh@users.noreply.github.com> --- DEVELOPER_GUIDE.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/DEVELOPER_GUIDE.md b/DEVELOPER_GUIDE.md index 99eb3ac..b0a897e 100644 --- a/DEVELOPER_GUIDE.md +++ b/DEVELOPER_GUIDE.md @@ -4,6 +4,7 @@ - [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) @@ -32,6 +33,15 @@ OpenSearch Go Client builds using [Go](https://golang.org/doc/install) 1.11 at a [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: From 0f646092c952309c223966f854c732757b07b8ef Mon Sep 17 00:00:00 2001 From: Rakhat Date: Mon, 24 Apr 2023 22:53:27 +0600 Subject: [PATCH 41/84] [FIX] Increased timeout in actions between cluster start and test run (#303) * Increased timeout Signed-off-by: Rakhat Zhuman * Decreased timeout Signed-off-by: Rakhat Zhuman * increased timeout Signed-off-by: Rakhat Zhuman * updated CHANGELOG.md Signed-off-by: Rakhat Zhuman * increased timeout Signed-off-by: Rakhat Zhuman * checking without timeout Signed-off-by: Rakhat Zhuman * added active loop to check cluster health Signed-off-by: Rakhat Zhuman * added active loop to check cluster health Signed-off-by: Rakhat Zhuman * added active loop to check cluster health Signed-off-by: Rakhat Zhuman * added active loop to check cluster health Signed-off-by: Rakhat Zhuman * added active loop to check cluster health Signed-off-by: Rakhat Zhuman * added active loop to check cluster health Signed-off-by: Rakhat Zhuman * add healthcheck for secure connection Signed-off-by: Rakhat Zhuman * add healthcheck for secure connection Signed-off-by: Rakhat Zhuman * add restarting container Signed-off-by: Rakhat Zhuman --------- Signed-off-by: Rakhat Zhuman --- .github/workflows/test-compatibility.yml | 6 ++++- .gitignore | 2 ++ CHANGELOG.md | 1 + Makefile | 31 ++++++++++++++++++++++++ 4 files changed, 39 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-compatibility.yml b/.github/workflows/test-compatibility.yml index 0c48fce..795dc83 100644 --- a/.github/workflows/test-compatibility.yml +++ b/.github/workflows/test-compatibility.yml @@ -40,10 +40,14 @@ jobs: export OPENSEARCH_VERSION=${{ matrix.entry.opensearch_version }} export SECURE_INTEGRATION=${{ matrix.secured }} make cluster.clean cluster.build cluster.start + - name: Check Opensearch cluster health + run: | + make cluster.check SECURE_INTEGRATION=${{ matrix.secured }} NUM_CHECKS=30 CHECK_INTERVAL=1 - name: Integration test without security if: ${{ matrix.secured == 'false'}} - run: make test-integ race=true + run: | + make test-integ race=true - name: Integration test with security if: ${{ matrix.secured == 'true'}} diff --git a/.gitignore b/.gitignore index c21189c..8c2fd15 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ tmp/ .idea .vscode bin/ + +.DS_Store \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 7430911..e7d20c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - 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)) ### Changed diff --git a/Makefile b/Makefile index ade9b96..68db1b3 100644 --- a/Makefile +++ b/Makefile @@ -205,6 +205,37 @@ cluster.clean: ## Remove unused Docker volumes and networks docker network prune --force docker system prune --volumes --force +cluster.check: + @printf "\033[2m→ Checking up cluster health...\033[0m\n" + SECURE_INTEGRATION=$(SECURE_INTEGRATION) \ + NUM_CHECKS=$(NUM_CHECKS) \ + CHECK_INTERVAL=$(CHECK_INTERVAL) \ + echo "SECURE_INTEGRATION: $$SECURE_INTEGRATION"; \ + for ((i=1; i<=NUM_CHECKS; i++)); do \ + if [[ $$SECURE_INTEGRATION == "true" ]]; \ + then response=$$(curl --insecure -sS "https://localhost:9200/_cluster/health" -u admin:admin); \ + else response=$$(curl -sS "http://localhost:9200/_cluster/health"); \ + fi; \ + if [[ $$response == *"green"* || $$response == *"yellow"* ]]; then \ + echo "Cluster is healthy."; \ + exit 0; \ + fi; \ + echo "Check #$$i: Cluster is not healthy. Status: $$response"; \ + if [[ $$i == $$((NUM_CHECKS / 5)) ]]; then \ + echo "Restarting OpenSearch Container..."; \ + docker-compose --project-directory .ci/opensearch restart; \ + fi; \ + sleep $$CHECK_INTERVAL; \ + done; \ + echo "Cluster is still not healthy after $$NUM_CHECKS checks."; \ + exit 1; + +cluster.kek: + if [[ "$$SECURE_INTEGRATION" == "false" ]] \ + then HEALTH_CHECK_URL="https://localhost:9200/_cluster/health" \ + else HEALTH_CHECK_URL="http://localhost:9200/_cluster/health" \ + fi; \ + linters: ./bin/golangci-lint run ./... --timeout=5m From b9b5afc1b95f53f54a1225a03acb7d72e3f059ab Mon Sep 17 00:00:00 2001 From: Jakob Date: Mon, 24 Apr 2023 18:54:08 +0200 Subject: [PATCH 42/84] Read, close and replace the http Reponse Body (#300) Signed-off-by: Jakob Hahn --- CHANGELOG.md | 1 + opensearchtransport/opensearchtransport.go | 15 +++++----- .../opensearchtransport_integration_test.go | 28 +++++++++++++++++++ 3 files changed, 37 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e7d20c3..4207997 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - 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 diff --git a/opensearchtransport/opensearchtransport.go b/opensearchtransport/opensearchtransport.go index 491a9b7..fe8e450 100644 --- a/opensearchtransport/opensearchtransport.go +++ b/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/opensearchtransport/opensearchtransport_integration_test.go b/opensearchtransport/opensearchtransport_integration_test.go index 024da3a..bb9876a 100644 --- a/opensearchtransport/opensearchtransport_integration_test.go +++ b/opensearchtransport/opensearchtransport_integration_test.go @@ -24,6 +24,7 @@ // specific language governing permissions and limitations // under the License. +//go:build integration // +build integration package opensearchtransport_test @@ -121,6 +122,33 @@ func TestTransportHeaders(t *testing.T) { } } +func TestTransportBodyClose(t *testing.T) { + u, _ := url.Parse("http://localhost:9200") + + tp, _ := opensearchtransport.New(opensearchtransport.Config{ + URLs: []*url.URL{u}, + }) + + req, _ := http.NewRequest("GET", "/", nil) + res, err := tp.Perform(req) + if err != nil { + t.Fatalf("Unexpected error: %s", err) + } + if closeResp := res.Body.Close(); closeResp != nil { + t.Fatalf("Unexpected return on res.Body.Close(): %s", closeResp) + } + if closeResp := res.Body.Close(); closeResp != nil { + t.Fatalf("Unexpected return on res.Body.Close(): %s", closeResp) + } + body, err := io.ReadAll(res.Body) + if err != nil { + t.Fatalf("Failed to read the reponse body: %s", err) + } + if body == nil || len(body) == 0 { + t.Fatalf("Unexpected response body:\n%s", body) + } +} + func TestTransportCompression(t *testing.T) { var req *http.Request var res *http.Response From 50f72046a7919a9525f5071da394cca36dd47d14 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Apr 2023 23:39:06 -0700 Subject: [PATCH 43/84] Bump github.com/aws/aws-sdk-go-v2 from 1.17.8 to 1.18.0 (#312) * Bump github.com/aws/aws-sdk-go-v2 from 1.17.8 to 1.18.0 Bumps [github.com/aws/aws-sdk-go-v2](https://github.com/aws/aws-sdk-go-v2) from 1.17.8 to 1.18.0. - [Release notes](https://github.com/aws/aws-sdk-go-v2/releases) - [Changelog](https://github.com/aws/aws-sdk-go-v2/blob/main/CHANGELOG.md) - [Commits](https://github.com/aws/aws-sdk-go-v2/compare/v1.17.8...v1.18.0) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go-v2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * Update changelog Signed-off-by: dependabot[bot] --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] --- CHANGELOG.md | 2 +- go.mod | 2 +- go.sum | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4207997..dd8b271 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Dependencies - Bumps `github.com/aws/aws-sdk-go` from 1.44.45 to 1.44.245 -- Bumps `github.com/aws/aws-sdk-go-v2` from 1.17.1 to 1.17.6 +- Bumps `github.com/aws/aws-sdk-go-v2` from 1.17.1 to 1.18.0 - Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.8 to 1.18.21 - Bumps `github.com/stretchr/testify` from 1.8.0 to 1.8.2 diff --git a/go.mod b/go.mod index dc4246c..a113a92 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.15 require ( github.com/aws/aws-sdk-go v1.44.245 - github.com/aws/aws-sdk-go-v2 v1.17.8 + github.com/aws/aws-sdk-go-v2 v1.18.0 github.com/aws/aws-sdk-go-v2/config v1.18.21 github.com/stretchr/testify v1.8.2 golang.org/x/net v0.7.0 // indirect diff --git a/go.sum b/go.sum index 29e9454..0ffd509 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,8 @@ github.com/aws/aws-sdk-go v1.44.245 h1:KtY2s4q31/kn33AdV63R5t77mdxsI7rq3YT7Mgo805M= github.com/aws/aws-sdk-go v1.44.245/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= -github.com/aws/aws-sdk-go-v2 v1.17.8 h1:GMupCNNI7FARX27L7GjCJM8NgivWbRgpjNI/hOQjFS8= github.com/aws/aws-sdk-go-v2 v1.17.8/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= +github.com/aws/aws-sdk-go-v2 v1.18.0 h1:882kkTpSFhdgYRKVZ/VCgf7sd0ru57p2JCxz4/oN5RY= +github.com/aws/aws-sdk-go-v2 v1.18.0/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= github.com/aws/aws-sdk-go-v2/config v1.18.21 h1:ENTXWKwE8b9YXgQCsruGLhvA9bhg+RqAsL9XEMEsa2c= github.com/aws/aws-sdk-go-v2/config v1.18.21/go.mod h1:+jPQiVPz1diRnjj6VGqWcLK6EzNmQ42l7J3OqGTLsSY= github.com/aws/aws-sdk-go-v2/credentials v1.13.20 h1:oZCEFcrMppP/CNiS8myzv9JgOzq2s0d3v3MXYil/mxQ= From 741bc935cb883c2e0c03a0901eb519e542f52fb6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 25 Apr 2023 00:01:26 -0700 Subject: [PATCH 44/84] Bump github.com/aws/aws-sdk-go from 1.44.245 to 1.44.249 (#310) * Bump github.com/aws/aws-sdk-go from 1.44.245 to 1.44.249 Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.44.245 to 1.44.249. - [Release notes](https://github.com/aws/aws-sdk-go/releases) - [Commits](https://github.com/aws/aws-sdk-go/compare/v1.44.245...v1.44.249) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Update changelog Signed-off-by: dependabot[bot] --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] --- CHANGELOG.md | 2 +- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dd8b271..6b4e8b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Dependencies -- Bumps `github.com/aws/aws-sdk-go` from 1.44.45 to 1.44.245 +- Bumps `github.com/aws/aws-sdk-go` from 1.44.45 to 1.44.249 - Bumps `github.com/aws/aws-sdk-go-v2` from 1.17.1 to 1.18.0 - Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.8 to 1.18.21 - Bumps `github.com/stretchr/testify` from 1.8.0 to 1.8.2 diff --git a/go.mod b/go.mod index a113a92..372727b 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/opensearch-project/opensearch-go/v2 go 1.15 require ( - github.com/aws/aws-sdk-go v1.44.245 + github.com/aws/aws-sdk-go v1.44.249 github.com/aws/aws-sdk-go-v2 v1.18.0 github.com/aws/aws-sdk-go-v2/config v1.18.21 github.com/stretchr/testify v1.8.2 diff --git a/go.sum b/go.sum index 0ffd509..21a3334 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/aws/aws-sdk-go v1.44.245 h1:KtY2s4q31/kn33AdV63R5t77mdxsI7rq3YT7Mgo805M= -github.com/aws/aws-sdk-go v1.44.245/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= +github.com/aws/aws-sdk-go v1.44.249 h1:UbUvh/oYHdAD3vZjNi316M0NIupJsrqAcJckVuhaCB8= +github.com/aws/aws-sdk-go v1.44.249/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go-v2 v1.17.8/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= github.com/aws/aws-sdk-go-v2 v1.18.0 h1:882kkTpSFhdgYRKVZ/VCgf7sd0ru57p2JCxz4/oN5RY= github.com/aws/aws-sdk-go-v2 v1.18.0/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= From 924585eef1283a6504a20c26033f85a7b6a5dd5d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 25 Apr 2023 12:04:05 -0400 Subject: [PATCH 45/84] Bump github.com/aws/aws-sdk-go-v2/config from 1.18.21 to 1.18.22 (#311) * Bump github.com/aws/aws-sdk-go-v2/config from 1.18.21 to 1.18.22 Bumps [github.com/aws/aws-sdk-go-v2/config](https://github.com/aws/aws-sdk-go-v2) from 1.18.21 to 1.18.22. - [Release notes](https://github.com/aws/aws-sdk-go-v2/releases) - [Changelog](https://github.com/aws/aws-sdk-go-v2/blob/main/CHANGELOG.md) - [Commits](https://github.com/aws/aws-sdk-go-v2/compare/config/v1.18.21...config/v1.18.22) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go-v2/config dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Update changelog Signed-off-by: dependabot[bot] --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] --- CHANGELOG.md | 2 +- go.mod | 2 +- go.sum | 41 ++++++++++++++++++++--------------------- 3 files changed, 22 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b4e8b1..69c7468 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Bumps `github.com/aws/aws-sdk-go` from 1.44.45 to 1.44.249 - Bumps `github.com/aws/aws-sdk-go-v2` from 1.17.1 to 1.18.0 -- Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.8 to 1.18.21 +- Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.8 to 1.18.22 - Bumps `github.com/stretchr/testify` from 1.8.0 to 1.8.2 ### Added diff --git a/go.mod b/go.mod index 372727b..0372470 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.15 require ( github.com/aws/aws-sdk-go v1.44.249 github.com/aws/aws-sdk-go-v2 v1.18.0 - github.com/aws/aws-sdk-go-v2/config v1.18.21 + github.com/aws/aws-sdk-go-v2/config v1.18.22 github.com/stretchr/testify v1.8.2 golang.org/x/net v0.7.0 // indirect ) diff --git a/go.sum b/go.sum index 21a3334..de49549 100644 --- a/go.sum +++ b/go.sum @@ -1,28 +1,27 @@ github.com/aws/aws-sdk-go v1.44.249 h1:UbUvh/oYHdAD3vZjNi316M0NIupJsrqAcJckVuhaCB8= github.com/aws/aws-sdk-go v1.44.249/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= -github.com/aws/aws-sdk-go-v2 v1.17.8/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= github.com/aws/aws-sdk-go-v2 v1.18.0 h1:882kkTpSFhdgYRKVZ/VCgf7sd0ru57p2JCxz4/oN5RY= github.com/aws/aws-sdk-go-v2 v1.18.0/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= -github.com/aws/aws-sdk-go-v2/config v1.18.21 h1:ENTXWKwE8b9YXgQCsruGLhvA9bhg+RqAsL9XEMEsa2c= -github.com/aws/aws-sdk-go-v2/config v1.18.21/go.mod h1:+jPQiVPz1diRnjj6VGqWcLK6EzNmQ42l7J3OqGTLsSY= -github.com/aws/aws-sdk-go-v2/credentials v1.13.20 h1:oZCEFcrMppP/CNiS8myzv9JgOzq2s0d3v3MXYil/mxQ= -github.com/aws/aws-sdk-go-v2/credentials v1.13.20/go.mod h1:xtZnXErtbZ8YGXC3+8WfajpMBn5Ga/3ojZdxHq6iI8o= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.2 h1:jOzQAesnBFDmz93feqKnsTHsXrlwWORNZMFHMV+WLFU= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.2/go.mod h1:cDh1p6XkSGSwSRIArWRc6+UqAQ7x4alQ0QfpVR6f+co= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.32 h1:dpbVNUjczQ8Ae3QKHbpHBpfvaVkRdesxpTOe9pTouhU= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.32/go.mod h1:RudqOgadTWdcS3t/erPQo24pcVEoYyqj/kKW5Vya21I= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.26 h1:QH2kOS3Ht7x+u0gHCh06CXL/h6G8LQJFpZfFBYBNboo= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.26/go.mod h1:vq86l7956VgFr0/FWQ2BWnK07QC3WYsepKzy33qqY5U= -github.com/aws/aws-sdk-go-v2/internal/ini v1.3.33 h1:HbH1VjUgrCdLJ+4lnnuLI4iVNRvBbBELGaJ5f69ClA8= -github.com/aws/aws-sdk-go-v2/internal/ini v1.3.33/go.mod h1:zG2FcwjQarWaqXSCGpgcr3RSjZ6dHGguZSppUL0XR7Q= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.26 h1:uUt4XctZLhl9wBE1L8lobU3bVN8SNUP7T+olb0bWBO4= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.26/go.mod h1:Bd4C/4PkVGubtNe5iMXu5BNnaBi/9t/UsFspPt4ram8= -github.com/aws/aws-sdk-go-v2/service/sso v1.12.8 h1:5cb3D6xb006bPTqEfCNaEA6PPEfBXxxy4NNeX/44kGk= -github.com/aws/aws-sdk-go-v2/service/sso v1.12.8/go.mod h1:GNIveDnP+aE3jujyUSH5aZ/rktsTM5EvtKnCqBZawdw= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.8 h1:NZaj0ngZMzsubWZbrEFSB4rgSQRbFq38Sd6KBxHuOIU= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.8/go.mod h1:44qFP1g7pfd+U+sQHLPalAPKnyfTZjJsYR4xIwsJy5o= -github.com/aws/aws-sdk-go-v2/service/sts v1.18.9 h1:Qf1aWwnsNkyAoqDqmdM3nHwN78XQjec27LjM6b9vyfI= -github.com/aws/aws-sdk-go-v2/service/sts v1.18.9/go.mod h1:yyW88BEPXA2fGFyI2KCcZC3dNpiT0CZAHaF+i656/tQ= +github.com/aws/aws-sdk-go-v2/config v1.18.22 h1:7vkUEmjjv+giht4wIROqLs+49VWmiQMMHSduxmoNKLU= +github.com/aws/aws-sdk-go-v2/config v1.18.22/go.mod h1:mN7Li1wxaPxSSy4Xkr6stFuinJGf3VZW3ZSNvO0q6sI= +github.com/aws/aws-sdk-go-v2/credentials v1.13.21 h1:VRiXnPEaaPeGeoFcXvMZOB5K/yfIXOYE3q97Kgb0zbU= +github.com/aws/aws-sdk-go-v2/credentials v1.13.21/go.mod h1:90Dk1lJoMyspa/EDUrldTxsPns0wn6+KpRKpdAWc0uA= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.3 h1:jJPgroehGvjrde3XufFIJUZVK5A2L9a3KwSFgKy9n8w= +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 h1:kG5eQilShqmJbv11XL1VpyDbaEJzWxd4zRiCG30GSn4= +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 h1:vFQlirhuM8lLlpI7imKOMsjdQLuN9CPi+k44F/OFVsk= +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 h1:gGLG7yKaXG02/jBlg210R7VgQIotiQntNhsCFejawx8= +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 h1:0iKliEXAcCa2qVtRs7Ot5hItA2MsufrphbRFlz1Owxo= +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.9 h1:GAiaQWuQhQQui76KjuXeShmyXqECwQ0mGRMc/rwsL+c= +github.com/aws/aws-sdk-go-v2/service/sso v1.12.9/go.mod h1:ouy2P4z6sJN70fR3ka3wD3Ro3KezSxU6eKGQI2+2fjI= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.9 h1:TraLwncRJkWqtIBVKI/UqBymq4+hL+3MzUOtUATuzkA= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.9/go.mod h1:AFvkxc8xfBe8XA+5St5XIHHrQQtkxqrRincx4hmMHOk= +github.com/aws/aws-sdk-go-v2/service/sts v1.18.10 h1:6UbNM/KJhMBfOI5+lpVcJ/8OA7cBSz0O6OX37SRKlSw= +github.com/aws/aws-sdk-go-v2/service/sts v1.18.10/go.mod h1:BgQOMsg8av8jset59jelyPW7NoZcZXLVpDsXunGDrk8= github.com/aws/smithy-go v1.13.5 h1:hgz0X/DX0dGqTYpGALqXJoRKRj5oQ7150i5FdTePzO8= github.com/aws/smithy-go v1.13.5/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= From 953b0ad718ec213dd71ea4a64f0af4589e84e5df Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 3 May 2023 17:04:02 -0400 Subject: [PATCH 46/84] Bump github.com/aws/aws-sdk-go from 1.44.249 to 1.44.254 (#314) * Bump github.com/aws/aws-sdk-go from 1.44.249 to 1.44.254 Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.44.249 to 1.44.254. - [Release notes](https://github.com/aws/aws-sdk-go/releases) - [Commits](https://github.com/aws/aws-sdk-go/compare/v1.44.249...v1.44.254) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Update changelog Signed-off-by: dependabot[bot] --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] --- CHANGELOG.md | 2 +- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 69c7468..d81636a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Dependencies -- Bumps `github.com/aws/aws-sdk-go` from 1.44.45 to 1.44.249 +- Bumps `github.com/aws/aws-sdk-go` from 1.44.45 to 1.44.254 - Bumps `github.com/aws/aws-sdk-go-v2` from 1.17.1 to 1.18.0 - Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.8 to 1.18.22 - Bumps `github.com/stretchr/testify` from 1.8.0 to 1.8.2 diff --git a/go.mod b/go.mod index 0372470..d3ff426 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/opensearch-project/opensearch-go/v2 go 1.15 require ( - github.com/aws/aws-sdk-go v1.44.249 + github.com/aws/aws-sdk-go v1.44.254 github.com/aws/aws-sdk-go-v2 v1.18.0 github.com/aws/aws-sdk-go-v2/config v1.18.22 github.com/stretchr/testify v1.8.2 diff --git a/go.sum b/go.sum index de49549..ecda684 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/aws/aws-sdk-go v1.44.249 h1:UbUvh/oYHdAD3vZjNi316M0NIupJsrqAcJckVuhaCB8= -github.com/aws/aws-sdk-go v1.44.249/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= +github.com/aws/aws-sdk-go v1.44.254 h1:8baW4yal2xGiM/Wm5/ZU10drS8sd+BVjMjPFjJx2ooc= +github.com/aws/aws-sdk-go v1.44.254/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go-v2 v1.18.0 h1:882kkTpSFhdgYRKVZ/VCgf7sd0ru57p2JCxz4/oN5RY= github.com/aws/aws-sdk-go-v2 v1.18.0/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= github.com/aws/aws-sdk-go-v2/config v1.18.22 h1:7vkUEmjjv+giht4wIROqLs+49VWmiQMMHSduxmoNKLU= From 9c7af77814ec051846e081aa0b13c634482a2d5d Mon Sep 17 00:00:00 2001 From: Jakob Date: Fri, 5 May 2023 20:36:48 +0200 Subject: [PATCH 47/84] [Feature] Add healthcheck to docker container (#316) * add container healthcheck Signed-off-by: Rakhat Zhuman * update CHANGELOG.md Signed-off-by: Rakhat Zhuman * Makefile: Remove sleep from cluster.start Signed-off-by: Jakob Hahn * docker-compose: Restart container on failure Signed-off-by: Jakob Hahn * Add custer ready check to workflows Signed-off-by: Jakob Hahn --------- Signed-off-by: Rakhat Zhuman Signed-off-by: Jakob Hahn Co-authored-by: Rakhat Zhuman --- .ci/opensearch/Dockerfile.opensearch | 6 +++++ .ci/opensearch/docker-compose.yml | 4 ++- .github/workflows/test-compatibility.yml | 6 ++--- CHANGELOG.md | 3 ++- Makefile | 32 ------------------------ 5 files changed, 14 insertions(+), 37 deletions(-) diff --git a/.ci/opensearch/Dockerfile.opensearch b/.ci/opensearch/Dockerfile.opensearch index 787b1b8..284362f 100755 --- a/.ci/opensearch/Dockerfile.opensearch +++ b/.ci/opensearch/Dockerfile.opensearch @@ -3,5 +3,11 @@ FROM opensearchproject/opensearch:${OPENSEARCH_VERSION} ARG opensearch_path=/usr/share/opensearch ARG SECURE_INTEGRATION +ENV SECURE_INTEGRATION=$SECURE_INTEGRATION RUN if [ "$SECURE_INTEGRATION" != "true" ] ; then $opensearch_path/bin/opensearch-plugin remove opensearch-security; fi + +HEALTHCHECK --start-period=20s --interval=30s \ + CMD curl -sf -retry 5 --max-time 5 --retry-delay 5 --retry-max-time 30 \ + $(if $SECURE_INTEGRATION; then echo "-u admin:admin -k https://"; fi)"localhost:9200" \ + || bash -c 'kill -s 15 -1 && (sleep 10; kill -s 9 -1)' diff --git a/.ci/opensearch/docker-compose.yml b/.ci/opensearch/docker-compose.yml index b27694e..ce150c9 100755 --- a/.ci/opensearch/docker-compose.yml +++ b/.ci/opensearch/docker-compose.yml @@ -1,8 +1,10 @@ version: '3' services: - opensearch: + deploy: + restart_policy: + condition: any build: context: . dockerfile: Dockerfile.opensearch diff --git a/.github/workflows/test-compatibility.yml b/.github/workflows/test-compatibility.yml index 795dc83..a09b9c8 100644 --- a/.github/workflows/test-compatibility.yml +++ b/.github/workflows/test-compatibility.yml @@ -40,9 +40,9 @@ jobs: export OPENSEARCH_VERSION=${{ matrix.entry.opensearch_version }} export SECURE_INTEGRATION=${{ matrix.secured }} make cluster.clean cluster.build cluster.start - - name: Check Opensearch cluster health - run: | - make cluster.check SECURE_INTEGRATION=${{ matrix.secured }} NUM_CHECKS=30 CHECK_INTERVAL=1 + for attempt in `seq 25`; do sleep 5; \ + if curl -s $(if $SECURE_INTEGRATION; then echo "-ku admin:admin https://"; fi)localhost:9200; \ + then echo '=====> ready'; break; fi; if [ $attempt == 25 ]; then exit 1; fi; echo '=====> waiting...'; done - name: Integration test without security if: ${{ matrix.secured == 'false'}} diff --git a/CHANGELOG.md b/CHANGELOG.md index d81636a..26e9ed8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - 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 @@ -57,4 +58,4 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Security -[Unreleased]: https://github.com/opensearch-project/opensearch-go/compare/2.1...HEAD \ No newline at end of file +[Unreleased]: https://github.com/opensearch-project/opensearch-go/compare/2.1...HEAD diff --git a/Makefile b/Makefile index 68db1b3..137db3f 100644 --- a/Makefile +++ b/Makefile @@ -193,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 ; @@ -205,37 +204,6 @@ cluster.clean: ## Remove unused Docker volumes and networks docker network prune --force docker system prune --volumes --force -cluster.check: - @printf "\033[2m→ Checking up cluster health...\033[0m\n" - SECURE_INTEGRATION=$(SECURE_INTEGRATION) \ - NUM_CHECKS=$(NUM_CHECKS) \ - CHECK_INTERVAL=$(CHECK_INTERVAL) \ - echo "SECURE_INTEGRATION: $$SECURE_INTEGRATION"; \ - for ((i=1; i<=NUM_CHECKS; i++)); do \ - if [[ $$SECURE_INTEGRATION == "true" ]]; \ - then response=$$(curl --insecure -sS "https://localhost:9200/_cluster/health" -u admin:admin); \ - else response=$$(curl -sS "http://localhost:9200/_cluster/health"); \ - fi; \ - if [[ $$response == *"green"* || $$response == *"yellow"* ]]; then \ - echo "Cluster is healthy."; \ - exit 0; \ - fi; \ - echo "Check #$$i: Cluster is not healthy. Status: $$response"; \ - if [[ $$i == $$((NUM_CHECKS / 5)) ]]; then \ - echo "Restarting OpenSearch Container..."; \ - docker-compose --project-directory .ci/opensearch restart; \ - fi; \ - sleep $$CHECK_INTERVAL; \ - done; \ - echo "Cluster is still not healthy after $$NUM_CHECKS checks."; \ - exit 1; - -cluster.kek: - if [[ "$$SECURE_INTEGRATION" == "false" ]] \ - then HEALTH_CHECK_URL="https://localhost:9200/_cluster/health" \ - else HEALTH_CHECK_URL="http://localhost:9200/_cluster/health" \ - fi; \ - linters: ./bin/golangci-lint run ./... --timeout=5m From 54de3f18fcfc478705cac7fa8f80bbde8e6b0238 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 9 May 2023 10:33:48 -0700 Subject: [PATCH 48/84] Bump github.com/aws/aws-sdk-go from 1.44.254 to 1.44.259 (#319) * Bump github.com/aws/aws-sdk-go from 1.44.254 to 1.44.259 Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.44.254 to 1.44.259. - [Release notes](https://github.com/aws/aws-sdk-go/releases) - [Commits](https://github.com/aws/aws-sdk-go/compare/v1.44.254...v1.44.259) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Update changelog Signed-off-by: dependabot[bot] --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] --- CHANGELOG.md | 4 ++-- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 26e9ed8..e241025 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Dependencies -- Bumps `github.com/aws/aws-sdk-go` from 1.44.45 to 1.44.254 +- Bumps `github.com/aws/aws-sdk-go` from 1.44.45 to 1.44.259 - Bumps `github.com/aws/aws-sdk-go-v2` from 1.17.1 to 1.18.0 - Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.8 to 1.18.22 - Bumps `github.com/stretchr/testify` from 1.8.0 to 1.8.2 @@ -58,4 +58,4 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Security -[Unreleased]: https://github.com/opensearch-project/opensearch-go/compare/2.1...HEAD +[Unreleased]: https://github.com/opensearch-project/opensearch-go/compare/2.1...HEAD \ No newline at end of file diff --git a/go.mod b/go.mod index d3ff426..954784e 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/opensearch-project/opensearch-go/v2 go 1.15 require ( - github.com/aws/aws-sdk-go v1.44.254 + github.com/aws/aws-sdk-go v1.44.259 github.com/aws/aws-sdk-go-v2 v1.18.0 github.com/aws/aws-sdk-go-v2/config v1.18.22 github.com/stretchr/testify v1.8.2 diff --git a/go.sum b/go.sum index ecda684..dfdb08a 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/aws/aws-sdk-go v1.44.254 h1:8baW4yal2xGiM/Wm5/ZU10drS8sd+BVjMjPFjJx2ooc= -github.com/aws/aws-sdk-go v1.44.254/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= +github.com/aws/aws-sdk-go v1.44.259 h1:7yDn1dcv4DZFMKpu+2exIH5O6ipNj9qXrKfdMUaIJwY= +github.com/aws/aws-sdk-go v1.44.259/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go-v2 v1.18.0 h1:882kkTpSFhdgYRKVZ/VCgf7sd0ru57p2JCxz4/oN5RY= github.com/aws/aws-sdk-go-v2 v1.18.0/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= github.com/aws/aws-sdk-go-v2/config v1.18.22 h1:7vkUEmjjv+giht4wIROqLs+49VWmiQMMHSduxmoNKLU= From 928012082cbf7f0f3bf19a21b425cf5772ebb1be Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 9 May 2023 13:48:21 -0400 Subject: [PATCH 49/84] Bump github.com/aws/aws-sdk-go-v2/config from 1.18.22 to 1.18.24 (#318) * Bump github.com/aws/aws-sdk-go-v2/config from 1.18.22 to 1.18.24 Bumps [github.com/aws/aws-sdk-go-v2/config](https://github.com/aws/aws-sdk-go-v2) from 1.18.22 to 1.18.24. - [Release notes](https://github.com/aws/aws-sdk-go-v2/releases) - [Changelog](https://github.com/aws/aws-sdk-go-v2/blob/main/CHANGELOG.md) - [Commits](https://github.com/aws/aws-sdk-go-v2/compare/config/v1.18.22...config/v1.18.24) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go-v2/config dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Update changelog Signed-off-by: dependabot[bot] --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] --- CHANGELOG.md | 2 +- go.mod | 2 +- go.sum | 20 ++++++++++---------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e241025..f6ca3fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Bumps `github.com/aws/aws-sdk-go` from 1.44.45 to 1.44.259 - Bumps `github.com/aws/aws-sdk-go-v2` from 1.17.1 to 1.18.0 -- Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.8 to 1.18.22 +- Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.8 to 1.18.24 - Bumps `github.com/stretchr/testify` from 1.8.0 to 1.8.2 ### Added diff --git a/go.mod b/go.mod index 954784e..e05d418 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.15 require ( github.com/aws/aws-sdk-go v1.44.259 github.com/aws/aws-sdk-go-v2 v1.18.0 - github.com/aws/aws-sdk-go-v2/config v1.18.22 + github.com/aws/aws-sdk-go-v2/config v1.18.24 github.com/stretchr/testify v1.8.2 golang.org/x/net v0.7.0 // indirect ) diff --git a/go.sum b/go.sum index dfdb08a..15b26bd 100644 --- a/go.sum +++ b/go.sum @@ -2,10 +2,10 @@ github.com/aws/aws-sdk-go v1.44.259 h1:7yDn1dcv4DZFMKpu+2exIH5O6ipNj9qXrKfdMUaIJ github.com/aws/aws-sdk-go v1.44.259/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go-v2 v1.18.0 h1:882kkTpSFhdgYRKVZ/VCgf7sd0ru57p2JCxz4/oN5RY= github.com/aws/aws-sdk-go-v2 v1.18.0/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= -github.com/aws/aws-sdk-go-v2/config v1.18.22 h1:7vkUEmjjv+giht4wIROqLs+49VWmiQMMHSduxmoNKLU= -github.com/aws/aws-sdk-go-v2/config v1.18.22/go.mod h1:mN7Li1wxaPxSSy4Xkr6stFuinJGf3VZW3ZSNvO0q6sI= -github.com/aws/aws-sdk-go-v2/credentials v1.13.21 h1:VRiXnPEaaPeGeoFcXvMZOB5K/yfIXOYE3q97Kgb0zbU= -github.com/aws/aws-sdk-go-v2/credentials v1.13.21/go.mod h1:90Dk1lJoMyspa/EDUrldTxsPns0wn6+KpRKpdAWc0uA= +github.com/aws/aws-sdk-go-v2/config v1.18.24 h1:G0mJzpMjJFtK+7KtAky2kAjio21BdzNXblQSm2ZKsy0= +github.com/aws/aws-sdk-go-v2/config v1.18.24/go.mod h1:+9/RIaxGG2let2y9lIYEwOTBhaXqArOakom2TVytvFE= +github.com/aws/aws-sdk-go-v2/credentials v1.13.23 h1:uKTIH4RmFIo04Pijn132WEMaboVLAg96H4l2KFRGzZU= +github.com/aws/aws-sdk-go-v2/credentials v1.13.23/go.mod h1:jYPYi99wUOPIFi0rhiOvXeSEReVOzBqFNOX5bXYoG2o= github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.3 h1:jJPgroehGvjrde3XufFIJUZVK5A2L9a3KwSFgKy9n8w= 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 h1:kG5eQilShqmJbv11XL1VpyDbaEJzWxd4zRiCG30GSn4= @@ -16,12 +16,12 @@ github.com/aws/aws-sdk-go-v2/internal/ini v1.3.34 h1:gGLG7yKaXG02/jBlg210R7VgQIo 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 h1:0iKliEXAcCa2qVtRs7Ot5hItA2MsufrphbRFlz1Owxo= 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.9 h1:GAiaQWuQhQQui76KjuXeShmyXqECwQ0mGRMc/rwsL+c= -github.com/aws/aws-sdk-go-v2/service/sso v1.12.9/go.mod h1:ouy2P4z6sJN70fR3ka3wD3Ro3KezSxU6eKGQI2+2fjI= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.9 h1:TraLwncRJkWqtIBVKI/UqBymq4+hL+3MzUOtUATuzkA= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.9/go.mod h1:AFvkxc8xfBe8XA+5St5XIHHrQQtkxqrRincx4hmMHOk= -github.com/aws/aws-sdk-go-v2/service/sts v1.18.10 h1:6UbNM/KJhMBfOI5+lpVcJ/8OA7cBSz0O6OX37SRKlSw= -github.com/aws/aws-sdk-go-v2/service/sts v1.18.10/go.mod h1:BgQOMsg8av8jset59jelyPW7NoZcZXLVpDsXunGDrk8= +github.com/aws/aws-sdk-go-v2/service/sso v1.12.10 h1:UBQjaMTCKwyUYwiVnUt6toEJwGXsLBI6al083tpjJzY= +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 h1:PkHIIJs8qvq0e5QybnZoG1K/9QTrLr9OsqCIo59jOBA= +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 h1:2DQLAKDteoEDI8zpCzqBMaZlJuoE9iTYD0gFmXVax9E= +github.com/aws/aws-sdk-go-v2/service/sts v1.19.0/go.mod h1:BgQOMsg8av8jset59jelyPW7NoZcZXLVpDsXunGDrk8= github.com/aws/smithy-go v1.13.5 h1:hgz0X/DX0dGqTYpGALqXJoRKRj5oQ7150i5FdTePzO8= github.com/aws/smithy-go v1.13.5/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= From 5831f1f4f5c63706e5f706caa96030d512f1d1b5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 16 May 2023 11:03:18 -0700 Subject: [PATCH 50/84] Bump github.com/aws/aws-sdk-go-v2/config from 1.18.24 to 1.18.25 (#320) * Bump github.com/aws/aws-sdk-go-v2/config from 1.18.24 to 1.18.25 Bumps [github.com/aws/aws-sdk-go-v2/config](https://github.com/aws/aws-sdk-go-v2) from 1.18.24 to 1.18.25. - [Release notes](https://github.com/aws/aws-sdk-go-v2/releases) - [Changelog](https://github.com/aws/aws-sdk-go-v2/blob/main/CHANGELOG.md) - [Commits](https://github.com/aws/aws-sdk-go-v2/compare/config/v1.18.24...config/v1.18.25) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go-v2/config dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Update changelog Signed-off-by: dependabot[bot] --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] --- CHANGELOG.md | 2 +- go.mod | 2 +- go.sum | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f6ca3fe..aa13df6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Bumps `github.com/aws/aws-sdk-go` from 1.44.45 to 1.44.259 - Bumps `github.com/aws/aws-sdk-go-v2` from 1.17.1 to 1.18.0 -- Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.8 to 1.18.24 +- 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.0 to 1.8.2 ### Added diff --git a/go.mod b/go.mod index e05d418..3219caf 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.15 require ( github.com/aws/aws-sdk-go v1.44.259 github.com/aws/aws-sdk-go-v2 v1.18.0 - github.com/aws/aws-sdk-go-v2/config v1.18.24 + github.com/aws/aws-sdk-go-v2/config v1.18.25 github.com/stretchr/testify v1.8.2 golang.org/x/net v0.7.0 // indirect ) diff --git a/go.sum b/go.sum index 15b26bd..2306834 100644 --- a/go.sum +++ b/go.sum @@ -2,10 +2,10 @@ github.com/aws/aws-sdk-go v1.44.259 h1:7yDn1dcv4DZFMKpu+2exIH5O6ipNj9qXrKfdMUaIJ github.com/aws/aws-sdk-go v1.44.259/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go-v2 v1.18.0 h1:882kkTpSFhdgYRKVZ/VCgf7sd0ru57p2JCxz4/oN5RY= github.com/aws/aws-sdk-go-v2 v1.18.0/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= -github.com/aws/aws-sdk-go-v2/config v1.18.24 h1:G0mJzpMjJFtK+7KtAky2kAjio21BdzNXblQSm2ZKsy0= -github.com/aws/aws-sdk-go-v2/config v1.18.24/go.mod h1:+9/RIaxGG2let2y9lIYEwOTBhaXqArOakom2TVytvFE= -github.com/aws/aws-sdk-go-v2/credentials v1.13.23 h1:uKTIH4RmFIo04Pijn132WEMaboVLAg96H4l2KFRGzZU= -github.com/aws/aws-sdk-go-v2/credentials v1.13.23/go.mod h1:jYPYi99wUOPIFi0rhiOvXeSEReVOzBqFNOX5bXYoG2o= +github.com/aws/aws-sdk-go-v2/config v1.18.25 h1:JuYyZcnMPBiFqn87L2cRppo+rNwgah6YwD3VuyvaW6Q= +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 h1:PjiYyls3QdCrzqUN35jMWtUK1vqVZ+zLfdOa/UPFDp0= +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 h1:jJPgroehGvjrde3XufFIJUZVK5A2L9a3KwSFgKy9n8w= 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 h1:kG5eQilShqmJbv11XL1VpyDbaEJzWxd4zRiCG30GSn4= From 18023633606e2e0c9b585f592fe2d2c5061a44a9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 17 May 2023 22:27:32 -0700 Subject: [PATCH 51/84] Bump github.com/aws/aws-sdk-go from 1.44.259 to 1.44.263 (#321) * Bump github.com/aws/aws-sdk-go from 1.44.259 to 1.44.263 Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.44.259 to 1.44.263. - [Release notes](https://github.com/aws/aws-sdk-go/releases) - [Commits](https://github.com/aws/aws-sdk-go/compare/v1.44.259...v1.44.263) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Update changelog Signed-off-by: dependabot[bot] --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] --- CHANGELOG.md | 2 +- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa13df6..7768ffe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Dependencies -- Bumps `github.com/aws/aws-sdk-go` from 1.44.45 to 1.44.259 +- Bumps `github.com/aws/aws-sdk-go` from 1.44.45 to 1.44.263 - Bumps `github.com/aws/aws-sdk-go-v2` from 1.17.1 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.0 to 1.8.2 diff --git a/go.mod b/go.mod index 3219caf..943b179 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/opensearch-project/opensearch-go/v2 go 1.15 require ( - github.com/aws/aws-sdk-go v1.44.259 + github.com/aws/aws-sdk-go v1.44.263 github.com/aws/aws-sdk-go-v2 v1.18.0 github.com/aws/aws-sdk-go-v2/config v1.18.25 github.com/stretchr/testify v1.8.2 diff --git a/go.sum b/go.sum index 2306834..504a2cf 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/aws/aws-sdk-go v1.44.259 h1:7yDn1dcv4DZFMKpu+2exIH5O6ipNj9qXrKfdMUaIJwY= -github.com/aws/aws-sdk-go v1.44.259/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= +github.com/aws/aws-sdk-go v1.44.263 h1:Dkt5fcdtL8QtK3cz0bOTQ84m9dGx+YDeTsDl+wY2yW4= +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 h1:882kkTpSFhdgYRKVZ/VCgf7sd0ru57p2JCxz4/oN5RY= 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 h1:JuYyZcnMPBiFqn87L2cRppo+rNwgah6YwD3VuyvaW6Q= From 79276589f559b82d5860552e25dea3b4dcb5b010 Mon Sep 17 00:00:00 2001 From: Vacha Shah Date: Thu, 18 May 2023 13:40:11 -0700 Subject: [PATCH 52/84] Fixing Changelog with only unreleased entries (#323) Signed-off-by: Vacha Shah --- CHANGELOG.md | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7768ffe..f5a140d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,25 +6,22 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Dependencies -- Bumps `github.com/aws/aws-sdk-go` from 1.44.45 to 1.44.263 -- Bumps `github.com/aws/aws-sdk-go-v2` from 1.17.1 to 1.18.0 +- 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.0 to 1.8.2 +- Bumps `github.com/stretchr/testify` from 1.8.1 to 1.8.2 ### Added -- Adds support for Amazon OpenSearch Serverless ([#216](https://github.com/opensearch-project/opensearch-go/pull/216), [#259](https://github.com/opensearch-project/opensearch-go/pull/259)) -- Adds Github workflow for changelog verification ([#172](https://github.com/opensearch-project/opensearch-go/pull/172)) -- Adds Go Documentation link for the client ([#182](https://github.com/opensearch-project/opensearch-go/pull/182)) -- Adds implementation of Data Streams API ([#257](https://github.com/opensearch-project/opensearch-go/pull/257) +- Adds implementation of Data Streams API ([#257](https://github.com/opensearch-project/opensearch-go/pull/257)) - Adds `Err()` function to Response for detailed errors ([#246](https://github.com/opensearch-project/opensearch-go/pull/246)) - 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 ([#207](https://github.com/opensearch-project/opensearch-go/issues/207)) +- 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 ([#158](https://github.com/opensearch-project/opensearch-go/issues/158)) -- Adds testcases for Document API ([#280](https://github.com/opensearch-project/opensearch-go/issues/280)) +- 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)) @@ -32,7 +29,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - 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 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 @@ -51,11 +48,9 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Fixed -- Renames the sequence number struct tag to `if_seq_no` to fix optimistic concurrency control ([#166](https://github.com/opensearch-project/opensearch-go/pull/166)) -- Fixes `RetryOnConflict` on bulk indexer ([#215](https://github.com/opensearch-project/opensearch-go/pull/215)) - 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 \ No newline at end of file +[Unreleased]: https://github.com/opensearch-project/opensearch-go/compare/v2.2.0...HEAD \ No newline at end of file From 602fa25ab68ee16784c4b711b57ef98228308ad8 Mon Sep 17 00:00:00 2001 From: Rakhat Date: Tue, 30 May 2023 23:32:16 +0600 Subject: [PATCH 53/84] [FEATURE] Code analysis tool (#313) * add code analysis tool Signed-off-by: Rakhat Zhuman * increased timeout Signed-off-by: Rakhat Zhuman * add only-new-issues paramter Signed-off-by: Rakhat Zhuman --------- Signed-off-by: Rakhat Zhuman --- .github/workflows/lint.yml | 15 +++++++-------- .golangci.yml | 3 +++ CHANGELOG.md | 1 + 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 7422aee..7f79c24 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -18,15 +18,14 @@ jobs: steps: - uses: actions/checkout@v3 with: { fetch-depth: 1 } - - uses: actions/setup-go@v2 + - uses: actions/setup-go@v3 with: { go-version: '1.x' } - - name: Install dependencies - run: go install golang.org/x/lint/golint@latest - env: - GOBIN: ${{ env.GOROOT }}/bin - shell: bash - - run: go version - - run: make lint + - name: golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + version: v1.52.2 + args: -v -c .golangci.yml + only-new-issues: true prettify: name: Prettify diff --git a/.golangci.yml b/.golangci.yml index ecde6ec..1279c9a 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,4 +1,7 @@ run: + # Timeout for analysis, e.g. 30s, 5m. + # Default: 1m + timeout: 20m modules-download-mode: readonly issues-exit-code: 0 diff --git a/CHANGELOG.md b/CHANGELOG.md index f5a140d..80be976 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - 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)) +- Adds golangci-lint as code analysis tool ([#313](https://github.com/opensearch-project/opensearch-go/pull/313)) ### Changed From 399922dcb21d52b44dcd7318f333791d71f71103 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 20 Jun 2023 08:20:50 -0400 Subject: [PATCH 54/84] Bump github.com/aws/aws-sdk-go-v2 from 1.18.0 to 1.18.1 (#333) * Bump github.com/aws/aws-sdk-go-v2 from 1.18.0 to 1.18.1 Bumps [github.com/aws/aws-sdk-go-v2](https://github.com/aws/aws-sdk-go-v2) from 1.18.0 to 1.18.1. - [Release notes](https://github.com/aws/aws-sdk-go-v2/releases) - [Changelog](https://github.com/aws/aws-sdk-go-v2/blob/main/CHANGELOG.md) - [Commits](https://github.com/aws/aws-sdk-go-v2/compare/v1.18.0...v1.18.1) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go-v2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Update changelog Signed-off-by: dependabot[bot] --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] --- CHANGELOG.md | 2 +- go.mod | 2 +- go.sum | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 80be976..122d72a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Dependencies - 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` from 1.17.4 to 1.18.1 - 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 diff --git a/go.mod b/go.mod index 943b179..92707ea 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.15 require ( github.com/aws/aws-sdk-go v1.44.263 - github.com/aws/aws-sdk-go-v2 v1.18.0 + github.com/aws/aws-sdk-go-v2 v1.18.1 github.com/aws/aws-sdk-go-v2/config v1.18.25 github.com/stretchr/testify v1.8.2 golang.org/x/net v0.7.0 // indirect diff --git a/go.sum b/go.sum index 504a2cf..12ecfbe 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,8 @@ github.com/aws/aws-sdk-go v1.44.263 h1:Dkt5fcdtL8QtK3cz0bOTQ84m9dGx+YDeTsDl+wY2yW4= 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 h1:882kkTpSFhdgYRKVZ/VCgf7sd0ru57p2JCxz4/oN5RY= github.com/aws/aws-sdk-go-v2 v1.18.0/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= +github.com/aws/aws-sdk-go-v2 v1.18.1 h1:+tefE750oAb7ZQGzla6bLkOwfcQCEtC5y2RqoqCeqKo= +github.com/aws/aws-sdk-go-v2 v1.18.1/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= github.com/aws/aws-sdk-go-v2/config v1.18.25 h1:JuYyZcnMPBiFqn87L2cRppo+rNwgah6YwD3VuyvaW6Q= 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 h1:PjiYyls3QdCrzqUN35jMWtUK1vqVZ+zLfdOa/UPFDp0= From b91d0558ab084ff895345c7ca82c06440bec7660 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 20 Jun 2023 08:31:17 -0400 Subject: [PATCH 55/84] Bump github.com/aws/aws-sdk-go from 1.44.263 to 1.44.285 (#335) * Bump github.com/aws/aws-sdk-go from 1.44.263 to 1.44.285 Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.44.263 to 1.44.285. - [Release notes](https://github.com/aws/aws-sdk-go/releases) - [Commits](https://github.com/aws/aws-sdk-go/compare/v1.44.263...v1.44.285) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Update changelog Signed-off-by: dependabot[bot] --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] --- CHANGELOG.md | 2 +- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 122d72a..63714a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Dependencies -- Bumps `github.com/aws/aws-sdk-go` from 1.44.180 to 1.44.263 +- Bumps `github.com/aws/aws-sdk-go` from 1.44.180 to 1.44.285 - Bumps `github.com/aws/aws-sdk-go-v2` from 1.17.4 to 1.18.1 - 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 diff --git a/go.mod b/go.mod index 92707ea..5a24915 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/opensearch-project/opensearch-go/v2 go 1.15 require ( - github.com/aws/aws-sdk-go v1.44.263 + github.com/aws/aws-sdk-go v1.44.285 github.com/aws/aws-sdk-go-v2 v1.18.1 github.com/aws/aws-sdk-go-v2/config v1.18.25 github.com/stretchr/testify v1.8.2 diff --git a/go.sum b/go.sum index 12ecfbe..520a916 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/aws/aws-sdk-go v1.44.263 h1:Dkt5fcdtL8QtK3cz0bOTQ84m9dGx+YDeTsDl+wY2yW4= -github.com/aws/aws-sdk-go v1.44.263/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= +github.com/aws/aws-sdk-go v1.44.285 h1:rgoWYl+NdmKzRgoi/fZLEtGXOjCkcWIa5jPH02Uahdo= +github.com/aws/aws-sdk-go v1.44.285/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 v1.18.1 h1:+tefE750oAb7ZQGzla6bLkOwfcQCEtC5y2RqoqCeqKo= github.com/aws/aws-sdk-go-v2 v1.18.1/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= From 4d8e860d4767cbe7871674e77f6f2d9a8a6e2b5c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 20 Jun 2023 08:50:36 -0400 Subject: [PATCH 56/84] Bump github.com/stretchr/testify from 1.8.2 to 1.8.4 (#329) * Bump github.com/stretchr/testify from 1.8.2 to 1.8.4 Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.8.2 to 1.8.4. - [Release notes](https://github.com/stretchr/testify/releases) - [Commits](https://github.com/stretchr/testify/compare/v1.8.2...v1.8.4) --- updated-dependencies: - dependency-name: github.com/stretchr/testify dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Update changelog Signed-off-by: dependabot[bot] --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] --- CHANGELOG.md | 2 +- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 63714a3..f47a51c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Bumps `github.com/aws/aws-sdk-go` from 1.44.180 to 1.44.285 - Bumps `github.com/aws/aws-sdk-go-v2` from 1.17.4 to 1.18.1 - 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 +- Bumps `github.com/stretchr/testify` from 1.8.1 to 1.8.4 ### Added diff --git a/go.mod b/go.mod index 5a24915..f40bd6a 100644 --- a/go.mod +++ b/go.mod @@ -6,6 +6,6 @@ require ( github.com/aws/aws-sdk-go v1.44.285 github.com/aws/aws-sdk-go-v2 v1.18.1 github.com/aws/aws-sdk-go-v2/config v1.18.25 - github.com/stretchr/testify v1.8.2 + github.com/stretchr/testify v1.8.4 golang.org/x/net v0.7.0 // indirect ) diff --git a/go.sum b/go.sum index 520a916..6b46115 100644 --- a/go.sum +++ b/go.sum @@ -42,8 +42,8 @@ github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSS github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= 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.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= From c04e36a91a64755d6205a64326a65667d51d285d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 20 Jun 2023 13:43:07 -0400 Subject: [PATCH 57/84] Bump github.com/aws/aws-sdk-go-v2/config from 1.18.25 to 1.18.27 (#334) * Bump github.com/aws/aws-sdk-go-v2/config from 1.18.25 to 1.18.27 Bumps [github.com/aws/aws-sdk-go-v2/config](https://github.com/aws/aws-sdk-go-v2) from 1.18.25 to 1.18.27. - [Release notes](https://github.com/aws/aws-sdk-go-v2/releases) - [Changelog](https://github.com/aws/aws-sdk-go-v2/blob/main/CHANGELOG.md) - [Commits](https://github.com/aws/aws-sdk-go-v2/compare/config/v1.18.25...config/v1.18.27) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go-v2/config dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Update changelog Signed-off-by: dependabot[bot] --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] --- CHANGELOG.md | 2 +- go.mod | 2 +- go.sum | 41 ++++++++++++++++++++--------------------- 3 files changed, 22 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f47a51c..50a09d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Bumps `github.com/aws/aws-sdk-go` from 1.44.180 to 1.44.285 - Bumps `github.com/aws/aws-sdk-go-v2` from 1.17.4 to 1.18.1 -- Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.8 to 1.18.25 +- Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.8 to 1.18.27 - Bumps `github.com/stretchr/testify` from 1.8.1 to 1.8.4 ### Added diff --git a/go.mod b/go.mod index f40bd6a..e7b964d 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.15 require ( github.com/aws/aws-sdk-go v1.44.285 github.com/aws/aws-sdk-go-v2 v1.18.1 - github.com/aws/aws-sdk-go-v2/config v1.18.25 + github.com/aws/aws-sdk-go-v2/config v1.18.27 github.com/stretchr/testify v1.8.4 golang.org/x/net v0.7.0 // indirect ) diff --git a/go.sum b/go.sum index 6b46115..8c4501f 100644 --- a/go.sum +++ b/go.sum @@ -1,28 +1,27 @@ github.com/aws/aws-sdk-go v1.44.285 h1:rgoWYl+NdmKzRgoi/fZLEtGXOjCkcWIa5jPH02Uahdo= github.com/aws/aws-sdk-go v1.44.285/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 v1.18.1 h1:+tefE750oAb7ZQGzla6bLkOwfcQCEtC5y2RqoqCeqKo= github.com/aws/aws-sdk-go-v2 v1.18.1/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= -github.com/aws/aws-sdk-go-v2/config v1.18.25 h1:JuYyZcnMPBiFqn87L2cRppo+rNwgah6YwD3VuyvaW6Q= -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 h1:PjiYyls3QdCrzqUN35jMWtUK1vqVZ+zLfdOa/UPFDp0= -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 h1:jJPgroehGvjrde3XufFIJUZVK5A2L9a3KwSFgKy9n8w= -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 h1:kG5eQilShqmJbv11XL1VpyDbaEJzWxd4zRiCG30GSn4= -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 h1:vFQlirhuM8lLlpI7imKOMsjdQLuN9CPi+k44F/OFVsk= -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 h1:gGLG7yKaXG02/jBlg210R7VgQIotiQntNhsCFejawx8= -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 h1:0iKliEXAcCa2qVtRs7Ot5hItA2MsufrphbRFlz1Owxo= -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 h1:UBQjaMTCKwyUYwiVnUt6toEJwGXsLBI6al083tpjJzY= -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 h1:PkHIIJs8qvq0e5QybnZoG1K/9QTrLr9OsqCIo59jOBA= -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 h1:2DQLAKDteoEDI8zpCzqBMaZlJuoE9iTYD0gFmXVax9E= -github.com/aws/aws-sdk-go-v2/service/sts v1.19.0/go.mod h1:BgQOMsg8av8jset59jelyPW7NoZcZXLVpDsXunGDrk8= +github.com/aws/aws-sdk-go-v2/config v1.18.27 h1:Az9uLwmssTE6OGTpsFqOnaGpLnKDqNYOJzWuC6UAYzA= +github.com/aws/aws-sdk-go-v2/config v1.18.27/go.mod h1:0My+YgmkGxeqjXZb5BYme5pc4drjTnM+x1GJ3zv42Nw= +github.com/aws/aws-sdk-go-v2/credentials v1.13.26 h1:qmU+yhKmOCyujmuPY7tf5MxR/RKyZrOPO3V4DobiTUk= +github.com/aws/aws-sdk-go-v2/credentials v1.13.26/go.mod h1:GoXt2YC8jHUBbA4jr+W3JiemnIbkXOfxSXcisUsZ3os= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.4 h1:LxK/bitrAr4lnh9LnIS6i7zWbCOdMsfzKFBI6LUCS0I= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.4/go.mod h1:E1hLXN/BL2e6YizK1zFlYd8vsfi2GTjbjBazinMmeaM= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.34 h1:A5UqQEmPaCFpedKouS4v+dHCTUo2sKqhoKO9U5kxyWo= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.34/go.mod h1:wZpTEecJe0Btj3IYnDx/VlUzor9wm3fJHyvLpQF0VwY= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.28 h1:srIVS45eQuewqz6fKKu6ZGXaq6FuFg5NzgQBAM6g8Y4= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.28/go.mod h1:7VRpKQQedkfIEXb4k52I7swUnZP0wohVajJMRn3vsUw= +github.com/aws/aws-sdk-go-v2/internal/ini v1.3.35 h1:LWA+3kDM8ly001vJ1X1waCuLJdtTl48gwkPKWy9sosI= +github.com/aws/aws-sdk-go-v2/internal/ini v1.3.35/go.mod h1:0Eg1YjxE0Bhn56lx+SHJwCzhW+2JGtizsrx+lCqrfm0= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.28 h1:bkRyG4a929RCnpVSTvLM2j/T4ls015ZhhYApbmYs15s= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.28/go.mod h1:jj7znCIg05jXlaGBlFMGP8+7UN3VtCkRBG2spnmRQkU= +github.com/aws/aws-sdk-go-v2/service/sso v1.12.12 h1:nneMBM2p79PGWBQovYO/6Xnc2ryRMw3InnDJq1FHkSY= +github.com/aws/aws-sdk-go-v2/service/sso v1.12.12/go.mod h1:HuCOxYsF21eKrerARYO6HapNeh9GBNq7fius2AcwodY= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.12 h1:2qTR7IFk7/0IN/adSFhYu9Xthr0zVFTgBrmPldILn80= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.12/go.mod h1:E4VrHCPzmVB/KFXtqBGKb3c8zpbNBgKe3fisDNLAW5w= +github.com/aws/aws-sdk-go-v2/service/sts v1.19.2 h1:XFJ2Z6sNUUcAz9poj+245DMkrHE4h2j5I9/xD50RHfE= +github.com/aws/aws-sdk-go-v2/service/sts v1.19.2/go.mod h1:dp0yLPsLBOi++WTxzCjA/oZqi6NPIhoR+uF7GeMU9eg= github.com/aws/smithy-go v1.13.5 h1:hgz0X/DX0dGqTYpGALqXJoRKRj5oQ7150i5FdTePzO8= github.com/aws/smithy-go v1.13.5/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= From 2218d5b2cab8d71066f0049b59eec81cdac2808a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 27 Jun 2023 12:20:26 -0700 Subject: [PATCH 58/84] Bump github.com/aws/aws-sdk-go from 1.44.285 to 1.44.290 (#340) * Bump github.com/aws/aws-sdk-go from 1.44.285 to 1.44.290 Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.44.285 to 1.44.290. - [Release notes](https://github.com/aws/aws-sdk-go/releases) - [Commits](https://github.com/aws/aws-sdk-go/compare/v1.44.285...v1.44.290) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Update changelog Signed-off-by: dependabot[bot] --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] --- CHANGELOG.md | 2 +- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 50a09d3..0478027 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Dependencies -- Bumps `github.com/aws/aws-sdk-go` from 1.44.180 to 1.44.285 +- Bumps `github.com/aws/aws-sdk-go` from 1.44.180 to 1.44.290 - Bumps `github.com/aws/aws-sdk-go-v2` from 1.17.4 to 1.18.1 - Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.8 to 1.18.27 - Bumps `github.com/stretchr/testify` from 1.8.1 to 1.8.4 diff --git a/go.mod b/go.mod index e7b964d..03cfebd 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/opensearch-project/opensearch-go/v2 go 1.15 require ( - github.com/aws/aws-sdk-go v1.44.285 + github.com/aws/aws-sdk-go v1.44.290 github.com/aws/aws-sdk-go-v2 v1.18.1 github.com/aws/aws-sdk-go-v2/config v1.18.27 github.com/stretchr/testify v1.8.4 diff --git a/go.sum b/go.sum index 8c4501f..c0df4ce 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/aws/aws-sdk-go v1.44.285 h1:rgoWYl+NdmKzRgoi/fZLEtGXOjCkcWIa5jPH02Uahdo= -github.com/aws/aws-sdk-go v1.44.285/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= +github.com/aws/aws-sdk-go v1.44.290 h1:Md4+os9DQtJjow0lWLMzeJljsimD+XS2xwwHDr5Z+Lk= +github.com/aws/aws-sdk-go v1.44.290/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go-v2 v1.18.1 h1:+tefE750oAb7ZQGzla6bLkOwfcQCEtC5y2RqoqCeqKo= github.com/aws/aws-sdk-go-v2 v1.18.1/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= github.com/aws/aws-sdk-go-v2/config v1.18.27 h1:Az9uLwmssTE6OGTpsFqOnaGpLnKDqNYOJzWuC6UAYzA= From a19eff59e036c1e15b5eb0ad1ceec2e45aff9a2b Mon Sep 17 00:00:00 2001 From: aboy Date: Sat, 1 Jul 2023 02:22:57 +0900 Subject: [PATCH 59/84] Add an introduction to utility function NewJSONReader in USER_GUIDE (#341) * Added an introduction to utility functions. That can omit the conversion from structure to io.Reader, a common use case. Signed-off-by: YuyaAbo * Inserted the appropriate tab. Signed-off-by: YuyaAbo --------- Signed-off-by: YuyaAbo --- USER_GUIDE.md | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/USER_GUIDE.md b/USER_GUIDE.md index 360e57b..0e63bc3 100644 --- a/USER_GUIDE.md +++ b/USER_GUIDE.md @@ -25,6 +25,7 @@ import ( opensearch "github.com/opensearch-project/opensearch-go/v2" opensearchapi "github.com/opensearch-project/opensearch-go/v2/opensearchapi" + opensearchutil "github.com/opensearch-project/opensearch-go/v2/opensearchutil" ) const IndexName = "go-test-index1" @@ -83,18 +84,22 @@ func example() error { } fmt.Println(createIndexResponse) - // Add a document to the index. - document := strings.NewReader(`{ - "title": "Moneyball", - "director": "Bennett Miller", - "year": "2011" - }`) + // When using a structure, the conversion process to io.Reader can be omitted using utility functions. + document := struct { + Title string `json:"title"` + Director string `json:"director"` + Year string `json:"year"` + }{ + Title: "Moneyball", + Director: "Bennett Miller", + Year: "2011", + } docId := "1" req := opensearchapi.IndexRequest{ Index: IndexName, DocumentID: docId, - Body: document, + Body: opensearchutil.NewJSONReader(&document), } insertResponse, err := req.Do(ctx, client) if err != nil { @@ -333,4 +338,4 @@ func getCredentialProvider(accessKey, secretAccessKey, token string) aws.Credent - [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 +- [Data Streams](guides/data_streams.md) From 09e6b93959708be123a14e44e99d89e0a45d87f7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 5 Jul 2023 12:42:19 -0400 Subject: [PATCH 60/84] Bump github.com/aws/aws-sdk-go from 1.44.290 to 1.44.295 (#342) * Bump github.com/aws/aws-sdk-go from 1.44.290 to 1.44.295 Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.44.290 to 1.44.295. - [Release notes](https://github.com/aws/aws-sdk-go/releases) - [Commits](https://github.com/aws/aws-sdk-go/compare/v1.44.290...v1.44.295) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Update changelog Signed-off-by: dependabot[bot] --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] --- CHANGELOG.md | 2 +- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0478027..a5a0089 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Dependencies -- Bumps `github.com/aws/aws-sdk-go` from 1.44.180 to 1.44.290 +- Bumps `github.com/aws/aws-sdk-go` from 1.44.180 to 1.44.295 - Bumps `github.com/aws/aws-sdk-go-v2` from 1.17.4 to 1.18.1 - Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.8 to 1.18.27 - Bumps `github.com/stretchr/testify` from 1.8.1 to 1.8.4 diff --git a/go.mod b/go.mod index 03cfebd..8918fd5 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/opensearch-project/opensearch-go/v2 go 1.15 require ( - github.com/aws/aws-sdk-go v1.44.290 + github.com/aws/aws-sdk-go v1.44.295 github.com/aws/aws-sdk-go-v2 v1.18.1 github.com/aws/aws-sdk-go-v2/config v1.18.27 github.com/stretchr/testify v1.8.4 diff --git a/go.sum b/go.sum index c0df4ce..744ca60 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/aws/aws-sdk-go v1.44.290 h1:Md4+os9DQtJjow0lWLMzeJljsimD+XS2xwwHDr5Z+Lk= -github.com/aws/aws-sdk-go v1.44.290/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= +github.com/aws/aws-sdk-go v1.44.295 h1:SGjU1+MqttXfRiWHD6WU0DRhaanJgAFY+xIhEaugV8Y= +github.com/aws/aws-sdk-go v1.44.295/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go-v2 v1.18.1 h1:+tefE750oAb7ZQGzla6bLkOwfcQCEtC5y2RqoqCeqKo= github.com/aws/aws-sdk-go-v2 v1.18.1/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= github.com/aws/aws-sdk-go-v2/config v1.18.27 h1:Az9uLwmssTE6OGTpsFqOnaGpLnKDqNYOJzWuC6UAYzA= From 3aa067cfa319593953b1a9962f07da2c71edbe6d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 11 Jul 2023 11:02:17 -0700 Subject: [PATCH 61/84] Bump github.com/aws/aws-sdk-go from 1.44.295 to 1.44.298 (#343) * Bump github.com/aws/aws-sdk-go from 1.44.295 to 1.44.298 Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.44.295 to 1.44.298. - [Release notes](https://github.com/aws/aws-sdk-go/releases) - [Commits](https://github.com/aws/aws-sdk-go/compare/v1.44.295...v1.44.298) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Update changelog Signed-off-by: dependabot[bot] --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] --- CHANGELOG.md | 2 +- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a5a0089..7b15348 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Dependencies -- Bumps `github.com/aws/aws-sdk-go` from 1.44.180 to 1.44.295 +- Bumps `github.com/aws/aws-sdk-go` from 1.44.180 to 1.44.298 - Bumps `github.com/aws/aws-sdk-go-v2` from 1.17.4 to 1.18.1 - Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.8 to 1.18.27 - Bumps `github.com/stretchr/testify` from 1.8.1 to 1.8.4 diff --git a/go.mod b/go.mod index 8918fd5..6a08aa5 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/opensearch-project/opensearch-go/v2 go 1.15 require ( - github.com/aws/aws-sdk-go v1.44.295 + github.com/aws/aws-sdk-go v1.44.298 github.com/aws/aws-sdk-go-v2 v1.18.1 github.com/aws/aws-sdk-go-v2/config v1.18.27 github.com/stretchr/testify v1.8.4 diff --git a/go.sum b/go.sum index 744ca60..545421e 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/aws/aws-sdk-go v1.44.295 h1:SGjU1+MqttXfRiWHD6WU0DRhaanJgAFY+xIhEaugV8Y= -github.com/aws/aws-sdk-go v1.44.295/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= +github.com/aws/aws-sdk-go v1.44.298 h1:5qTxdubgV7PptZJmp/2qDwD2JL187ePL7VOxsSh1i3g= +github.com/aws/aws-sdk-go v1.44.298/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go-v2 v1.18.1 h1:+tefE750oAb7ZQGzla6bLkOwfcQCEtC5y2RqoqCeqKo= github.com/aws/aws-sdk-go-v2 v1.18.1/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= github.com/aws/aws-sdk-go-v2/config v1.18.27 h1:Az9uLwmssTE6OGTpsFqOnaGpLnKDqNYOJzWuC6UAYzA= From 2c86e1baa292c2045d35d761af5d71f3791774ec Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 18 Jul 2023 17:17:12 -0400 Subject: [PATCH 62/84] Bump github.com/aws/aws-sdk-go-v2/config from 1.18.27 to 1.18.28 (#344) * Bump github.com/aws/aws-sdk-go-v2/config from 1.18.27 to 1.18.28 Bumps [github.com/aws/aws-sdk-go-v2/config](https://github.com/aws/aws-sdk-go-v2) from 1.18.27 to 1.18.28. - [Release notes](https://github.com/aws/aws-sdk-go-v2/releases) - [Changelog](https://github.com/aws/aws-sdk-go-v2/blob/main/CHANGELOG.md) - [Commits](https://github.com/aws/aws-sdk-go-v2/compare/config/v1.18.27...config/v1.18.28) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go-v2/config dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Update changelog Signed-off-by: dependabot[bot] --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] --- CHANGELOG.md | 2 +- go.mod | 4 ++-- go.sum | 44 ++++++++++++++++++++++---------------------- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b15348..c574d2e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Bumps `github.com/aws/aws-sdk-go` from 1.44.180 to 1.44.298 - Bumps `github.com/aws/aws-sdk-go-v2` from 1.17.4 to 1.18.1 -- Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.8 to 1.18.27 +- Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.8 to 1.18.28 - Bumps `github.com/stretchr/testify` from 1.8.1 to 1.8.4 ### Added diff --git a/go.mod b/go.mod index 6a08aa5..8fdf09c 100644 --- a/go.mod +++ b/go.mod @@ -4,8 +4,8 @@ go 1.15 require ( github.com/aws/aws-sdk-go v1.44.298 - github.com/aws/aws-sdk-go-v2 v1.18.1 - github.com/aws/aws-sdk-go-v2/config v1.18.27 + github.com/aws/aws-sdk-go-v2 v1.19.0 + github.com/aws/aws-sdk-go-v2/config v1.18.28 github.com/stretchr/testify v1.8.4 golang.org/x/net v0.7.0 // indirect ) diff --git a/go.sum b/go.sum index 545421e..cc74045 100644 --- a/go.sum +++ b/go.sum @@ -1,27 +1,27 @@ github.com/aws/aws-sdk-go v1.44.298 h1:5qTxdubgV7PptZJmp/2qDwD2JL187ePL7VOxsSh1i3g= github.com/aws/aws-sdk-go v1.44.298/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= -github.com/aws/aws-sdk-go-v2 v1.18.1 h1:+tefE750oAb7ZQGzla6bLkOwfcQCEtC5y2RqoqCeqKo= -github.com/aws/aws-sdk-go-v2 v1.18.1/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= -github.com/aws/aws-sdk-go-v2/config v1.18.27 h1:Az9uLwmssTE6OGTpsFqOnaGpLnKDqNYOJzWuC6UAYzA= -github.com/aws/aws-sdk-go-v2/config v1.18.27/go.mod h1:0My+YgmkGxeqjXZb5BYme5pc4drjTnM+x1GJ3zv42Nw= -github.com/aws/aws-sdk-go-v2/credentials v1.13.26 h1:qmU+yhKmOCyujmuPY7tf5MxR/RKyZrOPO3V4DobiTUk= -github.com/aws/aws-sdk-go-v2/credentials v1.13.26/go.mod h1:GoXt2YC8jHUBbA4jr+W3JiemnIbkXOfxSXcisUsZ3os= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.4 h1:LxK/bitrAr4lnh9LnIS6i7zWbCOdMsfzKFBI6LUCS0I= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.4/go.mod h1:E1hLXN/BL2e6YizK1zFlYd8vsfi2GTjbjBazinMmeaM= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.34 h1:A5UqQEmPaCFpedKouS4v+dHCTUo2sKqhoKO9U5kxyWo= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.34/go.mod h1:wZpTEecJe0Btj3IYnDx/VlUzor9wm3fJHyvLpQF0VwY= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.28 h1:srIVS45eQuewqz6fKKu6ZGXaq6FuFg5NzgQBAM6g8Y4= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.28/go.mod h1:7VRpKQQedkfIEXb4k52I7swUnZP0wohVajJMRn3vsUw= -github.com/aws/aws-sdk-go-v2/internal/ini v1.3.35 h1:LWA+3kDM8ly001vJ1X1waCuLJdtTl48gwkPKWy9sosI= -github.com/aws/aws-sdk-go-v2/internal/ini v1.3.35/go.mod h1:0Eg1YjxE0Bhn56lx+SHJwCzhW+2JGtizsrx+lCqrfm0= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.28 h1:bkRyG4a929RCnpVSTvLM2j/T4ls015ZhhYApbmYs15s= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.28/go.mod h1:jj7znCIg05jXlaGBlFMGP8+7UN3VtCkRBG2spnmRQkU= -github.com/aws/aws-sdk-go-v2/service/sso v1.12.12 h1:nneMBM2p79PGWBQovYO/6Xnc2ryRMw3InnDJq1FHkSY= -github.com/aws/aws-sdk-go-v2/service/sso v1.12.12/go.mod h1:HuCOxYsF21eKrerARYO6HapNeh9GBNq7fius2AcwodY= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.12 h1:2qTR7IFk7/0IN/adSFhYu9Xthr0zVFTgBrmPldILn80= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.12/go.mod h1:E4VrHCPzmVB/KFXtqBGKb3c8zpbNBgKe3fisDNLAW5w= -github.com/aws/aws-sdk-go-v2/service/sts v1.19.2 h1:XFJ2Z6sNUUcAz9poj+245DMkrHE4h2j5I9/xD50RHfE= -github.com/aws/aws-sdk-go-v2/service/sts v1.19.2/go.mod h1:dp0yLPsLBOi++WTxzCjA/oZqi6NPIhoR+uF7GeMU9eg= +github.com/aws/aws-sdk-go-v2 v1.19.0 h1:klAT+y3pGFBU/qVf1uzwttpBbiuozJYWzNLHioyDJ+k= +github.com/aws/aws-sdk-go-v2 v1.19.0/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= +github.com/aws/aws-sdk-go-v2/config v1.18.28 h1:TINEaKyh1Td64tqFvn09iYpKiWjmHYrG1fa91q2gnqw= +github.com/aws/aws-sdk-go-v2/config v1.18.28/go.mod h1:nIL+4/8JdAuNHEjn/gPEXqtnS02Q3NXB/9Z7o5xE4+A= +github.com/aws/aws-sdk-go-v2/credentials v1.13.27 h1:dz0yr/yR1jweAnsCx+BmjerUILVPQ6FS5AwF/OyG1kA= +github.com/aws/aws-sdk-go-v2/credentials v1.13.27/go.mod h1:syOqAek45ZXZp29HlnRS/BNgMIW6uiRmeuQsz4Qh2UE= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.5 h1:kP3Me6Fy3vdi+9uHd7YLr6ewPxRL+PU6y15urfTaamU= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.5/go.mod h1:Gj7tm95r+QsDoN2Fhuz/3npQvcZbkEf5mL70n3Xfluc= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.35 h1:hMUCiE3Zi5AHrRNGf5j985u0WyqI6r2NULhUfo0N/No= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.35/go.mod h1:ipR5PvpSPqIqL5Mi82BxLnfMkHVbmco8kUwO2xrCi0M= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.29 h1:yOpYx+FTBdpk/g+sBU6Cb1H0U/TLEcYYp66mYqsPpcc= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.29/go.mod h1:M/eUABlDbw2uVrdAn+UsI6M727qp2fxkp8K0ejcBDUY= +github.com/aws/aws-sdk-go-v2/internal/ini v1.3.36 h1:8r5m1BoAWkn0TDC34lUculryf7nUF25EgIMdjvGCkgo= +github.com/aws/aws-sdk-go-v2/internal/ini v1.3.36/go.mod h1:Rmw2M1hMVTwiUhjwMoIBFWFJMhvJbct06sSidxInkhY= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.29 h1:IiDolu/eLmuB18DRZibj77n1hHQT7z12jnGO7Ze3pLc= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.29/go.mod h1:fDbkK4o7fpPXWn8YAPmTieAMuB9mk/VgvW64uaUqxd4= +github.com/aws/aws-sdk-go-v2/service/sso v1.12.13 h1:sWDv7cMITPcZ21QdreULwxOOAmE05JjEsT6fCDtDA9k= +github.com/aws/aws-sdk-go-v2/service/sso v1.12.13/go.mod h1:DfX0sWuT46KpcqbMhJ9QWtxAIP1VozkDWf8VAkByjYY= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.13 h1:BFubHS/xN5bjl818QaroN6mQdjneYQ+AOx44KNXlyH4= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.13/go.mod h1:BzqsVVFduubEmzrVtUFQQIQdFqvUItF8XUq2EnS8Wog= +github.com/aws/aws-sdk-go-v2/service/sts v1.19.3 h1:e5mnydVdCVWxP+5rPAGi2PYxC7u2OZgH1ypC114H04U= +github.com/aws/aws-sdk-go-v2/service/sts v1.19.3/go.mod h1:yVGZA1CPkmUhBdA039jXNJJG7/6t+G+EBWmFq23xqnY= github.com/aws/smithy-go v1.13.5 h1:hgz0X/DX0dGqTYpGALqXJoRKRj5oQ7150i5FdTePzO8= github.com/aws/smithy-go v1.13.5/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= From 112d7611ab7069b15759e3761ab20c8e222d967c Mon Sep 17 00:00:00 2001 From: Jakob Date: Wed, 19 Jul 2023 15:16:58 +0200 Subject: [PATCH 63/84] Add opensearch 2.6.0, 2.7.0, 2.8.0 to compatibility test (#348) Signed-off-by: Jakob Hahn --- .github/workflows/test-compatibility.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test-compatibility.yml b/.github/workflows/test-compatibility.yml index a09b9c8..041e5da 100644 --- a/.github/workflows/test-compatibility.yml +++ b/.github/workflows/test-compatibility.yml @@ -19,6 +19,9 @@ jobs: - { opensearch_version: 2.3.0 } - { opensearch_version: 2.4.1 } - { opensearch_version: 2.5.0 } + - { opensearch_version: 2.6.0 } + - { opensearch_version: 2.7.0 } + - { opensearch_version: 2.8.0 } steps: - uses: actions/checkout@v3 with: { fetch-depth: 1 } From 8b49172843b3d7aea85cf395d663d24ae1191438 Mon Sep 17 00:00:00 2001 From: Jakob Date: Wed, 19 Jul 2023 16:44:10 +0200 Subject: [PATCH 64/84] opensearchapi: Change tests to check if got headers contains the wanted header (#349) Signed-off-by: Jakob Hahn --- opensearchapi/api.document_test.go | 7 +++++-- opensearchapi/api.indices.datastream_test.go | 5 ++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/opensearchapi/api.document_test.go b/opensearchapi/api.document_test.go index ec0bf1b..1250b5a 100644 --- a/opensearchapi/api.document_test.go +++ b/opensearchapi/api.document_test.go @@ -326,10 +326,13 @@ func TestDocumentRequest_Do(t *testing.T) { return } - require.Equalf(t, got.StatusCode, tt.want.StatusCode, "Do() got = %v, want %v", got.StatusCode, tt.want.StatusCode) + require.Equalf(t, tt.want.StatusCode, got.StatusCode, "Do() got = %v, want %v", got.StatusCode, tt.want.StatusCode) if tt.wantBody != "" { - require.Equalf(t, got.Header, tt.want.Header, "Do() got = %v, want %v", got.Header, tt.want.Header) + for name, value := range tt.want.Header { + require.Contains(t, got.Header, name) + require.Equal(t, value, got.Header[name]) + } defer got.Body.Close() body, err := ioutil.ReadAll(got.Body) diff --git a/opensearchapi/api.indices.datastream_test.go b/opensearchapi/api.indices.datastream_test.go index 2fe9fc8..39f98e3 100644 --- a/opensearchapi/api.indices.datastream_test.go +++ b/opensearchapi/api.indices.datastream_test.go @@ -168,7 +168,10 @@ func TestIndicesDataStreams_Do(t *testing.T) { require.Equalf(t, got.StatusCode, tt.want.StatusCode, "Do() got = %v, want %v", got.StatusCode, tt.want.StatusCode) if tt.wantBody != "" { - require.Equalf(t, got.Header, tt.want.Header, "Do() got = %v, want %v", got.Header, tt.want.Header) + for name, value := range tt.want.Header { + require.Contains(t, got.Header, name) + require.Equal(t, value, got.Header[name]) + } defer got.Body.Close() body, err := ioutil.ReadAll(got.Body) From 8758e4ef5a595e6997c32164f47a3d0d87882fba Mon Sep 17 00:00:00 2001 From: Dewald Viljoen Date: Mon, 24 Jul 2023 17:23:42 +0100 Subject: [PATCH 65/84] Data stream stats: Add name only if present (#338) * [BUG] Data stream stats: Add name only if present Signed-off-by: DewaldV * [BUG] Data Stream stats: Add unit test case We want to test the path of the URI specifically to ensure that we're constructing it correctly. Signed-off-by: DewaldV * [BUG] Data Stream stats: Add integration test case We test for multiple data stream stats on the /_stats endpoint. This needs another datastream added/removed to ensure we test it sufficiently. Signed-off-by: DewaldV * [BUG] Data Stream stats: Add license header Signed-off-by: DewaldV * [BUG] Data stream stats: Use jsonassert for tests Signed-off-by: DewaldV --------- Signed-off-by: DewaldV --- CHANGELOG.md | 3 +- go.mod | 1 + go.sum | 2 + opensearchapi/api.indices.datastream_test.go | 91 +++++++++++++++---- .../api.indices.get_datastream_stats.go | 7 +- .../api.indices.get_datastream_stats_test.go | 58 ++++++++++++ 6 files changed, 142 insertions(+), 20 deletions(-) create mode 100644 opensearchapi/api.indices.get_datastream_stats_test.go diff --git a/CHANGELOG.md b/CHANGELOG.md index c574d2e..13588e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -51,7 +51,8 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - 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)) +- Corrects AWSv4 signature on DataStream Stats with no index name specified ([#338](https://github.com/opensearch-project/opensearch-go/pull/338)) ### Security -[Unreleased]: https://github.com/opensearch-project/opensearch-go/compare/v2.2.0...HEAD \ No newline at end of file +[Unreleased]: https://github.com/opensearch-project/opensearch-go/compare/v2.2.0...HEAD diff --git a/go.mod b/go.mod index 8fdf09c..a6084d4 100644 --- a/go.mod +++ b/go.mod @@ -6,6 +6,7 @@ require ( github.com/aws/aws-sdk-go v1.44.298 github.com/aws/aws-sdk-go-v2 v1.19.0 github.com/aws/aws-sdk-go-v2/config v1.18.28 + github.com/kinbiko/jsonassert v1.1.1 github.com/stretchr/testify v1.8.4 golang.org/x/net v0.7.0 // indirect ) diff --git a/go.sum b/go.sum index cc74045..d70cdd2 100644 --- a/go.sum +++ b/go.sum @@ -33,6 +33,8 @@ github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9Y github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= +github.com/kinbiko/jsonassert v1.1.1 h1:DB12divY+YB+cVpHULLuKePSi6+ui4M/shHSzJISkSE= +github.com/kinbiko/jsonassert v1.1.1/go.mod h1:NO4lzrogohtIdNUNzx8sdzB55M4R4Q1bsrWVdqQ7C+A= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= diff --git a/opensearchapi/api.indices.datastream_test.go b/opensearchapi/api.indices.datastream_test.go index 39f98e3..a6aeb12 100644 --- a/opensearchapi/api.indices.datastream_test.go +++ b/opensearchapi/api.indices.datastream_test.go @@ -13,18 +13,18 @@ package opensearchapi_test import ( - "bytes" "context" - "encoding/json" "fmt" - "github.com/opensearch-project/opensearch-go/v2" - "github.com/opensearch-project/opensearch-go/v2/opensearchapi" - "github.com/stretchr/testify/require" "io/ioutil" "net/http" "strings" "testing" "time" + + "github.com/kinbiko/jsonassert" + "github.com/opensearch-project/opensearch-go/v2" + "github.com/opensearch-project/opensearch-go/v2/opensearchapi" + "github.com/stretchr/testify/require" ) type DataStreamRequest interface { @@ -32,7 +32,9 @@ type DataStreamRequest interface { } func TestIndicesDataStreams_Do(t *testing.T) { - name := fmt.Sprintf("demo-%s", time.Now().Format("2006-01-02-15-04-05")) + // We need two datastreams to ensure endpoints that fetch both are tested appropriately + dataStream1 := fmt.Sprintf("demo-1-%s", time.Now().Format("2006-01-02-15-04-05")) + dataStream2 := fmt.Sprintf("demo-2-%s", time.Now().Format("2006-01-02-15-04-05")) tests := []struct { name string @@ -44,7 +46,27 @@ func TestIndicesDataStreams_Do(t *testing.T) { { name: "TestIndicesCreateDataStreamRequest_Do", r: opensearchapi.IndicesCreateDataStreamRequest{ - Name: name, + Name: dataStream1, + Pretty: true, + Human: true, + ErrorTrace: true, + Header: map[string][]string{ + "Content-Type": {"application/json"}, + }, + }, + want: &opensearchapi.Response{ + StatusCode: 200, + Header: http.Header{ + "Content-Type": []string{"application/json; charset=UTF-8"}, + }, + }, + wantBody: `{"acknowledged":true}`, + wantErr: false, + }, + { + name: "TestIndicesCreateDataStream2Request_Do", + r: opensearchapi.IndicesCreateDataStreamRequest{ + Name: dataStream2, Pretty: true, Human: true, ErrorTrace: true, @@ -64,7 +86,7 @@ func TestIndicesDataStreams_Do(t *testing.T) { { name: "TestIndicesGetDataStreamRequest_Do", r: opensearchapi.IndicesGetDataStreamRequest{ - Name: name, + Name: dataStream1, Pretty: true, Human: true, ErrorTrace: true, @@ -101,7 +123,26 @@ func TestIndicesDataStreams_Do(t *testing.T) { { name: "TestIndicesGetStatsDataStreamRequest_Do", r: opensearchapi.IndicesGetDataStreamStatsRequest{ - Name: name, + Name: dataStream1, + Pretty: true, + Human: true, + ErrorTrace: true, + Header: map[string][]string{ + "Content-Type": {"application/json"}, + }, + }, + want: &opensearchapi.Response{ + StatusCode: 200, + Header: http.Header{ + "Content-Type": []string{"application/json; charset=UTF-8"}, + }, + }, + wantBody: fmt.Sprintf(`{"_shards":{"total":2,"successful":1,"failed":0},"data_stream_count":1,"backing_indices":1,"total_store_size":"208b","total_store_size_bytes":208,"data_streams":[{"data_stream":"%s","backing_indices":1,"store_size":"208b","store_size_bytes":208,"maximum_timestamp":0}]}`, dataStream1), + wantErr: false, + }, + { + name: "TestIndicesGetAllStatsDataStreamRequest_Do", + r: opensearchapi.IndicesGetDataStreamStatsRequest{ Pretty: true, Human: true, ErrorTrace: true, @@ -115,13 +156,33 @@ func TestIndicesDataStreams_Do(t *testing.T) { "Content-Type": []string{"application/json; charset=UTF-8"}, }, }, - wantBody: fmt.Sprintf(`{"_shards":{"total":2,"successful":1,"failed":0},"data_stream_count":1,"backing_indices":1,"total_store_size":"208b","total_store_size_bytes":208,"data_streams":[{"data_stream":"%s","backing_indices":1,"store_size":"208b","store_size_bytes":208,"maximum_timestamp":0}]}`, name), + wantBody: fmt.Sprintf(`{"_shards":{"total":4,"successful":2,"failed":0},"data_stream_count":2,"backing_indices":2,"total_store_size":"416b","total_store_size_bytes":416,"data_streams":["<>",{"data_stream":"%s","backing_indices":1,"store_size":"208b","store_size_bytes":208,"maximum_timestamp":0},{"data_stream":"%s","backing_indices":1,"store_size":"208b","store_size_bytes":208,"maximum_timestamp":0}]}`, dataStream2, dataStream1), wantErr: false, }, { name: "TestIndicesDeleteDataStreamRequest_Do", r: opensearchapi.IndicesDeleteDataStreamRequest{ - Name: name, + Name: dataStream1, + Pretty: true, + Human: true, + ErrorTrace: true, + Header: map[string][]string{ + "Content-Type": {"application/json"}, + }, + }, + want: &opensearchapi.Response{ + StatusCode: 200, + Header: http.Header{ + "Content-Type": []string{"application/json; charset=UTF-8"}, + }, + }, + wantBody: `{"acknowledged":true}`, + wantErr: false, + }, + { + name: "TestIndicesDeleteDataStream2Request_Do", + r: opensearchapi.IndicesDeleteDataStreamRequest{ + Name: dataStream2, Pretty: true, Human: true, ErrorTrace: true, @@ -177,12 +238,8 @@ func TestIndicesDataStreams_Do(t *testing.T) { body, err := ioutil.ReadAll(got.Body) require.NoError(t, err) - buffer := new(bytes.Buffer) - if err := json.Compact(buffer, body); err != nil { - fmt.Println(err) - } - - require.Equalf(t, buffer.String(), tt.wantBody, "Do() got = %v, want %v", got.String(), tt.wantBody) + ja := jsonassert.New(t) + ja.Assertf(string(body), tt.wantBody) } }) } diff --git a/opensearchapi/api.indices.get_datastream_stats.go b/opensearchapi/api.indices.get_datastream_stats.go index 4bc2e93..fe7dc31 100644 --- a/opensearchapi/api.indices.get_datastream_stats.go +++ b/opensearchapi/api.indices.get_datastream_stats.go @@ -58,8 +58,11 @@ func (r IndicesGetDataStreamStatsRequest) Do(ctx context.Context, transport Tran 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("/_data_stream") + if r.Name != "" { + path.WriteString("/") + path.WriteString(r.Name) + } path.WriteString("/_stats") params = make(map[string]string) diff --git a/opensearchapi/api.indices.get_datastream_stats_test.go b/opensearchapi/api.indices.get_datastream_stats_test.go new file mode 100644 index 0000000..1285c6c --- /dev/null +++ b/opensearchapi/api.indices.get_datastream_stats_test.go @@ -0,0 +1,58 @@ +// 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" + "fmt" + "net/http" + "testing" + + "github.com/stretchr/testify/require" +) + +type stubTransport struct { + req *http.Request +} + +func (t *stubTransport) Perform(req *http.Request) (*http.Response, error) { + t.req = req + return &http.Response{}, nil +} + +func TestIndicesGetDataStreamStatsRequest(t *testing.T) { + tt := stubTransport{} + req := IndicesGetDataStreamStatsRequest{} + + expectedPath := "/_data_stream/_stats" + + _, err := req.Do(context.Background(), &tt) + if err != nil { + t.Fatalf("Error getting response: %s", err) + } + + require.Equal(t, expectedPath, tt.req.URL.Path) +} + +func TestIndicesGetDataStreamStatsRequestOne(t *testing.T) { + tt := stubTransport{} + req := IndicesGetDataStreamStatsRequest{ + Name: "demo-1", + } + + expectedPath := fmt.Sprintf("/_data_stream/%s/_stats", req.Name) + + _, err := req.Do(context.Background(), &tt) + if err != nil { + t.Fatalf("Error getting response: %s", err) + } + + require.Equal(t, expectedPath, tt.req.URL.Path) +} From e970b763703f75cb309f04803134acf0750228e6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Jul 2023 12:24:04 -0400 Subject: [PATCH 66/84] Bump github.com/aws/aws-sdk-go from 1.44.298 to 1.44.302 (#347) * Bump github.com/aws/aws-sdk-go from 1.44.298 to 1.44.302 Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.44.298 to 1.44.302. - [Release notes](https://github.com/aws/aws-sdk-go/releases) - [Commits](https://github.com/aws/aws-sdk-go/compare/v1.44.298...v1.44.302) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Update changelog Signed-off-by: dependabot[bot] --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] --- CHANGELOG.md | 2 +- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 13588e4..b29ec67 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Dependencies -- Bumps `github.com/aws/aws-sdk-go` from 1.44.180 to 1.44.298 +- Bumps `github.com/aws/aws-sdk-go` from 1.44.180 to 1.44.302 - Bumps `github.com/aws/aws-sdk-go-v2` from 1.17.4 to 1.18.1 - Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.8 to 1.18.28 - Bumps `github.com/stretchr/testify` from 1.8.1 to 1.8.4 diff --git a/go.mod b/go.mod index a6084d4..01275e8 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/opensearch-project/opensearch-go/v2 go 1.15 require ( - github.com/aws/aws-sdk-go v1.44.298 + github.com/aws/aws-sdk-go v1.44.302 github.com/aws/aws-sdk-go-v2 v1.19.0 github.com/aws/aws-sdk-go-v2/config v1.18.28 github.com/kinbiko/jsonassert v1.1.1 diff --git a/go.sum b/go.sum index d70cdd2..2e232a6 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/aws/aws-sdk-go v1.44.298 h1:5qTxdubgV7PptZJmp/2qDwD2JL187ePL7VOxsSh1i3g= -github.com/aws/aws-sdk-go v1.44.298/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= +github.com/aws/aws-sdk-go v1.44.302 h1:ST3ko6GrJKn3Xi+nAvxjG3uk/V1pW8KC52WLeIxqqNk= +github.com/aws/aws-sdk-go v1.44.302/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go-v2 v1.19.0 h1:klAT+y3pGFBU/qVf1uzwttpBbiuozJYWzNLHioyDJ+k= github.com/aws/aws-sdk-go-v2 v1.19.0/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= github.com/aws/aws-sdk-go-v2/config v1.18.28 h1:TINEaKyh1Td64tqFvn09iYpKiWjmHYrG1fa91q2gnqw= From 0a06c9b82f048445b02a50e2e3e9c7f1f02644a4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Jul 2023 10:24:05 -0700 Subject: [PATCH 67/84] Bump github.com/aws/aws-sdk-go from 1.44.302 to 1.44.306 (#350) * Bump github.com/aws/aws-sdk-go from 1.44.302 to 1.44.306 Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.44.302 to 1.44.306. - [Release notes](https://github.com/aws/aws-sdk-go/releases) - [Commits](https://github.com/aws/aws-sdk-go/compare/v1.44.302...v1.44.306) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Update changelog Signed-off-by: dependabot[bot] --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] --- CHANGELOG.md | 4 ++-- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b29ec67..9ecaadd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Dependencies -- Bumps `github.com/aws/aws-sdk-go` from 1.44.180 to 1.44.302 +- Bumps `github.com/aws/aws-sdk-go` from 1.44.180 to 1.44.306 - Bumps `github.com/aws/aws-sdk-go-v2` from 1.17.4 to 1.18.1 - Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.8 to 1.18.28 - Bumps `github.com/stretchr/testify` from 1.8.1 to 1.8.4 @@ -55,4 +55,4 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Security -[Unreleased]: https://github.com/opensearch-project/opensearch-go/compare/v2.2.0...HEAD +[Unreleased]: https://github.com/opensearch-project/opensearch-go/compare/v2.2.0...HEAD \ No newline at end of file diff --git a/go.mod b/go.mod index 01275e8..5a906f7 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/opensearch-project/opensearch-go/v2 go 1.15 require ( - github.com/aws/aws-sdk-go v1.44.302 + github.com/aws/aws-sdk-go v1.44.306 github.com/aws/aws-sdk-go-v2 v1.19.0 github.com/aws/aws-sdk-go-v2/config v1.18.28 github.com/kinbiko/jsonassert v1.1.1 diff --git a/go.sum b/go.sum index 2e232a6..31c03c6 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/aws/aws-sdk-go v1.44.302 h1:ST3ko6GrJKn3Xi+nAvxjG3uk/V1pW8KC52WLeIxqqNk= -github.com/aws/aws-sdk-go v1.44.302/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= +github.com/aws/aws-sdk-go v1.44.306 h1:H487V/1N09BDxeGR7oR+LloC2uUpmf4atmqJaBgQOIs= +github.com/aws/aws-sdk-go v1.44.306/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go-v2 v1.19.0 h1:klAT+y3pGFBU/qVf1uzwttpBbiuozJYWzNLHioyDJ+k= github.com/aws/aws-sdk-go-v2 v1.19.0/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= github.com/aws/aws-sdk-go-v2/config v1.18.28 h1:TINEaKyh1Td64tqFvn09iYpKiWjmHYrG1fa91q2gnqw= From 6d665aaca1cec64311259b4d44f55944b85ffc41 Mon Sep 17 00:00:00 2001 From: Jakob Date: Wed, 26 Jul 2023 18:10:40 +0200 Subject: [PATCH 68/84] golangci-lint: Bump version, solve signer complains (#352) * singer: Solver linting complains Signed-off-by: Jakob Hahn * Update golangci-lint config Signed-off-by: Jakob Hahn * github: Bump golangci-lint version Signed-off-by: Jakob Hahn * changelog: Add entry Signed-off-by: Jakob Hahn --------- Signed-off-by: Jakob Hahn --- .github/workflows/lint.yml | 2 +- .golangci.yml | 206 +++++++++++++++++++------------ CHANGELOG.md | 3 +- signer/aws/aws.go | 19 +-- signer/aws/aws_test.go | 28 ++--- signer/awsv2/sdkv2signer.go | 16 ++- signer/awsv2/sdkv2signer_test.go | 44 ++++--- signer/signer.go | 2 +- 8 files changed, 189 insertions(+), 131 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 7f79c24..04ffe52 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -23,7 +23,7 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v3 with: - version: v1.52.2 + version: v1.53.3 args: -v -c .golangci.yml only-new-issues: true diff --git a/.golangci.yml b/.golangci.yml index 1279c9a..2c90648 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,11 +1,15 @@ run: - # Timeout for analysis, e.g. 30s, 5m. - # Default: 1m - timeout: 20m + timeout: 10m modules-download-mode: readonly issues-exit-code: 0 linters-settings: + errcheck: + check-blank: true + check-type-assertions: false + errorlint: + check-generated: false + default-signifies-exhaustive: false exhaustive: default-signifies-exhaustive: false gci: @@ -14,14 +18,8 @@ linters-settings: - default - prefix(github.com/opensearch-project/opensearch-go) goconst: - min-occurrences: 5 - ignore-tests: true - godot: - scope: toplevel - exclude: - - go-sumtype:decl - - check interfaces - capital: true + min-len: 3 + min-occurrences: 3 godox: keywords: - BUG @@ -29,92 +27,138 @@ linters-settings: - HACK goimports: local-prefixes: github.com/opensearch-project/opensearch-go - gosimple: - go: "1.18" - checks: ["all"] lll: - line-length: 130 - tab-width: 4 + line-length: 140 nolintlint: - allow-unused: false allow-leading-space: false - allow-no-explanation: [] require-explanation: true require-specific: true - staticcheck: - go: "1.18" - checks: ["all"] - stylecheck: - go: "1.18" - checks: ["all"] - dot-import-whitelist: [] - initialisms: [] - http-status-code-whitelist: [] unparam: check-exported: true - unused: - go: "1.18" - whitespace: - multi-if: false - multi-func: false - tagliatelle: + misspell: + locale: US + ignore-words: expect + prealloc: + simple: true + range-loops: true + for-loops: false linters: - enable-all: true - disable: - # TODO: enable one by one - - tparallel - - gofmt - - goimports - - ineffassign - - gci - - paralleltest - - maintidx - - unparam - - goconst - - wastedassign - - gosimple - - dupl - - structcheck - - unused - - nestif - - errorlint - - lll - - gocyclo - - prealloc + disable-all: true + enable: + - asasalint + - asciicheck + - bidichk - bodyclose - - whitespace - - gofumpt - - godot - - gocritic - - gocognit - - unconvert - - errchkjson - - thelper - - ireturn - - forbidigo - containedctx - - tagliatelle - - cyclop + - contextcheck + - decorder + - dogsled + - dupl + - dupword + - durationcheck - errcheck - - exhaustivestruct - - forcetypeassert - - funlen + - errchkjson + - errname + - errorlint + - execinquery + - exhaustive + - exportloopref + - gci + - ginkgolinter + - gocheckcompilerdirectives - gochecknoglobals - gochecknoinits - - goerr113 + - goconst + - gocritic + - godox + - gofmt + - gofumpt + - goheader + - goimports - gomnd + - gomoddirectives + - gomodguard + - goprintffuncname - gosec - - varnamelen - - wrapcheck + - gosimple + - govet + - grouper + - importas + - ineffassign + - interfacebloat + - lll + - loggercheck + - makezero + - mirror + - misspell + - musttag + - nakedret + - nestif + - nilerr + - nilnil - noctx + - nolintlint + - nonamedreturns + - nosprintfhostport + - prealloc + - predeclared + - promlinter + - reassign + - revive + - rowserrcheck + - sqlclosecheck - staticcheck - stylecheck - - golint - - interfacer - - maligned - - nlreturn - - scopelint - - testpackage - - wsl - - ifshort + - tagalign + - testpackage + - thelper + - tparallel + - typecheck + - unconvert + - unparam + - unused + - usestdlibvars + - wastedassign + - whitespace + - zerologlint + +issues: + exclude-rules: + - path: _test\.go + linters: + - cyclop + - dupl + - errcheck + - gochecknoglobals + - gochecknoinits + - goconst + - gomnd + - noctx + - linters: + - gosec + text: "math/rand" + path: _test\.go + - linters: + - gosec + text: "TLS InsecureSkipVerify set true" + path: _test\.go + - linters: + - gosec + text: "G108: Profiling endpoint is automatically exposed on /debug/pprof" + path: _test\.go + - linters: + - goconst + text: "string `true` has" + path: opensearchapi\/api_ + - linters: + - errcheck + text: "Error return value of `debugLogger.Logf` is not checked" + - linters: + - errcheck + - gomnd + - gochecknoglobals + path: opensearchtransport\/logger\.go + - linters: + - nestif + path: opensearchtransport/opensearchtransport.go diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ecaadd..9aa73c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - 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)) +- Updated and adjusted golangci-lint, solve linting complains for signer ([#352](https://github.com/opensearch-project/opensearch-go/pull/352)) ### Deprecated @@ -55,4 +56,4 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Security -[Unreleased]: https://github.com/opensearch-project/opensearch-go/compare/v2.2.0...HEAD \ No newline at end of file +[Unreleased]: https://github.com/opensearch-project/opensearch-go/compare/v2.2.0...HEAD diff --git a/signer/aws/aws.go b/signer/aws/aws.go index 3df651e..a812d29 100644 --- a/signer/aws/aws.go +++ b/signer/aws/aws.go @@ -49,10 +49,12 @@ func NewSignerWithService(opts session.Options, service string) (*Signer, error) if len(strings.TrimSpace(service)) < 1 { return nil, errors.New("service cannot be empty") } + awsSession, err := session.NewSessionWithOptions(opts) if err != nil { - return nil, fmt.Errorf("failed to get session from given options %v: %v", opts, err) + return nil, fmt.Errorf("failed to get session from given options %v: %w", opts, err) } + return &Signer{ session: *awsSession, service: service, @@ -70,18 +72,22 @@ func sign(req *http.Request, region *string, serviceName string, signer *v4.Sign } var body io.ReadSeeker - var contentSha256Hash = emptyBodySHA256 + + contentSha256Hash := emptyBodySHA256 if req.Body != nil { b, err := io.ReadAll(req.Body) if err != nil { - return fmt.Errorf("failed to read request body: %v", err) + return fmt.Errorf("failed to read request body: %w", err) } + body = bytes.NewReader(b) + hash, err := hexEncodedSha256(b) if err != nil { - return fmt.Errorf("failed to calculate hash of request body: %v", err) + return fmt.Errorf("failed to calculate hash of request body: %w", err) } + contentSha256Hash = hash } // Add the "X-Amz-Content-Sha256" header as required by Amazon OpenSearch Serverless. @@ -97,9 +103,8 @@ func sign(req *http.Request, region *string, serviceName string, signer *v4.Sign func hexEncodedSha256(b []byte) (string, error) { hasher := sha256.New() - _, err := hasher.Write(b) - if err != nil { - return "", fmt.Errorf("failed to write: %v", err) + if _, err := hasher.Write(b); err != nil { + return "", fmt.Errorf("failed to write: %w", err) } digest := hasher.Sum(nil) diff --git a/signer/aws/aws_test.go b/signer/aws/aws_test.go index 48ef4d8..564ac01 100644 --- a/signer/aws/aws_test.go +++ b/signer/aws/aws_test.go @@ -7,7 +7,7 @@ // Modifications Copyright OpenSearch Contributors. See // GitHub history for details. -package aws +package aws_test import ( "bytes" @@ -20,16 +20,16 @@ import ( "github.com/aws/aws-sdk-go/aws/credentials" "github.com/aws/aws-sdk-go/aws/session" "github.com/stretchr/testify/assert" + + osaws "github.com/opensearch-project/opensearch-go/v2/signer/aws" ) func TestConstants(t *testing.T) { - assert.Equal(t, "es", OpenSearchService) - assert.Equal(t, "aoss", OpenSearchServerless) - assert.Equal(t, "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824", emptyBodySHA256) + assert.Equal(t, "es", osaws.OpenSearchService) + assert.Equal(t, "aoss", osaws.OpenSearchServerless) } func TestV4Signer(t *testing.T) { - t.Run("sign request failed due to no region found", func(t *testing.T) { req, err := http.NewRequest(http.MethodGet, "https://localhost:9200", nil) assert.NoError(t, err) @@ -39,7 +39,7 @@ func TestV4Signer(t *testing.T) { Credentials: credentials.NewStaticCredentials("AKID", "SECRET_KEY", "TOKEN"), }, } - signer, err := NewSigner(sessionOptions) + signer, err := osaws.NewSigner(sessionOptions) assert.NoError(t, err) err = signer.SignRequest(req) @@ -56,7 +56,7 @@ func TestV4Signer(t *testing.T) { Credentials: credentials.NewStaticCredentials("AKID", "SECRET_KEY", "TOKEN"), }, } - signer, err := NewSigner(sessionOptions) + signer, err := osaws.NewSigner(sessionOptions) assert.NoError(t, err) err = signer.SignRequest(req) @@ -71,7 +71,7 @@ func TestV4Signer(t *testing.T) { t.Run("sign request success with body", func(t *testing.T) { req, err := http.NewRequest( http.MethodPost, "https://localhost:9200", - bytes.NewBuffer([]byte(`some data`))) + bytes.NewBufferString("some data")) assert.NoError(t, err) sessionOptions := session.Options{ @@ -80,7 +80,7 @@ func TestV4Signer(t *testing.T) { Credentials: credentials.NewStaticCredentials("AKID", "SECRET_KEY", "TOKEN"), }, } - signer, err := NewSigner(sessionOptions) + signer, err := osaws.NewSigner(sessionOptions) assert.NoError(t, err) err = signer.SignRequest(req) @@ -95,7 +95,7 @@ func TestV4Signer(t *testing.T) { t.Run("sign request success with body for OpenSearch Service Serverless", func(t *testing.T) { req, err := http.NewRequest( http.MethodPost, "https://localhost:9200", - bytes.NewBuffer([]byte(`some data`))) + bytes.NewBufferString("some data")) assert.NoError(t, err) sessionOptions := session.Options{ @@ -104,7 +104,7 @@ func TestV4Signer(t *testing.T) { Credentials: credentials.NewStaticCredentials("AKID", "SECRET_KEY", "TOKEN"), }, } - signer, err := NewSignerWithService(sessionOptions, OpenSearchServerless) + signer, err := osaws.NewSignerWithService(sessionOptions, osaws.OpenSearchServerless) assert.NoError(t, err) err = signer.SignRequest(req) @@ -123,7 +123,7 @@ func TestV4Signer(t *testing.T) { Credentials: credentials.NewStaticCredentials("AKID", "SECRET_KEY", "TOKEN"), }, } - _, err := NewSignerWithService(sessionOptions, "") + _, err := osaws.NewSignerWithService(sessionOptions, "") assert.EqualError(t, err, "service cannot be empty") }) @@ -134,7 +134,7 @@ func TestV4Signer(t *testing.T) { Credentials: credentials.NewStaticCredentials("AKID", "SECRET_KEY", "TOKEN"), }, } - _, err := NewSignerWithService(sessionOptions, " ") + _, err := osaws.NewSignerWithService(sessionOptions, " ") assert.EqualError(t, err, "service cannot be empty") }) @@ -150,7 +150,7 @@ func TestV4Signer(t *testing.T) { Credentials: credentials.NewStaticCredentials("AKID", "SECRET_KEY", "TOKEN"), }, } - signer, err := NewSigner(sessionOptions) + signer, err := osaws.NewSigner(sessionOptions) assert.NoError(t, err) err = signer.SignRequest(req) diff --git a/signer/awsv2/sdkv2signer.go b/signer/awsv2/sdkv2signer.go index 1312fae..aca4fda 100644 --- a/signer/awsv2/sdkv2signer.go +++ b/signer/awsv2/sdkv2signer.go @@ -16,13 +16,15 @@ import ( "encoding/hex" "errors" "fmt" - "github.com/aws/aws-sdk-go-v2/aws" - awsSignerV4 "github.com/aws/aws-sdk-go-v2/aws/signer/v4" - "github.com/opensearch-project/opensearch-go/v2/signer" - "io/ioutil" + "io" "net/http" "strings" "time" + + "github.com/aws/aws-sdk-go-v2/aws" + awsSignerV4 "github.com/aws/aws-sdk-go-v2/aws/signer/v4" + + "github.com/opensearch-project/opensearch-go/v2/signer" ) const ( @@ -69,6 +71,7 @@ func (s *awsSdkV2Signer) SignRequest(r *http.Request) error { hash, err := hexEncodedSha256OfRequest(r) r.Header.Set("X-Amz-Content-Sha256", hash) + if err != nil { return err } @@ -82,7 +85,8 @@ func hexEncodedSha256OfRequest(r *http.Request) (string, error) { } hasher := sha256.New() - reqBodyBytes, err := ioutil.ReadAll(r.Body) + + reqBodyBytes, err := io.ReadAll(r.Body) if err != nil { return "", err } @@ -90,8 +94,8 @@ func hexEncodedSha256OfRequest(r *http.Request) (string, error) { if err := r.Body.Close(); err != nil { return "", err } - r.Body = ioutil.NopCloser(bytes.NewBuffer(reqBodyBytes)) + r.Body = io.NopCloser(bytes.NewBuffer(reqBodyBytes)) hasher.Write(reqBodyBytes) digest := hasher.Sum(nil) diff --git a/signer/awsv2/sdkv2signer_test.go b/signer/awsv2/sdkv2signer_test.go index fcc0ce3..117add5 100644 --- a/signer/awsv2/sdkv2signer_test.go +++ b/signer/awsv2/sdkv2signer_test.go @@ -7,26 +7,30 @@ // Modifications Copyright OpenSearch Contributors. See // GitHub history for details. -package awsv2 +package awsv2_test import ( "bytes" "context" - "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/config" - "github.com/stretchr/testify/assert" "net/http" "os" "testing" + + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/config" + "github.com/stretchr/testify/assert" + + "github.com/opensearch-project/opensearch-go/v2/signer/awsv2" ) -func getCredentialProvider(accessKey, secretAccessKey, token string) aws.CredentialsProviderFunc { +func getCredentialProvider() aws.CredentialsProviderFunc { return func(ctx context.Context) (aws.Credentials, error) { c := &aws.Credentials{ - AccessKeyID: accessKey, - SecretAccessKey: secretAccessKey, - SessionToken: token, + AccessKeyID: "AKID", + SecretAccessKey: "SECRET_KEY", + SessionToken: "TOKEN", } + return *c, nil } } @@ -42,13 +46,13 @@ func TestV4SignerAwsSdkV2(t *testing.T) { }() awsCfg, err := config.LoadDefaultConfig(context.TODO(), config.WithCredentialsProvider( - getCredentialProvider("AKID", "SECRET_KEY", "TOKEN"), + getCredentialProvider(), ), config.WithRegion(""), ) assert.NoError(t, err) - signer, err := NewSigner(awsCfg) + signer, err := awsv2.NewSigner(awsCfg) assert.NoError(t, err) err = signer.SignRequest(req) @@ -67,12 +71,12 @@ func TestV4SignerAwsSdkV2(t *testing.T) { awsCfg, err := config.LoadDefaultConfig(context.TODO(), config.WithRegion("us-west-2"), config.WithCredentialsProvider( - getCredentialProvider("AKID", "SECRET_KEY", "TOKEN"), + getCredentialProvider(), ), ) assert.NoError(t, err) - signer, err := NewSigner(awsCfg) + signer, err := awsv2.NewSigner(awsCfg) assert.NoError(t, err) err = signer.SignRequest(req) @@ -86,7 +90,7 @@ func TestV4SignerAwsSdkV2(t *testing.T) { t.Run("sign request success with body", func(t *testing.T) { req, err := http.NewRequest( http.MethodPost, "https://localhost:9200", - bytes.NewBuffer([]byte(`some data`))) + bytes.NewBufferString("some data")) assert.NoError(t, err) region := os.Getenv("AWS_REGION") os.Setenv("AWS_REGION", "us-west-2") @@ -97,12 +101,12 @@ func TestV4SignerAwsSdkV2(t *testing.T) { awsCfg, err := config.LoadDefaultConfig(context.TODO(), config.WithRegion("us-west-2"), config.WithCredentialsProvider( - getCredentialProvider("AKID", "SECRET_KEY", "TOKEN"), + getCredentialProvider(), ), ) assert.NoError(t, err) - signer, err := NewSigner(awsCfg) + signer, err := awsv2.NewSigner(awsCfg) assert.NoError(t, err) err = signer.SignRequest(req) @@ -116,7 +120,7 @@ func TestV4SignerAwsSdkV2(t *testing.T) { t.Run("sign request success with body for other AWS Services", func(t *testing.T) { req, err := http.NewRequest( http.MethodPost, "https://localhost:9200", - bytes.NewBuffer([]byte(`some data`))) + bytes.NewBufferString("some data")) assert.NoError(t, err) region := os.Getenv("AWS_REGION") os.Setenv("AWS_REGION", "us-west-2") @@ -127,12 +131,12 @@ func TestV4SignerAwsSdkV2(t *testing.T) { awsCfg, err := config.LoadDefaultConfig(context.TODO(), config.WithRegion("us-west-2"), config.WithCredentialsProvider( - getCredentialProvider("AKID", "SECRET_KEY", "TOKEN"), + getCredentialProvider(), ), ) assert.NoError(t, err) - signer, err := NewSignerWithService(awsCfg, "ec") + signer, err := awsv2.NewSignerWithService(awsCfg, "ec") assert.NoError(t, err) assert.NoError(t, err) @@ -148,12 +152,12 @@ func TestV4SignerAwsSdkV2(t *testing.T) { awsCfg, err := config.LoadDefaultConfig(context.TODO(), config.WithRegion("us-west-2"), config.WithCredentialsProvider( - getCredentialProvider("AKID", "SECRET_KEY", "TOKEN"), + getCredentialProvider(), ), ) assert.NoError(t, err) - _, err = NewSignerWithService(awsCfg, "") + _, err = awsv2.NewSignerWithService(awsCfg, "") assert.EqualError(t, err, "service cannot be empty") }) } diff --git a/signer/signer.go b/signer/signer.go index f0a88e7..8a5beb9 100644 --- a/signer/signer.go +++ b/signer/signer.go @@ -11,7 +11,7 @@ package signer import "net/http" -//Signer an interface that will sign http.Request +// Signer an interface that will sign http.Request type Signer interface { SignRequest(request *http.Request) error } From 1e69a8ac7c7d0066eb7068d6833c2388233ee7fc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 26 Jul 2023 12:13:02 -0400 Subject: [PATCH 69/84] Bump github.com/aws/aws-sdk-go from 1.44.306 to 1.44.307 (#351) * Bump github.com/aws/aws-sdk-go from 1.44.306 to 1.44.307 Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.44.306 to 1.44.307. - [Release notes](https://github.com/aws/aws-sdk-go/releases) - [Commits](https://github.com/aws/aws-sdk-go/compare/v1.44.306...v1.44.307) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Update changelog Signed-off-by: dependabot[bot] --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] --- CHANGELOG.md | 2 +- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9aa73c8..7adb27a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Dependencies -- Bumps `github.com/aws/aws-sdk-go` from 1.44.180 to 1.44.306 +- Bumps `github.com/aws/aws-sdk-go` from 1.44.180 to 1.44.307 - Bumps `github.com/aws/aws-sdk-go-v2` from 1.17.4 to 1.18.1 - Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.8 to 1.18.28 - Bumps `github.com/stretchr/testify` from 1.8.1 to 1.8.4 diff --git a/go.mod b/go.mod index 5a906f7..be01ae7 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/opensearch-project/opensearch-go/v2 go 1.15 require ( - github.com/aws/aws-sdk-go v1.44.306 + github.com/aws/aws-sdk-go v1.44.307 github.com/aws/aws-sdk-go-v2 v1.19.0 github.com/aws/aws-sdk-go-v2/config v1.18.28 github.com/kinbiko/jsonassert v1.1.1 diff --git a/go.sum b/go.sum index 31c03c6..571be5d 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/aws/aws-sdk-go v1.44.306 h1:H487V/1N09BDxeGR7oR+LloC2uUpmf4atmqJaBgQOIs= -github.com/aws/aws-sdk-go v1.44.306/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= +github.com/aws/aws-sdk-go v1.44.307 h1:2R0/EPgpZcFSUwZhYImq/srjaOrOfLv5MNRzrFyAM38= +github.com/aws/aws-sdk-go v1.44.307/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go-v2 v1.19.0 h1:klAT+y3pGFBU/qVf1uzwttpBbiuozJYWzNLHioyDJ+k= github.com/aws/aws-sdk-go-v2 v1.19.0/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= github.com/aws/aws-sdk-go-v2/config v1.18.28 h1:TINEaKyh1Td64tqFvn09iYpKiWjmHYrG1fa91q2gnqw= From 25b957888f18fc1cca1cc41d9b9f00b490556436 Mon Sep 17 00:00:00 2001 From: Jakob Date: Thu, 27 Jul 2023 14:13:36 +0200 Subject: [PATCH 70/84] golangci-lint: Solve Complains for opensearchtransport (#353) * opensearchtransport: remove unneded error returns from connection functions, make defaults const Signed-off-by: Jakob Hahn * opensearchtransport: Solve linting complains Signed-off-by: Jakob Hahn * changelog: Solve linting complains for opensearchtransport Signed-off-by: Jakob Hahn --------- Signed-off-by: Jakob Hahn --- CHANGELOG.md | 1 + opensearchtransport/connection.go | 86 ++-- .../connection_benchmark_test.go | 88 ++-- .../connection_integration_test.go | 6 +- .../connection_internal_test.go | 70 ++-- opensearchtransport/discovery.go | 77 ++-- .../discovery_internal_test.go | 19 +- opensearchtransport/doc.go | 4 +- opensearchtransport/logger.go | 42 +- opensearchtransport/logger_benchmark_test.go | 48 ++- opensearchtransport/logger_internal_test.go | 99 +++-- opensearchtransport/metrics.go | 11 - opensearchtransport/metrics_internal_test.go | 9 +- opensearchtransport/opensearchtransport.go | 119 +++--- .../opensearchtransport_benchmark_test.go | 37 +- ...rchtransport_integration_multinode_test.go | 2 +- .../opensearchtransport_integration_test.go | 1 - .../opensearchtransport_internal_test.go | 391 ++++++++---------- 18 files changed, 529 insertions(+), 581 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7adb27a..dbdb36d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,6 +41,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - 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)) - Updated and adjusted golangci-lint, solve linting complains for signer ([#352](https://github.com/opensearch-project/opensearch-go/pull/352)) +- Solve linting complains for opensearchtransport ([#353](https://github.com/opensearch-project/opensearch-go/pull/353)) ### Deprecated diff --git a/opensearchtransport/connection.go b/opensearchtransport/connection.go index d4214f6..58e16ce 100644 --- a/opensearchtransport/connection.go +++ b/opensearchtransport/connection.go @@ -36,28 +36,25 @@ import ( "time" ) -var ( +const ( defaultResurrectTimeoutInitial = 60 * time.Second defaultResurrectTimeoutFactorCutoff = 5 ) // Selector defines the interface for selecting connections from the pool. -// type Selector interface { Select([]*Connection) (*Connection, error) } // ConnectionPool defines the interface for the connection pool. -// type ConnectionPool interface { Next() (*Connection, error) // Next returns the next available connection. - OnSuccess(*Connection) error // OnSuccess reports that the connection was successful. + OnSuccess(*Connection) // OnSuccess reports that the connection was successful. OnFailure(*Connection) error // OnFailure reports that the connection failed. URLs() []*url.URL // URLs returns the list of URLs of available connections. } // Connection represents a connection to a node. -// type Connection struct { sync.Mutex @@ -81,9 +78,11 @@ type singleConnectionPool struct { type statusConnectionPool struct { sync.Mutex - live []*Connection // List of live connections - dead []*Connection // List of dead connections - selector Selector + live []*Connection // List of live connections + dead []*Connection // List of dead connections + selector Selector + resurrectTimeoutInitial time.Duration + resurrectTimeoutFactorCutoff int metrics *metrics } @@ -95,28 +94,33 @@ type roundRobinSelector struct { } // NewConnectionPool creates and returns a default connection pool. -// -func NewConnectionPool(conns []*Connection, selector Selector) (ConnectionPool, error) { +func NewConnectionPool(conns []*Connection, selector Selector) ConnectionPool { if len(conns) == 1 { - return &singleConnectionPool{connection: conns[0]}, nil + return &singleConnectionPool{connection: conns[0]} } + if selector == nil { selector = &roundRobinSelector{curr: -1} } - return &statusConnectionPool{live: conns, selector: selector}, nil + + return &statusConnectionPool{ + live: conns, + selector: selector, + resurrectTimeoutInitial: defaultResurrectTimeoutInitial, + resurrectTimeoutFactorCutoff: defaultResurrectTimeoutFactorCutoff, + } } // Next returns the connection from pool. -// func (cp *singleConnectionPool) Next() (*Connection, error) { return cp.connection, nil } // OnSuccess is a no-op for single connection pool. -func (cp *singleConnectionPool) OnSuccess(c *Connection) error { return nil } +func (cp *singleConnectionPool) OnSuccess(*Connection) {} // OnFailure is a no-op for single connection pool. -func (cp *singleConnectionPool) OnFailure(c *Connection) error { return nil } +func (cp *singleConnectionPool) OnFailure(*Connection) error { return nil } // URLs returns the list of URLs of available connections. func (cp *singleConnectionPool) URLs() []*url.URL { return []*url.URL{cp.connection.URL} } @@ -124,7 +128,6 @@ func (cp *singleConnectionPool) URLs() []*url.URL { return []*url.URL{cp.connect func (cp *singleConnectionPool) connections() []*Connection { return []*Connection{cp.connection} } // Next returns a connection from pool, or an error. -// func (cp *statusConnectionPool) Next() (*Connection, error) { cp.Lock() defer cp.Unlock() @@ -141,29 +144,28 @@ func (cp *statusConnectionPool) Next() (*Connection, error) { cp.resurrect(c, false) return c, nil } + return nil, errors.New("no connection available") } // OnSuccess marks the connection as successful. -// -func (cp *statusConnectionPool) OnSuccess(c *Connection) error { +func (cp *statusConnectionPool) OnSuccess(c *Connection) { c.Lock() defer c.Unlock() // Short-circuit for live connection if !c.IsDead { - return nil + return } c.markAsHealthy() cp.Lock() defer cp.Unlock() - return cp.resurrect(c, true) + cp.resurrect(c, true) } // OnFailure marks the connection as failed. -// func (cp *statusConnectionPool) OnFailure(c *Connection) error { cp.Lock() defer cp.Unlock() @@ -175,12 +177,14 @@ func (cp *statusConnectionPool) OnFailure(c *Connection) error { debugLogger.Logf("Already removed %s\n", c.URL) } c.Unlock() + return nil } if debugLogger != nil { debugLogger.Logf("Removing %s...\n", c.URL) } + c.markAsDead() cp.scheduleResurrect(c) c.Unlock() @@ -201,12 +205,16 @@ func (cp *statusConnectionPool) OnFailure(c *Connection) error { // Check if connection exists in the list, return error if not. index := -1 + for i, conn := range cp.live { if conn == c { index = i } } + if index < 0 { + // Does this error even get raised? Under what conditions can the connection not be in the cp.live list? + // If the connection is marked dead the function already ended return errors.New("connection not in live list") } @@ -218,15 +226,13 @@ func (cp *statusConnectionPool) OnFailure(c *Connection) error { } // URLs returns the list of URLs of available connections. -// func (cp *statusConnectionPool) URLs() []*url.URL { - var urls []*url.URL - cp.Lock() defer cp.Unlock() - for _, c := range cp.live { - urls = append(urls, c.URL) + urls := make([]*url.URL, len(cp.live)) + for idx, c := range cp.live { + urls[idx] = c.URL } return urls @@ -236,14 +242,14 @@ func (cp *statusConnectionPool) connections() []*Connection { var conns []*Connection conns = append(conns, cp.live...) conns = append(conns, cp.dead...) + return conns } // resurrect adds the connection to the list of available connections. // When removeDead is true, it also removes it from the dead list. // The calling code is responsible for locking. -// -func (cp *statusConnectionPool) resurrect(c *Connection, removeDead bool) error { +func (cp *statusConnectionPool) resurrect(c *Connection, removeDead bool) { if debugLogger != nil { debugLogger.Logf("Resurrecting %s\n", c.URL) } @@ -253,28 +259,35 @@ func (cp *statusConnectionPool) resurrect(c *Connection, removeDead bool) error if removeDead { index := -1 + for i, conn := range cp.dead { if conn == c { index = i } } + if index >= 0 { // Remove item; https://github.com/golang/go/wiki/SliceTricks copy(cp.dead[index:], cp.dead[index+1:]) cp.dead = cp.dead[:len(cp.dead)-1] } } - - return nil } // scheduleResurrect schedules the connection to be resurrected. -// func (cp *statusConnectionPool) scheduleResurrect(c *Connection) { - factor := math.Min(float64(c.Failures-1), float64(defaultResurrectTimeoutFactorCutoff)) - timeout := time.Duration(defaultResurrectTimeoutInitial.Seconds() * math.Exp2(factor) * float64(time.Second)) + factor := math.Min(float64(c.Failures-1), float64(cp.resurrectTimeoutFactorCutoff)) + timeout := time.Duration(cp.resurrectTimeoutInitial.Seconds() * math.Exp2(factor) * float64(time.Second)) + if debugLogger != nil { - debugLogger.Logf("Resurrect %s (failures=%d, factor=%1.1f, timeout=%s) in %s\n", c.URL, c.Failures, factor, timeout, c.DeadSince.Add(timeout).Sub(time.Now().UTC()).Truncate(time.Second)) + debugLogger.Logf( + "Resurrect %s (failures=%d, factor=%1.1f, timeout=%s) in %s\n", + c.URL, + c.Failures, + factor, + timeout, + c.DeadSince.Add(timeout).Sub(time.Now().UTC()).Truncate(time.Second), + ) } time.AfterFunc(timeout, func() { @@ -296,7 +309,6 @@ func (cp *statusConnectionPool) scheduleResurrect(c *Connection) { } // Select returns the connection in a round-robin fashion. -// func (s *roundRobinSelector) Select(conns []*Connection) (*Connection, error) { s.Lock() defer s.Unlock() @@ -306,7 +318,6 @@ func (s *roundRobinSelector) Select(conns []*Connection) (*Connection, error) { } // markAsDead marks the connection as dead. -// func (c *Connection) markAsDead() { c.IsDead = true if c.DeadSince.IsZero() { @@ -316,13 +327,11 @@ func (c *Connection) markAsDead() { } // markAsLive marks the connection as alive. -// func (c *Connection) markAsLive() { c.IsDead = false } // markAsHealthy marks the connection as healthy. -// func (c *Connection) markAsHealthy() { c.IsDead = false c.DeadSince = time.Time{} @@ -330,7 +339,6 @@ func (c *Connection) markAsHealthy() { } // String returns a readable connection representation. -// func (c *Connection) String() string { c.Lock() defer c.Unlock() diff --git a/opensearchtransport/connection_benchmark_test.go b/opensearchtransport/connection_benchmark_test.go index 04d4059..fcc45b8 100644 --- a/opensearchtransport/connection_benchmark_test.go +++ b/opensearchtransport/connection_benchmark_test.go @@ -24,29 +24,48 @@ // specific language governing permissions and limitations // under the License. -// +build !integration +//go:build !integration +//nolint:testpackage // Can't be testpackage, because it tests the function resurrect() package opensearchtransport import ( "fmt" "log" "net/http" + _ "net/http/pprof" "net/url" "testing" - - _ "net/http/pprof" + "time" ) func init() { - go func() { log.Fatalln(http.ListenAndServe("localhost:6060", nil)) }() + go func() { + server := &http.Server{ + Addr: "localhost:6060", + ReadTimeout: 5 * time.Second, + WriteTimeout: 5 * time.Second, + } + log.Fatalln(server.ListenAndServe()) + }() +} + +func initSingleConnectionPool() *singleConnectionPool { + return &singleConnectionPool{ + connection: &Connection{ + URL: &url.URL{ + Scheme: "http", + Host: "foo1", + }, + }, + } } func BenchmarkSingleConnectionPool(b *testing.B) { b.ReportAllocs() b.Run("Next()", func(b *testing.B) { - pool := &singleConnectionPool{connection: &Connection{URL: &url.URL{Scheme: "http", Host: "foo1"}}} + pool := initSingleConnectionPool() b.Run("Single ", func(b *testing.B) { for i := 0; i < b.N; i++ { @@ -71,7 +90,7 @@ func BenchmarkSingleConnectionPool(b *testing.B) { }) b.Run("OnFailure()", func(b *testing.B) { - pool := &singleConnectionPool{connection: &Connection{URL: &url.URL{Scheme: "http", Host: "foo1"}}} + pool := initSingleConnectionPool() b.Run("Single ", func(b *testing.B) { c, _ := pool.Next() @@ -98,19 +117,25 @@ func BenchmarkSingleConnectionPool(b *testing.B) { }) } +func createStatusConnectionPool(conns []*Connection) *statusConnectionPool { + return &statusConnectionPool{ + live: conns, + selector: &roundRobinSelector{curr: -1}, + resurrectTimeoutInitial: defaultResurrectTimeoutInitial, + resurrectTimeoutFactorCutoff: defaultResurrectTimeoutFactorCutoff, + } +} + func BenchmarkStatusConnectionPool(b *testing.B) { b.ReportAllocs() - var conns []*Connection + conns := make([]*Connection, 1000) for i := 0; i < 1000; i++ { - conns = append(conns, &Connection{URL: &url.URL{Scheme: "http", Host: fmt.Sprintf("foo%d", i)}}) + conns[i] = &Connection{URL: &url.URL{Scheme: "http", Host: fmt.Sprintf("foo%d", i)}} } b.Run("Next()", func(b *testing.B) { - pool := &statusConnectionPool{ - live: conns, - selector: &roundRobinSelector{curr: -1}, - } + pool := createStatusConnectionPool(conns) b.Run("Single ", func(b *testing.B) { for i := 0; i < b.N; i++ { @@ -147,10 +172,7 @@ func BenchmarkStatusConnectionPool(b *testing.B) { }) b.Run("OnFailure()", func(b *testing.B) { - pool := &statusConnectionPool{ - live: conns, - selector: &roundRobinSelector{curr: -1}, - } + pool := createStatusConnectionPool(conns) b.Run("Single ", func(b *testing.B) { c, err := pool.Next() @@ -199,10 +221,7 @@ func BenchmarkStatusConnectionPool(b *testing.B) { }) b.Run("OnSuccess()", func(b *testing.B) { - pool := &statusConnectionPool{ - live: conns, - selector: &roundRobinSelector{curr: -1}, - } + pool := createStatusConnectionPool(conns) b.Run("Single ", func(b *testing.B) { c, err := pool.Next() @@ -211,9 +230,7 @@ func BenchmarkStatusConnectionPool(b *testing.B) { } for i := 0; i < b.N; i++ { - if err := pool.OnSuccess(c); err != nil { - b.Errorf("Unexpected error: %v", err) - } + pool.OnSuccess(c) } }) @@ -226,9 +243,7 @@ func BenchmarkStatusConnectionPool(b *testing.B) { } for pb.Next() { - if err := pool.OnSuccess(c); err != nil { - b.Errorf("Unexpected error: %v", err) - } + pool.OnSuccess(c) } }) }) @@ -242,19 +257,14 @@ func BenchmarkStatusConnectionPool(b *testing.B) { } for pb.Next() { - if err := pool.OnSuccess(c); err != nil { - b.Errorf("Unexpected error: %v", err) - } + pool.OnSuccess(c) } }) }) }) b.Run("resurrect()", func(b *testing.B) { - pool := &statusConnectionPool{ - live: conns, - selector: &roundRobinSelector{curr: -1}, - } + pool := createStatusConnectionPool(conns) b.Run("Single", func(b *testing.B) { c, err := pool.Next() @@ -268,9 +278,7 @@ func BenchmarkStatusConnectionPool(b *testing.B) { for i := 0; i < b.N; i++ { pool.Lock() - if err := pool.resurrect(c, true); err != nil { - b.Errorf("Unexpected error: %v", err) - } + pool.resurrect(c, true) pool.Unlock() } }) @@ -289,9 +297,7 @@ func BenchmarkStatusConnectionPool(b *testing.B) { for pb.Next() { pool.Lock() - if err := pool.resurrect(c, true); err != nil { - b.Errorf("Unexpected error: %v", err) - } + pool.resurrect(c, true) pool.Unlock() } }) @@ -311,9 +317,7 @@ func BenchmarkStatusConnectionPool(b *testing.B) { for pb.Next() { pool.Lock() - if err := pool.resurrect(c, true); err != nil { - b.Errorf("Unexpected error: %v", err) - } + pool.resurrect(c, true) pool.Unlock() } }) diff --git a/opensearchtransport/connection_integration_test.go b/opensearchtransport/connection_integration_test.go index 59e22c5..b657a55 100644 --- a/opensearchtransport/connection_integration_test.go +++ b/opensearchtransport/connection_integration_test.go @@ -24,7 +24,7 @@ // specific language governing permissions and limitations // under the License. -// +build integration +//go:build integration package opensearchtransport @@ -42,9 +42,6 @@ func NewServer(addr string, handler http.Handler) *http.Server { } func TestStatusConnectionPool(t *testing.T) { - defaultResurrectTimeoutInitial = time.Second - defer func() { defaultResurrectTimeoutInitial = 60 * time.Second }() - var ( server *http.Server servers []*http.Server @@ -88,6 +85,7 @@ func TestStatusConnectionPool(t *testing.T) { transport, _ := New(cfg) pool := transport.pool.(*statusConnectionPool) + pool.resurrectTimeoutInitial = time.Second for i := 1; i <= 9; i++ { req, _ := http.NewRequest("GET", "/", nil) diff --git a/opensearchtransport/connection_internal_test.go b/opensearchtransport/connection_internal_test.go index 3cb34b4..46c9a31 100644 --- a/opensearchtransport/connection_internal_test.go +++ b/opensearchtransport/connection_internal_test.go @@ -24,7 +24,7 @@ // specific language governing permissions and limitations // under the License. -// +build !integration +//go:build !integration package opensearchtransport @@ -81,8 +81,8 @@ func TestStatusConnectionPoolNext(t *testing.T) { pool := &statusConnectionPool{ live: []*Connection{ - &Connection{URL: &url.URL{Scheme: "http", Host: "foo1"}}, - &Connection{URL: &url.URL{Scheme: "http", Host: "foo2"}}, + {URL: &url.URL{Scheme: "http", Host: "foo1"}}, + {URL: &url.URL{Scheme: "http", Host: "foo2"}}, }, selector: &roundRobinSelector{curr: -1}, } @@ -107,9 +107,9 @@ func TestStatusConnectionPoolNext(t *testing.T) { t.Run("Three URLs", func(t *testing.T) { pool := &statusConnectionPool{ live: []*Connection{ - &Connection{URL: &url.URL{Scheme: "http", Host: "foo1"}}, - &Connection{URL: &url.URL{Scheme: "http", Host: "foo2"}}, - &Connection{URL: &url.URL{Scheme: "http", Host: "foo3"}}, + {URL: &url.URL{Scheme: "http", Host: "foo1"}}, + {URL: &url.URL{Scheme: "http", Host: "foo2"}}, + {URL: &url.URL{Scheme: "http", Host: "foo3"}}, }, selector: &roundRobinSelector{curr: -1}, } @@ -117,7 +117,6 @@ func TestStatusConnectionPoolNext(t *testing.T) { var expected string for i := 0; i < 11; i++ { c, err := pool.Next() - if err != nil { t.Errorf("Unexpected error: %s", err) } @@ -143,8 +142,8 @@ func TestStatusConnectionPoolNext(t *testing.T) { pool := &statusConnectionPool{ live: []*Connection{}, dead: []*Connection{ - &Connection{URL: &url.URL{Scheme: "http", Host: "foo1"}, Failures: 3}, - &Connection{URL: &url.URL{Scheme: "http", Host: "foo2"}, Failures: 1}, + {URL: &url.URL{Scheme: "http", Host: "foo1"}, Failures: 3}, + {URL: &url.URL{Scheme: "http", Host: "foo2"}, Failures: 1}, }, selector: &roundRobinSelector{curr: -1}, } @@ -180,16 +179,14 @@ func TestStatusConnectionPoolOnSuccess(t *testing.T) { t.Run("Move connection to live list and mark it as healthy", func(t *testing.T) { pool := &statusConnectionPool{ dead: []*Connection{ - &Connection{URL: &url.URL{Scheme: "http", Host: "foo1"}, Failures: 3, IsDead: true}, + {URL: &url.URL{Scheme: "http", Host: "foo1"}, Failures: 3, IsDead: true}, }, selector: &roundRobinSelector{curr: -1}, } conn := pool.dead[0] - if err := pool.OnSuccess(conn); err != nil { - t.Fatalf("Unexpected error: %s", err) - } + pool.OnSuccess(conn) if conn.IsDead { t.Errorf("Expected the connection to be live; %s", conn) @@ -213,12 +210,12 @@ func TestStatusConnectionPoolOnFailure(t *testing.T) { t.Run("Remove connection, mark it, and sort dead connections", func(t *testing.T) { pool := &statusConnectionPool{ live: []*Connection{ - &Connection{URL: &url.URL{Scheme: "http", Host: "foo1"}}, - &Connection{URL: &url.URL{Scheme: "http", Host: "foo2"}}, + {URL: &url.URL{Scheme: "http", Host: "foo1"}}, + {URL: &url.URL{Scheme: "http", Host: "foo2"}}, }, dead: []*Connection{ - &Connection{URL: &url.URL{Scheme: "http", Host: "foo3"}, Failures: 0}, - &Connection{URL: &url.URL{Scheme: "http", Host: "foo4"}, Failures: 99}, + {URL: &url.URL{Scheme: "http", Host: "foo3"}, Failures: 0}, + {URL: &url.URL{Scheme: "http", Host: "foo4"}, Failures: 99}, }, selector: &roundRobinSelector{curr: -1}, } @@ -228,7 +225,7 @@ func TestStatusConnectionPoolOnFailure(t *testing.T) { if err := pool.OnFailure(conn); err != nil { t.Fatalf("Unexpected error: %s", err) } - + conn.Lock() if !conn.IsDead { t.Errorf("Expected the connection to be dead; %s", conn) } @@ -236,7 +233,10 @@ func TestStatusConnectionPoolOnFailure(t *testing.T) { if conn.DeadSince.IsZero() { t.Errorf("Unexpected value for DeadSince: %s", conn.DeadSince) } + conn.Unlock() + pool.Lock() + defer pool.Unlock() if len(pool.live) != 1 { t.Errorf("Expected 1 live connection, got: %d", len(pool.live)) } @@ -261,9 +261,9 @@ func TestStatusConnectionPoolOnFailure(t *testing.T) { t.Run("Short circuit when the connection is already dead", func(t *testing.T) { pool := &statusConnectionPool{ live: []*Connection{ - &Connection{URL: &url.URL{Scheme: "http", Host: "foo1"}}, - &Connection{URL: &url.URL{Scheme: "http", Host: "foo2"}}, - &Connection{URL: &url.URL{Scheme: "http", Host: "foo3"}}, + {URL: &url.URL{Scheme: "http", Host: "foo1"}}, + {URL: &url.URL{Scheme: "http", Host: "foo2"}}, + {URL: &url.URL{Scheme: "http", Host: "foo3"}}, }, selector: &roundRobinSelector{curr: -1}, } @@ -285,15 +285,14 @@ func TestStatusConnectionPoolResurrect(t *testing.T) { t.Run("Mark the connection as dead and add/remove it to the lists", func(t *testing.T) { pool := &statusConnectionPool{ live: []*Connection{}, - dead: []*Connection{&Connection{URL: &url.URL{Scheme: "http", Host: "foo1"}, IsDead: true}}, + dead: []*Connection{{URL: &url.URL{Scheme: "http", Host: "foo1"}, IsDead: true}}, selector: &roundRobinSelector{curr: -1}, } conn := pool.dead[0] - - if err := pool.resurrect(conn, true); err != nil { - t.Fatalf("Unexpected error: %s", err) - } + conn.Lock() + defer conn.Unlock() + pool.resurrect(conn, true) if conn.IsDead { t.Errorf("Expected connection to be dead, got: %s", conn) @@ -310,15 +309,14 @@ func TestStatusConnectionPoolResurrect(t *testing.T) { t.Run("Short circuit removal when the connection is not in the dead list", func(t *testing.T) { pool := &statusConnectionPool{ - dead: []*Connection{&Connection{URL: &url.URL{Scheme: "http", Host: "bar"}, IsDead: true}}, + dead: []*Connection{{URL: &url.URL{Scheme: "http", Host: "bar"}, IsDead: true}}, selector: &roundRobinSelector{curr: -1}, } conn := &Connection{URL: &url.URL{Scheme: "http", Host: "foo1"}, IsDead: true} - - if err := pool.resurrect(conn, true); err != nil { - t.Fatalf("Unexpected error: %s", err) - } + conn.Lock() + defer conn.Unlock() + pool.resurrect(conn, true) if len(pool.live) != 1 { t.Errorf("Expected 1 live connection, got: %s", pool.live) @@ -330,20 +328,19 @@ func TestStatusConnectionPoolResurrect(t *testing.T) { }) t.Run("Schedule resurrect", func(t *testing.T) { - defaultResurrectTimeoutInitial = 0 - defer func() { defaultResurrectTimeoutInitial = 60 * time.Second }() - pool := &statusConnectionPool{ live: []*Connection{}, dead: []*Connection{ - &Connection{ + { URL: &url.URL{Scheme: "http", Host: "foo1"}, Failures: 100, IsDead: true, DeadSince: time.Now().UTC(), }, }, - selector: &roundRobinSelector{curr: -1}, + selector: &roundRobinSelector{curr: -1}, + resurrectTimeoutInitial: 0, + resurrectTimeoutFactorCutoff: defaultResurrectTimeoutFactorCutoff, } conn := pool.dead[0] @@ -375,7 +372,6 @@ func TestConnection(t *testing.T) { ` dead=true failures=10`, conn.String(), ) - if err != nil { t.Fatalf("Unexpected error: %s", err) } diff --git a/opensearchtransport/discovery.go b/opensearchtransport/discovery.go index 37aafbe..f4463f3 100644 --- a/opensearchtransport/discovery.go +++ b/opensearchtransport/discovery.go @@ -27,25 +27,23 @@ package opensearchtransport import ( + "context" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "net/url" - "sort" "strings" "sync" "time" ) // Discoverable defines the interface for transports supporting node discovery. -// type Discoverable interface { DiscoverNodes() error } // nodeInfo represents the information about node in a cluster. -// type nodeInfo struct { ID string Name string @@ -58,27 +56,22 @@ type nodeInfo struct { } // DiscoverNodes reloads the client connections by fetching information from the cluster. -// func (c *Client) DiscoverNodes() error { - var conns []*Connection + conns := make([]*Connection, 0) nodes, err := c.getNodesInfo() if err != nil { if debugLogger != nil { debugLogger.Logf("Error getting nodes info: %s\n", err) } - return fmt.Errorf("discovery: get nodes: %s", err) + + return fmt.Errorf("discovery: get nodes: %w", err) } for _, node := range nodes { - var ( - isClusterManagerOnlyNode bool - ) - - roles := append(node.Roles[:0:0], node.Roles...) - sort.Strings(roles) + var isClusterManagerOnlyNode bool - if len(roles) == 1 && (roles[0] == "master" || roles[0] == "cluster_manager") { + if len(node.Roles) == 1 && (node.Roles[0] == "master" || node.Roles[0] == "cluster_manager") { isClusterManagerOnlyNode = true } @@ -87,6 +80,7 @@ func (c *Client) DiscoverNodes() error { if isClusterManagerOnlyNode { skip = "; [SKIP]" } + debugLogger.Logf("Discovered node [%s]; %s; roles=%s%s\n", node.Name, node.URL, node.Roles, skip) } @@ -117,24 +111,18 @@ func (c *Client) DiscoverNodes() error { c.pool = c.poolFunc(conns, c.selector) } else { // TODO: Replace only live connections, leave dead scheduled for resurrect? - c.pool, err = NewConnectionPool(conns, c.selector) - if err != nil { - return err - } + c.pool = NewConnectionPool(conns, c.selector) } return nil } func (c *Client) getNodesInfo() ([]nodeInfo, error) { - var ( - out []nodeInfo - scheme = c.urls[0].Scheme - ) + scheme := c.urls[0].Scheme - req, err := http.NewRequest("GET", "/_nodes/http", nil) + req, err := http.NewRequestWithContext(context.TODO(), http.MethodGet, "/_nodes/http", nil) if err != nil { - return out, err + return nil, err } c.Lock() @@ -142,7 +130,7 @@ func (c *Client) getNodesInfo() ([]nodeInfo, error) { c.Unlock() // TODO: If no connection is returned, fallback to original URLs if err != nil { - return out, err + return nil, err } c.setReqURL(conn.URL, req) @@ -151,39 +139,43 @@ func (c *Client) getNodesInfo() ([]nodeInfo, error) { res, err := c.transport.RoundTrip(req) if err != nil { - return out, err + return nil, err } defer res.Body.Close() - if res.StatusCode > 200 { - body, _ := ioutil.ReadAll(res.Body) - return out, fmt.Errorf("server error: %s: %s", res.Status, body) + if res.StatusCode > http.StatusOK { + body, err := io.ReadAll(res.Body) + if err != nil { + return nil, fmt.Errorf("server error: %s: %w", res.Status, err) + } + return nil, fmt.Errorf("server error: %s: %s", res.Status, body) } var env map[string]json.RawMessage if err := json.NewDecoder(res.Body).Decode(&env); err != nil { - return out, err + return nil, err } var nodes map[string]nodeInfo if err := json.Unmarshal(env["nodes"], &nodes); err != nil { - return out, err + return nil, err } + out := make([]nodeInfo, len(nodes)) + idx := 0 + for id, node := range nodes { node.ID = id - u, err := c.getNodeURL(node, scheme) - if err != nil { - return out, err - } + u := c.getNodeURL(node, scheme) node.URL = u - out = append(out, node) + out[idx] = node + idx++ } return out, nil } -func (c *Client) getNodeURL(node nodeInfo, scheme string) (*url.URL, error) { +func (c *Client) getNodeURL(node nodeInfo, scheme string) *url.URL { var ( host string port string @@ -197,25 +189,28 @@ func (c *Client) getNodeURL(node nodeInfo, scheme string) (*url.URL, error) { } else { host = strings.Split(addrs[0], ":")[0] } - port = ports[len(ports)-1] + port = ports[len(ports)-1] u := &url.URL{ Scheme: scheme, Host: host + ":" + port, } - return u, nil + return u } -func (c *Client) scheduleDiscoverNodes(d time.Duration) { +func (c *Client) scheduleDiscoverNodes() { + //nolint:errcheck // errors are logged inside the function go c.DiscoverNodes() c.Lock() defer c.Unlock() + if c.discoverNodesTimer != nil { c.discoverNodesTimer.Stop() } + c.discoverNodesTimer = time.AfterFunc(c.discoverNodesInterval, func() { - c.scheduleDiscoverNodes(c.discoverNodesInterval) + c.scheduleDiscoverNodes() }) } diff --git a/opensearchtransport/discovery_internal_test.go b/opensearchtransport/discovery_internal_test.go index 8218976..41ba462 100644 --- a/opensearchtransport/discovery_internal_test.go +++ b/opensearchtransport/discovery_internal_test.go @@ -24,7 +24,7 @@ // specific language governing permissions and limitations // under the License. -// +build !integration +//go:build !integration package opensearchtransport @@ -34,7 +34,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "net/http" "net/url" "os" @@ -47,14 +46,14 @@ func TestDiscovery(t *testing.T) { defaultHandler := func(w http.ResponseWriter, r *http.Request) { f, err := os.Open("testdata/nodes.info.json") if err != nil { - http.Error(w, fmt.Sprintf("Fixture error: %s", err), 500) + http.Error(w, fmt.Sprintf("Fixture error: %s", err), http.StatusInternalServerError) return } io.Copy(w, f) } - srv := &http.Server{Addr: "localhost:10001", Handler: http.HandlerFunc(defaultHandler)} - srvTLS := &http.Server{Addr: "localhost:12001", Handler: http.HandlerFunc(defaultHandler)} + srv := &http.Server{Addr: "localhost:10001", Handler: http.HandlerFunc(defaultHandler), ReadTimeout: 1 * time.Second} + srvTLS := &http.Server{Addr: "localhost:12001", Handler: http.HandlerFunc(defaultHandler), ReadTimeout: 1 * time.Second} go func() { if err := srv.ListenAndServe(); err != nil && err != http.ErrServerClosed { @@ -485,12 +484,10 @@ func TestDiscovery(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - var names []string var urls []*url.URL - for name, node := range tt.args.Nodes { + for _, node := range tt.args.Nodes { u, _ := url.Parse(node.URL) urls = append(urls, u) - names = append(names, name) } newRoundTripper := func() http.RoundTripper { @@ -505,11 +502,11 @@ func TestDiscovery(t *testing.T) { b, _ := json.Marshal(nodes) return &http.Response{ - Status: "200 OK", - StatusCode: 200, + Status: fmt.Sprintf("%d %s", http.StatusOK, http.StatusText(http.StatusOK)), + StatusCode: http.StatusOK, ContentLength: int64(len(b)), Header: http.Header(map[string][]string{"Content-Type": {"application/json"}}), - Body: ioutil.NopCloser(bytes.NewReader(b)), + Body: io.NopCloser(bytes.NewReader(b)), }, nil }, } diff --git a/opensearchtransport/doc.go b/opensearchtransport/doc.go index abefe86..721e27d 100644 --- a/opensearchtransport/doc.go +++ b/opensearchtransport/doc.go @@ -37,7 +37,7 @@ response status codes (by default 502, 503, 504). Use the RetryOnStatus option t The transport will not retry a timeout network error, unless enabled by setting EnableRetryOnTimeout to true. Use the MaxRetries option to configure the number of retries, and set DisableRetry to true -to disable the retry behaviour altogether. +to disable the retry behavior altogether. By default, the retry will be performed without any delay; to configure a backoff interval, implement the RetryBackoff option function; see an example in the package unit tests for information. @@ -45,7 +45,7 @@ implement the RetryBackoff option function; see an example in the package unit t When multiple addresses are passed in configuration, the package will use them in a round-robin fashion, and will keep track of live and dead nodes. The status of dead nodes is checked periodically. -To customize the node selection behaviour, provide a Selector implementation in the configuration. +To customize the node selection behavior, provide a Selector implementation in the configuration. To replace the connection pool entirely, provide a custom ConnectionPool implementation via the ConnectionPoolFunc option. diff --git a/opensearchtransport/logger.go b/opensearchtransport/logger.go index f089e9e..f7994e9 100644 --- a/opensearchtransport/logger.go +++ b/opensearchtransport/logger.go @@ -32,7 +32,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "net/http" "net/url" "strconv" @@ -43,7 +42,6 @@ import ( var debugLogger DebuggingLogger // Logger defines an interface for logging request and response. -// type Logger interface { // LogRoundTrip should not modify the request or response, except for consuming and closing the body. // Implementations have to check for nil values in request and response. @@ -55,14 +53,12 @@ type Logger interface { } // DebuggingLogger defines the interface for a debugging logger. -// type DebuggingLogger interface { Log(a ...interface{}) error Logf(format string, a ...interface{}) error } // TextLogger prints the log message in plain text. -// type TextLogger struct { Output io.Writer EnableRequestBody bool @@ -70,7 +66,6 @@ type TextLogger struct { } // ColorLogger prints the log message in a terminal-optimized plain text. -// type ColorLogger struct { Output io.Writer EnableRequestBody bool @@ -78,7 +73,6 @@ type ColorLogger struct { } // CurlLogger prints the log message as a runnable curl command. -// type CurlLogger struct { Output io.Writer EnableRequestBody bool @@ -86,7 +80,6 @@ type CurlLogger struct { } // JSONLogger prints the log message as JSON. -// type JSONLogger struct { Output io.Writer EnableRequestBody bool @@ -94,13 +87,11 @@ type JSONLogger struct { } // debuggingLogger prints debug messages as plain text. -// type debuggingLogger struct { Output io.Writer } // LogRoundTrip prints the information about request and response. -// func (l *TextLogger) LogRoundTrip(req *http.Request, res *http.Response, err error, start time.Time, dur time.Duration) error { fmt.Fprintf(l.Output, "%s %s %s [status:%d request:%s]\n", start.Format(time.RFC3339), @@ -138,8 +129,7 @@ func (l *TextLogger) RequestBodyEnabled() bool { return l.EnableRequestBody } func (l *TextLogger) ResponseBodyEnabled() bool { return l.EnableResponseBody } // LogRoundTrip prints the information about request and response. -// -func (l *ColorLogger) LogRoundTrip(req *http.Request, res *http.Response, err error, start time.Time, dur time.Duration) error { +func (l *ColorLogger) LogRoundTrip(req *http.Request, res *http.Response, err error, _ time.Time, dur time.Duration) error { query, _ := url.QueryUnescape(req.URL.RawQuery) if query != "" { query = "?" + query @@ -213,8 +203,7 @@ func (l *ColorLogger) RequestBodyEnabled() bool { return l.EnableRequestBody } func (l *ColorLogger) ResponseBodyEnabled() bool { return l.EnableResponseBody } // LogRoundTrip prints the information about request and response. -// -func (l *CurlLogger) LogRoundTrip(req *http.Request, res *http.Response, err error, start time.Time, dur time.Duration) error { +func (l *CurlLogger) LogRoundTrip(req *http.Request, res *http.Response, _ error, start time.Time, dur time.Duration) error { var b bytes.Buffer var query string @@ -232,7 +221,7 @@ func (l *CurlLogger) LogRoundTrip(req *http.Request, res *http.Response, err err } b.WriteString(`curl`) - if req.Method == "HEAD" { + if req.Method == http.MethodHead { b.WriteString(" --head") } else { fmt.Fprintf(&b, " -X %s", req.Method) @@ -277,8 +266,7 @@ func (l *CurlLogger) LogRoundTrip(req *http.Request, res *http.Response, err err b.WriteRune('\n') - var status string - status = res.Status + status := res.Status fmt.Fprintf(&b, "# => %s [%s] %s\n", start.UTC().Format(time.RFC3339), status, dur.Truncate(time.Millisecond)) if l.ResponseBodyEnabled() && res != nil && res.Body != nil && res.Body != http.NoBody { @@ -307,13 +295,12 @@ func (l *CurlLogger) RequestBodyEnabled() bool { return l.EnableRequestBody } func (l *CurlLogger) ResponseBodyEnabled() bool { return l.EnableResponseBody } // LogRoundTrip prints the information about request and response. -// func (l *JSONLogger) LogRoundTrip(req *http.Request, res *http.Response, err error, start time.Time, dur time.Duration) error { // TODO: Research performance optimization of using sync.Pool bsize := 200 - var b = bytes.NewBuffer(make([]byte, 0, bsize)) - var v = make([]byte, 0, bsize) + b := bytes.NewBuffer(make([]byte, 0, bsize)) + v := make([]byte, 0, bsize) appendTime := func(t time.Time) { v = v[:0] @@ -333,8 +320,6 @@ func (l *JSONLogger) LogRoundTrip(req *http.Request, res *http.Response, err err b.Write(v) } - port := req.URL.Port() - b.WriteRune('{') // -- Timestamp b.WriteString(`"@timestamp":"`) @@ -351,7 +336,7 @@ func (l *JSONLogger) LogRoundTrip(req *http.Request, res *http.Response, err err appendQuote(req.URL.Scheme) b.WriteString(`,"domain":`) appendQuote(req.URL.Hostname()) - if port != "" { + if port := req.URL.Port(); port != "" { b.WriteString(`,"port":`) b.WriteString(port) } @@ -415,14 +400,12 @@ func (l *JSONLogger) RequestBodyEnabled() bool { return l.EnableRequestBody } func (l *JSONLogger) ResponseBodyEnabled() bool { return l.EnableResponseBody } // Log prints the arguments to output in default format. -// func (l *debuggingLogger) Log(a ...interface{}) error { _, err := fmt.Fprint(l.Output, a...) return err } // Logf prints formats the arguments and prints them to output. -// func (l *debuggingLogger) Logf(format string, a ...interface{}) error { _, err := fmt.Fprintf(l.Output, format, a...) return err @@ -444,13 +427,14 @@ func duplicateBody(body io.ReadCloser) (io.ReadCloser, io.ReadCloser, error) { b2 bytes.Buffer tr = io.TeeReader(body, &b2) ) - _, err := b1.ReadFrom(tr) - if err != nil { - return ioutil.NopCloser(io.MultiReader(&b1, errorReader{err: err})), ioutil.NopCloser(io.MultiReader(&b2, errorReader{err: err})), err + + if _, err := b1.ReadFrom(tr); err != nil { + return io.NopCloser(io.MultiReader(&b1, errorReader{err: err})), io.NopCloser(io.MultiReader(&b2, errorReader{err: err})), err } + defer func() { body.Close() }() - return ioutil.NopCloser(&b1), ioutil.NopCloser(&b2), nil + return io.NopCloser(&b1), io.NopCloser(&b2), nil } func resStatusCode(res *http.Response) int { @@ -462,4 +446,4 @@ func resStatusCode(res *http.Response) int { type errorReader struct{ err error } -func (r errorReader) Read(p []byte) (int, error) { return 0, r.err } +func (r errorReader) Read(_ []byte) (int, error) { return 0, r.err } diff --git a/opensearchtransport/logger_benchmark_test.go b/opensearchtransport/logger_benchmark_test.go index 3ed3111..6e176a1 100644 --- a/opensearchtransport/logger_benchmark_test.go +++ b/opensearchtransport/logger_benchmark_test.go @@ -24,13 +24,13 @@ // specific language governing permissions and limitations // under the License. -// +build !integration +//go:build !integration package opensearchtransport_test import ( "bytes" - "io/ioutil" + "io" "net/http" "net/url" "testing" @@ -46,14 +46,17 @@ func BenchmarkTransportLogger(b *testing.B) { tp, _ := opensearchtransport.New(opensearchtransport.Config{ URLs: []*url.URL{{Scheme: "http", Host: "foo"}}, Transport: newFakeTransport(b), - Logger: &opensearchtransport.TextLogger{Output: ioutil.Discard}, + Logger: &opensearchtransport.TextLogger{Output: io.Discard}, }) - req, _ := http.NewRequest("GET", "/abc", nil) - _, err := tp.Perform(req) + req, _ := http.NewRequest(http.MethodGet, "/abc", nil) + resp, err := tp.Perform(req) if err != nil { b.Fatalf("Unexpected error: %s", err) } + if resp.Body != nil { + resp.Body.Close() + } } }) @@ -62,20 +65,25 @@ func BenchmarkTransportLogger(b *testing.B) { tp, _ := opensearchtransport.New(opensearchtransport.Config{ URLs: []*url.URL{{Scheme: "http", Host: "foo"}}, Transport: newFakeTransport(b), - Logger: &opensearchtransport.TextLogger{Output: ioutil.Discard, EnableRequestBody: true, EnableResponseBody: true}, + Logger: &opensearchtransport.TextLogger{ + Output: io.Discard, + EnableRequestBody: true, + EnableResponseBody: true, + }, }) - req, _ := http.NewRequest("GET", "/abc", nil) + req, _ := http.NewRequest(http.MethodGet, "/abc", nil) res, err := tp.Perform(req) if err != nil { b.Fatalf("Unexpected error: %s", err) } + res.Body.Close() - body, err := ioutil.ReadAll(res.Body) + body, err := io.ReadAll(res.Body) if err != nil { b.Fatalf("Error reading response body: %s", err) } - res.Body = ioutil.NopCloser(bytes.NewBuffer(body)) + res.Body = io.NopCloser(bytes.NewBuffer(body)) if len(body) < 13 { b.Errorf("Error reading response body bytes, want=13, got=%d", len(body)) } @@ -87,14 +95,17 @@ func BenchmarkTransportLogger(b *testing.B) { tp, _ := opensearchtransport.New(opensearchtransport.Config{ URLs: []*url.URL{{Scheme: "http", Host: "foo"}}, Transport: newFakeTransport(b), - Logger: &opensearchtransport.JSONLogger{Output: ioutil.Discard}, + Logger: &opensearchtransport.JSONLogger{Output: io.Discard}, }) - req, _ := http.NewRequest("GET", "/abc", nil) - _, err := tp.Perform(req) + req, _ := http.NewRequest(http.MethodGet, "/abc", nil) + resp, err := tp.Perform(req) if err != nil { b.Fatalf("Unexpected error: %s", err) } + if resp != nil && resp.Body != nil { + resp.Body.Close() + } } }) @@ -103,14 +114,21 @@ func BenchmarkTransportLogger(b *testing.B) { tp, _ := opensearchtransport.New(opensearchtransport.Config{ URLs: []*url.URL{{Scheme: "http", Host: "foo"}}, Transport: newFakeTransport(b), - Logger: &opensearchtransport.JSONLogger{Output: ioutil.Discard, EnableRequestBody: true, EnableResponseBody: true}, + Logger: &opensearchtransport.JSONLogger{ + Output: io.Discard, + EnableRequestBody: true, + EnableResponseBody: true, + }, }) - req, _ := http.NewRequest("GET", "/abc", nil) - _, err := tp.Perform(req) + req, _ := http.NewRequest(http.MethodGet, "/abc", nil) + resp, err := tp.Perform(req) if err != nil { b.Fatalf("Unexpected error: %s", err) } + if resp != nil && resp.Body != nil { + resp.Body.Close() + } } }) } diff --git a/opensearchtransport/logger_internal_test.go b/opensearchtransport/logger_internal_test.go index 27beae7..f862c8d 100644 --- a/opensearchtransport/logger_internal_test.go +++ b/opensearchtransport/logger_internal_test.go @@ -24,7 +24,7 @@ // specific language governing permissions and limitations // under the License. -// +build !integration +//go:build !integration package opensearchtransport @@ -33,7 +33,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "net/http" "net/url" "os" @@ -54,11 +53,11 @@ func TestTransportLogger(t *testing.T) { return &mockTransp{ RoundTripFunc: func(req *http.Request) (*http.Response, error) { return &http.Response{ - Status: "200 OK", - StatusCode: 200, + Status: fmt.Sprintf("%d %s", http.StatusOK, http.StatusText(http.StatusOK)), + StatusCode: http.StatusOK, ContentLength: 13, Header: http.Header(map[string][]string{"Content-Type": {"application/json"}}), - Body: ioutil.NopCloser(strings.NewReader(`{"foo":"bar"}`)), + Body: io.NopCloser(strings.NewReader(`{"foo":"bar"}`)), }, nil }, } @@ -70,7 +69,7 @@ func TestTransportLogger(t *testing.T) { tp, _ := New(Config{ URLs: []*url.URL{{Scheme: "http", Host: "foo"}}, Transport: newRoundTripper(), - // Logger: ioutil.Discard, + // Logger: io.Discard, }) for i := 0; i < 100; i++ { @@ -78,12 +77,13 @@ func TestTransportLogger(t *testing.T) { go func() { defer wg.Done() - req, _ := http.NewRequest("GET", "/abc", nil) - _, err := tp.Perform(req) + req, _ := http.NewRequest(http.MethodGet, "/abc", nil) + resp, err := tp.Perform(req) if err != nil { t.Errorf("Unexpected error: %s", err) return } + defer resp.Body.Close() }() } wg.Wait() @@ -96,11 +96,12 @@ func TestTransportLogger(t *testing.T) { Logger: nil, }) - req, _ := http.NewRequest("GET", "/abc", nil) - _, err := tp.Perform(req) + req, _ := http.NewRequest(http.MethodGet, "/abc", nil) + resp, err := tp.Perform(req) if err != nil { t.Fatalf("Unexpected error: %s", err) } + defer resp.Body.Close() }) t.Run("No HTTP response", func(t *testing.T) { @@ -111,15 +112,16 @@ func TestTransportLogger(t *testing.T) { return nil, errors.New("Mock error") }, }, - Logger: &TextLogger{Output: ioutil.Discard}, + Logger: &TextLogger{Output: io.Discard}, }) - req, _ := http.NewRequest("GET", "/abc", nil) - res, err := tp.Perform(req) + req, _ := http.NewRequest(http.MethodGet, "/abc", nil) + resp, err := tp.Perform(req) if err == nil { + defer resp.Body.Close() t.Errorf("Expected error: %v", err) } - if res != nil { + if resp != nil { t.Errorf("Expected nil response, got: %v", err) } }) @@ -133,15 +135,16 @@ func TestTransportLogger(t *testing.T) { Logger: &TextLogger{Output: &dst, EnableRequestBody: true, EnableResponseBody: true}, }) - req, _ := http.NewRequest("GET", "/abc?q=a,b", nil) - req.Body = ioutil.NopCloser(strings.NewReader(`{"query":"42"}`)) + req, _ := http.NewRequest(http.MethodGet, "/abc?q=a,b", nil) + req.Body = io.NopCloser(strings.NewReader(`{"query":"42"}`)) res, err := tp.Perform(req) if err != nil { t.Fatalf("Unexpected error: %s", err) } + defer res.Body.Close() - body, err := ioutil.ReadAll(res.Body) + body, err := io.ReadAll(res.Body) if err != nil { t.Fatalf("Error reading response body: %s", err) } @@ -164,15 +167,16 @@ func TestTransportLogger(t *testing.T) { Logger: &TextLogger{Output: &dst, EnableRequestBody: true, EnableResponseBody: true}, }) - req, _ := http.NewRequest("GET", "/abc?q=a,b", nil) - req.Body = ioutil.NopCloser(strings.NewReader(`{"query":"42"}`)) + req, _ := http.NewRequest(http.MethodGet, "/abc?q=a,b", nil) + req.Body = io.NopCloser(strings.NewReader(`{"query":"42"}`)) res, err := tp.Perform(req) if err != nil { t.Fatalf("Unexpected error: %s", err) } + defer res.Body.Close() - _, err = ioutil.ReadAll(res.Body) + _, err = io.ReadAll(res.Body) if err != nil { t.Fatalf("Error reading response body: %s", err) } @@ -209,15 +213,16 @@ func TestTransportLogger(t *testing.T) { Logger: &ColorLogger{Output: &dst, EnableRequestBody: true, EnableResponseBody: true}, }) - req, _ := http.NewRequest("GET", "/abc?q=a,b", nil) - req.Body = ioutil.NopCloser(strings.NewReader(`{"query":"42"}`)) + req, _ := http.NewRequest(http.MethodGet, "/abc?q=a,b", nil) + req.Body = io.NopCloser(strings.NewReader(`{"query":"42"}`)) res, err := tp.Perform(req) if err != nil { t.Fatalf("Unexpected error: %s", err) } + defer res.Body.Close() - _, err = ioutil.ReadAll(res.Body) + _, err = io.ReadAll(res.Body) if err != nil { t.Fatalf("Error reading response body: %s", err) } @@ -263,15 +268,16 @@ func TestTransportLogger(t *testing.T) { Logger: &CurlLogger{Output: &dst, EnableRequestBody: true, EnableResponseBody: true}, }) - req, _ := http.NewRequest("GET", "/abc?q=a,b", nil) - req.Body = ioutil.NopCloser(strings.NewReader(`{"query":"42"}`)) + req, _ := http.NewRequest(http.MethodGet, "/abc?q=a,b", nil) + req.Body = io.NopCloser(strings.NewReader(`{"query":"42"}`)) res, err := tp.Perform(req) if err != nil { t.Fatalf("Unexpected error: %s", err) } + defer res.Body.Close() - _, err = ioutil.ReadAll(res.Body) + _, err = io.ReadAll(res.Body) if err != nil { t.Fatalf("Error reading response body: %s", err) } @@ -299,12 +305,13 @@ func TestTransportLogger(t *testing.T) { Logger: &JSONLogger{Output: &dst}, }) - req, _ := http.NewRequest("GET", "/abc?q=a,b", nil) - req.Body = ioutil.NopCloser(strings.NewReader(`{"query":"42"}`)) - _, err := tp.Perform(req) + req, _ := http.NewRequest(http.MethodGet, "/abc?q=a,b", nil) + req.Body = io.NopCloser(strings.NewReader(`{"query":"42"}`)) + resp, err := tp.Perform(req) if err != nil { t.Fatalf("Unexpected error: %s", err) } + defer resp.Body.Close() output := dst.String() output = strings.TrimSuffix(output, "\n") @@ -336,15 +343,16 @@ func TestTransportLogger(t *testing.T) { Logger: &JSONLogger{Output: &dst, EnableRequestBody: true}, }) - req, _ := http.NewRequest("GET", "/abc?q=a,b", nil) - req.Body = ioutil.NopCloser(strings.NewReader(`{"query":"42"}`)) + req, _ := http.NewRequest(http.MethodGet, "/abc?q=a,b", nil) + req.Body = io.NopCloser(strings.NewReader(`{"query":"42"}`)) res, err := tp.Perform(req) if err != nil { t.Fatalf("Unexpected error: %s", err) } + defer res.Body.Close() - _, err = ioutil.ReadAll(res.Body) + _, err = io.ReadAll(res.Body) if err != nil { t.Fatalf("Error reading response body: %s", err) } @@ -379,13 +387,14 @@ func TestTransportLogger(t *testing.T) { Logger: &CustomLogger{Output: &dst}, }) - req, _ := http.NewRequest("GET", "/abc?q=a,b", nil) - req.Body = ioutil.NopCloser(strings.NewReader(`{"query":"42"}`)) + req, _ := http.NewRequest(http.MethodGet, "/abc?q=a,b", nil) + req.Body = io.NopCloser(strings.NewReader(`{"query":"42"}`)) - _, err := tp.Perform(req) + res, err := tp.Perform(req) if err != nil { t.Fatalf("Unexpected error: %s", err) } + defer res.Body.Close() if !strings.HasPrefix(dst.String(), "GET http://foo/abc?q=a,b") { t.Errorf("Unexpected output: %s", dst.String()) @@ -403,13 +412,13 @@ func TestTransportLogger(t *testing.T) { t.Errorf("Expected input to be closed: %#v", input) } - read, _ := ioutil.ReadAll(&input) + read, _ := io.ReadAll(&input) if len(read) > 0 { t.Errorf("Expected input to be drained: %#v", input.content) } - b1r, _ := ioutil.ReadAll(b1) - b2r, _ := ioutil.ReadAll(b2) + b1r, _ := io.ReadAll(b1) + b2r, _ := io.ReadAll(b2) if len(b1r) != 6 || len(b2r) != 6 { t.Errorf( "Unexpected duplicate content, b1=%q (%db), b2=%q (%db)", @@ -429,17 +438,17 @@ func TestTransportLogger(t *testing.T) { t.Errorf("Unexpected error value, expected [ERROR MOCK], got [%s]", err.Error()) } - read, _ := ioutil.ReadAll(&input) + read, _ := io.ReadAll(&input) if string(read) != "BAR" { t.Errorf("Unexpected undrained part: %q", read) } - b2r, _ := ioutil.ReadAll(b2) + b2r, _ := io.ReadAll(b2) if string(b2r) != "FOO" { t.Errorf("Unexpected value, b2=%q", string(b2r)) } - b1c, err := ioutil.ReadAll(b1) + b1c, err := io.ReadAll(b1) if string(b1c) != "FOO" { t.Errorf("Unexpected value, b1=%q", string(b1c)) } @@ -453,7 +462,7 @@ func TestTransportLogger(t *testing.T) { } func TestDebuggingLogger(t *testing.T) { - logger := &debuggingLogger{Output: ioutil.Discard} + logger := &debuggingLogger{Output: io.Discard} t.Run("Log", func(t *testing.T) { if err := logger.Log("Foo"); err != nil { @@ -474,9 +483,9 @@ type CustomLogger struct { func (l *CustomLogger) LogRoundTrip( req *http.Request, res *http.Response, - err error, - start time.Time, - dur time.Duration, + _ error, + _ time.Time, + _ time.Duration, ) error { fmt.Fprintln(l.Output, req.Method, req.URL, "->", res.Status) return nil diff --git a/opensearchtransport/metrics.go b/opensearchtransport/metrics.go index caef13e..7a8252c 100644 --- a/opensearchtransport/metrics.go +++ b/opensearchtransport/metrics.go @@ -36,19 +36,16 @@ import ( ) // Measurable defines the interface for transports supporting metrics. -// type Measurable interface { Metrics() (Metrics, error) } // connectionable defines the interface for transports returning a list of connections. -// type connectionable interface { connections() []*Connection } // Metrics represents the transport metrics. -// type Metrics struct { Requests int `json:"requests"` Failures int `json:"failures"` @@ -58,7 +55,6 @@ type Metrics struct { } // ConnectionMetric represents metric information for a connection. -// type ConnectionMetric struct { URL string `json:"url"` Failures int `json:"failures,omitempty"` @@ -73,19 +69,15 @@ type ConnectionMetric struct { } // metrics represents the inner state of metrics. -// type metrics struct { sync.RWMutex requests int failures int responses map[int]int - - connections []*Connection } // Metrics returns the transport metrics. -// func (c *Client) Metrics() (Metrics, error) { if c.metrics == nil { return Metrics{}, errors.New("transport metrics not enabled") @@ -139,7 +131,6 @@ func (c *Client) Metrics() (Metrics, error) { } // String returns the metrics as a string. -// func (m Metrics) String() string { var ( i int @@ -175,7 +166,6 @@ func (m Metrics) String() string { if i+1 < len(m.Connections) { b.WriteString(", ") } - i++ } b.WriteString("]") @@ -184,7 +174,6 @@ func (m Metrics) String() string { } // String returns the connection information as a string. -// func (cm ConnectionMetric) String() string { var b strings.Builder b.WriteString("{") diff --git a/opensearchtransport/metrics_internal_test.go b/opensearchtransport/metrics_internal_test.go index 6097015..d0265e5 100644 --- a/opensearchtransport/metrics_internal_test.go +++ b/opensearchtransport/metrics_internal_test.go @@ -24,7 +24,7 @@ // specific language governing permissions and limitations // under the License. -// +build !integration +//go:build !integration package opensearchtransport @@ -56,8 +56,11 @@ func TestMetrics(t *testing.T) { tp.metrics.responses[200] = 1 tp.metrics.responses[404] = 2 - req, _ := http.NewRequest("HEAD", "/", nil) - tp.Perform(req) + req, _ := http.NewRequest(http.MethodHead, "/", nil) + resp, err := tp.Perform(req) + if err == nil { + defer resp.Body.Close() + } m, err := tp.Metrics() if err != nil { diff --git a/opensearchtransport/opensearchtransport.go b/opensearchtransport/opensearchtransport.go index fe8e450..199d530 100644 --- a/opensearchtransport/opensearchtransport.go +++ b/opensearchtransport/opensearchtransport.go @@ -33,46 +33,27 @@ import ( "errors" "fmt" "io" - "io/ioutil" "net" "net/http" "net/url" "os" "regexp" "runtime" - "strconv" "strings" "sync" "time" - "github.com/opensearch-project/opensearch-go/v2/signer" - "github.com/opensearch-project/opensearch-go/v2/internal/version" + "github.com/opensearch-project/opensearch-go/v2/signer" ) const ( // Version returns the package version as a string. - Version = version.Client - - // esCompatHeader defines the env var for Compatibility header. - esCompatHeader = "ELASTIC_CLIENT_APIVERSIONING" -) - -var ( - userAgent string - compatibilityHeader bool - reGoVersion = regexp.MustCompile(`go(\d+\.\d+\..+)`) - - defaultMaxRetries = 3 - defaultRetryOnStatus = [...]int{502, 503, 504} + Version = version.Client + defaultMaxRetries = 3 ) -func init() { - userAgent = initUserAgent() - - compatHeaderEnv := os.Getenv(esCompatHeader) - compatibilityHeader, _ = strconv.ParseBool(compatHeaderEnv) -} +var reGoVersion = regexp.MustCompile(`go(\d+\.\d+\..+)`) // Interface defines the interface for HTTP client. type Interface interface { @@ -114,10 +95,11 @@ type Config struct { type Client struct { sync.Mutex - urls []*url.URL - username string - password string - header http.Header + urls []*url.URL + username string + password string + header http.Header + userAgent string signer signer.Signer @@ -164,17 +146,17 @@ func New(cfg Config) (*Client, error) { cfg.Transport = httpTransport } - if len(cfg.RetryOnStatus) == 0 { - cfg.RetryOnStatus = defaultRetryOnStatus[:] + if len(cfg.RetryOnStatus) == 0 && cfg.RetryOnStatus == nil { + cfg.RetryOnStatus = []int{502, 503, 504} } if cfg.MaxRetries == 0 { cfg.MaxRetries = defaultMaxRetries } - var conns []*Connection - for _, u := range cfg.URLs { - conns = append(conns, &Connection{URL: u}) + conns := make([]*Connection, len(cfg.URLs)) + for idx, u := range cfg.URLs { + conns[idx] = &Connection{URL: u} } client := Client{ @@ -200,10 +182,12 @@ func New(cfg Config) (*Client, error) { poolFunc: cfg.ConnectionPoolFunc, } + client.userAgent = initUserAgent() + if client.poolFunc != nil { client.pool = client.poolFunc(conns, client.selector) } else { - client.pool, _ = NewConnectionPool(conns, client.selector) + client.pool = NewConnectionPool(conns, client.selector) } if cfg.EnableDebugLogger { @@ -223,7 +207,7 @@ func New(cfg Config) (*Client, error) { if client.discoverNodesInterval > 0 { time.AfterFunc(client.discoverNodesInterval, func() { - client.scheduleDiscoverNodes(client.discoverNodesInterval) + client.scheduleDiscoverNodes() }) } @@ -237,14 +221,6 @@ func (c *Client) Perform(req *http.Request) (*http.Response, error) { err error ) - // Compatibility Header - if compatibilityHeader { - if req.Body != nil { - req.Header.Set("Content-Type", "application/vnd.elasticsearch+json;compatible-with=7") - } - req.Header.Set("Accept", "application/vnd.elasticsearch+json;compatible-with=7") - } - // Record metrics, when enabled if c.metrics != nil { c.metrics.Lock() @@ -261,30 +237,31 @@ func (c *Client) Perform(req *http.Request) (*http.Response, error) { var buf bytes.Buffer zw := gzip.NewWriter(&buf) if _, err := io.Copy(zw, req.Body); err != nil { - return nil, fmt.Errorf("failed to compress request body: %s", err) + return nil, fmt.Errorf("failed to compress request body: %w", err) } if err := zw.Close(); err != nil { - return nil, fmt.Errorf("failed to compress request body (during close): %s", err) + return nil, fmt.Errorf("failed to compress request body (during close): %w", err) } req.GetBody = func() (io.ReadCloser, error) { r := buf - return ioutil.NopCloser(&r), nil + return io.NopCloser(&r), nil } + //nolint:errcheck // error is always nil req.Body, _ = req.GetBody() req.Header.Set("Content-Encoding", "gzip") req.ContentLength = int64(buf.Len()) - } else if req.GetBody == nil { if !c.disableRetry || (c.logger != nil && c.logger.RequestBodyEnabled()) { var buf bytes.Buffer + //nolint:errcheck // ignored as this is only for logging buf.ReadFrom(req.Body) - req.GetBody = func() (io.ReadCloser, error) { r := buf - return ioutil.NopCloser(&r), nil + return io.NopCloser(&r), nil } + //nolint:errcheck // error is always nil req.Body, _ = req.GetBody() } } @@ -305,7 +282,7 @@ func (c *Client) Perform(req *http.Request) (*http.Response, error) { if c.logger != nil { c.logRoundTrip(req, nil, err, time.Time{}, time.Duration(0)) } - return nil, fmt.Errorf("cannot get connection: %s", err) + return nil, fmt.Errorf("cannot get connection: %w", err) } // Update request @@ -313,13 +290,13 @@ func (c *Client) Perform(req *http.Request) (*http.Response, error) { c.setReqAuth(conn.URL, req) if err = c.signRequest(req); err != nil { - return nil, fmt.Errorf("failed to sign request: %s", err) + return nil, fmt.Errorf("failed to sign request: %w", err) } if !c.disableRetry && i > 0 && req.Body != nil && req.Body != http.NoBody { body, err := req.GetBody() if err != nil { - return nil, fmt.Errorf("cannot get request body: %s", err) + return nil, fmt.Errorf("cannot get request body: %w", err) } req.Body = body } @@ -332,6 +309,7 @@ func (c *Client) Perform(req *http.Request) (*http.Response, error) { // Log request and response if c.logger != nil { if c.logger.RequestBodyEnabled() && req.Body != nil && req.Body != http.NoBody { + //nolint:errcheck // ignored as this is only for logging req.Body, _ = req.GetBody() } c.logRoundTrip(req, res, err, start, dur) @@ -347,17 +325,19 @@ func (c *Client) Perform(req *http.Request) (*http.Response, error) { // Report the connection as unsuccessful c.Lock() + //nolint:errcheck // Questionable if the function even returns an error c.pool.OnFailure(conn) c.Unlock() // Retry on EOF errors - if err == io.EOF { + if errors.Is(err, io.EOF) { shouldRetry = true } // Retry on network errors, but not on timeout errors, unless configured - if err, ok := err.(net.Error); ok { - if (!err.Timeout() || c.enableRetryOnTimeout) && !c.disableRetry { + var netError net.Error + if errors.As(err, &netError) { + if (!netError.Timeout() || c.enableRetryOnTimeout) && !c.disableRetry { shouldRetry = true } } @@ -392,7 +372,8 @@ func (c *Client) Perform(req *http.Request) (*http.Response, error) { // Drain and close body when retrying after response if shouldCloseBody && i < c.maxRetries { if res.Body != nil { - io.Copy(ioutil.Discard, res.Body) + //nolint:errcheck // undexpected but okay if it failes + io.Copy(io.Discard, res.Body) res.Body.Close() } } @@ -402,7 +383,7 @@ 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 + // Read, close and replace the http response body to close the connection if res != nil && res.Body != nil { body, err := io.ReadAll(res.Body) res.Body.Close() @@ -420,7 +401,7 @@ func (c *Client) URLs() []*url.URL { return c.pool.URLs() } -func (c *Client) setReqURL(u *url.URL, req *http.Request) *http.Request { +func (c *Client) setReqURL(u *url.URL, req *http.Request) { req.URL.Scheme = u.Scheme req.URL.Host = u.Host @@ -431,25 +412,21 @@ func (c *Client) setReqURL(u *url.URL, req *http.Request) *http.Request { b.WriteString(req.URL.Path) req.URL.Path = b.String() } - - return req } -func (c *Client) setReqAuth(u *url.URL, req *http.Request) *http.Request { +func (c *Client) setReqAuth(u *url.URL, req *http.Request) { if _, ok := req.Header["Authorization"]; !ok { if u.User != nil { password, _ := u.User.Password() req.SetBasicAuth(u.User.Username(), password) - return req + return } if c.username != "" && c.password != "" { req.SetBasicAuth(c.username, c.password) - return req + return } } - - return req } func (c *Client) signRequest(req *http.Request) error { @@ -459,12 +436,11 @@ func (c *Client) signRequest(req *http.Request) error { return nil } -func (c *Client) setReqUserAgent(req *http.Request) *http.Request { - req.Header.Set("User-Agent", userAgent) - return req +func (c *Client) setReqUserAgent(req *http.Request) { + req.Header.Set("User-Agent", c.userAgent) } -func (c *Client) setReqGlobalHeader(req *http.Request) *http.Request { +func (c *Client) setReqGlobalHeader(req *http.Request) { if len(c.header) > 0 { for k, v := range c.header { if req.Header.Get(k) != k { @@ -474,7 +450,6 @@ func (c *Client) setReqGlobalHeader(req *http.Request) *http.Request { } } } - return req } func (c *Client) logRoundTrip( @@ -488,14 +463,18 @@ func (c *Client) logRoundTrip( if res != nil { dupRes = *res } + if c.logger.ResponseBodyEnabled() { if res != nil && res.Body != nil && res.Body != http.NoBody { + //nolint:errcheck // ignored as this is only for logging b1, b2, _ := duplicateBody(res.Body) dupRes.Body = b1 res.Body = b2 } } - c.logger.LogRoundTrip(req, &dupRes, err, start, dur) // errcheck exclude + + //nolint:errcheck // ignored as this is only for logging + c.logger.LogRoundTrip(req, &dupRes, err, start, dur) } func initUserAgent() string { diff --git a/opensearchtransport/opensearchtransport_benchmark_test.go b/opensearchtransport/opensearchtransport_benchmark_test.go index 6730cab..977b3e5 100644 --- a/opensearchtransport/opensearchtransport_benchmark_test.go +++ b/opensearchtransport/opensearchtransport_benchmark_test.go @@ -24,12 +24,13 @@ // specific language governing permissions and limitations // under the License. -// +build !integration +//go:build !integration package opensearchtransport_test import ( - "io/ioutil" + "fmt" + "io" "net/http" "net/url" "strings" @@ -38,24 +39,24 @@ import ( "github.com/opensearch-project/opensearch-go/v2/opensearchtransport" ) -var defaultResponse = http.Response{ - Status: "200 OK", - StatusCode: 200, - ContentLength: 13, - Header: http.Header(map[string][]string{"Content-Type": {"application/json"}}), - Body: ioutil.NopCloser(strings.NewReader(`{"foo":"bar"}`)), -} - type FakeTransport struct { FakeResponse *http.Response } -func (t *FakeTransport) RoundTrip(req *http.Request) (*http.Response, error) { +func (t *FakeTransport) RoundTrip(_ *http.Request) (*http.Response, error) { return t.FakeResponse, nil } -func newFakeTransport(b *testing.B) *FakeTransport { - return &FakeTransport{FakeResponse: &defaultResponse} +func newFakeTransport(_ *testing.B) *FakeTransport { + return &FakeTransport{ + FakeResponse: &http.Response{ + Status: fmt.Sprintf("%d %s", http.StatusOK, http.StatusText(http.StatusOK)), + StatusCode: http.StatusOK, + ContentLength: 13, + Header: http.Header(map[string][]string{"Content-Type": {"application/json"}}), + Body: io.NopCloser(strings.NewReader(`{"foo":"bar"}`)), + }, + } } func BenchmarkTransport(b *testing.B) { @@ -68,11 +69,12 @@ func BenchmarkTransport(b *testing.B) { Transport: newFakeTransport(b), }) - req, _ := http.NewRequest("GET", "/abc", nil) - _, err := tp.Perform(req) + req, _ := http.NewRequest(http.MethodGet, "/abc", nil) + res, err := tp.Perform(req) if err != nil { b.Fatalf("Unexpected error: %s", err) } + defer res.Body.Close() } }) @@ -87,11 +89,12 @@ func BenchmarkTransport(b *testing.B) { Transport: newFakeTransport(b), }) - req, _ := http.NewRequest("GET", "/abc", nil) - _, err := tp.Perform(req) + req, _ := http.NewRequest(http.MethodGet, "/abc", nil) + res, err := tp.Perform(req) if err != nil { b.Fatalf("Unexpected error: %s", err) } + defer res.Body.Close() } }) } diff --git a/opensearchtransport/opensearchtransport_integration_multinode_test.go b/opensearchtransport/opensearchtransport_integration_multinode_test.go index d8dcb5b..3173edc 100644 --- a/opensearchtransport/opensearchtransport_integration_multinode_test.go +++ b/opensearchtransport/opensearchtransport_integration_multinode_test.go @@ -24,7 +24,7 @@ // specific language governing permissions and limitations // under the License. -// +build integration,multinode +//go:build integration && multinode package opensearchtransport_test diff --git a/opensearchtransport/opensearchtransport_integration_test.go b/opensearchtransport/opensearchtransport_integration_test.go index bb9876a..614c71e 100644 --- a/opensearchtransport/opensearchtransport_integration_test.go +++ b/opensearchtransport/opensearchtransport_integration_test.go @@ -25,7 +25,6 @@ // under the License. //go:build integration -// +build integration package opensearchtransport_test diff --git a/opensearchtransport/opensearchtransport_internal_test.go b/opensearchtransport/opensearchtransport_internal_test.go index 8e3a327..fbe1f26 100644 --- a/opensearchtransport/opensearchtransport_internal_test.go +++ b/opensearchtransport/opensearchtransport_internal_test.go @@ -24,7 +24,7 @@ // specific language governing permissions and limitations // under the License. -// +build !integration +//go:build !integration package opensearchtransport @@ -33,7 +33,6 @@ import ( "compress/gzip" "fmt" "io" - "io/ioutil" "math/rand" "net/http" "net/url" @@ -43,12 +42,10 @@ import ( "time" ) -var ( - _ = fmt.Print -) +var _ = fmt.Print func init() { - rand.Seed(time.Now().Unix()) + rand.New(rand.NewSource(time.Now().Unix())).Uint64() } type mockTransp struct { @@ -96,13 +93,15 @@ func TestTransport(t *testing.T) { }) t.Run("Custom", func(t *testing.T) { - tp, _ := New(Config{ - URLs: []*url.URL{{}}, - Transport: &mockTransp{ - RoundTripFunc: func(req *http.Request) (*http.Response, error) { return &http.Response{Status: "MOCK"}, nil }, + tp, _ := New( + Config{ + URLs: []*url.URL{{}}, + Transport: &mockTransp{ + RoundTripFunc: func(req *http.Request) (*http.Response, error) { return &http.Response{Status: "MOCK"}, nil }, + }, }, - }) - + ) + //nolint:bodyclose // Mock response does not have a body to close res, err := tp.transport.RoundTrip(&http.Request{URL: &url.URL{}}) if err != nil { t.Fatalf("Unexpected error: %s", err) @@ -240,7 +239,7 @@ func (cp *CustomConnectionPool) Next() (*Connection, error) { } func (cp *CustomConnectionPool) OnFailure(c *Connection) error { - var index = -1 + index := -1 for i, u := range cp.urls { if u == c.URL { index = i @@ -252,8 +251,8 @@ func (cp *CustomConnectionPool) OnFailure(c *Connection) error { } return fmt.Errorf("connection not found") } -func (cp *CustomConnectionPool) OnSuccess(c *Connection) error { return nil } -func (cp *CustomConnectionPool) URLs() []*url.URL { return cp.urls } +func (cp *CustomConnectionPool) OnSuccess(_ *Connection) {} +func (cp *CustomConnectionPool) URLs() []*url.URL { return cp.urls } func TestTransportCustomConnectionPool(t *testing.T) { t.Run("Run", func(t *testing.T) { @@ -291,14 +290,18 @@ func TestTransportCustomConnectionPool(t *testing.T) { func TestTransportPerform(t *testing.T) { t.Run("Executes", func(t *testing.T) { u, _ := url.Parse("https://foo.com/bar") - tp, _ := New(Config{ - URLs: []*url.URL{u}, - Transport: &mockTransp{ - RoundTripFunc: func(req *http.Request) (*http.Response, error) { return &http.Response{Status: "MOCK"}, nil }, - }}) + tp, _ := New( + Config{ + URLs: []*url.URL{u}, + Transport: &mockTransp{ + RoundTripFunc: func(req *http.Request) (*http.Response, error) { return &http.Response{Status: "MOCK"}, nil }, + }, + }, + ) - req, _ := http.NewRequest("GET", "/abc", nil) + req, _ := http.NewRequest(http.MethodGet, "/abc", nil) + //nolint:bodyclose // Mock response does not have a body to close res, err := tp.Perform(req) if err != nil { t.Fatalf("Unexpected error: %s", err) @@ -313,7 +316,7 @@ func TestTransportPerform(t *testing.T) { u, _ := url.Parse("https://foo.com/bar") tp, _ := New(Config{URLs: []*url.URL{u}}) - req, _ := http.NewRequest("GET", "/abc", nil) + req, _ := http.NewRequest(http.MethodGet, "/abc", nil) tp.setReqURL(u, req) expected := "https://foo.com/bar/abc" @@ -327,7 +330,7 @@ func TestTransportPerform(t *testing.T) { u, _ := url.Parse("https://foo:bar@example.com") tp, _ := New(Config{URLs: []*url.URL{u}}) - req, _ := http.NewRequest("GET", "/", nil) + req, _ := http.NewRequest(http.MethodGet, "/", nil) tp.setReqAuth(u, req) username, password, ok := req.BasicAuth() @@ -344,7 +347,7 @@ func TestTransportPerform(t *testing.T) { u, _ := url.Parse("http://example.com") tp, _ := New(Config{URLs: []*url.URL{u}, Username: "foo", Password: "bar"}) - req, _ := http.NewRequest("GET", "/", nil) + req, _ := http.NewRequest(http.MethodGet, "/", nil) tp.setReqAuth(u, req) username, password, ok := req.BasicAuth() @@ -361,7 +364,7 @@ func TestTransportPerform(t *testing.T) { u, _ := url.Parse("http://example.com") tp, _ := New(Config{URLs: []*url.URL{u}}) - req, _ := http.NewRequest("GET", "/abc", nil) + req, _ := http.NewRequest(http.MethodGet, "/abc", nil) tp.setReqUserAgent(req) if !strings.HasPrefix(req.UserAgent(), "opensearch-go") { @@ -377,7 +380,7 @@ func TestTransportPerform(t *testing.T) { { // Set the global HTTP header - req, _ := http.NewRequest("GET", "/abc", nil) + req, _ := http.NewRequest(http.MethodGet, "/abc", nil) tp.setReqGlobalHeader(req) if req.Header.Get("X-Foo") != "bar" { @@ -387,7 +390,7 @@ func TestTransportPerform(t *testing.T) { { // Do NOT overwrite an existing request header - req, _ := http.NewRequest("GET", "/abc", nil) + req, _ := http.NewRequest(http.MethodGet, "/abc", nil) req.Header.Set("X-Foo", "baz") tp.setReqGlobalHeader(req) @@ -409,7 +412,7 @@ func TestTransportPerform(t *testing.T) { }, ) - req, _ := http.NewRequest("GET", "/", nil) + req, _ := http.NewRequest(http.MethodGet, "/", nil) tp.signRequest(req) if _, ok := req.Header["Sign-Status"]; !ok { @@ -418,14 +421,18 @@ func TestTransportPerform(t *testing.T) { }) t.Run("Error No URL", func(t *testing.T) { - tp, _ := New(Config{ - URLs: []*url.URL{}, - Transport: &mockTransp{ - RoundTripFunc: func(req *http.Request) (*http.Response, error) { return &http.Response{Status: "MOCK"}, nil }, - }}) + tp, _ := New( + Config{ + URLs: []*url.URL{}, + Transport: &mockTransp{ + RoundTripFunc: func(req *http.Request) (*http.Response, error) { return &http.Response{Status: "MOCK"}, nil }, + }, + }, + ) - req, _ := http.NewRequest("GET", "/abc", nil) + req, _ := http.NewRequest(http.MethodGet, "/abc", nil) + //nolint:bodyclose // Mock response does not have a body to close _, err := tp.Perform(req) if err.Error() != `cannot get connection: no connection available` { t.Fatalf("Expected error `cannot get URL`: but got error %q", err) @@ -441,25 +448,28 @@ func TestTransportPerformRetries(t *testing.T) { ) u, _ := url.Parse("http://foo.bar") - tp, _ := New(Config{ - URLs: []*url.URL{u, u, u}, - Transport: &mockTransp{ - RoundTripFunc: func(req *http.Request) (*http.Response, error) { - i++ - fmt.Printf("Request #%d", i) - if i == numReqs { - fmt.Print(": OK\n") - return &http.Response{Status: "OK"}, nil - } - fmt.Print(": ERR\n") - return nil, &mockNetError{error: fmt.Errorf("Mock network error (%d)", i)} + tp, _ := New( + Config{ + URLs: []*url.URL{u, u, u}, + Transport: &mockTransp{ + RoundTripFunc: func(req *http.Request) (*http.Response, error) { + i++ + fmt.Printf("Request #%d", i) + if i == numReqs { + fmt.Print(": OK\n") + return &http.Response{Status: "OK"}, nil + } + fmt.Print(": ERR\n") + return nil, &mockNetError{error: fmt.Errorf("Mock network error (%d)", i)} + }, }, - }}) + }, + ) - req, _ := http.NewRequest("GET", "/abc", nil) + req, _ := http.NewRequest(http.MethodGet, "/abc", nil) + //nolint:bodyclose // Mock response does not have a body to close res, err := tp.Perform(req) - if err != nil { t.Fatalf("Unexpected error: %s", err) } @@ -480,25 +490,28 @@ func TestTransportPerformRetries(t *testing.T) { ) u, _ := url.Parse("http://foo.bar") - tp, _ := New(Config{ - URLs: []*url.URL{u, u, u}, - Transport: &mockTransp{ - RoundTripFunc: func(req *http.Request) (*http.Response, error) { - i++ - fmt.Printf("Request #%d", i) - if i == numReqs { - fmt.Print(": OK\n") - return &http.Response{Status: "OK"}, nil - } - fmt.Print(": ERR\n") - return nil, io.EOF + tp, _ := New( + Config{ + URLs: []*url.URL{u, u, u}, + Transport: &mockTransp{ + RoundTripFunc: func(req *http.Request) (*http.Response, error) { + i++ + fmt.Printf("Request #%d", i) + if i == numReqs { + fmt.Print(": OK\n") + return &http.Response{Status: "OK"}, nil + } + fmt.Print(": ERR\n") + return nil, io.EOF + }, }, - }}) + }, + ) - req, _ := http.NewRequest("GET", "/abc", nil) + req, _ := http.NewRequest(http.MethodGet, "/abc", nil) + //nolint:bodyclose // Mock response does not have a body to close res, err := tp.Perform(req) - if err != nil { t.Fatalf("Unexpected error: %s", err) } @@ -519,30 +532,33 @@ func TestTransportPerformRetries(t *testing.T) { ) u, _ := url.Parse("http://foo.bar") - tp, _ := New(Config{ - URLs: []*url.URL{u, u, u}, - Transport: &mockTransp{ - RoundTripFunc: func(req *http.Request) (*http.Response, error) { - i++ - fmt.Printf("Request #%d", i) - if i == numReqs { - fmt.Print(": 200\n") - return &http.Response{StatusCode: 200}, nil - } - fmt.Print(": 502\n") - return &http.Response{StatusCode: 502}, nil + tp, _ := New( + Config{ + URLs: []*url.URL{u, u, u}, + Transport: &mockTransp{ + RoundTripFunc: func(req *http.Request) (*http.Response, error) { + i++ + fmt.Printf("Request #%d", i) + if i == numReqs { + fmt.Print(": 200\n") + return &http.Response{StatusCode: http.StatusOK}, nil + } + fmt.Print(": 502\n") + return &http.Response{StatusCode: http.StatusBadGateway}, nil + }, }, - }}) + }, + ) - req, _ := http.NewRequest("GET", "/abc", nil) + req, _ := http.NewRequest(http.MethodGet, "/abc", nil) + //nolint:bodyclose // Mock response does not have a body to close res, err := tp.Perform(req) - if err != nil { t.Fatalf("Unexpected error: %s", err) } - if res.StatusCode != 200 { + if res.StatusCode != http.StatusOK { t.Errorf("Unexpected response: %+v", res) } @@ -558,23 +574,25 @@ func TestTransportPerformRetries(t *testing.T) { ) u, _ := url.Parse("http://foo.bar") - tp, _ := New(Config{ - URLs: []*url.URL{u, u, u}, - MaxRetries: numReqs, - Transport: &mockTransp{ - RoundTripFunc: func(req *http.Request) (*http.Response, error) { - i++ - fmt.Printf("Request #%d", i) - fmt.Print(": 502\n") - body := ioutil.NopCloser(strings.NewReader(`MOCK`)) - return &http.Response{StatusCode: 502, Body: body}, nil + tp, _ := New( + Config{ + URLs: []*url.URL{u, u, u}, + MaxRetries: numReqs, + Transport: &mockTransp{ + RoundTripFunc: func(req *http.Request) (*http.Response, error) { + i++ + fmt.Printf("Request #%d", i) + fmt.Print(": 502\n") + body := io.NopCloser(strings.NewReader(`MOCK`)) + return &http.Response{StatusCode: http.StatusBadGateway, Body: body}, nil + }, }, - }}) + }, + ) - req, _ := http.NewRequest("GET", "/", nil) + req, _ := http.NewRequest(http.MethodGet, "/", nil) res, err := tp.Perform(req) - if err != nil { t.Fatalf("Unexpected error: %s", err) } @@ -583,11 +601,11 @@ func TestTransportPerformRetries(t *testing.T) { t.Errorf("Unexpected number of requests, want=%d, got=%d", numReqs, i) } - if res.StatusCode != 502 { + if res.StatusCode != http.StatusBadGateway { t.Errorf("Unexpected response: %+v", res) } - resBody, _ := ioutil.ReadAll(res.Body) + resBody, _ := io.ReadAll(res.Body) res.Body.Close() if string(resBody) != "MOCK" { @@ -602,21 +620,24 @@ func TestTransportPerformRetries(t *testing.T) { ) u, _ := url.Parse("http://foo.bar") - tp, _ := New(Config{ - URLs: []*url.URL{u, u, u}, - Transport: &mockTransp{ - RoundTripFunc: func(req *http.Request) (*http.Response, error) { - i++ - fmt.Printf("Request #%d", i) - fmt.Print(": ERR\n") - return nil, &mockNetError{error: fmt.Errorf("Mock network error (%d)", i)} + tp, _ := New( + Config{ + URLs: []*url.URL{u, u, u}, + Transport: &mockTransp{ + RoundTripFunc: func(req *http.Request) (*http.Response, error) { + i++ + fmt.Printf("Request #%d", i) + fmt.Print(": ERR\n") + return nil, &mockNetError{error: fmt.Errorf("Mock network error (%d)", i)} + }, }, - }}) + }, + ) - req, _ := http.NewRequest("GET", "/abc", nil) + req, _ := http.NewRequest(http.MethodGet, "/abc", nil) + //nolint:bodyclose // Mock response does not have a body to close res, err := tp.Perform(req) - if err == nil { t.Fatalf("Expected error, got: %v", err) } @@ -634,21 +655,24 @@ func TestTransportPerformRetries(t *testing.T) { t.Run("Reset request body during retry", func(t *testing.T) { var bodies []string u, _ := url.Parse("https://foo.com/bar") - tp, _ := New(Config{ - URLs: []*url.URL{u}, - Transport: &mockTransp{ - RoundTripFunc: func(req *http.Request) (*http.Response, error) { - body, err := ioutil.ReadAll(req.Body) - if err != nil { - panic(err) - } - bodies = append(bodies, string(body)) - return &http.Response{Status: "MOCK", StatusCode: 502}, nil + tp, _ := New( + Config{ + URLs: []*url.URL{u}, + Transport: &mockTransp{ + RoundTripFunc: func(req *http.Request) (*http.Response, error) { + body, err := io.ReadAll(req.Body) + if err != nil { + panic(err) + } + bodies = append(bodies, string(body)) + return &http.Response{Status: "MOCK", StatusCode: http.StatusBadGateway}, nil + }, }, - }}, + }, ) - req, _ := http.NewRequest("POST", "/abc", strings.NewReader("FOOBAR")) + req, _ := http.NewRequest(http.MethodPost, "/abc", strings.NewReader("FOOBAR")) + //nolint:bodyclose // Mock response does not have a body to close res, err := tp.Perform(req) if err != nil { t.Fatalf("Unexpected error: %s", err) @@ -669,21 +693,24 @@ func TestTransportPerformRetries(t *testing.T) { var i int u, _ := url.Parse("http://foo.bar") - tp, _ := New(Config{ - URLs: []*url.URL{u, u, u}, - Transport: &mockTransp{ - RoundTripFunc: func(req *http.Request) (*http.Response, error) { - i++ - fmt.Printf("Request #%d", i) - fmt.Print(": ERR\n") - return nil, fmt.Errorf("Mock regular error (%d)", i) + tp, _ := New( + Config{ + URLs: []*url.URL{u, u, u}, + Transport: &mockTransp{ + RoundTripFunc: func(req *http.Request) (*http.Response, error) { + i++ + fmt.Printf("Request #%d", i) + fmt.Print(": ERR\n") + return nil, fmt.Errorf("Mock regular error (%d)", i) + }, }, - }}) + }, + ) - req, _ := http.NewRequest("GET", "/abc", nil) + req, _ := http.NewRequest(http.MethodGet, "/abc", nil) + //nolint:bodyclose // Mock response does not have a body to close res, err := tp.Perform(req) - if err == nil { t.Fatalf("Expected error, got: %v", err) } @@ -701,20 +728,23 @@ func TestTransportPerformRetries(t *testing.T) { var i int u, _ := url.Parse("http://foo.bar") - tp, _ := New(Config{ - URLs: []*url.URL{u, u, u}, - Transport: &mockTransp{ - RoundTripFunc: func(req *http.Request) (*http.Response, error) { - i++ - fmt.Printf("Request #%d", i) - fmt.Print(": ERR\n") - return nil, &mockNetError{error: fmt.Errorf("Mock network error (%d)", i)} + tp, _ := New( + Config{ + URLs: []*url.URL{u, u, u}, + Transport: &mockTransp{ + RoundTripFunc: func(req *http.Request) (*http.Response, error) { + i++ + fmt.Printf("Request #%d", i) + fmt.Print(": ERR\n") + return nil, &mockNetError{error: fmt.Errorf("Mock network error (%d)", i)} + }, }, + DisableRetry: true, }, - DisableRetry: true, - }) + ) - req, _ := http.NewRequest("GET", "/abc", nil) + req, _ := http.NewRequest(http.MethodGet, "/abc", nil) + //nolint:bodyclose // Mock response does not have a body to close tp.Perform(req) if i != 1 { @@ -756,11 +786,11 @@ func TestTransportPerformRetries(t *testing.T) { }, }) - req, _ := http.NewRequest("GET", "/abc", nil) + req, _ := http.NewRequest(http.MethodGet, "/abc", nil) + //nolint:bodyclose // Mock response does not have a body to close res, err := tp.Perform(req) end := time.Since(start) - if err != nil { t.Fatalf("Unexpected error: %s", err) } @@ -862,6 +892,7 @@ func TestMaxRetries(t *testing.T) { DisableRetry: test.disableRetry, }) + //nolint:bodyclose // Mock response does not have a body to close c.Perform(&http.Request{URL: &url.URL{}, Header: make(http.Header)}) // errcheck ignore if test.expectedCallCount != callCount { @@ -871,74 +902,7 @@ func TestMaxRetries(t *testing.T) { } } -func TestCompatibilityHeader(t *testing.T) { - tests := []struct { - name string - compatibilityHeader bool - bodyPresent bool - expectsHeader []string - }{ - { - name: "Compatibility header disabled", - compatibilityHeader: false, - bodyPresent: false, - expectsHeader: []string{"application/json"}, - }, - { - name: "Compatibility header enabled", - compatibilityHeader: true, - bodyPresent: false, - expectsHeader: []string{"application/vnd.elasticsearch+json;compatible-with=7"}, - }, - { - name: "Compatibility header enabled with body", - compatibilityHeader: true, - bodyPresent: true, - expectsHeader: []string{"application/vnd.elasticsearch+json;compatible-with=7"}, - }, - } - - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - compatibilityHeader = test.compatibilityHeader - - c, _ := New(Config{ - URLs: []*url.URL{{}}, - Transport: &mockTransp{ - RoundTripFunc: func(req *http.Request) (*http.Response, error) { - if test.compatibilityHeader { - if !reflect.DeepEqual(req.Header["Accept"], test.expectsHeader) { - t.Errorf("Compatibility header enabled but header is, not in request headers, got: %s, want: %s", req.Header["Accept"], test.expectsHeader) - } - } - if test.bodyPresent { - if !reflect.DeepEqual(req.Header["Content-Type"], test.expectsHeader) { - t.Errorf("Compatibility header with Body enabled, not in request headers, got: %s, want: %s", req.Header["Content-Type"], test.expectsHeader) - } - } - - return &http.Response{ - StatusCode: http.StatusOK, - Status: "MOCK", - }, nil - }, - }, - }) - - req := &http.Request{URL: &url.URL{}, Header: make(http.Header)} - if test.bodyPresent { - req.Body = ioutil.NopCloser(strings.NewReader("{}")) - } - - _, _ = c.Perform(req) - - compatibilityHeader = false - }) - } -} - func TestRequestCompression(t *testing.T) { - tests := []struct { name string compressionFlag bool @@ -978,7 +942,7 @@ func TestRequestCompression(t *testing.T) { var unBuf bytes.Buffer zr, err := gzip.NewReader(&buf) if err != nil { - return nil, fmt.Errorf("decompression error: %v", err) + return nil, fmt.Errorf("decompression error: %w", err) } unBuf.ReadFrom(zr) buf = unBuf @@ -993,8 +957,9 @@ func TestRequestCompression(t *testing.T) { }, }) - req, _ := http.NewRequest("POST", "/abc", bytes.NewBufferString(test.inputBody)) + req, _ := http.NewRequest(http.MethodPost, "/abc", bytes.NewBufferString(test.inputBody)) + //nolint:bodyclose // Mock response does not have a body to close res, err := tp.Perform(req) if err != nil { t.Fatalf("Unexpected error: %s", err) @@ -1008,7 +973,6 @@ func TestRequestCompression(t *testing.T) { } func TestRequestSigning(t *testing.T) { - t.Run("Sign request fails", func(t *testing.T) { u, _ := url.Parse("https://foo:bar@example.com") tp, _ := New( @@ -1024,7 +988,8 @@ func TestRequestSigning(t *testing.T) { }, }, ) - req, _ := http.NewRequest("GET", "/", nil) + req, _ := http.NewRequest(http.MethodGet, "/", nil) + //nolint:bodyclose // Mock response does not have a body to close _, err := tp.Perform(req) if err == nil { t.Fatal("Expected error, but, no error found") From c1e7c2221129f3f8b84ec1f1e6539f58735f5f05 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Aug 2023 11:30:07 -0700 Subject: [PATCH 71/84] Bump github.com/aws/aws-sdk-go-v2 from 1.19.0 to 1.20.0 (#356) * Bump github.com/aws/aws-sdk-go-v2 from 1.19.0 to 1.20.0 Bumps [github.com/aws/aws-sdk-go-v2](https://github.com/aws/aws-sdk-go-v2) from 1.19.0 to 1.20.0. - [Release notes](https://github.com/aws/aws-sdk-go-v2/releases) - [Changelog](https://github.com/aws/aws-sdk-go-v2/blob/main/CHANGELOG.md) - [Commits](https://github.com/aws/aws-sdk-go-v2/compare/v1.19.0...v1.20.0) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go-v2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * Update changelog Signed-off-by: dependabot[bot] --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] --- CHANGELOG.md | 4 ++-- go.mod | 2 +- go.sum | 6 ++++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dbdb36d..07726f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Dependencies - Bumps `github.com/aws/aws-sdk-go` from 1.44.180 to 1.44.307 -- Bumps `github.com/aws/aws-sdk-go-v2` from 1.17.4 to 1.18.1 +- Bumps `github.com/aws/aws-sdk-go-v2` from 1.17.4 to 1.20.0 - Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.8 to 1.18.28 - Bumps `github.com/stretchr/testify` from 1.8.1 to 1.8.4 @@ -57,4 +57,4 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Security -[Unreleased]: https://github.com/opensearch-project/opensearch-go/compare/v2.2.0...HEAD +[Unreleased]: https://github.com/opensearch-project/opensearch-go/compare/v2.2.0...HEAD \ No newline at end of file diff --git a/go.mod b/go.mod index be01ae7..b7d094d 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.15 require ( github.com/aws/aws-sdk-go v1.44.307 - github.com/aws/aws-sdk-go-v2 v1.19.0 + github.com/aws/aws-sdk-go-v2 v1.20.0 github.com/aws/aws-sdk-go-v2/config v1.18.28 github.com/kinbiko/jsonassert v1.1.1 github.com/stretchr/testify v1.8.4 diff --git a/go.sum b/go.sum index 571be5d..61364c4 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,8 @@ github.com/aws/aws-sdk-go v1.44.307 h1:2R0/EPgpZcFSUwZhYImq/srjaOrOfLv5MNRzrFyAM38= github.com/aws/aws-sdk-go v1.44.307/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= -github.com/aws/aws-sdk-go-v2 v1.19.0 h1:klAT+y3pGFBU/qVf1uzwttpBbiuozJYWzNLHioyDJ+k= github.com/aws/aws-sdk-go-v2 v1.19.0/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= +github.com/aws/aws-sdk-go-v2 v1.20.0 h1:INUDpYLt4oiPOJl0XwZDK2OVAVf0Rzo+MGVTv9f+gy8= +github.com/aws/aws-sdk-go-v2 v1.20.0/go.mod h1:uWOr0m0jDsiWw8nnXiqZ+YG6LdvAlGYDLLf2NmHZoy4= github.com/aws/aws-sdk-go-v2/config v1.18.28 h1:TINEaKyh1Td64tqFvn09iYpKiWjmHYrG1fa91q2gnqw= github.com/aws/aws-sdk-go-v2/config v1.18.28/go.mod h1:nIL+4/8JdAuNHEjn/gPEXqtnS02Q3NXB/9Z7o5xE4+A= github.com/aws/aws-sdk-go-v2/credentials v1.13.27 h1:dz0yr/yR1jweAnsCx+BmjerUILVPQ6FS5AwF/OyG1kA= @@ -22,8 +23,9 @@ github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.13 h1:BFubHS/xN5bjl818QaroN6m github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.13/go.mod h1:BzqsVVFduubEmzrVtUFQQIQdFqvUItF8XUq2EnS8Wog= github.com/aws/aws-sdk-go-v2/service/sts v1.19.3 h1:e5mnydVdCVWxP+5rPAGi2PYxC7u2OZgH1ypC114H04U= github.com/aws/aws-sdk-go-v2/service/sts v1.19.3/go.mod h1:yVGZA1CPkmUhBdA039jXNJJG7/6t+G+EBWmFq23xqnY= -github.com/aws/smithy-go v1.13.5 h1:hgz0X/DX0dGqTYpGALqXJoRKRj5oQ7150i5FdTePzO8= github.com/aws/smithy-go v1.13.5/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= +github.com/aws/smithy-go v1.14.0 h1:+X90sB94fizKjDmwb4vyl2cTTPXTE5E2G/1mjByb0io= +github.com/aws/smithy-go v1.14.0/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= From 4558e0c5714dee10acd60e7fff842e34d4b2f3db Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Aug 2023 18:30:57 +0000 Subject: [PATCH 72/84] Bump github.com/aws/aws-sdk-go from 1.44.307 to 1.44.313 Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.44.307 to 1.44.313. - [Release notes](https://github.com/aws/aws-sdk-go/releases) - [Commits](https://github.com/aws/aws-sdk-go/compare/v1.44.307...v1.44.313) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index b7d094d..5a2b978 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/opensearch-project/opensearch-go/v2 go 1.15 require ( - github.com/aws/aws-sdk-go v1.44.307 + github.com/aws/aws-sdk-go v1.44.313 github.com/aws/aws-sdk-go-v2 v1.20.0 github.com/aws/aws-sdk-go-v2/config v1.18.28 github.com/kinbiko/jsonassert v1.1.1 diff --git a/go.sum b/go.sum index 61364c4..418298b 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/aws/aws-sdk-go v1.44.307 h1:2R0/EPgpZcFSUwZhYImq/srjaOrOfLv5MNRzrFyAM38= -github.com/aws/aws-sdk-go v1.44.307/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= +github.com/aws/aws-sdk-go v1.44.313 h1:u6EuNQqgAmi09GEZ5g/XGHLF0XV31WcdU5rnHyIBHBc= +github.com/aws/aws-sdk-go v1.44.313/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go-v2 v1.19.0/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= github.com/aws/aws-sdk-go-v2 v1.20.0 h1:INUDpYLt4oiPOJl0XwZDK2OVAVf0Rzo+MGVTv9f+gy8= github.com/aws/aws-sdk-go-v2 v1.20.0/go.mod h1:uWOr0m0jDsiWw8nnXiqZ+YG6LdvAlGYDLLf2NmHZoy4= From f01a81215a2ef12a82862a6e096bf834cbc04635 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Tue, 1 Aug 2023 18:45:18 +0000 Subject: [PATCH 73/84] Update changelog Signed-off-by: dependabot[bot] --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 07726f0..6183188 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Dependencies -- Bumps `github.com/aws/aws-sdk-go` from 1.44.180 to 1.44.307 +- Bumps `github.com/aws/aws-sdk-go` from 1.44.180 to 1.44.313 - Bumps `github.com/aws/aws-sdk-go-v2` from 1.17.4 to 1.20.0 - Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.8 to 1.18.28 - Bumps `github.com/stretchr/testify` from 1.8.1 to 1.8.4 From e47cc523d5ec945cc207fd4d5f9815e97d0db2d5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 8 Aug 2023 11:19:03 -0700 Subject: [PATCH 74/84] Bump github.com/aws/aws-sdk-go-v2 from 1.20.0 to 1.20.1 (#361) * Bump github.com/aws/aws-sdk-go-v2 from 1.20.0 to 1.20.1 Bumps [github.com/aws/aws-sdk-go-v2](https://github.com/aws/aws-sdk-go-v2) from 1.20.0 to 1.20.1. - [Release notes](https://github.com/aws/aws-sdk-go-v2/releases) - [Commits](https://github.com/aws/aws-sdk-go-v2/compare/v1.20.0...v1.20.1) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go-v2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Update changelog Signed-off-by: dependabot[bot] --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] --- CHANGELOG.md | 2 +- go.mod | 2 +- go.sum | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6183188..a43f0aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Dependencies - Bumps `github.com/aws/aws-sdk-go` from 1.44.180 to 1.44.313 -- Bumps `github.com/aws/aws-sdk-go-v2` from 1.17.4 to 1.20.0 +- Bumps `github.com/aws/aws-sdk-go-v2` from 1.17.4 to 1.20.1 - Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.8 to 1.18.28 - Bumps `github.com/stretchr/testify` from 1.8.1 to 1.8.4 diff --git a/go.mod b/go.mod index 5a2b978..9ea393a 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.15 require ( github.com/aws/aws-sdk-go v1.44.313 - github.com/aws/aws-sdk-go-v2 v1.20.0 + github.com/aws/aws-sdk-go-v2 v1.20.1 github.com/aws/aws-sdk-go-v2/config v1.18.28 github.com/kinbiko/jsonassert v1.1.1 github.com/stretchr/testify v1.8.4 diff --git a/go.sum b/go.sum index 418298b..ca31dae 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,8 @@ github.com/aws/aws-sdk-go v1.44.313 h1:u6EuNQqgAmi09GEZ5g/XGHLF0XV31WcdU5rnHyIBHBc= github.com/aws/aws-sdk-go v1.44.313/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go-v2 v1.19.0/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= -github.com/aws/aws-sdk-go-v2 v1.20.0 h1:INUDpYLt4oiPOJl0XwZDK2OVAVf0Rzo+MGVTv9f+gy8= -github.com/aws/aws-sdk-go-v2 v1.20.0/go.mod h1:uWOr0m0jDsiWw8nnXiqZ+YG6LdvAlGYDLLf2NmHZoy4= +github.com/aws/aws-sdk-go-v2 v1.20.1 h1:rZBf5DWr7YGrnlTK4kgDQGn1ltqOg5orCYb/UhOFZkg= +github.com/aws/aws-sdk-go-v2 v1.20.1/go.mod h1:NU06lETsFm8fUC6ZjhgDpVBcGZTFQ6XM+LZWZxMI4ac= github.com/aws/aws-sdk-go-v2/config v1.18.28 h1:TINEaKyh1Td64tqFvn09iYpKiWjmHYrG1fa91q2gnqw= github.com/aws/aws-sdk-go-v2/config v1.18.28/go.mod h1:nIL+4/8JdAuNHEjn/gPEXqtnS02Q3NXB/9Z7o5xE4+A= github.com/aws/aws-sdk-go-v2/credentials v1.13.27 h1:dz0yr/yR1jweAnsCx+BmjerUILVPQ6FS5AwF/OyG1kA= @@ -24,8 +24,8 @@ github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.13/go.mod h1:BzqsVVFduubEmzrV github.com/aws/aws-sdk-go-v2/service/sts v1.19.3 h1:e5mnydVdCVWxP+5rPAGi2PYxC7u2OZgH1ypC114H04U= github.com/aws/aws-sdk-go-v2/service/sts v1.19.3/go.mod h1:yVGZA1CPkmUhBdA039jXNJJG7/6t+G+EBWmFq23xqnY= github.com/aws/smithy-go v1.13.5/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= -github.com/aws/smithy-go v1.14.0 h1:+X90sB94fizKjDmwb4vyl2cTTPXTE5E2G/1mjByb0io= -github.com/aws/smithy-go v1.14.0/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= +github.com/aws/smithy-go v1.14.1 h1:EFKMUmH/iHMqLiwoEDx2rRjRQpI1YCn5jTysoaDujFs= +github.com/aws/smithy-go v1.14.1/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= From 3486b02058dcf210f75c3d05c71c24a61ded84af Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 8 Aug 2023 11:28:47 -0700 Subject: [PATCH 75/84] Bump github.com/aws/aws-sdk-go-v2/config from 1.18.28 to 1.18.33 (#360) * Bump github.com/aws/aws-sdk-go-v2/config from 1.18.28 to 1.18.33 Bumps [github.com/aws/aws-sdk-go-v2/config](https://github.com/aws/aws-sdk-go-v2) from 1.18.28 to 1.18.33. - [Release notes](https://github.com/aws/aws-sdk-go-v2/releases) - [Commits](https://github.com/aws/aws-sdk-go-v2/compare/config/v1.18.28...config/v1.18.33) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go-v2/config dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Update changelog Signed-off-by: dependabot[bot] --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] --- CHANGELOG.md | 2 +- go.mod | 2 +- go.sum | 42 ++++++++++++++++++++---------------------- 3 files changed, 22 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a43f0aa..5e0792a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Bumps `github.com/aws/aws-sdk-go` from 1.44.180 to 1.44.313 - Bumps `github.com/aws/aws-sdk-go-v2` from 1.17.4 to 1.20.1 -- Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.8 to 1.18.28 +- Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.8 to 1.18.33 - Bumps `github.com/stretchr/testify` from 1.8.1 to 1.8.4 ### Added diff --git a/go.mod b/go.mod index 9ea393a..001849c 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.15 require ( github.com/aws/aws-sdk-go v1.44.313 github.com/aws/aws-sdk-go-v2 v1.20.1 - github.com/aws/aws-sdk-go-v2/config v1.18.28 + github.com/aws/aws-sdk-go-v2/config v1.18.33 github.com/kinbiko/jsonassert v1.1.1 github.com/stretchr/testify v1.8.4 golang.org/x/net v0.7.0 // indirect diff --git a/go.sum b/go.sum index ca31dae..1214d0d 100644 --- a/go.sum +++ b/go.sum @@ -1,29 +1,27 @@ github.com/aws/aws-sdk-go v1.44.313 h1:u6EuNQqgAmi09GEZ5g/XGHLF0XV31WcdU5rnHyIBHBc= github.com/aws/aws-sdk-go v1.44.313/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= -github.com/aws/aws-sdk-go-v2 v1.19.0/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= github.com/aws/aws-sdk-go-v2 v1.20.1 h1:rZBf5DWr7YGrnlTK4kgDQGn1ltqOg5orCYb/UhOFZkg= github.com/aws/aws-sdk-go-v2 v1.20.1/go.mod h1:NU06lETsFm8fUC6ZjhgDpVBcGZTFQ6XM+LZWZxMI4ac= -github.com/aws/aws-sdk-go-v2/config v1.18.28 h1:TINEaKyh1Td64tqFvn09iYpKiWjmHYrG1fa91q2gnqw= -github.com/aws/aws-sdk-go-v2/config v1.18.28/go.mod h1:nIL+4/8JdAuNHEjn/gPEXqtnS02Q3NXB/9Z7o5xE4+A= -github.com/aws/aws-sdk-go-v2/credentials v1.13.27 h1:dz0yr/yR1jweAnsCx+BmjerUILVPQ6FS5AwF/OyG1kA= -github.com/aws/aws-sdk-go-v2/credentials v1.13.27/go.mod h1:syOqAek45ZXZp29HlnRS/BNgMIW6uiRmeuQsz4Qh2UE= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.5 h1:kP3Me6Fy3vdi+9uHd7YLr6ewPxRL+PU6y15urfTaamU= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.5/go.mod h1:Gj7tm95r+QsDoN2Fhuz/3npQvcZbkEf5mL70n3Xfluc= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.35 h1:hMUCiE3Zi5AHrRNGf5j985u0WyqI6r2NULhUfo0N/No= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.35/go.mod h1:ipR5PvpSPqIqL5Mi82BxLnfMkHVbmco8kUwO2xrCi0M= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.29 h1:yOpYx+FTBdpk/g+sBU6Cb1H0U/TLEcYYp66mYqsPpcc= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.29/go.mod h1:M/eUABlDbw2uVrdAn+UsI6M727qp2fxkp8K0ejcBDUY= -github.com/aws/aws-sdk-go-v2/internal/ini v1.3.36 h1:8r5m1BoAWkn0TDC34lUculryf7nUF25EgIMdjvGCkgo= -github.com/aws/aws-sdk-go-v2/internal/ini v1.3.36/go.mod h1:Rmw2M1hMVTwiUhjwMoIBFWFJMhvJbct06sSidxInkhY= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.29 h1:IiDolu/eLmuB18DRZibj77n1hHQT7z12jnGO7Ze3pLc= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.29/go.mod h1:fDbkK4o7fpPXWn8YAPmTieAMuB9mk/VgvW64uaUqxd4= -github.com/aws/aws-sdk-go-v2/service/sso v1.12.13 h1:sWDv7cMITPcZ21QdreULwxOOAmE05JjEsT6fCDtDA9k= -github.com/aws/aws-sdk-go-v2/service/sso v1.12.13/go.mod h1:DfX0sWuT46KpcqbMhJ9QWtxAIP1VozkDWf8VAkByjYY= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.13 h1:BFubHS/xN5bjl818QaroN6mQdjneYQ+AOx44KNXlyH4= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.13/go.mod h1:BzqsVVFduubEmzrVtUFQQIQdFqvUItF8XUq2EnS8Wog= -github.com/aws/aws-sdk-go-v2/service/sts v1.19.3 h1:e5mnydVdCVWxP+5rPAGi2PYxC7u2OZgH1ypC114H04U= -github.com/aws/aws-sdk-go-v2/service/sts v1.19.3/go.mod h1:yVGZA1CPkmUhBdA039jXNJJG7/6t+G+EBWmFq23xqnY= -github.com/aws/smithy-go v1.13.5/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= +github.com/aws/aws-sdk-go-v2/config v1.18.33 h1:JKcw5SFxFW/rpM4mOPjv0VQ11E2kxW13F3exWOy7VZU= +github.com/aws/aws-sdk-go-v2/config v1.18.33/go.mod h1:hXO/l9pgY3K5oZJldamP0pbZHdPqqk+4/maa7DSD3cA= +github.com/aws/aws-sdk-go-v2/credentials v1.13.32 h1:lIH1eKPcCY1ylR4B6PkBGRWMHO3aVenOKJHWiS4/G2w= +github.com/aws/aws-sdk-go-v2/credentials v1.13.32/go.mod h1:lL8U3v/Y79YRG69WlAho0OHIKUXCyFvSXaIvfo81sls= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.8 h1:DK/9C+UN/X+1+Wm8pqaDksQr2tSLzq+8X1/rI/ZxKEQ= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.8/go.mod h1:ce7BgLQfYr5hQFdy67oX2svto3ufGtm6oBvmsHScI1Q= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.38 h1:c8ed/T9T2K5I+h/JzmF5tpI46+OODQ74dzmdo+QnaMg= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.38/go.mod h1:qggunOChCMu9ZF/UkAfhTz25+U2rLVb3ya0Ua6TTfCA= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.32 h1:hNeAAymUY5gu11WrrmFb3CVIp9Dar9hbo44yzzcQpzA= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.32/go.mod h1:0ZXSqrty4FtQ7p8TEuRde/SZm9X05KT18LAUlR40Ln0= +github.com/aws/aws-sdk-go-v2/internal/ini v1.3.39 h1:fc0ukRAiP1syoSGZYu+DaE+FulSYhTiJ8WpVu5jElU4= +github.com/aws/aws-sdk-go-v2/internal/ini v1.3.39/go.mod h1:WLAW8PT7+JhjZfLSWe7WEJaJu0GNo0cKc2Zyo003RBs= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.32 h1:dGAseBFEYxth10V23b5e2mAS+tX7oVbfYHD6dnDdAsg= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.32/go.mod h1:4jwAWKEkCR0anWk5+1RbfSg1R5Gzld7NLiuaq5bTR/Y= +github.com/aws/aws-sdk-go-v2/service/sso v1.13.2 h1:A2RlEMo4SJSwbNoUUgkxTAEMduAy/8wG3eB2b2lP4gY= +github.com/aws/aws-sdk-go-v2/service/sso v1.13.2/go.mod h1:ju+nNXUunfIFamXUIZQiICjnO/TPlOmWcYhZcSy7xaE= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.15.2 h1:OJELEgyaT2kmaBGZ+myyZbTTLobfe3ox3FSh5eYK9Qs= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.15.2/go.mod h1:ubDBBaDFs1GHijSOTi8ljppML15GLG0HxhILtbjNNYQ= +github.com/aws/aws-sdk-go-v2/service/sts v1.21.2 h1:ympg1+Lnq33XLhcK/xTG4yZHPs1Oyxu+6DEWbl7qOzA= +github.com/aws/aws-sdk-go-v2/service/sts v1.21.2/go.mod h1:FQ/DQcOfESELfJi5ED+IPPAjI5xC6nxtSolVVB773jM= github.com/aws/smithy-go v1.14.1 h1:EFKMUmH/iHMqLiwoEDx2rRjRQpI1YCn5jTysoaDujFs= github.com/aws/smithy-go v1.14.1/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= From d057c247b542cd7bec9772b857015571b2f433e7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 8 Aug 2023 11:52:35 -0700 Subject: [PATCH 76/84] Bump github.com/aws/aws-sdk-go from 1.44.313 to 1.44.319 (#362) * Bump github.com/aws/aws-sdk-go from 1.44.313 to 1.44.319 Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.44.313 to 1.44.319. - [Release notes](https://github.com/aws/aws-sdk-go/releases) - [Commits](https://github.com/aws/aws-sdk-go/compare/v1.44.313...v1.44.319) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Update changelog Signed-off-by: dependabot[bot] --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] --- CHANGELOG.md | 2 +- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e0792a..c347af5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Dependencies -- Bumps `github.com/aws/aws-sdk-go` from 1.44.180 to 1.44.313 +- Bumps `github.com/aws/aws-sdk-go` from 1.44.180 to 1.44.319 - Bumps `github.com/aws/aws-sdk-go-v2` from 1.17.4 to 1.20.1 - Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.8 to 1.18.33 - Bumps `github.com/stretchr/testify` from 1.8.1 to 1.8.4 diff --git a/go.mod b/go.mod index 001849c..bb75e3b 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/opensearch-project/opensearch-go/v2 go 1.15 require ( - github.com/aws/aws-sdk-go v1.44.313 + github.com/aws/aws-sdk-go v1.44.319 github.com/aws/aws-sdk-go-v2 v1.20.1 github.com/aws/aws-sdk-go-v2/config v1.18.33 github.com/kinbiko/jsonassert v1.1.1 diff --git a/go.sum b/go.sum index 1214d0d..57cd7b6 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/aws/aws-sdk-go v1.44.313 h1:u6EuNQqgAmi09GEZ5g/XGHLF0XV31WcdU5rnHyIBHBc= -github.com/aws/aws-sdk-go v1.44.313/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= +github.com/aws/aws-sdk-go v1.44.319 h1:cwynvM8DBwWGzlINTZ6XLkGy5O99wZIS0197j3B61Fs= +github.com/aws/aws-sdk-go v1.44.319/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go-v2 v1.20.1 h1:rZBf5DWr7YGrnlTK4kgDQGn1ltqOg5orCYb/UhOFZkg= github.com/aws/aws-sdk-go-v2 v1.20.1/go.mod h1:NU06lETsFm8fUC6ZjhgDpVBcGZTFQ6XM+LZWZxMI4ac= github.com/aws/aws-sdk-go-v2/config v1.18.33 h1:JKcw5SFxFW/rpM4mOPjv0VQ11E2kxW13F3exWOy7VZU= From 403d8707e4fac60fab111ded1956065e8c97358c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 15 Aug 2023 11:16:35 -0400 Subject: [PATCH 77/84] Bump github.com/aws/aws-sdk-go from 1.44.319 to 1.44.323 (#363) * Bump github.com/aws/aws-sdk-go from 1.44.319 to 1.44.323 Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.44.319 to 1.44.323. - [Release notes](https://github.com/aws/aws-sdk-go/releases) - [Commits](https://github.com/aws/aws-sdk-go/compare/v1.44.319...v1.44.323) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Update changelog Signed-off-by: dependabot[bot] --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] --- CHANGELOG.md | 2 +- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c347af5..21a8371 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Dependencies -- Bumps `github.com/aws/aws-sdk-go` from 1.44.180 to 1.44.319 +- Bumps `github.com/aws/aws-sdk-go` from 1.44.180 to 1.44.323 - Bumps `github.com/aws/aws-sdk-go-v2` from 1.17.4 to 1.20.1 - Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.8 to 1.18.33 - Bumps `github.com/stretchr/testify` from 1.8.1 to 1.8.4 diff --git a/go.mod b/go.mod index bb75e3b..fbfb312 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/opensearch-project/opensearch-go/v2 go 1.15 require ( - github.com/aws/aws-sdk-go v1.44.319 + github.com/aws/aws-sdk-go v1.44.323 github.com/aws/aws-sdk-go-v2 v1.20.1 github.com/aws/aws-sdk-go-v2/config v1.18.33 github.com/kinbiko/jsonassert v1.1.1 diff --git a/go.sum b/go.sum index 57cd7b6..06a9e40 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/aws/aws-sdk-go v1.44.319 h1:cwynvM8DBwWGzlINTZ6XLkGy5O99wZIS0197j3B61Fs= -github.com/aws/aws-sdk-go v1.44.319/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= +github.com/aws/aws-sdk-go v1.44.323 h1:97/dn93DWrN1VfhAWQ2tV+xuE6oO/LO9rSsEsuC4PLU= +github.com/aws/aws-sdk-go v1.44.323/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go-v2 v1.20.1 h1:rZBf5DWr7YGrnlTK4kgDQGn1ltqOg5orCYb/UhOFZkg= github.com/aws/aws-sdk-go-v2 v1.20.1/go.mod h1:NU06lETsFm8fUC6ZjhgDpVBcGZTFQ6XM+LZWZxMI4ac= github.com/aws/aws-sdk-go-v2/config v1.18.33 h1:JKcw5SFxFW/rpM4mOPjv0VQ11E2kxW13F3exWOy7VZU= From d14c709365eadf59a6d57131a52aa0b026a226e3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Aug 2023 17:08:14 -0700 Subject: [PATCH 78/84] Bump github.com/aws/aws-sdk-go-v2 from 1.20.1 to 1.21.0 (#366) * Bump github.com/aws/aws-sdk-go-v2 from 1.20.1 to 1.21.0 Bumps [github.com/aws/aws-sdk-go-v2](https://github.com/aws/aws-sdk-go-v2) from 1.20.1 to 1.21.0. - [Release notes](https://github.com/aws/aws-sdk-go-v2/releases) - [Commits](https://github.com/aws/aws-sdk-go-v2/compare/v1.20.1...v1.21.0) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go-v2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * Update changelog Signed-off-by: dependabot[bot] --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] --- CHANGELOG.md | 2 +- go.mod | 2 +- go.sum | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 21a8371..32ee937 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Dependencies - Bumps `github.com/aws/aws-sdk-go` from 1.44.180 to 1.44.323 -- Bumps `github.com/aws/aws-sdk-go-v2` from 1.17.4 to 1.20.1 +- Bumps `github.com/aws/aws-sdk-go-v2` from 1.17.4 to 1.21.0 - Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.8 to 1.18.33 - Bumps `github.com/stretchr/testify` from 1.8.1 to 1.8.4 diff --git a/go.mod b/go.mod index fbfb312..bcec23c 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.15 require ( github.com/aws/aws-sdk-go v1.44.323 - github.com/aws/aws-sdk-go-v2 v1.20.1 + github.com/aws/aws-sdk-go-v2 v1.21.0 github.com/aws/aws-sdk-go-v2/config v1.18.33 github.com/kinbiko/jsonassert v1.1.1 github.com/stretchr/testify v1.8.4 diff --git a/go.sum b/go.sum index 06a9e40..c4cd74d 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,8 @@ github.com/aws/aws-sdk-go v1.44.323 h1:97/dn93DWrN1VfhAWQ2tV+xuE6oO/LO9rSsEsuC4PLU= github.com/aws/aws-sdk-go v1.44.323/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= -github.com/aws/aws-sdk-go-v2 v1.20.1 h1:rZBf5DWr7YGrnlTK4kgDQGn1ltqOg5orCYb/UhOFZkg= github.com/aws/aws-sdk-go-v2 v1.20.1/go.mod h1:NU06lETsFm8fUC6ZjhgDpVBcGZTFQ6XM+LZWZxMI4ac= +github.com/aws/aws-sdk-go-v2 v1.21.0 h1:gMT0IW+03wtYJhRqTVYn0wLzwdnK9sRMcxmtfGzRdJc= +github.com/aws/aws-sdk-go-v2 v1.21.0/go.mod h1:/RfNgGmRxI+iFOB1OeJUyxiU+9s88k3pfHvDagGEp0M= github.com/aws/aws-sdk-go-v2/config v1.18.33 h1:JKcw5SFxFW/rpM4mOPjv0VQ11E2kxW13F3exWOy7VZU= github.com/aws/aws-sdk-go-v2/config v1.18.33/go.mod h1:hXO/l9pgY3K5oZJldamP0pbZHdPqqk+4/maa7DSD3cA= github.com/aws/aws-sdk-go-v2/credentials v1.13.32 h1:lIH1eKPcCY1ylR4B6PkBGRWMHO3aVenOKJHWiS4/G2w= @@ -22,8 +23,9 @@ github.com/aws/aws-sdk-go-v2/service/ssooidc v1.15.2 h1:OJELEgyaT2kmaBGZ+myyZbTT github.com/aws/aws-sdk-go-v2/service/ssooidc v1.15.2/go.mod h1:ubDBBaDFs1GHijSOTi8ljppML15GLG0HxhILtbjNNYQ= github.com/aws/aws-sdk-go-v2/service/sts v1.21.2 h1:ympg1+Lnq33XLhcK/xTG4yZHPs1Oyxu+6DEWbl7qOzA= github.com/aws/aws-sdk-go-v2/service/sts v1.21.2/go.mod h1:FQ/DQcOfESELfJi5ED+IPPAjI5xC6nxtSolVVB773jM= -github.com/aws/smithy-go v1.14.1 h1:EFKMUmH/iHMqLiwoEDx2rRjRQpI1YCn5jTysoaDujFs= github.com/aws/smithy-go v1.14.1/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= +github.com/aws/smithy-go v1.14.2 h1:MJU9hqBGbvWZdApzpvoF2WAIJDbtjK2NDJSiJP7HblQ= +github.com/aws/smithy-go v1.14.2/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= From 79657fa0ec6745861b2032e7f1ee21e926dafcee Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Aug 2023 23:26:33 -0700 Subject: [PATCH 79/84] Bump github.com/aws/aws-sdk-go from 1.44.323 to 1.44.328 (#364) * Bump github.com/aws/aws-sdk-go from 1.44.323 to 1.44.328 Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.44.323 to 1.44.328. - [Release notes](https://github.com/aws/aws-sdk-go/releases) - [Commits](https://github.com/aws/aws-sdk-go/compare/v1.44.323...v1.44.328) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Update changelog Signed-off-by: dependabot[bot] --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] --- CHANGELOG.md | 2 +- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 32ee937..35132e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Dependencies -- Bumps `github.com/aws/aws-sdk-go` from 1.44.180 to 1.44.323 +- Bumps `github.com/aws/aws-sdk-go` from 1.44.180 to 1.44.328 - Bumps `github.com/aws/aws-sdk-go-v2` from 1.17.4 to 1.21.0 - Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.8 to 1.18.33 - Bumps `github.com/stretchr/testify` from 1.8.1 to 1.8.4 diff --git a/go.mod b/go.mod index bcec23c..5cd5ad5 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/opensearch-project/opensearch-go/v2 go 1.15 require ( - github.com/aws/aws-sdk-go v1.44.323 + github.com/aws/aws-sdk-go v1.44.328 github.com/aws/aws-sdk-go-v2 v1.21.0 github.com/aws/aws-sdk-go-v2/config v1.18.33 github.com/kinbiko/jsonassert v1.1.1 diff --git a/go.sum b/go.sum index c4cd74d..945ef84 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/aws/aws-sdk-go v1.44.323 h1:97/dn93DWrN1VfhAWQ2tV+xuE6oO/LO9rSsEsuC4PLU= -github.com/aws/aws-sdk-go v1.44.323/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= +github.com/aws/aws-sdk-go v1.44.328 h1:WBwlf8ym9SDQ/GTIBO9eXyvwappKJyOetWJKl4mT7ZU= +github.com/aws/aws-sdk-go v1.44.328/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go-v2 v1.20.1/go.mod h1:NU06lETsFm8fUC6ZjhgDpVBcGZTFQ6XM+LZWZxMI4ac= github.com/aws/aws-sdk-go-v2 v1.21.0 h1:gMT0IW+03wtYJhRqTVYn0wLzwdnK9sRMcxmtfGzRdJc= github.com/aws/aws-sdk-go-v2 v1.21.0/go.mod h1:/RfNgGmRxI+iFOB1OeJUyxiU+9s88k3pfHvDagGEp0M= From 277a15e40d93a86d985b49a95e257fe19ba7b7aa Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 22 Aug 2023 11:25:47 -0700 Subject: [PATCH 80/84] Bump github.com/aws/aws-sdk-go-v2/config from 1.18.33 to 1.18.36 (#365) * Bump github.com/aws/aws-sdk-go-v2/config from 1.18.33 to 1.18.36 Bumps [github.com/aws/aws-sdk-go-v2/config](https://github.com/aws/aws-sdk-go-v2) from 1.18.33 to 1.18.36. - [Release notes](https://github.com/aws/aws-sdk-go-v2/releases) - [Commits](https://github.com/aws/aws-sdk-go-v2/compare/config/v1.18.33...config/v1.18.36) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go-v2/config dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Update changelog Signed-off-by: dependabot[bot] --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] --- CHANGELOG.md | 2 +- go.mod | 2 +- go.sum | 42 ++++++++++++++++++++---------------------- 3 files changed, 22 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 35132e5..38c8bed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Bumps `github.com/aws/aws-sdk-go` from 1.44.180 to 1.44.328 - Bumps `github.com/aws/aws-sdk-go-v2` from 1.17.4 to 1.21.0 -- Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.8 to 1.18.33 +- Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.8 to 1.18.36 - Bumps `github.com/stretchr/testify` from 1.8.1 to 1.8.4 ### Added diff --git a/go.mod b/go.mod index 5cd5ad5..0022a53 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.15 require ( github.com/aws/aws-sdk-go v1.44.328 github.com/aws/aws-sdk-go-v2 v1.21.0 - github.com/aws/aws-sdk-go-v2/config v1.18.33 + github.com/aws/aws-sdk-go-v2/config v1.18.36 github.com/kinbiko/jsonassert v1.1.1 github.com/stretchr/testify v1.8.4 golang.org/x/net v0.7.0 // indirect diff --git a/go.sum b/go.sum index 945ef84..d21aa3e 100644 --- a/go.sum +++ b/go.sum @@ -1,29 +1,27 @@ github.com/aws/aws-sdk-go v1.44.328 h1:WBwlf8ym9SDQ/GTIBO9eXyvwappKJyOetWJKl4mT7ZU= github.com/aws/aws-sdk-go v1.44.328/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= -github.com/aws/aws-sdk-go-v2 v1.20.1/go.mod h1:NU06lETsFm8fUC6ZjhgDpVBcGZTFQ6XM+LZWZxMI4ac= github.com/aws/aws-sdk-go-v2 v1.21.0 h1:gMT0IW+03wtYJhRqTVYn0wLzwdnK9sRMcxmtfGzRdJc= github.com/aws/aws-sdk-go-v2 v1.21.0/go.mod h1:/RfNgGmRxI+iFOB1OeJUyxiU+9s88k3pfHvDagGEp0M= -github.com/aws/aws-sdk-go-v2/config v1.18.33 h1:JKcw5SFxFW/rpM4mOPjv0VQ11E2kxW13F3exWOy7VZU= -github.com/aws/aws-sdk-go-v2/config v1.18.33/go.mod h1:hXO/l9pgY3K5oZJldamP0pbZHdPqqk+4/maa7DSD3cA= -github.com/aws/aws-sdk-go-v2/credentials v1.13.32 h1:lIH1eKPcCY1ylR4B6PkBGRWMHO3aVenOKJHWiS4/G2w= -github.com/aws/aws-sdk-go-v2/credentials v1.13.32/go.mod h1:lL8U3v/Y79YRG69WlAho0OHIKUXCyFvSXaIvfo81sls= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.8 h1:DK/9C+UN/X+1+Wm8pqaDksQr2tSLzq+8X1/rI/ZxKEQ= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.8/go.mod h1:ce7BgLQfYr5hQFdy67oX2svto3ufGtm6oBvmsHScI1Q= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.38 h1:c8ed/T9T2K5I+h/JzmF5tpI46+OODQ74dzmdo+QnaMg= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.38/go.mod h1:qggunOChCMu9ZF/UkAfhTz25+U2rLVb3ya0Ua6TTfCA= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.32 h1:hNeAAymUY5gu11WrrmFb3CVIp9Dar9hbo44yzzcQpzA= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.32/go.mod h1:0ZXSqrty4FtQ7p8TEuRde/SZm9X05KT18LAUlR40Ln0= -github.com/aws/aws-sdk-go-v2/internal/ini v1.3.39 h1:fc0ukRAiP1syoSGZYu+DaE+FulSYhTiJ8WpVu5jElU4= -github.com/aws/aws-sdk-go-v2/internal/ini v1.3.39/go.mod h1:WLAW8PT7+JhjZfLSWe7WEJaJu0GNo0cKc2Zyo003RBs= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.32 h1:dGAseBFEYxth10V23b5e2mAS+tX7oVbfYHD6dnDdAsg= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.32/go.mod h1:4jwAWKEkCR0anWk5+1RbfSg1R5Gzld7NLiuaq5bTR/Y= -github.com/aws/aws-sdk-go-v2/service/sso v1.13.2 h1:A2RlEMo4SJSwbNoUUgkxTAEMduAy/8wG3eB2b2lP4gY= -github.com/aws/aws-sdk-go-v2/service/sso v1.13.2/go.mod h1:ju+nNXUunfIFamXUIZQiICjnO/TPlOmWcYhZcSy7xaE= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.15.2 h1:OJELEgyaT2kmaBGZ+myyZbTTLobfe3ox3FSh5eYK9Qs= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.15.2/go.mod h1:ubDBBaDFs1GHijSOTi8ljppML15GLG0HxhILtbjNNYQ= -github.com/aws/aws-sdk-go-v2/service/sts v1.21.2 h1:ympg1+Lnq33XLhcK/xTG4yZHPs1Oyxu+6DEWbl7qOzA= -github.com/aws/aws-sdk-go-v2/service/sts v1.21.2/go.mod h1:FQ/DQcOfESELfJi5ED+IPPAjI5xC6nxtSolVVB773jM= -github.com/aws/smithy-go v1.14.1/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= +github.com/aws/aws-sdk-go-v2/config v1.18.36 h1:mLNA12PWU1Y+ueOO79QgQfKIPhc1MYKl44RmvASkJ7Q= +github.com/aws/aws-sdk-go-v2/config v1.18.36/go.mod h1:8AnEFxW9/XGKCbjYDCJy7iltVNyEI9Iu9qC21UzhhgQ= +github.com/aws/aws-sdk-go-v2/credentials v1.13.35 h1:QpsNitYJu0GgvMBLUIYu9H4yryA5kMksjeIVQfgXrt8= +github.com/aws/aws-sdk-go-v2/credentials v1.13.35/go.mod h1:o7rCaLtvK0hUggAGclf76mNGGkaG5a9KWlp+d9IpcV8= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.11 h1:uDZJF1hu0EVT/4bogChk8DyjSF6fof6uL/0Y26Ma7Fg= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.11/go.mod h1:TEPP4tENqBGO99KwVpV9MlOX4NSrSLP8u3KRy2CDwA8= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.41 h1:22dGT7PneFMx4+b3pz7lMTRyN8ZKH7M2cW4GP9yUS2g= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.41/go.mod h1:CrObHAuPneJBlfEJ5T3szXOUkLEThaGfvnhTf33buas= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.35 h1:SijA0mgjV8E+8G45ltVHs0fvKpTj8xmZJ3VwhGKtUSI= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.35/go.mod h1:SJC1nEVVva1g3pHAIdCp7QsRIkMmLAgoDquQ9Rr8kYw= +github.com/aws/aws-sdk-go-v2/internal/ini v1.3.42 h1:GPUcE/Yq7Ur8YSUk6lVkoIMWnJNO0HT18GUzCWCgCI0= +github.com/aws/aws-sdk-go-v2/internal/ini v1.3.42/go.mod h1:rzfdUlfA+jdgLDmPKjd3Chq9V7LVLYo1Nz++Wb91aRo= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.35 h1:CdzPW9kKitgIiLV1+MHobfR5Xg25iYnyzWZhyQuSlDI= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.35/go.mod h1:QGF2Rs33W5MaN9gYdEQOBBFPLwTZkEhRwI33f7KIG0o= +github.com/aws/aws-sdk-go-v2/service/sso v1.13.5 h1:oCvTFSDi67AX0pOX3PuPdGFewvLRU2zzFSrTsgURNo0= +github.com/aws/aws-sdk-go-v2/service/sso v1.13.5/go.mod h1:fIAwKQKBFu90pBxx07BFOMJLpRUGu8VOzLJakeY+0K4= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.15.5 h1:dnInJb4S0oy8aQuri1mV6ipLlnZPfnsDNB9BGO9PDNY= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.15.5/go.mod h1:yygr8ACQRY2PrEcy3xsUI357stq2AxnFM6DIsR9lij4= +github.com/aws/aws-sdk-go-v2/service/sts v1.21.5 h1:CQBFElb0LS8RojMJlxRSo/HXipvTZW2S44Lt9Mk2aYQ= +github.com/aws/aws-sdk-go-v2/service/sts v1.21.5/go.mod h1:VC7JDqsqiwXukYEDjoHh9U0fOJtNWh04FPQz4ct4GGU= github.com/aws/smithy-go v1.14.2 h1:MJU9hqBGbvWZdApzpvoF2WAIJDbtjK2NDJSiJP7HblQ= github.com/aws/smithy-go v1.14.2/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= From 9282f355c064c9046eff438764dae021aae71151 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 29 Aug 2023 17:03:15 -0400 Subject: [PATCH 81/84] Bump github.com/aws/aws-sdk-go-v2/config from 1.18.36 to 1.18.37 (#367) * Bump github.com/aws/aws-sdk-go-v2/config from 1.18.36 to 1.18.37 Bumps [github.com/aws/aws-sdk-go-v2/config](https://github.com/aws/aws-sdk-go-v2) from 1.18.36 to 1.18.37. - [Release notes](https://github.com/aws/aws-sdk-go-v2/releases) - [Commits](https://github.com/aws/aws-sdk-go-v2/compare/config/v1.18.36...config/v1.18.37) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go-v2/config dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Update changelog Signed-off-by: dependabot[bot] --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] --- CHANGELOG.md | 2 +- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 38c8bed..646b9dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Bumps `github.com/aws/aws-sdk-go` from 1.44.180 to 1.44.328 - Bumps `github.com/aws/aws-sdk-go-v2` from 1.17.4 to 1.21.0 -- Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.8 to 1.18.36 +- Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.8 to 1.18.37 - Bumps `github.com/stretchr/testify` from 1.8.1 to 1.8.4 ### Added diff --git a/go.mod b/go.mod index 0022a53..7320a44 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.15 require ( github.com/aws/aws-sdk-go v1.44.328 github.com/aws/aws-sdk-go-v2 v1.21.0 - github.com/aws/aws-sdk-go-v2/config v1.18.36 + github.com/aws/aws-sdk-go-v2/config v1.18.37 github.com/kinbiko/jsonassert v1.1.1 github.com/stretchr/testify v1.8.4 golang.org/x/net v0.7.0 // indirect diff --git a/go.sum b/go.sum index d21aa3e..408d236 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,8 @@ github.com/aws/aws-sdk-go v1.44.328 h1:WBwlf8ym9SDQ/GTIBO9eXyvwappKJyOetWJKl4mT7 github.com/aws/aws-sdk-go v1.44.328/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go-v2 v1.21.0 h1:gMT0IW+03wtYJhRqTVYn0wLzwdnK9sRMcxmtfGzRdJc= github.com/aws/aws-sdk-go-v2 v1.21.0/go.mod h1:/RfNgGmRxI+iFOB1OeJUyxiU+9s88k3pfHvDagGEp0M= -github.com/aws/aws-sdk-go-v2/config v1.18.36 h1:mLNA12PWU1Y+ueOO79QgQfKIPhc1MYKl44RmvASkJ7Q= -github.com/aws/aws-sdk-go-v2/config v1.18.36/go.mod h1:8AnEFxW9/XGKCbjYDCJy7iltVNyEI9Iu9qC21UzhhgQ= +github.com/aws/aws-sdk-go-v2/config v1.18.37 h1:RNAfbPqw1CstCooHaTPhScz7z1PyocQj0UL+l95CgzI= +github.com/aws/aws-sdk-go-v2/config v1.18.37/go.mod h1:8AnEFxW9/XGKCbjYDCJy7iltVNyEI9Iu9qC21UzhhgQ= github.com/aws/aws-sdk-go-v2/credentials v1.13.35 h1:QpsNitYJu0GgvMBLUIYu9H4yryA5kMksjeIVQfgXrt8= github.com/aws/aws-sdk-go-v2/credentials v1.13.35/go.mod h1:o7rCaLtvK0hUggAGclf76mNGGkaG5a9KWlp+d9IpcV8= github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.11 h1:uDZJF1hu0EVT/4bogChk8DyjSF6fof6uL/0Y26Ma7Fg= From e4b95c6f94e8506def8be273f8e7017b6f74c249 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 30 Aug 2023 10:49:09 -0700 Subject: [PATCH 82/84] Bump github.com/aws/aws-sdk-go from 1.44.328 to 1.44.334 (#369) * Bump github.com/aws/aws-sdk-go from 1.44.328 to 1.44.334 Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.44.328 to 1.44.334. - [Release notes](https://github.com/aws/aws-sdk-go/releases) - [Changelog](https://github.com/aws/aws-sdk-go/blob/main/CHANGELOG_PENDING.md) - [Commits](https://github.com/aws/aws-sdk-go/compare/v1.44.328...v1.44.334) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Update changelog Signed-off-by: dependabot[bot] --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] --- CHANGELOG.md | 2 +- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 646b9dd..8a3c5ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Dependencies -- Bumps `github.com/aws/aws-sdk-go` from 1.44.180 to 1.44.328 +- Bumps `github.com/aws/aws-sdk-go` from 1.44.180 to 1.44.334 - Bumps `github.com/aws/aws-sdk-go-v2` from 1.17.4 to 1.21.0 - Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.8 to 1.18.37 - Bumps `github.com/stretchr/testify` from 1.8.1 to 1.8.4 diff --git a/go.mod b/go.mod index 7320a44..e32debc 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/opensearch-project/opensearch-go/v2 go 1.15 require ( - github.com/aws/aws-sdk-go v1.44.328 + github.com/aws/aws-sdk-go v1.44.334 github.com/aws/aws-sdk-go-v2 v1.21.0 github.com/aws/aws-sdk-go-v2/config v1.18.37 github.com/kinbiko/jsonassert v1.1.1 diff --git a/go.sum b/go.sum index 408d236..7852a06 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/aws/aws-sdk-go v1.44.328 h1:WBwlf8ym9SDQ/GTIBO9eXyvwappKJyOetWJKl4mT7ZU= -github.com/aws/aws-sdk-go v1.44.328/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= +github.com/aws/aws-sdk-go v1.44.334 h1:h2bdbGb//fez6Sv6PaYv868s9liDeoYM6hYsAqTB4MU= +github.com/aws/aws-sdk-go v1.44.334/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go-v2 v1.21.0 h1:gMT0IW+03wtYJhRqTVYn0wLzwdnK9sRMcxmtfGzRdJc= github.com/aws/aws-sdk-go-v2 v1.21.0/go.mod h1:/RfNgGmRxI+iFOB1OeJUyxiU+9s88k3pfHvDagGEp0M= github.com/aws/aws-sdk-go-v2/config v1.18.37 h1:RNAfbPqw1CstCooHaTPhScz7z1PyocQj0UL+l95CgzI= From dac5ca6ca1f770c4b95c649b163c551eca7a96e0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Sep 2023 17:03:05 -0700 Subject: [PATCH 83/84] Bump github.com/aws/aws-sdk-go-v2/config from 1.18.37 to 1.18.38 (#372) * Bump github.com/aws/aws-sdk-go-v2/config from 1.18.37 to 1.18.38 Bumps [github.com/aws/aws-sdk-go-v2/config](https://github.com/aws/aws-sdk-go-v2) from 1.18.37 to 1.18.38. - [Release notes](https://github.com/aws/aws-sdk-go-v2/releases) - [Commits](https://github.com/aws/aws-sdk-go-v2/compare/config/v1.18.37...config/v1.18.38) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go-v2/config dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Update changelog Signed-off-by: dependabot[bot] --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] --- CHANGELOG.md | 2 +- go.mod | 2 +- go.sum | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a3c5ae..85d6a5f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Bumps `github.com/aws/aws-sdk-go` from 1.44.180 to 1.44.334 - Bumps `github.com/aws/aws-sdk-go-v2` from 1.17.4 to 1.21.0 -- Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.8 to 1.18.37 +- Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.8 to 1.18.38 - Bumps `github.com/stretchr/testify` from 1.8.1 to 1.8.4 ### Added diff --git a/go.mod b/go.mod index e32debc..639139d 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.15 require ( github.com/aws/aws-sdk-go v1.44.334 github.com/aws/aws-sdk-go-v2 v1.21.0 - github.com/aws/aws-sdk-go-v2/config v1.18.37 + github.com/aws/aws-sdk-go-v2/config v1.18.38 github.com/kinbiko/jsonassert v1.1.1 github.com/stretchr/testify v1.8.4 golang.org/x/net v0.7.0 // indirect diff --git a/go.sum b/go.sum index 7852a06..6e74370 100644 --- a/go.sum +++ b/go.sum @@ -2,10 +2,10 @@ github.com/aws/aws-sdk-go v1.44.334 h1:h2bdbGb//fez6Sv6PaYv868s9liDeoYM6hYsAqTB4 github.com/aws/aws-sdk-go v1.44.334/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go-v2 v1.21.0 h1:gMT0IW+03wtYJhRqTVYn0wLzwdnK9sRMcxmtfGzRdJc= github.com/aws/aws-sdk-go-v2 v1.21.0/go.mod h1:/RfNgGmRxI+iFOB1OeJUyxiU+9s88k3pfHvDagGEp0M= -github.com/aws/aws-sdk-go-v2/config v1.18.37 h1:RNAfbPqw1CstCooHaTPhScz7z1PyocQj0UL+l95CgzI= -github.com/aws/aws-sdk-go-v2/config v1.18.37/go.mod h1:8AnEFxW9/XGKCbjYDCJy7iltVNyEI9Iu9qC21UzhhgQ= -github.com/aws/aws-sdk-go-v2/credentials v1.13.35 h1:QpsNitYJu0GgvMBLUIYu9H4yryA5kMksjeIVQfgXrt8= -github.com/aws/aws-sdk-go-v2/credentials v1.13.35/go.mod h1:o7rCaLtvK0hUggAGclf76mNGGkaG5a9KWlp+d9IpcV8= +github.com/aws/aws-sdk-go-v2/config v1.18.38 h1:CByQCELMgm2tM1lAehx3XNg0R/pfeXsYzqn0Aq2chJQ= +github.com/aws/aws-sdk-go-v2/config v1.18.38/go.mod h1:vNm9Hf5VgG2fSUWhT3zFrqN/RosGcabFMYgiSoxKFU8= +github.com/aws/aws-sdk-go-v2/credentials v1.13.36 h1:ps0cPswZjpsOk6sLwG6fdXTzrYjCplgPEyG3OUbbdqE= +github.com/aws/aws-sdk-go-v2/credentials v1.13.36/go.mod h1:sY2phUzxbygoyDtTXhqi7GjGjCQ1S5a5Rj8u3ksBxCg= github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.11 h1:uDZJF1hu0EVT/4bogChk8DyjSF6fof6uL/0Y26Ma7Fg= github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.11/go.mod h1:TEPP4tENqBGO99KwVpV9MlOX4NSrSLP8u3KRy2CDwA8= github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.41 h1:22dGT7PneFMx4+b3pz7lMTRyN8ZKH7M2cW4GP9yUS2g= @@ -16,8 +16,8 @@ github.com/aws/aws-sdk-go-v2/internal/ini v1.3.42 h1:GPUcE/Yq7Ur8YSUk6lVkoIMWnJN github.com/aws/aws-sdk-go-v2/internal/ini v1.3.42/go.mod h1:rzfdUlfA+jdgLDmPKjd3Chq9V7LVLYo1Nz++Wb91aRo= github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.35 h1:CdzPW9kKitgIiLV1+MHobfR5Xg25iYnyzWZhyQuSlDI= github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.35/go.mod h1:QGF2Rs33W5MaN9gYdEQOBBFPLwTZkEhRwI33f7KIG0o= -github.com/aws/aws-sdk-go-v2/service/sso v1.13.5 h1:oCvTFSDi67AX0pOX3PuPdGFewvLRU2zzFSrTsgURNo0= -github.com/aws/aws-sdk-go-v2/service/sso v1.13.5/go.mod h1:fIAwKQKBFu90pBxx07BFOMJLpRUGu8VOzLJakeY+0K4= +github.com/aws/aws-sdk-go-v2/service/sso v1.13.6 h1:2PylFCfKCEDv6PeSN09pC/VUiRd10wi1VfHG5FrW0/g= +github.com/aws/aws-sdk-go-v2/service/sso v1.13.6/go.mod h1:fIAwKQKBFu90pBxx07BFOMJLpRUGu8VOzLJakeY+0K4= github.com/aws/aws-sdk-go-v2/service/ssooidc v1.15.5 h1:dnInJb4S0oy8aQuri1mV6ipLlnZPfnsDNB9BGO9PDNY= github.com/aws/aws-sdk-go-v2/service/ssooidc v1.15.5/go.mod h1:yygr8ACQRY2PrEcy3xsUI357stq2AxnFM6DIsR9lij4= github.com/aws/aws-sdk-go-v2/service/sts v1.21.5 h1:CQBFElb0LS8RojMJlxRSo/HXipvTZW2S44Lt9Mk2aYQ= From 1963c2e4c153edfe919f819af019cc42a0afef2a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Sep 2023 17:56:33 -0700 Subject: [PATCH 84/84] Bump github.com/aws/aws-sdk-go from 1.44.334 to 1.45.2 (#373) * Bump github.com/aws/aws-sdk-go from 1.44.334 to 1.45.2 Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.44.334 to 1.45.2. - [Release notes](https://github.com/aws/aws-sdk-go/releases) - [Commits](https://github.com/aws/aws-sdk-go/compare/v1.44.334...v1.45.2) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * Update changelog Signed-off-by: dependabot[bot] --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] --- CHANGELOG.md | 2 +- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 85d6a5f..b70ce2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Dependencies -- Bumps `github.com/aws/aws-sdk-go` from 1.44.180 to 1.44.334 +- Bumps `github.com/aws/aws-sdk-go` from 1.44.180 to 1.45.2 - Bumps `github.com/aws/aws-sdk-go-v2` from 1.17.4 to 1.21.0 - Bumps `github.com/aws/aws-sdk-go-v2/config` from 1.18.8 to 1.18.38 - Bumps `github.com/stretchr/testify` from 1.8.1 to 1.8.4 diff --git a/go.mod b/go.mod index 639139d..240a538 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/opensearch-project/opensearch-go/v2 go 1.15 require ( - github.com/aws/aws-sdk-go v1.44.334 + github.com/aws/aws-sdk-go v1.45.2 github.com/aws/aws-sdk-go-v2 v1.21.0 github.com/aws/aws-sdk-go-v2/config v1.18.38 github.com/kinbiko/jsonassert v1.1.1 diff --git a/go.sum b/go.sum index 6e74370..300f989 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/aws/aws-sdk-go v1.44.334 h1:h2bdbGb//fez6Sv6PaYv868s9liDeoYM6hYsAqTB4MU= -github.com/aws/aws-sdk-go v1.44.334/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= +github.com/aws/aws-sdk-go v1.45.2 h1:hTong9YUklQKqzrGk3WnKABReb5R8GjbG4Y6dEQfjnk= +github.com/aws/aws-sdk-go v1.45.2/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go-v2 v1.21.0 h1:gMT0IW+03wtYJhRqTVYn0wLzwdnK9sRMcxmtfGzRdJc= github.com/aws/aws-sdk-go-v2 v1.21.0/go.mod h1:/RfNgGmRxI+iFOB1OeJUyxiU+9s88k3pfHvDagGEp0M= github.com/aws/aws-sdk-go-v2/config v1.18.38 h1:CByQCELMgm2tM1lAehx3XNg0R/pfeXsYzqn0Aq2chJQ=