From 3babb546ac67b54516b4d04dae39dc67c7496b4a Mon Sep 17 00:00:00 2001 From: Rafa Date: Wed, 1 Dec 2021 13:31:00 +0000 Subject: [PATCH 1/8] Update dp-component-test --- go.mod | 28 ++++++++--------- go.sum | 99 ++++++++++++++++++++-------------------------------------- 2 files changed, 47 insertions(+), 80 deletions(-) diff --git a/go.mod b/go.mod index 9a6655f7..ec99aec4 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ replace github.com/coreos/etcd => github.com/coreos/etcd v3.3.24+incompatible require ( github.com/ONSdigital/dp-api-clients-go/v2 v2.4.4 github.com/ONSdigital/dp-authorisation v0.2.0 - github.com/ONSdigital/dp-component-test v0.6.1 + github.com/ONSdigital/dp-component-test v0.6.3 github.com/ONSdigital/dp-elasticsearch/v2 v2.3.0 github.com/ONSdigital/dp-healthcheck v1.2.1 github.com/ONSdigital/dp-net v1.2.0 @@ -24,14 +24,14 @@ require ( require ( github.com/ONSdigital/dp-api-clients-go v1.41.1 // indirect - github.com/ONSdigital/dp-mongodb-in-memory v1.0.0 // indirect + github.com/ONSdigital/dp-mongodb-in-memory v1.1.0 // indirect github.com/ONSdigital/dp-rchttp v1.0.0 // indirect github.com/ONSdigital/go-ns v0.0.0-20200205115900-a11716f93bad // indirect github.com/aws/aws-sdk-go v1.38.15 // indirect github.com/cucumber/gherkin-go/v19 v19.0.3 // indirect github.com/cucumber/messages-go/v16 v16.0.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/fatih/color v1.12.0 // indirect + github.com/fatih/color v1.13.0 // indirect github.com/go-stack/stack v1.8.0 // indirect github.com/gofrs/uuid v4.0.0+incompatible // indirect github.com/golang/snappy v0.0.1 // indirect @@ -39,13 +39,13 @@ require ( github.com/hashicorp/go-immutable-radix v1.3.0 // indirect github.com/hashicorp/go-memdb v1.3.0 // indirect github.com/hashicorp/golang-lru v0.5.4 // indirect - github.com/hokaccha/go-prettyjson v0.0.0-20210113012101-fb4e108d2519 // indirect + github.com/hokaccha/go-prettyjson v0.0.0-20211117102719-0474bc63780f // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/jtolds/gls v4.20.0+incompatible // indirect github.com/justinas/alice v1.2.0 // indirect - github.com/klauspost/compress v1.9.5 // indirect - github.com/mattn/go-colorable v0.1.8 // indirect - github.com/mattn/go-isatty v0.0.13 // indirect + github.com/klauspost/compress v1.13.6 // indirect + github.com/mattn/go-colorable v0.1.12 // indirect + github.com/mattn/go-isatty v0.0.14 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/smartystreets/assertions v1.2.0 // indirect github.com/spf13/afero v1.6.0 // indirect @@ -57,11 +57,11 @@ require ( github.com/xdg-go/scram v1.0.2 // indirect github.com/xdg-go/stringprep v1.0.2 // indirect github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect - go.mongodb.org/mongo-driver v1.7.1 // indirect - golang.org/x/crypto v0.0.0-20210314154223-e6e6c4f2bb5b // indirect - golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d // indirect - golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9 // indirect - golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e // indirect - golang.org/x/text v0.3.6 // indirect - gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 // indirect + go.mongodb.org/mongo-driver v1.8.0 // indirect + golang.org/x/crypto v0.0.0-20211117183948-ae814b36b871 // indirect + golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 // indirect + golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect + golang.org/x/sys v0.0.0-20211124211545-fe61309f8881 // indirect + golang.org/x/text v0.3.7 // indirect + gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect ) diff --git a/go.sum b/go.sum index 5654641d..44effc12 100644 --- a/go.sum +++ b/go.sum @@ -22,8 +22,8 @@ github.com/ONSdigital/dp-api-clients-go/v2 v2.4.4 h1:v04tB2xmVgrSIsskm+jGkmjsE/1 github.com/ONSdigital/dp-api-clients-go/v2 v2.4.4/go.mod h1:oB+Pw1BJlLHUh+a6BJY52VFTRGBEM5RSPlg2Xkq7D9k= github.com/ONSdigital/dp-authorisation v0.2.0 h1:QVjTUSR3c1swZwP7lMbvnBsh4Je9oc54eGzgwPOvHOc= github.com/ONSdigital/dp-authorisation v0.2.0/go.mod h1:Tg3BiohT3+bRv4vr4aid/1Rf+S3eXLUI8oHbOLFqFpQ= -github.com/ONSdigital/dp-component-test v0.6.1 h1:jkwTdhJQfeUoDDWSS2IzD1CRZXyNsuevML8HUSlFRRw= -github.com/ONSdigital/dp-component-test v0.6.1/go.mod h1:cfmJ48/wjetFsBO3rPX6o4QlVPKKscX2B5tWtxFVd3A= +github.com/ONSdigital/dp-component-test v0.6.3 h1:WxaKaMZGdTUAb9DNp1K+PH+Xfc8ATIXpJ3lhcUW3myk= +github.com/ONSdigital/dp-component-test v0.6.3/go.mod h1:CfpOujIEqZS5qON7sWn0LRyiP0V+5l12+2XWHB7S/oo= github.com/ONSdigital/dp-elasticsearch/v2 v2.3.0 h1:RPGEjjpnJQrbEEFY/uPf2yb4ewhRlDk9AJOc7LZfWW4= github.com/ONSdigital/dp-elasticsearch/v2 v2.3.0/go.mod h1:B+WXR1PRVgrU1/tS3UygATLVTnX+5Sp+M0w5i3LROac= github.com/ONSdigital/dp-frontend-models v1.1.0/go.mod h1:TT96P7Mi69N3Tc/jFNdbjiwG4GAaMjP26HLotFQ6BPw= @@ -33,8 +33,8 @@ github.com/ONSdigital/dp-healthcheck v1.1.0/go.mod h1:vZwyjMJiCHjp/sJ2R1ZEqzZT0r github.com/ONSdigital/dp-healthcheck v1.2.1 h1:HL0zHV5FI2Ym31gdMVNW9VLWiEJ0nrwXkVKX1MMPNr4= github.com/ONSdigital/dp-healthcheck v1.2.1/go.mod h1:XUhXoDIWPCdletDtpDOoXhmDFcc9b/kbedx96jN75aI= github.com/ONSdigital/dp-mocking v0.0.0-20190905163309-fee2702ad1b9/go.mod h1:BcIRgitUju//qgNePRBmNjATarTtynAgc0yV29VpLEk= -github.com/ONSdigital/dp-mongodb-in-memory v1.0.0 h1:lnV+Fz302qZG4x+DL2mrZ4dzLEACW4UVj8S61hSTlFI= -github.com/ONSdigital/dp-mongodb-in-memory v1.0.0/go.mod h1:1/9sBl447eRpkidK4eEZ667W8vvg/MaFNy5OnrJbStA= +github.com/ONSdigital/dp-mongodb-in-memory v1.1.0 h1:EjUU1zpIU1LElhiTMAG7qxy7Rq9+VTUtt3/lyA+K7jI= +github.com/ONSdigital/dp-mongodb-in-memory v1.1.0/go.mod h1:AQaNcbSS18WtldA4iWUlHQDn9FCLB2K6ff68QnvZBqM= github.com/ONSdigital/dp-net v1.0.5-0.20200805082802-e518bc287596/go.mod h1:wDVhk2pYosQ1q6PXxuFIRYhYk2XX5+1CeRRnXpSczPY= github.com/ONSdigital/dp-net v1.0.5-0.20200805145012-9227a11caddb/go.mod h1:MrSZwDUvp8u1VJEqa+36Gwq4E7/DdceW+BDCvGes6Cs= github.com/ONSdigital/dp-net v1.0.5-0.20200805150805-cac050646ab5/go.mod h1:de3LB9tedE0tObBwa12dUOt5rvTW4qQkF5rXtt4b6CE= @@ -96,8 +96,9 @@ github.com/facebookgo/freeport v0.0.0-20150612182905-d4adf43b75b9/go.mod h1:uPmA github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM= -github.com/fatih/color v1.12.0 h1:mRhaKNwANqRgUBGKmnI5ZxEk7QXmjQeCcuYFMX2bfcc= github.com/fatih/color v1.12.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM= +github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= +github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/go-avro/avro v0.0.0-20171219232920-444163702c11/go.mod h1:kxj6THYP0dmFPk4Z+bijIAhJoGgeBfyOKXMduhvdJPA= @@ -107,30 +108,6 @@ github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9 github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/gobuffalo/attrs v0.0.0-20190224210810-a9411de4debd/go.mod h1:4duuawTqi2wkkpB4ePgWMaai6/Kc6WEz83bhFwpHzj0= -github.com/gobuffalo/depgen v0.0.0-20190329151759-d478694a28d3/go.mod h1:3STtPUQYuzV0gBVOY3vy6CfMm/ljR4pABfrTeHNLHUY= -github.com/gobuffalo/depgen v0.1.0/go.mod h1:+ifsuy7fhi15RWncXQQKjWS9JPkdah5sZvtHc2RXGlg= -github.com/gobuffalo/envy v1.6.15/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI= -github.com/gobuffalo/envy v1.7.0/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI= -github.com/gobuffalo/flect v0.1.0/go.mod h1:d2ehjJqGOH/Kjqcoz+F7jHTBbmDb38yXA598Hb50EGs= -github.com/gobuffalo/flect v0.1.1/go.mod h1:8JCgGVbRjJhVgD6399mQr4fx5rRfGKVzFjbj6RE/9UI= -github.com/gobuffalo/flect v0.1.3/go.mod h1:8JCgGVbRjJhVgD6399mQr4fx5rRfGKVzFjbj6RE/9UI= -github.com/gobuffalo/genny v0.0.0-20190329151137-27723ad26ef9/go.mod h1:rWs4Z12d1Zbf19rlsn0nurr75KqhYp52EAGGxTbBhNk= -github.com/gobuffalo/genny v0.0.0-20190403191548-3ca520ef0d9e/go.mod h1:80lIj3kVJWwOrXWWMRzzdhW3DsrdjILVil/SFKBzF28= -github.com/gobuffalo/genny v0.1.0/go.mod h1:XidbUqzak3lHdS//TPu2OgiFB+51Ur5f7CSnXZ/JDvo= -github.com/gobuffalo/genny v0.1.1/go.mod h1:5TExbEyY48pfunL4QSXxlDOmdsD44RRq4mVZ0Ex28Xk= -github.com/gobuffalo/gitgen v0.0.0-20190315122116-cc086187d211/go.mod h1:vEHJk/E9DmhejeLeNt7UVvlSGv3ziL+djtTr3yyzcOw= -github.com/gobuffalo/gogen v0.0.0-20190315121717-8f38393713f5/go.mod h1:V9QVDIxsgKNZs6L2IYiGR8datgMhB577vzTDqypH360= -github.com/gobuffalo/gogen v0.1.0/go.mod h1:8NTelM5qd8RZ15VjQTFkAW6qOMx5wBbW4dSCS3BY8gg= -github.com/gobuffalo/gogen v0.1.1/go.mod h1:y8iBtmHmGc4qa3urIyo1shvOD8JftTtfcKi+71xfDNE= -github.com/gobuffalo/logger v0.0.0-20190315122211-86e12af44bc2/go.mod h1:QdxcLw541hSGtBnhUc4gaNIXRjiDppFGaDqzbrBd3v8= -github.com/gobuffalo/mapi v1.0.1/go.mod h1:4VAGh89y6rVOvm5A8fKFxYG+wIW6LO1FMTG9hnKStFc= -github.com/gobuffalo/mapi v1.0.2/go.mod h1:4VAGh89y6rVOvm5A8fKFxYG+wIW6LO1FMTG9hnKStFc= -github.com/gobuffalo/packd v0.0.0-20190315124812-a385830c7fc0/go.mod h1:M2Juc+hhDXf/PnmBANFCqx4DM3wRbgDvnVWeG2RIxq4= -github.com/gobuffalo/packd v0.1.0/go.mod h1:M2Juc+hhDXf/PnmBANFCqx4DM3wRbgDvnVWeG2RIxq4= -github.com/gobuffalo/packr/v2 v2.0.9/go.mod h1:emmyGweYTm6Kdper+iywB6YK5YzuKchGtJQZ0Odn4pQ= -github.com/gobuffalo/packr/v2 v2.2.0/go.mod h1:CaAwI0GPIAv+5wKLtv8Afwl+Cm78K/I/VCm/3ptBN+0= -github.com/gobuffalo/syncx v0.0.0-20190224160051-33c29581e754/go.mod h1:HhnNqWY95UYwwW3uSASeV7vtgYkT2t16hJgV3AEPUpw= github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw= github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= @@ -200,14 +177,14 @@ github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0m github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= github.com/hokaccha/go-prettyjson v0.0.0-20190818114111-108c894c2c0e/go.mod h1:pFlLw2CfqZiIBOx6BuCeRLCrfxBJipTY0nIOF/VbGcI= -github.com/hokaccha/go-prettyjson v0.0.0-20210113012101-fb4e108d2519 h1:nqAlWFEdqI0ClbTDrhDvE/8LeQ4pftrqKUX9w5k0j3s= github.com/hokaccha/go-prettyjson v0.0.0-20210113012101-fb4e108d2519/go.mod h1:pFlLw2CfqZiIBOx6BuCeRLCrfxBJipTY0nIOF/VbGcI= +github.com/hokaccha/go-prettyjson v0.0.0-20211117102719-0474bc63780f h1:7LYC+Yfkj3CTRcShK0KOL/w6iTiKyqqBA9a41Wnggw8= +github.com/hokaccha/go-prettyjson v0.0.0-20211117102719-0474bc63780f/go.mod h1:pFlLw2CfqZiIBOx6BuCeRLCrfxBJipTY0nIOF/VbGcI= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= 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/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= @@ -216,16 +193,13 @@ github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfV github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/justinas/alice v1.2.0 h1:+MHSA/vccVCF4Uq37S42jwlkvI2Xzl7zTPCN5BnZNVo= github.com/justinas/alice v1.2.0/go.mod h1:fN5HRH/reO/zrUflLfTN43t3vXvKzvZIENsNEe7i7qA= -github.com/karrick/godirwalk v1.8.0/go.mod h1:H5KPZjojv4lE+QYImBI8xVtrBRgYrIVsaRPx4tDPEn4= -github.com/karrick/godirwalk v1.10.3/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0LhBygSwrAsHA= github.com/kelseyhightower/envconfig v1.4.0 h1:Im6hONhd3pLkfDFsbRgu68RDNkGF1r3dvMUtDTo2cv8= github.com/kelseyhightower/envconfig v1.4.0/go.mod h1:cccZRl6mQpaq41TPp5QxidR+Sa3axMbJDNb//FQX6Gg= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/klauspost/compress v1.9.5 h1:U+CaK85mrNNb4k8BNOfgJtJ/gr6kswUCFj6miSzVC6M= -github.com/klauspost/compress v1.9.5/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= +github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc= +github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= @@ -235,18 +209,19 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= -github.com/markbates/oncer v0.0.0-20181203154359-bf2de49a0be2/go.mod h1:Ld9puTsIW75CHf65OeIOkyKbteujpZVXDpWK6YGZbxE= -github.com/markbates/safe v1.0.1/go.mod h1:nAqgmRi7cY2nqMc92/bSEeQA+R4OheNU2T1kNSCBdG0= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= -github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8= github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= +github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= +github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40= +github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= -github.com/mattn/go-isatty v0.0.13 h1:qdl+GuBjcsKKDco5BsxPJlId98mSWNKqYA+Co0SC1yA= github.com/mattn/go-isatty v0.0.13/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= +github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/maxcnunes/httpfake v1.2.4 h1:l7s/N7zuG6XpzG+5dUolg5SSoR3hANQxqzAkv+lREko= github.com/maxcnunes/httpfake v1.2.4/go.mod h1:rWVxb0bLKtOUM/5hN3UO1VEdEitz1hfcTXs7UyiK6r0= @@ -268,7 +243,6 @@ github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRW github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= -github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -287,17 +261,12 @@ github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= -github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rogpeppe/go-internal v1.2.2/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= -github.com/sirupsen/logrus v1.4.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= -github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= -github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/assertions v1.2.0 h1:42S6lae5dvLc7BrLu/0ugRtcFVjoJNMC/N3yZFZkDFs= github.com/smartystreets/assertions v1.2.0/go.mod h1:tcbTF8ujkAEcZ8TElKY+i30BzYlVhC/LOxJk7iOWnoo= @@ -310,7 +279,6 @@ github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B github.com/spf13/afero v1.6.0 h1:xoax2sJ2DT8S8xA2paPFjDCScCNeWsg75VG0DLRreiY= github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= -github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v1.1.1/go.mod h1:WnodtKOvamDL/PwE2M4iKs8aMDBZ5Q5klgD3qfVJQMI= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= @@ -346,8 +314,8 @@ github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d h1:splanxYIlg+5LfHAM6xpdFEAYOk8iySO56hMFq6uLyA= github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= -go.mongodb.org/mongo-driver v1.7.1 h1:jwqTeEM3x6L9xDXrCxN0Hbg7vdGfPBOTIkr0+/LYZDA= -go.mongodb.org/mongo-driver v1.7.1/go.mod h1:Q4oFMbo1+MSNqICAdYMlC/zSTrwCogR4R8NzkI+yfU8= +go.mongodb.org/mongo-driver v1.8.0 h1:R/P/JJzu8LJvJ1lDfph9GLNIKQxEtIHFfnUUUve35zY= +go.mongodb.org/mongo-driver v1.8.0/go.mod h1:0sQWfOeY63QTntERDJJ/0SuKK0T1uVSgKCuAROlKEPY= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= @@ -356,14 +324,14 @@ go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190422162423-af44ce270edf/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20210314154223-e6e6c4f2bb5b h1:wSOdpTq0/eI46Ez/LkDwIsAKA71YP2SRKBODiRWM0as= +golang.org/x/crypto v0.0.0-20201216223049-8b5274cf687f/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/crypto v0.0.0-20210314154223-e6e6c4f2bb5b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= +golang.org/x/crypto v0.0.0-20211117183948-ae814b36b871 h1:/pEO3GD/ABYAjuakUS6xSEmmlyVS4kxBNkeA9tLJiTI= +golang.org/x/crypto v0.0.0-20211117183948-ae814b36b871/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -401,8 +369,9 @@ golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/ golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d h1:20cMwl2fHAzkJMEA+8J4JgqBQcQGzbisXo31MIeenXI= golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 h1:CIJ76btIcR3eFI5EgSo6k1qKw9KJexJuRLI9G7Hp5wE= +golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -410,11 +379,10 @@ golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190412183630-56d357773e84/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9 h1:SQFwaSi55rU7vdNs9Yr0Z324VNlrF+0wMqRXT4St8ck= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -424,13 +392,9 @@ golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190419153524-e8e3143a4f4a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190531175056-4c3a928424d2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -441,16 +405,21 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210414055047-fe65e336abe0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e h1:WUoyKPm6nCo1BnNUvPGnFG3T5DUVem42yDJZZ4CNxMA= +golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211124211545-fe61309f8881 h1:TyHqChC80pFkXWraUUf6RuB5IqFdQieMLwwCJokV2pc= +golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -461,9 +430,6 @@ golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3 golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190329151228-23e29df326fe/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190416151739-9c9e1878f421/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190420181800-aa740d480789/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190531172133-b3315ee88b7d/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= @@ -514,8 +480,9 @@ gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 h1:tQIYjPdBoyREyB9XMu+nnTclpTYkz2zFM+lzLJFO4gQ= gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= From 6da88c767f8ac614e4aff6a38c659d3e64e72a8c Mon Sep 17 00:00:00 2001 From: Jon Dewi Jones Date: Fri, 17 Dec 2021 15:17:33 +0000 Subject: [PATCH 2/8] add additional content types --- api/search.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/api/search.go b/api/search.go index 99a8f7b6..3cc2bd9c 100644 --- a/api/search.go +++ b/api/search.go @@ -18,7 +18,10 @@ const defaultContentTypes string = "bulletin," + "article," + "article_download," + "compendium_landing_page," + + "compendium_chapter," + + "compendium_data," + "reference_tables," + + "dataset," + "dataset_landing_page," + "static_adhoc," + "static_article," + @@ -28,7 +31,11 @@ const defaultContentTypes string = "bulletin," + "static_methodology_download," + "static_page," + "static_qmi," + - "timeseries" + "timeseries," + + "timeseries_dataset," + + "product_page," + + "release," + + "reference_tables" var serverErrorMessage = "internal server error" From ced8904751a8c738c3a8cf556740bc185b1b29a3 Mon Sep 17 00:00:00 2001 From: rahulmadathumpalliyalil Date: Wed, 22 Dec 2021 18:13:33 +0000 Subject: [PATCH 3/8] Enable linter to the seacrh api repo --- .golangci.yml | 96 +++++++++++++++++++ api/api.go | 2 +- api/data.go | 8 +- api/data_test.go | 1 - api/health.go | 2 +- api/search.go | 3 +- api/search_test.go | 1 - api/timeseries.go | 6 +- api/timeseries_test.go | 1 - config/config.go | 4 +- config/config_test.go | 3 - elasticsearch/assets.go | 4 +- elasticsearch/assets_test.go | 10 +- elasticsearch/client.go | 35 ++++--- elasticsearch/client_test.go | 24 +---- features/steps/component.go | 5 +- features/steps/fakeapi.go | 4 +- features/steps/steps.go | 18 ++-- main_test.go | 7 +- query/query.go | 5 +- query/query_test.go | 8 +- query/search.go | 9 +- query/search_test.go | 4 - service/initialise.go | 1 - service/service.go | 31 +++--- .../search/contentFilterOnFirstLetter.tmpl | 2 +- templates/search/contentFilterOnLatest.tmpl | 2 +- .../search/contentFilterOnUriPrefix.tmpl | 4 +- templates/search/contentFilters.tmpl | 6 +- templates/search/countQuery.tmpl | 4 +- transformer/transformer.go | 22 ++--- transformer/transformer_test.go | 16 ++-- 32 files changed, 201 insertions(+), 147 deletions(-) create mode 100644 .golangci.yml diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 00000000..faf8d96b --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,96 @@ +# This file was inspired by the golangci-lint one: +# https://github.com/golangci/golangci-lint/blob/master/.golangci.yml +run: + # default concurrency is a available CPU number + concurrency: 4 + + # timeout for analysis, e.g. 30s, 5m, default is 1m + timeout: 5m +linters-settings: + govet: + check-shadowing: true + golint: + min-confidence: 0 + gocyclo: + min-complexity: 15 + maligned: + suggest-new: true + dupl: + threshold: 100 + goconst: + min-len: 2 + min-occurrences: 2 + misspell: + locale: UK + lll: + line-length: 140 + gofmt: + simplify: false + gocritic: + enabled-tags: + - diagnostic + - experimental + - opinionated + - performance + - style + disabled-checks: + - wrapperFunc + - dupImport # https://github.com/go-critic/go-critic/issues/845 + - ifElseChain + - octalLiteral + - hugeParam + funlen: + # lines: 100 + # statements: 100 + +linters: + # please, do not use `enable-all`: it's deprecated and will be removed soon. + # inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint + disable-all: true + enable: + - deadcode + - depguard + - dogsled + - errcheck + - gochecknoinits + - goconst + - gocritic + - gocyclo + - gofmt + - goimports + - revive + - gosec + - gosimple + - govet + - ineffassign + - nakedret + - staticcheck + - structcheck + - stylecheck + - typecheck + - unconvert + - unused + - varcheck + - whitespace + - gocognit + - prealloc + +issues: + exclude-rules: + - path: _test\.go + linters: + - gocyclo + - errcheck + - dupl + - gosec + - path: features/steps/ + linters: + - unused + new: false + +# golangci.com configuration +# https://github.com/golangci/golangci/wiki/Configuration +service: + golangci-lint-version: 1.43.x # use the fixed version to not introduce new linters unexpectedly + prepare: + - echo "here I can run custom commands, but no preparation needed for this repo" \ No newline at end of file diff --git a/api/api.go b/api/api.go index a83e2b16..915eaccf 100644 --- a/api/api.go +++ b/api/api.go @@ -16,7 +16,7 @@ var ( update = auth.Permissions{Update: true} ) -//SearchAPI provides an API around elasticseach +// SearchAPI provides an API around elasticseach type SearchAPI struct { Router *mux.Router QueryBuilder QueryBuilder diff --git a/api/data.go b/api/data.go index 1f645e07..8a7b0e15 100644 --- a/api/data.go +++ b/api/data.go @@ -61,8 +61,8 @@ func DataLookupHandlerFunc(elasticSearchClient ElasticSearcher) http.HandlerFunc } responseData := dataLookupResponse{Responses: make([]interface{}, 1)} - if err := json.Unmarshal([]byte(responseString), &responseData.Responses[0]); err != nil { - log.Error(ctx, "failed to unmarshal response from elasticsearch for data query", err) + if unMarshalErr := json.Unmarshal(responseString, &responseData.Responses[0]); unMarshalErr != nil { + log.Error(ctx, "failed to unmarshal response from elasticsearch for data query", unMarshalErr) http.Error(w, "Failed to process data query", http.StatusInternalServerError) return } @@ -75,6 +75,8 @@ func DataLookupHandlerFunc(elasticSearchClient ElasticSearcher) http.HandlerFunc } w.Header().Set("Content-Type", "application/json;charset=utf-8") - w.Write(dataWithResponse) + if _, err := w.Write(dataWithResponse); err != nil { + log.Error(ctx, "error occured while writing response data", err) + } } } diff --git a/api/data_test.go b/api/data_test.go index 75e8b56c..70ef120d 100644 --- a/api/data_test.go +++ b/api/data_test.go @@ -12,7 +12,6 @@ import ( ) func TestDataLookupHandlerFunc(t *testing.T) { - Convey("Should return InternalError for invalid template", t, func() { setupDataTestTemplates("dummy{{.Moo}}") esMock := &ElasticSearcherMock{ diff --git a/api/health.go b/api/health.go index 5a2149f8..23ad9c11 100644 --- a/api/health.go +++ b/api/health.go @@ -47,7 +47,7 @@ func HealthCheckHandlerCreator(elasticSearchClient ElasticSearcher) func(http.Re } // return json - fmt.Fprintf(w, string(body)) + fmt.Fprint(w, string(body)) } } diff --git a/api/search.go b/api/search.go index 99a8f7b6..6e4cd906 100644 --- a/api/search.go +++ b/api/search.go @@ -117,7 +117,7 @@ func SearchHandlerFunc(queryBuilder QueryBuilder, elasticSearchClient ElasticSea return } - if !json.Valid([]byte(responseData)) { + if !json.Valid(responseData) { log.Error(ctx, "elastic search returned invalid JSON for search query", errors.New("elastic search returned invalid JSON for search query")) http.Error(w, "Failed to process search query", http.StatusInternalServerError) return @@ -139,7 +139,6 @@ func SearchHandlerFunc(queryBuilder QueryBuilder, elasticSearchClient ElasticSea http.Error(w, "Failed to write http response", http.StatusInternalServerError) return } - } } diff --git a/api/search_test.go b/api/search_test.go index 5f9ec4cc..712eec44 100644 --- a/api/search_test.go +++ b/api/search_test.go @@ -16,7 +16,6 @@ const validESResponse string = `{"raw":"response"}` const validTransformedResponse string = `{"transformed":"response"}` func TestSearchHandlerFunc(t *testing.T) { - Convey("Should return BadRequest for invalid limit parameter", t, func() { qbMock := newQueryBuilderMock(nil, nil) esMock := newElasticSearcherMock(nil, nil) diff --git a/api/timeseries.go b/api/timeseries.go index 2c7a4211..34a8d882 100644 --- a/api/timeseries.go +++ b/api/timeseries.go @@ -48,13 +48,15 @@ func TimeseriesLookupHandlerFunc(elasticSearchClient ElasticSearcher) http.Handl return } - if !json.Valid([]byte(responseData)) { + if !json.Valid(responseData) { log.Error(ctx, "elastic search returned invalid JSON for timeseries query", errors.New("elastic search returned invalid JSON for timeseries query")) http.Error(w, "Failed to process timeseries query", http.StatusInternalServerError) return } w.Header().Set("Content-Type", "application/json;charset=utf-8") - w.Write(responseData) + if _, err := w.Write(responseData); err != nil { + log.Error(ctx, "error occured while writing response data", err) + } } } diff --git a/api/timeseries_test.go b/api/timeseries_test.go index 76e98d1b..1c2c73c0 100644 --- a/api/timeseries_test.go +++ b/api/timeseries_test.go @@ -13,7 +13,6 @@ import ( ) func TestTimeseriesLookupHandlerFunc(t *testing.T) { - Convey("Should return InternalError for invalid template", t, func() { setupTimeseriesTestTemplates("dummy{{.Moo}}") esMock := &ElasticSearcherMock{ diff --git a/config/config.go b/config/config.go index b92a9dcf..435970be 100644 --- a/config/config.go +++ b/config/config.go @@ -46,6 +46,6 @@ func Get() (*Config, error) { // String is implemented to prevent sensitive fields being logged. // The config is returned as JSON with sensitive fields omitted. func (config Config) String() string { - json, _ := json.Marshal(config) - return string(json) + data, _ := json.Marshal(config) + return string(data) } diff --git a/config/config_test.go b/config/config_test.go index b10df88a..2c3e2d2b 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -12,13 +12,10 @@ import ( func TestSpec(t *testing.T) { Convey("Given an environment with no environment variables set", t, func() { cfg, err := config.Get() - Convey("When the config values are retrieved", func() { - Convey("There should be no error returned", func() { So(err, ShouldBeNil) }) - Convey("The values should be set to the expected defaults", func() { So(cfg.AwsRegion, ShouldEqual, "eu-west-1") So(cfg.AwsService, ShouldEqual, "es") diff --git a/elasticsearch/assets.go b/elasticsearch/assets.go index 406db767..0ec2a6fd 100644 --- a/elasticsearch/assets.go +++ b/elasticsearch/assets.go @@ -3,8 +3,8 @@ package elasticsearch import _ "embed" //go:embed search-index-settings.json -var searchIndexSettingsJson []byte +var searchIndexSettingsJSON []byte func GetSearchIndexSettings() []byte { - return searchIndexSettingsJson + return searchIndexSettingsJSON } diff --git a/elasticsearch/assets_test.go b/elasticsearch/assets_test.go index 5cfdf786..e4edba00 100644 --- a/elasticsearch/assets_test.go +++ b/elasticsearch/assets_test.go @@ -2,21 +2,19 @@ package elasticsearch_test import ( "encoding/json" + "testing" + "github.com/ONSdigital/dp-search-api/elasticsearch" . "github.com/smartystreets/goconvey/convey" - "testing" ) func TestGetDefaultMappings_ValidJson(t *testing.T) { Convey("File `search-index-settings.json` is valid jason", t, func() { Convey("When we get the default search index settings json", func() { - mappingsJson := elasticsearch.GetSearchIndexSettings() - + mappingsJSON := elasticsearch.GetSearchIndexSettings() Convey("Then the json returned should be valid", func() { - - So(json.Valid(mappingsJson), ShouldBeTrue) + So(json.Valid(mappingsJSON), ShouldBeTrue) }) - }) }) } diff --git a/elasticsearch/client.go b/elasticsearch/client.go index f27ab944..6332f260 100644 --- a/elasticsearch/client.go +++ b/elasticsearch/client.go @@ -3,7 +3,7 @@ package elasticsearch import ( "bytes" "context" - "io/ioutil" + "io" "net/http" "time" @@ -23,7 +23,7 @@ type Client struct { } // New creates a new elasticsearch client. Any trailing slashes from the URL are removed. -func New(url string, client dphttp.Clienter, signRequests bool, awsSDKSigner *esauth.Signer, awsService string, awsRegion string) *Client { +func New(url string, client dphttp.Clienter, signRequests bool, awsSDKSigner *esauth.Signer, awsService, awsRegion string) *Client { return &Client{ awsSDKSigner: awsSDKSigner, awsRegion: awsRegion, @@ -35,27 +35,26 @@ func New(url string, client dphttp.Clienter, signRequests bool, awsSDKSigner *es } // Search is a method that wraps the Search function of the elasticsearch package -func (cli *Client) Search(ctx context.Context, index string, docType string, request []byte) ([]byte, error) { +func (cli *Client) Search(ctx context.Context, index, docType string, request []byte) ([]byte, error) { return cli.post(ctx, index, docType, "_search", request) } // MultiSearch is a method that wraps the MultiSearch function of the elasticsearch package -func (cli *Client) MultiSearch(ctx context.Context, index string, docType string, request []byte) ([]byte, error) { +func (cli *Client) MultiSearch(ctx context.Context, index, docType string, request []byte) ([]byte, error) { return cli.post(ctx, index, docType, "_msearch", request) } // GetStatus makes status call for healthcheck purposes func (cli *Client) GetStatus(ctx context.Context) ([]byte, error) { - - req, err := http.NewRequest("GET", cli.url+"/_cat/health", nil) + req, err := http.NewRequest("GET", cli.url+"/_cat/health", http.NoBody) if err != nil { return nil, err } if cli.signRequests { reader := bytes.NewReader([]byte{}) - if err = cli.awsSDKSigner.Sign(req, reader, time.Now()); err != nil { - return nil, err + if awsSignErr := cli.awsSDKSigner.Sign(req, reader, time.Now()); awsSignErr != nil { + return nil, awsSignErr } } @@ -65,7 +64,7 @@ func (cli *Client) GetStatus(ctx context.Context) ([]byte, error) { } defer resp.Body.Close() - response, err := ioutil.ReadAll(resp.Body) + response, err := io.ReadAll(resp.Body) if err != nil { return nil, errors.Wrap(err, "elaticsearchClient error reading get status response body") } @@ -73,7 +72,7 @@ func (cli *Client) GetStatus(ctx context.Context) ([]byte, error) { return response, err } -func (cli *Client) post(ctx context.Context, index string, docType string, action string, request []byte) ([]byte, error) { +func (cli *Client) post(ctx context.Context, index, docType, action string, request []byte) ([]byte, error) { reader := bytes.NewReader(request) req, err := http.NewRequest("POST", cli.url+"/"+buildContext(index, docType)+action, reader) if err != nil { @@ -81,8 +80,8 @@ func (cli *Client) post(ctx context.Context, index string, docType string, actio } if cli.signRequests { - if err = cli.awsSDKSigner.Sign(req, reader, time.Now()); err != nil { - return nil, err + if awsSignErr := cli.awsSDKSigner.Sign(req, reader, time.Now()); awsSignErr != nil { + return nil, awsSignErr } } @@ -92,7 +91,7 @@ func (cli *Client) post(ctx context.Context, index string, docType string, actio } defer resp.Body.Close() - response, err := ioutil.ReadAll(resp.Body) + response, err := io.ReadAll(resp.Body) if err != nil { return nil, errors.Wrap(err, "elaticsearchClient error reading post response body") } @@ -100,13 +99,13 @@ func (cli *Client) post(ctx context.Context, index string, docType string, actio return response, err } -func buildContext(index string, docType string) string { - context := "" +func buildContext(index, docType string) string { + ctx := "" if len(index) > 0 { - context = index + "/" + ctx = index + "/" if len(docType) > 0 { - context += docType + "/" + ctx += docType + "/" } } - return context + return ctx } diff --git a/elasticsearch/client_test.go b/elasticsearch/client_test.go index 21b416c4..420f1a50 100644 --- a/elasticsearch/client_test.go +++ b/elasticsearch/client_test.go @@ -3,7 +3,7 @@ package elasticsearch import ( "context" "errors" - "io/ioutil" + "io" "net/http" "net/http/httptest" "testing" @@ -14,10 +14,8 @@ import ( ) func TestSearch(t *testing.T) { - Convey("When Search is called", t, func() { // Define a mock struct to be used in your unit tests of myFunc. - Convey("Then a request with the search action should be posted", func() { dphttpMock := &dphttp.ClienterMock{ DoFunc: func(ctx context.Context, req *http.Request) (*http.Response, error) { @@ -36,10 +34,9 @@ func TestSearch(t *testing.T) { actualRequest := dphttpMock.DoCalls()[0].Req So(actualRequest.URL.String(), ShouldResemble, "http://localhost:999/index/doctype/_search") So(actualRequest.Method, ShouldResemble, "POST") - body, err := ioutil.ReadAll(actualRequest.Body) + body, err := io.ReadAll(actualRequest.Body) So(err, ShouldBeNil) So(string(body), ShouldResemble, "search request") - }) Convey("Then a returned error should be passed back", func() { @@ -60,21 +57,16 @@ func TestSearch(t *testing.T) { actualRequest := dphttpMock.DoCalls()[0].Req So(actualRequest.URL.String(), ShouldResemble, "http://localhost:999/index/doctype/_search") So(actualRequest.Method, ShouldResemble, "POST") - body, err := ioutil.ReadAll(actualRequest.Body) + body, err := io.ReadAll(actualRequest.Body) So(err, ShouldBeNil) So(string(body), ShouldResemble, "search request") - }) - }) } func TestMultiSearch(t *testing.T) { - Convey("When MultiSearch is called", t, func() { - Convey("Then a request with the multi search action should be posted", func() { - dphttpMock := &dphttp.ClienterMock{ DoFunc: func(ctx context.Context, req *http.Request) (*http.Response, error) { return newResponse("moo"), nil @@ -92,7 +84,7 @@ func TestMultiSearch(t *testing.T) { actualRequest := dphttpMock.DoCalls()[0].Req So(actualRequest.URL.String(), ShouldResemble, "http://localhost:999/index/doctype/_msearch") So(actualRequest.Method, ShouldResemble, "POST") - body, err := ioutil.ReadAll(actualRequest.Body) + body, err := io.ReadAll(actualRequest.Body) So(err, ShouldBeNil) So(string(body), ShouldResemble, "multiSearch request") }) @@ -114,20 +106,16 @@ func TestMultiSearch(t *testing.T) { actualRequest := dphttpMock.DoCalls()[0].Req So(actualRequest.URL.String(), ShouldResemble, "http://localhost:999/index/doctype/_msearch") So(actualRequest.Method, ShouldResemble, "POST") - body, err := ioutil.ReadAll(actualRequest.Body) + body, err := io.ReadAll(actualRequest.Body) So(err, ShouldBeNil) So(string(body), ShouldResemble, "search request") - }) }) } func TestGetStatus(t *testing.T) { - Convey("When GetStatus is called", t, func() { - Convey("Then a GET request with the status action should be called", func() { - dphttpMock := &dphttp.ClienterMock{ DoFunc: func(ctx context.Context, req *http.Request) (*http.Response, error) { return newResponse("moo"), nil @@ -165,7 +153,6 @@ func TestGetStatus(t *testing.T) { actualRequest := dphttpMock.DoCalls()[0].Req So(actualRequest.URL.String(), ShouldResemble, "http://localhost:999/_cat/health") So(actualRequest.Method, ShouldResemble, "GET") - }) Convey("Then a signing error should be passed back", func() { @@ -182,7 +169,6 @@ func TestGetStatus(t *testing.T) { _, err := client.GetStatus(context.Background()) So(err, ShouldNotBeNil) So(err.Error(), ShouldResemble, "v4 signer missing. Cannot sign request") - }) }) } diff --git a/features/steps/component.go b/features/steps/component.go index 19609f2a..87be9a58 100644 --- a/features/steps/component.go +++ b/features/steps/component.go @@ -14,7 +14,6 @@ import ( "github.com/ONSdigital/dp-search-api/config" "github.com/ONSdigital/dp-search-api/service" mocks "github.com/ONSdigital/dp-search-api/service/mock" - "github.com/maxcnunes/httpfake" ) const ( @@ -30,7 +29,6 @@ type Component struct { cfg *config.Config ErrorFeature componentTest.ErrorFeature FakeElasticSearchAPI *FakeAPI - fakeRequest *httpfake.Request HTTPServer *http.Server ServiceRunning bool svc *service.Service @@ -95,7 +93,6 @@ func (c *Component) InitAPIFeature() *componentTest.APIFeature { // Reset resets the search api component (should not reset Fake APIs) func (c *Component) Reset() *Component { - return c } @@ -124,7 +121,7 @@ func getHealthCheckOK(cfg *config.Config, buildTime, gitCommit, version string) }, nil } -func (c *Component) getHealthClient(name string, url string) *health.Client { +func (c *Component) getHealthClient(name, url string) *health.Client { return &health.Client{ URL: url, Name: "elasticsearch", diff --git a/features/steps/fakeapi.go b/features/steps/fakeapi.go index b2a66227..f25a438a 100644 --- a/features/steps/fakeapi.go +++ b/features/steps/fakeapi.go @@ -2,7 +2,7 @@ package steps import ( "fmt" - "io/ioutil" + "io" "net/http" "testing" @@ -24,7 +24,7 @@ func NewFakeAPI(t testing.TB) *FakeAPI { fa.collectOutboundRequestBodies = func(r *http.Request) error { // inspect request - body, err := ioutil.ReadAll(r.Body) + body, err := io.ReadAll(r.Body) if err != nil { return fmt.Errorf("error reading the outbound request body: %s", err.Error()) } diff --git a/features/steps/steps.go b/features/steps/steps.go index 3772effd..7b1ac5c0 100644 --- a/features/steps/steps.go +++ b/features/steps/steps.go @@ -3,12 +3,12 @@ package steps import ( "encoding/json" "fmt" - "io/ioutil" - - "github.com/google/go-cmp/cmp" + "io" + "os" "github.com/ONSdigital/dp-search-api/transformer" "github.com/cucumber/godog" + "github.com/google/go-cmp/cmp" ) // RegisterSteps registers the specific steps needed to do component tests for the search api @@ -22,7 +22,7 @@ func (c *Component) RegisterSteps(ctx *godog.ScenarioContext) { } func (c *Component) successfullyReturnMultipleSearchResults() error { - body, err := ioutil.ReadFile("./features/testdata/es_mulitple_search_results.json") + body, err := os.ReadFile("./features/testdata/es_mulitple_search_results.json") if err != nil { return err } @@ -33,7 +33,7 @@ func (c *Component) successfullyReturnMultipleSearchResults() error { } func (c *Component) successfullyReturnSingleSearchResult() error { - body, err := ioutil.ReadFile("./features/testdata/es_single_search_result.json") + body, err := os.ReadFile("./features/testdata/es_single_search_result.json") if err != nil { return err } @@ -44,7 +44,7 @@ func (c *Component) successfullyReturnSingleSearchResult() error { } func (c *Component) successfullyReturnNoSearchResults() error { - body, err := ioutil.ReadFile("./features/testdata/es_zero_search_results.json") + body, err := os.ReadFile("./features/testdata/es_zero_search_results.json") if err != nil { return err } @@ -63,7 +63,7 @@ func (c *Component) failureInternalServerError() error { func (c *Component) iShouldReceiveTheFollowingSearchResponse(expectedJSONFile string) error { var searchResponse, expectedSearchResponse transformer.SearchResponse - responseBody, err := ioutil.ReadAll(c.APIFeature.HttpResponse.Body) + responseBody, err := io.ReadAll(c.APIFeature.HttpResponse.Body) if err != nil { return fmt.Errorf("failed to read response of search api component - error: %v", err) } @@ -72,7 +72,7 @@ func (c *Component) iShouldReceiveTheFollowingSearchResponse(expectedJSONFile st if err != nil { return fmt.Errorf("failed to unmarshal response of search api component - error: %v", err) } - expectedSearchResults, err := ioutil.ReadFile(expectedJSONFile) + expectedSearchResults, err := os.ReadFile(expectedJSONFile) if err != nil { return fmt.Errorf("failed to read file of expected results - error: %v", err) } @@ -83,7 +83,7 @@ func (c *Component) iShouldReceiveTheFollowingSearchResponse(expectedJSONFile st } if diff := cmp.Diff(expectedSearchResponse, searchResponse); diff != "" { - return fmt.Errorf("Expected response mismatch (-expected +actual):\n%s", diff) + return fmt.Errorf("expected response mismatch (-expected +actual):\n%s", diff) } return c.ErrorFeature.StepError() diff --git a/main_test.go b/main_test.go index 28ae1f10..0342ca7b 100644 --- a/main_test.go +++ b/main_test.go @@ -30,19 +30,20 @@ func (c *ComponentTest) InitializeScenario(godogCtx *godog.ScenarioContext) { apiFeature := apiComponent.InitAPIFeature() - godogCtx.BeforeScenario(func(*godog.Scenario) { + godogCtx.Before(func(ctx context.Context, sc *godog.Scenario) (context.Context, error) { apiFeature.Reset() c.AuthFeature.Reset() apiComponent.Reset() + return context.Background(), nil }) - godogCtx.AfterScenario(func(*godog.Scenario, error) { + godogCtx.After(func(ctx context.Context, sc *godog.Scenario, err error) (context.Context, error) { if err := apiComponent.Close(); err != nil { fmt.Println(ctx, "error occurred while closing the api component - error: #{err}") os.Exit(1) } + return context.Background(), nil }) - apiComponent.RegisterSteps(godogCtx) c.AuthFeature.RegisterSteps(godogCtx) } diff --git a/query/query.go b/query/query.go index 62f72719..d33829e1 100644 --- a/query/query.go +++ b/query/query.go @@ -28,7 +28,7 @@ func NewQueryBuilder(pathToTemplates string) (*Builder, error) { // FormatMultiQuery minifies and reformats an elasticsearch MultiQuery func FormatMultiQuery(rawQuery []byte) ([]byte, error) { - //Is minify thread Safe? can I put this as a global? + // Is minify thread Safe? can I put this as a global? m := minify.New() m.AddFuncRegexp(regexp.MustCompile("[/+]js$"), js.Minify) @@ -37,7 +37,6 @@ func FormatMultiQuery(rawQuery []byte) ([]byte, error) { return nil, err } - //Put new lines in for ElasticSearch to determine the headers and the queries are detected + // Put new lines in for ElasticSearch to determine the headers and the queries are detected return bytes.Replace(linearQuery, []byte("$$"), []byte("\n"), -1), nil - } diff --git a/query/query_test.go b/query/query_test.go index abce9507..2ea445cf 100644 --- a/query/query_test.go +++ b/query/query_test.go @@ -1,20 +1,19 @@ package query import ( - . "github.com/smartystreets/goconvey/convey" "testing" + + . "github.com/smartystreets/goconvey/convey" ) var testPathToTemplates = "../" func TestSetupSearch(t *testing.T) { Convey("Should return templates and error should be nil", t, func() { - searchTemplates, err := SetupSearch(testPathToTemplates) So(err, ShouldBeNil) So(searchTemplates, ShouldNotBeNil) - }) } @@ -24,6 +23,5 @@ func TestNewQueryBuilder(t *testing.T) { So(builderObject.searchTemplates, ShouldNotBeNil) So(err, ShouldBeNil) - }) -} \ No newline at end of file +} diff --git a/query/search.go b/query/search.go index 956c259b..ec3df8eb 100644 --- a/query/search.go +++ b/query/search.go @@ -24,7 +24,7 @@ type searchRequest struct { FilterOnFirstLetter string ReleasedAfter string ReleasedBefore string - UriPrefix string + URIPrefix string Topic []string TopicWildcard []string Upcoming bool @@ -34,8 +34,8 @@ type searchRequest struct { // SetupSearch loads templates for use by the search handler and should be done only once func SetupSearch(pathToTemplates string) (*template.Template, error) { - //Load the templates once, the main entry point for the templates is search.tmpl. The search.tmpl takes - //the SearchRequest struct and uses the Request to build up the multi-query queries that is used to query elastic. + // Load the templates once, the main entry point for the templates is search.tmpl. The search.tmpl takes + // the SearchRequest struct and uses the Request to build up the multi-query queries that is used to query elastic. templates, err := template.ParseFiles( pathToTemplates+"templates/search/search.tmpl", @@ -73,7 +73,6 @@ func SetupSearch(pathToTemplates string) (*template.Template, error) { // BuildSearchQuery creates an elastic search query from the provided search parameters func (sb *Builder) BuildSearchQuery(ctx context.Context, q, contentTypes, sort string, limit, offset int) ([]byte, error) { - reqParams := searchRequest{ Term: q, From: offset, @@ -96,7 +95,7 @@ func (sb *Builder) BuildSearchQuery(ctx context.Context, q, contentTypes, sort s return nil, errors.Wrap(err, "creation of search from template failed") } - //Put new lines in for ElasticSearch to determine the headers and the queries are detected + // Put new lines in for ElasticSearch to determine the headers and the queries are detected formattedQuery, err := FormatMultiQuery(doc.Bytes()) if err != nil { return nil, errors.Wrap(err, "formating of query for elasticsearch failed") diff --git a/query/search_test.go b/query/search_test.go index c335df70..8cb0ade6 100644 --- a/query/search_test.go +++ b/query/search_test.go @@ -10,9 +10,7 @@ import ( func TestBuildSearchQuery(t *testing.T) { Convey("Should return InternalError for invalid template", t, func() { - qb := createQueryBuilderForTemplate("dummy{{.Moo}}") - query, err := qb.BuildSearchQuery(context.Background(), "", "", "", 2, 1) So(err, ShouldNotBeNil) @@ -75,7 +73,6 @@ func TestHasQuery(t *testing.T) { Convey("Should return false for excluded queries", func() { So(sr.HasQuery("oink"), ShouldBeFalse) - }) }) @@ -84,6 +81,5 @@ func TestHasQuery(t *testing.T) { Queries: []string{}, } So(sr.HasQuery("oink"), ShouldBeFalse) - }) } diff --git a/service/initialise.go b/service/initialise.go index 60240401..b4ee319d 100644 --- a/service/initialise.go +++ b/service/initialise.go @@ -74,7 +74,6 @@ func (e *Init) DoGetHTTPServer(bindAddr string, router http.Handler) HTTPServer // GetAuthorisationHandlers creates an AuthHandler client and sets the Auth flag to true func (e *ExternalServiceList) GetAuthorisationHandlers(cfg *config.Config) api.AuthHandler { - e.Auth = true return e.Init.DoGetAuthorisationHandlers(cfg) } diff --git a/service/service.go b/service/service.go index 88377f7d..a9273fa4 100644 --- a/service/service.go +++ b/service/service.go @@ -29,7 +29,7 @@ type Service struct { router *mux.Router server HTTPServer serviceList *ExternalServiceList - transformer transformer.Transformer + transformer *transformer.Transformer } // SetServer sets the http server for a service @@ -58,8 +58,8 @@ func (svc *Service) SetElasticSearchClient(elasticSearchClient elasticsearch.Cli } // SetTransformer sets the transformer for a service -func (svc *Service) SetTransformer(transformer transformer.Transformer) { - svc.transformer = transformer +func (svc *Service) SetTransformer(transformerClient *transformer.Transformer) { + svc.transformer = transformerClient } // Run the service @@ -67,8 +67,8 @@ func Run(ctx context.Context, cfg *config.Config, serviceList *ExternalServiceLi var esSigner *esauth.Signer elasticHTTPClient := dphttp.NewClient() - // Initialise transformer - transformer := transformer.New() + // Initialise transformerClient + transformerClient := transformer.New() // Initialse AWS signer if cfg.SignElasticsearchRequests { @@ -94,15 +94,15 @@ func Run(ctx context.Context, cfg *config.Config, serviceList *ExternalServiceLi // Initialise authorisation handler permissions := serviceList.GetAuthorisationHandlers(cfg) - //Get HealthCheck + // Get HealthCheck healthCheck, err := serviceList.GetHealthCheck(cfg, buildTime, gitCommit, version) if err != nil { log.Fatal(ctx, "could not instantiate healthcheck", err) return nil, err } - if err := registerCheckers(ctx, healthCheck, dpESClient); err != nil { - return nil, errors.Wrap(err, "unable to register checkers") + if regErr := registerCheckers(ctx, healthCheck, dpESClient); regErr != nil { + return nil, errors.Wrap(regErr, "unable to register checkers") } router := mux.NewRouter() @@ -112,7 +112,7 @@ func Run(ctx context.Context, cfg *config.Config, serviceList *ExternalServiceLi healthCheck.Start(ctx) // Create Search API - searchAPI, err := api.NewSearchAPI(router, dpESClient, deprecatedESClient, queryBuilder, transformer, permissions) + searchAPI, err := api.NewSearchAPI(router, dpESClient, deprecatedESClient, queryBuilder, transformerClient, permissions) if err != nil { log.Fatal(ctx, "error initialising API", err) return nil, err @@ -136,7 +136,7 @@ func Run(ctx context.Context, cfg *config.Config, serviceList *ExternalServiceLi router: router, server: server, serviceList: serviceList, - transformer: *transformer, + transformer: transformerClient, }, nil } @@ -185,16 +185,9 @@ func (svc *Service) Close(ctx context.Context) error { } func registerCheckers(ctx context.Context, hc HealthChecker, dpESClient *dpelastic.Client) (err error) { - hasErrors := false - if err = hc.AddCheck("Elasticsearch", dpESClient.Checker); err != nil { log.Error(ctx, "error creating elasticsearch health check", err) - hasErrors = true - } - - if hasErrors { - errors.New("Error(s) registering checkers for health check") + err = errors.New("Error(s) registering checkers for health check") } - - return nil + return err } diff --git a/templates/search/contentFilterOnFirstLetter.tmpl b/templates/search/contentFilterOnFirstLetter.tmpl index eb4fb137..896af21f 100644 --- a/templates/search/contentFilterOnFirstLetter.tmpl +++ b/templates/search/contentFilterOnFirstLetter.tmpl @@ -4,5 +4,5 @@ "description.title.title_first_letter": "{{.FilterOnFirstLetter}}" } } - {{if or .ReleasedBefore .ReleasedAfter .UriPrefix .Topic .TopicWildcard .Upcoming .Published}},{{end}} + {{if or .ReleasedBefore .ReleasedAfter .URIPrefix .Topic .TopicWildcard .Upcoming .Published}},{{end}} {{end}} diff --git a/templates/search/contentFilterOnLatest.tmpl b/templates/search/contentFilterOnLatest.tmpl index 4f2ce3f1..d15b3622 100644 --- a/templates/search/contentFilterOnLatest.tmpl +++ b/templates/search/contentFilterOnLatest.tmpl @@ -4,5 +4,5 @@ "description.latestRelease" : true } } - {{if or .FilterOnFirstLetter .ReleasedBefore .ReleasedAfter .UriPrefix .Topic .TopicWildcard .Upcoming .Published}},{{end}} + {{if or .FilterOnFirstLetter .ReleasedBefore .ReleasedAfter .URIPrefix .Topic .TopicWildcard .Upcoming .Published}},{{end}} {{end}} \ No newline at end of file diff --git a/templates/search/contentFilterOnUriPrefix.tmpl b/templates/search/contentFilterOnUriPrefix.tmpl index bc406069..b7724c22 100644 --- a/templates/search/contentFilterOnUriPrefix.tmpl +++ b/templates/search/contentFilterOnUriPrefix.tmpl @@ -1,7 +1,7 @@ - {{if .UriPrefix}} + {{if .URIPrefix}} { "prefix" : - { "uri" : "{{.UriPrefix}}" } + { "uri" : "{{.URIPrefix}}" } } {{if or .Topic .TopicWildcard}},{{end}} {{end}} \ No newline at end of file diff --git a/templates/search/contentFilters.tmpl b/templates/search/contentFilters.tmpl index 5b830955..4984b1ed 100644 --- a/templates/search/contentFilters.tmpl +++ b/templates/search/contentFilters.tmpl @@ -1,12 +1,12 @@ -{{ if or .FilterOnLatest .FilterOnFirstLetter .ReleasedBefore .ReleasedAfter .UriPrefix .Topic .TopicWildcard .Upcoming .Published}} +{{ if or .FilterOnLatest .FilterOnFirstLetter .ReleasedBefore .ReleasedAfter .URIPrefix .Topic .TopicWildcard .Upcoming .Published}} , "filter" : [ {{ template "contentFilterOnLatest.tmpl" . }} {{ template "contentFilterOnFirstLetter.tmpl" . }} -{{if or .UriPrefix .Topic .TopicWildcard}} +{{if or .URIPrefix .Topic .TopicWildcard}} { "bool": { "should": [ - {{ template "contentFilterOnUriPrefix.tmpl" . }} + {{ template "contentFilterOnURIPrefix.tmpl" . }} {{ template "contentFilterOnTopic.tmpl" . }} {{ template "contentFilterOnTopicWildcard.tmpl" . }} diff --git a/templates/search/countQuery.tmpl b/templates/search/countQuery.tmpl index 8406628c..7928c86f 100644 --- a/templates/search/countQuery.tmpl +++ b/templates/search/countQuery.tmpl @@ -9,10 +9,10 @@ {{- end}} } {{- template "countFilterLatest.tmpl" .}} - {{- if .UriPrefix }} + {{- if .URIPrefix }} ,"filter": [{ "prefix": { - "uri": "{{.UriPrefix}}" + "uri": "{{.URIPrefix}}" }} {{- if or .ReleasedBefore .ReleasedAfter}}, {{- end}} {{ template "contentFilterOnReleaseDate.tmpl" .}} diff --git a/transformer/transformer.go b/transformer/transformer.go index 8c3d7861..44275312 100644 --- a/transformer/transformer.go +++ b/transformer/transformer.go @@ -11,7 +11,7 @@ import ( // Transformer represents an instance of the ResponseTransformer interface type Transformer struct { - higlightReplacer strings.Replacer + higlightReplacer *strings.Replacer } // Structs representing the transformed response @@ -156,7 +156,7 @@ type ESSearchSuggestOptions struct { func New() *Transformer { highlightReplacer := strings.NewReplacer("", "", "", "") return &Transformer{ - higlightReplacer: *highlightReplacer, + higlightReplacer: highlightReplacer, } } @@ -194,16 +194,16 @@ func (t *Transformer) transform(source *ESResponse, highlight bool) SearchRespon Items: []ContentItem{}, ContentTypes: []ContentType{}, } - var took int = 0 + var took int for _, response := range source.Responses { - for _, doc := range response.Hits.Hits { - sr.Items = append(sr.Items, t.buildContentItem(doc, highlight)) + for i := 0; i < len(response.Hits.Hits); i++ { + sr.Items = append(sr.Items, t.buildContentItem(response.Hits.Hits[i], highlight)) } - for _, bucket := range response.Aggregations.DocCounts.Buckets { - sr.ContentTypes = append(sr.ContentTypes, buildContentTypes(bucket)) + for j := 0; j < len(response.Aggregations.DocCounts.Buckets); j++ { + sr.ContentTypes = append(sr.ContentTypes, buildContentTypes(response.Aggregations.DocCounts.Buckets[j])) } - for _, suggest := range response.Suggest.SearchSuggest { - for _, option := range suggest.Options { + for z := 0; z < len(response.Suggest.SearchSuggest); z++ { + for _, option := range response.Suggest.SearchSuggest[z].Options { sr.Suggestions = append(sr.Suggestions, option.Text) } } @@ -263,15 +263,13 @@ func (t *Transformer) buildDescription(doc ESResponseHit, highlight bool) descri } func (t *Transformer) overlaySingleItem(hl *[]string, def string, highlight bool) (overlaid string) { - if highlight && hl != nil && len(*hl) > 0 { overlaid = (*hl)[0] } - return } -func (t *Transformer) overlayItemList(hlList *[]string, defaultList *[]string, highlight bool) *[]string { +func (t *Transformer) overlayItemList(hlList, defaultList *[]string, highlight bool) *[]string { if defaultList == nil || hlList == nil { return nil } diff --git a/transformer/transformer_test.go b/transformer/transformer_test.go index 9a22f42c..5acaf5f0 100644 --- a/transformer/transformer_test.go +++ b/transformer/transformer_test.go @@ -3,7 +3,7 @@ package transformer import ( "context" "encoding/json" - "io/ioutil" + "os" "testing" . "github.com/smartystreets/goconvey/convey" @@ -79,7 +79,6 @@ func TestTransform(t *testing.T) { func TestBuildAdditionalSuggestionsList(t *testing.T) { Convey("buildAdditionalSuggestionList successfully", t, func() { - Convey("returns array of strings", func() { query1 := buildAdditionalSuggestionList("test-query") So(query1, ShouldHaveLength, 1) @@ -120,9 +119,9 @@ func TestTransformSearchResponse(t *testing.T) { }) Convey("Converts an example response with highlighting", func() { - sampleResponse, err := ioutil.ReadFile("testdata/search_example.json") + sampleResponse, err := os.ReadFile("testdata/search_example.json") So(err, ShouldBeNil) - expected, err := ioutil.ReadFile("testdata/search_expected_highlighted.json") + expected, err := os.ReadFile("testdata/search_expected_highlighted.json") So(err, ShouldBeNil) actual, err := transformer.TransformSearchResponse(ctx, sampleResponse, "test-query", true) @@ -135,9 +134,9 @@ func TestTransformSearchResponse(t *testing.T) { }) Convey("Converts an example response without highlighting", func() { - sampleResponse, err := ioutil.ReadFile("testdata/search_example.json") + sampleResponse, err := os.ReadFile("testdata/search_example.json") So(err, ShouldBeNil) - expected, err := ioutil.ReadFile("testdata/search_expected_plain.json") + expected, err := os.ReadFile("testdata/search_expected_plain.json") So(err, ShouldBeNil) actual, err := transformer.TransformSearchResponse(ctx, sampleResponse, "test-query", false) @@ -150,9 +149,9 @@ func TestTransformSearchResponse(t *testing.T) { }) Convey("Calls buildAdditionalSuggestionsList if zero search results", func() { - sampleResponse, err := ioutil.ReadFile("testdata/zero_search_example.json") + sampleResponse, err := os.ReadFile("testdata/zero_search_example.json") So(err, ShouldBeNil) - expected, err := ioutil.ReadFile("testdata/zero_search_expected.json") + expected, err := os.ReadFile("testdata/zero_search_expected.json") So(err, ShouldBeNil) actual, err := transformer.TransformSearchResponse(ctx, sampleResponse, "test query \"with quote marks\"", false) @@ -163,6 +162,5 @@ func TestTransformSearchResponse(t *testing.T) { So(json.Unmarshal(actual, &act), ShouldBeNil) So(act, ShouldResemble, exp) }) - }) } From e7d29865d88a704d0aca5d4467fdb295edd27e9c Mon Sep 17 00:00:00 2001 From: rahulmadathumpalliyalil Date: Wed, 22 Dec 2021 21:18:49 +0000 Subject: [PATCH 4/8] Add golangci lint option --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 0496dab2..7a1ff51a 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,8 @@ audit: .PHONY: lint lint: - exit + go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.43.0 + golangci-lint run ./... .PHONY: build build: From 3d94427ebae8e54f44be0567004a05a67350f85e Mon Sep 17 00:00:00 2001 From: rahulmadathumpalliyalil Date: Thu, 23 Dec 2021 12:23:46 +0000 Subject: [PATCH 5/8] Remove redundant getstatus api --- .golangci.yml | 3 -- api/api.go | 1 - api/health.go | 64 ---------------------------------- api/mocks.go | 67 ++---------------------------------- elasticsearch/client.go | 28 --------------- elasticsearch/client_test.go | 60 -------------------------------- 6 files changed, 2 insertions(+), 221 deletions(-) delete mode 100644 api/health.go diff --git a/.golangci.yml b/.golangci.yml index faf8d96b..ac31d4c4 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -83,9 +83,6 @@ issues: - errcheck - dupl - gosec - - path: features/steps/ - linters: - - unused new: false # golangci.com configuration diff --git a/api/api.go b/api/api.go index 915eaccf..2f8e21f3 100644 --- a/api/api.go +++ b/api/api.go @@ -36,7 +36,6 @@ type AuthHandler interface { type ElasticSearcher interface { Search(ctx context.Context, index string, docType string, request []byte) ([]byte, error) MultiSearch(ctx context.Context, index string, docType string, request []byte) ([]byte, error) - GetStatus(ctx context.Context) ([]byte, error) } // QueryBuilder provides methods for the search package diff --git a/api/health.go b/api/health.go deleted file mode 100644 index 23ad9c11..00000000 --- a/api/health.go +++ /dev/null @@ -1,64 +0,0 @@ -package api - -import ( - "encoding/json" - "fmt" - "net/http" - "strings" - - "github.com/ONSdigital/log.go/v2/log" -) - -type healthMessage struct { - Status string `json:"status"` - Error string `json:"error,omitempty"` -} - -func HealthCheckHandlerCreator(elasticSearchClient ElasticSearcher) func(http.ResponseWriter, *http.Request) { - return func(w http.ResponseWriter, req *http.Request) { - ctx := req.Context() - var ( - healthIssue string - err error - ) - - // assume all well - w.Header().Set("Content-Type", "application/json; charset=utf-8") - body := []byte("{\"status\":\"OK\"}") // quicker than json.Marshal(healthMessage{...}) - - // test elastic access - res, err := elasticSearchClient.GetStatus(ctx) - if err != nil { - healthIssue = err.Error() - } else if !isElasticSearchHealthy(string(res)) { - healthIssue = string(res) - } - - // when there's a healthIssue, change headers and content - if healthIssue != "" { - w.WriteHeader(http.StatusInternalServerError) - if body, err = json.Marshal(healthMessage{ - Status: "error", - Error: healthIssue, - }); err != nil { - log.Error(ctx, "elasticsearch healthcheck status json failed to parse", err) - panic(err) - } - } - - // return json - fmt.Fprint(w, string(body)) - } -} - -func isElasticSearchHealthy(res string) bool { - if strings.Contains(res, " green ") { - return true - } - - if strings.Contains(res, " yellow ") { - return true - } - - return false -} diff --git a/api/mocks.go b/api/mocks.go index 4a8c8fe6..7f905aef 100644 --- a/api/mocks.go +++ b/api/mocks.go @@ -5,14 +5,14 @@ package api import ( "context" - "github.com/ONSdigital/dp-authorisation/auth" "net/http" "sync" + + "github.com/ONSdigital/dp-authorisation/auth" ) var ( lockElasticSearcherMockCreateNewEmptyIndex sync.RWMutex - lockElasticSearcherMockGetStatus sync.RWMutex lockElasticSearcherMockMultiSearch sync.RWMutex lockElasticSearcherMockSearch sync.RWMutex ) @@ -21,37 +21,10 @@ var ( // If this is not the case, regenerate this file with moq. var _ ElasticSearcher = &ElasticSearcherMock{} -// ElasticSearcherMock is a mock implementation of ElasticSearcher. -// -// func TestSomethingThatUsesElasticSearcher(t *testing.T) { -// -// // make and configure a mocked ElasticSearcher -// mockedElasticSearcher := &ElasticSearcherMock{ -// CreateNewEmptyIndexFunc: func(ctx context.Context, indexName string) (bool, error) { -// panic("mock out the CreateNewEmptyIndex method") -// }, -// GetStatusFunc: func(ctx context.Context) ([]byte, error) { -// panic("mock out the GetStatus method") -// }, -// MultiSearchFunc: func(ctx context.Context, index string, docType string, request []byte) ([]byte, error) { -// panic("mock out the MultiSearch method") -// }, -// SearchFunc: func(ctx context.Context, index string, docType string, request []byte) ([]byte, error) { -// panic("mock out the Search method") -// }, -// } -// -// // use mockedElasticSearcher in code that requires ElasticSearcher -// // and then make assertions. -// -// } type ElasticSearcherMock struct { // CreateNewEmptyIndexFunc mocks the CreateNewEmptyIndex method. CreateNewEmptyIndexFunc func(ctx context.Context, indexName string) (bool, error) - // GetStatusFunc mocks the GetStatus method. - GetStatusFunc func(ctx context.Context) ([]byte, error) - // MultiSearchFunc mocks the MultiSearch method. MultiSearchFunc func(ctx context.Context, index string, docType string, request []byte) ([]byte, error) @@ -67,11 +40,6 @@ type ElasticSearcherMock struct { // IndexName is the indexName argument value. IndexName string } - // GetStatus holds details about calls to the GetStatus method. - GetStatus []struct { - // Ctx is the ctx argument value. - Ctx context.Context - } // MultiSearch holds details about calls to the MultiSearch method. MultiSearch []struct { // Ctx is the ctx argument value. @@ -132,37 +100,6 @@ func (mock *ElasticSearcherMock) CreateNewEmptyIndexCalls() []struct { return calls } -// GetStatus calls GetStatusFunc. -func (mock *ElasticSearcherMock) GetStatus(ctx context.Context) ([]byte, error) { - if mock.GetStatusFunc == nil { - panic("ElasticSearcherMock.GetStatusFunc: method is nil but ElasticSearcher.GetStatus was just called") - } - callInfo := struct { - Ctx context.Context - }{ - Ctx: ctx, - } - lockElasticSearcherMockGetStatus.Lock() - mock.calls.GetStatus = append(mock.calls.GetStatus, callInfo) - lockElasticSearcherMockGetStatus.Unlock() - return mock.GetStatusFunc(ctx) -} - -// GetStatusCalls gets all the calls that were made to GetStatus. -// Check the length with: -// len(mockedElasticSearcher.GetStatusCalls()) -func (mock *ElasticSearcherMock) GetStatusCalls() []struct { - Ctx context.Context -} { - var calls []struct { - Ctx context.Context - } - lockElasticSearcherMockGetStatus.RLock() - calls = mock.calls.GetStatus - lockElasticSearcherMockGetStatus.RUnlock() - return calls -} - // MultiSearch calls MultiSearchFunc. func (mock *ElasticSearcherMock) MultiSearch(ctx context.Context, index string, docType string, request []byte) ([]byte, error) { if mock.MultiSearchFunc == nil { diff --git a/elasticsearch/client.go b/elasticsearch/client.go index 6332f260..b530b532 100644 --- a/elasticsearch/client.go +++ b/elasticsearch/client.go @@ -44,34 +44,6 @@ func (cli *Client) MultiSearch(ctx context.Context, index, docType string, reque return cli.post(ctx, index, docType, "_msearch", request) } -// GetStatus makes status call for healthcheck purposes -func (cli *Client) GetStatus(ctx context.Context) ([]byte, error) { - req, err := http.NewRequest("GET", cli.url+"/_cat/health", http.NoBody) - if err != nil { - return nil, err - } - - if cli.signRequests { - reader := bytes.NewReader([]byte{}) - if awsSignErr := cli.awsSDKSigner.Sign(req, reader, time.Now()); awsSignErr != nil { - return nil, awsSignErr - } - } - - resp, err := cli.client.Do(ctx, req) - if err != nil { - return nil, err - } - defer resp.Body.Close() - - response, err := io.ReadAll(resp.Body) - if err != nil { - return nil, errors.Wrap(err, "elaticsearchClient error reading get status response body") - } - - return response, err -} - func (cli *Client) post(ctx context.Context, index, docType, action string, request []byte) ([]byte, error) { reader := bytes.NewReader(request) req, err := http.NewRequest("POST", cli.url+"/"+buildContext(index, docType)+action, reader) diff --git a/elasticsearch/client_test.go b/elasticsearch/client_test.go index 420f1a50..b7867f1e 100644 --- a/elasticsearch/client_test.go +++ b/elasticsearch/client_test.go @@ -113,66 +113,6 @@ func TestMultiSearch(t *testing.T) { }) } -func TestGetStatus(t *testing.T) { - Convey("When GetStatus is called", t, func() { - Convey("Then a GET request with the status action should be called", func() { - dphttpMock := &dphttp.ClienterMock{ - DoFunc: func(ctx context.Context, req *http.Request) (*http.Response, error) { - return newResponse("moo"), nil - }, - } - - var testSigner *esauth.Signer - - client := New("http://localhost:999", dphttpMock, false, testSigner, "es", "eu-west-1") - - res, err := client.GetStatus(context.Background()) - So(err, ShouldBeNil) - So(res, ShouldNotBeEmpty) - So(dphttpMock.DoCalls(), ShouldHaveLength, 1) - actualRequest := dphttpMock.DoCalls()[0].Req - So(actualRequest.URL.String(), ShouldResemble, "http://localhost:999/_cat/health") - So(actualRequest.Method, ShouldResemble, "GET") - }) - - Convey("Then a returned error should be passed back", func() { - dphttpMock := &dphttp.ClienterMock{ - DoFunc: func(ctx context.Context, req *http.Request) (*http.Response, error) { - return nil, errors.New("http error") - }, - } - - var testSigner *esauth.Signer - - client := New("http://localhost:999", dphttpMock, false, testSigner, "es", "eu-west-1") - - _, err := client.GetStatus(context.Background()) - So(err, ShouldNotBeNil) - So(err.Error(), ShouldResemble, "http error") - So(dphttpMock.DoCalls(), ShouldHaveLength, 1) - actualRequest := dphttpMock.DoCalls()[0].Req - So(actualRequest.URL.String(), ShouldResemble, "http://localhost:999/_cat/health") - So(actualRequest.Method, ShouldResemble, "GET") - }) - - Convey("Then a signing error should be passed back", func() { - dphttpMock := &dphttp.ClienterMock{ - DoFunc: func(ctx context.Context, req *http.Request) (*http.Response, error) { - return newResponse("moo"), nil - }, - } - - var testSigner *esauth.Signer - - client := New("http://localhost:999", dphttpMock, true, testSigner, "es", "eu-west-1") - - _, err := client.GetStatus(context.Background()) - So(err, ShouldNotBeNil) - So(err.Error(), ShouldResemble, "v4 signer missing. Cannot sign request") - }) - }) -} - func newResponse(body string) *http.Response { recorder := httptest.NewRecorder() recorder.WriteString(body) From 58120d27a72fb7f2e7d2fb004e53951858f1e74e Mon Sep 17 00:00:00 2001 From: rahulmadathumpalliyalil Date: Thu, 23 Dec 2021 13:28:41 +0000 Subject: [PATCH 6/8] Fix comments --- main_test.go | 4 ++-- transformer/transformer.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/main_test.go b/main_test.go index 0342ca7b..cc4482da 100644 --- a/main_test.go +++ b/main_test.go @@ -34,7 +34,7 @@ func (c *ComponentTest) InitializeScenario(godogCtx *godog.ScenarioContext) { apiFeature.Reset() c.AuthFeature.Reset() apiComponent.Reset() - return context.Background(), nil + return ctx, nil }) godogCtx.After(func(ctx context.Context, sc *godog.Scenario, err error) (context.Context, error) { @@ -42,7 +42,7 @@ func (c *ComponentTest) InitializeScenario(godogCtx *godog.ScenarioContext) { fmt.Println(ctx, "error occurred while closing the api component - error: #{err}") os.Exit(1) } - return context.Background(), nil + return ctx, nil }) apiComponent.RegisterSteps(godogCtx) c.AuthFeature.RegisterSteps(godogCtx) diff --git a/transformer/transformer.go b/transformer/transformer.go index 44275312..eb607367 100644 --- a/transformer/transformer.go +++ b/transformer/transformer.go @@ -202,8 +202,8 @@ func (t *Transformer) transform(source *ESResponse, highlight bool) SearchRespon for j := 0; j < len(response.Aggregations.DocCounts.Buckets); j++ { sr.ContentTypes = append(sr.ContentTypes, buildContentTypes(response.Aggregations.DocCounts.Buckets[j])) } - for z := 0; z < len(response.Suggest.SearchSuggest); z++ { - for _, option := range response.Suggest.SearchSuggest[z].Options { + for k := 0; k < len(response.Suggest.SearchSuggest); k++ { + for _, option := range response.Suggest.SearchSuggest[k].Options { sr.Suggestions = append(sr.Suggestions, option.Text) } } From aa2934fdca0fec073ecb9bb748a4bbf45b77aff2 Mon Sep 17 00:00:00 2001 From: rahulmadathumpalliyalil Date: Wed, 29 Dec 2021 10:56:52 +0000 Subject: [PATCH 7/8] Update elasticsearch mappings for es 7.10 --- elasticsearch/search-index-settings.json | 230 +++++++++++------------ 1 file changed, 113 insertions(+), 117 deletions(-) diff --git a/elasticsearch/search-index-settings.json b/elasticsearch/search-index-settings.json index 80896daf..54e884f5 100644 --- a/elasticsearch/search-index-settings.json +++ b/elasticsearch/search-index-settings.json @@ -1,28 +1,28 @@ { - "settings": { - "index": { - "number_of_shards": 5, - "number_of_replicas": 1 + "settings":{ + "index":{ + "number_of_shards":5, + "number_of_replicas":2 }, - "analysis": { - "analyzer": { - "default": { - "tokenizer": "keyword", - "filter": [ + "analysis":{ + "analyzer":{ + "default":{ + "tokenizer":"keyword", + "filter":[ "trim", "lowercase" ] }, - "ons_standard": { - "tokenizer": "standard", - "filter": [ + "ons_standard":{ + "tokenizer":"standard", + "filter":[ "lowercase", "stop" ] }, - "ons_synonym_stem": { - "tokenizer": "standard", - "filter": [ + "ons_synonym_stem":{ + "tokenizer":"standard", + "filter":[ "lowercase", "ons_synonyms", "stop", @@ -30,27 +30,27 @@ "snowball" ] }, - "ons_synonym": { - "tokenizer": "standard", - "filter": [ + "ons_synonym":{ + "tokenizer":"standard", + "filter":[ "lowercase", "ons_synonyms", "stop" ] }, - "ons_stem": { - "tokenizer": "standard", - "filter": [ + "ons_stem":{ + "tokenizer":"standard", + "filter":[ "lowercase", "stop", "stem_exclusion", "snowball" ] }, - "ons_synonym_stem_clear_dates": { - "tokenizer": "standard", - "char_filter": "clear_dates", - "filter": [ + "ons_synonym_stem_clear_dates":{ + "tokenizer":"standard", + "char_filter":"clear_dates", + "filter":[ "lowercase", "ons_synonyms", "stop", @@ -58,48 +58,48 @@ "snowball" ] }, - "ons_stem_clear_dates": { - "tokenizer": "standard", - "char_filter": "clear_dates", - "filter": [ + "ons_stem_clear_dates":{ + "tokenizer":"standard", + "char_filter":"clear_dates", + "filter":[ "lowercase", "stop", "stem_exclusion", "snowball" ] }, - "first_letter": { - "tokenizer": "keyword", - "filter": [ + "first_letter":{ + "tokenizer":"keyword", + "filter":[ "lowercase", "first_letter" ] } }, - "char_filter": { - "clear_dates": { - "type": "pattern_replace", - "pattern": "([1|2]\\d{3})|((?i)january|february|march|april|may|june|july|august|september|october|november|december)" + "char_filter":{ + "clear_dates":{ + "type":"pattern_replace", + "pattern":"([1|2]\\d{3})|((?i)january|february|march|april|may|june|july|august|september|october|november|december)" } }, - "filter": { - "stem_exclusion": { - "type": "keyword_marker", - "keywords": [ + "filter":{ + "stem_exclusion":{ + "type":"keyword_marker", + "keywords":[ "productivity", "production" ] }, - "first_letter": { - "type": "pattern_capture", - "preserve_original": false, - "patterns": [ + "first_letter":{ + "type":"pattern_capture", + "preserve_original":false, + "patterns":[ "^[^a-zA-Z]*([a-zA-Z]).*" ] }, - "ons_synonyms": { - "type": "synonym", - "synonyms": [ + "ons_synonyms":{ + "type":"synonym", + "synonyms":[ "cpi, consumer price inflation, consumer price index", "rpi, retail price index", "gdp, gross domestic product", @@ -185,86 +185,82 @@ } } }, - "mappings": { - "dynamic_date_formats": [ + "mappings":{ + "dynamic_date_formats":[ "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'" ], - "properties": { - "type": { - "type": "keyword" + "properties":{ + "type":{ + "type":"keyword" }, - "description": { - "properties": { - "cdid": { - "type": "text", - "analyzer": "ons_standard" - }, - "datasetId": { - "type": "text", - "analyzer": "ons_standard" - }, - "title": { - "type": "text", - "analyzer": "ons_synonym_stem", - "search_analyzer": "ons_stem", - "fields": { - "title_raw": { - "type": "keyword" - }, - "title_no_stem": { - "type": "text", - "analyzer": "ons_synonym", - "search_analyzer": "ons_standard" - }, - "title_no_synonym_no_stem": { - "type": "text", - "analyzer": "ons_standard" - }, - "title_no_dates": { - "type": "text", - "analyzer": "ons_synonym_stem_clear_dates", - "search_analyzer": "ons_stem_clear_dates" - }, - "title_first_letter": { - "type": "text", - "analyzer": "first_letter" - } - } - }, - "edition": { - "type": "text", - "analyzer": "ons_synonym_stem", - "search_analyzer": "ons_stem" + "cdid":{ + "type":"text", + "analyzer":"ons_standard" + }, + "datasetId":{ + "type":"text", + "analyzer":"ons_standard" + }, + "title":{ + "type":"text", + "analyzer":"ons_synonym_stem", + "search_analyzer":"ons_stem", + "fields":{ + "title_raw":{ + "type":"keyword" }, - "metaDescription": { - "type": "text", - "analyzer": "ons_standard" + "title_no_stem":{ + "type":"text", + "analyzer":"ons_synonym", + "search_analyzer":"ons_standard" }, - "summary": { - "type": "text", - "analyzer": "ons_standard" + "title_no_synonym_no_stem":{ + "type":"text", + "analyzer":"ons_standard" }, - "keywords": { - "type": "text", - "analyzer": "ons_synonym_stem", - "search_analyzer": "ons_stem", - "fields": { - "keywords_raw": { - "type": "text" - } - } + "title_no_dates":{ + "type":"text", + "analyzer":"ons_synonym_stem_clear_dates", + "search_analyzer":"ons_stem_clear_dates" }, - "releaseDate": { - "type": "date" + "title_first_letter":{ + "type":"text", + "analyzer":"first_letter" + } + } + }, + "edition":{ + "type":"text", + "analyzer":"ons_synonym_stem", + "search_analyzer":"ons_stem" + }, + "metaDescription":{ + "type":"text", + "analyzer":"ons_standard" + }, + "summary":{ + "type":"text", + "analyzer":"ons_standard" + }, + "keywords":{ + "type":"text", + "analyzer":"ons_synonym_stem", + "search_analyzer":"ons_stem", + "fields":{ + "keywords_raw":{ + "type":"text" } } }, - "searchBoost": { - "type": "text", - "analyzer": "ons_synonym_stem", - "search_analyzer": "ons_stem", - "norms": false + "releaseDate":{ + "type":"date" + }, + "searchBoost":{ + "type":"text", + "analyzer":"ons_synonym_stem", + "search_analyzer":"ons_stem", + "norms":false } } } -} +} \ No newline at end of file From b2b4eb1f4d0f3033d01743d92460ad05f5fc3c5f Mon Sep 17 00:00:00 2001 From: Jon Dewi Jones Date: Tue, 4 Jan 2022 11:24:45 +0000 Subject: [PATCH 8/8] reorder data types to be alphabetical and remove duplicate --- api/search.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/api/search.go b/api/search.go index d3899bd8..37bb5985 100644 --- a/api/search.go +++ b/api/search.go @@ -14,15 +14,17 @@ import ( "github.com/pkg/errors" ) -const defaultContentTypes string = "bulletin," + - "article," + +const defaultContentTypes string = "article," + "article_download," + + "bulletin," + "compendium_landing_page," + "compendium_chapter," + "compendium_data," + - "reference_tables," + "dataset," + "dataset_landing_page," + + "product_page," + + "reference_tables," + + "release," + "static_adhoc," + "static_article," + "static_foi," + @@ -32,10 +34,7 @@ const defaultContentTypes string = "bulletin," + "static_page," + "static_qmi," + "timeseries," + - "timeseries_dataset," + - "product_page," + - "release," + - "reference_tables" + "timeseries_dataset" var serverErrorMessage = "internal server error"