diff --git a/go.mod b/go.mod index 76f08647..c166968c 100644 --- a/go.mod +++ b/go.mod @@ -6,57 +6,54 @@ toolchain go1.22.3 require ( github.com/Masterminds/squirrel v1.5.4 - github.com/coreos/go-oidc/v3 v3.6.0 + github.com/coreos/go-oidc/v3 v3.10.0 github.com/crewjam/saml v0.4.14 github.com/elastic/go-elasticsearch/v8 v8.13.1 github.com/go-chi/chi/v5 v5.0.12 github.com/go-chi/cors v1.2.1 github.com/go-chi/jwtauth/v5 v5.3.1 - github.com/golang-jwt/jwt/v4 v4.5.0 - github.com/golang/protobuf v1.5.3 github.com/google/uuid v1.6.0 github.com/gorilla/context v1.1.2 github.com/gorilla/websocket v1.5.1 - github.com/hashicorp/go-hclog v1.6.2 - github.com/hashicorp/go-plugin v1.5.2 - github.com/jmoiron/sqlx v1.3.5 + github.com/hashicorp/go-hclog v1.6.3 + github.com/hashicorp/go-plugin v1.6.1 + github.com/jmoiron/sqlx v1.4.0 github.com/json-iterator/go v1.1.12 - github.com/lestrrat-go/jwx/v2 v2.0.21 - github.com/lib/pq v1.2.0 - github.com/myrteametrics/myrtea-sdk/v4 v4.6.3 - github.com/olivere/elastic v6.2.16+incompatible - github.com/prataprc/goparsec v0.0.0-20180806094145-2600a2a4a410 - github.com/prometheus/client_golang v1.14.0 - github.com/robfig/cron/v3 v3.0.0 + github.com/lib/pq v1.10.9 + github.com/myrteametrics/myrtea-sdk/v5 v5.0.0 + github.com/prataprc/goparsec v0.0.0-20211219142520-daac0e635e7e + github.com/prometheus/client_golang v1.19.1 + github.com/robfig/cron/v3 v3.0.1 github.com/russellhaering/goxmldsig v1.4.0 - github.com/spf13/viper v1.3.1 - github.com/swaggo/http-swagger v1.3.3 - github.com/swaggo/swag v1.16.1 + github.com/spf13/viper v1.18.2 + github.com/swaggo/http-swagger v1.3.4 + github.com/swaggo/swag v1.16.3 go.uber.org/zap v1.27.0 - golang.org/x/net v0.22.0 - golang.org/x/oauth2 v0.6.0 - google.golang.org/grpc v1.40.0 - google.golang.org/protobuf v1.28.2-0.20230222093303-bc1253ad3743 + golang.org/x/net v0.25.0 + golang.org/x/oauth2 v0.20.0 + google.golang.org/grpc v1.64.0 + google.golang.org/protobuf v1.34.1 ) require ( - github.com/IBM/sarama v1.43.1 // indirect + github.com/IBM/sarama v1.43.2 // indirect github.com/KyleBanks/depth v1.2.1 // indirect github.com/PaesslerAG/gval v1.2.2 // indirect github.com/beevik/etree v1.1.0 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/buger/jsonparser v1.1.1 // indirect - github.com/cespare/xxhash/v2 v2.1.2 // indirect + github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/crewjam/httperr v0.2.0 // indirect - github.com/davecgh/go-spew v1.1.1 // indirect + github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect github.com/eapache/go-resiliency v1.6.0 // indirect github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3 // indirect github.com/eapache/queue v1.1.0 // indirect github.com/elastic/elastic-transport-go/v8 v8.5.0 // indirect - github.com/fatih/color v1.13.0 // indirect - github.com/fsnotify/fsnotify v1.4.9 // indirect - github.com/go-jose/go-jose/v3 v3.0.0 // indirect + github.com/fatih/color v1.16.0 // indirect + github.com/fsnotify/fsnotify v1.7.0 // indirect + github.com/go-jose/go-jose/v4 v4.0.1 // indirect + github.com/go-kit/kit v0.13.0 // indirect github.com/go-logr/logr v1.3.0 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-openapi/jsonpointer v0.20.0 // indirect @@ -64,14 +61,16 @@ require ( github.com/go-openapi/spec v0.20.9 // indirect github.com/go-openapi/swag v0.22.4 // indirect github.com/goccy/go-json v0.10.2 // indirect + github.com/golang-jwt/jwt/v4 v4.5.0 // indirect + github.com/golang/protobuf v1.5.4 // indirect github.com/golang/snappy v0.0.4 // indirect github.com/hashicorp/errwrap v1.0.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect - github.com/hashicorp/go-retryablehttp v0.7.1 // indirect + github.com/hashicorp/go-retryablehttp v0.7.6 // indirect github.com/hashicorp/go-uuid v1.0.3 // indirect github.com/hashicorp/hcl v1.0.0 // indirect - github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb // indirect + github.com/hashicorp/yamux v0.1.1 // indirect github.com/jcmturner/aescts/v2 v2.0.0 // indirect github.com/jcmturner/dnsutils/v2 v2.0.0 // indirect github.com/jcmturner/gofork v1.7.6 // indirect @@ -79,51 +78,54 @@ require ( github.com/jcmturner/rpc/v2 v2.0.3 // indirect github.com/jonboulle/clockwork v0.2.2 // indirect github.com/josharian/intern v1.0.0 // indirect - github.com/klauspost/compress v1.17.7 // indirect + github.com/klauspost/compress v1.17.8 // indirect github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect github.com/lestrrat-go/blackmagic v1.0.2 // indirect github.com/lestrrat-go/httpcc v1.0.1 // indirect github.com/lestrrat-go/httprc v1.0.5 // indirect github.com/lestrrat-go/iter v1.0.2 // indirect + github.com/lestrrat-go/jwx/v2 v2.0.21 // indirect github.com/lestrrat-go/option v1.0.1 // indirect github.com/linkedin/goavro v2.1.0+incompatible // indirect - github.com/magiconair/properties v1.8.0 // indirect + github.com/magiconair/properties v1.8.7 // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/mattermost/xml-roundtrip-validator v0.1.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.16 // indirect - github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect github.com/mitchellh/go-testing-interface v1.0.0 // indirect - github.com/mitchellh/mapstructure v1.4.2 // indirect + github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/oklog/run v1.0.0 // indirect - github.com/pelletier/go-toml v1.2.0 // indirect + github.com/pelletier/go-toml/v2 v2.1.0 // indirect github.com/pierrec/lz4/v4 v4.1.21 // indirect github.com/pkg/errors v0.9.1 // indirect - github.com/prometheus/client_model v0.3.0 // indirect - github.com/prometheus/common v0.37.0 // indirect - github.com/prometheus/procfs v0.8.0 // indirect + github.com/prometheus/client_model v0.5.0 // indirect + github.com/prometheus/common v0.48.0 // indirect + github.com/prometheus/procfs v0.12.0 // indirect github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect github.com/rickar/cal v1.0.2-0.20191101183814-0e8e6fcfe1c2 // indirect + github.com/sagikazarmark/locafero v0.4.0 // indirect + github.com/sagikazarmark/slog-shim v0.1.0 // indirect github.com/segmentio/asm v1.2.0 // indirect github.com/shopspring/decimal v1.3.1 // indirect - github.com/spf13/afero v1.1.2 // indirect - github.com/spf13/cast v1.3.0 // indirect - github.com/spf13/jwalterweatherman v1.0.0 // indirect - github.com/spf13/pflag v1.0.3 // indirect + github.com/sourcegraph/conc v0.3.0 // indirect + github.com/spf13/afero v1.11.0 // indirect + github.com/spf13/cast v1.6.0 // indirect + github.com/spf13/pflag v1.0.5 // indirect + github.com/subosito/gotenv v1.6.0 // indirect github.com/swaggo/files v0.0.0-20220610200504-28940afbdbfe // indirect go.opentelemetry.io/otel v1.21.0 // indirect go.opentelemetry.io/otel/metric v1.21.0 // indirect go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/multierr v1.10.0 // indirect - golang.org/x/crypto v0.21.0 // indirect - golang.org/x/sys v0.18.0 // indirect - golang.org/x/text v0.14.0 // indirect - golang.org/x/tools v0.11.1 // indirect - google.golang.org/appengine v1.6.7 // indirect - google.golang.org/genproto v0.0.0-20210917145530-b395a37504d4 // indirect - gopkg.in/yaml.v2 v2.4.0 // indirect + golang.org/x/crypto v0.23.0 // indirect + golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect + golang.org/x/sys v0.20.0 // indirect + golang.org/x/text v0.15.0 // indirect + golang.org/x/tools v0.13.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 // indirect + gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index f3bac07f..98275e0f 100644 --- a/go.sum +++ b/go.sum @@ -1,91 +1,38 @@ -cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= -cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= -cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= -cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= -cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= -cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= -cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4= -cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M= -cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc= -cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= -cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= -cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= -cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= -cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= -cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= -cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= -cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= -cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= -cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= -cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= -cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= -cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= -cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= -cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= -cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= -cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= -cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= -cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= -cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= -cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= -dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/BurntSushi/toml v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak= -github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/IBM/sarama v1.43.1 h1:Z5uz65Px7f4DhI/jQqEm/tV9t8aU+JUdTyW/K/fCXpA= -github.com/IBM/sarama v1.43.1/go.mod h1:GG5q1RURtDNPz8xxJs3mgX6Ytak8Z9eLhAkJPObe2xE= +filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA= +filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= +github.com/IBM/sarama v1.43.2 h1:HABeEqRUh32z8yzY2hGB/j8mHSzC/HA9zlEjqFNCzSw= +github.com/IBM/sarama v1.43.2/go.mod h1:Kyo4WkF24Z+1nz7xeVUFWIuKVV8RS3wM8mkvPKMdXFQ= github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc= github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE= github.com/Masterminds/squirrel v1.5.4 h1:uUcX/aBc8O7Fg9kaISIUsHXdKuqehiXAMQTYX8afzqM= github.com/Masterminds/squirrel v1.5.4/go.mod h1:NNaOrjSoIDfDA40n7sr2tPNZRfjzjA400rg+riTZj10= -github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/PaesslerAG/gval v1.2.2 h1:Y7iBzhgE09IGTt5QgGQ2IdaYYYOU134YGHBThD+wm9E= github.com/PaesslerAG/gval v1.2.2/go.mod h1:XRFLwvmkTEdYziLdaCeCa5ImcGVrfQbeNUbVR+C6xac= github.com/PaesslerAG/jsonpath v0.1.0 h1:gADYeifvlqK3R3i2cR5B4DGgxLXIPb3TRTH1mGi0jPI= github.com/PaesslerAG/jsonpath v0.1.0/go.mod h1:4BzmtoM/PI8fPO4aQGIusjGxGir2BzcV0grWtFzq1Y8= -github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= -github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= -github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= -github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= -github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= +github.com/VividCortex/gohistogram v1.0.0 h1:6+hBz+qvs0JOrrNhhmR7lFxo5sINxBCGXrdtl/UvroE= +github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= github.com/beevik/etree v1.1.0 h1:T0xke/WvNtMoCqgzPhkX2r4rjY3GDZFi+FjpRZY2Jbs= github.com/beevik/etree v1.1.0/go.mod h1:r8Aw8JqVegEf0w2fDnATrX9VpkMcyFeM0FhwO62wh+A= -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= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZlaQsNA= +github.com/bufbuild/protocompile v0.4.0/go.mod h1:3v93+mbWn/v3xzN+31nwkJfrEpAUwp+BagBSZWx+TP8= github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs= github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0= -github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= -github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE= -github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= -github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= -github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= -github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= -github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= -github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= -github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= -github.com/coreos/go-oidc/v3 v3.6.0 h1:AKVxfYw1Gmkn/w96z0DbT/B/xFnzTd3MkZvWLjF4n/o= -github.com/coreos/go-oidc/v3 v3.6.0/go.mod h1:ZpHUsHBucTUj6WOkrP4E20UPynbLZzhTQ1XKCXkxyPc= -github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= +github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/coreos/go-oidc/v3 v3.10.0 h1:tDnXHnLyiTVyT/2zLDGj09pFPkhND8Gl8lnTRhoEaJU= +github.com/coreos/go-oidc/v3 v3.10.0/go.mod h1:5j11xcw0D3+SGxn6Z/WFADsgcWVMyNAlSQupk0KK3ac= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/crewjam/httperr v0.2.0 h1:b2BfXR8U3AlIHwNeFFvZ+BV1LFvKLlzMjzaTnZMybNo= github.com/crewjam/httperr v0.2.0/go.mod h1:Jlz+Sg/XqBQhyMjdDiC+GNNRzZTD7x39Gu3pglZ5oH4= github.com/crewjam/saml v0.4.14 h1:g9FBNx62osKusnFzs3QTN5L9CVA/Egfgm+stJShzw/c= github.com/crewjam/saml v0.4.14/go.mod h1:UVSZCf18jJkk6GpWNVqcyQJMD5HsRugBPf4I1nl2mME= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= github.com/eapache/go-resiliency v1.6.0 h1:CqGDTLtpwuWKn6Nj3uNUdflaq+/kIPsg0gfNzHton30= @@ -98,38 +45,25 @@ github.com/elastic/elastic-transport-go/v8 v8.5.0 h1:v5membAl7lvQgBTexPRDBO/Rdnl github.com/elastic/elastic-transport-go/v8 v8.5.0/go.mod h1:YLHer5cj0csTzNFXoNQ8qhtGY1GTvSqPnKWKaqQE3Hk= github.com/elastic/go-elasticsearch/v8 v8.13.1 h1:du5F8IzUUyCkzxyHdrO9AtopcG95I/qwi2WK8Kf1xlg= github.com/elastic/go-elasticsearch/v8 v8.13.1/go.mod h1:DIn7HopJs4oZC/w0WoJR13uMUxtHeq92eI5bqv5CRfI= -github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= -github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= -github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= +github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM= +github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE= github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= -github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= -github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= -github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= +github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= +github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= +github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= +github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= github.com/go-chi/chi/v5 v5.0.12 h1:9euLV5sTrTNTRUU9POmDUvfxyj6LAABLUcEWO+JJb4s= github.com/go-chi/chi/v5 v5.0.12/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8= github.com/go-chi/cors v1.2.1 h1:xEC8UT3Rlp2QuWNEr4Fs/c2EAGVKBwy/1vHx3bppil4= github.com/go-chi/cors v1.2.1/go.mod h1:sSbTewc+6wYHBBCW7ytsFSn836hqM7JxpglAy2Vzc58= github.com/go-chi/jwtauth/v5 v5.3.1 h1:1ePWrjVctvp1tyBq5b/2ER8Th/+RbYc7x4qNsc5rh5A= github.com/go-chi/jwtauth/v5 v5.3.1/go.mod h1:6Fl2RRmWXs3tJYE1IQGX81FsPoGqDwq9c15j52R5q80= -github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= -github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-jose/go-jose/v3 v3.0.0 h1:s6rrhirfEP/CGIoc6p+PZAeogN2SxKav6Wp7+dyMWVo= -github.com/go-jose/go-jose/v3 v3.0.0/go.mod h1:RNkWWRld676jZEYoV3+XK8L2ZnNSvIsxFMht0mSX+u8= -github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= -github.com/go-kit/log v0.2.0/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= -github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= -github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= -github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= -github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= +github.com/go-jose/go-jose/v4 v4.0.1 h1:QVEPDE3OluqXBQZDcnNvQrInro2h0e4eqNbnZSWqS6U= +github.com/go-jose/go-jose/v4 v4.0.1/go.mod h1:WVf9LFMHh/QVrmqrOfqun0C45tMe3RoiKJMPvgWwLfY= +github.com/go-kit/kit v0.13.0 h1:OoneCcHKHQ03LfBpoQCUfCluwd2Vt3ohz+kvbJneZAU= +github.com/go-kit/kit v0.13.0/go.mod h1:phqEHMMUbyrCFCTgH48JueqrM3md2HcAZ8N3XE4FKDg= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY= github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= @@ -150,104 +84,46 @@ github.com/go-openapi/swag v0.19.15/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/ github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= github.com/go-openapi/swag v0.22.4 h1:QLMzNJnMGPRNDCbySlcj1x01tzU8/9LTTL9hZZZogBU= github.com/go-openapi/swag v0.22.4/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= -github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE= -github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= -github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpvNJ1Y= +github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg= github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= -github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= -github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= -github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= -github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= -github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= -github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= -github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= -github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= -github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= -github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= -github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= -github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= -github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/gorilla/context v1.1.2 h1:WRkNAv2uoa03QNIc1A6u4O7DAGMUVoopZhkiXWA2V1o= github.com/gorilla/context v1.1.2/go.mod h1:KDPwT9i/MeWHiLl90fuTgrt4/wPcv75vFAZLaOOcbxM= github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4= github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM= github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY= github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY= -github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= -github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= -github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= -github.com/hashicorp/go-hclog v1.6.2 h1:NOtoftovWkDheyUM/8JW3QMiXyxJK3uHRK7wV04nD2I= -github.com/hashicorp/go-hclog v1.6.2/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= +github.com/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB11/k= +github.com/hashicorp/go-hclog v1.6.3/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= -github.com/hashicorp/go-plugin v1.5.2 h1:aWv8eimFqWlsEiMrYZdPYl+FdHaBJSN4AWwGWfT1G2Y= -github.com/hashicorp/go-plugin v1.5.2/go.mod h1:w1sAEES3g3PuV/RzUrgow20W2uErMly84hhD3um1WL4= -github.com/hashicorp/go-retryablehttp v0.7.1 h1:sUiuQAnLlbvmExtFQs72iFW/HXeUn8Z1aJLQ4LJJbTQ= -github.com/hashicorp/go-retryablehttp v0.7.1/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER/9wtLZZ8meHqQvEYWY= +github.com/hashicorp/go-plugin v1.6.1 h1:P7MR2UP6gNKGPp+y7EZw2kOiq4IR9WiqLvp0XOsVdwI= +github.com/hashicorp/go-plugin v1.6.1/go.mod h1:XPHFku2tFo3o3QKFgSYo+cghcUhw1NA1hZyMK0PWAw0= +github.com/hashicorp/go-retryablehttp v0.7.6 h1:TwRYfx2z2C4cLbXmT8I5PgP/xmuqASDyiVuGYfs9GZM= +github.com/hashicorp/go-retryablehttp v0.7.6/go.mod h1:pkQpWZeYWskR+D1tR2O5OcBFOxfA7DoAO6xtkuQnHTk= github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= -github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb h1:b5rjCoWHc7eqmAS4/qyk21ZsHyb6Mxv/jykxvNTkU4M= -github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= -github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE= +github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ= github.com/jcmturner/aescts/v2 v2.0.0 h1:9YKLH6ey7H4eDBXW8khjYslgyqG2xZikXP0EQFKrle8= github.com/jcmturner/aescts/v2 v2.0.0/go.mod h1:AiaICIRyfYg35RUkr8yESTqvSy7csK90qZ5xfvvsoNs= github.com/jcmturner/dnsutils/v2 v2.0.0 h1:lltnkeZGL0wILNvrNiVCR6Ro5PGU/SeBvVO/8c/iPbo= @@ -261,32 +137,22 @@ github.com/jcmturner/gokrb5/v8 v8.4.4/go.mod h1:1btQEpgT6k+unzCwX1KdWMEwPPkkgBtP github.com/jcmturner/rpc/v2 v2.0.3 h1:7FXXj8Ti1IaVFpSAziCZWNzbNuZmnvw/i6CqLNdWfZY= github.com/jcmturner/rpc/v2 v2.0.3/go.mod h1:VUJYCIDm3PVOEHw8sgt091/20OJjskO/YJki3ELg/Hc= github.com/jhump/protoreflect v1.15.1 h1:HUMERORf3I3ZdX05WaQ6MIpd/NJ434hTp5YiKgfCL6c= -github.com/jmoiron/sqlx v1.3.5 h1:vFFPA71p1o5gAeqtEAwLU4dnX2napprKtHr7PYIcN3g= -github.com/jmoiron/sqlx v1.3.5/go.mod h1:nRVWtLre0KfCLJvgxzCsLVMogSvQ1zNJtpYr2Ccp0mQ= +github.com/jhump/protoreflect v1.15.1/go.mod h1:jD/2GMKKE6OqX8qTjhADU1e6DShO+gavG9e0Q693nKo= +github.com/jmoiron/sqlx v1.4.0 h1:1PLqN7S1UYp5t4SrVVnt4nUVNemrDAtxlulVe+Qgm3o= +github.com/jmoiron/sqlx v1.4.0/go.mod h1:ZrZ7UsYB/weZdl2Bxg6jCRO9c3YHl8r3ahlKmRT4JLY= github.com/jonboulle/clockwork v0.2.2 h1:UOGuzwb1PwsrDAObMuhUnj0p5ULPj8V/xJ7Kx9qUBdQ= github.com/jonboulle/clockwork v0.2.2/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= -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= -github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= -github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= -github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= -github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/klauspost/compress v1.17.7 h1:ehO88t2UGzQK66LMdE8tibEd1ErmzZjNEqWkjLAKQQg= -github.com/klauspost/compress v1.17.7/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= -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.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= +github.com/klauspost/compress v1.17.8 h1:YcnTYrq7MikUT7k0Yb5eceMmALQPYBW/Xltxn0NAMnU= +github.com/klauspost/compress v1.17.8/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -307,12 +173,12 @@ github.com/lestrrat-go/jwx/v2 v2.0.21 h1:jAPKupy4uHgrHFEdjVjNkUgoBKtVDgrQPB/h55F github.com/lestrrat-go/jwx/v2 v2.0.21/go.mod h1:09mLW8zto6bWL9GbwnqAli+ArLf+5M33QLQPDggkUWM= github.com/lestrrat-go/option v1.0.1 h1:oAzP2fvZGQKWkvHa1/SAcFolBEca1oN+mQ7eooNBEYU= github.com/lestrrat-go/option v1.0.1/go.mod h1:5ZHFbivi4xwXxhxY9XHDe2FHo6/Z7WWmtT7T5nBBp3I= -github.com/lib/pq v1.2.0 h1:LXpIM/LZ5xGFhOpXAQUIMM1HdyqzVYM13zNdjCEEcA0= -github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= +github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/linkedin/goavro v2.1.0+incompatible h1:DV2aUlj2xZiuxQyvag8Dy7zjY69ENjS66bWkSfdpddY= github.com/linkedin/goavro v2.1.0+incompatible/go.mod h1:bBCwI2eGYpUI/4820s67MElg9tdeLbINjLjiM2xZFYM= -github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY= -github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= +github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= +github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= @@ -326,473 +192,187 @@ github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxec github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= -github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-sqlite3 v1.14.6 h1:dNPt6NO46WmLVt2DLNpwczCmdV5boIZ6g/tlDrlRUbg= -github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= -github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= -github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU= +github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= github.com/mitchellh/go-testing-interface v1.0.0 h1:fzU/JVNcaqHQEcVFAKeR41fkiLdIPrefOvVG1VZ96U0= github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= -github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/mitchellh/mapstructure v1.4.2 h1:6h7AQ0yhTcIsmFmnAwQls75jp2Gzs4iB8W7pjMO+rqo= -github.com/mitchellh/mapstructure v1.4.2/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= +github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= -github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= -github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= -github.com/myrteametrics/myrtea-sdk/v4 v4.6.3 h1:GNMsaTjDfxi0ytZGd8GLzvrYdBV9e/lIixj2YdiBhP8= -github.com/myrteametrics/myrtea-sdk/v4 v4.6.3/go.mod h1:KhH98gR582s0U/rWJZf7UVWX0mMrIUCR8cc0PdvVXDI= +github.com/myrteametrics/myrtea-sdk/v5 v5.0.0 h1:F3iYRPogc7XA07CMz09XlHXW17z0LGuaK7VXuA5lnNg= +github.com/myrteametrics/myrtea-sdk/v5 v5.0.0/go.mod h1:NPhtQGVRE6Fb6emMOdZT6uh+bXWnMKc9Fbo0DdtRO9A= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= -github.com/olivere/elastic v6.2.16+incompatible h1:+mQIHbkADkOgq9tFqnbyg7uNFVV6swGU07EoK1u0nEQ= -github.com/olivere/elastic v6.2.16+incompatible/go.mod h1:J+q1zQJTgAz9woqsbVRqGeB5G1iqDKVBWLNSYW8yfJ8= -github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc= -github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= +github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4= +github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc= github.com/pierrec/lz4/v4 v4.1.21 h1:yOVMLb6qSIDP67pl/5F7RepeKYu/VmTyEXvuMI5d9mQ= github.com/pierrec/lz4/v4 v4.1.21/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= -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= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prataprc/goparsec v0.0.0-20180806094145-2600a2a4a410 h1:BZjOxwDguSqFR+Uk9DSlT1SZ9jsDsNVdgoDmEuAhIew= -github.com/prataprc/goparsec v0.0.0-20180806094145-2600a2a4a410/go.mod h1:YbpxZqbf10o5u96/iDpcfDQmbIOTX/iNCH/yBByTfaM= -github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= -github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= -github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= -github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= -github.com/prometheus/client_golang v1.14.0 h1:nJdhIvne2eSX/XRAFV9PcvFFRbrjbcTUj0VP62TMhnw= -github.com/prometheus/client_golang v1.14.0/go.mod h1:8vpkKitgIVNcqrRBWh1C4TIUQgYNtG/XQE4E/Zae36Y= -github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= -github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4= -github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= -github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= -github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= -github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= -github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= -github.com/prometheus/common v0.37.0 h1:ccBbHCgIiT9uSoFY0vX8H3zsNR5eLt17/RQLUvn8pXE= -github.com/prometheus/common v0.37.0/go.mod h1:phzohg0JFMnBEFGxTDbfu3QyL5GI8gTQJFhYO5B3mfA= -github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= -github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= -github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= -github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= -github.com/prometheus/procfs v0.8.0 h1:ODq8ZFEaYeCaZOJlZZdJA2AbQR98dSHSM1KW/You5mo= -github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prataprc/goparsec v0.0.0-20211219142520-daac0e635e7e h1:7teoyCCMBovX+/L3/C2adcGNJI6Tsx6a2hbWQ8vWoO8= +github.com/prataprc/goparsec v0.0.0-20211219142520-daac0e635e7e/go.mod h1:YbpxZqbf10o5u96/iDpcfDQmbIOTX/iNCH/yBByTfaM= +github.com/prometheus/client_golang v1.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQeLaYJFJBOE= +github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho= +github.com/prometheus/client_model v0.5.0 h1:VQw1hfvPvk3Uv6Qf29VrPF32JB6rtbgI6cYPYQjL0Qw= +github.com/prometheus/client_model v0.5.0/go.mod h1:dTiFglRmd66nLR9Pv9f0mZi7B7fk5Pm3gvsjB5tr+kI= +github.com/prometheus/common v0.48.0 h1:QO8U2CdOzSn1BBsmXJXduaaW+dY/5QLjfB8svtSzKKE= +github.com/prometheus/common v0.48.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc= +github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= +github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5XpJzTSTfLsJV/mx9Q9g7kxmchpfZyxgzM= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rickar/cal v1.0.2-0.20191101183814-0e8e6fcfe1c2 h1:M+IxaqPU4BsXtwWhePi22zCb3dQ3TDEmXRiziUtTpd4= github.com/rickar/cal v1.0.2-0.20191101183814-0e8e6fcfe1c2/go.mod h1:3GBx8OBrvh4/y/JTxM0e1bUUIHMnqILl1rMANHWExxQ= -github.com/robfig/cron/v3 v3.0.0 h1:kQ6Cb7aHOHTSzNVNEhmp8EcWKLb4CbiMW9h9VyIhO4E= -github.com/robfig/cron/v3 v3.0.0/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro= -github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= -github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs= +github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro= github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= +github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/russellhaering/goxmldsig v1.4.0 h1:8UcDh/xGyQiyrW+Fq5t8f+l2DLB1+zlhYzkPUJ7Qhys= github.com/russellhaering/goxmldsig v1.4.0/go.mod h1:gM4MDENBQf7M+V824SGfyIUVFWydB7n0KkEubVJl+Tw= +github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6keLGt6kNQ= +github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4= +github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE= +github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ= github.com/segmentio/asm v1.2.0 h1:9BQrFxC+YOHJlTlHGkTrFWf59nbL3XnCoFLTwDCI7ys= github.com/segmentio/asm v1.2.0/go.mod h1:BqMnlJP91P8d+4ibuonYZw9mfnzI9HfxselHZr5aAcs= github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8= github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= -github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= -github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= -github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= -github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= -github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI= -github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= -github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8= -github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= -github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk= -github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= -github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg= -github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -github.com/spf13/viper v1.3.1 h1:5+8j8FTpnFV4nEImW/ofkzEt8VoOiLXxdYIDsB73T38= -github.com/spf13/viper v1.3.1/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= +github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo= +github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0= +github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8= +github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNoBjkY= +github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0= +github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/spf13/viper v1.18.2 h1:LUXCnvUvSM6FXAsj6nnfc8Q2tp1dIgUfY9Kc8GsSOiQ= +github.com/spf13/viper v1.18.2/go.mod h1:EKmWIqdnk5lOcmR72yw6hS+8OPYcwD0jteitLMVB+yk= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= +github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/swaggo/files v0.0.0-20220610200504-28940afbdbfe h1:K8pHPVoTgxFJt1lXuIzzOX7zZhZFldJQK/CgKx9BFIc= github.com/swaggo/files v0.0.0-20220610200504-28940afbdbfe/go.mod h1:lKJPbtWzJ9JhsTN1k1gZgleJWY/cqq0psdoMmaThG3w= -github.com/swaggo/http-swagger v1.3.3 h1:Hu5Z0L9ssyBLofaama21iYaF2VbWyA8jdohaaCGpHsc= -github.com/swaggo/http-swagger v1.3.3/go.mod h1:sE+4PjD89IxMPm77FnkDz0sdO+p5lbXzrVWT6OTVVGo= -github.com/swaggo/swag v1.16.1 h1:fTNRhKstPKxcnoKsytm4sahr8FaYzUcT7i1/3nd/fBg= -github.com/swaggo/swag v1.16.1/go.mod h1:9/LMvHycG3NFHfR6LwvikHv5iFvmPADQ359cKikGxto= -github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= -github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= -github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +github.com/swaggo/http-swagger v1.3.4 h1:q7t/XLx0n15H1Q9/tk3Y9L4n210XzJF5WtnDX64a5ww= +github.com/swaggo/http-swagger v1.3.4/go.mod h1:9dAh0unqMBAlbp1uE2Uc2mQTxNMU/ha4UbucIg1MFkQ= +github.com/swaggo/swag v1.16.3 h1:PnCYjPCah8FK4I26l2F/KQ4yz3sILcVUN3cTlBFA9Pg= +github.com/swaggo/swag v1.16.3/go.mod h1:DImHIuOFXKpMFAQjcC7FG4m3Dg4+QuUgUzJmKjI/gRk= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= -go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= -go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opentelemetry.io/otel v1.21.0 h1:hzLeKBZEL7Okw2mGzZ0cc4k/A7Fta0uoPgaJCr8fsFc= go.opentelemetry.io/otel v1.21.0/go.mod h1:QZzNPQPm1zLX4gZK4cMi+71eaorMSGT3A4znnUvNNEo= go.opentelemetry.io/otel/metric v1.21.0 h1:tlYWfeo+Bocx5kLEloTjbcDwBuELRrIFxwdQ36PlJu4= go.opentelemetry.io/otel/metric v1.21.0/go.mod h1:o1p3CA8nNHW8j5yuQLdc1eeqEaPfzug24uvsyIEJRWM= go.opentelemetry.io/otel/sdk v1.21.0 h1:FTt8qirL1EysG6sTQRZ5TokkU8d0ugCj8htOgThZXQ8= +go.opentelemetry.io/otel/sdk v1.21.0/go.mod h1:Nna6Yv7PWTdgJHVRD9hIYywQBRx7pbox6nwBnZIxl/E= go.opentelemetry.io/otel/trace v1.21.0 h1:WD9i5gzvoUPuXIXH24ZNBudiarZDKuekPqi/E8fpfLc= go.opentelemetry.io/otel/trace v1.21.0/go.mod h1:LGbsEB0f9LGjN+OZaQQ26sohbOmiMR+BaslueVtS/qQ= -go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ= go.uber.org/multierr v1.10.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= -golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/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-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-20190911031432-227b76d455e7/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= -golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= -golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= -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= -golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= -golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= -golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= -golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= -golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= -golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= -golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= -golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= -golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= -golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= -golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI= +golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= +golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g= +golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= -golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= -golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= -golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= -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= -golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= -golang.org/x/oauth2 v0.6.0 h1:Lh8GPgSKBfWSwFvtuWOfeI3aAAnbXTSutYxJiOJFgIw= -golang.org/x/oauth2 v0.6.0/go.mod h1:ycmewcwgD4Rpr3eZJLSB4Kyyljb3qDh40vJ8STE5HKw= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -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/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac= +golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= +golang.org/x/oauth2 v0.20.0 h1:4mQdhULixXKP1rwYBW0vAijoXnkTG0BLCDRzfe1idMo= +golang.org/x/oauth2 v0.20.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= 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-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= -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= -golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= +golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/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-20190412213103-97732733099d/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-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-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/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-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= -golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= +golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= -golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 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/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -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/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk= +golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= -golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -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-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-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= -golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= -golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= -golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.11.1 h1:ojD5zOW8+7dOGzdnNgersm8aPfcDjhMp12UfG93NIMc= -golang.org/x/tools v0.11.1/go.mod h1:anzJrxPjNtfgiYQYirP2CPGzGLxrH2u2QBhn6Bf3qY8= +golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ= +golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= -google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= -google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= -google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= -google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= -google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= -google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= -google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= -google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= -google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= -google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= -google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= -google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= -google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= -google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210917145530-b395a37504d4 h1:ysnBoUyeL/H6RCvNRhWHjKoDEmguI+mPU+qHgK8qv/w= -google.golang.org/genproto v0.0.0-20210917145530-b395a37504d4/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= -google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= -google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= -google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= -google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= -google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= -google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.40.0 h1:AGJ0Ih4mHjSeibYkFGh1dD9KJ/eOtZ93I6hoHhukQ5Q= -google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= -google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= -google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= -google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= -google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= -google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= -google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= -google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.2-0.20230222093303-bc1253ad3743 h1:yqElulDvOF26oZ2O+2/aoX7mQ8DY/6+p39neytrycd8= -google.golang.org/protobuf v1.28.2-0.20230222093303-bc1253ad3743/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 h1:NnYq6UN9ReLM9/Y01KWNOWyI5xQ9kbIms5GGJVwS/Yc= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY= +google.golang.org/grpc v1.64.0 h1:KH3VH9y/MgNQg1dE7b3XfVK0GsPSIzJwdF617gUSbvY= +google.golang.org/grpc v1.64.0/go.mod h1:oxjF8E3FBnjp+/gVFYdWacaLDx9na1aqy9oovLpxQYg= +google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg= +google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= +gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/linkedin/goavro.v1 v1.0.5 h1:BJa69CDh0awSsLUmZ9+BowBdokpduDZSM9Zk8oKHfN4= -gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/linkedin/goavro.v1 v1.0.5/go.mod h1:Aw5GdAbizjOEl0kAMHV9iHmA8reZzW/OKuJAl4Hb9F0= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= @@ -801,13 +381,4 @@ gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= -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= -honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= -honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= -rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= -rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= +gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= diff --git a/internals/app/configuration.go b/internals/app/configuration.go index 44a1eda3..01b7f2c3 100644 --- a/internals/app/configuration.go +++ b/internals/app/configuration.go @@ -1,7 +1,7 @@ package app import ( - "github.com/myrteametrics/myrtea-sdk/v4/helpers" + "github.com/myrteametrics/myrtea-sdk/v5/helpers" "github.com/spf13/viper" "go.uber.org/zap" ) diff --git a/internals/app/elasticsearch.go b/internals/app/elasticsearch.go index 0e0fdfb4..6395d975 100644 --- a/internals/app/elasticsearch.go +++ b/internals/app/elasticsearch.go @@ -4,7 +4,7 @@ import ( "github.com/elastic/go-elasticsearch/v8" "github.com/myrteametrics/myrtea-engine-api/v5/internals/config/esconfig" "github.com/myrteametrics/myrtea-engine-api/v5/internals/models" - "github.com/myrteametrics/myrtea-sdk/v4/elasticsearchv8" + elasticsearchsdk "github.com/myrteametrics/myrtea-sdk/v5/elasticsearch" "github.com/spf13/viper" "go.uber.org/zap" ) @@ -37,10 +37,12 @@ func initElasticsearch() { zap.L().Warn("ElasticSearch default config does not contains any urls, using ELASTICSEARCH_URLS", zap.Strings("urls", config.URLs)) } - err = elasticsearchv8.ReplaceGlobals(elasticsearch.Config{ - Addresses: config.URLs, + urls := viper.GetStringSlice("ELASTICSEARCH_URLS") + err = elasticsearchsdk.ReplaceGlobals(elasticsearch.Config{ + Addresses: urls, }) if err != nil { - zap.L().Error("Could not init elasticsearchv8", zap.Error(err)) + zap.L().Error("Could not init elasticsearch", zap.Error(err)) + } } diff --git a/internals/app/postgres.go b/internals/app/postgres.go index 1ef60955..9fa7a1c0 100644 --- a/internals/app/postgres.go +++ b/internals/app/postgres.go @@ -1,7 +1,7 @@ package app import ( - "github.com/myrteametrics/myrtea-sdk/v4/postgres" + "github.com/myrteametrics/myrtea-sdk/v5/postgres" "github.com/spf13/viper" "go.uber.org/zap" ) diff --git a/internals/app/services.go b/internals/app/services.go index 3706832e..6d41230a 100644 --- a/internals/app/services.go +++ b/internals/app/services.go @@ -33,7 +33,7 @@ import ( "github.com/myrteametrics/myrtea-engine-api/v5/internals/security/users" "github.com/myrteametrics/myrtea-engine-api/v5/internals/situation" "github.com/myrteametrics/myrtea-engine-api/v5/internals/tasker" - "github.com/myrteametrics/myrtea-sdk/v4/postgres" + "github.com/myrteametrics/myrtea-sdk/v5/postgres" "github.com/spf13/viper" "go.uber.org/zap" ) diff --git a/internals/calendar/postgres_repository_test.go b/internals/calendar/postgres_repository_test.go index e791cc77..91fc393c 100644 --- a/internals/calendar/postgres_repository_test.go +++ b/internals/calendar/postgres_repository_test.go @@ -6,7 +6,7 @@ import ( "github.com/jmoiron/sqlx" "github.com/myrteametrics/myrtea-engine-api/v5/internals/tests" - "github.com/myrteametrics/myrtea-sdk/v4/postgres" + "github.com/myrteametrics/myrtea-sdk/v5/postgres" ) func dbCalendarInit(dbClient *sqlx.DB, t *testing.T) { diff --git a/internals/coordinator/coordinator_test.go b/internals/coordinator/coordinator_test.go index 01cd8163..49f0c85a 100644 --- a/internals/coordinator/coordinator_test.go +++ b/internals/coordinator/coordinator_test.go @@ -1,18 +1,15 @@ package coordinator import ( - "context" - "fmt" + "github.com/elastic/go-elasticsearch/v8" + elasticsearchsdk "github.com/myrteametrics/myrtea-sdk/v5/elasticsearch" "sync" "testing" "time" - "github.com/myrteametrics/myrtea-sdk/v4/elasticsearchv6" - "github.com/myrteametrics/myrtea-sdk/v4/helpers" - "github.com/myrteametrics/myrtea-sdk/v4/modeler" - "github.com/olivere/elastic" + "github.com/myrteametrics/myrtea-sdk/v5/helpers" + "github.com/myrteametrics/myrtea-sdk/v5/modeler" "github.com/spf13/viper" - "go.uber.org/zap" ) // ConfigPath is the toml configuration file path @@ -111,34 +108,6 @@ var ( // } -func TestGetIndices(t *testing.T) { - if testing.Short() { - t.Skip("Skipping elasticsearch test in short mode") - } - helpers.InitializeConfig(AllowedConfigKey, ConfigName, ConfigPath, EnvPrefix) - helpers.InitLogger(viper.GetBool("LOGGER_PRODUCTION")) - - client, err := elastic.NewClient(elastic.SetSniff(false), - elastic.SetHealthcheckTimeoutStartup(60*time.Second), - elastic.SetURL(viper.GetStringSlice("ELASTICSEARCH_URLS")...), - // elastic.SetHttpClient(retryClient.StandardClient()), - ) - if err != nil { - zap.L().Error("Elasticsearch client initialization", zap.Error(err)) - } else { - zap.L().Info("Initialize Elasticsearch client", zap.String("status", "done")) - } - - indices, err := client.CatIndices().Index("myrtea-myindex-*").Columns("index").Do(context.Background()) - if err != nil { - t.Error(err) - } - for _, index := range indices { - t.Logf("%+v", index.Index) - } - t.Fail() -} - func TestCoordinator(t *testing.T) { if testing.Short() { t.Skip("Skipping elasticsearch test in short mode") @@ -146,7 +115,7 @@ func TestCoordinator(t *testing.T) { helpers.InitializeConfig(AllowedConfigKey, ConfigName, ConfigPath, EnvPrefix) helpers.InitLogger(viper.GetBool("LOGGER_PRODUCTION")) - elasticsearchv6.ReplaceGlobals(&elasticsearchv6.Credentials{URLs: viper.GetStringSlice("ELASTICSEARCH_URLS")}) + elasticsearchsdk.ReplaceGlobals(elasticsearch.Config{Addresses: viper.GetStringSlice("ELASTICSEARCH_URLS")}) err := InitInstance( viper.GetString("INSTANCE_NAME"), @@ -178,9 +147,9 @@ func TestPurge(t *testing.T) { helpers.InitializeConfig(AllowedConfigKey, ConfigName, ConfigPath, EnvPrefix) helpers.InitLogger(viper.GetBool("LOGGER_PRODUCTION")) - elasticsearchv6.ReplaceGlobals(&elasticsearchv6.Credentials{URLs: viper.GetStringSlice("ELASTICSEARCH_URLS")}) + elasticsearchsdk.ReplaceGlobals(elasticsearch.Config{Addresses: viper.GetStringSlice("ELASTICSEARCH_URLS")}) - logicalIndex, err := NewLogicalIndexTimeBasedV6("myrtea", modeler.Model{Name: "myindex", ElasticsearchOptions: modeler.ElasticsearchOptions{ + logicalIndex, err := NewLogicalIndexTimeBased("myrtea", modeler.Model{Name: "myindex", ElasticsearchOptions: modeler.ElasticsearchOptions{ Rollmode: "timebased", Rollcron: "0 * * * *", EnablePurge: true, @@ -193,70 +162,3 @@ func TestPurge(t *testing.T) { logicalIndex.purge() t.Fail() } - -func TestFindIndices(t *testing.T) { - if testing.Short() { - t.Skip("Skipping elasticsearch test in short mode") - } - helpers.InitializeConfig(AllowedConfigKey, ConfigName, ConfigPath, EnvPrefix) - helpers.InitLogger(viper.GetBool("LOGGER_PRODUCTION")) - - client, err := elastic.NewClient(elastic.SetSniff(false), - elastic.SetHealthcheckTimeoutStartup(60*time.Second), - elastic.SetURL(viper.GetStringSlice("ELASTICSEARCH_URLS")...), - // elastic.SetHttpClient(retryClient.StandardClient()), - ) - if err != nil { - zap.L().Error("Elasticsearch client initialization", zap.Error(err)) - } else { - zap.L().Info("Initialize Elasticsearch client", zap.String("status", "done")) - } - - catIndicesResponse, err := client.CatIndices().Index("myrtea-myindex-*").Columns("index").Do(context.Background()) - if err != nil { - t.Error(err) - } - - indices := make([]string, 0) - for _, index := range catIndicesResponse { - indices = append(indices, index.Index) - } - t.Fail() - // indices := []string{ - // "myrtea-myindex-2022-01-01", - // "myrtea-myindex-2022-12-31", - // "myrtea-myindex-2023-01-01", - // "myrtea-myindex-2023-01-02", - // "myrtea-myindex-2023-01-03", - // "myrtea-myindex-2023-01-14", - // "myrtea-myindex-2023-01-15", - // "myrtea-myindex-2023-01-16", - // "myrtea-myindex-2023-01-28", - // "myrtea-myindex-2023-01-29", - // "myrtea-myindex-2023-01-30", - // "myrtea-myindex-2023-02-01", - // "myrtea-myindex-2023-02-02", - // "myrtea-myindex-2023-02-03", - // } - - tsEnd := time.Date(2023, 1, 30, 12, 0, 0, 0, time.UTC) - tsStart := tsEnd.Add(-20 * 24 * time.Hour) - - indexEnd := fmt.Sprintf("myrtea-%s-%s", "myindex", tsEnd.Format("2006-01-02")) - indexStart := fmt.Sprintf("myrtea-%s-%s", "myindex", tsStart.Format("2006-01-02")) - - t.Log(indexEnd) - t.Log(indexStart) - - subIndices := make([]string, 0) - for _, index := range indices { - if index < indexStart { - // if index >= indexStart { - subIndices = append(subIndices, index) - } - } - t.Log(indices) - t.Log(subIndices) - t.Fail() - -} diff --git a/internals/coordinator/instance.go b/internals/coordinator/instance.go index d91aa432..9c3174d1 100644 --- a/internals/coordinator/instance.go +++ b/internals/coordinator/instance.go @@ -3,8 +3,7 @@ package coordinator import ( "sync" - "github.com/myrteametrics/myrtea-sdk/v4/modeler" - "github.com/spf13/viper" + "github.com/myrteametrics/myrtea-sdk/v5/modeler" "go.uber.org/zap" ) @@ -38,34 +37,14 @@ func InitInstance(instanceName string, models map[int64]modeler.Model) error { LogicalIndices: make(map[string]LogicalIndex), } - version := viper.GetInt("ELASTICSEARCH_VERSION") for _, model := range models { var err error var logicalIndex LogicalIndex switch model.ElasticsearchOptions.Rollmode { case "cron": - switch version { - case 6: - logicalIndex, err = NewLogicalIndexCronV6(instance.Name, model) - case 7: - fallthrough - case 8: - logicalIndex, err = NewLogicalIndexCronV8(instance.Name, model) - default: - zap.L().Fatal("Unsupported Elasticsearch version", zap.Int("version", version)) - } - + logicalIndex, err = NewLogicalIndexCron(instance.Name, model) case "timebased": - switch version { - case 6: - logicalIndex, err = NewLogicalIndexTimeBasedV6(instance.Name, model) - case 7: - fallthrough - case 8: - logicalIndex, err = NewLogicalIndexTimeBasedV8(instance.Name, model) - default: - zap.L().Fatal("Unsupported Elasticsearch version", zap.Int("version", version)) - } + logicalIndex, err = NewLogicalIndexTimeBased(instance.Name, model) } if err != nil { return err diff --git a/internals/coordinator/logicalindex_cron_v8.go b/internals/coordinator/logicalindex_cron.go similarity index 76% rename from internals/coordinator/logicalindex_cron_v8.go rename to internals/coordinator/logicalindex_cron.go index 4542b6ff..dbc75317 100644 --- a/internals/coordinator/logicalindex_cron_v8.go +++ b/internals/coordinator/logicalindex_cron.go @@ -4,6 +4,7 @@ import ( "context" "errors" "fmt" + "github.com/myrteametrics/myrtea-sdk/v5/elasticsearch" "sort" "sync" "time" @@ -12,17 +13,16 @@ import ( "github.com/elastic/go-elasticsearch/v8/typedapi/indices/updatealiases" "github.com/elastic/go-elasticsearch/v8/typedapi/some" "github.com/elastic/go-elasticsearch/v8/typedapi/types" - "github.com/myrteametrics/myrtea-sdk/v4/elasticsearchv8" - "github.com/myrteametrics/myrtea-sdk/v4/index" - "github.com/myrteametrics/myrtea-sdk/v4/modeler" + "github.com/myrteametrics/myrtea-sdk/v5/index" + "github.com/myrteametrics/myrtea-sdk/v5/modeler" - "github.com/myrteametrics/myrtea-sdk/v4/postgres" + "github.com/myrteametrics/myrtea-sdk/v5/postgres" "github.com/robfig/cron/v3" "go.uber.org/zap" ) -// LogicalIndexCronV8 abstracts a group a technical elasticsearchv6 indices, which are accessibles with specific aliases -type LogicalIndexCronV8 struct { +// LogicalIndexCron abstracts a group a technical elasticsearchv8 indices, which are accessibles with specific aliases +type LogicalIndexCron struct { Initialized bool Name string Cron *cron.Cron @@ -30,17 +30,17 @@ type LogicalIndexCronV8 struct { mu sync.RWMutex } -func NewLogicalIndexCronV8(instanceName string, model modeler.Model) (*LogicalIndexCronV8, error) { +func NewLogicalIndexCron(instanceName string, model modeler.Model) (*LogicalIndexCron, error) { logicalIndexName := fmt.Sprintf("%s-%s", instanceName, model.Name) - zap.L().Info("Initialize logicalIndex (LogicalIndexCronV8)", zap.String("name", logicalIndexName), zap.String("model", model.Name), zap.Any("options", model.ElasticsearchOptions)) + zap.L().Info("Initialize logicalIndex (LogicalIndexCron)", zap.String("name", logicalIndexName), zap.String("model", model.Name), zap.Any("options", model.ElasticsearchOptions)) if model.ElasticsearchOptions.Rollmode != "cron" { return nil, errors.New("invalid rollmode for this logicalIndex type") } - logicalIndex := &LogicalIndexCronV8{ + logicalIndex := &LogicalIndexCron{ Initialized: false, Name: logicalIndexName, Cron: nil, @@ -55,7 +55,7 @@ func NewLogicalIndexCronV8(instanceName string, model modeler.Model) (*LogicalIn // First create template if not exists templateName := fmt.Sprintf("template-%s", logicalIndexName) - templateExists, err := elasticsearchv8.C().Indices.ExistsTemplate(templateName).IsSuccess(ctx) + templateExists, err := elasticsearch.C().Indices.ExistsTemplate(templateName).IsSuccess(ctx) if err != nil { zap.L().Error("IndexTemplateExists()", zap.String("templateName", templateName), zap.Error(err)) return nil, err @@ -68,7 +68,7 @@ func NewLogicalIndexCronV8(instanceName string, model modeler.Model) (*LogicalIn // Then create base index name if not exists baseIndexName := logicalIndexName + "-active-000001" - baseIndexExists, err := elasticsearchv8.C().Indices.Exists(baseIndexName).IsSuccess(ctx) + baseIndexExists, err := elasticsearch.C().Indices.Exists(baseIndexName).IsSuccess(ctx) if err != nil { zap.L().Error("IndexExists()", zap.String("baseIndexName", baseIndexName), zap.Error(err)) return nil, err @@ -76,9 +76,9 @@ func NewLogicalIndexCronV8(instanceName string, model modeler.Model) (*LogicalIn if !baseIndexExists { zap.L().Info("Creating missing index", zap.String("baseIndexName", baseIndexName), zap.String("model", model.Name)) - _, err = elasticsearchv8.C().Indices.Create(baseIndexName).Do(ctx) + _, err = elasticsearch.C().Indices.Create(baseIndexName).Do(ctx) if err != nil { - zap.L().Error("elasticsearchv8.C().PutIndex()", zap.String("baseIndexName", baseIndexName), + zap.L().Error("elasticsearch.C().PutIndex()", zap.String("baseIndexName", baseIndexName), zap.Error(err)) return nil, err } @@ -126,8 +126,8 @@ func NewLogicalIndexCronV8(instanceName string, model modeler.Model) (*LogicalIn return logicalIndex, nil } -func (logicalIndex *LogicalIndexCronV8) putAlias(name, indexPattern, modelName string, ctx context.Context) error { - aliasExists, err := elasticsearchv8.C().Indices.ExistsAlias(name).IsSuccess(ctx) +func (logicalIndex *LogicalIndexCron) putAlias(name, indexPattern, modelName string, ctx context.Context) error { + aliasExists, err := elasticsearch.C().Indices.ExistsAlias(name).IsSuccess(ctx) if err != nil { zap.L().Error("IndexExists()", zap.String("aliasName", name), zap.Error(err)) return err @@ -138,20 +138,20 @@ func (logicalIndex *LogicalIndexCronV8) putAlias(name, indexPattern, modelName s zap.L().Info("Creating missing alias", zap.String("aliasName", name), zap.String("aliasIndex", indexPattern), zap.String("model", modelName)) - _, err = elasticsearchv8.C().Indices.PutAlias(indexPattern, name).Do(ctx) + _, err = elasticsearch.C().Indices.PutAlias(indexPattern, name).Do(ctx) if err != nil { - zap.L().Error("elasticsearchv8.C().PutAlias()", zap.String("aliasName", name), zap.Error(err)) + zap.L().Error("elasticsearch.C().PutAlias()", zap.String("aliasName", name), zap.Error(err)) return err } return nil } -func (logicalIndex *LogicalIndexCronV8) putTemplate(name string, indexPattern string, model modeler.Model) { - req := elasticsearchv8.NewPutTemplateRequestV8([]string{indexPattern}, model) +func (logicalIndex *LogicalIndexCron) putTemplate(name string, indexPattern string, model modeler.Model) { + req := elasticsearch.NewPutTemplateRequestV8([]string{indexPattern}, model) ctx, cancel := context.WithTimeout(context.Background(), 1*time.Minute) defer cancel() - response, err := elasticsearchv8.C().Indices.PutTemplate(name).Request(req).Do(ctx) + response, err := elasticsearch.C().Indices.PutTemplate(name).Request(req).Do(ctx) if err != nil { zap.L().Error("PutTemplate", zap.Error(err)) } @@ -160,12 +160,12 @@ func (logicalIndex *LogicalIndexCronV8) putTemplate(name string, indexPattern st } } -func (logicalIndex *LogicalIndexCronV8) GetCron() *cron.Cron { +func (logicalIndex *LogicalIndexCron) GetCron() *cron.Cron { return logicalIndex.Cron } // FindIndices search in indices referential every indices between two dates (calculated using current time and depth) -func (logicalIndex *LogicalIndexCronV8) FindIndices(t time.Time, depthDays int64) ([]string, error) { +func (logicalIndex *LogicalIndexCron) FindIndices(t time.Time, depthDays int64) ([]string, error) { if depthDays == 0 { return []string{fmt.Sprintf("%s-%s", logicalIndex.Name, index.All)}, nil } @@ -195,7 +195,7 @@ func (logicalIndex *LogicalIndexCronV8) FindIndices(t time.Time, depthDays int64 return indices, nil } -func (logicalIndex *LogicalIndexCronV8) rollover() { +func (logicalIndex *LogicalIndexCron) rollover() { ctx := context.Background() // Using rollover API to manage alias swap and indices names @@ -205,7 +205,7 @@ func (logicalIndex *LogicalIndexCronV8) rollover() { // req.Conditions.MaxAge = "24 h" // req.Conditions.MaxDocs = some.Int64(0) - resRollover, err := elasticsearchv8.C().Indices.Rollover(logicalIndex.Name + "-current").Request(req).Do(ctx) + resRollover, err := elasticsearch.C().Indices.Rollover(logicalIndex.Name + "-current").Request(req).Do(ctx) if err != nil { zap.L().Error("RollOverV2", zap.Error(err)) return @@ -213,7 +213,7 @@ func (logicalIndex *LogicalIndexCronV8) rollover() { // Roll patch alias alias := logicalIndex.Name + "-patch" - resAlias, err := elasticsearchv8.C().Indices.GetAlias().Name(alias).Do(ctx) + resAlias, err := elasticsearch.C().Indices.GetAlias().Name(alias).Do(ctx) if err != nil { zap.L().Error("GetIndicesByAlias", zap.Error(err)) return @@ -236,7 +236,7 @@ func (logicalIndex *LogicalIndexCronV8) rollover() { types.IndicesAction{Add: &types.AddAction{Index: some.String(resRollover.NewIndex), Alias: some.String(alias)}}, ) - updateAliasesResponse, err := elasticsearchv8.C().Indices.UpdateAliases().Request(updateAliasesRequest).Do(ctx) + updateAliasesResponse, err := elasticsearch.C().Indices.UpdateAliases().Request(updateAliasesRequest).Do(ctx) if err != nil { zap.L().Error("Putting alias", zap.Error(err), zap.String("index", resRollover.NewIndex), zap.String("alias", alias)) @@ -255,7 +255,7 @@ func (logicalIndex *LogicalIndexCronV8) rollover() { // Adding search alias on the newly created active index // Includes every active + inactive indices // TODO: Remove this step when template are reworked (and include this search alias) - _, err = elasticsearchv8.C().Indices.PutAlias(logicalIndex.Name+"-*", logicalIndex.Name+"-search").Do(ctx) + _, err = elasticsearch.C().Indices.PutAlias(logicalIndex.Name+"-*", logicalIndex.Name+"-search").Do(ctx) if err != nil { zap.L().Error("Putting alias", zap.Error(err), zap.String("index", logicalIndex.Name+"-*"), zap.String("alias", logicalIndex.Name+"-search")) @@ -269,7 +269,7 @@ func (logicalIndex *LogicalIndexCronV8) rollover() { // Purge outdated indices if logicalIndex.Model.ElasticsearchOptions.EnablePurge { - resAlias, err := elasticsearchv8.C().Indices.GetAlias().Name(logicalIndex.Name + "-search").Do(ctx) + resAlias, err := elasticsearch.C().Indices.GetAlias().Name(logicalIndex.Name + "-search").Do(ctx) if err != nil { zap.L().Error("GetIndicesByAlias", zap.Error(err)) return @@ -283,7 +283,7 @@ func (logicalIndex *LogicalIndexCronV8) rollover() { if len(searchIndices) > logicalIndex.Model.ElasticsearchOptions.PurgeMaxConcurrentIndices { toDelete := searchIndices[0] // oldest indices - _, err := elasticsearchv8.C().Indices.Delete(toDelete).Do(ctx) + _, err := elasticsearch.C().Indices.Delete(toDelete).Do(ctx) if err != nil { zap.L().Error("DeleteIndex", zap.Error(err), zap.String("index", searchIndices[0])) return @@ -297,7 +297,7 @@ func (logicalIndex *LogicalIndexCronV8) rollover() { } } -func (logicalIndex *LogicalIndexCronV8) persistTechnicalIndex(newIndex string, t time.Time) error { +func (logicalIndex *LogicalIndexCron) persistTechnicalIndex(newIndex string, t time.Time) error { if postgres.DB() == nil { return errors.New("postgresql Client not initialized") } @@ -318,7 +318,7 @@ func (logicalIndex *LogicalIndexCronV8) persistTechnicalIndex(newIndex string, t return nil } -func (logicalIndex *LogicalIndexCronV8) purgeTechnicalIndex(technicalIndex string) error { +func (logicalIndex *LogicalIndexCron) purgeTechnicalIndex(technicalIndex string) error { if postgres.DB() == nil { return errors.New("postgresql Client not initialized") } diff --git a/internals/coordinator/logicalindex_cron_v6.go b/internals/coordinator/logicalindex_cron_v6.go deleted file mode 100644 index 5344e6b0..00000000 --- a/internals/coordinator/logicalindex_cron_v6.go +++ /dev/null @@ -1,274 +0,0 @@ -package coordinator - -import ( - "context" - "errors" - "fmt" - "sort" - "sync" - "time" - - "github.com/myrteametrics/myrtea-sdk/v4/elasticsearchv6" - "github.com/myrteametrics/myrtea-sdk/v4/index" - "github.com/myrteametrics/myrtea-sdk/v4/modeler" - "github.com/myrteametrics/myrtea-sdk/v4/models" - - "github.com/myrteametrics/myrtea-sdk/v4/postgres" - "github.com/robfig/cron/v3" - "go.uber.org/zap" -) - -// LogicalIndexCronV6 abstracts a group a technical elasticsearchv6 indices, which are accessibles with specific aliases -type LogicalIndexCronV6 struct { - Initialized bool - Name string - Cron *cron.Cron - Model modeler.Model - mu sync.RWMutex -} - -func NewLogicalIndexCronV6(instanceName string, model modeler.Model) (*LogicalIndexCronV6, error) { - - logicalIndexName := fmt.Sprintf("%s-%s", instanceName, model.Name) - - zap.L().Info("Initialize logicalIndex (LogicalIndexCronV6)", zap.String("name", logicalIndexName), zap.String("model", model.Name), zap.Any("options", model.ElasticsearchOptions)) - - if model.ElasticsearchOptions.Rollmode != "cron" { - return nil, errors.New("invalid rollmode for this logicalIndex type") - } - - logicalIndex := &LogicalIndexCronV6{ - Initialized: false, - Name: logicalIndexName, - Cron: nil, - Model: model, - } - - ctx := context.Background() - indexPatern := fmt.Sprintf("%s-active-*", logicalIndexName) - exists, err := elasticsearchv6.C().IndexExists(ctx, indexPatern) - if err != nil { - return nil, err - } - if !exists { - // Build and put template - templateName := fmt.Sprintf("template-%s", logicalIndexName) - templateBody := models.NewTemplateV6( - []string{indexPatern}, - model.ToElasticsearchMappingProperties(), - model.ElasticsearchOptions.AdvancedSettings, - ) - - err := elasticsearchv6.C().PutTemplate(ctx, templateName, templateBody) - if err != nil { - zap.L().Error("elasticsearchv6.C().PutTemplate()", zap.Error(err)) - return nil, err - } - - // Put bootstrap index if missing - err = elasticsearchv6.C().PutIndex(ctx, logicalIndexName+"-active-*", logicalIndexName+"-active-000001") - if err != nil { - zap.L().Error("elasticsearchv6.C().PutIndex()", zap.Error(err)) - return nil, err - } - - // Adding current active index alias - err = elasticsearchv6.C().PutAlias(ctx, logicalIndexName+"-active-*", logicalIndexName+"-current") - if err != nil { - zap.L().Error("elasticsearchv6.C().PutAlias()", zap.Error(err)) - return nil, err - } - - if model.ElasticsearchOptions.PatchAliasMaxIndices > 0 { - // Adding current active index alias - err = elasticsearchv6.C().PutAlias(ctx, logicalIndexName+"-*", logicalIndexName+"-patch") - if err != nil { - zap.L().Error("elasticsearchv6.C().PutAlias()", zap.Error(err)) - return nil, err - } - } - - // Adding search alias on all active index - err = elasticsearchv6.C().PutAlias(ctx, logicalIndexName+"-*", logicalIndexName+"-search") - if err != nil { - zap.L().Error("elasticsearchv6.C().PutAlias()", zap.Error(err)) - return nil, err - } - - err = logicalIndex.persistTechnicalIndex(logicalIndexName+"-active-000001", time.Now().UTC()) - if err != nil { - zap.L().Error("Could not persist technical index data", zap.Error(err)) - } - } - - c := cron.New() - _, err = c.AddFunc(model.ElasticsearchOptions.Rollcron, logicalIndex.rollover) - if err != nil { - zap.L().Error("Cron add function logicalIndex.updateAliases", zap.Error(err)) - return nil, err - } - logicalIndex.Cron = c - zap.L().Info("Cron started", zap.String("logicalIndex", logicalIndexName), zap.String("cron", logicalIndex.Model.ElasticsearchOptions.Rollcron)) - - logicalIndex.Initialized = true - - return logicalIndex, nil -} - -func (logicalIndex *LogicalIndexCronV6) GetCron() *cron.Cron { - return logicalIndex.Cron -} - -// FindIndicesWithDynamicDepth search in indices referential every indices between two dates (calculated using current time and depth) -func (logicalIndex *LogicalIndexCronV6) FindIndices(t time.Time, depthDays int64) ([]string, error) { - if depthDays == 0 { - return []string{fmt.Sprintf("%s-%s", logicalIndex.Name, index.All)}, nil - } - - query := "select technical from elasticsearch_indices_v1 where logical = :logical AND creation_date BETWEEN :mindate AND :maxdate" - params := map[string]interface{}{ - "logical": logicalIndex.Name, - "mindate": t.Add(-1 * time.Duration(depthDays+1) * 24 * time.Hour), - "maxdate": t, - } - rows, err := postgres.DB().NamedQuery(query, params) - if err != nil { - return nil, err - } - defer rows.Close() - - indices := make([]string, 0) - for rows.Next() { - var name string - err := rows.Scan(&name) - if err != nil { - return nil, err - } - indices = append(indices, name) - } - - return indices, nil -} - -func (logicalIndex *LogicalIndexCronV6) rollover() { - ctx := context.Background() - - // Using rollover API to manage alias swap and indices names - // TODO: Change this dirty abuse of rollover API (triggered every day "max_docx = 0") - _, newIndex, err := elasticsearchv6.C().RollOver(ctx, logicalIndex.Name+"-current", "1d", 0) - if err != nil { - zap.L().Error("RollOverV2", zap.Error(err), zap.String("index", newIndex)) - return - } - - // Roll patch alias - patchIndices, err := elasticsearchv6.C().GetIndicesByAlias(ctx, logicalIndex.Name+"-patch") - if err != nil { - zap.L().Error("GetIndicesByAlias", zap.Error(err), zap.String("index", newIndex)) - return - } - sort.Strings(patchIndices) - - alias := logicalIndex.Name + "-patch" - aliasCmd := elasticsearchv6.C().Client.Alias() - if len(patchIndices) <= logicalIndex.Model.ElasticsearchOptions.PatchAliasMaxIndices { - if len(patchIndices) >= logicalIndex.Model.ElasticsearchOptions.PatchAliasMaxIndices { - aliasCmd = aliasCmd.Remove(patchIndices[0], alias) - } - aliasCmd = aliasCmd.Add(newIndex, alias) - aliasResult, err := aliasCmd.Do(context.Background()) - - if err != nil { - zap.L().Error("Putting alias", zap.Error(err), zap.String("index", newIndex), - zap.String("alias", alias)) - return - } - if !aliasResult.Acknowledged { - err := errors.New("es API return false acknowledged") - zap.L().Error("Putting alias", zap.Error(err), zap.String("index", newIndex), - zap.String("alias", alias)) - return - } - - zap.L().Info("Patch aliases rollover done", zap.String("alias", alias)) - } - - // Adding search alias on the newly created active index - // Includes every active + inactive indices - // TODO: Remove this step when template are reworked (and include this search alias) - err = elasticsearchv6.C().PutAlias(ctx, logicalIndex.Name+"-*", logicalIndex.Name+"-search") - if err != nil { - zap.L().Error("Putting alias", zap.Error(err), zap.String("index", logicalIndex.Name+"-*"), - zap.String("alias", logicalIndex.Name+"-search")) - return - } - - err = logicalIndex.persistTechnicalIndex(newIndex, time.Now().UTC()) - if err != nil { - zap.L().Error("Could not persist technical index data", zap.Error(err)) - } - - // Purge outdated indices - if logicalIndex.Model.ElasticsearchOptions.EnablePurge { - searchIndices, err := elasticsearchv6.C().GetIndicesByAlias(ctx, logicalIndex.Name+"-search") - if err != nil { - zap.L().Error("GetIndicesByAlias", zap.Error(err), zap.String("alias", logicalIndex.Name+"-search")) - return - } - sort.Strings(searchIndices) - - if len(searchIndices) > logicalIndex.Model.ElasticsearchOptions.PurgeMaxConcurrentIndices { - toDelete := searchIndices[0] // oldest indices - err := elasticsearchv6.C().DeleteIndices(ctx, []string{toDelete}) - if err != nil { - zap.L().Error("DeleteIndex", zap.Error(err), zap.String("index", searchIndices[0])) - return - } - err = logicalIndex.purgeTechnicalIndex(toDelete) - if err != nil { - zap.L().Error("Could not persist technical index data", zap.Error(err)) - } - zap.L().Info("Index purged", zap.String("name", toDelete)) - } - } -} - -func (logicalIndex *LogicalIndexCronV6) persistTechnicalIndex(newIndex string, t time.Time) error { - if postgres.DB() == nil { - return errors.New("postgresql Client not initialized") - } - - query := `INSERT INTO elasticsearch_indices_v1 (id, logical, technical, creation_date) - VALUES (DEFAULT, :logical, :technical, :creation_date);` - params := map[string]interface{}{ - "logical": logicalIndex.Name, - "technical": newIndex, - "creation_date": t, - } - - _, err := postgres.DB().NamedExec(query, params) - if err != nil { - return err - } - - return nil -} - -func (logicalIndex *LogicalIndexCronV6) purgeTechnicalIndex(technicalIndex string) error { - if postgres.DB() == nil { - return errors.New("postgresql Client not initialized") - } - - query := `DELETE FROM elasticsearch_indices_v1 where logical = :logical AND technical = :technical` - params := map[string]interface{}{ - "logical": logicalIndex.Name, - "technical": technicalIndex, - } - - _, err := postgres.DB().NamedExec(query, params) - if err != nil { - return err - } - - return nil -} diff --git a/internals/coordinator/logicalindex_timebased_v8.go b/internals/coordinator/logicalindex_timebased.go similarity index 71% rename from internals/coordinator/logicalindex_timebased_v8.go rename to internals/coordinator/logicalindex_timebased.go index 84e60f1a..aea12317 100644 --- a/internals/coordinator/logicalindex_timebased_v8.go +++ b/internals/coordinator/logicalindex_timebased.go @@ -4,19 +4,19 @@ import ( "context" "errors" "fmt" + "github.com/myrteametrics/myrtea-sdk/v5/elasticsearch" "sort" "sync" "time" - "github.com/myrteametrics/myrtea-sdk/v4/elasticsearchv8" - "github.com/myrteametrics/myrtea-sdk/v4/modeler" + "github.com/myrteametrics/myrtea-sdk/v5/modeler" "github.com/robfig/cron/v3" "go.uber.org/zap" ) -// LogicalIndexTimeBasedV8 abstracts a group a technical elasticsearchv8 indices, which are accessibles with specific aliases -type LogicalIndexTimeBasedV8 struct { +// LogicalIndexTimeBased abstracts a group a technical elasticsearchv8 indices, which are accessibles with specific aliases +type LogicalIndexTimeBased struct { Initialized bool Name string Cron *cron.Cron @@ -25,11 +25,11 @@ type LogicalIndexTimeBasedV8 struct { mu sync.RWMutex } -func NewLogicalIndexTimeBasedV8(instanceName string, model modeler.Model) (*LogicalIndexTimeBasedV8, error) { +func NewLogicalIndexTimeBased(instanceName string, model modeler.Model) (*LogicalIndexTimeBased, error) { logicalIndexName := fmt.Sprintf("%s-%s", instanceName, model.Name) - zap.L().Info("Initialize logicalIndex (LogicalIndexTimeBasedV8)", zap.String("name", logicalIndexName), zap.String("model", model.Name), zap.Any("options", model.ElasticsearchOptions)) + zap.L().Info("Initialize logicalIndex (LogicalIndexTimeBased)", zap.String("name", logicalIndexName), zap.String("model", model.Name), zap.Any("options", model.ElasticsearchOptions)) if model.ElasticsearchOptions.Rollmode != "timebased" { return nil, errors.New("invalid rollmode for this logicalIndex type") @@ -37,7 +37,7 @@ func NewLogicalIndexTimeBasedV8(instanceName string, model modeler.Model) (*Logi templateName := fmt.Sprintf("template-%s", logicalIndexName) - logicalIndex := &LogicalIndexTimeBasedV8{ + logicalIndex := &LogicalIndexTimeBased{ Initialized: false, Name: logicalIndexName, Cron: nil, @@ -47,7 +47,7 @@ func NewLogicalIndexTimeBasedV8(instanceName string, model modeler.Model) (*Logi ctx, cancel := context.WithTimeout(context.Background(), 1*time.Minute) defer cancel() - templateExists, err := elasticsearchv8.C().Indices.ExistsTemplate(templateName).IsSuccess(ctx) + templateExists, err := elasticsearch.C().Indices.ExistsTemplate(templateName).IsSuccess(ctx) if err != nil { zap.L().Error("IndexTemplateExists()", zap.Error(err)) return nil, err @@ -81,11 +81,11 @@ func NewLogicalIndexTimeBasedV8(instanceName string, model modeler.Model) (*Logi return logicalIndex, nil } -func (logicalIndex *LogicalIndexTimeBasedV8) GetCron() *cron.Cron { +func (logicalIndex *LogicalIndexTimeBased) GetCron() *cron.Cron { return logicalIndex.Cron } -func (logicalIndex *LogicalIndexTimeBasedV8) purge() { +func (logicalIndex *LogicalIndexTimeBased) purge() { if !logicalIndex.Model.ElasticsearchOptions.EnablePurge { return } @@ -113,12 +113,12 @@ func (logicalIndex *LogicalIndexTimeBasedV8) purge() { logicalIndex.FetchIndices() } -func (logicalIndex *LogicalIndexTimeBasedV8) putTemplate(name string, indexPatern string, model modeler.Model) { - req := elasticsearchv8.NewPutTemplateRequestV8([]string{indexPatern}, model) +func (logicalIndex *LogicalIndexTimeBased) putTemplate(name string, indexPatern string, model modeler.Model) { + req := elasticsearch.NewPutTemplateRequestV8([]string{indexPatern}, model) ctx, cancel := context.WithTimeout(context.Background(), 1*time.Minute) defer cancel() - response, err := elasticsearchv8.C().Indices.PutTemplate(name).Request(req).Do(ctx) + response, err := elasticsearch.C().Indices.PutTemplate(name).Request(req).Do(ctx) if err != nil { zap.L().Error("PutTemplate", zap.Error(err)) } @@ -127,11 +127,11 @@ func (logicalIndex *LogicalIndexTimeBasedV8) putTemplate(name string, indexPater } } -func (logicalIndex *LogicalIndexTimeBasedV8) deleteIndex(index string) { +func (logicalIndex *LogicalIndexTimeBased) deleteIndex(index string) { ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) defer cancel() - success, err := elasticsearchv8.C().Indices.Delete(index).IsSuccess(ctx) + success, err := elasticsearch.C().Indices.Delete(index).IsSuccess(ctx) if err != nil { zap.L().Warn("Delete index failed", zap.Error(err)) } @@ -140,7 +140,7 @@ func (logicalIndex *LogicalIndexTimeBasedV8) deleteIndex(index string) { } } -func (logicalIndex *LogicalIndexTimeBasedV8) FetchIndices() { +func (logicalIndex *LogicalIndexTimeBased) FetchIndices() { indices := logicalIndex.GetAllIndices() logicalIndex.mu.Lock() @@ -148,10 +148,10 @@ func (logicalIndex *LogicalIndexTimeBasedV8) FetchIndices() { logicalIndex.mu.Unlock() } -func (logicalIndex *LogicalIndexTimeBasedV8) GetAllIndices() []string { +func (logicalIndex *LogicalIndexTimeBased) GetAllIndices() []string { ctx, cancel := context.WithTimeout(context.Background(), 1*time.Minute) defer cancel() - response, err := elasticsearchv8.C().Cat.Indices().Index(fmt.Sprintf("%s-*", logicalIndex.Name)).Do(ctx) + response, err := elasticsearch.C().Cat.Indices().Index(fmt.Sprintf("%s-*", logicalIndex.Name)).Do(ctx) if err != nil { zap.L().Error("elasticsearchv8 CatIndices", zap.Error(err)) return make([]string, 0) @@ -167,7 +167,7 @@ func (logicalIndex *LogicalIndexTimeBasedV8) GetAllIndices() []string { return indices } -func (logicalIndex *LogicalIndexTimeBasedV8) FindIndices(t time.Time, depthDays int64) ([]string, error) { +func (logicalIndex *LogicalIndexTimeBased) FindIndices(t time.Time, depthDays int64) ([]string, error) { tsStart := t.Add(time.Duration(depthDays) * -1 * 24 * time.Hour) indexEnd := fmt.Sprintf("%s-%s", logicalIndex.Name, t.Format("2006-01-02")) indexStart := fmt.Sprintf("%s-%s", logicalIndex.Name, tsStart.Format("2006-01-02")) diff --git a/internals/coordinator/logicalindex_timebased_v6.go b/internals/coordinator/logicalindex_timebased_v6.go deleted file mode 100644 index 136f4dcf..00000000 --- a/internals/coordinator/logicalindex_timebased_v6.go +++ /dev/null @@ -1,165 +0,0 @@ -package coordinator - -import ( - "context" - "errors" - "fmt" - "sort" - "sync" - "time" - - "github.com/myrteametrics/myrtea-sdk/v4/modeler" - "github.com/myrteametrics/myrtea-sdk/v4/models" - - "github.com/myrteametrics/myrtea-sdk/v4/elasticsearchv6" - "github.com/robfig/cron/v3" - "go.uber.org/zap" -) - -// LogicalIndexTimeBasedV6 abstracts a group a technical elasticsearchv6 indices, which are accessibles with specific aliases -type LogicalIndexTimeBasedV6 struct { - Initialized bool - Name string - Cron *cron.Cron - Model modeler.Model - LiveIndices []string - mu sync.RWMutex -} - -func NewLogicalIndexTimeBasedV6(instanceName string, model modeler.Model) (*LogicalIndexTimeBasedV6, error) { - - logicalIndexName := fmt.Sprintf("%s-%s", instanceName, model.Name) - - zap.L().Info("Initialize logicalIndex (LogicalIndexTimeBasedV6)", zap.String("name", logicalIndexName), zap.String("model", model.Name), zap.Any("options", model.ElasticsearchOptions)) - - if model.ElasticsearchOptions.Rollmode != "timebased" { - return nil, errors.New("invalid rollmode for this logicalIndex type") - } - - ctx, cancel := context.WithTimeout(context.Background(), 1*time.Minute) - defer cancel() - templateName := fmt.Sprintf("template-%s", logicalIndexName) - templateExists, err := elasticsearchv6.C().Client.IndexTemplateExists(templateName).Do(ctx) - if err != nil { - zap.L().Error("IndexTemplateExists()", zap.Error(err)) - return nil, err - } - if !templateExists { - indexPatern := fmt.Sprintf("%s-*", logicalIndexName) - templateBody := models.NewTemplateV6([]string{indexPatern}, model.ToElasticsearchMappingProperties(), model.ElasticsearchOptions.AdvancedSettings) - err := elasticsearchv6.C().PutTemplate(ctx, templateName, templateBody) - if err != nil { - zap.L().Error("PutTemplate()", zap.Error(err)) - return nil, err - } - } - - logicalIndex := &LogicalIndexTimeBasedV6{ - Initialized: false, - Name: logicalIndexName, - Cron: nil, - Model: model, - LiveIndices: make([]string, 0), - } - - logicalIndex.FetchIndices() - - c := cron.New() - _, err = c.AddFunc("*/30 * * * *", logicalIndex.FetchIndices) - if err != nil { - zap.L().Error("Cron add function logicalIndex.updateAliases", zap.Error(err)) - return nil, err - } - - if logicalIndex.Model.ElasticsearchOptions.EnablePurge { - _, err = c.AddFunc(logicalIndex.Model.ElasticsearchOptions.Rollcron, logicalIndex.purge) - if err != nil { - zap.L().Error("Cron add function logicalIndex.updateAliases", zap.Error(err)) - return nil, err - } - } - - logicalIndex.Cron = c - zap.L().Info("Cron started", zap.String("logicalIndex", logicalIndex.Name), zap.String("cron", logicalIndex.Model.ElasticsearchOptions.Rollcron)) - - return logicalIndex, nil -} - -func (logicalIndex *LogicalIndexTimeBasedV6) GetCron() *cron.Cron { - return logicalIndex.Cron -} - -func (logicalIndex *LogicalIndexTimeBasedV6) purge() { - if !logicalIndex.Model.ElasticsearchOptions.EnablePurge { - return - } - - tsStart := time.Now().Add(time.Duration(logicalIndex.Model.ElasticsearchOptions.PurgeMaxConcurrentIndices) * -1 * 24 * time.Hour) - indexStart := fmt.Sprintf("%s-%s", logicalIndex.Name, tsStart.Format("2006-01-02")) - - ctx, cancel := context.WithTimeout(context.Background(), 1*time.Minute) - defer cancel() - catIndicesResponse, err := elasticsearchv6.C().Client.CatIndices().Index(fmt.Sprintf("%s-*", logicalIndex.Name)).Columns("index").Do(ctx) - if err != nil { - zap.L().Error("elasticsearchv6 CatIndices", zap.Error(err)) - return - } - - indices := make([]string, 0) - for _, index := range catIndicesResponse { - if index.Index < indexStart { // purge selection condition - indices = append(indices, index.Index) - } - } - sort.Strings(indices) - - zap.L().Info("Purging indices older than", zap.String("indexStart", indexStart), zap.Strings("indices", indices)) - - if len(indices) > 0 { - ctxDelete, cancelDelete := context.WithTimeout(context.Background(), 5*time.Minute) - defer cancelDelete() - _, err = elasticsearchv6.C().Client.DeleteIndex(indices...).Do(ctxDelete) - if err != nil { - zap.L().Warn("Delete index", zap.Error(err)) - } - } - - logicalIndex.FetchIndices() - -} - -func (logicalIndex *LogicalIndexTimeBasedV6) FetchIndices() { - ctx, cancel := context.WithTimeout(context.Background(), 1*time.Minute) - defer cancel() - catIndicesResponse, err := elasticsearchv6.C().Client.CatIndices().Index(fmt.Sprintf("%s-*", logicalIndex.Name)).Columns("index").Do(ctx) - if err != nil { - zap.L().Error("elasticsearchv6 CatIndices", zap.Error(err)) - return - } - - indices := make([]string, 0) - for _, index := range catIndicesResponse { - indices = append(indices, index.Index) - } - sort.Strings(indices) - - logicalIndex.mu.Lock() - logicalIndex.LiveIndices = indices - logicalIndex.mu.Unlock() -} - -func (logicalIndex *LogicalIndexTimeBasedV6) FindIndices(t time.Time, depthDays int64) ([]string, error) { - tsStart := t.Add(time.Duration(depthDays) * -1 * 24 * time.Hour) - indexEnd := fmt.Sprintf("%s-%s", logicalIndex.Name, t.Format("2006-01-02")) - indexStart := fmt.Sprintf("%s-%s", logicalIndex.Name, tsStart.Format("2006-01-02")) - - indices := make([]string, 0) - logicalIndex.mu.RLock() - for _, index := range logicalIndex.LiveIndices { - if index >= indexStart && index <= indexEnd { - indices = append(indices, index) - } - } - logicalIndex.mu.RUnlock() - return indices, nil -} diff --git a/internals/coordinator/update.go b/internals/coordinator/update.go index 7aef8cec..d0e981d0 100644 --- a/internals/coordinator/update.go +++ b/internals/coordinator/update.go @@ -8,7 +8,7 @@ package coordinator // "github.com/spf13/viper" // "github.com/myrteametrics/myrtea-engine-api/v5/internals/coordinator" // "github.com/myrteametrics/myrtea-engine-api/v5/internals/model" -// "github.com/myrteametrics/myrtea-sdk/v4/modeler" +// "github.com/myrteametrics/myrtea-sdk/v5/modeler" // "go.uber.org/zap" // ) diff --git a/internals/evaluator/engine.go b/internals/evaluator/engine.go index fa427836..9393494f 100644 --- a/internals/evaluator/engine.go +++ b/internals/evaluator/engine.go @@ -7,7 +7,7 @@ import ( "time" "github.com/myrteametrics/myrtea-engine-api/v5/internals/rule" - "github.com/myrteametrics/myrtea-sdk/v4/ruleeng" + "github.com/myrteametrics/myrtea-sdk/v5/ruleeng" ) var ( diff --git a/internals/evaluator/evaluator.go b/internals/evaluator/evaluator.go index c17f9f78..b3b315ee 100644 --- a/internals/evaluator/evaluator.go +++ b/internals/evaluator/evaluator.go @@ -1,7 +1,7 @@ package evaluator import ( - "github.com/myrteametrics/myrtea-sdk/v4/ruleeng" + "github.com/myrteametrics/myrtea-sdk/v5/ruleeng" ) func BuildLocalRuleEngine(engineID string) (*ruleeng.RuleEngine, error) { diff --git a/internals/evaluator/evaluator.go.old b/internals/evaluator/evaluator.go.old index 041f8870..6823474e 100644 --- a/internals/evaluator/evaluator.go.old +++ b/internals/evaluator/evaluator.go.old @@ -10,8 +10,8 @@ import ( "github.com/myrteametrics/myrtea-engine-api/v5/internals/reader" "github.com/myrteametrics/myrtea-engine-api/v5/internals/rule" "github.com/myrteametrics/myrtea-engine-api/v5/internals/situation" - "github.com/myrteametrics/myrtea-sdk/v4/engine" - "github.com/myrteametrics/myrtea-sdk/v4/expression" + "github.com/myrteametrics/myrtea-sdk/v5/engine" + "github.com/myrteametrics/myrtea-sdk/v5/expression" "go.uber.org/zap" ) diff --git a/internals/evaluator/evaluator_test.go.old b/internals/evaluator/evaluator_test.go.old index bc46412b..781d668d 100644 --- a/internals/evaluator/evaluator_test.go.old +++ b/internals/evaluator/evaluator_test.go.old @@ -12,8 +12,8 @@ import ( "github.com/myrteametrics/myrtea-engine-api/v5/internals/rule" "github.com/myrteametrics/myrtea-engine-api/v5/internals/situation" "github.com/myrteametrics/myrtea-engine-api/v5/internals/tests" - "github.com/myrteametrics/myrtea-sdk/v4/engine" - "github.com/myrteametrics/myrtea-sdk/v4/postgres" + "github.com/myrteametrics/myrtea-sdk/v5/engine" + "github.com/myrteametrics/myrtea-sdk/v5/postgres" ) func dbInit(dbClient *sqlx.DB, t *testing.T) { diff --git a/internals/evaluator/models.go b/internals/evaluator/models.go index 1a38ab27..901b23ab 100644 --- a/internals/evaluator/models.go +++ b/internals/evaluator/models.go @@ -3,7 +3,7 @@ package evaluator import ( "time" - "github.com/myrteametrics/myrtea-sdk/v4/ruleeng" + "github.com/myrteametrics/myrtea-sdk/v5/ruleeng" ) // SituationToEvaluate is used to notify a rule engine instance that a situation must me evaluated diff --git a/internals/explainer/bulk.go b/internals/explainer/bulk.go index 0cce53ed..7cdb14d6 100644 --- a/internals/explainer/bulk.go +++ b/internals/explainer/bulk.go @@ -8,7 +8,7 @@ import ( "github.com/myrteametrics/myrtea-engine-api/v5/internals/handlers/render" "github.com/myrteametrics/myrtea-engine-api/v5/internals/models" "github.com/myrteametrics/myrtea-engine-api/v5/internals/security/users" - "github.com/myrteametrics/myrtea-sdk/v4/postgres" + "github.com/myrteametrics/myrtea-sdk/v5/postgres" "go.uber.org/zap" ) @@ -27,7 +27,7 @@ func DraftIssues(idIssues []int64, user users.User, status *models.DraftIssuesSt DrafHandleError(status, idIssue, errors.New("recommendation tree based on issue resolution stats table"), render.ErrAPIDBSelectFailed) continue } - + err = SaveIssueDraft(nil, issue, *tree, user) if err != nil { zap.L().Error("SaveIssueDraft", zap.Error(err)) diff --git a/internals/explainer/detection_feedback_test.go b/internals/explainer/detection_feedback_test.go index c58534dc..24fb3ac5 100644 --- a/internals/explainer/detection_feedback_test.go +++ b/internals/explainer/detection_feedback_test.go @@ -11,7 +11,7 @@ package explainer // "github.com/myrteametrics/myrtea-engine-api/v5/internals/situation" // "github.com/myrteametrics/myrtea-engine-api/v5/internals/tests" // "github.com/myrteametrics/myrtea-engine-api/v5/internals/users" -// "github.com/myrteametrics/myrtea-sdk/v4/security" +// "github.com/myrteametrics/myrtea-sdk/v5/security" // ) // func dbInitDetection(dbClient *sqlx.DB, t *testing.T) { diff --git a/internals/explainer/feedback.go b/internals/explainer/feedback.go index 246ea699..b509f140 100644 --- a/internals/explainer/feedback.go +++ b/internals/explainer/feedback.go @@ -12,7 +12,7 @@ import ( "github.com/myrteametrics/myrtea-engine-api/v5/internals/explainer/rootcause" "github.com/myrteametrics/myrtea-engine-api/v5/internals/models" "github.com/myrteametrics/myrtea-engine-api/v5/internals/security/users" - "github.com/myrteametrics/myrtea-sdk/v4/postgres" + "github.com/myrteametrics/myrtea-sdk/v5/postgres" ) // CloseIssueWithoutFeedback close an issue without standard feedback on rootcause / action diff --git a/internals/explainer/issues.go b/internals/explainer/issues.go index 979e92a2..6bc4e4e2 100644 --- a/internals/explainer/issues.go +++ b/internals/explainer/issues.go @@ -8,7 +8,7 @@ import ( "github.com/myrteametrics/myrtea-engine-api/v5/internals/history" "github.com/myrteametrics/myrtea-engine-api/v5/internals/models" "github.com/myrteametrics/myrtea-engine-api/v5/internals/reader" - "github.com/myrteametrics/myrtea-sdk/v4/engine" + "github.com/myrteametrics/myrtea-sdk/v5/engine" "go.uber.org/zap" ) @@ -70,7 +70,7 @@ func IsOpenOrDraftIssue(issueKey string) (bool, error) { return true, nil } -//GetFactsHistory get the history of facts for an issue +// GetFactsHistory get the history of facts for an issue func GetFactsHistory(issue models.Issue) ([]models.FrontFactHistory, bool, error) { // TODO: interval shouldn't hard coded ? diff --git a/internals/explainer/issues_test.go.old b/internals/explainer/issues_test.go.old index fd0a866e..b9cd3bbe 100644 --- a/internals/explainer/issues_test.go.old +++ b/internals/explainer/issues_test.go.old @@ -11,8 +11,8 @@ import ( "github.com/myrteametrics/myrtea-engine-api/v5/internals/reader" "github.com/myrteametrics/myrtea-engine-api/v5/internals/situation" "github.com/myrteametrics/myrtea-engine-api/v5/internals/tests" - "github.com/myrteametrics/myrtea-sdk/v4/engine" - "github.com/myrteametrics/myrtea-sdk/v4/postgres" + "github.com/myrteametrics/myrtea-sdk/v5/engine" + "github.com/myrteametrics/myrtea-sdk/v5/postgres" ) func dbInitRepo(dbClient *sqlx.DB, t *testing.T) { diff --git a/internals/explainer/stats_action.go b/internals/explainer/stats_action.go index 5868f4fe..8b8b81da 100644 --- a/internals/explainer/stats_action.go +++ b/internals/explainer/stats_action.go @@ -1,6 +1,6 @@ package explainer -import "github.com/myrteametrics/myrtea-sdk/v4/postgres" +import "github.com/myrteametrics/myrtea-sdk/v5/postgres" // ActionStats is a single action usage stats type ActionStats struct { diff --git a/internals/explainer/stats_rootcause.go b/internals/explainer/stats_rootcause.go index d735ec6e..28ade7fc 100644 --- a/internals/explainer/stats_rootcause.go +++ b/internals/explainer/stats_rootcause.go @@ -1,7 +1,7 @@ package explainer import ( - "github.com/myrteametrics/myrtea-sdk/v4/postgres" + "github.com/myrteametrics/myrtea-sdk/v5/postgres" ) // RootCauseStats is a single rootcause usage stats diff --git a/internals/export/elasticsearch.go b/internals/export/elasticsearch.go index f2de69fa..e0311e77 100644 --- a/internals/export/elasticsearch.go +++ b/internals/export/elasticsearch.go @@ -3,19 +3,18 @@ package export import ( "context" "errors" - "github.com/elastic/go-elasticsearch/v8" + es "github.com/elastic/go-elasticsearch/v8" "github.com/elastic/go-elasticsearch/v8/typedapi/core/search" "github.com/myrteametrics/myrtea-engine-api/v5/internals/config/esconfig" + "github.com/myrteametrics/myrtea-sdk/v5/elasticsearch" "strings" "time" "github.com/elastic/go-elasticsearch/v8/typedapi/core/closepointintime" "github.com/elastic/go-elasticsearch/v8/typedapi/types" - "github.com/myrteametrics/myrtea-sdk/v4/elasticsearchv8" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/fact" "github.com/myrteametrics/myrtea-engine-api/v5/internals/reader" - "github.com/myrteametrics/myrtea-sdk/v4/engine" + "github.com/myrteametrics/myrtea-sdk/v5/engine" "go.uber.org/zap" ) @@ -42,6 +41,7 @@ func (export StreamedExport) DrainChannel() { } // StreamedExportFactHitsFull export data from ElasticSearch to a channel +// Please note that the channel is not closed when this function is executed // it is building the searchRequest generated by the fact, and the indices func (export StreamedExport) StreamedExportFactHitsFull(ctx context.Context, f engine.Fact, limit int64, factParameters map[string]string) error { ti := time.Now() @@ -53,7 +53,7 @@ func (export StreamedExport) StreamedExportFactHitsFull(ctx context.Context, f e return err } - searchRequest, err := elasticsearchv8.ConvertFactToSearchRequestV8(f, ti, factParameters) + searchRequest, err := elasticsearch.ConvertFactToSearchRequestV8(f, ti, factParameters) if err != nil { zap.L().Error("ConvertFactToSearchRequestV8 failed", zap.Error(err)) return err @@ -69,7 +69,7 @@ func (export StreamedExport) StreamedExportFactHitsFull(ctx context.Context, f e // using a given elastic client, request and indices to query // Please note that the channel is not closed when this function is executed func (export StreamedExport) ProcessStreamedExport(ctx context.Context, elasticClient, indicesStr string, searchRequest *search.Request, limit int64) error { - cli := elasticsearchv8.C() // defaults to singleton instance + cli := elasticsearch.C() // defaults to singleton instance if elasticClient != "" { config, b, err := esconfig.R().GetByName(elasticClient) @@ -92,7 +92,7 @@ func (export StreamedExport) ProcessStreamedExport(ctx context.Context, elasticC return errors.New("cannot init an elasticsearch client with missing URLs") } - cli, err = elasticsearch.NewTypedClient(elasticsearch.Config{ + cli, err = es.NewTypedClient(es.Config{ Addresses: config.URLs, }) if err != nil { @@ -162,7 +162,7 @@ func (export StreamedExport) ProcessStreamedExport(ctx context.Context, elasticC break } - widgetData, err := reader.ParseV8(response) + widgetData, err := reader.Parse(response) if err != nil { return err } @@ -201,7 +201,7 @@ func ExportFactHitsFull(f engine.Fact) ([]reader.Hit, error) { return nil, err } - searchRequest, err := elasticsearchv8.ConvertFactToSearchRequestV8(f, ti, placeholders) + searchRequest, err := elasticsearch.ConvertFactToSearchRequestV8(f, ti, placeholders) if err != nil { zap.L().Error("ConvertFactToSearchRequestV8 failed", zap.Error(err)) return nil, err @@ -211,7 +211,7 @@ func ExportFactHitsFull(f engine.Fact) ([]reader.Hit, error) { indicesStr := strings.Join(indices, ",") // handle pit creation - pit, err := elasticsearchv8.C().OpenPointInTime(indicesStr).KeepAlive("1m").Do(context.Background()) + pit, err := elasticsearch.C().OpenPointInTime(indicesStr).KeepAlive("1m").Do(context.Background()) if err != nil { zap.L().Error("OpenPointInTime failed", zap.Error(err)) return nil, err @@ -221,7 +221,7 @@ func ExportFactHitsFull(f engine.Fact) ([]reader.Hit, error) { // searchRequest.TrackTotalHits = false // Speeds up pagination (maybe impl?) for { - response, err := elasticsearchv8.C().Search(). + response, err := elasticsearch.C().Search(). //Index(indicesStr). Size(10000). Request(searchRequest). @@ -239,7 +239,7 @@ func ExportFactHitsFull(f engine.Fact) ([]reader.Hit, error) { break } - widgetData, err := reader.ParseV8(response) + widgetData, err := reader.Parse(response) if err != nil { return nil, err } @@ -254,7 +254,7 @@ func ExportFactHitsFull(f engine.Fact) ([]reader.Hit, error) { } } - do, err := elasticsearchv8.C().ClosePointInTime(). + do, err := elasticsearch.C().ClosePointInTime(). Request(&closepointintime.Request{Id: pit.Id}). Do(context.Background()) @@ -267,7 +267,8 @@ func ExportFactHitsFull(f engine.Fact) ([]reader.Hit, error) { return fullHits, nil } -func ExportFactHitsV8(ti time.Time, f engine.Fact, placeholders map[string]string, nhit int, offset int) ([]reader.Hit, error) { +// ExportFactHits export data from ElasticSearch and returns a slice of Hits +func ExportFactHits(ti time.Time, f engine.Fact, placeholders map[string]string, nhit int, offset int) ([]reader.Hit, error) { // Change the behaviour of the Fact f.Intent.Operator = engine.Select diff --git a/internals/export/elasticsearch_test.go b/internals/export/elasticsearch_test.go index d19cae10..3354ad9a 100644 --- a/internals/export/elasticsearch_test.go +++ b/internals/export/elasticsearch_test.go @@ -1,9 +1,10 @@ package export import ( + "github.com/elastic/go-elasticsearch/v8" + elasticsearchsdk "github.com/myrteametrics/myrtea-sdk/v5/elasticsearch" "testing" - "github.com/elastic/go-elasticsearch/v8" "github.com/myrteametrics/myrtea-engine-api/v5/internals/coordinator" "github.com/myrteametrics/myrtea-engine-api/v5/internals/fact" "github.com/myrteametrics/myrtea-engine-api/v5/internals/history" @@ -11,12 +12,11 @@ import ( "github.com/myrteametrics/myrtea-engine-api/v5/internals/rule" "github.com/myrteametrics/myrtea-engine-api/v5/internals/situation" "github.com/myrteametrics/myrtea-engine-api/v5/internals/tests" - "github.com/myrteametrics/myrtea-sdk/v4/elasticsearchv8" - "github.com/myrteametrics/myrtea-sdk/v4/helpers" - "github.com/myrteametrics/myrtea-sdk/v4/postgres" + "github.com/myrteametrics/myrtea-sdk/v5/helpers" + "github.com/myrteametrics/myrtea-sdk/v5/postgres" "github.com/spf13/viper" - "github.com/myrteametrics/myrtea-sdk/v4/engine" + "github.com/myrteametrics/myrtea-sdk/v5/engine" ) // ConfigPath is the toml configuration file path @@ -71,7 +71,7 @@ func TestExportFactHits(t *testing.T) { helpers.InitializeConfig(AllowedConfigKey, ConfigName, "../../config", EnvPrefix) helpers.InitLogger(viper.GetBool("LOGGER_PRODUCTION")) urls := viper.GetStringSlice("ELASTICSEARCH_URLS") - elasticsearchv8.ReplaceGlobals(elasticsearch.Config{ + elasticsearchsdk.ReplaceGlobals(elasticsearch.Config{ Addresses: urls, }) diff --git a/internals/export/notification_test.go b/internals/export/notification_test.go index ca390224..1c7e267b 100644 --- a/internals/export/notification_test.go +++ b/internals/export/notification_test.go @@ -3,7 +3,7 @@ package export import ( "github.com/google/uuid" "github.com/myrteametrics/myrtea-engine-api/v5/internals/notifier/notification" - "github.com/myrteametrics/myrtea-sdk/v4/expression" + "github.com/myrteametrics/myrtea-sdk/v5/expression" "testing" ) diff --git a/internals/export/utils_test.go b/internals/export/utils_test.go index 8be6a793..f9f2ba6a 100644 --- a/internals/export/utils_test.go +++ b/internals/export/utils_test.go @@ -1,7 +1,7 @@ package export import ( - "github.com/myrteametrics/myrtea-sdk/v4/expression" + "github.com/myrteametrics/myrtea-sdk/v5/expression" "testing" ) diff --git a/internals/export/worker_test.go b/internals/export/worker_test.go index fd1b50b4..40a27f68 100644 --- a/internals/export/worker_test.go +++ b/internals/export/worker_test.go @@ -1,7 +1,7 @@ package export import ( - "github.com/myrteametrics/myrtea-sdk/v4/expression" + "github.com/myrteametrics/myrtea-sdk/v5/expression" "testing" ) diff --git a/internals/export/wrapper.go b/internals/export/wrapper.go index a8e41d44..1ba283fc 100644 --- a/internals/export/wrapper.go +++ b/internals/export/wrapper.go @@ -3,6 +3,7 @@ package export import ( "context" "github.com/elastic/go-elasticsearch/v8/typedapi/core/search" + sdksecurity "github.com/myrteametrics/myrtea-sdk/v5/security" "os" "path/filepath" "strings" @@ -11,9 +12,8 @@ import ( "github.com/google/uuid" "github.com/myrteametrics/myrtea-engine-api/v5/internals/notifier" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/security" "github.com/myrteametrics/myrtea-engine-api/v5/internals/security/users" - "github.com/myrteametrics/myrtea-sdk/v4/engine" + "github.com/myrteametrics/myrtea-sdk/v5/engine" "go.uber.org/zap" ) @@ -97,7 +97,7 @@ func NewWrapperItem(facts []engine.Fact, title string, params CSVParameters, use if addHashPrefix { // file extension should be gz // add random string to avoid multiple files with same name - fileName = security.RandStringWithCharset(5, randCharSet) + "_" + + fileName = sdksecurity.RandStringWithCharset(5, randCharSet) + "_" + strings.ReplaceAll(title, " ", "_") + ".csv.gz" } else if !strings.HasSuffix(title, ".csv.gz") { fileName = strings.ReplaceAll(title, " ", "_") + ".csv.gz" diff --git a/internals/export/wrapper_test.go b/internals/export/wrapper_test.go index 7711423c..3d01633f 100644 --- a/internals/export/wrapper_test.go +++ b/internals/export/wrapper_test.go @@ -12,8 +12,8 @@ import ( "github.com/google/uuid" "github.com/myrteametrics/myrtea-engine-api/v5/internals/notifier" "github.com/myrteametrics/myrtea-engine-api/v5/internals/security/users" - "github.com/myrteametrics/myrtea-sdk/v4/engine" - "github.com/myrteametrics/myrtea-sdk/v4/expression" + "github.com/myrteametrics/myrtea-sdk/v5/engine" + "github.com/myrteametrics/myrtea-sdk/v5/expression" ) func TestNewWrapper(t *testing.T) { diff --git a/internals/fact/build.go b/internals/fact/build.go index 46149999..fbef6f46 100644 --- a/internals/fact/build.go +++ b/internals/fact/build.go @@ -7,7 +7,7 @@ import ( "strings" "github.com/myrteametrics/myrtea-engine-api/v5/internals/fact/lexer" - "github.com/myrteametrics/myrtea-sdk/v4/engine" + "github.com/myrteametrics/myrtea-sdk/v5/engine" parsec "github.com/prataprc/goparsec" "github.com/spf13/viper" "go.uber.org/zap" diff --git a/internals/fact/history.go.old b/internals/fact/history.go.old deleted file mode 100644 index 2b9b0d89..00000000 --- a/internals/fact/history.go.old +++ /dev/null @@ -1,316 +0,0 @@ -package fact - -import ( - "encoding/json" - "errors" - "fmt" - "time" - - "github.com/lib/pq" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/reader" - "github.com/myrteametrics/myrtea-sdk/v4/engine" - "github.com/myrteametrics/myrtea-sdk/v4/postgres" - "go.uber.org/zap" -) - -// SituationHistoryRecord represents a single and unique situation history entry -type SituationHistoryRecord struct { - ID int64 - TS time.Time - TemplateInstanceID int64 - Parameters map[string]string -} - -// HistoryRecord fact history record -type HistoryRecord struct { - Fact engine.Fact - ID int64 - TS time.Time - SituationID int64 - TemplateInstanceID int64 - SituationInstances []SituationHistoryRecord -} - -// PersistFactResult persists a fact result (related to a specific time) in postgresql -func PersistFactResult(factID int64, t time.Time, situationID int64, templateInstanceID int64, item *reader.Item, success bool) error { - if postgres.DB() == nil { - return errors.New("db Client is not initialized") - } - if item == nil { - return errors.New("cannot persist nil item") - } - - itemJSON, err := json.Marshal(*item) - if err != nil { - zap.L().Error("PersistFactResult.Marshal:", zap.Error(err)) - return err - } - - query := `INSERT INTO fact_history_v1(id, ts, situation_id, situation_instance_id, result, success) VALUES (:id, :ts, :situation_id, :situation_instance_id, :result, :success)` - - params := map[string]interface{}{ - "id": factID, - "ts": t, - "situation_id": situationID, - "situation_instance_id": templateInstanceID, - "result": string(itemJSON), - "success": success, - } - res, err := postgres.DB().NamedExec(query, params) - if err != nil { - return err - } - i, err := res.RowsAffected() - if err != nil { - return err - } - if i != 1 { - return errors.New("no row inserted (or multiple row inserted) instead of 1 row") - } - return nil -} - -// UpdateFactResult updates a fact result (related to a specific time) in postgresql -func UpdateFactResult(factID int64, t time.Time, situationID int64, templateInstanceID int64, item *reader.Item) error { - if postgres.DB() == nil { - return errors.New("db Client is not initialized") - } - if item == nil { - return errors.New("cannot persist nil item") - } - - itemJSON, err := json.Marshal(*item) - if err != nil { - zap.L().Error("PersistFactResult.Marshal:", zap.Error(err)) - return err - } - - query := `UPDATE fact_history_v1 set result = :result WHERE id = :id AND ts = :ts AND situation_id = :situation_id AND situation_instance_id = :situation_instance_id` - params := map[string]interface{}{ - "id": factID, - "ts": t, - "situation_id": situationID, - "situation_instance_id": templateInstanceID, - "result": string(itemJSON), - } - res, err := postgres.DB().NamedExec(query, params) - if err != nil { - return err - } - i, err := res.RowsAffected() - if err != nil { - return err - } - if i != 1 { - return errors.New("no row inserted (or multiple row inserted) instead of 1 row") - } - return nil -} - -// GetFactResultFromHistory returns the fact result matching the input timestamp. -// It can be based on an exact timestamp or approximated to the closest calculated result -func GetFactResultFromHistory(factID int64, t time.Time, situationID int64, templateInstanceID int64, closest bool, notOlderThan time.Duration) (*reader.Item, time.Time, error) { - if postgres.DB() == nil { - return nil, time.Time{}, errors.New("db Client is not initialized") - } - - params := map[string]interface{}{ - "fact_id": factID, - "ts": t, - "situation_id": situationID, - "situation_instance_id": templateInstanceID, - } - - var query string - if !closest { - query = "SELECT ts, result FROM fact_history_v1 WHERE success = true AND id = :fact_id AND ts = :ts AND (situation_id = 0 OR situation_id = :situation_id) AND (situation_instance_id = 0 OR situation_instance_id = :situation_instance_id)" - } else { - query = "SELECT ts, result FROM fact_history_v1 WHERE success = true AND id = :fact_id AND ts <= :ts AND (situation_id = 0 OR situation_id = :situation_id) AND (situation_instance_id = 0 OR situation_instance_id = :situation_instance_id)" - if notOlderThan > 0 { - query += " AND ts > :ts_min" - params["ts_min"] = t.Add(-1 * notOlderThan) - } - query += " ORDER BY ts DESC LIMIT 1" - } - - rows, err := postgres.DB().NamedQuery(query, params) - if err != nil { - return nil, time.Time{}, err - } - defer rows.Close() - - if rows.Err() != nil { - return nil, time.Time{}, rows.Err() - } - if rows.Next() { - var result []byte - var ts time.Time - err = rows.Scan(&ts, &result) - if err != nil { - return nil, time.Time{}, err - } - - var item reader.Item - err = json.Unmarshal(result, &item) - if err != nil { - return nil, time.Time{}, err - } - return &item, ts, nil - } - return nil, time.Time{}, nil -} - -//GetFactRangeFromHistory get the facts history within a date range -func GetFactRangeFromHistory(factID int64, situationID int64, templateInstanceID int64, tsFrom time.Time, tsTo time.Time) (map[time.Time]reader.Item, error) { - items := make(map[time.Time]reader.Item, 0) - - if postgres.DB() == nil { - return nil, errors.New("db Client is not initialized") - } - - query := `SELECT ts, result - FROM fact_history_v1 - WHERE success = true AND id = :factid - AND (situation_id = 0 OR situation_id = :situation_id) - AND (situation_instance_id = 0 OR situation_instance_id = :situation_instance_id) - AND ts >= :tsFrom AND ts <= :tsTo ORDER BY ts` - params := map[string]interface{}{ - "factid": factID, - "tsFrom": tsFrom, - "tsTo": tsTo, - "situation_id": situationID, - "situation_instance_id": templateInstanceID, - } - rows, err := postgres.DB().NamedQuery(query, params) - if err != nil { - return nil, err - } - defer rows.Close() - - if rows.Err() != nil { - return nil, rows.Err() - } - - for rows.Next() { - var result []byte - var ts time.Time - - err = rows.Scan(&ts, &result) - if err != nil { - return nil, err - } - - var item reader.Item - - err = json.Unmarshal(result, &item) - if err != nil { - return nil, err - } - - items[ts] = item - } - - return items, nil -} - -//GetFactSituationInstances get the situation instances for fact instances between to and from -func GetFactSituationInstances(factIDs []int64, from time.Time, to time.Time, lastDailyValue bool) ([]HistoryRecord, error) { - mapRecords := make(map[string]HistoryRecord, 0) - - if postgres.DB() == nil { - return nil, errors.New("db Client is not initialized") - } - - var factsFilterQuery string - if lastDailyValue { - factsFilterQuery = `SELECT DISTINCT ON (id, situation_id, situation_instance_id, interval) - id, ts, situation_id, situation_instance_id, FLOOR(DATE_PART('epoch', ts - $2)/86400) AS interval - FROM fact_history_v1 WHERE id = ANY ($1) AND ts >= $2 AND ts <= $3 - ORDER by id, situation_id, situation_instance_id, interval, ts DESC` - } else { - factsFilterQuery = `SELECT id, ts, situation_id, situation_instance_id - FROM fact_history_v1 WHERE id = ANY ($1) AND ts >= $2 AND ts <= $3 - ORDER by id, situation_id, situation_instance_id, ts DESC` - } - - query := `SELECT fd.definition, f.id, f.ts, f.situation_id, f.situation_instance_id, s.id, s.ts, s.situation_instance_id, s.parameters - FROM (` + factsFilterQuery + `) as f - INNER JOIN (SELECT id, ts, situation_instance_id, parameters, facts_ids FROM situation_history_v1 WHERE ts >= $2 AND ts <= $3) as s - ON (f.situation_id = s.id OR f.situation_id = 0) AND (f.situation_instance_id = s.situation_instance_id OR f.situation_instance_id = 0) AND - (s.facts_ids ->> CAST(f.id AS TEXT))::timestamptz = f.ts - INNER JOIN fact_definition_v1 as fd ON fd.id = f.id;` - - rows, err := postgres.DB().Query(query, pq.Array(factIDs), from, to) - if err != nil { - return nil, err - } - defer rows.Close() - - if rows.Err() != nil { - return nil, rows.Err() - } - - for rows.Next() { - var rawFact string - var factID int64 - var factTS time.Time - var factSID int64 - var factSTemplateID int64 - var situationID int64 - var situationTS time.Time - var situationTemplateID int64 - var rawSParams []byte - - err = rows.Scan(&rawFact, &factID, &factTS, &factSID, &factSTemplateID, &situationID, &situationTS, &situationTemplateID, &rawSParams) - if err != nil { - return nil, err - } - - var parameters map[string]string - err = json.Unmarshal(rawSParams, ¶meters) - if err != nil { - return nil, err - } - - key := fmt.Sprintf("%d-%s-%d-%d", factID, factTS, factSID, factSTemplateID) - if record, ok := mapRecords[key]; ok { - record.SituationInstances = append(record.SituationInstances, SituationHistoryRecord{ - ID: situationID, - TS: situationTS, - TemplateInstanceID: situationTemplateID, - Parameters: parameters, - }) - } else { - - var fact engine.Fact - err = json.Unmarshal([]byte(rawFact), &fact) - if err != nil { - return nil, err - } - fact.ID = factID - - mapRecords[key] = HistoryRecord{ - Fact: fact, - ID: factID, - TS: factTS, - SituationID: factSID, - TemplateInstanceID: factSTemplateID, - SituationInstances: []SituationHistoryRecord{ - SituationHistoryRecord{ - ID: situationID, - TS: situationTS, - TemplateInstanceID: situationTemplateID, - Parameters: parameters, - }, - }, - } - } - } - - records := make([]HistoryRecord, 0) - for _, record := range mapRecords { - records = append(records, record) - } - - return records, nil -} diff --git a/internals/fact/history_test.go.old b/internals/fact/history_test.go.old deleted file mode 100644 index 9786d293..00000000 --- a/internals/fact/history_test.go.old +++ /dev/null @@ -1,104 +0,0 @@ -package fact - -import ( - "testing" - "time" - - "github.com/myrteametrics/myrtea-engine-api/v5/internals/reader" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/tests" - "github.com/myrteametrics/myrtea-sdk/v4/engine" - "github.com/myrteametrics/myrtea-sdk/v4/postgres" -) - -func TestPersistFactResult(t *testing.T) { - if testing.Short() { - t.Skip("skipping postgresql test in short mode") - } - db := tests.DBClient(t) - defer dbDestroy(db, t) - dbInit(db, t) - postgres.ReplaceGlobals(db) - r := NewPostgresRepository(db) - - fact := engine.Fact{Name: "test_name", Comment: "test comment"} - id, err := r.Create(fact) - if err != nil { - t.Error(err) - } - - err = PersistFactResult(id, time.Date(2019, time.November, 2, 12, 00, 0, 0, time.UTC), 0, 0, &reader.Item{}, true) - if err != nil { - t.Error(err) - } -} - -func TestGetFactResultFromHistory(t *testing.T) { - if testing.Short() { - t.Skip("skipping postgresql test in short mode") - } - db := tests.DBClient(t) - defer dbDestroy(db, t) - dbInit(db, t) - postgres.ReplaceGlobals(db) - r := NewPostgresRepository(db) - - fact := engine.Fact{Name: "test_name", Comment: "test comment"} - id, err := r.Create(fact) - if err != nil { - t.Error(err) - } - - PersistFactResult(id, time.Date(2019, time.November, 2, 12, 00, 0, 0, time.UTC), 0, 0, &reader.Item{}, true) - PersistFactResult(id, time.Date(2019, time.November, 2, 12, 30, 0, 0, time.UTC), 0, 0, &reader.Item{}, true) - PersistFactResult(id, time.Date(2019, time.November, 2, 13, 00, 0, 0, time.UTC), 0, 0, &reader.Item{}, true) - PersistFactResult(id, time.Date(2019, time.November, 2, 13, 30, 0, 0, time.UTC), 0, 0, &reader.Item{}, true) - - item, ts, err := GetFactResultFromHistory(id, time.Date(2019, time.November, 2, 13, 00, 0, 0, time.UTC), -1, 0, false, 0) - if err != nil { - t.Error(err) - } - if item == nil { - t.Error("item not found") - } - if ts.UTC() != time.Date(2019, time.November, 2, 13, 00, 0, 0, time.UTC) { - t.Error("invalid date time found", ts) - } - - item, ts, err = GetFactResultFromHistory(id, time.Date(2019, time.November, 2, 13, 20, 0, 0, time.UTC), -1, 0, false, 0) - if err != nil { - t.Error(err) - } - if item != nil { - t.Error("item found while it should not") - } - - item, ts, err = GetFactResultFromHistory(id, time.Date(2019, time.November, 2, 20, 00, 0, 0, time.UTC), -1, 0, true, 0) - if err != nil { - t.Error(err) - } - if item == nil { - t.Error("item not found") - } - if ts.UTC() != time.Date(2019, time.November, 2, 13, 30, 0, 0, time.UTC) { - t.Error("invalid date time found", ts) - } - - item, ts, err = GetFactResultFromHistory(id, time.Date(2019, time.November, 2, 13, 20, 0, 0, time.UTC), -1, 0, true, 30*time.Minute) - if err != nil { - t.Error(err) - } - if item == nil { - t.Error("item not found") - } - if ts.UTC() != time.Date(2019, time.November, 2, 13, 00, 0, 0, time.UTC) { - t.Error("invalid date time found", ts) - } - - item, ts, err = GetFactResultFromHistory(id, time.Date(2019, time.November, 2, 13, 20, 0, 0, time.UTC), -1, 0, true, 10*time.Minute) - if err != nil { - t.Error(err) - } - if item != nil { - t.Error("item found while it should not") - } -} diff --git a/internals/fact/nativemap_repository.go b/internals/fact/nativemap_repository.go index f9a00da1..7f04cb56 100644 --- a/internals/fact/nativemap_repository.go +++ b/internals/fact/nativemap_repository.go @@ -5,7 +5,7 @@ import ( "strconv" "sync" - "github.com/myrteametrics/myrtea-sdk/v4/engine" + "github.com/myrteametrics/myrtea-sdk/v5/engine" ) // NativeMapRepository is an implementation of entity.Repository, supported by standard native in-memory map diff --git a/internals/fact/nativemap_repository_test.go b/internals/fact/nativemap_repository_test.go index 55864518..7ec4e1cd 100644 --- a/internals/fact/nativemap_repository_test.go +++ b/internals/fact/nativemap_repository_test.go @@ -3,7 +3,7 @@ package fact import ( "testing" - "github.com/myrteametrics/myrtea-sdk/v4/engine" + "github.com/myrteametrics/myrtea-sdk/v5/engine" ) func TestNew(t *testing.T) { diff --git a/internals/fact/postgres_repository.go b/internals/fact/postgres_repository.go index 8d5930b5..c489729c 100644 --- a/internals/fact/postgres_repository.go +++ b/internals/fact/postgres_repository.go @@ -8,7 +8,7 @@ import ( "github.com/jmoiron/sqlx" "github.com/lib/pq" - "github.com/myrteametrics/myrtea-sdk/v4/engine" + "github.com/myrteametrics/myrtea-sdk/v5/engine" ) // PostgresRepository is a repository containing the Fact definition based on a PSQL database and @@ -26,7 +26,7 @@ func NewPostgresRepository(dbClient *sqlx.DB) Repository { return ifm } -//Get search and returns an entity from the repository by its id +// Get search and returns an entity from the repository by its id func (r *PostgresRepository) Get(id int64) (engine.Fact, bool, error) { query := `SELECT definition FROM fact_definition_v1 WHERE id = :id` rows, err := r.conn.NamedQuery(query, map[string]interface{}{ @@ -59,7 +59,7 @@ func (r *PostgresRepository) Get(id int64) (engine.Fact, bool, error) { return fact, true, nil } -//GetByName search and returns an entity from the repository by its name +// GetByName search and returns an entity from the repository by its name func (r *PostgresRepository) GetByName(name string) (engine.Fact, bool, error) { query := `SELECT id, definition FROM fact_definition_v1 WHERE name = :name` rows, err := r.conn.NamedQuery(query, map[string]interface{}{ diff --git a/internals/fact/postgres_repository_test.go b/internals/fact/postgres_repository_test.go index 735fdd01..24a09e5c 100644 --- a/internals/fact/postgres_repository_test.go +++ b/internals/fact/postgres_repository_test.go @@ -5,7 +5,7 @@ import ( "github.com/jmoiron/sqlx" "github.com/myrteametrics/myrtea-engine-api/v5/internals/tests" - "github.com/myrteametrics/myrtea-sdk/v4/engine" + "github.com/myrteametrics/myrtea-sdk/v5/engine" ) func dbInit(dbClient *sqlx.DB, t *testing.T) { diff --git a/internals/fact/repository.go b/internals/fact/repository.go index ff8d10eb..5784fb06 100644 --- a/internals/fact/repository.go +++ b/internals/fact/repository.go @@ -3,7 +3,7 @@ package fact import ( "sync" - "github.com/myrteametrics/myrtea-sdk/v4/engine" + "github.com/myrteametrics/myrtea-sdk/v5/engine" ) // Repository is a storage interface which can be implemented by multiple backend diff --git a/internals/fact/servicev8.go b/internals/fact/service.go similarity index 85% rename from internals/fact/servicev8.go rename to internals/fact/service.go index 7a4c6582..d868a317 100644 --- a/internals/fact/servicev8.go +++ b/internals/fact/service.go @@ -3,19 +3,19 @@ package fact import ( "context" "errors" + "github.com/myrteametrics/myrtea-sdk/v5/elasticsearch" "strings" "time" "github.com/myrteametrics/myrtea-engine-api/v5/internals/coordinator" "github.com/myrteametrics/myrtea-engine-api/v5/internals/reader" - "github.com/myrteametrics/myrtea-sdk/v4/elasticsearchv8" - "github.com/myrteametrics/myrtea-sdk/v4/engine" - "github.com/myrteametrics/myrtea-sdk/v4/index" + "github.com/myrteametrics/myrtea-sdk/v5/engine" + "github.com/myrteametrics/myrtea-sdk/v5/index" "github.com/spf13/viper" "go.uber.org/zap" ) -func ExecuteFactV8( +func ExecuteFact( ti time.Time, f engine.Fact, situationID int64, situationInstanceID int64, parameters map[string]string, nhit int, offset int, update bool, @@ -27,7 +27,7 @@ func ExecuteFactV8( return nil, err } - searchRequest, err := elasticsearchv8.ConvertFactToSearchRequestV8(f, ti, parameters) + searchRequest, err := elasticsearch.ConvertFactToSearchRequestV8(f, ti, parameters) if err != nil { zap.L().Error("ConvertFactToSearchRequestV8 failed", zap.Error(err)) return nil, err @@ -37,7 +37,7 @@ func ExecuteFactV8( indices := FindIndices(f, ti, update) zap.L().Debug("search", zap.Strings("indices", indices), zap.Any("request", searchRequest)) - response, err := elasticsearchv8.C().Search(). + response, err := elasticsearch.C().Search(). Index(strings.Join(indices, ",")). From(offset). Size(nhit). @@ -52,7 +52,7 @@ func ExecuteFactV8( return nil, errors.New("search failed") } - widgetData, err := reader.ParseV8(response) + widgetData, err := reader.Parse(response) if err != nil { return nil, err } diff --git a/internals/fact/servicev6.go b/internals/fact/servicev6.go deleted file mode 100644 index 38817808..00000000 --- a/internals/fact/servicev6.go +++ /dev/null @@ -1,153 +0,0 @@ -package fact - -import ( - "context" - "fmt" - "time" - - "encoding/json" - - "github.com/myrteametrics/myrtea-engine-api/v5/internals/coordinator" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/reader" - "github.com/myrteametrics/myrtea-sdk/v4/builder" - "github.com/myrteametrics/myrtea-sdk/v4/elasticsearchv6" - "github.com/myrteametrics/myrtea-sdk/v4/engine" - "github.com/myrteametrics/myrtea-sdk/v4/index" - "github.com/spf13/viper" - "go.uber.org/zap" -) - -func ExecuteFact( - ti time.Time, - f engine.Fact, situationID int64, situationInstanceID int64, parameters map[string]string, - nhit int, offset int, update bool, -) (*reader.WidgetData, error) { - - version := viper.GetInt("ELASTICSEARCH_VERSION") - switch version { - case 6: - return ExecuteFactV6(ti, f, situationID, situationInstanceID, parameters, nhit, offset, update) - case 7: - fallthrough - case 8: - return ExecuteFactV8(ti, f, situationID, situationInstanceID, parameters, nhit, offset, update) - default: - zap.L().Fatal("Unsupported Elasticsearch version", zap.Int("version", version)) - return nil, fmt.Errorf("Unsupported Elasticsearch version") - } -} - -func ExecuteFactV6( - ti time.Time, - f engine.Fact, situationID int64, situationInstanceID int64, parameters map[string]string, - nhit int, offset int, update bool, -) (*reader.WidgetData, error) { - pf, err := PrepareV6(&f, nhit, offset, ti, parameters, update) - if err != nil { - zap.L().Error("Cannot prepare fact", zap.Int64("id", f.ID), zap.Any("fact", f), zap.Error(err)) - return nil, err - } - - widgetData, err := ExecuteV6(pf) - if err != nil { - zap.L().Error("Cannot execute fact", zap.Int64("id", f.ID), zap.Any("pf", pf), zap.Error(err)) - return nil, err - } - - GetBaselineValues(widgetData, f.ID, situationID, situationInstanceID, ti) - - return widgetData, nil -} - -// PrepareV6 enrich a fact by specifying the offset and the number of hits returned -// It also specify the target index based on the fact model -func PrepareV6(f *engine.Fact, nhit int, offset int, t time.Time, parameters map[string]string, update bool) (*builder.EsSearch, error) { - if f.AdvancedSource != "" { - var data map[string]interface{} - var err error - err = json.Unmarshal([]byte(f.AdvancedSource), &data) - if err != nil { - return nil, err - } - - data["size"] = 0 - if nhit != -1 { - data["size"] = nhit - } - - data["from"] = 0 - if offset != -1 { - data["from"] = offset - } - - b, err := json.Marshal(data) - if err != nil { - return nil, err - } - - strSource := string(b) - strSource = builder.ContextualizeDatePlaceholders(strSource, t) - strSource = builder.ContextualizeTimeZonePlaceholders(strSource, t) - strSource = builder.ContextualizePlaceholders(strSource, parameters) - - f.AdvancedSource = strSource - } else { - f.ContextualizeDimensions(t, parameters) - err := f.ContextualizeCondition(t, parameters) - if err != nil { - return nil, err - } - } - - esSearch, err := f.ToElasticQuery(t, parameters) - if err != nil { - return nil, err - } - - var indices []string - if update { - indices, err = coordinator.GetInstance().LogicalIndex(f.Model).FindIndices(time.Now(), f.CalculationDepth+int64(time.Now().Sub(t).Hours()/24)+5) - } else { - indices, err = coordinator.GetInstance().LogicalIndex(f.Model).FindIndices(t, f.CalculationDepth) - } - if err != nil { - return nil, err - } - if len(indices) == 0 { - zap.L().Info("No indices found, fallback on search-all", zap.String("fact", f.Name), zap.String("model", f.Model), zap.Int64("depth", f.CalculationDepth)) - indices = []string{index.BuildAliasName(viper.GetString("INSTANCE_NAME"), f.Model, index.All)} - } - esSearch.Indices = indices - - esSearch.Size = 0 - if nhit != -1 { - esSearch.Size = nhit - } - - esSearch.Offset = 0 - if offset != -1 { - esSearch.Offset = offset - } - - return esSearch, nil -} - -// ExecuteV6 calculate a fact a specific time and returns the result in a standard format -func ExecuteV6(esSearch *builder.EsSearch) (*reader.WidgetData, error) { - search, err := builder.BuildEsSearch(elasticsearchv6.C(), esSearch) - if err != nil { - return nil, err - } - - res, err := elasticsearchv6.C().ExecuteSearch(context.Background(), search) - if err != nil { - return nil, err - } - - widgetData, err := reader.Parse(res) - if err != nil { - return nil, err - } - - return widgetData, nil -} diff --git a/internals/handlers/facts_handlers.go b/internals/handlers/facts_handlers.go index 8e5f027a..ba9e3172 100644 --- a/internals/handlers/facts_handlers.go +++ b/internals/handlers/facts_handlers.go @@ -4,6 +4,7 @@ import ( "encoding/json" "errors" "fmt" + "github.com/myrteametrics/myrtea-sdk/v5/elasticsearch" "net/http" "sort" "strconv" @@ -16,8 +17,7 @@ import ( "github.com/myrteametrics/myrtea-engine-api/v5/internals/security/permissions" "github.com/myrteametrics/myrtea-engine-api/v5/internals/situation" "github.com/myrteametrics/myrtea-engine-api/v5/plugins/baseline" - "github.com/myrteametrics/myrtea-sdk/v4/builder" - "github.com/myrteametrics/myrtea-sdk/v4/engine" + "github.com/myrteametrics/myrtea-sdk/v5/engine" "go.uber.org/zap" ) @@ -752,14 +752,24 @@ func FactToESQuery(w http.ResponseWriter, r *http.Request) { zap.L().Debug("Debugging fact", zap.Any("f", f)) } - pf, err := fact.PrepareV6(&f, nhit, offset, t, parameters, false) + // Add context to fact, replace params and evaluate queries + f.ContextualizeDimensions(t, parameters) + err = f.ContextualizeCondition(t, parameters) if err != nil { - zap.L().Error("Cannot execute fact", zap.Error(err), zap.Any("fact", f)) + render.Error(w, r, apiError, err) + return + } + + source, err := elasticsearch.ConvertFactToSearchRequestV8(f, t, parameters) + if err != nil { + zap.L().Error("Cannot convert fact to search request", zap.Error(err), zap.Any("fact", f)) render.Error(w, r, render.ErrAPIResourceInvalid, err) return } - source, _ := builder.BuildEsSearchSource(pf) + source.Size = &nhit + source.From = &offset + zap.L().Info("Debugging final elastic query", zap.Any("query", source)) render.JSON(w, r, source) diff --git a/internals/handlers/facts_handlers_test.go b/internals/handlers/facts_handlers_test.go index 66b476da..c0dfb7c7 100644 --- a/internals/handlers/facts_handlers_test.go +++ b/internals/handlers/facts_handlers_test.go @@ -9,7 +9,7 @@ import ( "github.com/myrteametrics/myrtea-engine-api/v5/internals/fact" "github.com/myrteametrics/myrtea-engine-api/v5/internals/tests" - "github.com/myrteametrics/myrtea-sdk/v4/engine" + "github.com/myrteametrics/myrtea-sdk/v5/engine" ) func initGlobalRepository() { diff --git a/internals/handlers/issues_handlers.go b/internals/handlers/issues_handlers.go index 9607a802..55cd19c1 100644 --- a/internals/handlers/issues_handlers.go +++ b/internals/handlers/issues_handlers.go @@ -13,7 +13,7 @@ import ( "github.com/myrteametrics/myrtea-engine-api/v5/internals/handlers/render" "github.com/myrteametrics/myrtea-engine-api/v5/internals/models" "github.com/myrteametrics/myrtea-engine-api/v5/internals/security/permissions" - "github.com/myrteametrics/myrtea-sdk/v4/postgres" + "github.com/myrteametrics/myrtea-sdk/v5/postgres" "go.uber.org/zap" ) diff --git a/internals/handlers/issues_handlers_test.go.old b/internals/handlers/issues_handlers_test.go.old deleted file mode 100644 index 378fe05e..00000000 --- a/internals/handlers/issues_handlers_test.go.old +++ /dev/null @@ -1,604 +0,0 @@ -package handlers - -import ( - "bytes" - "context" - "encoding/json" - "fmt" - "net/http" - "net/http/httptest" - "strconv" - "testing" - "time" - - "github.com/go-chi/chi/v5" - "github.com/jmoiron/sqlx" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/explainer" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/explainer/action" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/explainer/draft" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/explainer/issues" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/explainer/rootcause" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/models" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/rule" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/security/permissions" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/security/users" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/situation" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/tests" - "github.com/myrteametrics/myrtea-sdk/v4/postgres" - "github.com/myrteametrics/myrtea-sdk/v4/ruleeng" -) - -func dbIssueInitRepo(dbClient *sqlx.DB, t *testing.T) { - dbIssueDestroyRepo(dbClient, t) - tests.DBExec(dbClient, `CREATE EXTENSION IF NOT EXISTS pgcrypto;`, t, true) - tests.DBExec(dbClient, tests.UsersTableV1, t, true) - tests.DBExec(dbClient, tests.CalendarTableV3, t, true) - tests.DBExec(dbClient, tests.SituationDefinitionTableV1, t, true) - tests.DBExec(dbClient, tests.FactDefinitionTableV1, t, true) - tests.DBExec(dbClient, tests.SituationFactsTableV1, t, true) - tests.DBExec(dbClient, tests.IssuesTableV1, t, true) - tests.DBExec(dbClient, tests.SituationHistoryTableV1, t, true) - tests.DBExec(dbClient, tests.RulesTableV1, t, true) - tests.DBExec(dbClient, tests.RuleVersionsTableV1, t, true) - tests.DBExec(dbClient, tests.SituationRulesTableV1, t, true) - tests.DBExec(dbClient, tests.RefRootCauseTableV1, t, true) - tests.DBExec(dbClient, tests.RefActionTableV1, t, true) - tests.DBExec(dbClient, tests.IssueResolutionDraftTableV1, t, true) - tests.DBExec(dbClient, tests.IssueResolutionTableV1, t, true) -} - -func dbIssueDestroyRepo(dbClient *sqlx.DB, t *testing.T) { - tests.DBExec(dbClient, tests.IssueResolutionDraftDropTableV1, t, true) - tests.DBExec(dbClient, tests.IssueResolutionDropTableV1, t, true) - tests.DBExec(dbClient, tests.RefActionDropTableV1, t, true) - tests.DBExec(dbClient, tests.RefRootCauseDropTableV1, t, true) - tests.DBExec(dbClient, tests.SituationRulesDropTableV1, t, true) - tests.DBExec(dbClient, tests.RuleVersionsDropTableV1, t, true) - tests.DBExec(dbClient, tests.RulesDropTableV1, t, true) - tests.DBExec(dbClient, tests.IssuesDropTableV1, t, true) - tests.DBExec(dbClient, tests.SituationFactsDropTableV1, t, true) - tests.DBExec(dbClient, tests.SituationDefinitionDropTableV1, t, true) - tests.DBExec(dbClient, tests.CalendarDropTableV3, t, true) - tests.DBExec(dbClient, tests.FactDefinitionDropTableV1, t, true) - tests.DBExec(dbClient, tests.UsersDropTableV1, t, true) - tests.DBExec(dbClient, tests.SituationHistoryDropTableV1, t, false) -} - -func TestGetIssues(t *testing.T) { - if testing.Short() { - t.Skip("skipping integration test in short mode") - } - - db := tests.DBClient(t) - defer dbIssueDestroyRepo(db, t) - dbIssueInitRepo(db, t) - - issues.ReplaceGlobals(issues.NewPostgresRepository(db)) - situation.ReplaceGlobals(situation.NewPostgresRepository(db)) - - //Situation - situation1 := situation.Situation{ - Name: "test_name", - } - - situationID, err := situation.R().Create(situation1) - if err != nil { - t.Error(err) - } - - timestamp := time.Now().Truncate(1 * time.Millisecond).UTC() - - cas := models.CaseInput{ - Name: "case1", - Condition: "3 > 2", - State: models.Met, - } - - //Rule - rule := models.RuleData{ - RuleID: 1, - RuleVersion: 0, - CaseName: cas.Name, - } - - issue := models.Issue{ - Key: "key1", - Level: models.Critical, - SituationID: situationID, - ExpirationTS: timestamp.Add(24 * time.Hour).UTC(), - SituationTS: timestamp, - Rule: rule, - State: models.Open, - } - - id, err := issues.R().Create(issue) - if err != nil { - t.Error(err) - } - - // groupsOfUser := make([]groups.GroupOfUser, 0) - // groupsOfUser = append(groupsOfUser, groups.GroupOfUser{ - // ID: 1, - // Name: "user", - // UserRole: 1, - // }) - - // user := groups.UserWithGroups{ - // User: security.User{}, - // Groups: groupsOfUser, - // } - - req, err := http.NewRequest("GET", "/issues", nil) - if err != nil { - t.Fatal(err) - } - - user := users.UserWithPermissions{Permissions: []permissions.Permission{permissions.New(permissions.TypeSituationIssues, "*", permissions.ActionList), permissions.New(permissions.TypeSituationIssues, "*", permissions.ActionGet)}} - ctx := context.WithValue(req.Context(), models.ContextKeyUser, user) - - rr := httptest.NewRecorder() - r := chi.NewRouter() - - r.Get("/issues", GetIssues) - r.ServeHTTP(rr, req.WithContext(ctx)) - - if status := rr.Code; status != http.StatusOK { - t.Errorf("handler returned wrong status code: got %v want %v", status, http.StatusOK) - } - - var issues map[int64]*models.Issue - err = json.Unmarshal(rr.Body.Bytes(), &issues) - if err != nil { - t.Errorf("handler returned unexpected body") - } - - if issues[id] != nil && issues[id].ID != id { - t.Errorf("handler returned unexpected body: got %v want %v", issues[id].ID, id) - } -} - -func TestGetIssuesStates(t *testing.T) { - if testing.Short() { - t.Skip("skipping integration test in short mode") - } - - db := tests.DBClient(t) - defer dbIssueDestroyRepo(db, t) - dbIssueInitRepo(db, t) - - issues.ReplaceGlobals(issues.NewPostgresRepository(db)) - situation.ReplaceGlobals(situation.NewPostgresRepository(db)) - - //Situation - situation1 := situation.Situation{ - Name: "test_name", - } - - situationID, err := situation.R().Create(situation1) - if err != nil { - t.Error(err) - } - - timestamp := time.Now().Truncate(1 * time.Millisecond).UTC() - - cas := models.CaseInput{ - Name: "case1", - Condition: "3 > 2", - State: models.Met, - } - - //Rule - rule := models.RuleData{ - RuleID: 1, - RuleVersion: 0, - CaseName: cas.Name, - } - - issue := models.Issue{ - SituationID: situationID, - Key: "key1", - Level: models.Critical, - SituationTS: timestamp, - Rule: rule, - State: models.ClosedFeedback, - } - - issue2 := models.Issue{ - SituationID: situationID, - Key: "key2", - Level: models.Critical, - SituationTS: timestamp, - Rule: rule, - State: models.Open, - } - - issue3 := models.Issue{ - SituationID: situationID, - Key: "key3", - Level: models.Critical, - SituationTS: timestamp, - Rule: rule, - State: models.ClosedNoFeedback, - } - - _, err = issues.R().Create(issue) - if err != nil { - t.Error(err) - } - - _, err = issues.R().Create(issue2) - if err != nil { - t.Error(err) - } - - _, err = issues.R().Create(issue3) - if err != nil { - t.Error(err) - } - - // groupsOfUser := make([]groups.GroupOfUser, 0) - // groupsOfUser = append(groupsOfUser, groups.GroupOfUser{ - // ID: 1, - // Name: "user", - // UserRole: 1, - // }) - - // user := groups.UserWithGroups{ - // User: security.User{}, - // Groups: groupsOfUser, - // } - - req, err := http.NewRequest("GET", "/issues?states=open,closedfeedback", nil) - if err != nil { - t.Fatal(err) - } - - user := users.UserWithPermissions{Permissions: []permissions.Permission{permissions.New(permissions.TypeSituationIssues, permissions.All, permissions.ActionList), permissions.New(permissions.TypeSituationIssues, permissions.All, permissions.ActionGet)}} - ctx := context.WithValue(req.Context(), models.ContextKeyUser, user) - - rr := httptest.NewRecorder() - r := chi.NewRouter() - - r.Get("/issues", GetIssuesByStatesByPage) - r.ServeHTTP(rr, req.WithContext(ctx)) - - if status := rr.Code; status != http.StatusOK { - t.Errorf("handler returned wrong status code: got %v want %v", status, http.StatusOK) - } - - var issues models.PaginatedResource - err = json.Unmarshal(rr.Body.Bytes(), &issues) - if err != nil { - t.Errorf("handler returned unexpected body") - t.Log(rr.Body.String()) - } - - if items := issues.Items.([]interface{}); len(items) != 2 { - t.Errorf("handler returned unexpected body: more or less issues than expected") - } -} - -func TestGetIssue(t *testing.T) { - if testing.Short() { - t.Skip("skipping integration test in short mode") - } - - db := tests.DBClient(t) - defer dbIssueDestroyRepo(db, t) - dbIssueInitRepo(db, t) - - issues.ReplaceGlobals(issues.NewPostgresRepository(db)) - situation.ReplaceGlobals(situation.NewPostgresRepository(db)) - - //Situation - situation1 := situation.Situation{Name: "test_name"} - - situationID, err := situation.R().Create(situation1) - if err != nil { - t.Error(err) - } - - timestamp := time.Now().Truncate(1 * time.Millisecond).UTC() - - cas := models.CaseInput{ - Name: "", - Condition: "", - State: models.Met, - } - - //Rule - rule := models.RuleData{ - RuleID: 1, - RuleVersion: 0, - CaseName: cas.Name, - } - - issue := models.Issue{ - Key: "key1", - SituationID: situationID, - SituationTS: timestamp, - Level: models.Critical, - Rule: rule, - State: models.Open, - } - - id, err := issues.R().Create(issue) - if err != nil { - t.Error(err) - } - - // groupsOfUser := make([]groups.GroupOfUser, 0) - // groupsOfUser = append(groupsOfUser, groups.GroupOfUser{ - // ID: 1, - // Name: "user", - // UserRole: 1, - // }) - - // user := groups.UserWithGroups{ - // User: security.User{}, - // Groups: groupsOfUser, - // } - - req, err := http.NewRequest("GET", "/issues/"+strconv.FormatInt(id, 10), nil) - if err != nil { - t.Fatal(err) - } - - user := users.UserWithPermissions{Permissions: []permissions.Permission{permissions.New(permissions.TypeSituationIssues, "1", permissions.ActionGet)}} - ctx := context.WithValue(req.Context(), models.ContextKeyUser, user) - - rr := httptest.NewRecorder() - r := chi.NewRouter() - r.Get("/issues/{id}", GetIssue) - r.ServeHTTP(rr, req.WithContext(ctx)) - - if status := rr.Code; status != http.StatusOK { - t.Errorf("handler returned wrong status code: got %v want %v", status, http.StatusOK) - } - - var issueGet *models.Issue - err = json.Unmarshal(rr.Body.Bytes(), &issueGet) - if err != nil { - t.Errorf("handler returned unexpected body") - } - - if id != issueGet.ID { - t.Errorf("handler returned unexpected body: more or less issues than expected") - } -} - -func TestPostIssue(t *testing.T) { - if testing.Short() { - t.Skip("skipping integration test in short mode") - } - - db := tests.DBClient(t) - defer dbIssueDestroyRepo(db, t) - dbIssueInitRepo(db, t) - - issues.ReplaceGlobals(issues.NewPostgresRepository(db)) - situation.ReplaceGlobals(situation.NewPostgresRepository(db)) - - //Situation - situation1 := situation.Situation{ - Name: "test_name", - } - situationID, err := situation.R().Create(situation1) - if err != nil { - t.Error(err) - } - - timestamp := time.Now().Truncate(1 * time.Millisecond).UTC() - - cas := models.CaseInput{ - Name: "case1", - Condition: "3 > 2", - State: models.Met, - } - - //Rule - rule := models.RuleData{ - RuleID: 1, - RuleVersion: 0, - CaseName: cas.Name, - } - - issue := models.Issue{ - SituationID: situationID, - SituationTS: timestamp, - Rule: rule, - State: models.Open, - } - - issueData, _ := json.Marshal(issue) - - req, err := http.NewRequest("POST", "/issues", bytes.NewBuffer([]byte(issueData))) - if err != nil { - t.Fatal(err) - } - - user := users.UserWithPermissions{Permissions: []permissions.Permission{permissions.New(permissions.TypeSituationIssues, permissions.All, permissions.ActionCreate)}} - ctx := context.WithValue(req.Context(), models.ContextKeyUser, user) - - rr := httptest.NewRecorder() - r := chi.NewRouter() - r.Post("/issues", PostIssue) - r.ServeHTTP(rr, req.WithContext(ctx)) - - if status := rr.Code; status != http.StatusOK { - t.Errorf("handler returned wrong status code: got %v want %v", status, http.StatusOK) - } - if rr.Body.String() != "" { - t.Errorf("handler returned unexpected body: got %v want %v", rr.Body.String(), "") - } - - id := int64(1) - - issues, err := issues.R().GetAll() - if err != nil { - t.Error(err) - t.FailNow() - } - if _, exists := issues[id]; !exists { - t.Error("Issue 1 should not be nil") - } -} - -func TestIssueLifecycle(t *testing.T) { - if testing.Short() { - t.Skip("skipping integration test in short mode") - } - - db := tests.DBClient(t) - defer dbIssueDestroyRepo(db, t) - dbIssueInitRepo(db, t) - - postgres.ReplaceGlobals(db) - issues.ReplaceGlobals(issues.NewPostgresRepository(db)) - situation.ReplaceGlobals(situation.NewPostgresRepository(db)) - rule.ReplaceGlobals(rule.NewPostgresRepository(db)) - draft.ReplaceGlobals(draft.NewPostgresRepository(db)) - rootcause.ReplaceGlobals(rootcause.NewPostgresRepository(db)) - action.ReplaceGlobals(action.NewPostgresRepository(db)) - - //Situation - situation1 := situation.Situation{Name: "test_name"} - - situationID, err := situation.R().Create(situation1) - if err != nil { - t.Error(err) - } - - timestamp := time.Now().Truncate(1 * time.Millisecond).UTC() - - rule1 := rule.Rule{ - Name: "rule_1", - DefaultRule: ruleeng.DefaultRule{Cases: []ruleeng.Case{ - { - Name: "case_1", - Condition: ruleeng.Expression("true"), - Actions: []ruleeng.ActionDef{{ - Name: ruleeng.Expression(`"create-set"`), - Parameters: map[string]ruleeng.Expression{ - "key": ruleeng.Expression(`"1"`), - }, - }}, - }, - }}, - Enabled: true, - } - - ruleID, _ := rule.R().Create(rule1) - err = situation.R().SetRules(situationID, []int64{int64(ruleID)}) - if err != nil { - t.Error(err) - t.FailNow() - } - - cas := models.CaseInput{ - Name: "", - Condition: "", - State: models.Met, - } - - //Rule - ruleInput := models.RuleData{ - RuleID: int64(ruleID), - RuleVersion: 0, - CaseName: cas.Name, - } - - issue1 := models.Issue{ - Key: "key1", - SituationID: situationID, - SituationTS: timestamp, - Level: models.Critical, - Rule: ruleInput, - State: models.Open, - } - - issue2 := models.Issue{ - Key: "key2", - SituationID: situationID, - SituationTS: timestamp, - Level: models.Critical, - Rule: ruleInput, - State: models.Open, - } - - issue1ID, err := issues.R().Create(issue1) - if err != nil { - t.Error(err) - } - - issue2ID, err := issues.R().Create(issue2) - if err != nil { - t.Error(err) - } - - // user := groups.UserWithGroups{ - // User: security.User{ - // FirstName: "user_first_name", - // LastName: "user_last_name", - // }, - // Groups: []groups.GroupOfUser{{ - // ID: 1, - // Name: "group1", - // UserRole: 1, - // }}, - // } - - draft := models.FrontDraft{ - Tree: []*models.FrontRootCause{ - { - Name: "rootcause_1", - Description: "this is the root cause 1", - Custom: true, - Actions: []*models.FrontAction{ - { - Name: "action_1", - Description: "this is the action 1", - Custom: true, - }, - }, - }, - }, - } - b, _ := json.Marshal(draft) - - user := users.UserWithPermissions{Permissions: []permissions.Permission{permissions.New(permissions.TypeSituationIssues, permissions.All, permissions.ActionGet)}} - - rr := tests.BuildTestHandler(t, "POST", fmt.Sprintf("/issues/%d/draft", issue1ID), string(b), "/issues/{id}/draft", PostIssueDraft, user) - if rr.Code != http.StatusOK { - t.Error("Unexpected error posting issue resolution draft") - } - - getIssue, _, _ := issues.R().Get(issue1ID) - if *getIssue.AssignedTo != user.Login || getIssue.AssignedAt.IsZero() { - t.Error("Unexpected recomendation tree") - } - recomendation, _ := explainer.GetRecommendationTree(getIssue) - recomendation.Tree[0].Selected = true - recomendation.Tree[0].Actions[0].Selected = true - b, _ = json.Marshal(recomendation) - - rr = tests.BuildTestHandler(t, "POST", fmt.Sprintf("/issues/%d/feedback", issue1ID), string(b), "/issues/{id}/feedback", PostIssueCloseWithFeedback, user) - if rr.Code != http.StatusOK { - t.Error("Unexpected error closing issue with feedback") - } - getIssue, _, _ = issues.R().Get(issue1ID) - if getIssue.CloseBy == nil || *getIssue.CloseBy != user.Login || - getIssue.ClosedAt == nil || getIssue.ClosedAt.IsZero() || getIssue.State != models.ClosedFeedback { - t.Error("Unexpected obtained issue") - } - - rr = tests.BuildTestHandler(t, "POST", fmt.Sprintf("/issues/%d/close", issue2ID), "", "/issues/{id}/close", PostIssueCloseWithoutFeedback, user) - if rr.Code != http.StatusOK { - t.Error("Unexpected error closing issue without feedback") - } - getIssue, _, _ = issues.R().Get(issue2ID) - if getIssue.CloseBy == nil || *getIssue.CloseBy != user.Login || - getIssue.ClosedAt == nil || getIssue.ClosedAt.IsZero() || getIssue.State != models.ClosedNoFeedback { - t.Error("Unexpected obtained issue") - } -} diff --git a/internals/handlers/model_handlers.go b/internals/handlers/model_handlers.go index 283999aa..f423050f 100644 --- a/internals/handlers/model_handlers.go +++ b/internals/handlers/model_handlers.go @@ -11,7 +11,7 @@ import ( "github.com/myrteametrics/myrtea-engine-api/v5/internals/handlers/render" model "github.com/myrteametrics/myrtea-engine-api/v5/internals/modeler" "github.com/myrteametrics/myrtea-engine-api/v5/internals/security/permissions" - "github.com/myrteametrics/myrtea-sdk/v4/modeler" + "github.com/myrteametrics/myrtea-sdk/v5/modeler" "go.uber.org/zap" ) diff --git a/internals/handlers/model_handlers_test.go b/internals/handlers/model_handlers_test.go index f1925724..cba55e80 100644 --- a/internals/handlers/model_handlers_test.go +++ b/internals/handlers/model_handlers_test.go @@ -9,7 +9,7 @@ import ( "github.com/myrteametrics/myrtea-engine-api/v5/internals/security/permissions" "github.com/myrteametrics/myrtea-engine-api/v5/internals/security/users" "github.com/myrteametrics/myrtea-engine-api/v5/internals/tests" - "github.com/myrteametrics/myrtea-sdk/v4/modeler" + "github.com/myrteametrics/myrtea-sdk/v5/modeler" ) func initModelRepository(t *testing.T) []modeler.Model { diff --git a/internals/handlers/processor_handlers.go b/internals/handlers/processor_handlers.go index 72726de9..925106f0 100644 --- a/internals/handlers/processor_handlers.go +++ b/internals/handlers/processor_handlers.go @@ -7,7 +7,7 @@ import ( "github.com/myrteametrics/myrtea-engine-api/v5/internals/ingester" "github.com/myrteametrics/myrtea-engine-api/v5/internals/processor" "github.com/myrteametrics/myrtea-engine-api/v5/internals/scheduler" - "github.com/myrteametrics/myrtea-sdk/v4/models" + "github.com/myrteametrics/myrtea-sdk/v5/models" "go.uber.org/zap" "net/http" ) diff --git a/internals/handlers/rules_handlers_test.go b/internals/handlers/rules_handlers_test.go index 01e5e351..5f0e8e25 100644 --- a/internals/handlers/rules_handlers_test.go +++ b/internals/handlers/rules_handlers_test.go @@ -13,7 +13,7 @@ import ( "github.com/myrteametrics/myrtea-engine-api/v5/internals/security/users" "github.com/myrteametrics/myrtea-engine-api/v5/internals/situation" "github.com/myrteametrics/myrtea-engine-api/v5/internals/tests" - "github.com/myrteametrics/myrtea-sdk/v4/postgres" + "github.com/myrteametrics/myrtea-sdk/v5/postgres" ) func dbInit(dbClient *sqlx.DB, t *testing.T) { diff --git a/internals/handlers/rules_linked_handlers.go b/internals/handlers/rules_linked_handlers.go index 115c5a7c..ce60bdd8 100644 --- a/internals/handlers/rules_linked_handlers.go +++ b/internals/handlers/rules_linked_handlers.go @@ -9,7 +9,7 @@ import ( "github.com/go-chi/chi/v5" "github.com/myrteametrics/myrtea-engine-api/v5/internals/handlers/render" "github.com/myrteametrics/myrtea-engine-api/v5/internals/situation" - "github.com/myrteametrics/myrtea-sdk/v4/postgres" + "github.com/myrteametrics/myrtea-sdk/v5/postgres" "go.uber.org/zap" ) diff --git a/internals/handlers/search_handlers.go.old b/internals/handlers/search_handlers.go.old deleted file mode 100644 index e70f8b93..00000000 --- a/internals/handlers/search_handlers.go.old +++ /dev/null @@ -1,83 +0,0 @@ -package handlers - -import ( - "encoding/json" - "errors" - "net/http" - "strconv" - - "github.com/myrteametrics/myrtea-engine-api/v5/internals/handlers/render" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/search" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/security/permissions" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/situation" - "go.uber.org/zap" -) - -// Search godoc -// @Summary query situation history data -// @Description query situation history data -// @Tags Search -// @Accept json -// @Produce json -// @Param query body search.Query true "query (json)" -// @Security Bearer -// @Success 200 {array} search.QueryResult "query result" -// @Failure 500 "internal server error" -// @Router /engine/search [post] -func Search(w http.ResponseWriter, r *http.Request) { - var query search.Query - err := json.NewDecoder(r.Body).Decode(&query) - if err != nil { - zap.L().Warn("Query json decode", zap.Error(err)) - render.Error(w, r, render.ErrAPIDecodeJSONBody, err) - return - } - - userCtx, _ := GetUserFromContext(r) - // Check Situation - if !userCtx.HasPermission(permissions.New(permissions.TypeSituation, strconv.FormatInt(query.SituationID, 10), permissions.ActionSearch)) { - render.Error(w, r, render.ErrAPISecurityNoPermissions, errors.New("missing permission")) - return - } - - _, found, err := situation.R().Get(query.SituationID) - if err != nil { - render.Error(w, r, render.ErrAPIDBSelectFailed, err) - return - } - if !found { - render.Error(w, r, render.ErrAPIDBResourceNotFound, nil) - return - } - - // Check situation instance - if query.SituationInstanceID != 0 { - if !userCtx.HasPermission(permissions.New(permissions.TypeSituationInstance, strconv.FormatInt(query.SituationInstanceID, 10), permissions.ActionSearch)) { - render.Error(w, r, render.ErrAPISecurityNoPermissions, errors.New("missing permission")) - return - } - } - // } else { - // if userCtx.HasPermission(permissions.New(permissions.TypeSituationInstance, permissions.All, permissions.ActionSearch)) { - // // OK ? - // } else { - // resourceIDs := userCtx.GetMatchingResourceIDsInt64(permissions.New(permissions.TypeSituationInstance, permissions.All, permissions.ActionSearch)) - // _ = resourceIDs - // } - // } - - result, err := query.Execute() - if err != nil { - switch err.(type) { - case search.ErrResourceNotFound: - render.Error(w, r, render.ErrAPIDBResourceNotFound, err) - case search.ErrDatabase: - render.Error(w, r, render.ErrAPIDBSelectFailed, err) - default: - render.Error(w, r, render.ErrAPIDBSelectFailed, err) - } - return - } - - render.JSON(w, r, result) -} diff --git a/internals/handlers/search_handlers_test.go.old b/internals/handlers/search_handlers_test.go.old deleted file mode 100644 index 8d7fd270..00000000 --- a/internals/handlers/search_handlers_test.go.old +++ /dev/null @@ -1,36 +0,0 @@ -package handlers - -import ( - "net/http" - "testing" - - "github.com/myrteametrics/myrtea-engine-api/v5/internals/search" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/security/users" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/situation" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/tests" -) - -func TestSearch(t *testing.T) { - t.Skip("Development test") - db := tests.DBClient(t) - - situationR := situation.NewPostgresRepository(db) - situation.ReplaceGlobals(situationR) - - searchR := search.NewPostgresRepository(db) - search.ReplaceGlobals(searchR) - - q := `{ - "situationId": 2, - "situationInstanceId": 0, - "range": "10s", - "start": "2020-04-29T19:04:45+02:00", - "downSampling": { - "granularity": "2s", - "operation": "avg" - } - }` - - rr := tests.BuildTestHandler(t, "POST", "/search", q, "/search", Search, users.UserWithPermissions{}) - tests.CheckTestHandler(t, rr, http.StatusOK, `{}`) -} diff --git a/internals/handlers/situations_handlers_test.go b/internals/handlers/situations_handlers_test.go index 3acf830b..102486d1 100644 --- a/internals/handlers/situations_handlers_test.go +++ b/internals/handlers/situations_handlers_test.go @@ -12,7 +12,7 @@ import ( "github.com/myrteametrics/myrtea-engine-api/v5/internals/security/users" "github.com/myrteametrics/myrtea-engine-api/v5/internals/situation" "github.com/myrteametrics/myrtea-engine-api/v5/internals/tests" - "github.com/myrteametrics/myrtea-sdk/v4/engine" + "github.com/myrteametrics/myrtea-sdk/v5/engine" ) func situationDbInit(dbClient *sqlx.DB, t *testing.T) { diff --git a/internals/handlers/situations_linked_handlers.go b/internals/handlers/situations_linked_handlers.go index 3ddacbf2..a89442fe 100644 --- a/internals/handlers/situations_linked_handlers.go +++ b/internals/handlers/situations_linked_handlers.go @@ -11,7 +11,7 @@ import ( "github.com/myrteametrics/myrtea-engine-api/v5/internals/handlers/render" "github.com/myrteametrics/myrtea-engine-api/v5/internals/rule" "github.com/myrteametrics/myrtea-engine-api/v5/internals/situation" - "github.com/myrteametrics/myrtea-sdk/v4/engine" + "github.com/myrteametrics/myrtea-sdk/v5/engine" "go.uber.org/zap" ) diff --git a/internals/handlers/users_handlers_test.go.old b/internals/handlers/users_handlers_test.go.old deleted file mode 100644 index f0277411..00000000 --- a/internals/handlers/users_handlers_test.go.old +++ /dev/null @@ -1,270 +0,0 @@ -package handlers - -import ( - "bytes" - "encoding/json" - "net/http" - "net/http/httptest" - "strconv" - "testing" - - "github.com/go-chi/chi/v5" - "github.com/jmoiron/sqlx" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/groups" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/tests" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/users" - "github.com/myrteametrics/myrtea-sdk/v4/security" -) - -func usersDBInit(dbClient *sqlx.DB, t *testing.T) { - usersDBDestroy(dbClient, t) - tests.DBExec(dbClient, `CREATE EXTENSION IF NOT EXISTS pgcrypto;`, t, true) - tests.DBExec(dbClient, tests.UsersTableV1, t, true) - tests.DBExec(dbClient, tests.GroupsTableV1, t, true) - tests.DBExec(dbClient, tests.UserMembershipsTableV1, t, true) -} - -func usersDBDestroy(dbClient *sqlx.DB, t *testing.T) { - tests.DBExec(dbClient, tests.UserMembershipsDropTableV1, t, false) - tests.DBExec(dbClient, tests.GroupsDropTableV1, t, false) - tests.DBExec(dbClient, tests.UsersDropTableV1, t, false) -} - -func TestGetUsers(t *testing.T) { - if testing.Short() { - t.Skip("skipping postgresql test in short mode") - } - db := tests.DBClient(t) - defer usersDBDestroy(db, t) - usersDBInit(db, t) - - usersR := users.NewPostgresRepository(db) - users.ReplaceGlobals(usersR) - - user1 := security.UserWithPassword{ - User: security.User{ - Login: "admin", - Role: 1, - }, - Password: "pass1", - } - user2 := security.UserWithPassword{ - User: security.User{ - Login: "test", - Role: 1, - }, - Password: "pass2", - } - user1.ID, _ = usersR.Create(user1) - user2.ID, _ = usersR.Create(user2) - - req, err := http.NewRequest("GET", "/users", nil) - if err != nil { - t.Fatal(err) - } - rr := httptest.NewRecorder() - r := chi.NewRouter() - r.Get("/users", GetUsers) - r.ServeHTTP(rr, req) - - if status := rr.Code; status != http.StatusOK { - t.Errorf("handler returned wrong status code: got %v want %v", status, http.StatusOK) - } - - mapUsers := []security.User{user1.User, user2.User} - usersData, _ := json.Marshal(mapUsers) - expected := string(usersData) + "\n" - - if rr.Body.String() != expected { - t.Errorf("handler returned unexpected body: got %v want %v", rr.Body.String(), expected) - } - -} - -func TestGetUser(t *testing.T) { - if testing.Short() { - t.Skip("skipping postgresql test in short mode") - } - db := tests.DBClient(t) - defer usersDBDestroy(db, t) - usersDBInit(db, t) - - users.ReplaceGlobals(users.NewPostgresRepository(db)) - groups.ReplaceGlobals(groups.NewPostgresRepository(db)) - - user := security.UserWithPassword{ - User: security.User{ - Login: "admin", - Role: 1, - }, - Password: "pass1", - } - user.ID, _ = users.R().Create(user) - groupID, _ := groups.R().Create(groups.Group{Name: "mygroup"}) - err := groups.R().CreateMembership(groups.Membership{UserID: user.ID, GroupID: groupID, Role: 1}) - if err != nil { - t.Error(err) - t.FailNow() - } - - req, err := http.NewRequest("GET", "/users/"+strconv.FormatInt(user.ID, 10), nil) - if err != nil { - t.Fatal(err) - } - rr := httptest.NewRecorder() - r := chi.NewRouter() - r.Get("/users/{id}", GetUser) - r.ServeHTTP(rr, req) - - if status := rr.Code; status != http.StatusOK { - t.Errorf("handler returned wrong status code: got %v want %v", status, http.StatusOK) - } - - userData, _ := json.Marshal(groups.UserWithGroups{ - User: user.User, - Groups: []groups.GroupOfUser{{ID: groupID, Name: "mygroup", UserRole: 1}}, - }) - expected := string(userData) + "\n" - if rr.Body.String() != expected { - t.Errorf("handler returned unexpected body: got %v want %v", rr.Body.String(), expected) - } -} - -func TestPostUser(t *testing.T) { - if testing.Short() { - t.Skip("skipping postgresql test in short mode") - } - db := tests.DBClient(t) - defer usersDBDestroy(db, t) - usersDBInit(db, t) - - usersR := users.NewPostgresRepository(db) - users.ReplaceGlobals(usersR) - - user := security.UserWithPassword{ - User: security.User{ - Login: "admin", - Role: 1, - LastName: "admin", - }, - Password: "password", - } - userData, _ := json.Marshal(user) - - req, err := http.NewRequest("POST", "/users", bytes.NewBuffer(userData)) - if err != nil { - t.Fatal(err) - } - rr := httptest.NewRecorder() - r := chi.NewRouter() - r.Post("/users", PostUser) - r.ServeHTTP(rr, req) - - if status := rr.Code; status != http.StatusOK { - t.Errorf("handler returned wrong status code: got %v want %v", status, http.StatusOK) - } - - userGet, found, err := users.R().Get(1) - if err != nil { - t.Errorf("unexpected error: " + err.Error()) - t.FailNow() - } - if !found { - t.Error("user not found") - t.FailNow() - } - if userGet.Login != user.Login || userGet.Role != user.Role { - t.Errorf("The user was not inserted correctly") - } -} - -func TestPutUser(t *testing.T) { - if testing.Short() { - t.Skip("skipping postgresql test in short mode") - } - db := tests.DBClient(t) - defer usersDBDestroy(db, t) - usersDBInit(db, t) - - usersR := users.NewPostgresRepository(db) - users.ReplaceGlobals(usersR) - - user := security.UserWithPassword{ - User: security.User{ - Login: "admin", - Role: 1, - LastName: "admin", - }, - Password: "pass1", - } - user.ID, _ = usersR.Create(user) - - user.Login = "newLogin" - user.Role = 1 - - userData, _ := json.Marshal(user.User) - req, err := http.NewRequest("PUT", "/users/"+strconv.FormatInt(user.ID, 10), bytes.NewBuffer(userData)) - if err != nil { - t.Fatal(err) - } - rr := httptest.NewRecorder() - r := chi.NewRouter() - r.Put("/users/{id}", PutUser) - r.ServeHTTP(rr, req) - - if status := rr.Code; status != http.StatusOK { - t.Errorf("handler returned wrong status code: got %v want %v", status, http.StatusOK) - } - - userGet, found, err := users.R().Get(1) - if err != nil { - t.Errorf("unexpected error: " + err.Error()) - t.FailNow() - } - if !found { - t.Error("user not found") - t.FailNow() - } - if userGet.Login != user.Login || userGet.Role != user.Role { - t.Errorf("The user was not updated correctly") - } -} - -func TestDeleteUser(t *testing.T) { - if testing.Short() { - t.Skip("skipping postgresql test in short mode") - } - db := tests.DBClient(t) - defer usersDBDestroy(db, t) - usersDBInit(db, t) - - usersR := users.NewPostgresRepository(db) - users.ReplaceGlobals(usersR) - - user := security.UserWithPassword{ - User: security.User{ - Login: "admin", - Role: 1, - }, - Password: "pass1", - } - user.ID, _ = usersR.Create(user) - - req, err := http.NewRequest("DELETE", "/users/"+strconv.FormatInt(user.ID, 10), nil) - if err != nil { - t.Fatal(err) - } - rr := httptest.NewRecorder() - r := chi.NewRouter() - r.Delete("/users/{id}", DeleteUser) - r.ServeHTTP(rr, req) - - _, found, err := usersR.Get(user.ID) - if err != nil { - t.Error(err) - t.FailNow() - } - if found { - t.Error("User found after deletion") - } -} diff --git a/internals/handlers/utils.go b/internals/handlers/utils.go index 31d322f2..e773d1a9 100644 --- a/internals/handlers/utils.go +++ b/internals/handlers/utils.go @@ -14,7 +14,7 @@ import ( "github.com/myrteametrics/myrtea-engine-api/v5/internals/fact" "github.com/myrteametrics/myrtea-engine-api/v5/internals/utils" - "github.com/myrteametrics/myrtea-sdk/v4/engine" + "github.com/myrteametrics/myrtea-sdk/v5/engine" "net/http" "net/url" diff --git a/internals/history/fact_history_builder_test.go b/internals/history/fact_history_builder_test.go index 6950b1cc..60dedc9b 100644 --- a/internals/history/fact_history_builder_test.go +++ b/internals/history/fact_history_builder_test.go @@ -8,7 +8,7 @@ import ( "github.com/jmoiron/sqlx" _ "github.com/lib/pq" "github.com/myrteametrics/myrtea-engine-api/v5/internals/reader" - "github.com/myrteametrics/myrtea-sdk/v4/postgres" + "github.com/myrteametrics/myrtea-sdk/v5/postgres" ) func TestGetHistoryFactLast(t *testing.T) { diff --git a/internals/history/service_test.go.old b/internals/history/service_test.go.old index edd66b54..774ab2d8 100644 --- a/internals/history/service_test.go.old +++ b/internals/history/service_test.go.old @@ -11,7 +11,7 @@ import ( "github.com/myrteametrics/myrtea-engine-api/v5/internals/scheduler" "github.com/myrteametrics/myrtea-engine-api/v5/internals/situation" "github.com/myrteametrics/myrtea-engine-api/v5/internals/tests" - "github.com/myrteametrics/myrtea-sdk/v4/expression" + "github.com/myrteametrics/myrtea-sdk/v5/expression" "go.uber.org/zap" ) diff --git a/internals/history/utils.go b/internals/history/utils.go index 4070f9f5..20b1828d 100644 --- a/internals/history/utils.go +++ b/internals/history/utils.go @@ -7,7 +7,7 @@ import ( "github.com/myrteametrics/myrtea-engine-api/v5/internals/search" "github.com/myrteametrics/myrtea-engine-api/v5/internals/situation" - "github.com/myrteametrics/myrtea-sdk/v4/expression" + "github.com/myrteametrics/myrtea-sdk/v5/expression" "go.uber.org/zap" ) diff --git a/internals/history/utils_test.go b/internals/history/utils_test.go index d0b48975..78aabd42 100644 --- a/internals/history/utils_test.go +++ b/internals/history/utils_test.go @@ -5,7 +5,7 @@ import ( "time" "github.com/myrteametrics/myrtea-engine-api/v5/internals/situation" - "github.com/myrteametrics/myrtea-sdk/v4/expression" + "github.com/myrteametrics/myrtea-sdk/v5/expression" ) func TestEvaluateExpressionFactsChain(t *testing.T) { diff --git a/internals/modeler/nativemap_repository.go b/internals/modeler/nativemap_repository.go index 542fc595..9291d33e 100644 --- a/internals/modeler/nativemap_repository.go +++ b/internals/modeler/nativemap_repository.go @@ -5,7 +5,7 @@ import ( "strconv" "sync" - "github.com/myrteametrics/myrtea-sdk/v4/modeler" + "github.com/myrteametrics/myrtea-sdk/v5/modeler" ) // NativeMapRepository is an implementation of entity.Repository, supported by standard native in-memory map diff --git a/internals/modeler/nativemap_repository_test.go b/internals/modeler/nativemap_repository_test.go index 3b21fb15..9b10c2be 100644 --- a/internals/modeler/nativemap_repository_test.go +++ b/internals/modeler/nativemap_repository_test.go @@ -3,7 +3,7 @@ package modeler import ( "testing" - "github.com/myrteametrics/myrtea-sdk/v4/modeler" + "github.com/myrteametrics/myrtea-sdk/v5/modeler" ) func TestNew(t *testing.T) { diff --git a/internals/modeler/postgres_repository.go b/internals/modeler/postgres_repository.go index 7e7b6d65..e135478e 100644 --- a/internals/modeler/postgres_repository.go +++ b/internals/modeler/postgres_repository.go @@ -6,7 +6,7 @@ import ( "github.com/jmoiron/sqlx" "github.com/lib/pq" - "github.com/myrteametrics/myrtea-sdk/v4/modeler" + "github.com/myrteametrics/myrtea-sdk/v5/modeler" "go.uber.org/zap" ) diff --git a/internals/modeler/postgres_repository_test.go b/internals/modeler/postgres_repository_test.go index df07a359..10949a68 100644 --- a/internals/modeler/postgres_repository_test.go +++ b/internals/modeler/postgres_repository_test.go @@ -5,7 +5,7 @@ import ( "github.com/jmoiron/sqlx" "github.com/myrteametrics/myrtea-engine-api/v5/internals/tests" - "github.com/myrteametrics/myrtea-sdk/v4/modeler" + "github.com/myrteametrics/myrtea-sdk/v5/modeler" ) func dbInit(dbClient *sqlx.DB, t *testing.T) { diff --git a/internals/modeler/repository.go b/internals/modeler/repository.go index b74fce64..dab6d085 100644 --- a/internals/modeler/repository.go +++ b/internals/modeler/repository.go @@ -3,7 +3,7 @@ package modeler import ( "sync" - "github.com/myrteametrics/myrtea-sdk/v4/modeler" + "github.com/myrteametrics/myrtea-sdk/v5/modeler" ) // Repository is a storage interface which can be implemented by multiple backend diff --git a/internals/notifier/notification/handler_test.go b/internals/notifier/notification/handler_test.go index da2b1289..8b9bb1ed 100644 --- a/internals/notifier/notification/handler_test.go +++ b/internals/notifier/notification/handler_test.go @@ -1,7 +1,7 @@ package notification import ( - "github.com/myrteametrics/myrtea-sdk/v4/expression" + "github.com/myrteametrics/myrtea-sdk/v5/expression" "testing" ) diff --git a/internals/notifier/notification/notification_test.go b/internals/notifier/notification/notification_test.go index d8c3d3d4..47869661 100644 --- a/internals/notifier/notification/notification_test.go +++ b/internals/notifier/notification/notification_test.go @@ -1,7 +1,7 @@ package notification import ( - "github.com/myrteametrics/myrtea-sdk/v4/expression" + "github.com/myrteametrics/myrtea-sdk/v5/expression" "testing" "time" ) diff --git a/internals/processor/filter.go b/internals/processor/filter.go index 378615fa..332e9761 100644 --- a/internals/processor/filter.go +++ b/internals/processor/filter.go @@ -4,8 +4,8 @@ import ( "strings" "github.com/myrteametrics/myrtea-engine-api/v5/internals/fact" - "github.com/myrteametrics/myrtea-sdk/v4/engine" - sdk_models "github.com/myrteametrics/myrtea-sdk/v4/models" + "github.com/myrteametrics/myrtea-sdk/v5/engine" + sdk_models "github.com/myrteametrics/myrtea-sdk/v5/models" "go.uber.org/zap" ) diff --git a/internals/processor/filter_test.go b/internals/processor/filter_test.go index 6145ea88..baff312a 100644 --- a/internals/processor/filter_test.go +++ b/internals/processor/filter_test.go @@ -4,7 +4,7 @@ import ( "reflect" "testing" - "github.com/myrteametrics/myrtea-sdk/v4/engine" + "github.com/myrteametrics/myrtea-sdk/v5/engine" ) func TestFilter(t *testing.T) { diff --git a/internals/processor/processor.go b/internals/processor/processor.go index fa6db38d..d2f61c42 100644 --- a/internals/processor/processor.go +++ b/internals/processor/processor.go @@ -10,8 +10,8 @@ import ( "github.com/myrteametrics/myrtea-engine-api/v5/internals/rule" "github.com/myrteametrics/myrtea-engine-api/v5/internals/situation" "github.com/myrteametrics/myrtea-engine-api/v5/internals/tasker" - "github.com/myrteametrics/myrtea-sdk/v4/engine" - "github.com/myrteametrics/myrtea-sdk/v4/expression" + "github.com/myrteametrics/myrtea-sdk/v5/engine" + "github.com/myrteametrics/myrtea-sdk/v5/expression" "go.uber.org/zap" ) diff --git a/internals/processor/processor_test.go.old b/internals/processor/processor_test.go.old deleted file mode 100644 index e55ea3d1..00000000 --- a/internals/processor/processor_test.go.old +++ /dev/null @@ -1,204 +0,0 @@ -package processor - -import ( - "encoding/json" - "testing" - "time" - - "github.com/jmoiron/sqlx" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/calendar" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/explainer/issues" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/fact" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/notifier" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/notifier/notification" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/reader" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/rule" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/situation" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/tasker" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/tests" - "github.com/myrteametrics/myrtea-sdk/v4/engine" - skd_models "github.com/myrteametrics/myrtea-sdk/v4/models" - "github.com/myrteametrics/myrtea-sdk/v4/postgres" - "github.com/myrteametrics/myrtea-sdk/v4/ruleeng" -) - -func dbInitRepo(dbClient *sqlx.DB, t *testing.T) { - dbDestroyRepo(dbClient, t) - tests.DBExec(dbClient, `CREATE EXTENSION IF NOT EXISTS pgcrypto;`, t, true) - tests.DBExec(dbClient, tests.UsersTableV1, t, true) - tests.DBExec(dbClient, tests.CalendarTableV3, t, true) - tests.DBExec(dbClient, tests.SituationDefinitionTableV1, t, true) - tests.DBExec(dbClient, tests.SituationHistoryTableV1, t, true) - tests.DBExec(dbClient, tests.FactDefinitionTableV1, t, true) - tests.DBExec(dbClient, tests.SituationFactsTableV1, t, true) - tests.DBExec(dbClient, tests.FactHistoryTableV1, t, true) - tests.DBExec(dbClient, tests.RulesTableV1, t, true) - tests.DBExec(dbClient, tests.RuleVersionsTableV1, t, true) - tests.DBExec(dbClient, tests.IssuesTableV1, t, true) - tests.DBExec(dbClient, tests.SituationRulesTableV1, t, true) -} - -func dbDestroyRepo(dbClient *sqlx.DB, t *testing.T) { - tests.DBExec(dbClient, tests.SituationRulesDropTableV1, t, false) - tests.DBExec(dbClient, tests.IssuesDropTableV1, t, false) - tests.DBExec(dbClient, tests.FactHistoryDropTableV1, t, false) - tests.DBExec(dbClient, tests.SituationFactsDropTableV1, t, false) - tests.DBExec(dbClient, tests.FactDefinitionDropTableV1, t, false) - tests.DBExec(dbClient, tests.SituationHistoryDropTableV1, t, false) - tests.DBExec(dbClient, tests.SituationDefinitionDropTableV1, t, false) - tests.DBExec(dbClient, tests.UsersDropTableV1, t, false) - tests.DBExec(dbClient, tests.RuleVersionsDropTableV1, t, false) - tests.DBExec(dbClient, tests.RulesDropTableV1, t, false) - tests.DBExec(dbClient, tests.CalendarDropTableV3, t, false) -} - -func TestEvalProcessor(t *testing.T) { - //Init Postgres repo for Issues - if testing.Short() { - t.Skip("skipping postgresql test in short mode") - } - tests.CheckDebugLogs(t) - - db := tests.DBClient(t) - defer dbDestroyRepo(db, t) - dbInitRepo(db, t) - - postgres.ReplaceGlobals(db) - issues.ReplaceGlobals(issues.NewPostgresRepository(db)) - fact.ReplaceGlobals(fact.NewPostgresRepository(db)) - situation.ReplaceGlobals(situation.NewPostgresRepository(db)) - rule.ReplaceGlobals(rule.NewPostgresRepository(db)) - notifier.ReplaceGlobals(notifier.NewNotifier()) - notification.ReplaceGlobals(notification.NewPostgresRepository(db)) - tasker.ReplaceGlobals(tasker.NewTasker()) - calendar.ReplaceGlobals(calendar.NewPostgresRepository(db)) - - calendar.Init() - - timestamp := time.Now().Truncate(1 * time.Millisecond).UTC() - - idFact1, err := fact.R().Create(engine.Fact{Name: "fact_test_1"}) - idFact2, err := fact.R().Create(engine.Fact{Name: "fact_test_2"}) - idFact3, err := fact.R().Create(engine.Fact{Name: "object", IsObject: true}) - - if err != nil { - t.Error(err) - } - - //Situation - situation1 := situation.Situation{ - Name: "test_name", - Facts: []int64{idFact1, idFact2, idFact3}, - } - - situationID, err := situation.R().Create(situation1) - if err != nil { - t.Error(err) - } - - //Fact History - rangeInterval := 5 //number of days - from := timestamp.Add(-(time.Hour * 24 * time.Duration(rangeInterval))) - - for i := 0; i < rangeInterval; i++ { - ts := from.Add(time.Hour * 24 * time.Duration(i)) - - item1 := &reader.Item{ - Aggs: map[string]*reader.ItemAgg{ - "doc_count": {Value: 10}, - }, - } - - item2 := &reader.Item{ - Aggs: map[string]*reader.ItemAgg{ - "doc_count": {Value: 5}, - }, - } - - fact.PersistFactResult(idFact1, ts, 0, 0, item1, true) - fact.PersistFactResult(idFact2, ts, 0, 0, item2, true) - - factHistory := make(map[int64]*time.Time, 0) - - factHistory[idFact1] = &ts - factHistory[idFact2] = &ts - - //Situation History - historyRecord := situation.HistoryRecord{ - ID: situationID, - TS: ts, - FactsIDS: factHistory, - } - situation.Persist(historyRecord, false) - } - - task1 := ruleeng.ActionDef{ - Name: ruleeng.Expression(`"create-issue"`), - Parameters: map[string]ruleeng.Expression{ - "id": ruleeng.Expression(`"key_task_test"`), - "name": ruleeng.Expression(`"create-issue"`), - "level": ruleeng.Expression(`"critical"`), - "timeout": ruleeng.Expression(`"12h"`), - "isNotification": ruleeng.Expression(`false`), - }, - } - ruleID, _ := rule.R().Create(rule.Rule{ - Name: "testRule1", - DefaultRule: ruleeng.DefaultRule{Cases: []ruleeng.Case{ - { - Name: "case1", - Condition: ruleeng.Expression("object.f1 > object.f2 && fact_test_1.aggs.doc_count.value == 10"), - Actions: []ruleeng.ActionDef{task1}, - }, - }}, - Enabled: true, - }) - situation.R().SetRules(situationID, []int64{int64(ruleID)}) - - //Test - documents := make([]skd_models.Document, 0) - - var object1 map[string]interface{} - var object2 map[string]interface{} - data1 := `{"f3":2,"f2":1}` - data2 := `{"f1":2,"f2":1}` - json.Unmarshal([]byte(data1), &object1) - json.Unmarshal([]byte(data2), &object2) - - documents = append(documents, - skd_models.Document{ID: "id_object1", Source: map[string]interface{}{"f3": 2, "f2": 1}}, // no match (missing f1) - skd_models.Document{ID: "id_object2", Source: map[string]interface{}{"f1": 2, "f2": 1}}, // match - skd_models.Document{ID: "id_object3", Source: map[string]interface{}{"f1": 2, "f2": 100}}, // no match (not f1 > f2) - skd_models.Document{ID: "id_object4", Source: map[string]interface{}{"f1": 20, "f2": 1}}, // match - skd_models.Document{ID: "id_object5", Source: map[string]interface{}{"f1": 3, "f2": 1}}, // match - skd_models.Document{ID: "id_object6", Source: map[string]interface{}{"f1": 19, "f2": 1}}, // match - ) - - tasker.T().StartBatchProcessor() - - err = ReceiveObjects("object", documents) - if err != nil { - t.Error(err) - t.FailNow() - } - - tasker.T().StopBatchProcessor() - - var count int - postgres.DB().Get(&count, "select count(*) from fact_history_v1 where id = $1", idFact3) - if count != 4 { - t.Error("invalid fact history rows") - t.FailNow() - } - - issues, err := issues.R().GetAll() - if err != nil { - t.Error(err) - t.FailNow() - } - if len(issues) != 1 { - // 4 matched rule, but 1 issue + 3 skipped - t.Error("Failed to get all issues") - t.Log(issues) - } -} diff --git a/internals/processor/processor_test.go.old2 b/internals/processor/processor_test.go.old2 deleted file mode 100644 index e55ea3d1..00000000 --- a/internals/processor/processor_test.go.old2 +++ /dev/null @@ -1,204 +0,0 @@ -package processor - -import ( - "encoding/json" - "testing" - "time" - - "github.com/jmoiron/sqlx" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/calendar" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/explainer/issues" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/fact" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/notifier" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/notifier/notification" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/reader" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/rule" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/situation" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/tasker" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/tests" - "github.com/myrteametrics/myrtea-sdk/v4/engine" - skd_models "github.com/myrteametrics/myrtea-sdk/v4/models" - "github.com/myrteametrics/myrtea-sdk/v4/postgres" - "github.com/myrteametrics/myrtea-sdk/v4/ruleeng" -) - -func dbInitRepo(dbClient *sqlx.DB, t *testing.T) { - dbDestroyRepo(dbClient, t) - tests.DBExec(dbClient, `CREATE EXTENSION IF NOT EXISTS pgcrypto;`, t, true) - tests.DBExec(dbClient, tests.UsersTableV1, t, true) - tests.DBExec(dbClient, tests.CalendarTableV3, t, true) - tests.DBExec(dbClient, tests.SituationDefinitionTableV1, t, true) - tests.DBExec(dbClient, tests.SituationHistoryTableV1, t, true) - tests.DBExec(dbClient, tests.FactDefinitionTableV1, t, true) - tests.DBExec(dbClient, tests.SituationFactsTableV1, t, true) - tests.DBExec(dbClient, tests.FactHistoryTableV1, t, true) - tests.DBExec(dbClient, tests.RulesTableV1, t, true) - tests.DBExec(dbClient, tests.RuleVersionsTableV1, t, true) - tests.DBExec(dbClient, tests.IssuesTableV1, t, true) - tests.DBExec(dbClient, tests.SituationRulesTableV1, t, true) -} - -func dbDestroyRepo(dbClient *sqlx.DB, t *testing.T) { - tests.DBExec(dbClient, tests.SituationRulesDropTableV1, t, false) - tests.DBExec(dbClient, tests.IssuesDropTableV1, t, false) - tests.DBExec(dbClient, tests.FactHistoryDropTableV1, t, false) - tests.DBExec(dbClient, tests.SituationFactsDropTableV1, t, false) - tests.DBExec(dbClient, tests.FactDefinitionDropTableV1, t, false) - tests.DBExec(dbClient, tests.SituationHistoryDropTableV1, t, false) - tests.DBExec(dbClient, tests.SituationDefinitionDropTableV1, t, false) - tests.DBExec(dbClient, tests.UsersDropTableV1, t, false) - tests.DBExec(dbClient, tests.RuleVersionsDropTableV1, t, false) - tests.DBExec(dbClient, tests.RulesDropTableV1, t, false) - tests.DBExec(dbClient, tests.CalendarDropTableV3, t, false) -} - -func TestEvalProcessor(t *testing.T) { - //Init Postgres repo for Issues - if testing.Short() { - t.Skip("skipping postgresql test in short mode") - } - tests.CheckDebugLogs(t) - - db := tests.DBClient(t) - defer dbDestroyRepo(db, t) - dbInitRepo(db, t) - - postgres.ReplaceGlobals(db) - issues.ReplaceGlobals(issues.NewPostgresRepository(db)) - fact.ReplaceGlobals(fact.NewPostgresRepository(db)) - situation.ReplaceGlobals(situation.NewPostgresRepository(db)) - rule.ReplaceGlobals(rule.NewPostgresRepository(db)) - notifier.ReplaceGlobals(notifier.NewNotifier()) - notification.ReplaceGlobals(notification.NewPostgresRepository(db)) - tasker.ReplaceGlobals(tasker.NewTasker()) - calendar.ReplaceGlobals(calendar.NewPostgresRepository(db)) - - calendar.Init() - - timestamp := time.Now().Truncate(1 * time.Millisecond).UTC() - - idFact1, err := fact.R().Create(engine.Fact{Name: "fact_test_1"}) - idFact2, err := fact.R().Create(engine.Fact{Name: "fact_test_2"}) - idFact3, err := fact.R().Create(engine.Fact{Name: "object", IsObject: true}) - - if err != nil { - t.Error(err) - } - - //Situation - situation1 := situation.Situation{ - Name: "test_name", - Facts: []int64{idFact1, idFact2, idFact3}, - } - - situationID, err := situation.R().Create(situation1) - if err != nil { - t.Error(err) - } - - //Fact History - rangeInterval := 5 //number of days - from := timestamp.Add(-(time.Hour * 24 * time.Duration(rangeInterval))) - - for i := 0; i < rangeInterval; i++ { - ts := from.Add(time.Hour * 24 * time.Duration(i)) - - item1 := &reader.Item{ - Aggs: map[string]*reader.ItemAgg{ - "doc_count": {Value: 10}, - }, - } - - item2 := &reader.Item{ - Aggs: map[string]*reader.ItemAgg{ - "doc_count": {Value: 5}, - }, - } - - fact.PersistFactResult(idFact1, ts, 0, 0, item1, true) - fact.PersistFactResult(idFact2, ts, 0, 0, item2, true) - - factHistory := make(map[int64]*time.Time, 0) - - factHistory[idFact1] = &ts - factHistory[idFact2] = &ts - - //Situation History - historyRecord := situation.HistoryRecord{ - ID: situationID, - TS: ts, - FactsIDS: factHistory, - } - situation.Persist(historyRecord, false) - } - - task1 := ruleeng.ActionDef{ - Name: ruleeng.Expression(`"create-issue"`), - Parameters: map[string]ruleeng.Expression{ - "id": ruleeng.Expression(`"key_task_test"`), - "name": ruleeng.Expression(`"create-issue"`), - "level": ruleeng.Expression(`"critical"`), - "timeout": ruleeng.Expression(`"12h"`), - "isNotification": ruleeng.Expression(`false`), - }, - } - ruleID, _ := rule.R().Create(rule.Rule{ - Name: "testRule1", - DefaultRule: ruleeng.DefaultRule{Cases: []ruleeng.Case{ - { - Name: "case1", - Condition: ruleeng.Expression("object.f1 > object.f2 && fact_test_1.aggs.doc_count.value == 10"), - Actions: []ruleeng.ActionDef{task1}, - }, - }}, - Enabled: true, - }) - situation.R().SetRules(situationID, []int64{int64(ruleID)}) - - //Test - documents := make([]skd_models.Document, 0) - - var object1 map[string]interface{} - var object2 map[string]interface{} - data1 := `{"f3":2,"f2":1}` - data2 := `{"f1":2,"f2":1}` - json.Unmarshal([]byte(data1), &object1) - json.Unmarshal([]byte(data2), &object2) - - documents = append(documents, - skd_models.Document{ID: "id_object1", Source: map[string]interface{}{"f3": 2, "f2": 1}}, // no match (missing f1) - skd_models.Document{ID: "id_object2", Source: map[string]interface{}{"f1": 2, "f2": 1}}, // match - skd_models.Document{ID: "id_object3", Source: map[string]interface{}{"f1": 2, "f2": 100}}, // no match (not f1 > f2) - skd_models.Document{ID: "id_object4", Source: map[string]interface{}{"f1": 20, "f2": 1}}, // match - skd_models.Document{ID: "id_object5", Source: map[string]interface{}{"f1": 3, "f2": 1}}, // match - skd_models.Document{ID: "id_object6", Source: map[string]interface{}{"f1": 19, "f2": 1}}, // match - ) - - tasker.T().StartBatchProcessor() - - err = ReceiveObjects("object", documents) - if err != nil { - t.Error(err) - t.FailNow() - } - - tasker.T().StopBatchProcessor() - - var count int - postgres.DB().Get(&count, "select count(*) from fact_history_v1 where id = $1", idFact3) - if count != 4 { - t.Error("invalid fact history rows") - t.FailNow() - } - - issues, err := issues.R().GetAll() - if err != nil { - t.Error(err) - t.FailNow() - } - if len(issues) != 1 { - // 4 matched rule, but 1 issue + 3 skipped - t.Error("Failed to get all issues") - t.Log(issues) - } -} diff --git a/internals/reader/reader_v6.go b/internals/reader/reader.go similarity index 89% rename from internals/reader/reader_v6.go rename to internals/reader/reader.go index cef90587..a4a57b2a 100644 --- a/internals/reader/reader_v6.go +++ b/internals/reader/reader.go @@ -3,10 +3,10 @@ package reader import ( "encoding/json" "fmt" + "github.com/myrteametrics/myrtea-engine-api/v5/plugins/baseline" + "github.com/elastic/go-elasticsearch/v8/typedapi/core/search" jsoniter "github.com/json-iterator/go" - "github.com/myrteametrics/myrtea-engine-api/v5/plugins/baseline" - "github.com/olivere/elastic" "go.uber.org/zap" ) @@ -52,49 +52,6 @@ type ItemAgg struct { Value interface{} `json:"value,omitempty"` } -// Parse parse a elasticsearch SearchResult (hits and aggregations) and returns a WidgetData -func Parse(res *elastic.SearchResult) (*WidgetData, error) { - item := &Item{} - - // Parse Aggregations - data, err := jsoniter.Marshal(res.Aggregations) - if err != nil { - zap.L().Error("LoadKPI.MarshalAggregation:", zap.Error(err)) - return nil, err - } - if string(data) != "null" && string(data) != "{}" { - aggs := make(map[string]interface{}) - err := json.Unmarshal(data, &aggs) - if err != nil { - return nil, err - } - item = ParseAggs(aggs) - } - item = EnrichWithTotalHits(item, res.TotalHits()) - - // Parse Hits - hits := make([]Hit, 0) - for _, hit := range res.Hits.Hits { - var fields map[string]interface{} - b, err := hit.Source.MarshalJSON() - if err != nil { - return nil, err - } - err = json.Unmarshal(b, &fields) - if err != nil { - return nil, err - } - hits = append(hits, Hit{ID: hit.Id, Fields: fields}) - } - - widgetData := WidgetData{ - Hits: hits, - Aggregates: item, - } - - return &widgetData, nil -} - // EnrichWithTotalHits enrich an Item with a new key doc_count giving the total number of hits func EnrichWithTotalHits(item *Item, totalHits int64) *Item { itemAgg := &ItemAgg{} @@ -160,3 +117,43 @@ func ParseAggs(item map[string]interface{}) *Item { } return itm } + +// Parse an elasticsearch search.Response (hits and aggregations) and returns a WidgetData +func Parse(res *search.Response) (*WidgetData, error) { + item := &Item{} + + // Parse Aggregations + data, err := jsoniter.Marshal(res.Aggregations) + if err != nil { + zap.L().Error("LoadKPI.MarshalAggregation:", zap.Error(err)) + return nil, err + } + if string(data) != "null" && string(data) != "{}" { + aggs := make(map[string]interface{}) + err := json.Unmarshal(data, &aggs) + if err != nil { + return nil, err + } + item = ParseAggs(aggs) + } + item = EnrichWithTotalHits(item, res.Hits.Total.Value) + + // Parse Hits + hits := make([]Hit, 0) + for _, hit := range res.Hits.Hits { + var fields map[string]interface{} + err := json.Unmarshal(hit.Source_, &fields) + if err != nil { + zap.L().Warn("Cannot unmarshall Source", zap.Any("source", hit.Source_)) + continue + } + hits = append(hits, Hit{ID: hit.Id_, Fields: fields}) + } + + widgetData := WidgetData{ + Hits: hits, + Aggregates: item, + } + + return &widgetData, nil +} diff --git a/internals/reader/reader_v8.go b/internals/reader/reader_v8.go deleted file mode 100644 index dfc12e38..00000000 --- a/internals/reader/reader_v8.go +++ /dev/null @@ -1,49 +0,0 @@ -package reader - -import ( - "encoding/json" - - "github.com/elastic/go-elasticsearch/v8/typedapi/core/search" - jsoniter "github.com/json-iterator/go" - "go.uber.org/zap" -) - -// ParseV8 parse a elasticsearch search.Response (hits and aggregations) and returns a WidgetData -func ParseV8(res *search.Response) (*WidgetData, error) { - item := &Item{} - - // Parse Aggregations - data, err := jsoniter.Marshal(res.Aggregations) - if err != nil { - zap.L().Error("LoadKPI.MarshalAggregation:", zap.Error(err)) - return nil, err - } - if string(data) != "null" && string(data) != "{}" { - aggs := make(map[string]interface{}) - err := json.Unmarshal(data, &aggs) - if err != nil { - return nil, err - } - item = ParseAggs(aggs) - } - item = EnrichWithTotalHits(item, res.Hits.Total.Value) - - // Parse Hits - hits := make([]Hit, 0) - for _, hit := range res.Hits.Hits { - var fields map[string]interface{} - err := json.Unmarshal(hit.Source_, &fields) - if err != nil { - zap.L().Warn("Cannot unmarshall Source", zap.Any("source", hit.Source_)) - continue - } - hits = append(hits, Hit{ID: hit.Id_, Fields: fields}) - } - - widgetData := WidgetData{ - Hits: hits, - Aggregates: item, - } - - return &widgetData, nil -} diff --git a/internals/router/middleware.go b/internals/router/middleware.go index 50d1da32..dbaa8ce6 100644 --- a/internals/router/middleware.go +++ b/internals/router/middleware.go @@ -9,7 +9,6 @@ import ( "github.com/go-chi/jwtauth/v5" "github.com/google/uuid" gorillacontext "github.com/gorilla/context" - "github.com/lestrrat-go/jwx/v2/jwt" "github.com/myrteametrics/myrtea-engine-api/v5/internals/handlers/render" "github.com/myrteametrics/myrtea-engine-api/v5/internals/models" "github.com/myrteametrics/myrtea-engine-api/v5/internals/security/permissions" @@ -18,40 +17,6 @@ import ( "go.uber.org/zap" ) -// UnverifiedAuthenticator doc -// WARNING: Don't use this method unless you know what you're doing -// This method parses the token but doesn't validate the signature. It's only -// ever useful in cases where you know the signature is valid (because it has -// been checked previously in the stack) and you want to extract values from -// it. -func UnverifiedAuthenticator(next http.Handler) http.Handler { - return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - ctx := r.Context() - findTokenFns := []func(r *http.Request) string{jwtauth.TokenFromQuery, jwtauth.TokenFromHeader, jwtauth.TokenFromCookie} - var tokenStr string - for _, fn := range findTokenFns { - if tokenStr = fn(r); tokenStr != "" { - break - } - } - if tokenStr == "" { - zap.L().Warn("No JWT string found in request") - render.Error(w, r, render.ErrAPISecurityMissingContext, errors.New("missing JWT")) - return - } - - token, err := jwt.Parse([]byte(tokenStr)) - if err != nil { - zap.L().Warn("JWT string cannot be parsed") // , zap.String("jwt", tokenStr)) // Security issue if logged without check ? - render.Error(w, r, render.ErrAPISecurityMissingContext, errors.New("invalid JWT")) - return - } - - ctx = jwtauth.NewContext(ctx, token, err) - next.ServeHTTP(w, r.WithContext(ctx)) - }) -} - // ContextMiddleware : func ContextMiddleware(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { @@ -69,7 +34,14 @@ func ContextMiddleware(next http.Handler) http.Handler { return } - userID, _ := uuid.Parse(rawUserID.(string)) + rawUserIDStr, ok := rawUserID.(string) + if !ok { + zap.L().Warn("Cannot parse user ID", zap.Any("claims", claims)) + render.Error(w, r, render.ErrAPISecurityMissingContext, errors.New("invalid JWT")) + return + } + + userID, _ := uuid.Parse(rawUserIDStr) user, found, err := users.R().Get(userID) if err != nil { diff --git a/internals/router/router.go b/internals/router/router.go index a25e9225..85722d96 100644 --- a/internals/router/router.go +++ b/internals/router/router.go @@ -2,7 +2,6 @@ package router import ( "fmt" - "github.com/lestrrat-go/jwx/v2/jwa" "net/http" "net/http/httputil" "net/url" @@ -16,9 +15,10 @@ import ( "github.com/myrteametrics/myrtea-engine-api/v5/internals/handlers" "github.com/myrteametrics/myrtea-engine-api/v5/internals/handlers/render" oidcAuth "github.com/myrteametrics/myrtea-engine-api/v5/internals/router/oidc" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/security" plugin "github.com/myrteametrics/myrtea-engine-api/v5/plugins" - "github.com/myrteametrics/myrtea-sdk/v4/postgres" + "github.com/myrteametrics/myrtea-sdk/v5/postgres" + sdkrouter "github.com/myrteametrics/myrtea-sdk/v5/router" + sdksecurity "github.com/myrteametrics/myrtea-sdk/v5/security" "github.com/spf13/viper" httpSwagger "github.com/swaggo/http-swagger" "go.uber.org/zap" @@ -132,8 +132,8 @@ func New(config Config, services Services) *chi.Mux { } func buildRoutesV3Basic(config Config, services Services) (func(r chi.Router), error) { - signingKey := []byte(security.RandString(128)) - securityMiddleware := security.NewMiddlewareJWT(signingKey, security.NewDatabaseAuth(postgres.DB())) + signingKey := []byte(sdksecurity.RandString(128)) + securityMiddleware := sdksecurity.NewMiddlewareJWT(signingKey, sdksecurity.NewDatabaseAuth(postgres.DB())) return func(r chi.Router) { @@ -155,13 +155,13 @@ func buildRoutesV3Basic(config Config, services Services) (func(r chi.Router), e if config.GatewayMode { // Warning: No signature verification will be done on JWT. // JWT MUST have been verified before by the API Gateway - rg.Use(UnverifiedAuthenticator) + rg.Use(sdkrouter.UnverifiedAuthenticator) } else { rg.Use(func(next http.Handler) http.Handler { // jwtauth.Verifier function only verifies header & cookie but not query // websocket requests only handles uri parameters, so jwtauth.TokenFromHeader // is needed here. - return jwtauth.Verify(jwtauth.New(jwa.HS256.String(), signingKey, nil), + return jwtauth.Verify(jwtauth.New("HS256", signingKey, nil), jwtauth.TokenFromQuery, jwtauth.TokenFromHeader, jwtauth.TokenFromCookie)(next) }) rg.Use(CustomAuthenticator) @@ -189,9 +189,9 @@ func buildRoutesV3Basic(config Config, services Services) (func(r chi.Router), e if config.GatewayMode { // Warning: No signature verification will be done on JWT. // JWT MUST have been verified before by the API Gateway - rg.Use(UnverifiedAuthenticator) + rg.Use(sdkrouter.UnverifiedAuthenticator) } else { - rg.Use(jwtauth.Verifier(jwtauth.New(jwa.HS256.String(), signingKey, nil))) + rg.Use(jwtauth.Verifier(jwtauth.New("HS256", signingKey, nil))) rg.Use(CustomAuthenticator) } // rg.Use(security.AdminAuthentificator) diff --git a/internals/rule/models.go b/internals/rule/models.go index 0d662c5d..4de407d6 100644 --- a/internals/rule/models.go +++ b/internals/rule/models.go @@ -4,7 +4,7 @@ import ( "encoding/json" "errors" - "github.com/myrteametrics/myrtea-sdk/v4/ruleeng" + "github.com/myrteametrics/myrtea-sdk/v5/ruleeng" ) // Rule ... @@ -34,7 +34,7 @@ func (r *Rule) IsValid() (bool, error) { return true, nil } -//SameCasesAs returns true if the cases of the are equal to the case of the rule passed as parameter or false otherwise +// SameCasesAs returns true if the cases of the are equal to the case of the rule passed as parameter or false otherwise func (r Rule) SameCasesAs(rule Rule) bool { rCasesData, err := json.Marshal(r.Cases) if err != nil { @@ -47,7 +47,7 @@ func (r Rule) SameCasesAs(rule Rule) bool { return string(rCasesData) == string(ruleCasesData) } -//EqualTo returns true if the rule is equal to the rule passed as parameter or false otherwise +// EqualTo returns true if the rule is equal to the rule passed as parameter or false otherwise func (r Rule) EqualTo(rule Rule) bool { if r.Name != rule.Name { return false @@ -64,15 +64,15 @@ func (r Rule) EqualTo(rule Rule) bool { // UnmarshalJSON unmashals a quoted json string to Expression func (r *Rule) UnmarshalJSON(data []byte) error { type Alias struct { - Name string `json:"name"` - Description string `json:"description"` - Enabled bool `json:"enabled"` - CalendarID int `json:"calendarId"` - ID int64 `json:"id,omitempty"` - Cases []ruleeng.Case `json:"cases"` - Version int64 `json:"version"` - Parameters map[string]interface{} `json:"parameters"` - EvaluateAllCases bool `json:"evaluateallcase"` + Name string `json:"name"` + Description string `json:"description"` + Enabled bool `json:"enabled"` + CalendarID int `json:"calendarId"` + ID int64 `json:"id,omitempty"` + Cases []ruleeng.Case `json:"cases"` + Version int64 `json:"version"` + Parameters map[string]interface{} `json:"parameters"` + EvaluateAllCases bool `json:"evaluateallcase"` } aux := Alias{} diff --git a/internals/scheduler/fact_calculation_job.go b/internals/scheduler/fact_calculation_job.go index a54b46d1..d08dfbb0 100644 --- a/internals/scheduler/fact_calculation_job.go +++ b/internals/scheduler/fact_calculation_job.go @@ -15,9 +15,9 @@ import ( "github.com/myrteametrics/myrtea-engine-api/v5/internals/rule" "github.com/myrteametrics/myrtea-engine-api/v5/internals/situation" "github.com/myrteametrics/myrtea-engine-api/v5/internals/tasker" - "github.com/myrteametrics/myrtea-sdk/v4/engine" - "github.com/myrteametrics/myrtea-sdk/v4/expression" - "github.com/myrteametrics/myrtea-sdk/v4/ruleeng" + "github.com/myrteametrics/myrtea-sdk/v5/engine" + "github.com/myrteametrics/myrtea-sdk/v5/expression" + "github.com/myrteametrics/myrtea-sdk/v5/ruleeng" "go.uber.org/zap" ) diff --git a/internals/scheduler/fact_calculation_job_test.go.old b/internals/scheduler/fact_calculation_job_test.go.old index 9a4014cf..ef936b36 100644 --- a/internals/scheduler/fact_calculation_job_test.go.old +++ b/internals/scheduler/fact_calculation_job_test.go.old @@ -18,11 +18,11 @@ import ( "github.com/myrteametrics/myrtea-engine-api/v5/internals/situation" "github.com/myrteametrics/myrtea-engine-api/v5/internals/tasker" "github.com/myrteametrics/myrtea-engine-api/v5/internals/tests" - "github.com/myrteametrics/myrtea-sdk/v4/configuration" - "github.com/myrteametrics/myrtea-sdk/v4/elasticsearch" - "github.com/myrteametrics/myrtea-sdk/v4/engine" - "github.com/myrteametrics/myrtea-sdk/v4/models" - "github.com/myrteametrics/myrtea-sdk/v4/postgres" + "github.com/myrteametrics/myrtea-sdk/v5/configuration" + "github.com/myrteametrics/myrtea-sdk/v5/elasticsearch" + "github.com/myrteametrics/myrtea-sdk/v5/engine" + "github.com/myrteametrics/myrtea-sdk/v5/models" + "github.com/myrteametrics/myrtea-sdk/v5/postgres" "github.com/spf13/viper" "go.uber.org/zap" ) diff --git a/internals/scheduler/fact_recalculation_job.go b/internals/scheduler/fact_recalculation_job.go index afc3d17d..f65ff45c 100644 --- a/internals/scheduler/fact_recalculation_job.go +++ b/internals/scheduler/fact_recalculation_job.go @@ -12,9 +12,9 @@ import ( "github.com/myrteametrics/myrtea-engine-api/v5/internals/rule" "github.com/myrteametrics/myrtea-engine-api/v5/internals/situation" "github.com/myrteametrics/myrtea-engine-api/v5/internals/tasker" - "github.com/myrteametrics/myrtea-sdk/v4/engine" - "github.com/myrteametrics/myrtea-sdk/v4/expression" - "github.com/myrteametrics/myrtea-sdk/v4/ruleeng" + "github.com/myrteametrics/myrtea-sdk/v5/engine" + "github.com/myrteametrics/myrtea-sdk/v5/expression" + "github.com/myrteametrics/myrtea-sdk/v5/ruleeng" "go.uber.org/zap" ) @@ -28,8 +28,8 @@ import ( // "github.com/myrteametrics/myrtea-engine-api/v5/internals/fact" // "github.com/myrteametrics/myrtea-engine-api/v5/internals/situation" // "github.com/myrteametrics/myrtea-engine-api/v5/internals/tasker" -// "github.com/myrteametrics/myrtea-sdk/v4/expression" -// "github.com/myrteametrics/myrtea-sdk/v4/ruleeng" +// "github.com/myrteametrics/myrtea-sdk/v5/expression" +// "github.com/myrteametrics/myrtea-sdk/v5/ruleeng" // "go.uber.org/zap" // ) diff --git a/internals/scheduler/fact_recalculation_job_test.go b/internals/scheduler/fact_recalculation_job_test.go index 3ab173ff..370cd18c 100644 --- a/internals/scheduler/fact_recalculation_job_test.go +++ b/internals/scheduler/fact_recalculation_job_test.go @@ -2,6 +2,8 @@ package scheduler import ( "fmt" + "github.com/elastic/go-elasticsearch/v8" + elasticsearchsdk "github.com/myrteametrics/myrtea-sdk/v5/elasticsearch" "log" "testing" "time" @@ -13,9 +15,8 @@ import ( "github.com/myrteametrics/myrtea-engine-api/v5/internals/rule" "github.com/myrteametrics/myrtea-engine-api/v5/internals/situation" "github.com/myrteametrics/myrtea-engine-api/v5/internals/tests" - "github.com/myrteametrics/myrtea-sdk/v4/elasticsearchv6" - "github.com/myrteametrics/myrtea-sdk/v4/helpers" - "github.com/myrteametrics/myrtea-sdk/v4/postgres" + "github.com/myrteametrics/myrtea-sdk/v5/helpers" + "github.com/myrteametrics/myrtea-sdk/v5/postgres" "github.com/spf13/viper" "go.uber.org/zap" ) @@ -83,10 +84,9 @@ func TestFactRecalculationJobRun(t *testing.T) { zap.ReplaceGlobals(logger) loadConfiguration() - credentials := &elasticsearchv6.Credentials{ - URLs: []string{"http://localhost:9200"}, - } - elasticsearchv6.ReplaceGlobals(credentials) + elasticsearchsdk.ReplaceGlobals(elasticsearch.Config{ + Addresses: []string{"http://localhost:9200"}, + }) db := tests.DBClient(t) postgres.ReplaceGlobals(db) diff --git a/internals/search/query_test.go.old b/internals/search/query_test.go.old index 573e9e91..3ea3ab6b 100644 --- a/internals/search/query_test.go.old +++ b/internals/search/query_test.go.old @@ -11,8 +11,8 @@ import ( "github.com/myrteametrics/myrtea-engine-api/v5/internals/rule" "github.com/myrteametrics/myrtea-engine-api/v5/internals/situation" "github.com/myrteametrics/myrtea-engine-api/v5/internals/tests" - "github.com/myrteametrics/myrtea-sdk/v4/engine" - "github.com/myrteametrics/myrtea-sdk/v4/postgres" + "github.com/myrteametrics/myrtea-sdk/v5/engine" + "github.com/myrteametrics/myrtea-sdk/v5/postgres" ) func dbFactInit(dbClient *sqlx.DB, t *testing.T) { diff --git a/internals/security/auth.go b/internals/security/auth.go deleted file mode 100644 index b422e588..00000000 --- a/internals/security/auth.go +++ /dev/null @@ -1,8 +0,0 @@ -package security - -import "github.com/myrteametrics/myrtea-engine-api/v5/internals/security/users" - -// Auth refers to a generic interface which must be implemented by every authentication backend -type Auth interface { - Authenticate(string, string) (users.User, bool, error) -} diff --git a/internals/security/database_auth.go b/internals/security/database_auth.go deleted file mode 100644 index 1b211f68..00000000 --- a/internals/security/database_auth.go +++ /dev/null @@ -1,88 +0,0 @@ -package security - -import ( - "database/sql" - "errors" - - sq "github.com/Masterminds/squirrel" - - "github.com/jmoiron/sqlx" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/security/users" -) - -const table = "users_v4" - -var fields = []string{"id", "login", "created", "last_name", "first_name", "email", "phone"} - -// DatabaseAuth is a basic Auth implementation requiring the tuple admin/admin to authenticate successfully -type DatabaseAuth struct { - DBClient *sqlx.DB -} - -// NewDatabaseAuth returns a pointer of DatabaseAuth -func NewDatabaseAuth(DBClient *sqlx.DB) *DatabaseAuth { - return &DatabaseAuth{DBClient} -} - -func (auth *DatabaseAuth) newStatement() sq.StatementBuilderType { - return sq.StatementBuilder.PlaceholderFormat(sq.Dollar).RunWith(auth.DBClient.DB) -} - -func (auth *DatabaseAuth) scan(rows *sql.Rows) (users.User, error) { - user := users.User{} - err := rows.Scan(&user.ID, &user.Login, &user.Created, &user.LastName, &user.FirstName, &user.Email, &user.Phone) - if err != nil { - return users.User{}, errors.New("couldn't scan the retrieved data: " + err.Error()) - } - return user, nil -} - -//Get search and returns an User from the repository by its id -func (auth *DatabaseAuth) Authenticate(login string, password string) (users.User, bool, error) { - rows, err := auth.newStatement(). - Select(fields...). - From(table). - Where("login = ? AND password = crypt(?, password)", login, password). - Query() - if err != nil { - return users.User{}, false, err - } - defer rows.Close() - if rows.Next() { - user, err := auth.scan(rows) - return user, err == nil, err - } - return users.User{}, false, errors.New("no user found, invalid credentials") -} - -// // Authenticate check the input credentials and returns a User the passwords matches -// func (auth *DatabaseAuth) Authenticate(login string, password string) (bool, users.User, error) { - -// query := `SELECT id, login, role, last_name, first_name, email, created, phone FROM users_v1 -// WHERE login = :login AND (password =crypt(:password, password))` -// params := map[string]interface{}{ -// "login": login, -// "password": password, -// } -// rows, err := auth.DBClient.NamedQuery(query, params) -// if err != nil { -// return false, users.User{}, err -// } -// defer rows.Close() - -// var user users.User -// // i := 0 -// // for rows.Next() { -// // err = rows.Scan(&user.ID, &user.Login, &user.Role, &user.LastName, &user.FirstName, &user.Email, &user.Created, &user.Phone) -// // if err != nil { -// // return false, users.User{}, err -// // } -// // i++ -// // break -// // } -// // if i == 0 { -// // return false, users.User{}, errors.New("invalid credentials") -// // } - -// return true, user, nil -// } diff --git a/internals/security/middleware.go b/internals/security/middleware.go deleted file mode 100644 index a9ec96b0..00000000 --- a/internals/security/middleware.go +++ /dev/null @@ -1,137 +0,0 @@ -package security - -import ( - "encoding/json" - "github.com/golang-jwt/jwt/v4" - "math/rand" - "net/http" - "time" - - "github.com/go-chi/jwtauth/v5" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/security/users" - - "go.uber.org/zap" -) - -// Middleware is an interface for standard http middleware -type Middleware interface { - Handler(h http.Handler) http.Handler -} - -// -// TODO: Must be refactored and merged in a single lib with github.com/auth0/go-jwt-middleware/jwtmiddleware.go (instead of wrapping it) -// - -// MiddlewareJWT is an implementation of Middleware interface, which provides a specific security handler based on JWT (JSON Web Token) -type MiddlewareJWT struct { - Auth Auth - Handler func(h http.Handler) http.Handler - signingKey []byte -} - -// JwtToken wrap the json web token string -type JwtToken struct { - Token string `json:"token"` -} - -const charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" - -var seededRand = rand.New(rand.NewSource(time.Now().UnixNano())) - -// RandStringWithCharset generate a random string with a specific charset -func RandStringWithCharset(length int, charset string) string { - b := make([]byte, length) - for i := range b { - b[i] = charset[seededRand.Intn(len(charset))] - } - return string(b) -} - -// RandString generate a random string with the default charset ([A-Za-z]) -func RandString(length int) string { - return RandStringWithCharset(length, charset) -} - -// NewMiddlewareJWT initialize a new instance of MiddlewareJWT and returns a pointer of it -func NewMiddlewareJWT(jwtSigningKey []byte, auth Auth) *MiddlewareJWT { - /* - var jwtMiddleware = jwtmiddleware.New(jwtmiddleware.Options{ - ValidationKeyGetter: func(token *jwt.Token) (interface{}, error) { - return jwtSigningKey, nil - }, - SigningMethod: jwt.SigningMethodHS256, - Debug: true, - }) - securingHandler := jwtMiddleware.Handler - */ - return &MiddlewareJWT{auth, nil, jwtSigningKey} -} - -// GetToken returns a http.Handler to authenticate and get a JWT -func (middleware *MiddlewareJWT) GetToken() http.HandlerFunc { - return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - var credentials users.UserWithPassword - err := json.NewDecoder(r.Body).Decode(&credentials) - if err != nil { - zap.L().Error("GetToken.Decode:", zap.Error(err)) - w.WriteHeader(http.StatusBadRequest) - return - } - - user, allowed, err := middleware.Auth.Authenticate(credentials.Login, credentials.Password) - if err != nil { - zap.L().Warn("Authentication failed", zap.Error(err)) - w.WriteHeader(http.StatusBadRequest) - return - } - if !allowed { - zap.L().Error("Invalid credentials") - w.WriteHeader(http.StatusUnauthorized) - return - } - - token := jwt.NewWithClaims(jwt.SigningMethodHS256, jwt.MapClaims{ - "iss": "Myrtea metrics", - "exp": time.Now().Add(time.Hour * 12).Unix(), - "iat": time.Now().Unix(), - "nbf": time.Now().Unix(), - "id": user.ID, - }) - - // Sign the token with our signing key - tokenString, err := token.SignedString(middleware.signingKey) - if err != nil { - zap.L().Error("Error while signing token", zap.Error(err)) - w.WriteHeader(http.StatusBadRequest) - return - } - - err = json.NewEncoder(w).Encode(JwtToken{Token: tokenString}) - if err != nil { - zap.L().Error("Error while encoding the token ", zap.Error(err)) - w.WriteHeader(http.StatusBadRequest) - return - } - }) -} - -// AdminAuthenticator is a middle which check if the user is administrator (role=1) -func AdminAuthenticator(next http.Handler) http.Handler { - return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - // get user infos from token - _, claims, _ := jwtauth.FromContext(r.Context()) - // test if user haven't right to access - if claims["role"] != float64(1) { - http.Error(w, http.StatusText(http.StatusForbidden), http.StatusForbidden) - return - } - next.ServeHTTP(w, r) - }) -} - -// Handler return a specific securing Handler. It should be used to wrap other handlers which must be secured with JWT -/* -func (middleware *MiddlewareJWT) Handler(next http.Handler) http.Handler { - return middleware.Handler(next) -} -*/ diff --git a/internals/service/connector.go b/internals/service/connector.go index 43c873ad..ad8dd3bc 100644 --- a/internals/service/connector.go +++ b/internals/service/connector.go @@ -4,7 +4,7 @@ import ( "bytes" "encoding/json" "fmt" - "github.com/myrteametrics/myrtea-sdk/v4/connector" + "github.com/myrteametrics/myrtea-sdk/v5/connector" "go.uber.org/zap" "io" "net/http" diff --git a/internals/service/connector_test.go b/internals/service/connector_test.go index dfd4c906..c3c58018 100644 --- a/internals/service/connector_test.go +++ b/internals/service/connector_test.go @@ -2,8 +2,8 @@ package service import ( "errors" - "github.com/myrteametrics/myrtea-sdk/v4/connector" - "github.com/myrteametrics/myrtea-sdk/v4/expression" + "github.com/myrteametrics/myrtea-sdk/v5/connector" + "github.com/myrteametrics/myrtea-sdk/v5/expression" "testing" ) diff --git a/internals/service/manager_test.go b/internals/service/manager_test.go index 697110dc..8e294469 100644 --- a/internals/service/manager_test.go +++ b/internals/service/manager_test.go @@ -3,7 +3,7 @@ package service import ( plugin "github.com/myrteametrics/myrtea-engine-api/v5/plugins" "github.com/myrteametrics/myrtea-engine-api/v5/plugins/pluginutils" - "github.com/myrteametrics/myrtea-sdk/v4/expression" + "github.com/myrteametrics/myrtea-sdk/v5/expression" "github.com/spf13/viper" "os" "path/filepath" diff --git a/internals/service/plugin_test.go b/internals/service/plugin_test.go index 1c6353b2..e0dfc073 100644 --- a/internals/service/plugin_test.go +++ b/internals/service/plugin_test.go @@ -3,7 +3,7 @@ package service import ( "errors" "github.com/google/uuid" - "github.com/myrteametrics/myrtea-sdk/v4/expression" + "github.com/myrteametrics/myrtea-sdk/v5/expression" "net/http" "testing" ) diff --git a/internals/situation/build_test.go b/internals/situation/build_test.go index ea80dff9..c399f5a2 100644 --- a/internals/situation/build_test.go +++ b/internals/situation/build_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/myrteametrics/myrtea-engine-api/v5/internals/fact" - "github.com/myrteametrics/myrtea-sdk/v4/engine" + "github.com/myrteametrics/myrtea-sdk/v5/engine" ) func TestBuildSituationsFromFileNoFile(t *testing.T) { diff --git a/internals/situation/history.go.old b/internals/situation/history.go.old index f849b33a..99e547b7 100644 --- a/internals/situation/history.go.old +++ b/internals/situation/history.go.old @@ -7,7 +7,7 @@ import ( "time" "github.com/myrteametrics/myrtea-engine-api/v5/internals/models" - "github.com/myrteametrics/myrtea-sdk/v4/postgres" + "github.com/myrteametrics/myrtea-sdk/v5/postgres" "go.uber.org/zap" ) diff --git a/internals/situation/history_test.go.old b/internals/situation/history_test.go.old index 6e1453d3..3956935b 100644 --- a/internals/situation/history_test.go.old +++ b/internals/situation/history_test.go.old @@ -7,7 +7,7 @@ import ( "github.com/jmoiron/sqlx" "github.com/myrteametrics/myrtea-engine-api/v5/internals/models" "github.com/myrteametrics/myrtea-engine-api/v5/internals/tests" - "github.com/myrteametrics/myrtea-sdk/v4/postgres" + "github.com/myrteametrics/myrtea-sdk/v5/postgres" ) func dbInit(dbClient *sqlx.DB, t *testing.T) { diff --git a/internals/situation/postgres_repository_test.go b/internals/situation/postgres_repository_test.go index f13727ca..d0054fbf 100644 --- a/internals/situation/postgres_repository_test.go +++ b/internals/situation/postgres_repository_test.go @@ -8,7 +8,7 @@ import ( "github.com/jmoiron/sqlx" "github.com/myrteametrics/myrtea-engine-api/v5/internals/fact" "github.com/myrteametrics/myrtea-engine-api/v5/internals/tests" - "github.com/myrteametrics/myrtea-sdk/v4/engine" + "github.com/myrteametrics/myrtea-sdk/v5/engine" ) func dbInitRepo(dbClient *sqlx.DB, t *testing.T) { diff --git a/internals/situation/utils.go b/internals/situation/utils.go index 048bb7e6..2ef3cb0c 100644 --- a/internals/situation/utils.go +++ b/internals/situation/utils.go @@ -6,7 +6,7 @@ import ( "go.uber.org/zap" "github.com/myrteametrics/myrtea-engine-api/v5/internals/variablesconfig" - "github.com/myrteametrics/myrtea-sdk/v4/expression" + "github.com/myrteametrics/myrtea-sdk/v5/expression" ) func shouldParseGlobalVariables(translateOpt ...bool) bool { diff --git a/internals/tasker/models.go b/internals/tasker/models.go index 58832f70..9d8da580 100644 --- a/internals/tasker/models.go +++ b/internals/tasker/models.go @@ -3,16 +3,16 @@ package tasker import ( "time" - "github.com/myrteametrics/myrtea-sdk/v4/ruleeng" + "github.com/myrteametrics/myrtea-sdk/v5/ruleeng" ) -//TaskBatch batch of action to be performed +// TaskBatch batch of action to be performed type TaskBatch struct { Context map[string]interface{} Agenda []ruleeng.Action } -//ContextData struct to represent the data related to the context in an action perform +// ContextData struct to represent the data related to the context in an action perform type ContextData struct { RuleID int64 RuleVersion int64 diff --git a/internals/tasker/persist.go.old b/internals/tasker/persist.go.old deleted file mode 100644 index 8a8b47eb..00000000 --- a/internals/tasker/persist.go.old +++ /dev/null @@ -1,50 +0,0 @@ -package tasker - -import ( - "errors" - "fmt" - - "github.com/myrteametrics/myrtea-engine-api/v5/internals/models" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/situation" -) - -// PersistDataTask struct to represent a persit metadata task (use to persist situation instance metadata) -type PersistDataTask struct { - Data []models.MetaData -} - -func (task PersistDataTask) String() string { - return fmt.Sprint("Persist data ", fmt.Sprint(task.Data)) -} - -// GetID returns the task key -func (task PersistDataTask) GetID() string { - return "" -} - -// Perform executes the task -func (task PersistDataTask) Perform(key string, context ContextData) error { - - if context.SituationID == 0 || context.TS.IsZero() { - return errors.New("errro performinf PersistDataTask, situation instance not defined") - } - - err := situation.UpdateHistoryMetadata(int64(context.SituationID), context.TS, int64(context.TemplateInstanceID), task.Data) - if err != nil { - return errors.New("error when performing PersistDataTask: " + err.Error()) - } - return nil -} - -func (task *PersistDataTask) addData(parameters map[string]interface{}, context ContextData) { - - for key, value := range parameters { - task.Data = append(task.Data, models.MetaData{ - Key: key, - Value: value, - RuleID: context.RuleID, - RuleVersion: context.RuleVersion, - CaseName: context.CaseName, - }) - } -} diff --git a/internals/tasker/tasker_test.go.old b/internals/tasker/tasker_test.go.old deleted file mode 100644 index cfb18abb..00000000 --- a/internals/tasker/tasker_test.go.old +++ /dev/null @@ -1,530 +0,0 @@ -package tasker - -import ( - "testing" - "time" - - "github.com/jmoiron/sqlx" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/calendar" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/evaluator" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/explainer/issues" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/fact" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/models" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/reader" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/rule" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/situation" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/tests" - "github.com/myrteametrics/myrtea-sdk/v4/engine" - "github.com/myrteametrics/myrtea-sdk/v4/postgres" - "github.com/myrteametrics/myrtea-sdk/v4/ruleeng" -) - -func dbInit(dbClient *sqlx.DB, t *testing.T) { - dbDestroy(dbClient, t) - tests.DBExec(dbClient, tests.CalendarTableV3, t, true) - tests.DBExec(dbClient, tests.SituationDefinitionTableV1, t, true) - tests.DBExec(dbClient, tests.FactDefinitionTableV1, t, true) - tests.DBExec(dbClient, tests.SituationFactsTableV1, t, true) - tests.DBExec(dbClient, tests.RulesTableV1, t, true) - tests.DBExec(dbClient, tests.RuleVersionsTableV1, t, true) - tests.DBExec(dbClient, tests.SituationRulesTableV1, t, true) - tests.DBExec(dbClient, tests.SituationHistoryTableV1, t, true) - tests.DBExec(dbClient, tests.FactHistoryTableV1, t, true) - tests.DBExec(dbClient, tests.IssuesTableV1, t, true) -} - -func dbDestroy(dbClient *sqlx.DB, t *testing.T) { - tests.DBExec(dbClient, tests.IssuesDropTableV1, t, true) - tests.DBExec(dbClient, tests.SituationRulesDropTableV1, t, true) - tests.DBExec(dbClient, tests.SituationFactsDropTableV1, t, true) - tests.DBExec(dbClient, tests.FactDefinitionDropTableV1, t, true) - tests.DBExec(dbClient, tests.SituationDefinitionDropTableV1, t, true) - tests.DBExec(dbClient, tests.RuleVersionsDropTableV1, t, true) - tests.DBExec(dbClient, tests.RulesDropTableV1, t, true) - tests.DBExec(dbClient, tests.SituationHistoryDropTableV1, t, true) - tests.DBExec(dbClient, tests.FactHistoryDropTableV1, t, true) - tests.DBExec(dbClient, tests.CalendarDropTableV3, t, true) -} - -func TestNewTasker(t *testing.T) { - tasker := NewTasker() - if tasker == nil { - t.Error("tasker constructor returns nil") - } -} - -func TestReplaceGlobal(t *testing.T) { - - if testing.Short() { - t.Skip("skipping postgresql test in short mode") - } - tasker := NewTasker() - reverse := ReplaceGlobals(tasker) - if T() == nil { - t.Error("Global tasker is nil") - } - reverse() - if T() != nil { - t.Error("Global situation repository is not nil after reverse") - } -} - -// func TestPersisDataPerform(t *testing.T) { -// if testing.Short() { -// t.Skip("skipping postgresql test in short mode") -// } - -// db := tests.DBClient(t) -// defer dbDestroy(db, t) -// dbInit(db, t) -// postgres.ReplaceGlobals(db) - -// id := int64(1) -// ts1 := time.Date(2019, time.June, 14, 12, 30, 15, 0, time.UTC) -// r1 := situation.HistoryRecord{ -// ID: id, -// TS: ts1, -// FactsIDS: []situation.FactHistoryID{ -// situation.FactHistoryID{ -// ID: 1, -// TS: &ts1, -// }, -// }, -// } - -// err := situation.Persist(r1, false) -// if err != nil { -// t.Error(err) -// } - -// exp1, _ := expressions.New("3 + 4") -// exp2, _ := expressions.New("(3 + 4) * 2") - -// definitions := []taskdef.Definition{ -// &taskdef.SetTaskDefinition{ -// Key: "key1", -// Value: exp1, -// }, -// &taskdef.SetTaskDefinition{ -// Key: "key2", -// Value: exp2, -// }, -// } - -// tasks := InstantiateTasks(definitions, knowledge.NewBase()) - -// if len(tasks) != 1 { -// t.Error("The number of Tasks is not as expected") -// } else { -// tasks[0].Perform( -// "key-1", -// models.InputTask{ -// SituationID: id, -// TS: ts1, -// Rule: models.RuleInput{ -// RuleID: 1, -// RuleVersion: 0, -// CasesInput: []models.CaseInput{ -// models.CaseInput{ -// Name: "case1", -// Condition: "true", -// State: models.Met, -// }, -// }, -// }, -// }, -// ) - -// getMetaDatas, _ := situation.GetHistoryMetadata(id, ts1) -// if len(getMetaDatas) != 1 { -// t.Error("The number of MetaDatas is not as expected") -// } else { -// tasks[0].Perform( -// "key-2", -// models.InputTask{ -// SituationID: id, -// TS: ts1, -// Rule: models.RuleInput{ -// RuleID: 2, -// RuleVersion: 0, -// CasesInput: []models.CaseInput{ -// models.CaseInput{ -// Name: "case1", -// Condition: "true", -// State: models.Met, -// }, -// }, -// }, -// }, -// ) -// getMetaDatas, _ = situation.GetHistoryMetadata(id, ts1) -// if len(getMetaDatas) != 2 { -// t.Error("The number of MetaDatas is not as expected") -// } -// } -// } -// } - -func TestIssueTasks(t *testing.T) { - - if testing.Short() { - t.Skip("skipping postgresql test in short mode") - } - tests.CheckDebugLogs(t) - - db := tests.DBClient(t) - defer dbDestroy(db, t) - dbInit(db, t) - - postgres.ReplaceGlobals(db) - fact.ReplaceGlobals(fact.NewPostgresRepository(db)) - rule.ReplaceGlobals(rule.NewPostgresRepository(db)) - situation.ReplaceGlobals(situation.NewPostgresRepository(db)) - issues.ReplaceGlobals(issues.NewPostgresRepository(db)) - - calendar.ReplaceGlobals(calendar.NewPostgresRepository(db)) - calendar.Init() - - factID, _ := fact.R().Create(engine.Fact{Name: "fact_test_1"}) - - s := situation.Situation{Name: "situation_test", Facts: []int64{factID}} - sID, err := situation.R().Create(s) - if err != nil { - t.Error(err) - } - - ruleID, _ := rule.R().Create(rule.Rule{ - Name: "rule_test", - DefaultRule: ruleeng.DefaultRule{Cases: []ruleeng.Case{ - { - Name: "case1", - Condition: ruleeng.Expression("fact_test_1.aggs.agg0.value > 5"), - Actions: []ruleeng.ActionDef{{ - Name: ruleeng.Expression(`"create-issue"`), - Parameters: map[string]ruleeng.Expression{ - "id": ruleeng.Expression(`"task1"`), - "name": ruleeng.Expression(`"Issue_test"`), - "level": ruleeng.Expression(`"info"`), - "timeout": ruleeng.Expression(`"10s"`), - "isNotification": ruleeng.Expression(`false`), - }, - }}, - }, - { - Name: "case2", - Condition: ruleeng.Expression("fact_test_1.aggs.agg0.value <= 5"), - Actions: []ruleeng.ActionDef{{ - Name: ruleeng.Expression(`"close-today-issues"`), - Parameters: map[string]ruleeng.Expression{ - "id": ruleeng.Expression(`"task1"`), - }, - }}, - }, - }}, - Enabled: true, - }) - - situation.R().SetRules(sID, []int64{int64(ruleID)}) - - ReplaceGlobals(NewTasker()) - T().StartBatchProcessor() - defer T().StopBatchProcessor() - - t1 := time.Now() - situations := []evaluator.SituationToEvaluate{ - {ID: sID, TS: t1}, - } - item := &reader.Item{ - Key: "fact_test_1", - KeyAsString: "fact_test_1", - Aggs: map[string]*reader.ItemAgg{ - "agg0": {Value: 10}, - "doc_count": {Value: 1}, - }, - Buckets: nil, - } - sh := situation.HistoryRecord{ - ID: sID, - TS: t1, - FactsIDS: map[int64]*time.Time{factID: &t1}, - } - fact.PersistFactResult(1, t1, 0, 0, item, true) - situation.Persist(sh, false) - - evaluations, _ := evaluator.EvaluateSituations(situations, "standart") - taskBatchs := make([]TaskBatch, 0) - for _, evaluation := range evaluations { - taskBatchs = append(taskBatchs, TaskBatch{ - Context: map[string]interface{}{ - "situationID": evaluation.ID, - "ts": evaluation.TS, - "templateInstanceID": evaluation.TemplateInstanceID, - }, - Agenda: evaluation.Agenda, - }) - } - T().BatchReceiver <- taskBatchs - time.Sleep(100 * time.Millisecond) - - createdIssues, _ := issues.R().GetAll() - if createdIssues[1].Key != "1-1-task1" || createdIssues[1].State != models.Open { - t.Errorf("The created Issue is not as expected") - } - - tasks := evaluations[0].Agenda - if len(tasks) != 1 { - t.Errorf("The number of tasks is not as expected") - } - if tasks[0].GetName() != "create-issue" { - t.Errorf("The task is not as expected") - } - - t1 = time.Now() - situations = []evaluator.SituationToEvaluate{ - {ID: sID, TS: t1}, - } - item = &reader.Item{ - Key: "fact_test_1", - KeyAsString: "fact_test_1", - Aggs: map[string]*reader.ItemAgg{ - "agg0": {Value: 2}, - "doc_count": {Value: 1}, - }, - Buckets: nil, - } - sh = situation.HistoryRecord{ - ID: sID, - TS: t1, - FactsIDS: map[int64]*time.Time{factID: &t1}, - } - fact.PersistFactResult(1, t1, 0, 0, item, true) - situation.Persist(sh, false) - - evaluations, _ = evaluator.EvaluateSituations(situations, "standart") - for _, evaluation := range evaluations { - taskBatchs = append(taskBatchs, TaskBatch{ - Context: map[string]interface{}{ - "situationID": evaluation.ID, - "ts": evaluation.TS, - "templateInstanceID": evaluation.TemplateInstanceID, - }, - Agenda: evaluation.Agenda, - }) - } - T().BatchReceiver <- taskBatchs - time.Sleep(100 * time.Millisecond) - - tasks = evaluations[0].Agenda - if len(tasks) != 1 { - t.Errorf("The number of tasks is not as expected") - } - if tasks[0].GetName() != "close-today-issues" { - t.Errorf("The task is not as expected") - } - - createdIssues, _ = issues.R().GetAll() - if createdIssues[1].Key != "1-1-task1" || createdIssues[1].State != models.ClosedDiscard { - t.Errorf("The created Issue is not as expected") - } -} - -func TestTimezoneInCloseIssueTask(t *testing.T) { - - if testing.Short() { - t.Skip("skipping postgresql test in short mode") - } - tests.CheckDebugLogs(t) - - db := tests.DBClient(t) - defer dbDestroy(db, t) - dbInit(db, t) - - postgres.ReplaceGlobals(db) - fact.ReplaceGlobals(fact.NewPostgresRepository(db)) - rule.ReplaceGlobals(rule.NewPostgresRepository(db)) - situation.ReplaceGlobals(situation.NewPostgresRepository(db)) - issues.ReplaceGlobals(issues.NewPostgresRepository(db)) - - calendar.ReplaceGlobals(calendar.NewPostgresRepository(db)) - calendar.Init() - - factID, _ := fact.R().Create(engine.Fact{Name: "fact_test_1"}) - - s := situation.Situation{Name: "situation_test", Facts: []int64{factID}} - sID, err := situation.R().Create(s) - if err != nil { - t.Error(err) - } - - rule1 := rule.Rule{ - Name: "rule_test", - DefaultRule: ruleeng.DefaultRule{Cases: []ruleeng.Case{ - { - Name: "case1", - Condition: ruleeng.Expression("fact_test_1.aggs.agg0.value > 5"), - Actions: []ruleeng.ActionDef{{ - Name: ruleeng.Expression(`"create-issue"`), - Parameters: map[string]ruleeng.Expression{ - "id": ruleeng.Expression(`"task1"`), - "name": ruleeng.Expression(`"Issue_test"`), - "level": ruleeng.Expression(`"info"`), - "timeout": ruleeng.Expression(`"10s"`), - "isNotification": ruleeng.Expression(`false`), - }, - }}, - }, - { - Name: "case2", - Condition: ruleeng.Expression("fact_test_1.aggs.agg0.value <= 5"), - Actions: []ruleeng.ActionDef{{ - Name: ruleeng.Expression(`"close-today-issues"`), - Parameters: map[string]ruleeng.Expression{ - "id": ruleeng.Expression(`"task1"`), - }, - }}, - }, - }}, - Enabled: true, - } - ruleID, _ := rule.R().Create(rule1) - rule1.ID = ruleID - - situation.R().SetRules(sID, []int64{int64(ruleID)}) - - ReplaceGlobals(NewTasker()) - T().StartBatchProcessor() - defer T().StopBatchProcessor() - - loc, _ := time.LoadLocation("Europe/Paris") - now := time.Now().In(loc) - t1 := time.Date(now.Year(), now.Month(), now.Day(), 0, 10, 0, 0, loc) - situations := []evaluator.SituationToEvaluate{ - {ID: sID, TS: t1}, - } - item := &reader.Item{ - Key: "fact_test_1", - KeyAsString: "fact_test_1", - Aggs: map[string]*reader.ItemAgg{ - "agg0": {Value: 10}, - "doc_count": {Value: 1}, - }, - Buckets: nil, - } - sh := situation.HistoryRecord{ - ID: sID, - TS: t1, - FactsIDS: map[int64]*time.Time{factID: &t1}, - } - fact.PersistFactResult(1, t1, 0, 0, item, true) - situation.Persist(sh, false) - - evaluations, _ := evaluator.EvaluateSituations(situations, "standart") - taskBatchs := make([]TaskBatch, 0) - for _, evaluation := range evaluations { - taskBatchs = append(taskBatchs, TaskBatch{ - Context: map[string]interface{}{ - "situationID": evaluation.ID, - "ts": evaluation.TS, - "templateInstanceID": evaluation.TemplateInstanceID, - }, - Agenda: evaluation.Agenda, - }) - } - T().BatchReceiver <- taskBatchs - time.Sleep(100 * time.Millisecond) - - createdIssues, _ := issues.R().GetAll() - if createdIssues[1].Key != "1-1-task1" || createdIssues[1].State != models.Open { - t.Errorf("The created Issue is not as expected") - } - - tasks := evaluations[0].Agenda - if len(tasks) != 1 { - t.Errorf("The number of tasks is not as expected") - } - if tasks[0].GetName() != "create-issue" { - t.Errorf("The task is not as expected") - } - - tests.DBExec(db, `UPDATE issues_v1 SET created_at = '`+t1.UTC().Format("2006-01-02 15:04:05.000Z")+`' WHERE id = 1`, t, true) - - t1 = time.Now() - situations = []evaluator.SituationToEvaluate{ - {ID: sID, TS: t1}, - } - item = &reader.Item{ - Key: "fact_test_1", - KeyAsString: "fact_test_1", - Aggs: map[string]*reader.ItemAgg{ - "agg0": {Value: 2}, - "doc_count": {Value: 1}, - }, - Buckets: nil, - } - sh = situation.HistoryRecord{ - ID: sID, - TS: t1, - FactsIDS: map[int64]*time.Time{factID: &t1}, - } - fact.PersistFactResult(1, t1, 0, 0, item, true) - situation.Persist(sh, false) - - evaluations, _ = evaluator.EvaluateSituations(situations, "standart") - taskBatchs = make([]TaskBatch, 0) - for _, evaluation := range evaluations { - taskBatchs = append(taskBatchs, TaskBatch{ - Context: map[string]interface{}{ - "situationID": evaluation.ID, - "ts": evaluation.TS, - "templateInstanceID": evaluation.TemplateInstanceID, - }, - Agenda: evaluation.Agenda, - }) - } - T().BatchReceiver <- taskBatchs - time.Sleep(100 * time.Millisecond) - - tasks = evaluations[0].Agenda - if len(tasks) != 1 { - t.Errorf("The number of tasks is not as expected") - } - if tasks[0].GetName() != "close-today-issues" { - t.Errorf("The task is not as expected") - } - - createdIssues, _ = issues.R().GetAll() - if createdIssues[1].Key != "1-1-task1" || createdIssues[1].State != models.Open { - t.Errorf("The created Issue is not as expected") - } - - rule1.Cases[1].Actions[0].Parameters["timezone"] = "`Europe/Paris`" - _ = rule.R().Update(rule1) - - evaluations, _ = evaluator.EvaluateSituations(situations, "standart") - taskBatchs = make([]TaskBatch, 0) - for _, evaluation := range evaluations { - taskBatchs = append(taskBatchs, TaskBatch{ - Context: map[string]interface{}{ - "situationID": evaluation.ID, - "ts": evaluation.TS, - "templateInstanceID": evaluation.TemplateInstanceID, - }, - Agenda: evaluation.Agenda, - }) - } - T().BatchReceiver <- taskBatchs - time.Sleep(100 * time.Millisecond) - - tasks = evaluations[0].Agenda - if len(tasks) != 1 { - t.Errorf("The number of tasks is not as expected") - } - if tasks[0].GetName() != "close-today-issues" { - t.Errorf("The task is not as expected") - } - - createdIssues, _ = issues.R().GetAll() - if createdIssues[1].Key != "1-1-task1" || createdIssues[1].State != models.ClosedDiscard { - t.Errorf("The created Issue is not as expected") - } -} diff --git a/internals/tests/postgresql.go b/internals/tests/postgresql.go index 3bd44da1..918b0ddf 100644 --- a/internals/tests/postgresql.go +++ b/internals/tests/postgresql.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/jmoiron/sqlx" - "github.com/myrteametrics/myrtea-sdk/v4/postgres" + "github.com/myrteametrics/myrtea-sdk/v5/postgres" ) // DBClient returns a postgresql test client for integration tests diff --git a/main.go b/main.go index 415e4639..7e4373fd 100644 --- a/main.go +++ b/main.go @@ -17,8 +17,8 @@ import ( "github.com/myrteametrics/myrtea-engine-api/v5/internals/app" "github.com/myrteametrics/myrtea-engine-api/v5/internals/router" plugin "github.com/myrteametrics/myrtea-engine-api/v5/plugins" - "github.com/myrteametrics/myrtea-sdk/v4/helpers" - "github.com/myrteametrics/myrtea-sdk/v4/server" + "github.com/myrteametrics/myrtea-sdk/v5/helpers" + "github.com/myrteametrics/myrtea-sdk/v5/server" "github.com/spf13/viper" "go.uber.org/zap" ) diff --git a/plugins/assistant/Makefile b/plugins/assistant/Makefile deleted file mode 100644 index caa90e18..00000000 --- a/plugins/assistant/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -COMPONENT = assistant - -.PHONY: build -build: - protoc -I proto/ proto/$(COMPONENT).proto --go_out=plugins=grpc:proto/ \ No newline at end of file diff --git a/plugins/assistant/grpc.go b/plugins/assistant/grpc.go deleted file mode 100644 index c6f5dbb8..00000000 --- a/plugins/assistant/grpc.go +++ /dev/null @@ -1,68 +0,0 @@ -package assistant - -import ( - "github.com/hashicorp/go-plugin" - "github.com/myrteametrics/myrtea-engine-api/v5/plugins/assistant/proto" - "golang.org/x/net/context" - "google.golang.org/grpc" -) - -type AssistantGRPCPlugin struct { - // GRPCPlugin must still implement the Plugin interface - plugin.Plugin - // Concrete implementation, written in Go. This is only used for plugins that are written in Go. - Impl Assistant -} - -func (p *AssistantGRPCPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error { - proto.RegisterAssistantServer(s, &GRPCServer{Impl: p.Impl}) - return nil -} - -func (p *AssistantGRPCPlugin) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error) { - return &GRPCClient{client: proto.NewAssistantClient(c)}, nil -} - -// GRPCClient is an implementation of Assistant that talks over RPC. -type GRPCClient struct { - client proto.AssistantClient -} - -func (m *GRPCClient) SentenceProcess(ti string, message string, tokens [][]string) ([]byte, []string, error) { - - previousContext := make([]*proto.TokenizedSentence, 0) - for _, s := range tokens { - previousContext = append(previousContext, &proto.TokenizedSentence{Word: s}) - } - - resp, err := m.client.SentenceProcess(context.Background(), &proto.NLPSentenceRequest{ - Time: ti, - Message: message, - PreviousContext: previousContext, - }) - if err != nil { - return nil, nil, err - } - - return resp.Fact, resp.Tokens, nil -} - -type GRPCServer struct { - // This is the real implementation - Impl Assistant -} - -func (m *GRPCServer) SentenceProcess(ctx context.Context, req *proto.NLPSentenceRequest) (*proto.NLPSentenceResponse, error) { - - contextTokens := make([][]string, 0) - for _, s := range req.PreviousContext { - contextTokens = append(contextTokens, s.Word) - } - - f, tokens, err := m.Impl.SentenceProcess(req.Time, req.Message, contextTokens) - if err != nil { - return nil, err - } - - return &proto.NLPSentenceResponse{Fact: f, Tokens: tokens}, nil -} diff --git a/plugins/assistant/handlers.go b/plugins/assistant/handlers.go deleted file mode 100644 index f1889db1..00000000 --- a/plugins/assistant/handlers.go +++ /dev/null @@ -1,196 +0,0 @@ -package assistant - -import ( - "encoding/json" - "errors" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/handlers/render" - "net/http" - "time" - - "github.com/go-chi/chi/v5" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/fact" - "github.com/myrteametrics/myrtea-engine-api/v5/internals/reader" - "github.com/myrteametrics/myrtea-sdk/v4/engine" - "github.com/myrteametrics/myrtea-sdk/v4/postgres" - "go.uber.org/zap" -) - -func (p *AssistantPlugin) Handler() http.Handler { - r := chi.NewRouter() - - r.Post("/message", p.SendMessage) // ?time=2019-05-10T12:00:00.000 - - return r -} - -// Message represents an input raw message with its contexts -type Message struct { - Sentence string `json:"sentence"` - ContextTokens [][]string `json:"contextTokens"` -} - -// SendMessage godoc -// @Summary Sends a message to the myrtea Assistant. -// @Description Sends a message to the myrtea Assistant. -// @Tags Assistant -// @Accept json -// @Produce json -// @Param time query string true "Timestamp" -// @Param sentence body interface{} true "User sentence and context Tokens" -// @Param debug query string false "Enable log debugging" -// @Security Bearer -// @Success 200 "Status OK" -// @Failure 400 "Status Bad Request" -// @Failure 500 "Status Internal Server Error" -// @Router /assistant/message [post] -func (p *AssistantPlugin) SendMessage(w http.ResponseWriter, r *http.Request) { - - // TODO: Refactoring for cleaner code separation - receiveTs := time.Now().Truncate(1 * time.Millisecond).UTC() - - t, err := p.parseTime(r.URL.Query().Get("time")) - if err != nil { - zap.L().Warn("Parse input time", zap.Error(err)) - err = PersistInteractionTrace(receiveTs, t, nil, nil, nil, nil, err) - if err != nil { - zap.L().Warn("Persist interaction trace", zap.Error(err)) - } - render.Error(w, r, render.ErrAPIParsingDateTime, err) - return - } - - // debug := false - // _debug := r.URL.Query().Get("debug") - // if _debug == "true" { - // debug = true - // } - - var message Message - err = json.NewDecoder(r.Body).Decode(&message) - if err != nil { - zap.L().Warn("assistant message json decode", zap.Error(err)) - err := PersistInteractionTrace(receiveTs, t, nil, nil, nil, nil, err) - if err != nil { - zap.L().Warn("Persist interaction trace", zap.Error(err)) - } - render.Error(w, r, render.ErrAPIDecodeJSONBody, err) - return - } - - // f, nlp, err := assistant.C().ProcessMessage(t, message) - bFact, nlpTokens, err := p.Assistant.SentenceProcess(t.Format("2006-01-02T15:04:05.000Z07:00"), message.Sentence, nil) - if err != nil { - zap.L().Warn("NL Process sentence", zap.Error(err)) - render.Error(w, r, render.ErrAPIProcessError, err) - return - } - - var f engine.Fact - err = json.Unmarshal(bFact, &f) - if err != nil { - zap.L().Warn("Fact unmarshal", zap.Error(err)) - render.Error(w, r, render.ErrAPIDecodeJSONBody, err) - return - } - - for _, dim := range f.Dimensions { - dim.DateInterval = "1h" - } - - widgetData, err := fact.ExecuteFact(t, f, 0, 0, nil, -1, -1, false) - if err != nil { - zap.L().Error("Cannot execute fact", zap.Error(err)) - err := PersistInteractionTrace(receiveTs, t, &message, &nlpTokens, &f, nil, err) - if err != nil { - zap.L().Warn("Persist interaction trace", zap.Error(err)) - } - return - } - - err = PersistInteractionTrace(receiveTs, t, &message, &nlpTokens, &f, widgetData.Aggregates, err) - if err != nil { - zap.L().Warn("Persist interaction trace", zap.Error(err)) - } - - render.JSON(w, r, &AssistantResponse{ - Result: widgetData, - Tokens: nlpTokens, - }) -} - -// AssistantResponse reflcts the response format of the assistant -type AssistantResponse struct { - Result *reader.WidgetData `json:"result"` - Tokens []string `json:"tokens"` -} - -// PersistInteractionTrace store a trace of the assistant interaction in postgresql -func PersistInteractionTrace(receiveTs time.Time, askedTs time.Time, message *Message, nlpTokens *[]string, fact *engine.Fact, result *reader.Item, pipelineErr error) error { - - if postgres.DB() == nil { - return errors.New("db Client is not initialized") - } - - params := map[string]interface{}{ - "input_ts": receiveTs, - "asked_ts": askedTs, - "input_sentence": nil, - "input_context_tokens": nil, - "nlp_tokens": nil, - "fact": nil, - "result": nil, - "end_ts": time.Now().Truncate(1 * time.Millisecond).UTC(), - "success": false, - "error": nil, - } - - if message != nil { - params["input_sentence"] = message.Sentence - if len(message.ContextTokens) > 0 { - params["input_context_tokens"] = message.ContextTokens[0] - } - } - - if pipelineErr == nil { - params["success"] = true - } else { - params["success"] = false - params["error"] = pipelineErr.Error() - } - - if factJSON, err := json.Marshal(fact); err == nil { - params["fact"] = factJSON - } - if resultJSON, err := json.Marshal(result); err == nil { - params["result"] = resultJSON - } - - query := ` - INSERT INTO interaction_history_v1(id, input_ts, asked_ts, input_sentence, input_context_tokens, nlp_tokens, fact, result, end_ts, success, error) - VALUES (DEFAULT, :input_ts, :asked_ts, :input_sentence, :input_context_tokens, :nlp_tokens, :fact, :result, :end_ts, :success, :error)` - - res, err := postgres.DB().NamedExec(query, params) - if err != nil { - zap.L().Error("Insert interaction history V1", zap.Error(err)) - return err - } - i, err := res.RowsAffected() - if err != nil { - zap.L().Error("Insert interaction history V1", zap.Error(err)) - return err - } - if i != 1 { - zap.L().Error("Insert interaction history V1", zap.Error(errors.New("no row inserted (or multiple row inserted) instead of 1 row"))) - return errors.New("no row inserted (or multiple row inserted) instead of 1 row") - } - return nil -} - -// parseTime try to parse a supposed time string as a time.Time or returns time.Now() -func (p *AssistantPlugin) parseTime(tStr string) (time.Time, error) { - t, err := time.Parse("2006-01-02T15:04:05.000Z07:00", tStr) - if err != nil { - return time.Now().UTC(), err - } - return t, nil -} diff --git a/plugins/assistant/interface.go b/plugins/assistant/interface.go deleted file mode 100644 index a8c87f84..00000000 --- a/plugins/assistant/interface.go +++ /dev/null @@ -1,6 +0,0 @@ -package assistant - -// Assistant is the interface that we're exposing as a plugin. -type Assistant interface { - SentenceProcess(string, string, [][]string) ([]byte, []string, error) -} diff --git a/plugins/assistant/plugin.go b/plugins/assistant/plugin.go deleted file mode 100644 index d3e66b71..00000000 --- a/plugins/assistant/plugin.go +++ /dev/null @@ -1,162 +0,0 @@ -package assistant - -import ( - "encoding/json" - "errors" - "fmt" - "github.com/myrteametrics/myrtea-engine-api/v5/plugins/pluginutils" - "os" - "os/exec" - "runtime" - "sync" - - "github.com/hashicorp/go-plugin" - "github.com/myrteametrics/myrtea-sdk/v4/engine" - "go.uber.org/zap" -) - -var ( - _globalPluginMu sync.RWMutex - _globalPlugin *AssistantPlugin -) - -// P is used to access the global plugin singleton -func P() (*AssistantPlugin, error) { - _globalPluginMu.RLock() - defer _globalPluginMu.RUnlock() - - plugin := _globalPlugin - if plugin == nil { - return nil, errors.New("no Assistant plugin found, feature is not available") - } - return plugin, nil -} - -func Register(plugin *AssistantPlugin) func() { - _globalPluginMu.Lock() - defer _globalPluginMu.Unlock() - - prev := _globalPlugin - _globalPlugin = plugin - return func() { Register(prev) } -} - -// Handshake is a common handshake that is shared by plugin and host. -var Handshake = plugin.HandshakeConfig{ - // This isn't required when using VersionedPlugins - ProtocolVersion: 1, - MagicCookieKey: "BASIC_PLUGIN", - MagicCookieValue: "hello", -} - -type AssistantPlugin struct { - Config pluginutils.PluginConfig - ClientConfig *plugin.ClientConfig - Client *plugin.Client - Assistant Assistant -} - -func NewAssistantPlugin(config pluginutils.PluginConfig) *AssistantPlugin { - pluginPath := fmt.Sprintf("plugin/myrtea-%s.plugin", config.Name) - - stat, err := os.Stat(pluginPath) - if os.IsNotExist(err) || stat.IsDir() { - zap.L().Warn("Couldn't find plugin binaries", zap.String("pluginName", "assistant"), - zap.String("pluginPath", pluginPath)) - return nil - } - - return &AssistantPlugin{ - Config: config, - } -} - -func (p *AssistantPlugin) init() { - pluginPath := fmt.Sprintf("plugin/myrtea-%s.plugin", p.Config.Name) - - var cmd *exec.Cmd - if runtime.GOOS != "windows" { - cmd = exec.Command("sh", "-c", pluginPath) - } else { - cmd = exec.Command(pluginPath) - } - cmd.Env = os.Environ() - // cmd.Env = append(cmd.Env, "MYRTEA_ASSISTANT_DEBUG_MODE=true") - - pluginMap := map[string]plugin.Plugin{ - p.Config.Name: &AssistantGRPCPlugin{}, - } - - p.ClientConfig = &plugin.ClientConfig{ - HandshakeConfig: Handshake, - Plugins: pluginMap, - Cmd: cmd, - AllowedProtocols: []plugin.Protocol{plugin.ProtocolGRPC}, - } -} - -func (p *AssistantPlugin) HandlerPrefix() string { - return fmt.Sprintf("/%s", p.Config.Name) -} - -func (p *AssistantPlugin) ServicePort() int { - return p.Config.Port -} - -func (p *AssistantPlugin) Stop() error { - p.Client.Kill() - return nil -} - -func (p *AssistantPlugin) Start() error { - if p.Running() { - return errors.New("plugin is already running") - } - - p.init() - - client := plugin.NewClient(p.ClientConfig) - - rpcClient, err := client.Client() - if err != nil { - zap.L().Error("Initialize rpc client", zap.String("module", p.Config.Name), zap.Error(err)) - return err - } - - raw, err := rpcClient.Dispense(p.Config.Name) - if err != nil { - zap.L().Error("Dispense plugin", zap.String("module", p.Config.Name), zap.Error(err)) - return err - } - - p.Assistant = raw.(Assistant) - p.Client = client - - Register(p) - - return nil -} - -func (p *AssistantPlugin) Running() bool { - return p.Client != nil && !p.Client.Exited() -} - -func (p *AssistantPlugin) Test() { - bFact, tokens, err := p.Assistant.SentenceProcess( - "2020-10-03T12:30:00.000+02:00", - "combien de colis pour client france", - [][]string{{"combien", "colis", "for", "country", "espagne"}}, - ) - if err != nil { - fmt.Println(err) - } - - var f engine.Fact - err = json.Unmarshal(bFact, &f) - if err != nil { - fmt.Println("error", err.Error()) - os.Exit(1) - } - - zap.L().Info("process", zap.Any("fact", f), zap.Any("tokens", tokens)) -} diff --git a/plugins/assistant/proto/assistant.pb.go b/plugins/assistant/proto/assistant.pb.go deleted file mode 100644 index 013db6b9..00000000 --- a/plugins/assistant/proto/assistant.pb.go +++ /dev/null @@ -1,314 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// source: assistant.proto - -package proto - -import ( - context "context" - fmt "fmt" - proto "github.com/golang/protobuf/proto" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - math "math" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package - -type NLPSentenceRequest struct { - Time string `protobuf:"bytes,1,opt,name=time,proto3" json:"time,omitempty"` - Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` - PreviousContext []*TokenizedSentence `protobuf:"bytes,3,rep,name=previousContext,proto3" json:"previousContext,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *NLPSentenceRequest) Reset() { *m = NLPSentenceRequest{} } -func (m *NLPSentenceRequest) String() string { return proto.CompactTextString(m) } -func (*NLPSentenceRequest) ProtoMessage() {} -func (*NLPSentenceRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_04466eecc6514430, []int{0} -} - -func (m *NLPSentenceRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_NLPSentenceRequest.Unmarshal(m, b) -} -func (m *NLPSentenceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_NLPSentenceRequest.Marshal(b, m, deterministic) -} -func (m *NLPSentenceRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_NLPSentenceRequest.Merge(m, src) -} -func (m *NLPSentenceRequest) XXX_Size() int { - return xxx_messageInfo_NLPSentenceRequest.Size(m) -} -func (m *NLPSentenceRequest) XXX_DiscardUnknown() { - xxx_messageInfo_NLPSentenceRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_NLPSentenceRequest proto.InternalMessageInfo - -func (m *NLPSentenceRequest) GetTime() string { - if m != nil { - return m.Time - } - return "" -} - -func (m *NLPSentenceRequest) GetMessage() string { - if m != nil { - return m.Message - } - return "" -} - -func (m *NLPSentenceRequest) GetPreviousContext() []*TokenizedSentence { - if m != nil { - return m.PreviousContext - } - return nil -} - -type TokenizedSentence struct { - Word []string `protobuf:"bytes,1,rep,name=word,proto3" json:"word,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *TokenizedSentence) Reset() { *m = TokenizedSentence{} } -func (m *TokenizedSentence) String() string { return proto.CompactTextString(m) } -func (*TokenizedSentence) ProtoMessage() {} -func (*TokenizedSentence) Descriptor() ([]byte, []int) { - return fileDescriptor_04466eecc6514430, []int{1} -} - -func (m *TokenizedSentence) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_TokenizedSentence.Unmarshal(m, b) -} -func (m *TokenizedSentence) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_TokenizedSentence.Marshal(b, m, deterministic) -} -func (m *TokenizedSentence) XXX_Merge(src proto.Message) { - xxx_messageInfo_TokenizedSentence.Merge(m, src) -} -func (m *TokenizedSentence) XXX_Size() int { - return xxx_messageInfo_TokenizedSentence.Size(m) -} -func (m *TokenizedSentence) XXX_DiscardUnknown() { - xxx_messageInfo_TokenizedSentence.DiscardUnknown(m) -} - -var xxx_messageInfo_TokenizedSentence proto.InternalMessageInfo - -func (m *TokenizedSentence) GetWord() []string { - if m != nil { - return m.Word - } - return nil -} - -type AssistantMessage struct { - Sentence string `protobuf:"bytes,1,opt,name=sentence,proto3" json:"sentence,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *AssistantMessage) Reset() { *m = AssistantMessage{} } -func (m *AssistantMessage) String() string { return proto.CompactTextString(m) } -func (*AssistantMessage) ProtoMessage() {} -func (*AssistantMessage) Descriptor() ([]byte, []int) { - return fileDescriptor_04466eecc6514430, []int{2} -} - -func (m *AssistantMessage) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_AssistantMessage.Unmarshal(m, b) -} -func (m *AssistantMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_AssistantMessage.Marshal(b, m, deterministic) -} -func (m *AssistantMessage) XXX_Merge(src proto.Message) { - xxx_messageInfo_AssistantMessage.Merge(m, src) -} -func (m *AssistantMessage) XXX_Size() int { - return xxx_messageInfo_AssistantMessage.Size(m) -} -func (m *AssistantMessage) XXX_DiscardUnknown() { - xxx_messageInfo_AssistantMessage.DiscardUnknown(m) -} - -var xxx_messageInfo_AssistantMessage proto.InternalMessageInfo - -func (m *AssistantMessage) GetSentence() string { - if m != nil { - return m.Sentence - } - return "" -} - -type NLPSentenceResponse struct { - Fact []byte `protobuf:"bytes,1,opt,name=fact,proto3" json:"fact,omitempty"` - Tokens []string `protobuf:"bytes,2,rep,name=tokens,proto3" json:"tokens,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *NLPSentenceResponse) Reset() { *m = NLPSentenceResponse{} } -func (m *NLPSentenceResponse) String() string { return proto.CompactTextString(m) } -func (*NLPSentenceResponse) ProtoMessage() {} -func (*NLPSentenceResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_04466eecc6514430, []int{3} -} - -func (m *NLPSentenceResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_NLPSentenceResponse.Unmarshal(m, b) -} -func (m *NLPSentenceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_NLPSentenceResponse.Marshal(b, m, deterministic) -} -func (m *NLPSentenceResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_NLPSentenceResponse.Merge(m, src) -} -func (m *NLPSentenceResponse) XXX_Size() int { - return xxx_messageInfo_NLPSentenceResponse.Size(m) -} -func (m *NLPSentenceResponse) XXX_DiscardUnknown() { - xxx_messageInfo_NLPSentenceResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_NLPSentenceResponse proto.InternalMessageInfo - -func (m *NLPSentenceResponse) GetFact() []byte { - if m != nil { - return m.Fact - } - return nil -} - -func (m *NLPSentenceResponse) GetTokens() []string { - if m != nil { - return m.Tokens - } - return nil -} - -func init() { - proto.RegisterType((*NLPSentenceRequest)(nil), "proto.NLPSentenceRequest") - proto.RegisterType((*TokenizedSentence)(nil), "proto.TokenizedSentence") - proto.RegisterType((*AssistantMessage)(nil), "proto.AssistantMessage") - proto.RegisterType((*NLPSentenceResponse)(nil), "proto.NLPSentenceResponse") -} - -func init() { proto.RegisterFile("assistant.proto", fileDescriptor_04466eecc6514430) } - -var fileDescriptor_04466eecc6514430 = []byte{ - // 254 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x90, 0xcf, 0x4e, 0x83, 0x40, - 0x10, 0xc6, 0x43, 0xd1, 0x6a, 0x47, 0x13, 0x74, 0x4c, 0xcc, 0xca, 0x89, 0x70, 0xb1, 0x27, 0x0e, - 0xf5, 0x09, 0xaa, 0x17, 0x0f, 0x6a, 0x1a, 0xd4, 0x07, 0x40, 0x3a, 0x1a, 0x62, 0xba, 0x8b, 0xcc, - 0x54, 0x8d, 0x0f, 0xe0, 0x73, 0x9b, 0x9d, 0x2e, 0x24, 0x5a, 0x4f, 0xcc, 0xc7, 0xfc, 0xf9, 0x7e, - 0xdf, 0x42, 0x52, 0x31, 0x37, 0x2c, 0x95, 0x95, 0xa2, 0xed, 0x9c, 0x38, 0xdc, 0xd5, 0x4f, 0xfe, - 0x1d, 0x01, 0xde, 0xdd, 0x2c, 0xee, 0xc9, 0x0a, 0xd9, 0x9a, 0x4a, 0x7a, 0x5b, 0x13, 0x0b, 0x22, - 0xec, 0x48, 0xb3, 0x22, 0x13, 0x65, 0xd1, 0x74, 0x52, 0x6a, 0x8d, 0x06, 0xf6, 0x56, 0xc4, 0x5c, - 0xbd, 0x90, 0x19, 0xe9, 0xef, 0x5e, 0xe2, 0x25, 0x24, 0x6d, 0x47, 0xef, 0x8d, 0x5b, 0xf3, 0x95, - 0xb3, 0x42, 0x9f, 0x62, 0xe2, 0x2c, 0x9e, 0x1e, 0xcc, 0xcc, 0xc6, 0xac, 0x78, 0x70, 0xaf, 0x64, - 0x9b, 0x2f, 0x5a, 0x0e, 0x3e, 0x7f, 0x17, 0xf2, 0x73, 0x38, 0xde, 0x9a, 0xf2, 0x18, 0x1f, 0xae, - 0x5b, 0x9a, 0x28, 0x8b, 0x3d, 0x86, 0xaf, 0xf3, 0x02, 0x8e, 0xe6, 0x7d, 0x96, 0xdb, 0x00, 0x90, - 0xc2, 0x3e, 0x87, 0x9d, 0x80, 0x3c, 0xe8, 0x7c, 0x0e, 0x27, 0xbf, 0x02, 0x72, 0xeb, 0x2c, 0xeb, - 0xe9, 0xe7, 0xaa, 0x16, 0x1d, 0x3f, 0x2c, 0xb5, 0xc6, 0x53, 0x18, 0x8b, 0x67, 0x60, 0x33, 0x52, - 0xc3, 0xa0, 0x66, 0x8f, 0x30, 0x19, 0x2c, 0xf1, 0x1a, 0x92, 0xfe, 0xd8, 0xa2, 0x73, 0x35, 0x31, - 0xe3, 0x59, 0x88, 0xb9, 0xfd, 0x90, 0x69, 0xfa, 0x5f, 0x6b, 0x83, 0xf0, 0x34, 0xd6, 0xd6, 0xc5, - 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x24, 0x98, 0x1d, 0x75, 0x9c, 0x01, 0x00, 0x00, -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// AssistantClient is the client API for Assistant service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type AssistantClient interface { - SentenceProcess(ctx context.Context, in *NLPSentenceRequest, opts ...grpc.CallOption) (*NLPSentenceResponse, error) -} - -type assistantClient struct { - cc *grpc.ClientConn -} - -func NewAssistantClient(cc *grpc.ClientConn) AssistantClient { - return &assistantClient{cc} -} - -func (c *assistantClient) SentenceProcess(ctx context.Context, in *NLPSentenceRequest, opts ...grpc.CallOption) (*NLPSentenceResponse, error) { - out := new(NLPSentenceResponse) - err := c.cc.Invoke(ctx, "/proto.Assistant/SentenceProcess", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// AssistantServer is the server API for Assistant service. -type AssistantServer interface { - SentenceProcess(context.Context, *NLPSentenceRequest) (*NLPSentenceResponse, error) -} - -// UnimplementedAssistantServer can be embedded to have forward compatible implementations. -type UnimplementedAssistantServer struct { -} - -func (*UnimplementedAssistantServer) SentenceProcess(ctx context.Context, req *NLPSentenceRequest) (*NLPSentenceResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method SentenceProcess not implemented") -} - -func RegisterAssistantServer(s *grpc.Server, srv AssistantServer) { - s.RegisterService(&_Assistant_serviceDesc, srv) -} - -func _Assistant_SentenceProcess_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(NLPSentenceRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(AssistantServer).SentenceProcess(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/proto.Assistant/SentenceProcess", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(AssistantServer).SentenceProcess(ctx, req.(*NLPSentenceRequest)) - } - return interceptor(ctx, in, info, handler) -} - -var _Assistant_serviceDesc = grpc.ServiceDesc{ - ServiceName: "proto.Assistant", - HandlerType: (*AssistantServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "SentenceProcess", - Handler: _Assistant_SentenceProcess_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "assistant.proto", -} diff --git a/plugins/assistant/proto/assistant.proto b/plugins/assistant/proto/assistant.proto deleted file mode 100644 index abc33693..00000000 --- a/plugins/assistant/proto/assistant.proto +++ /dev/null @@ -1,25 +0,0 @@ -syntax = "proto3"; -package proto; - -message NLPSentenceRequest { - string time = 1; - string message = 2; - repeated TokenizedSentence previousContext = 3; -} - -message TokenizedSentence { - repeated string word = 1; -} - -message AssistantMessage { - string sentence = 1; -} - -message NLPSentenceResponse { - bytes fact = 1; - repeated string tokens = 2; -} - -service Assistant { - rpc SentenceProcess(NLPSentenceRequest) returns (NLPSentenceResponse); -} diff --git a/plugins/baseline/grpc.go b/plugins/baseline/grpc.go index 3c8438f3..b985338b 100644 --- a/plugins/baseline/grpc.go +++ b/plugins/baseline/grpc.go @@ -1,9 +1,9 @@ package baseline import ( + "google.golang.org/protobuf/types/known/emptypb" "time" - "github.com/golang/protobuf/ptypes/empty" "github.com/hashicorp/go-plugin" "github.com/myrteametrics/myrtea-engine-api/v5/plugins/baseline/proto" "go.uber.org/zap" @@ -111,7 +111,7 @@ func (m *GRPCServer) GetBaselineValues(ctx context.Context, req *proto.BaselineV return &proto.BaselineValues{Values: baselineValues}, err } -func (m *GRPCServer) BuildBaselineValues(ctx context.Context, req *proto.BuildBaselineRequest) (*empty.Empty, error) { +func (m *GRPCServer) BuildBaselineValues(ctx context.Context, req *proto.BuildBaselineRequest) (*emptypb.Empty, error) { err := m.Impl.BuildBaselineValues(req.Id) - return &empty.Empty{}, err + return &emptypb.Empty{}, err } diff --git a/plugins/baseline/proto/baseline.pb.go b/plugins/baseline/proto/baseline.pb.go index 6cabb8a4..c90e5c48 100644 --- a/plugins/baseline/proto/baseline.pb.go +++ b/plugins/baseline/proto/baseline.pb.go @@ -1,15 +1,15 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.6.1 +// protoc-gen-go v1.32.0 +// protoc v3.19.4 // source: proto/baseline.proto package proto import ( - empty "github.com/golang/protobuf/ptypes/empty" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + emptypb "google.golang.org/protobuf/types/known/emptypb" reflect "reflect" sync "sync" ) @@ -367,7 +367,7 @@ var file_proto_baseline_proto_goTypes = []interface{}{ (*BaselineValue)(nil), // 2: proto.BaselineValue (*BaselineValues)(nil), // 3: proto.BaselineValues nil, // 4: proto.BaselineValues.ValuesEntry - (*empty.Empty)(nil), // 5: google.protobuf.Empty + (*emptypb.Empty)(nil), // 5: google.protobuf.Empty } var file_proto_baseline_proto_depIdxs = []int32{ 4, // 0: proto.BaselineValues.values:type_name -> proto.BaselineValues.ValuesEntry diff --git a/plugins/baseline/proto/baseline_grpc.pb.go b/plugins/baseline/proto/baseline_grpc.pb.go index dbbbeee6..4130d16c 100644 --- a/plugins/baseline/proto/baseline_grpc.pb.go +++ b/plugins/baseline/proto/baseline_grpc.pb.go @@ -1,18 +1,17 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.2.0 -// - protoc v3.6.1 +// - protoc-gen-go-grpc v1.3.0 +// - protoc v3.19.4 // source: proto/baseline.proto package proto import ( context "context" - - empty "github.com/golang/protobuf/ptypes/empty" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" + emptypb "google.golang.org/protobuf/types/known/emptypb" ) // This is a compile-time assertion to ensure that this generated file @@ -20,13 +19,18 @@ import ( // Requires gRPC-Go v1.32.0 or later. const _ = grpc.SupportPackageIsVersion7 +const ( + Baseline_GetBaselineValues_FullMethodName = "/proto.Baseline/GetBaselineValues" + Baseline_BuildBaselineValues_FullMethodName = "/proto.Baseline/BuildBaselineValues" +) + // BaselineClient is the client API for Baseline service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. type BaselineClient interface { // rpc GetBaselineValue(BaselineValueRequest) returns (BaselineValue) GetBaselineValues(ctx context.Context, in *BaselineValueRequest, opts ...grpc.CallOption) (*BaselineValues, error) - BuildBaselineValues(ctx context.Context, in *BuildBaselineRequest, opts ...grpc.CallOption) (*empty.Empty, error) + BuildBaselineValues(ctx context.Context, in *BuildBaselineRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) } type baselineClient struct { @@ -39,16 +43,16 @@ func NewBaselineClient(cc grpc.ClientConnInterface) BaselineClient { func (c *baselineClient) GetBaselineValues(ctx context.Context, in *BaselineValueRequest, opts ...grpc.CallOption) (*BaselineValues, error) { out := new(BaselineValues) - err := c.cc.Invoke(ctx, "/proto.Baseline/GetBaselineValues", in, out, opts...) + err := c.cc.Invoke(ctx, Baseline_GetBaselineValues_FullMethodName, in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *baselineClient) BuildBaselineValues(ctx context.Context, in *BuildBaselineRequest, opts ...grpc.CallOption) (*empty.Empty, error) { - out := new(empty.Empty) - err := c.cc.Invoke(ctx, "/proto.Baseline/BuildBaselineValues", in, out, opts...) +func (c *baselineClient) BuildBaselineValues(ctx context.Context, in *BuildBaselineRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) { + out := new(emptypb.Empty) + err := c.cc.Invoke(ctx, Baseline_BuildBaselineValues_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -61,7 +65,7 @@ func (c *baselineClient) BuildBaselineValues(ctx context.Context, in *BuildBasel type BaselineServer interface { // rpc GetBaselineValue(BaselineValueRequest) returns (BaselineValue) GetBaselineValues(context.Context, *BaselineValueRequest) (*BaselineValues, error) - BuildBaselineValues(context.Context, *BuildBaselineRequest) (*empty.Empty, error) + BuildBaselineValues(context.Context, *BuildBaselineRequest) (*emptypb.Empty, error) mustEmbedUnimplementedBaselineServer() } @@ -72,7 +76,7 @@ type UnimplementedBaselineServer struct { func (UnimplementedBaselineServer) GetBaselineValues(context.Context, *BaselineValueRequest) (*BaselineValues, error) { return nil, status.Errorf(codes.Unimplemented, "method GetBaselineValues not implemented") } -func (UnimplementedBaselineServer) BuildBaselineValues(context.Context, *BuildBaselineRequest) (*empty.Empty, error) { +func (UnimplementedBaselineServer) BuildBaselineValues(context.Context, *BuildBaselineRequest) (*emptypb.Empty, error) { return nil, status.Errorf(codes.Unimplemented, "method BuildBaselineValues not implemented") } func (UnimplementedBaselineServer) mustEmbedUnimplementedBaselineServer() {} @@ -98,7 +102,7 @@ func _Baseline_GetBaselineValues_Handler(srv interface{}, ctx context.Context, d } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/proto.Baseline/GetBaselineValues", + FullMethod: Baseline_GetBaselineValues_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(BaselineServer).GetBaselineValues(ctx, req.(*BaselineValueRequest)) @@ -116,7 +120,7 @@ func _Baseline_BuildBaselineValues_Handler(srv interface{}, ctx context.Context, } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/proto.Baseline/BuildBaselineValues", + FullMethod: Baseline_BuildBaselineValues_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(BaselineServer).BuildBaselineValues(ctx, req.(*BuildBaselineRequest)) diff --git a/plugins/config/assistant.toml b/plugins/config/assistant.toml deleted file mode 100644 index 6c626a93..00000000 --- a/plugins/config/assistant.toml +++ /dev/null @@ -1,106 +0,0 @@ -### DO NOT COMMIT ANY ENVIRONMENT CHANGE ON THIS FILE -### If you need to use another environment, edit this file localy, and do not propagate the changes. - -# Enable or disable debug mode -# Debug mode print all configuration variables when the binary start -# WARNING: every single variable will be printed, including password or sensitive data -# Default value: "false" -DEBUG_MODE = "false" - -# Enable or disable production log -# Default value: true -LOGGER_PRODUCTION = "true" - -# Specify the server running port. API (including swagger) will be reachable through this port -# Default value: "9081" -SERVER_PORT = "9081" - -# Enable or disable TLS and HTTPS server security (false = HTTPS / true = HTTP) -# If SERVER_ENABLE_TLS = true, SERVER_SSL_FILE_CRT and SERVER_SSL_FILE_KEY must be specified -# Default value: "false" -SERVER_ENABLE_TLS = "false" - -# TLS certificate file path -# Default value: "certs/server.rsa.crt" -SERVER_TLS_FILE_CRT = "certs/server.rsa.crt" - -# TLS private key file path -# Default value: "certs/server.rsa.key" -SERVER_TLS_FILE_KEY = "certs/server.rsa.key" - -# Enable or Disable CORS policy on the API -# See https://enable-cors.org/ -# Default value: "false" -API_ENABLE_CORS = "false" - -# Enable or Disable API security -# If unsecured = false, a valid JWT (JSON Web Token) is required to access the API -# This JWT is delivered using the /login endpoint (which required a login and a password) -# If API_ENABLE_SECURITY = false, no JWT is required and all endpoints can be called freely -# Default value: "true" -API_ENABLE_SECURITY = "true" - -# Enable or Disable API Gateway mode -# If API_ENABLE_GATEWAY_MODE = true, the API will still required a JWT but no validation will be done on this JWT -# Be aware that in gateway mode, every JWT MUST have been validated by another layer of security (in this case, an API Gateway using the auth-api) -# The auth-api will be responsible to deliver the tokens (/login) and to validate the tokens (/validate) -# Default value: "false" -API_ENABLE_GATEWAY_MODE = "false" - -# Specify the instance name -# The instance name must be the same in every components in the stack to ensure proper working conditions -# Default value: "myrtea" -INSTANCE_NAME = "myrtea" - -# Specify the hostname used to access the swagger UI -# If not set (or incorrect), the swagger UI will be available but will not be usable (using execute on endpoints) -# Default value: "localhost:9081" -SWAGGER_HOST = "localhost:9081" - -# Specify the basepath used to access the swagger UI -# If not set (or incorrect), the swagger UI will be available but will not be usable (using execute on endpoints) -# Default value: "/api/v4" -SWAGGER_BASEPATH = "/api/v4" - -# Specify the elasticsearch URLS -# Array of URLS might not work using environment variable (should be fixed soon) -# Default value: "http://localhost:9200" -ELASTICSEARCH_URLS = ["http://localhost:9200"] - -# Specify the postgresql host name -# Default value: "localhost" -POSTGRESQL_HOSTNAME = "localhost" - -# Specify the postgresql port -# Default value: "5432" -POSTGRESQL_PORT = "5432" - -# Specify the postgresql database name -# Default value: "postgres" -POSTGRESQL_DBNAME = "postgres" - -# Specify the postgresql user name -# Default value: "postgres" -POSTGRESQL_USERNAME = "postgres" - -# Specify the postgresql user password -# Default value: "postgres" -POSTGRESQL_PASSWORD = "postgres" - -# Specify the postgresql connection pool maximum open connection -# Default value: "6" -POSTGRESQL_CONN_POOL_MAX_OPEN = "6" - -# Specify the postgresql connection pool maximum idle connection -# Default value: "3" -POSTGRESQL_CONN_POOL_MAX_IDLE = "3" - -# Specify the postgresql connection pool maximum idle connection -# Expressed as a Golang duration -# Default value: "0" -POSTGRESQL_CONN_MAX_LIFETIME = "0" - -# Enable or disable crons automation on API start -# Warning: Keep this parameter to "true" in production to ensure proper rotation even after a restart -# Default value: "true" -ENABLE_CRONS_ON_START = "true" diff --git a/plugins/core.go b/plugins/core.go index 357aa7d5..f3aab978 100644 --- a/plugins/core.go +++ b/plugins/core.go @@ -2,7 +2,6 @@ package plugin import ( "fmt" - "github.com/myrteametrics/myrtea-engine-api/v5/plugins/assistant" "github.com/myrteametrics/myrtea-engine-api/v5/plugins/baseline" "github.com/myrteametrics/myrtea-engine-api/v5/plugins/pluginutils" "github.com/myrteametrics/myrtea-engine-api/v5/plugins/standalone" @@ -53,13 +52,6 @@ func (c *Core) RegisterPlugins() { } switch config.Name { - case "assistant": - if a := assistant.NewAssistantPlugin(config); a != nil { - plugin.Plugin = a - } else { - continue - } - break case "baseline": if b := baseline.NewBaselinePlugin(config); b != nil { plugin.Plugin = b diff --git a/plugins/core_test.go b/plugins/core_test.go index 1bf3a222..e1feb7f9 100644 --- a/plugins/core_test.go +++ b/plugins/core_test.go @@ -2,7 +2,7 @@ package plugin import ( "github.com/myrteametrics/myrtea-engine-api/v5/plugins/pluginutils" - "github.com/myrteametrics/myrtea-sdk/v4/expression" + "github.com/myrteametrics/myrtea-sdk/v5/expression" "github.com/spf13/viper" "os" "path/filepath"