Skip to content

Commit

Permalink
feat(elastic): update to elastic v7 (#6325)
Browse files Browse the repository at this point in the history
  • Loading branch information
richardlt authored Oct 7, 2022
1 parent 5a8f1fa commit f5f5a12
Show file tree
Hide file tree
Showing 10 changed files with 130 additions and 94 deletions.
10 changes: 5 additions & 5 deletions contrib/grpcplugins/action/plugin-kafka-publish/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmV
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
github.com/aws/aws-sdk-go v1.19.11 h1:tqaTGER6Byw3QvsjGW0p018U2UOqaJPeJuzoaF7jjoQ=
github.com/aws/aws-sdk-go v1.43.21 h1:E4S2eX3d2gKJyI/ISrcIrSwXwqjIvCK85gtBMt4sAPE=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
Expand Down Expand Up @@ -359,8 +359,9 @@ github.com/jfrog/gofrog v1.0.6 h1:yUDxSCw8gTK6vC4PvtG0HTnEOQJSZ+O4lWGCgkev1nU=
github.com/jfrog/gofrog v1.0.6/go.mod h1:HkDzg+tMNw23UryoOv0+LB94BzYcl6MCIoz8Tmlb+s8=
github.com/jfrog/jfrog-client-go v1.5.1 h1:RtdE6jH5b1PuKqr2DWpadL5EQ2emt/43TW8reHNvSUU=
github.com/jfrog/jfrog-client-go v1.5.1/go.mod h1:tzcQZUy/WxNfJNzKzFp9xQpEkzbFuYzF3tsMgxhyf1U=
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5imkbgOkpRUYLnmbU7UEFbjtDA2hxJ1ichM=
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4=
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
Expand Down Expand Up @@ -401,7 +402,7 @@ github.com/lib/pq v1.9.0 h1:L8nSXQQzAYByakOFMTwpjRoHsMJklur4Gi59b6VivR8=
github.com/lib/pq v1.9.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/magiconair/properties v1.8.5 h1:b6kJs+EmPFMYGkow9GiUyCyOvIwYetYJ3fSaWak/Gls=
github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e h1:hB2xlXdHp/pmPZq0y3QnmWAArdw9PqbmotexnWx/FU8=
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
github.com/maruel/panicparse/v2 v2.2.2 h1:4Gu/Z5oLpJCE/0/NwxrUkyn7alpqOQdJAUuchB2OoJU=
github.com/maruel/panicparse/v2 v2.2.2/go.mod h1:WizmeHJfpyKYYKGInKv8ax8jh7DJnQE5yFDuzFfHzIU=
github.com/matryer/is v1.2.0 h1:92UTHpy8CDwaJ08GqLDzhhuixiBUUD1p3AU6PHddz4A=
Expand Down Expand Up @@ -453,7 +454,7 @@ github.com/nwaples/rardecode v1.1.0/go.mod h1:5DzqNKiOdpKKBH87u8VlvAnPZMXcGRhxWk
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
github.com/olekukonko/tablewriter v0.0.0-20160621093029-daf2955e742c h1:1BS19mnpAe7Lm0etRs1uBVaki11WZ8fktvOQGipZPo4=
github.com/olekukonko/tablewriter v0.0.0-20160621093029-daf2955e742c/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo=
github.com/olivere/elastic v6.2.17+incompatible h1:g8tdYJgwHYh6LxfKp+YSgDmDVorZOm7+M8n1OkeQEWs=
github.com/olivere/elastic/v7 v7.0.32 h1:R7CXvbu8Eq+WlsLgxmKVKPox0oOwAE/2T9Si5BnvK6E=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.11.0 h1:JAKSXpt1YjtLA7YpPiqO9ss6sNXEsPfSGdwN0UHqzrw=
Expand Down Expand Up @@ -1094,7 +1095,6 @@ gopkg.in/gorp.v1 v1.7.1 h1:GBB9KrWRATQZh95HJyVGUZrWwOPswitEYEyqlK8JbAA=
gopkg.in/gorp.v1 v1.7.1/go.mod h1:Wo3h+DBQZIxATwftsglhdD/62zRFPhGhTiu5jUJmCaw=
gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/ini.v1 v1.66.4 h1:SsAcf+mM7mRZo2nJNGt8mZCjG8ZRaNGMURJw7BsIST4=
gopkg.in/olivere/elastic.v6 v6.2.17 h1:ewcJ35+DJUA/OeZYP6I+oWoYWvcBlonuFJ8JU1/W4RY=
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
gopkg.in/spacemonkeygo/httpsig.v0 v0.0.0-20170228231032-6732593ec966 h1:8kepDsMTleFJGPFjqiqahyFDI8s8zmx1CbCC3qUOh5c=
gopkg.in/spacemonkeygo/httpsig.v0 v0.0.0-20170228231032-6732593ec966/go.mod h1:KUilIqVZdvg7tsZSnGqOnw8jL2WVzcC0RHV/Av0km2U=
Expand Down
4 changes: 2 additions & 2 deletions engine/api/event/elasticsearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"encoding/json"

"github.com/go-gorp/gorp"
"github.com/olivere/elastic/v7"
"github.com/rockbears/log"
"gopkg.in/olivere/elastic.v6"

"github.com/ovh/cds/engine/api/services"
"github.com/ovh/cds/engine/cache"
Expand Down Expand Up @@ -65,7 +65,7 @@ func GetEvents(ctx context.Context, db gorp.SqlExecutor, store cache.Store, filt

events := make([]json.RawMessage, 0, len(esEvents))
for _, h := range esEvents {
events = append(events, *h.Source)
events = append(events, h.Source)
}
return events, nil
}
4 changes: 2 additions & 2 deletions engine/api/metrics/elasticsearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"time"

"github.com/go-gorp/gorp"
"github.com/olivere/elastic/v7"
"github.com/rockbears/log"
"github.com/sguiheux/go-coverage"
"gopkg.in/olivere/elastic.v6"

"github.com/ovh/cds/engine/api/services"
"github.com/ovh/cds/sdk"
Expand Down Expand Up @@ -68,7 +68,7 @@ func GetMetrics(ctx context.Context, db gorp.SqlExecutor, key string, appID int6

events := make([]json.RawMessage, len(esMetrics))
for i := range esMetrics {
events[len(esMetrics)-1-i] = *esMetrics[i].Source
events[len(esMetrics)-1-i] = esMetrics[i].Source
}
return events, nil
}
Expand Down
4 changes: 2 additions & 2 deletions engine/api/timeline_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
"net/http/httptest"
"testing"

"github.com/olivere/elastic/v7"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"gopkg.in/olivere/elastic.v6"

"github.com/ovh/cds/engine/api/services"
"github.com/ovh/cds/engine/api/test/assets"
Expand Down Expand Up @@ -98,7 +98,7 @@ func Test_getTimelineHandler(t *testing.T) {
for i := range res {
buf, _ := json.Marshal(res[i])
raw := json.RawMessage(buf)
hits = append(hits, elastic.SearchHit{Source: &raw})
hits = append(hits, elastic.SearchHit{Source: raw})
}

if err := enc.Encode(hits); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion engine/elasticsearch/elasticsearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"time"

"github.com/gorilla/mux"
"github.com/olivere/elastic/v7"
"github.com/rockbears/log"
"gopkg.in/olivere/elastic.v6"

"github.com/ovh/cds/engine/api"
"github.com/ovh/cds/sdk"
Expand Down
4 changes: 2 additions & 2 deletions engine/elasticsearch/elasticsearch_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"net/http"
"strings"

"github.com/olivere/elastic/v7"
"github.com/rockbears/log"
"gopkg.in/olivere/elastic.v6"

"github.com/ovh/cds/engine/service"
"github.com/ovh/cds/sdk"
Expand Down Expand Up @@ -160,7 +160,7 @@ func (s *Service) loadMetric(ctx context.Context, ID string) (sdk.Metric, error)
return m, nil
}

if err := sdk.JSONUnmarshal(*results.Hits.Hits[0].Source, &m); err != nil {
if err := sdk.JSONUnmarshal(results.Hits.Hits[0].Source, &m); err != nil {
return m, err
}
return m, nil
Expand Down
2 changes: 1 addition & 1 deletion engine/elasticsearch/mock_elasticsearch/esclient_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion engine/elasticsearch/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package elasticsearch
import (
"context"

"github.com/olivere/elastic/v7"

"github.com/ovh/cds/engine/api"
"github.com/ovh/cds/engine/service"
"github.com/ovh/cds/sdk/event"
"gopkg.in/olivere/elastic.v6"
)

const indexNotFoundException = "index_not_found_exception"
Expand Down
45 changes: 27 additions & 18 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
contrib.go.opencensus.io/exporter/prometheus v0.1.0
github.com/Shopify/sarama v1.36.0
github.com/andygrunwald/go-gerrit v0.0.0-20181207071854-19ef3e9332a4
github.com/aws/aws-sdk-go v1.19.11
github.com/aws/aws-sdk-go v1.43.21
github.com/blang/semver v3.5.1+incompatible
github.com/buger/goterm v0.0.0-20170918171949-d443b9114f9c
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e
Expand Down Expand Up @@ -57,6 +57,7 @@ require (
github.com/nbutton23/zxcvbn-go v0.0.0-20180912185939-ae427f1e4c1d
github.com/ncw/swift v1.0.52
github.com/olekukonko/tablewriter v0.0.0-20160621093029-daf2955e742c
github.com/olivere/elastic/v7 v7.0.32
github.com/ovh/cds/sdk/interpolate v0.0.0-20190319104452-71125b036b25
github.com/ovh/configstore v0.3.3-0.20200701085609-a539fcf61db5
github.com/ovh/symmecrypt v0.5.1
Expand Down Expand Up @@ -94,19 +95,18 @@ require (
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8
golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10
golang.org/x/text v0.3.7
golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8
google.golang.org/grpc v1.43.0
google.golang.org/protobuf v1.27.1
gopkg.in/AlecAivazis/survey.v1 v1.7.1
gopkg.in/h2non/gock.v1 v1.0.14
gopkg.in/ldap.v2 v2.5.1
gopkg.in/olivere/elastic.v6 v6.2.17
gopkg.in/spacemonkeygo/httpsig.v0 v0.0.0-20170228231032-6732593ec966
gopkg.in/square/go-jose.v2 v2.3.1
gopkg.in/yaml.v2 v2.4.0
k8s.io/api v0.21.2
k8s.io/apimachinery v0.21.2
k8s.io/client-go v0.21.2
k8s.io/api v0.24.2
k8s.io/apimachinery v0.24.2
k8s.io/client-go v0.24.2
layeh.com/gopher-json v0.0.0-20201124131017-552bb3c4c3bf
)

Expand All @@ -115,15 +115,17 @@ require (
cloud.google.com/go/firestore v1.6.1 // indirect
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 // indirect
github.com/Azure/go-autorest v14.2.0+incompatible // indirect
github.com/Azure/go-autorest/autorest v0.11.12 // indirect
github.com/Azure/go-autorest/autorest/adal v0.9.5 // indirect
github.com/Azure/go-autorest/autorest v0.11.18 // indirect
github.com/Azure/go-autorest/autorest/adal v0.9.13 // indirect
github.com/Azure/go-autorest/autorest/date v0.3.0 // indirect
github.com/Azure/go-autorest/logger v0.2.0 // indirect
github.com/Azure/go-autorest/logger v0.2.1 // indirect
github.com/Azure/go-autorest/tracing v0.6.0 // indirect
github.com/Microsoft/go-winio v0.4.16 // indirect
github.com/Netflix/go-expect v0.0.0-20180928190340-9d1f4485533b // indirect
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7 // indirect
github.com/PuerkitoBio/purell v1.1.1 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
github.com/SSSaaS/sssa-golang v0.0.0-20170502204618-d37d7782d752 // indirect
github.com/acomagu/bufpipe v1.0.3 // indirect
github.com/andybalholm/brotli v1.0.1 // indirect
Expand All @@ -142,26 +144,30 @@ require (
github.com/dustin/go-humanize v1.0.0 // indirect
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 // indirect
github.com/eapache/queue v1.1.0 // indirect
github.com/emicklei/go-restful v2.9.5+incompatible // indirect
github.com/emirpasic/gods v1.12.0 // indirect
github.com/envoyproxy/go-control-plane v0.10.1 // indirect
github.com/envoyproxy/protoc-gen-validate v0.6.2 // indirect
github.com/form3tech-oss/jwt-go v3.2.2+incompatible // indirect
github.com/form3tech-oss/jwt-go v3.2.3+incompatible // indirect
github.com/frankban/quicktest v1.14.3 // indirect
github.com/fsnotify/fsnotify v1.5.1 // indirect
github.com/go-git/gcfg v1.5.0 // indirect
github.com/go-git/go-billy/v5 v5.3.1 // indirect
github.com/go-git/go-git/v5 v5.4.2 // indirect
github.com/go-logr/logr v0.4.0 // indirect
github.com/go-logr/logr v1.2.2 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.19.5 // indirect
github.com/go-openapi/swag v0.19.14 // indirect
github.com/go-sql-driver/mysql v1.4.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.1.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/gnostic v0.5.7-v3refs // indirect
github.com/google/go-cmp v0.5.7 // indirect
github.com/google/go-querystring v1.0.0 // indirect
github.com/google/gofuzz v1.1.0 // indirect
github.com/googleapis/gax-go/v2 v2.1.1 // indirect
github.com/googleapis/gnostic v0.4.1 // indirect
github.com/gookit/color v1.4.2 // indirect
github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 // indirect
github.com/hashicorp/consul/api v1.12.0 // indirect
Expand Down Expand Up @@ -190,7 +196,8 @@ require (
github.com/jcmturner/gokrb5/v8 v8.4.3 // indirect
github.com/jcmturner/rpc/v2 v2.0.3 // indirect
github.com/jfrog/gofrog v1.0.6 // indirect
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351 // indirect
Expand All @@ -199,7 +206,7 @@ require (
github.com/kr/pty v1.1.8 // indirect
github.com/kylelemons/godebug v1.1.0 // indirect
github.com/magiconair/properties v1.8.5 // indirect
github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mattn/go-runewidth v0.0.1 // indirect
Expand All @@ -209,9 +216,9 @@ require (
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/nsf/termbox-go v0.0.0-20190817171036-93860e161317 // indirect
github.com/nwaples/rardecode v1.1.0 // indirect
github.com/olivere/elastic v6.2.17+incompatible // indirect
github.com/opencontainers/go-digest v1.0.0-rc1 // indirect
github.com/opencontainers/image-spec v1.0.2 // indirect
github.com/pierrec/lz4 v2.6.1+incompatible // indirect
Expand Down Expand Up @@ -257,9 +264,11 @@ require (
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gotest.tools v2.1.0+incompatible // indirect
k8s.io/klog/v2 v2.8.0 // indirect
k8s.io/utils v0.0.0-20201110183641-67b214c5f920 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.1.0 // indirect
k8s.io/klog/v2 v2.60.1 // indirect
k8s.io/kube-openapi v0.0.0-20220328201542-3ee0da9b0b42 // indirect
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 // indirect
sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect
sigs.k8s.io/yaml v1.2.0 // indirect
)

Expand Down
Loading

0 comments on commit f5f5a12

Please sign in to comment.