From 1f242da65ec5f284507b64154a01815c501a7d64 Mon Sep 17 00:00:00 2001 From: Serhii Zakharov Date: Sun, 21 Jun 2020 13:45:51 +0200 Subject: [PATCH 01/14] implemented-report-endpoint --- content/content.go | 139 +++++++++++++++++++++++++++++++++++++++ content/parsing.go | 88 +++++++++++++++++++++++++ go.mod | 5 +- go.sum | 44 +++++++++++++ server/auth.go | 71 +++++++++----------- server/endpoints.go | 67 +++++++++---------- server/endpoints_test.go | 5 +- server/errors.go | 5 +- server/handlers.go | 41 ++++-------- server/router_utils.go | 7 +- server/server.go | 136 ++++++++++++++++++++++++++++++++++---- server/server_test.go | 75 ++++++++++++++++----- services/services.go | 19 ++---- smart_proxy.go | 36 +++------- tests/helpers/errors.go | 5 ++ tests/helpers/http.go | 70 ++++++++++++++++++++ tests/helpers/json.go | 5 ++ tests/helpers/timeout.go | 6 ++ types/types.go | 35 ++++++++++ 19 files changed, 676 insertions(+), 183 deletions(-) create mode 100644 content/content.go create mode 100644 content/parsing.go create mode 100644 tests/helpers/errors.go create mode 100644 tests/helpers/http.go create mode 100644 tests/helpers/json.go create mode 100644 tests/helpers/timeout.go create mode 100644 types/types.go diff --git a/content/content.go b/content/content.go new file mode 100644 index 00000000..79eeff81 --- /dev/null +++ b/content/content.go @@ -0,0 +1,139 @@ +// Package content provides API to get rule's content by its `rule id` and `error key`. +// It takes all the work of caching rules taken from content service +package content + +import ( + "fmt" + "sync" + "time" + + "github.com/RedHatInsights/insights-content-service/content" + ics_content "github.com/RedHatInsights/insights-content-service/content" + "github.com/RedHatInsights/insights-results-aggregator-utils/types" + "github.com/rs/zerolog/log" + + "github.com/RedHatInsights/insights-results-smart-proxy/services" +) + +var ( + ruleContentDirectory *content.RuleContentDirectory + ruleContentDirectoryReady = make(chan struct{}) +) + +type ruleIDAndErrorKey struct { + RuleID types.RuleID + ErrorKey types.ErrorKey +} + +// RulesWithContentStorage is a key:value structure to store processed rules. +// It's thread safe +type RulesWithContentStorage struct { + sync.RWMutex + rulesWithContent map[ruleIDAndErrorKey]*types.RuleWithContent + rules map[types.RuleID]*ics_content.RuleContent +} + +func (s *RulesWithContentStorage) GetRuleWithErrorKeyContent( + ruleID types.RuleID, errorKey types.ErrorKey, +) (*types.RuleWithContent, bool) { + s.RLock() + defer s.RUnlock() + + res, found := s.rulesWithContent[ruleIDAndErrorKey{ + RuleID: ruleID, + ErrorKey: errorKey, + }] + return res, found +} + +func (s *RulesWithContentStorage) GetRuleContent(ruleID types.RuleID) (*ics_content.RuleContent, bool) { + s.RLock() + defer s.RUnlock() + + res, found := s.rules[ruleID] + return res, found +} + +func (s *RulesWithContentStorage) SetRuleWithContent( + ruleID types.RuleID, errorKey types.ErrorKey, ruleWithContent *types.RuleWithContent, +) { + s.Lock() + defer s.Unlock() + + s.rulesWithContent[ruleIDAndErrorKey{ + RuleID: ruleID, + ErrorKey: errorKey, + }] = ruleWithContent +} + +func (s *RulesWithContentStorage) SetRule( + ruleID types.RuleID, ruleContent *ics_content.RuleContent, +) { + s.Lock() + defer s.Unlock() + + s.rules[ruleID] = ruleContent +} + +var rulesWithContentStorage = RulesWithContentStorage{ + rulesWithContent: map[ruleIDAndErrorKey]*types.RuleWithContent{}, + rules: map[types.RuleID]*ics_content.RuleContent{}, +} + +// GetRuleWithErrorKeyContent returns content for rule with provided `rule id` and `error key`. +// Caching is done under the hood, don't worry about it. +func GetRuleWithErrorKeyContent( + ruleID types.RuleID, errorKey types.ErrorKey, +) (*types.RuleWithContent, error) { + // to be sure data is there + // it will wait only on opened channel + // something like condition variable + _, _ = <-ruleContentDirectoryReady + + res, found := rulesWithContentStorage.GetRuleWithErrorKeyContent(ruleID, errorKey) + if !found { + return nil, &types.ItemNotFoundError{ItemID: fmt.Sprintf("%v/%v", ruleID, errorKey)} + } + + return res, nil +} + +// GetRuleContent returns content for rule with provided `rule id` +// Caching is done under the hood, don't worry about it. +func GetRuleContent(ruleID types.RuleID) (*ics_content.RuleContent, error) { + // to be sure data is there + // it will wait only on opened channel + // something like condition variable + _, _ = <-ruleContentDirectoryReady + + res, found := rulesWithContentStorage.GetRuleContent(ruleID) + if !found { + return nil, &types.ItemNotFoundError{ItemID: ruleID} + } + + return res, nil +} + +// RunUpdateContentLoop runs loop which updates rules content by ticker +func RunUpdateContentLoop(servicesConf services.Configuration) { + ticker := time.NewTicker(servicesConf.GroupsPollingTime) + + for { + updateContent(servicesConf) + <-ticker.C + } +} + +func updateContent(servicesConf services.Configuration) { + var err error + + ruleContentDirectory, err = services.GetContent(servicesConf) + if err != nil { + log.Error().Err(err).Msg("Error retrieving static content") + return + } + + loadRuleContent(ruleContentDirectory) + + close(ruleContentDirectoryReady) +} diff --git a/content/parsing.go b/content/parsing.go new file mode 100644 index 00000000..3d37714f --- /dev/null +++ b/content/parsing.go @@ -0,0 +1,88 @@ +package content + +import ( + "strings" + "time" + + "github.com/RedHatInsights/insights-content-service/content" + "github.com/RedHatInsights/insights-results-aggregator-utils/types" + "github.com/rs/zerolog/log" +) + +// TODO: consider moving parsing to content service + +// loadRuleContent loads the parsed rule content into the storage +func loadRuleContent(contentDir *content.RuleContentDirectory) { + for _, rule := range contentDir.Rules { + ruleID := types.RuleID(rule.Plugin.PythonModule) + + rulesWithContentStorage.SetRule(ruleID, &rule) + + for errorKey, errorProperties := range rule.ErrorKeys { + impact, found := contentDir.Config.Impact[errorProperties.Metadata.Impact] + if !found { + log.Error().Msgf(`impact "%v" doesn't have integer representation'`, impact) + continue + } + var isActive bool + switch strings.ToLower(strings.TrimSpace(errorProperties.Metadata.Status)) { + case "active": + isActive = true + case "inactive": + isActive = false + default: + log.Error().Msgf("invalid rule error key status: '%s'", errorProperties.Metadata.Status) + return + } + + publishDate, err := time.Parse(time.RFC3339, errorProperties.Metadata.PublishDate) + if err != nil { + log.Error().Msgf( + `invalid to parse time "%v" using layout "%v"`, + errorProperties.Metadata.PublishDate, + time.RFC3339, + ) + return + } + + rulesWithContentStorage.SetRuleWithContent(ruleID, types.ErrorKey(errorKey), &types.RuleWithContent{ + Module: ruleID, + Name: rule.Plugin.Name, + Summary: rule.Summary, + Reason: rule.Reason, + Resolution: rule.Resolution, + MoreInfo: rule.MoreInfo, + ErrorKey: types.ErrorKey(errorKey), + Condition: errorProperties.Metadata.Condition, + Description: errorProperties.Metadata.Description, + TotalRisk: calculateTotalRisk(impact, errorProperties.Metadata.Likelihood), + RiskOfChange: calculateRiskOfChange(impact, errorProperties.Metadata.Likelihood), + PublishDate: publishDate, + Active: isActive, + Generic: errorProperties.Generic, + Tags: errorProperties.Metadata.Tags, + }) + } + } +} + +// TODO: move to utils +func calculateTotalRisk(impact, likelihood int) int { + return (impact + likelihood) / 2 +} + +// TODO: move to utils +func calculateRiskOfChange(impact, likelihood int) int { + // TODO: actually calculate + return 0 +} + +// TODO: move to utils +func commaSeparatedStrToTags(str string) []string { + str = strings.TrimSpace(str) + if len(str) == 0 { + return []string{} + } + + return strings.Split(str, ",") +} diff --git a/go.mod b/go.mod index c23a6169..1ac9663e 100644 --- a/go.mod +++ b/go.mod @@ -5,8 +5,10 @@ go 1.13 require ( github.com/BurntSushi/toml v0.3.1 github.com/RedHatInsights/insights-content-service v0.0.0-20200610101541-f0c10d6d451d - github.com/RedHatInsights/insights-operator-utils v1.0.2-0.20200610143236-c868b2f93d2a + github.com/RedHatInsights/insights-operator-utils v1.0.2-0.20200610143236-c868b2f93d2a github.com/RedHatInsights/insights-results-aggregator v0.0.0-20200604090056-3534f6dd9c1c + github.com/RedHatInsights/insights-results-aggregator-data v0.0.0-20200512064850-2d04c5d0c9a6 + github.com/RedHatInsights/insights-results-aggregator-utils v0.0.0-20200616074815-67f30b0e724d github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 github.com/dgrijalva/jwt-go v3.2.0+incompatible github.com/google/uuid v1.1.1 @@ -15,4 +17,5 @@ require ( github.com/rs/zerolog v1.19.0 github.com/spf13/viper v1.7.0 github.com/stretchr/testify v1.6.1 + gopkg.in/h2non/gock.v1 v1.0.15 ) diff --git a/go.sum b/go.sum index 4f438936..ab3f4da2 100644 --- a/go.sum +++ b/go.sum @@ -14,11 +14,13 @@ dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7 github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= +github.com/DATA-DOG/go-sqlmock v1.4.1 h1:ThlnYciV1iM/V0OSF/dtkqWb6xo5qITT1TJBG1MRDJM= github.com/DATA-DOG/go-sqlmock v1.4.1/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/DataDog/datadog-go v2.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/OneOfOne/xxhash v1.2.7/go.mod h1:eZbhyaAYD41SGSSsnmcpxVoRiQ/MPUTjUdIIOT9Um7Q= +github.com/RedHatInsights/cloudwatch v0.0.0-20200512151223-b0b55757a24b h1:IFT3csatW9XMCEi54wRo+GiFshT4E2V2vWCKYg7413w= github.com/RedHatInsights/cloudwatch v0.0.0-20200512151223-b0b55757a24b/go.mod h1:8l+HqU8iWM6hA9kSAHgY3ItSlpEsPr8fb2R0GBp9S0U= github.com/RedHatInsights/insights-content-service v0.0.0-20200610101541-f0c10d6d451d h1:0aXuHiiucADzC++1lOJs3u4k1UanSNX+wIcpnyi8Bi0= github.com/RedHatInsights/insights-content-service v0.0.0-20200610101541-f0c10d6d451d/go.mod h1:j3Mc+Xh2ospxJ+K2RIZjYlI6E6E4H2Qh3cgUzhstrfQ= @@ -27,8 +29,14 @@ github.com/RedHatInsights/insights-operator-utils v1.0.2-0.20200610143236-c868b2 github.com/RedHatInsights/insights-operator-utils v1.0.2-0.20200610143236-c868b2f93d2a/go.mod h1:0rhk13kn0BB+yKdfZjpMoQy0lXdXY3i4NJ1xGwGMcII= github.com/RedHatInsights/insights-results-aggregator v0.0.0-20200604090056-3534f6dd9c1c h1:/kb5AwNxizPf+0R4OWWRvWbLqAwf07Bu97R4WVHk2Uw= github.com/RedHatInsights/insights-results-aggregator v0.0.0-20200604090056-3534f6dd9c1c/go.mod h1:7Pc15NYXErx7BMJ4rF1Hacm+29G6atzjhwBpXNFMt+0= +github.com/RedHatInsights/insights-results-aggregator-data v0.0.0-20200512064850-2d04c5d0c9a6 h1:Yt6Znx4OoMNRENCBdphqhu78EO/y2VD50DEC0b6mCrk= +github.com/RedHatInsights/insights-results-aggregator-data v0.0.0-20200512064850-2d04c5d0c9a6/go.mod h1:O5X07zyJ9soaH2gMtYUNaJN6/9wt0E4J5TmheNBSdgc= +github.com/RedHatInsights/insights-results-aggregator-utils v0.0.0-20200616074815-67f30b0e724d h1:7fqXh2MMijj5YXTjzPFsOHCO+nXegHk7IVX0lCLl1ac= +github.com/RedHatInsights/insights-results-aggregator-utils v0.0.0-20200616074815-67f30b0e724d/go.mod h1:a2r0OkXqBR7MqsnIjEn1FVwZIGQO9ROnbjfV2ZelVvE= github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= +github.com/Shopify/sarama v1.26.0 h1:C+zFi+/NJdfeJgZWbu+WaLgk4NcsbmqfFTKsoJmR39U= github.com/Shopify/sarama v1.26.0/go.mod h1:y/CFFTO9eaMTNriwu/Q+W4eioLqiDMGkA1W+gmdfj8w= +github.com/Shopify/toxiproxy v2.1.4+incompatible h1:TKdv8HiTLgE5wdJuEML90aBgNWsokNbMijUGhmcoBJc= github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c= @@ -47,6 +55,7 @@ github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6l github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU= github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/aws/aws-sdk-go v1.30.11/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0= +github.com/aws/aws-sdk-go v1.30.25 h1:89NXJkfpjnMEnsxkP8MVX+LDsoiLCSqevraLb5y4Mjk= github.com/aws/aws-sdk-go v1.30.25/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0= github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= @@ -89,26 +98,33 @@ github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7Do 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/deckarep/golang-set v1.7.1 h1:SCQV0S6gTtp6itiFrTqI+pfmJ4LN85S1YzhDf9rTHJQ= github.com/deckarep/golang-set v1.7.1/go.mod h1:93vsz/8Wt4joVM7c2AVqh+YRMiUSc14yDtF28KmMOgQ= github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= +github.com/eapache/go-resiliency v1.1.0 h1:1NtRmCAqadE2FN4ZcN6g90TP3uk8cg9rn9eNK2197aU= github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= +github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 h1:YEetp8/yCZMuEPMUDHG0CW/brkkEp8mzqk2+ODEitlw= github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= +github.com/eapache/queue v1.1.0 h1:YOEu7KNc61ntiQlcEeUIoDTJ2o8mQznoNvUhiigpIqc= github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= +github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4= github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20= +github.com/frankban/quicktest v1.4.1 h1:Wv2VwvNn73pAdFIVUQRXYDFp31lXKbqblIXo/Q5GPSg= github.com/frankban/quicktest v1.4.1/go.mod h1:36zfPVQyHxymz4cH7wlDmVwDrJuljRB60qkgn7rorfQ= github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fzipp/gocyclo v0.0.0-20150627053110-6acd4345c835/go.mod h1:BjL/N0+C+j9uNX+1xcNuM9vdSIcXCZrQZUYbXOFbgN8= +github.com/gchaincl/sqlhooks v1.3.0 h1:yKPXxW9a5CjXaVf2HkQn6wn7TZARvbAOAelr3H8vK2Y= github.com/gchaincl/sqlhooks v1.3.0/go.mod h1:9BypXnereMT0+Ys8WGWHqzgkkOfHIhyeUCqXC24ra34= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= @@ -120,6 +136,7 @@ github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= +github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs= github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-yaml/yaml v2.1.0+incompatible h1:RYi2hDdss1u4YE7GwixGzWwVo47T8UQwnTLB6vQiq+o= @@ -145,12 +162,14 @@ github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:W github.com/golang/protobuf v1.4.0 h1:oOuy+ugB+P/kBdUnG5QaMXSIyJ1q38wWSojYCb3z5VQ= github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4= github.com/golang/snappy v0.0.1/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 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 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= @@ -162,6 +181,7 @@ github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= github.com/google/uuid v1.1.1/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/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= @@ -176,6 +196,8 @@ github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= +github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 h1:2VTzZjLZBgl62/EtslCrtky5vbi9dd7HrQPQIx6wqiw= +github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542/go.mod h1:Ow0tF8D4Kplbc8s8sSb3V2oUCygFHVp8gC3Dn6U4MNI= github.com/hashicorp/consul v1.4.5/go.mod h1:mFrjN1mfidgJfYP1xrJCF+AfRhr6Eaqhb2+sfyn/OOI= github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q= github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE= @@ -197,6 +219,7 @@ github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1BE= github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= @@ -218,9 +241,11 @@ github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpO github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= +github.com/jcmturner/gofork v0.0.0-20190328161633-dc7c13fece03 h1:FUwcHNlEqkqLjLBdCp5PRlCFijNjvcYANOZXzCfXwCM= github.com/jcmturner/gofork v0.0.0-20190328161633-dc7c13fece03/go.mod h1:MK8+TM0La+2rjBD4jE12Kj1pCCxK7d2LK/UM3ncEo0o= github.com/jcxplorer/cwlogger v0.0.0-20170704082755-4e30a5a47e6a/go.mod h1:jqP/JbBwy+LLLUwzr8XTr9IrnaNxFD7kmaXZlvjH9nQ= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= +github.com/jmespath/go-jmespath v0.3.0 h1:OS12ieG61fsCg5+qLJ+SsW9NicxNkg3b25OyT2yCeUc= github.com/jmespath/go-jmespath v0.3.0/go.mod h1:9QtRXoHjLGCJ5IBSaohpXITPlowMeeYCZ7fLUTSywik= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= @@ -228,10 +253,12 @@ github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/u github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= +github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/klauspost/compress v1.9.7 h1:hYW1gP94JUmAhBtJ+LNz5My+gBobDxPR1iVuKug26aA= github.com/klauspost/compress v1.9.7/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= @@ -286,6 +313,8 @@ github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzE github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= +github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32 h1:W6apQkHrMkS0Muv8G/TipAy/FJl/rCYT0+EuS8+Z0z4= +github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32/go.mod h1:9wM+0iRr9ahx58uYLpLIr5fm8diHn0JbqRycJi6w0Ms= github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= @@ -313,6 +342,7 @@ github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/9 github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= +github.com/pierrec/lz4 v2.2.6+incompatible h1:6aCX4/YZ9v8q69hTyiR7dNLnTA3fgtKHVVW5BCd5Znw= github.com/pierrec/lz4 v2.2.6+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -353,6 +383,7 @@ github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+Gx github.com/prometheus/procfs v0.0.11 h1:DhHlBtkHWPYi8O2y31JkK0TF+DGM+51OopZjH/Ia5qI= github.com/prometheus/procfs v0.0.11/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= +github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a h1:9ZKAASQSHhDYGoxY8uLVpewe1GDZ2vu2Tr/vTdVAkFQ= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= @@ -368,7 +399,9 @@ github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= +github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= +github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= github.com/sony/gobreaker v0.4.1/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJOjmxWY= @@ -391,6 +424,7 @@ github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3 github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= @@ -445,6 +479,7 @@ golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20191117063200-497ca9f6d64f h1:kz4KIr+xcPUsI3VMoqWfPMvtnJ6MGfiVwsWSVzphMO4= golang.org/x/crypto v0.0.0-20191117063200-497ca9f6d64f/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= 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= @@ -561,6 +596,7 @@ golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapK golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= 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 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk= google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= @@ -602,17 +638,25 @@ google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzi gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= 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 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o= +gopkg.in/h2non/gock.v1 v1.0.15 h1:SzLqcIlb/fDfg7UvukMpNcWsu7sI5tWwL+KCATZqks0= +gopkg.in/h2non/gock.v1 v1.0.15/go.mod h1:sX4zAkdYX1TRGJ2JY156cFspQn4yRWn6p9EMdODlynE= gopkg.in/ini.v1 v1.51.0 h1:AQvPpx3LzTDM0AjnIRlVFwFFGC+npRopjZxLJj6gdno= gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/jcmturner/aescts.v1 v1.0.1 h1:cVVZBK2b1zY26haWB4vbBiZrfFQnfbTVrE3xZq6hrEw= gopkg.in/jcmturner/aescts.v1 v1.0.1/go.mod h1:nsR8qBOg+OucoIW+WMhB3GspUQXq9XorLnQb9XtvcOo= +gopkg.in/jcmturner/dnsutils.v1 v1.0.1 h1:cIuC1OLRGZrld+16ZJvvZxVJeKPsvd5eUIvxfoN5hSM= gopkg.in/jcmturner/dnsutils.v1 v1.0.1/go.mod h1:m3v+5svpVOhtFAP/wSz+yzh4Mc0Fg7eRhxkJMWSIz9Q= +gopkg.in/jcmturner/goidentity.v3 v3.0.0 h1:1duIyWiTaYvVx3YX2CYtpJbUFd7/UuPYCfgXtQ3VTbI= gopkg.in/jcmturner/goidentity.v3 v3.0.0/go.mod h1:oG2kH0IvSYNIu80dVAyu/yoefjq1mNfM5bm88whjWx4= +gopkg.in/jcmturner/gokrb5.v7 v7.2.3 h1:hHMV/yKPwMnJhPuPx7pH2Uw/3Qyf+thJYlisUc44010= gopkg.in/jcmturner/gokrb5.v7 v7.2.3/go.mod h1:l8VISx+WGYp+Fp7KRbsiUuXTTOnxIc3Tuvyavf11/WM= +gopkg.in/jcmturner/rpc.v1 v1.1.0 h1:QHIUxTX1ISuAv9dD2wJ9HWQVuWDX/Zc0PfeC2tjc4rU= gopkg.in/jcmturner/rpc.v1 v1.1.0/go.mod h1:YIdkC4XfD6GXbzje11McwsDuOlZQSb9W4vfLvuNnlv8= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= diff --git a/server/auth.go b/server/auth.go index d4c43702..4a3d6f3a 100644 --- a/server/auth.go +++ b/server/auth.go @@ -25,45 +25,17 @@ import ( "net/http" "strings" - jwt "github.com/dgrijalva/jwt-go" - "github.com/rs/zerolog/log" - "github.com/RedHatInsights/insights-operator-utils/collections" - - "github.com/RedHatInsights/insights-results-aggregator/types" + "github.com/RedHatInsights/insights-results-aggregator-utils/types" + "github.com/dgrijalva/jwt-go" + "github.com/rs/zerolog/log" ) -type contextKey string - const ( - // ContextKeyUser is a constant for user authentication token in request - ContextKeyUser = contextKey("user") // #nosec G101 malformedTokenMessage = "Malformed authentication token" ) -// Internal contains information about organization ID -type Internal struct { - OrgID types.OrgID `json:"org_id,string"` -} - -// Identity contains internal user info -type Identity struct { - AccountNumber types.UserID `json:"account_number"` - Internal Internal `json:"internal"` -} - -// Token is x-rh-identity struct -type Token struct { - Identity Identity `json:"identity"` -} - -// JWTPayload is structure that contain data from parsed JWT token -type JWTPayload struct { - AccountNumber types.UserID `json:"account_number"` - OrgID types.OrgID `json:"org_id,string"` -} - // Authentication middleware for checking auth rights func (server *HTTPServer) Authentication(next http.Handler, noAuthURLs []string) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { @@ -87,21 +59,26 @@ func (server *HTTPServer) Authentication(next http.Handler, noAuthURLs []string) return } - tk := &Token{} + tk := &types.Token{} // If we took JWT token, it has different structure then x-rh-identity if server.Config.AuthType == "jwt" { - jwt := &JWTPayload{} - err = json.Unmarshal([]byte(decoded), jwt) + jwtPayload := &types.JWTPayload{} + err = json.Unmarshal(decoded, jwtPayload) if err != nil { //Malformed token, returns with http code 403 as usual log.Error().Err(err).Msg(malformedTokenMessage) handleServerError(w, &AuthenticationError{errString: malformedTokenMessage}) return } // Map JWT token to inner token - tk.Identity = Identity{AccountNumber: jwt.AccountNumber, Internal: Internal{OrgID: jwt.OrgID}} + tk.Identity = types.Identity{ + AccountNumber: jwtPayload.AccountNumber, + Internal: types.Internal{ + OrgID: jwtPayload.OrgID, + }, + } } else { - err = json.Unmarshal([]byte(decoded), tk) + err = json.Unmarshal(decoded, tk) if err != nil { //Malformed token, returns with http code 403 as usual log.Error().Err(err).Msg(malformedTokenMessage) @@ -111,7 +88,7 @@ func (server *HTTPServer) Authentication(next http.Handler, noAuthURLs []string) } // Everything went well, proceed with the request and set the caller to the user retrieved from the parsed token - ctx := context.WithValue(r.Context(), ContextKeyUser, tk.Identity) + ctx := context.WithValue(r.Context(), types.ContextKeyUser, tk.Identity) r = r.WithContext(ctx) next.ServeHTTP(w, r) @@ -120,13 +97,13 @@ func (server *HTTPServer) Authentication(next http.Handler, noAuthURLs []string) // GetCurrentUserID retrieves current user's id from request func (server *HTTPServer) GetCurrentUserID(request *http.Request) (types.UserID, error) { - i := request.Context().Value(ContextKeyUser) + i := request.Context().Value(types.ContextKeyUser) if i == nil { return "", &AuthenticationError{errString: "user id is not provided"} } - identity, ok := i.(Identity) + identity, ok := i.(types.Identity) if !ok { return "", fmt.Errorf("contextKeyUser has wrong type") } @@ -134,6 +111,22 @@ func (server *HTTPServer) GetCurrentUserID(request *http.Request) (types.UserID, return identity.AccountNumber, nil } +// GetAuthToken returns current authentication token +func (server *HTTPServer) GetAuthToken(request *http.Request) (*types.Identity, error) { + i := request.Context().Value(types.ContextKeyUser) + + if i == nil { + return nil, &AuthenticationError{errString: "token is not provided"} + } + + identity, ok := i.(types.Identity) + if !ok { + return nil, fmt.Errorf("contextKeyUser has wrong type") + } + + return &identity, nil +} + func (server *HTTPServer) getAuthTokenHeader(w http.ResponseWriter, r *http.Request) (string, bool) { var tokenHeader string // In case of testing on local machine we don't take x-rh-identity header, but instead Authorization with JWT token in it diff --git a/server/endpoints.go b/server/endpoints.go index 74e85dd9..ca7a8964 100644 --- a/server/endpoints.go +++ b/server/endpoints.go @@ -15,11 +15,10 @@ package server import ( - "fmt" "net/http" "path/filepath" - "regexp" + ira_server "github.com/RedHatInsights/insights-results-aggregator/server" "github.com/gorilla/mux" "github.com/prometheus/client_golang/prometheus/promhttp" ) @@ -27,39 +26,40 @@ import ( const ( // MainEndpoint returns status ok MainEndpoint = "" - // DeleteOrganizationsEndpoint deletes all {organizations}(comma separated array). DEBUG only - DeleteOrganizationsEndpoint = "organizations/{organizations}" - // DeleteClustersEndpoint deletes all {clusters}(comma separated array). DEBUG only - DeleteClustersEndpoint = "clusters/{clusters}" - // OrganizationsEndpoint returns all organizations - OrganizationsEndpoint = "organizations" - // ReportEndpoint returns report for provided {organization} and {cluster} - ReportEndpoint = "report/{organization}/{cluster}" + // ReportEndpoint returns report for provided {cluster} + ReportEndpoint = "clusters/{cluster}/report" + // RuleGroupsEndpoint is a simple redirect endpoint to the insights-content-service API specified in configuration + RuleGroupsEndpoint = "groups" + // RuleContent returns static content for {rule_id} + RuleContent = "rules/{rule_id}/content" + // MetricsEndpoint returns prometheus metrics + MetricsEndpoint = "metrics" + // LikeRuleEndpoint likes rule with {rule_id} for {cluster} using current user(from auth header) - LikeRuleEndpoint = "clusters/{cluster}/rules/{rule_id}/like" + LikeRuleEndpoint = ira_server.LikeRuleEndpoint // DislikeRuleEndpoint dislikes rule with {rule_id} for {cluster} using current user(from auth header) - DislikeRuleEndpoint = "clusters/{cluster}/rules/{rule_id}/dislike" + DislikeRuleEndpoint = ira_server.DislikeRuleEndpoint // ResetVoteOnRuleEndpoint resets vote on rule with {rule_id} for {cluster} using current user(from auth header) - ResetVoteOnRuleEndpoint = "clusters/{cluster}/rules/{rule_id}/reset_vote" - // GetVoteOnRuleEndpoint is an endpoint to get vote on rule. DEBUG only - GetVoteOnRuleEndpoint = "clusters/{cluster}/rules/{rule_id}/get_vote" - // RuleEndpoint is an endpoint to create&delete a rule. DEBUG only - RuleEndpoint = "rules/{rule_id}" - // RuleErrorKeyEndpoint is for endpoints to create&delete a rule_error_key (DEBUG only) - // and for endpoint to get a rule - RuleErrorKeyEndpoint = "rules/{rule_id}/error_keys/{error_key}" - // RuleGroupsEndpoint is a simple redirect endpoint to the insights-content-service API specified in configruation - RuleGroupsEndpoint = "groups" + ResetVoteOnRuleEndpoint = ira_server.ResetVoteOnRuleEndpoint // ClustersForOrganizationEndpoint returns all clusters for {organization} - ClustersForOrganizationEndpoint = "organizations/{organization}/clusters" + ClustersForOrganizationEndpoint = ira_server.ClustersForOrganizationEndpoint // DisableRuleForClusterEndpoint disables a rule for specified cluster - DisableRuleForClusterEndpoint = "clusters/{cluster}/rules/{rule_id}/disable" + DisableRuleForClusterEndpoint = ira_server.DisableRuleForClusterEndpoint // EnableRuleForClusterEndpoint re-enables a rule for specified cluster - EnableRuleForClusterEndpoint = "clusters/{cluster}/rules/{rule_id}/enable" - // MetricsEndpoint returns prometheus metrics - MetricsEndpoint = "metrics" - // RuleContent returns static content for {rule_id} - RuleContent = "rules/{rule_id}/content" + EnableRuleForClusterEndpoint = ira_server.EnableRuleForClusterEndpoint + // RuleErrorKeyEndpoint is for endpoints to create&delete a rule_error_key (DEBUG only) + // and for endpoint to get a rule + RuleErrorKeyEndpoint = ira_server.RuleErrorKeyEndpoint + // OrganizationsEndpoint returns all organizations + OrganizationsEndpoint = ira_server.OrganizationsEndpoint + // DeleteOrganizationsEndpoint deletes all {organizations}(comma separated array). DEBUG only + DeleteOrganizationsEndpoint = ira_server.DeleteOrganizationsEndpoint + // DeleteClustersEndpoint deletes all {clusters}(comma separated array). DEBUG only + DeleteClustersEndpoint = ira_server.DeleteClustersEndpoint + // GetVoteOnRuleEndpoint is an endpoint to get vote on rule. DEBUG only + GetVoteOnRuleEndpoint = ira_server.GetVoteOnRuleEndpoint + // RuleEndpoint is an endpoint to create&delete a rule. DEBUG only + RuleEndpoint = ira_server.RuleEndpoint ) func (server *HTTPServer) addDebugEndpointsToRouter(router *mux.Router) { @@ -91,7 +91,7 @@ func (server *HTTPServer) addEndpointsToRouter(router *mux.Router) { // common REST API endpoints router.HandleFunc(apiPrefix+MainEndpoint, server.mainEndpoint).Methods(http.MethodGet) - router.HandleFunc(apiPrefix+ReportEndpoint, server.proxyTo(aggregatorEndpoint)).Methods(http.MethodGet, http.MethodOptions) + router.HandleFunc(apiPrefix+ReportEndpoint, server.reportEndpoint).Methods(http.MethodGet, http.MethodOptions) router.HandleFunc(apiPrefix+LikeRuleEndpoint, server.proxyTo(aggregatorEndpoint)).Methods(http.MethodPut, http.MethodOptions) router.HandleFunc(apiPrefix+DislikeRuleEndpoint, server.proxyTo(aggregatorEndpoint)).Methods(http.MethodPut, http.MethodOptions) router.HandleFunc(apiPrefix+ResetVoteOnRuleEndpoint, server.proxyTo(aggregatorEndpoint)).Methods(http.MethodPut, http.MethodOptions) @@ -108,10 +108,3 @@ func (server *HTTPServer) addEndpointsToRouter(router *mux.Router) { // OpenAPI specs router.HandleFunc(openAPIURL, server.serveAPISpecFile).Methods(http.MethodGet) } - -// MakeURLToEndpoint creates URL to endpoint, use constants from file endpoints.go -func MakeURLToEndpoint(apiPrefix, endpoint string, args ...interface{}) string { - re := regexp.MustCompile(`\{[a-zA-Z_0-9]+\}`) - endpoint = re.ReplaceAllString(endpoint, "%v") - return apiPrefix + fmt.Sprintf(endpoint, args...) -} diff --git a/server/endpoints_test.go b/server/endpoints_test.go index 464d8269..25a62778 100644 --- a/server/endpoints_test.go +++ b/server/endpoints_test.go @@ -17,16 +17,15 @@ package server_test import ( "testing" + httputils "github.com/RedHatInsights/insights-results-aggregator-utils/http" "github.com/stretchr/testify/assert" - - "github.com/RedHatInsights/insights-results-smart-proxy/server" ) func TestMakeURLToEndpointWithValidValue(t *testing.T) { apiPrefix := "api/v1/" endpoint := "some_valid_endpoint" - retval := server.MakeURLToEndpoint(apiPrefix, endpoint) + retval := httputils.MakeURLToEndpoint(apiPrefix, endpoint) assert.Equal(t, "api/v1/some_valid_endpoint", retval) } diff --git a/server/errors.go b/server/errors.go index 8cdb273e..e1000b5f 100644 --- a/server/errors.go +++ b/server/errors.go @@ -19,10 +19,9 @@ import ( "fmt" "net/http" - "github.com/rs/zerolog/log" - "github.com/RedHatInsights/insights-operator-utils/responses" - "github.com/RedHatInsights/insights-results-aggregator/types" + "github.com/RedHatInsights/insights-results-aggregator-utils/types" + "github.com/rs/zerolog/log" ) // responseDataError is used as the error message when the responses functions return an error diff --git a/server/handlers.go b/server/handlers.go index 2868b4f4..98b115b9 100644 --- a/server/handlers.go +++ b/server/handlers.go @@ -20,14 +20,17 @@ import ( "github.com/RedHatInsights/insights-operator-utils/responses" "github.com/rs/zerolog/log" + + "github.com/RedHatInsights/insights-results-smart-proxy/content" ) -// getGroups retrives the groups configuration from a channel to get the latest valid one and send the response back to the client -func (server *HTTPServer) getGroups(writer http.ResponseWriter, request *http.Request) { +// getGroups retrieves the groups configuration from a channel to get the latest valid one +// and sends the response back to the client +func (server *HTTPServer) getGroups(writer http.ResponseWriter, _ *http.Request) { groupsConfig := <-server.GroupsChannel if groupsConfig == nil { - err := errors.New("No groups retrieved") - log.Error().Err(err).Msg("Groups cannot be retrieved from content service. Check logs") + err := errors.New("no groups retrieved") + log.Error().Err(err).Msg("groups cannot be retrieved from content service. Check logs") handleServerError(writer, err) return } @@ -44,39 +47,21 @@ func (server *HTTPServer) getGroups(writer http.ResponseWriter, request *http.Re // getContentForRule retrieves the static content for the given ruleID func (server HTTPServer) getContentForRule(writer http.ResponseWriter, request *http.Request) { - contentConfig := <-server.ContentChannel - - if contentConfig.Rules == nil { - err := errors.New("No rules content") - log.Error().Err(err).Msg("Rules static content cannot be retrieved from content service. Check logs") - handleServerError(writer, err) - return - } - ruleID, err := readRuleID(writer, request) if err != nil { // already handled in readRuleID return } - stringfiedRuleID := string(ruleID) - - for _, ruleContent := range contentConfig.Rules { - // Check if the given {rule_id} match with the Python module name, that is used as RuleID - if stringfiedRuleID == ruleContent.Plugin.PythonModule { - err = responses.SendOK(writer, responses.BuildOkResponseWithData("content", ruleContent)) - if err != nil { - log.Error().Err(err) - handleServerError(writer, err) - } - return - } + ruleContent, err := content.GetRuleContent(ruleID) + if err != nil { + handleServerError(writer, err) + return } - // if the loop ends without finding the ruleID, response with 404 code - err = responses.SendNotFound(writer, "No content found for the given rule ID") + err = responses.SendOK(writer, responses.BuildOkResponseWithData("content", ruleContent)) if err != nil { - log.Error().Err(err) handleServerError(writer, err) + return } } diff --git a/server/router_utils.go b/server/router_utils.go index 620dae78..17468197 100644 --- a/server/router_utils.go +++ b/server/router_utils.go @@ -22,11 +22,10 @@ import ( "strconv" "strings" + "github.com/RedHatInsights/insights-results-aggregator-utils/types" "github.com/google/uuid" "github.com/gorilla/mux" "github.com/rs/zerolog/log" - - "github.com/RedHatInsights/insights-results-aggregator/types" ) // getRouterParam retrieves parameter from URL like `/organization/{org_id}` @@ -133,9 +132,9 @@ func readOrganizationID(writer http.ResponseWriter, request *http.Request, auth } func checkPermissions(writer http.ResponseWriter, request *http.Request, orgID types.OrgID, auth bool) error { - identityContext := request.Context().Value(ContextKeyUser) + identityContext := request.Context().Value(types.ContextKeyUser) if identityContext != nil && auth { - identity := identityContext.(Identity) + identity := identityContext.(types.Identity) if identity.Internal.OrgID != orgID { const message = "You have no permissions to get or change info about this organization" log.Error().Msg(message) diff --git a/server/server.go b/server/server.go index e7d8d017..acecbd44 100644 --- a/server/server.go +++ b/server/server.go @@ -24,25 +24,31 @@ package server import ( "context" + "encoding/json" "io/ioutil" "net/http" "net/url" "strings" + "time" + "github.com/RedHatInsights/insights-content-service/groups" + "github.com/RedHatInsights/insights-operator-utils/responses" + "github.com/RedHatInsights/insights-results-aggregator-utils/types" + "github.com/gorilla/mux" + "github.com/rs/zerolog/log" // we just have to import this package in order to expose pprof interface in debug mode // disable "G108 (CWE-): Profiling endpoint is automatically exposed on /debug/pprof" // #nosec G108 _ "net/http/pprof" "path/filepath" - "github.com/RedHatInsights/insights-content-service/content" - "github.com/RedHatInsights/insights-content-service/groups" - "github.com/RedHatInsights/insights-operator-utils/responses" - "github.com/RedHatInsights/insights-results-aggregator/types" - "github.com/gorilla/mux" - "github.com/rs/zerolog/log" + httputils "github.com/RedHatInsights/insights-results-aggregator-utils/http" + ira_server "github.com/RedHatInsights/insights-results-aggregator/server" + "github.com/RedHatInsights/insights-results-smart-proxy/content" "github.com/RedHatInsights/insights-results-smart-proxy/services" + + proxy_types "github.com/RedHatInsights/insights-results-smart-proxy/types" ) // HTTPServer in an implementation of Server interface @@ -50,17 +56,15 @@ type HTTPServer struct { Config Configuration ServicesConfig services.Configuration GroupsChannel chan []groups.Group - ContentChannel chan content.RuleContentDirectory Serv *http.Server } // New constructs new implementation of Server interface -func New(config Configuration, servicesConfig services.Configuration, groupsChannel chan []groups.Group, contentChannel chan content.RuleContentDirectory) *HTTPServer { +func New(config Configuration, servicesConfig services.Configuration, groupsChannel chan []groups.Group) *HTTPServer { return &HTTPServer{ Config: config, ServicesConfig: servicesConfig, GroupsChannel: groupsChannel, - ContentChannel: contentChannel, } } @@ -232,14 +236,14 @@ func (server HTTPServer) proxyTo(baseURL string) func(http.ResponseWriter, *http handleServerError(writer, err) } - content, err := ioutil.ReadAll(response.Body) + body, err := ioutil.ReadAll(response.Body) if err != nil { log.Error().Err(err).Msgf("Error while retrieving content from request to %s", endpointURL.String()) handleServerError(writer, err) } // Maybe this code should be on responses.SendRaw or something like that - err = responses.Send(response.StatusCode, writer, content) + err = responses.Send(response.StatusCode, writer, body) if err != nil { log.Error().Err(err).Msgf("Error writing the response") handleServerError(writer, err) @@ -259,3 +263,113 @@ func copyHeader(srcHeaders http.Header, dstHeaders http.Header) { } } } + +// readAggregatorReportForClusterID reads report from aggregator, +// handles errors by sending corresponding message to the user. +// Returns report and bool value set to true if there was no errors +func (server HTTPServer) readAggregatorReportForClusterID( + orgID types.OrgID, clusterID types.ClusterName, userID types.UserID, writer http.ResponseWriter, +) (*types.ReportResponse, bool) { + aggregatorURL := httputils.MakeURLToEndpoint( + server.ServicesConfig.AggregatorBaseEndpoint, + ira_server.ReportEndpoint, + orgID, + clusterID, + userID, + ) + + aggregatorResp, err := http.Get(aggregatorURL) + if err != nil { + handleServerError(writer, err) + return nil, false + } + + var aggregatorResponse struct { + Report *types.ReportResponse `json:"report"` + Status string `json:"status"` + } + + responseBytes, err := ioutil.ReadAll(aggregatorResp.Body) + if err != nil { + handleServerError(writer, err) + return nil, false + } + + if aggregatorResp.StatusCode != http.StatusOK { + err := responses.Send(aggregatorResp.StatusCode, writer, responseBytes) + if err != nil { + log.Error().Err(err).Msg(responseDataError) + } + return nil, false + } + + err = json.Unmarshal(responseBytes, &aggregatorResponse) + if err != nil { + handleServerError(writer, err) + return nil, false + } + + return aggregatorResponse.Report, true +} + +func (server HTTPServer) reportEndpoint(writer http.ResponseWriter, request *http.Request) { + clusterID, successful := httputils.ReadClusterName(writer, request) + if !successful { + return + } + + authToken, err := server.GetAuthToken(request) + if err != nil { + handleServerError(writer, err) + return + } + + userID := authToken.AccountNumber + orgID := authToken.Internal.OrgID + + aggregatorResponse, successful := server.readAggregatorReportForClusterID(orgID, clusterID, userID, writer) + if !successful { + return + } + + var rules []proxy_types.RuleWithContentResponse + + for _, aggregatorRule := range aggregatorResponse.Report { + ruleID := aggregatorRule.Module + errorKey := aggregatorRule.ErrorKey + + ruleWithContent, err := content.GetRuleWithErrorKeyContent(ruleID, errorKey) + if err != nil { + handleServerError(writer, err) + return + } + + rule := proxy_types.RuleWithContentResponse{ + CreatedAt: ruleWithContent.PublishDate.UTC().Format(time.RFC3339), + Description: ruleWithContent.Description, + ErrorKey: errorKey, + Generic: ruleWithContent.Generic, + Reason: ruleWithContent.Reason, + Resolution: ruleWithContent.Resolution, + TotalRisk: ruleWithContent.TotalRisk, + RiskOfChange: ruleWithContent.RiskOfChange, + RuleID: ruleID, + TemplateData: aggregatorRule.TemplateData, + Tags: ruleWithContent.Tags, + UserVote: aggregatorRule.UserVote, + Disabled: aggregatorRule.Disabled, + } + + rules = append(rules, rule) + } + + report := proxy_types.SmartProxyReport{ + Meta: aggregatorResponse.Meta, + Data: rules, + } + + err = responses.SendOK(writer, responses.BuildOkResponseWithData("report", report)) + if err != nil { + log.Error().Err(err).Msg(responseDataError) + } +} diff --git a/server/server_test.go b/server/server_test.go index 0242181a..ebda02b8 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -17,35 +17,34 @@ limitations under the License. package server_test import ( + "bytes" + "encoding/gob" + "github.com/RedHatInsights/insights-results-smart-proxy/content" + "io/ioutil" + "net/http" "testing" + "time" + ics_server "github.com/RedHatInsights/insights-content-service/server" + "github.com/RedHatInsights/insights-results-aggregator-data/testdata" + ira_server "github.com/RedHatInsights/insights-results-aggregator/server" "github.com/rs/zerolog" "github.com/stretchr/testify/assert" + gock "gopkg.in/h2non/gock.v1" "github.com/RedHatInsights/insights-results-smart-proxy/server" "github.com/RedHatInsights/insights-results-smart-proxy/services" + "github.com/RedHatInsights/insights-results-smart-proxy/tests/helpers" ) -var config = server.Configuration{ - Address: ":8080", - APIPrefix: "/api/test/", - APISpecFile: "openapi.json", - Debug: true, - Auth: false, - UseHTTPS: false, - EnableCORS: true, -} +const ( + testTimeout = 10 * time.Second +) func init() { zerolog.SetGlobalLevel(zerolog.WarnLevel) } -func checkResponseCode(t *testing.T, expected, actual int) { - if expected != actual { - t.Errorf("Expected response code %d. Got %d\n", expected, actual) - } -} - func TestServerStartError(t *testing.T) { testServer := server.New(server.Configuration{ Address: "localhost:99999", @@ -55,9 +54,53 @@ func TestServerStartError(t *testing.T) { ContentBaseEndpoint: "http://localhost:8082/api/v1/", }, nil, - nil, ) err := testServer.Start() assert.EqualError(t, err, "listen tcp: address 99999: invalid port") } + +func MustGobSerialize(t testing.TB, obj interface{}) []byte { + buf := new(bytes.Buffer) + + err := gob.NewEncoder(buf).Encode(obj) + helpers.FailOnError(t, err) + + res, err := ioutil.ReadAll(buf) + helpers.FailOnError(t, err) + + return res +} + +func TestHTTPServer_ReportEndpoint(t *testing.T) { + helpers.RunTestWithTimeout(t, func(t *testing.T) { + defer gock.Off() + + gock.New(helpers.DefaultServicesConfig.AggregatorBaseEndpoint). + Get("/"). + AddMatcher(helpers.NewGockAPIEndpointMatcher(ira_server.ReportEndpoint)). + Reply(200). + JSON(testdata.Report3RulesExpectedResponse) + + gock.New(helpers.DefaultServicesConfig.ContentBaseEndpoint). + Get("/"). + AddMatcher(helpers.NewGockAPIEndpointMatcher(ics_server.AllContentEndpoint)). + Reply(200). + Body(bytes.NewBuffer(MustGobSerialize(t, &testdata.RuleContentDirectory3Rules))) + + go content.RunUpdateContentLoop(helpers.DefaultServicesConfig) + + helpers.AssertAPIRequest(t, nil, nil, nil, &helpers.APIRequest{ + Method: http.MethodGet, + Endpoint: server.ReportEndpoint, + EndpointArgs: []interface{}{testdata.ClusterName}, + UserID: testdata.UserID, + OrgID: testdata.OrgID, + }, &helpers.APIResponse{ + StatusCode: http.StatusOK, + Body: helpers.ToJSONString(testdata.SmartProxyReportResponse3Rules), + }) + }, testTimeout) +} + +// TODO: test more cases for report endpoint diff --git a/services/services.go b/services/services.go index 818a3813..6625d66f 100644 --- a/services/services.go +++ b/services/services.go @@ -18,6 +18,7 @@ import ( "bytes" "encoding/gob" "encoding/json" + "io/ioutil" "net/http" "net/url" @@ -81,32 +82,22 @@ func GetGroups(conf Configuration) ([]groups.Group, error) { // GetContent get the static rule content from content-service func GetContent(conf Configuration) (*content.RuleContentDirectory, error) { - type contentResponse struct { - Status string `json:"status"` - EncodedContent []byte `json:"rule-content"` - } - var receivedMsg contentResponse - - log.Info().Msg("Updating rules static content") + log.Info().Msg("getting rules static content") resp, err := getFromURL(conf.ContentBaseEndpoint + ContentEndpoint) if err != nil { - // Log already shown return nil, err } - err = json.NewDecoder(resp.Body).Decode(&receivedMsg) + respBytes, err := ioutil.ReadAll(resp.Body) if err != nil { - log.Error().Err(err).Msg("Error while decoding static content answer from content-service") return nil, err } var receivedContent content.RuleContentDirectory - encodedContent := bytes.NewBuffer(receivedMsg.EncodedContent) - err = gob.NewDecoder(encodedContent).Decode(&receivedContent) - + err = gob.NewDecoder(bytes.NewReader(respBytes)).Decode(&receivedContent) if err != nil { - log.Error().Err(err).Msg("Error trying to decode rules content from received answer") + log.Error().Err(err).Msg("error trying to decode rules content from received answer") return nil, err } diff --git a/smart_proxy.go b/smart_proxy.go index f2e5bda1..142c766d 100644 --- a/smart_proxy.go +++ b/smart_proxy.go @@ -25,13 +25,14 @@ import ( "strings" "time" - "github.com/RedHatInsights/insights-content-service/content" "github.com/RedHatInsights/insights-content-service/groups" "github.com/rs/zerolog/log" "github.com/RedHatInsights/insights-results-smart-proxy/conf" "github.com/RedHatInsights/insights-results-smart-proxy/server" "github.com/RedHatInsights/insights-results-smart-proxy/services" + + proxy_content "github.com/RedHatInsights/insights-results-smart-proxy/content" ) const ( @@ -94,10 +95,10 @@ func startServer() int { serverCfg := conf.GetServerConfiguration() servicesCfg := conf.GetServicesConfiguration() groupsChannel := make(chan []groups.Group) - contentChannel := make(chan content.RuleContentDirectory) - serverInstance = server.New(serverCfg, servicesCfg, groupsChannel, contentChannel) + serverInstance = server.New(serverCfg, servicesCfg, groupsChannel) - go updateGroupInfo(servicesCfg, groupsChannel, contentChannel) + go updateGroupInfo(servicesCfg, groupsChannel) + go proxy_content.RunUpdateContentLoop(servicesCfg) err := serverInstance.Start() if err != nil { @@ -111,9 +112,8 @@ func startServer() int { // updateGroupInfo function is run in a goroutine. It runs forever, waiting for 1 of 2 events: a Ticker or a channel // * If ticker comes first, the groups configuration is updated, doing a request to the content-service // * If the channel comes first, the latest valid groups configuration is send through the channel -func updateGroupInfo(servicesConf services.Configuration, groupsChannel chan []groups.Group, contentChannel chan content.RuleContentDirectory) { +func updateGroupInfo(servicesConf services.Configuration, groupsChannel chan []groups.Group) { var currentGroups []groups.Group - currentContent := &content.RuleContentDirectory{} groups, err := services.GetGroups(servicesConf) if err != nil { @@ -122,13 +122,6 @@ func updateGroupInfo(servicesConf services.Configuration, groupsChannel chan []g currentGroups = groups } - content, err := services.GetContent(servicesConf) - if err != nil { - log.Error().Err(err).Msg("Error retrieving static content") - } else { - currentContent = content - } - uptimeTicker := time.NewTicker(servicesConf.GroupsPollingTime) log.Info().Msgf("Updating groups configuration each %f seconds", servicesConf.GroupsPollingTime.Seconds()) @@ -141,16 +134,7 @@ func updateGroupInfo(servicesConf services.Configuration, groupsChannel chan []g } else { currentGroups = groups } - - content, err = services.GetContent(servicesConf) - if err != nil { - log.Error().Err(err).Msg("Error retrieving static content") - } else { - currentContent = content - } - case groupsChannel <- currentGroups: - case contentChannel <- *currentContent: } } } @@ -193,12 +177,11 @@ func main() { showVersion bool ) flag.BoolVar(&showHelp, "help", false, "Show the help") - flag.BoolVar(&showVersion, "version", false, "Show the version an exit") + flag.BoolVar(&showVersion, "version", false, "Show the version and exit") flag.Parse() if showHelp { - printHelp() - os.Exit(ExitStatusOK) + os.Exit(printHelp()) } if showVersion { @@ -206,8 +189,7 @@ func main() { os.Exit(ExitStatusOK) } - var args []string - args = flag.Args() + args := flag.Args() command := "start-service" if len(args) >= 1 { diff --git a/tests/helpers/errors.go b/tests/helpers/errors.go new file mode 100644 index 00000000..da1018a6 --- /dev/null +++ b/tests/helpers/errors.go @@ -0,0 +1,5 @@ +package helpers + +import "github.com/RedHatInsights/insights-results-aggregator-utils/tests/helpers" + +var FailOnError = helpers.FailOnError diff --git a/tests/helpers/http.go b/tests/helpers/http.go new file mode 100644 index 00000000..e718fe22 --- /dev/null +++ b/tests/helpers/http.go @@ -0,0 +1,70 @@ +package helpers + +import ( + "testing" + "time" + + "github.com/RedHatInsights/insights-content-service/groups" + "github.com/RedHatInsights/insights-results-aggregator-utils/tests/helpers" + + "github.com/RedHatInsights/insights-results-smart-proxy/server" + "github.com/RedHatInsights/insights-results-smart-proxy/services" +) + +type APIRequest = helpers.APIRequest +type APIResponse = helpers.APIResponse + +var ( + ExecuteRequest = helpers.ExecuteRequest + CheckResponseBodyJSON = helpers.CheckResponseBodyJSON + AssertReportResponsesEqual = helpers.AssertReportResponsesEqual + NewGockAPIEndpointMatcher = helpers.NewGockAPIEndpointMatcher +) + +var ( + DefaultServerConfig = server.Configuration{ + Address: ":8081", + APIPrefix: "/api/v1/", + APISpecFile: "openapi.json", + Debug: true, + Auth: false, + AuthType: "", + UseHTTPS: false, + EnableCORS: false, + } + + DefaultServicesConfig = services.Configuration{ + AggregatorBaseEndpoint: "http://localhost:8080/", + ContentBaseEndpoint: "http://localhost:8082/", + GroupsPollingTime: 1 * time.Minute, + } +) + +// AssertAPIRequest creates new server with provided +// serverConfig, servicesConfig (you can leave them nil to use the default ones), +// groupsChannel and contentChannel(can be nil) +// sends api request and checks api response (see docs for APIRequest and APIResponse) +func AssertAPIRequest( + t testing.TB, + serverConfig *server.Configuration, + servicesConfig *services.Configuration, + groupsChannel chan []groups.Group, + request *helpers.APIRequest, + expectedResponse *helpers.APIResponse, +) { + if serverConfig == nil { + serverConfig = &DefaultServerConfig + } + if servicesConfig == nil { + servicesConfig = &DefaultServicesConfig + } + + testServer := server.New( + *serverConfig, + *servicesConfig, + groupsChannel, + ) + + helpers.AssertAPIRequest(t, testServer, serverConfig.APIPrefix, request, expectedResponse) +} + diff --git a/tests/helpers/json.go b/tests/helpers/json.go new file mode 100644 index 00000000..d75302f7 --- /dev/null +++ b/tests/helpers/json.go @@ -0,0 +1,5 @@ +package helpers + +import "github.com/RedHatInsights/insights-results-aggregator-utils/tests/helpers" + +var ToJSONString = helpers.ToJSONString diff --git a/tests/helpers/timeout.go b/tests/helpers/timeout.go new file mode 100644 index 00000000..eb326987 --- /dev/null +++ b/tests/helpers/timeout.go @@ -0,0 +1,6 @@ +package helpers + +import "github.com/RedHatInsights/insights-results-aggregator-utils/tests/helpers" + +// RunTestWithTimeout runs test with timeToRun timeout and fails if it wasn't in time +var RunTestWithTimeout = helpers.RunTestWithTimeout diff --git a/types/types.go b/types/types.go new file mode 100644 index 00000000..622a847d --- /dev/null +++ b/types/types.go @@ -0,0 +1,35 @@ +package types + +import "github.com/RedHatInsights/insights-results-aggregator-utils/types" + +// UserID represents type for user id +type UserID = types.UserID + +// ReportResponseMeta contains metadata about the report +type ReportResponseMeta = types.ReportResponseMeta + +// Timestamp represents any timestamp in a form gathered from database +type Timestamp = types.Timestamp + +// RuleWithContentResponse represents a single rule in the response of /report endpoint +type RuleWithContentResponse struct { + RuleID types.RuleID `json:"rule_id"` + ErrorKey types.ErrorKey `json:"-"` + CreatedAt string `json:"created_at"` + Description string `json:"description"` + Generic string `json:"details"` + Reason string `json:"reason"` + Resolution string `json:"resolution"` + TotalRisk int `json:"total_risk"` + RiskOfChange int `json:"risk_of_change"` + Disabled bool `json:"disabled"` + UserVote types.UserVote `json:"user_vote"` + TemplateData interface{} `json:"extra_data"` + Tags []string `json:"tags"` +} + +// ReportResponse represents the response of /report endpoint +type SmartProxyReport struct { + Meta types.ReportResponseMeta `json:"meta"` + Data []RuleWithContentResponse `json:"data"` +} From fa612c8fb7620e7b045b62be883d1ab2693ee9bf Mon Sep 17 00:00:00 2001 From: Serhii Zakharov Date: Sun, 21 Jun 2020 13:53:57 +0200 Subject: [PATCH 02/14] fixed style --- content/content.go | 18 ++++++++++++++++++ content/parsing.go | 14 ++++++++++++++ server/server.go | 1 + tests/helpers/errors.go | 15 +++++++++++++++ tests/helpers/http.go | 28 +++++++++++++++++++++++++--- tests/helpers/json.go | 15 +++++++++++++++ tests/helpers/timeout.go | 14 ++++++++++++++ types/types.go | 16 +++++++++++++++- 8 files changed, 117 insertions(+), 4 deletions(-) diff --git a/content/content.go b/content/content.go index 79eeff81..77d3827d 100644 --- a/content/content.go +++ b/content/content.go @@ -1,3 +1,17 @@ +// Copyright 2020 Red Hat, Inc +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + // Package content provides API to get rule's content by its `rule id` and `error key`. // It takes all the work of caching rules taken from content service package content @@ -33,6 +47,7 @@ type RulesWithContentStorage struct { rules map[types.RuleID]*ics_content.RuleContent } +// GetRuleWithErrorKeyContent returns content for rule with error key func (s *RulesWithContentStorage) GetRuleWithErrorKeyContent( ruleID types.RuleID, errorKey types.ErrorKey, ) (*types.RuleWithContent, bool) { @@ -46,6 +61,7 @@ func (s *RulesWithContentStorage) GetRuleWithErrorKeyContent( return res, found } +// GetRuleContent returns content for rule func (s *RulesWithContentStorage) GetRuleContent(ruleID types.RuleID) (*ics_content.RuleContent, bool) { s.RLock() defer s.RUnlock() @@ -54,6 +70,7 @@ func (s *RulesWithContentStorage) GetRuleContent(ruleID types.RuleID) (*ics_cont return res, found } +// SetRuleWithContent sets content for rule with error key func (s *RulesWithContentStorage) SetRuleWithContent( ruleID types.RuleID, errorKey types.ErrorKey, ruleWithContent *types.RuleWithContent, ) { @@ -66,6 +83,7 @@ func (s *RulesWithContentStorage) SetRuleWithContent( }] = ruleWithContent } +// SetRule sets content for rule func (s *RulesWithContentStorage) SetRule( ruleID types.RuleID, ruleContent *ics_content.RuleContent, ) { diff --git a/content/parsing.go b/content/parsing.go index 3d37714f..20c2f491 100644 --- a/content/parsing.go +++ b/content/parsing.go @@ -1,3 +1,17 @@ +// Copyright 2020 Red Hat, Inc +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package content import ( diff --git a/server/server.go b/server/server.go index acecbd44..4eae44e4 100644 --- a/server/server.go +++ b/server/server.go @@ -278,6 +278,7 @@ func (server HTTPServer) readAggregatorReportForClusterID( userID, ) + // #nosec G107 aggregatorResp, err := http.Get(aggregatorURL) if err != nil { handleServerError(writer, err) diff --git a/tests/helpers/errors.go b/tests/helpers/errors.go index da1018a6..65606df8 100644 --- a/tests/helpers/errors.go +++ b/tests/helpers/errors.go @@ -1,5 +1,20 @@ +// Copyright 2020 Red Hat, Inc +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package helpers import "github.com/RedHatInsights/insights-results-aggregator-utils/tests/helpers" +// FailOnError fails on error var FailOnError = helpers.FailOnError diff --git a/tests/helpers/http.go b/tests/helpers/http.go index e718fe22..7d1471fa 100644 --- a/tests/helpers/http.go +++ b/tests/helpers/http.go @@ -1,3 +1,17 @@ +// Copyright 2020 Red Hat, Inc +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package helpers import ( @@ -11,17 +25,25 @@ import ( "github.com/RedHatInsights/insights-results-smart-proxy/services" ) +// APIRequest represents APIRequest type APIRequest = helpers.APIRequest + +// APIResponse represents APIResponse type APIResponse = helpers.APIResponse var ( - ExecuteRequest = helpers.ExecuteRequest - CheckResponseBodyJSON = helpers.CheckResponseBodyJSON + // ExecuteRequest executes request + ExecuteRequest = helpers.ExecuteRequest + // CheckResponseBodyJSON checks response body + CheckResponseBodyJSON = helpers.CheckResponseBodyJSON + // AssertReportResponsesEqual fails if report responses aren't equal AssertReportResponsesEqual = helpers.AssertReportResponsesEqual + // NewGockAPIEndpointMatcher creates a matcher for a given endpoint for gock NewGockAPIEndpointMatcher = helpers.NewGockAPIEndpointMatcher ) var ( + // DefaultServerConfig is a default server config DefaultServerConfig = server.Configuration{ Address: ":8081", APIPrefix: "/api/v1/", @@ -33,6 +55,7 @@ var ( EnableCORS: false, } + // DefaultServicesConfig is a default services config DefaultServicesConfig = services.Configuration{ AggregatorBaseEndpoint: "http://localhost:8080/", ContentBaseEndpoint: "http://localhost:8082/", @@ -67,4 +90,3 @@ func AssertAPIRequest( helpers.AssertAPIRequest(t, testServer, serverConfig.APIPrefix, request, expectedResponse) } - diff --git a/tests/helpers/json.go b/tests/helpers/json.go index d75302f7..3adc9333 100644 --- a/tests/helpers/json.go +++ b/tests/helpers/json.go @@ -1,5 +1,20 @@ +// Copyright 2020 Red Hat, Inc +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package helpers import "github.com/RedHatInsights/insights-results-aggregator-utils/tests/helpers" +// ToJSONString converts anything to json string var ToJSONString = helpers.ToJSONString diff --git a/tests/helpers/timeout.go b/tests/helpers/timeout.go index eb326987..474ae48f 100644 --- a/tests/helpers/timeout.go +++ b/tests/helpers/timeout.go @@ -1,3 +1,17 @@ +// Copyright 2020 Red Hat, Inc +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package helpers import "github.com/RedHatInsights/insights-results-aggregator-utils/tests/helpers" diff --git a/types/types.go b/types/types.go index 622a847d..0b7c248f 100644 --- a/types/types.go +++ b/types/types.go @@ -1,3 +1,17 @@ +// Copyright 2020 Red Hat, Inc +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package types import "github.com/RedHatInsights/insights-results-aggregator-utils/types" @@ -28,7 +42,7 @@ type RuleWithContentResponse struct { Tags []string `json:"tags"` } -// ReportResponse represents the response of /report endpoint +// SmartProxyReport represents the response of /report endpoint for smart proxy type SmartProxyReport struct { Meta types.ReportResponseMeta `json:"meta"` Data []RuleWithContentResponse `json:"data"` From 1610ddfcbb8354827dbb123aae5a50f8ed3cbd05 Mon Sep 17 00:00:00 2001 From: Serhii Zakharov Date: Mon, 22 Jun 2020 12:00:10 +0200 Subject: [PATCH 03/14] moved shared code to operator-utils --- content/content.go | 2 +- content/parsing.go | 2 +- go.mod | 1 - go.sum | 2 -- server/auth.go | 2 +- server/endpoints.go | 10 ---------- server/endpoints_test.go | 2 +- server/errors.go | 2 +- server/router_utils.go | 2 +- server/server.go | 4 ++-- tests/helpers/errors.go | 20 -------------------- tests/helpers/helpers.go | 12 ++++++++++++ tests/helpers/http.go | 2 +- tests/helpers/json.go | 20 -------------------- tests/helpers/timeout.go | 20 -------------------- types/types.go | 2 +- 16 files changed, 22 insertions(+), 83 deletions(-) delete mode 100644 tests/helpers/errors.go create mode 100644 tests/helpers/helpers.go delete mode 100644 tests/helpers/json.go delete mode 100644 tests/helpers/timeout.go diff --git a/content/content.go b/content/content.go index 77d3827d..29a68692 100644 --- a/content/content.go +++ b/content/content.go @@ -23,7 +23,7 @@ import ( "github.com/RedHatInsights/insights-content-service/content" ics_content "github.com/RedHatInsights/insights-content-service/content" - "github.com/RedHatInsights/insights-results-aggregator-utils/types" + "github.com/RedHatInsights/insights-operator-utils/types" "github.com/rs/zerolog/log" "github.com/RedHatInsights/insights-results-smart-proxy/services" diff --git a/content/parsing.go b/content/parsing.go index 20c2f491..52985d02 100644 --- a/content/parsing.go +++ b/content/parsing.go @@ -19,7 +19,7 @@ import ( "time" "github.com/RedHatInsights/insights-content-service/content" - "github.com/RedHatInsights/insights-results-aggregator-utils/types" + "github.com/RedHatInsights/insights-operator-utils/types" "github.com/rs/zerolog/log" ) diff --git a/go.mod b/go.mod index 1ac9663e..8dee82d1 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,6 @@ require ( github.com/RedHatInsights/insights-operator-utils v1.0.2-0.20200610143236-c868b2f93d2a github.com/RedHatInsights/insights-results-aggregator v0.0.0-20200604090056-3534f6dd9c1c github.com/RedHatInsights/insights-results-aggregator-data v0.0.0-20200512064850-2d04c5d0c9a6 - github.com/RedHatInsights/insights-results-aggregator-utils v0.0.0-20200616074815-67f30b0e724d github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 github.com/dgrijalva/jwt-go v3.2.0+incompatible github.com/google/uuid v1.1.1 diff --git a/go.sum b/go.sum index ab3f4da2..e2a364d3 100644 --- a/go.sum +++ b/go.sum @@ -31,8 +31,6 @@ github.com/RedHatInsights/insights-results-aggregator v0.0.0-20200604090056-3534 github.com/RedHatInsights/insights-results-aggregator v0.0.0-20200604090056-3534f6dd9c1c/go.mod h1:7Pc15NYXErx7BMJ4rF1Hacm+29G6atzjhwBpXNFMt+0= github.com/RedHatInsights/insights-results-aggregator-data v0.0.0-20200512064850-2d04c5d0c9a6 h1:Yt6Znx4OoMNRENCBdphqhu78EO/y2VD50DEC0b6mCrk= github.com/RedHatInsights/insights-results-aggregator-data v0.0.0-20200512064850-2d04c5d0c9a6/go.mod h1:O5X07zyJ9soaH2gMtYUNaJN6/9wt0E4J5TmheNBSdgc= -github.com/RedHatInsights/insights-results-aggregator-utils v0.0.0-20200616074815-67f30b0e724d h1:7fqXh2MMijj5YXTjzPFsOHCO+nXegHk7IVX0lCLl1ac= -github.com/RedHatInsights/insights-results-aggregator-utils v0.0.0-20200616074815-67f30b0e724d/go.mod h1:a2r0OkXqBR7MqsnIjEn1FVwZIGQO9ROnbjfV2ZelVvE= github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= github.com/Shopify/sarama v1.26.0 h1:C+zFi+/NJdfeJgZWbu+WaLgk4NcsbmqfFTKsoJmR39U= github.com/Shopify/sarama v1.26.0/go.mod h1:y/CFFTO9eaMTNriwu/Q+W4eioLqiDMGkA1W+gmdfj8w= diff --git a/server/auth.go b/server/auth.go index 4a3d6f3a..f0104636 100644 --- a/server/auth.go +++ b/server/auth.go @@ -26,7 +26,7 @@ import ( "strings" "github.com/RedHatInsights/insights-operator-utils/collections" - "github.com/RedHatInsights/insights-results-aggregator-utils/types" + "github.com/RedHatInsights/insights-operator-utils/types" "github.com/dgrijalva/jwt-go" "github.com/rs/zerolog/log" ) diff --git a/server/endpoints.go b/server/endpoints.go index ca7a8964..b270b2d4 100644 --- a/server/endpoints.go +++ b/server/endpoints.go @@ -47,9 +47,6 @@ const ( DisableRuleForClusterEndpoint = ira_server.DisableRuleForClusterEndpoint // EnableRuleForClusterEndpoint re-enables a rule for specified cluster EnableRuleForClusterEndpoint = ira_server.EnableRuleForClusterEndpoint - // RuleErrorKeyEndpoint is for endpoints to create&delete a rule_error_key (DEBUG only) - // and for endpoint to get a rule - RuleErrorKeyEndpoint = ira_server.RuleErrorKeyEndpoint // OrganizationsEndpoint returns all organizations OrganizationsEndpoint = ira_server.OrganizationsEndpoint // DeleteOrganizationsEndpoint deletes all {organizations}(comma separated array). DEBUG only @@ -58,8 +55,6 @@ const ( DeleteClustersEndpoint = ira_server.DeleteClustersEndpoint // GetVoteOnRuleEndpoint is an endpoint to get vote on rule. DEBUG only GetVoteOnRuleEndpoint = ira_server.GetVoteOnRuleEndpoint - // RuleEndpoint is an endpoint to create&delete a rule. DEBUG only - RuleEndpoint = ira_server.RuleEndpoint ) func (server *HTTPServer) addDebugEndpointsToRouter(router *mux.Router) { @@ -70,10 +65,6 @@ func (server *HTTPServer) addDebugEndpointsToRouter(router *mux.Router) { router.HandleFunc(apiPrefix+DeleteOrganizationsEndpoint, server.proxyTo(aggregatorEndpoint)).Methods(http.MethodDelete) router.HandleFunc(apiPrefix+DeleteClustersEndpoint, server.proxyTo(aggregatorEndpoint)).Methods(http.MethodDelete) router.HandleFunc(apiPrefix+GetVoteOnRuleEndpoint, server.proxyTo(aggregatorEndpoint)).Methods(http.MethodGet) - router.HandleFunc(apiPrefix+RuleEndpoint, server.proxyTo(aggregatorEndpoint)).Methods(http.MethodPost) - router.HandleFunc(apiPrefix+RuleErrorKeyEndpoint, server.proxyTo(aggregatorEndpoint)).Methods(http.MethodPost) - router.HandleFunc(apiPrefix+RuleEndpoint, server.proxyTo(aggregatorEndpoint)).Methods(http.MethodDelete) - router.HandleFunc(apiPrefix+RuleErrorKeyEndpoint, server.proxyTo(aggregatorEndpoint)).Methods(http.MethodDelete) // endpoints for pprof - needed for profiling, ie. usually in debug mode router.PathPrefix("/debug/pprof/").Handler(http.DefaultServeMux) @@ -99,7 +90,6 @@ func (server *HTTPServer) addEndpointsToRouter(router *mux.Router) { router.HandleFunc(apiPrefix+DisableRuleForClusterEndpoint, server.proxyTo(aggregatorEndpoint)).Methods(http.MethodPut, http.MethodOptions) router.HandleFunc(apiPrefix+EnableRuleForClusterEndpoint, server.proxyTo(aggregatorEndpoint)).Methods(http.MethodPut, http.MethodOptions) router.HandleFunc(apiPrefix+RuleGroupsEndpoint, server.getGroups).Methods(http.MethodGet, http.MethodOptions) - router.HandleFunc(apiPrefix+RuleErrorKeyEndpoint, server.proxyTo(aggregatorEndpoint)).Methods(http.MethodGet) router.HandleFunc(apiPrefix+RuleContent, server.getContentForRule).Methods(http.MethodGet) // Prometheus metrics diff --git a/server/endpoints_test.go b/server/endpoints_test.go index 25a62778..28f346e1 100644 --- a/server/endpoints_test.go +++ b/server/endpoints_test.go @@ -17,7 +17,7 @@ package server_test import ( "testing" - httputils "github.com/RedHatInsights/insights-results-aggregator-utils/http" + httputils "github.com/RedHatInsights/insights-operator-utils/http" "github.com/stretchr/testify/assert" ) diff --git a/server/errors.go b/server/errors.go index e1000b5f..04847b83 100644 --- a/server/errors.go +++ b/server/errors.go @@ -20,7 +20,7 @@ import ( "net/http" "github.com/RedHatInsights/insights-operator-utils/responses" - "github.com/RedHatInsights/insights-results-aggregator-utils/types" + "github.com/RedHatInsights/insights-operator-utils/types" "github.com/rs/zerolog/log" ) diff --git a/server/router_utils.go b/server/router_utils.go index 17468197..b262202d 100644 --- a/server/router_utils.go +++ b/server/router_utils.go @@ -22,7 +22,7 @@ import ( "strconv" "strings" - "github.com/RedHatInsights/insights-results-aggregator-utils/types" + "github.com/RedHatInsights/insights-operator-utils/types" "github.com/google/uuid" "github.com/gorilla/mux" "github.com/rs/zerolog/log" diff --git a/server/server.go b/server/server.go index 4eae44e4..a620a199 100644 --- a/server/server.go +++ b/server/server.go @@ -33,7 +33,7 @@ import ( "github.com/RedHatInsights/insights-content-service/groups" "github.com/RedHatInsights/insights-operator-utils/responses" - "github.com/RedHatInsights/insights-results-aggregator-utils/types" + "github.com/RedHatInsights/insights-operator-utils/types" "github.com/gorilla/mux" "github.com/rs/zerolog/log" // we just have to import this package in order to expose pprof interface in debug mode @@ -42,7 +42,7 @@ import ( _ "net/http/pprof" "path/filepath" - httputils "github.com/RedHatInsights/insights-results-aggregator-utils/http" + httputils "github.com/RedHatInsights/insights-operator-utils/http" ira_server "github.com/RedHatInsights/insights-results-aggregator/server" "github.com/RedHatInsights/insights-results-smart-proxy/content" diff --git a/tests/helpers/errors.go b/tests/helpers/errors.go deleted file mode 100644 index 65606df8..00000000 --- a/tests/helpers/errors.go +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2020 Red Hat, Inc -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package helpers - -import "github.com/RedHatInsights/insights-results-aggregator-utils/tests/helpers" - -// FailOnError fails on error -var FailOnError = helpers.FailOnError diff --git a/tests/helpers/helpers.go b/tests/helpers/helpers.go new file mode 100644 index 00000000..6d7151ea --- /dev/null +++ b/tests/helpers/helpers.go @@ -0,0 +1,12 @@ +package helpers + +import "github.com/RedHatInsights/insights-operator-utils/tests/helpers" + +// FailOnError fails on error +var FailOnError = helpers.FailOnError + +// ToJSONString converts anything to json string +var ToJSONString = helpers.ToJSONString + +// RunTestWithTimeout runs test with timeToRun timeout and fails if it wasn't in time +var RunTestWithTimeout = helpers.RunTestWithTimeout diff --git a/tests/helpers/http.go b/tests/helpers/http.go index 7d1471fa..2cf8454f 100644 --- a/tests/helpers/http.go +++ b/tests/helpers/http.go @@ -19,7 +19,7 @@ import ( "time" "github.com/RedHatInsights/insights-content-service/groups" - "github.com/RedHatInsights/insights-results-aggregator-utils/tests/helpers" + "github.com/RedHatInsights/insights-operator-utils/tests/helpers" "github.com/RedHatInsights/insights-results-smart-proxy/server" "github.com/RedHatInsights/insights-results-smart-proxy/services" diff --git a/tests/helpers/json.go b/tests/helpers/json.go deleted file mode 100644 index 3adc9333..00000000 --- a/tests/helpers/json.go +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2020 Red Hat, Inc -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package helpers - -import "github.com/RedHatInsights/insights-results-aggregator-utils/tests/helpers" - -// ToJSONString converts anything to json string -var ToJSONString = helpers.ToJSONString diff --git a/tests/helpers/timeout.go b/tests/helpers/timeout.go deleted file mode 100644 index 474ae48f..00000000 --- a/tests/helpers/timeout.go +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2020 Red Hat, Inc -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package helpers - -import "github.com/RedHatInsights/insights-results-aggregator-utils/tests/helpers" - -// RunTestWithTimeout runs test with timeToRun timeout and fails if it wasn't in time -var RunTestWithTimeout = helpers.RunTestWithTimeout diff --git a/types/types.go b/types/types.go index 0b7c248f..cae3e8d8 100644 --- a/types/types.go +++ b/types/types.go @@ -14,7 +14,7 @@ package types -import "github.com/RedHatInsights/insights-results-aggregator-utils/types" +import "github.com/RedHatInsights/insights-operator-utils/types" // UserID represents type for user id type UserID = types.UserID From fd99b2d58abca993321f8df11464cf797ee694fc Mon Sep 17 00:00:00 2001 From: Serhii Zakharov Date: Mon, 22 Jun 2020 12:18:23 +0200 Subject: [PATCH 04/14] fixed openapi & duplicated import --- content/content.go | 3 +-- openapi.json | 16 +++------------- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/content/content.go b/content/content.go index 29a68692..b37bb6de 100644 --- a/content/content.go +++ b/content/content.go @@ -21,7 +21,6 @@ import ( "sync" "time" - "github.com/RedHatInsights/insights-content-service/content" ics_content "github.com/RedHatInsights/insights-content-service/content" "github.com/RedHatInsights/insights-operator-utils/types" "github.com/rs/zerolog/log" @@ -30,7 +29,7 @@ import ( ) var ( - ruleContentDirectory *content.RuleContentDirectory + ruleContentDirectory *ics_content.RuleContentDirectory ruleContentDirectoryReady = make(chan struct{}) ) diff --git a/openapi.json b/openapi.json index d278c490..376ad9ac 100644 --- a/openapi.json +++ b/openapi.json @@ -173,22 +173,12 @@ ] } }, - "/report/{orgId}/{clusterId}": { + "/clusters/{clusterId}/report": { "get": { - "summary": "Returns the latest report for the given organization and cluster which contains information about rules that were hit by the cluster.", + "summary": "Returns the latest report for the a cluster which contains information about rules that were hit by the cluster. Information about the org_id and user_id is taken from the token.", "operationId": "getReportForCluster", - "description": "The report is specified by the organization ID and the cluster ID. The latest report available for the given combination will be returned.", + "description": "The report is specified by the cluster ID from params and information about the org_id and user_id is taken from the token. The latest report available for the given combination will be returned.", "parameters": [ - { - "name": "orgId", - "in": "path", - "required": true, - "schema": { - "type": "integer", - "format": "int64", - "minimum": 0 - } - }, { "name": "clusterId", "in": "path", From 3bcf1def9f0a3580248c02372498049022e63e52 Mon Sep 17 00:00:00 2001 From: Serhii Zakharov Date: Mon, 22 Jun 2020 14:37:06 +0200 Subject: [PATCH 05/14] fixed dependencies --- go.mod | 28 +++++++++--- go.sum | 92 ++++++++++++++++++++++++++++++++++++++++ server/server_test.go | 74 +++++++++++++++++++++++++++++++- tests/helpers/helpers.go | 14 ++++++ 4 files changed, 202 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 8dee82d1..e9596261 100644 --- a/go.mod +++ b/go.mod @@ -4,17 +4,35 @@ go 1.13 require ( github.com/BurntSushi/toml v0.3.1 - github.com/RedHatInsights/insights-content-service v0.0.0-20200610101541-f0c10d6d451d - github.com/RedHatInsights/insights-operator-utils v1.0.2-0.20200610143236-c868b2f93d2a - github.com/RedHatInsights/insights-results-aggregator v0.0.0-20200604090056-3534f6dd9c1c - github.com/RedHatInsights/insights-results-aggregator-data v0.0.0-20200512064850-2d04c5d0c9a6 + github.com/RedHatInsights/insights-content-service v0.0.0-20200619153839-23a428468a08 + github.com/RedHatInsights/insights-operator-utils v1.1.0 + github.com/RedHatInsights/insights-results-aggregator v0.0.0-20200622123018-31c3f8ac30bd + github.com/RedHatInsights/insights-results-aggregator-data v0.0.0-20200622112651-e5a7c1d79015 + github.com/RedHatInsights/insights-results-aggregator-utils v0.0.0-20200616074815-67f30b0e724d // indirect + github.com/Shopify/sarama v1.26.4 // indirect + github.com/aws/aws-sdk-go v1.32.6 // indirect github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 github.com/dgrijalva/jwt-go v3.2.0+incompatible + github.com/fsnotify/fsnotify v1.4.9 // indirect github.com/google/uuid v1.1.1 github.com/gorilla/mux v1.7.4 - github.com/prometheus/client_golang v1.6.0 + github.com/klauspost/compress v1.10.9 // indirect + github.com/mitchellh/mapstructure v1.3.2 // indirect + github.com/pelletier/go-toml v1.8.0 // indirect + github.com/pierrec/lz4 v2.5.2+incompatible // indirect + github.com/prometheus/client_golang v1.7.0 + github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 // indirect github.com/rs/zerolog v1.19.0 + github.com/spf13/afero v1.3.0 // indirect + github.com/spf13/cast v1.3.1 // indirect + github.com/spf13/jwalterweatherman v1.1.0 // indirect + github.com/spf13/pflag v1.0.5 // indirect github.com/spf13/viper v1.7.0 github.com/stretchr/testify v1.6.1 + golang.org/x/crypto v0.0.0-20200604202706-70a84ac30bf9 // indirect + golang.org/x/sys v0.0.0-20200620081246-981b61492c35 // indirect + golang.org/x/text v0.3.3 // indirect + google.golang.org/protobuf v1.24.0 // indirect gopkg.in/h2non/gock.v1 v1.0.15 + gopkg.in/ini.v1 v1.57.0 // indirect ) diff --git a/go.sum b/go.sum index e2a364d3..6855c091 100644 --- a/go.sum +++ b/go.sum @@ -20,20 +20,36 @@ github.com/DataDog/datadog-go v2.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3 github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/OneOfOne/xxhash v1.2.7/go.mod h1:eZbhyaAYD41SGSSsnmcpxVoRiQ/MPUTjUdIIOT9Um7Q= +github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc= github.com/RedHatInsights/cloudwatch v0.0.0-20200512151223-b0b55757a24b h1:IFT3csatW9XMCEi54wRo+GiFshT4E2V2vWCKYg7413w= github.com/RedHatInsights/cloudwatch v0.0.0-20200512151223-b0b55757a24b/go.mod h1:8l+HqU8iWM6hA9kSAHgY3ItSlpEsPr8fb2R0GBp9S0U= github.com/RedHatInsights/insights-content-service v0.0.0-20200610101541-f0c10d6d451d h1:0aXuHiiucADzC++1lOJs3u4k1UanSNX+wIcpnyi8Bi0= github.com/RedHatInsights/insights-content-service v0.0.0-20200610101541-f0c10d6d451d/go.mod h1:j3Mc+Xh2ospxJ+K2RIZjYlI6E6E4H2Qh3cgUzhstrfQ= +github.com/RedHatInsights/insights-content-service v0.0.0-20200619153839-23a428468a08 h1:hsmKH/lhX5KW1IIvjicC1lyTOt4t9RMjrGJkHuSDHN8= +github.com/RedHatInsights/insights-content-service v0.0.0-20200619153839-23a428468a08/go.mod h1:CSzDwoJXMIPnRNOZfYn68YbXejRqSr0i4uqtB6oLYt4= github.com/RedHatInsights/insights-operator-utils v1.0.1/go.mod h1:gRzYBMY4csuOXgrxUuC10WUkz6STOm3mqVsQCb+AGOQ= github.com/RedHatInsights/insights-operator-utils v1.0.2-0.20200610143236-c868b2f93d2a h1:/aAv1hq0ZFLDIxfmdTR23cm/B6nHEOVlWxOreOMqr80= github.com/RedHatInsights/insights-operator-utils v1.0.2-0.20200610143236-c868b2f93d2a/go.mod h1:0rhk13kn0BB+yKdfZjpMoQy0lXdXY3i4NJ1xGwGMcII= +github.com/RedHatInsights/insights-operator-utils v1.1.0 h1:Bhoqqopchg4OgbDTx72PVQUuFlymyMyQPYEqN0YELP0= +github.com/RedHatInsights/insights-operator-utils v1.1.0/go.mod h1:PHoCR0njiPXVArw+ooowqZgBjozu1h+8mYDoRoPVh6g= github.com/RedHatInsights/insights-results-aggregator v0.0.0-20200604090056-3534f6dd9c1c h1:/kb5AwNxizPf+0R4OWWRvWbLqAwf07Bu97R4WVHk2Uw= github.com/RedHatInsights/insights-results-aggregator v0.0.0-20200604090056-3534f6dd9c1c/go.mod h1:7Pc15NYXErx7BMJ4rF1Hacm+29G6atzjhwBpXNFMt+0= +github.com/RedHatInsights/insights-results-aggregator v0.0.0-20200622123018-31c3f8ac30bd h1:gdUaIRh8G8ud4Ir6S1nPMZ5I3p5PgQNzKlnMBFCKenA= +github.com/RedHatInsights/insights-results-aggregator v0.0.0-20200622123018-31c3f8ac30bd/go.mod h1:ESr5qmC0Hvod77nud0qfAUFNFGp5wK2ddIyHvnTf8ag= github.com/RedHatInsights/insights-results-aggregator-data v0.0.0-20200512064850-2d04c5d0c9a6 h1:Yt6Znx4OoMNRENCBdphqhu78EO/y2VD50DEC0b6mCrk= github.com/RedHatInsights/insights-results-aggregator-data v0.0.0-20200512064850-2d04c5d0c9a6/go.mod h1:O5X07zyJ9soaH2gMtYUNaJN6/9wt0E4J5TmheNBSdgc= +github.com/RedHatInsights/insights-results-aggregator-data v0.0.0-20200622065202-527c0c5b3f51 h1:f9wbH8JtwviDsN5tzAgPIgj6tzNL4cAXIjzaoBbGNVI= +github.com/RedHatInsights/insights-results-aggregator-data v0.0.0-20200622065202-527c0c5b3f51/go.mod h1:KbPSe0tGjDQjss7cBQxROkp8xRJC7L58WH38bKib0dM= +github.com/RedHatInsights/insights-results-aggregator-data v0.0.0-20200622112651-e5a7c1d79015 h1:NvNKLp20xelGO7Q8gfPshoRKd5Rhq9yZJJm009mlWPY= +github.com/RedHatInsights/insights-results-aggregator-data v0.0.0-20200622112651-e5a7c1d79015/go.mod h1:1pHaSnEh5Bhc8IZNqP6vbBI3jtWd5/rv4x2Y2/zG90w= +github.com/RedHatInsights/insights-results-aggregator-utils v0.0.0-20200616074815-67f30b0e724d h1:7fqXh2MMijj5YXTjzPFsOHCO+nXegHk7IVX0lCLl1ac= +github.com/RedHatInsights/insights-results-aggregator-utils v0.0.0-20200616074815-67f30b0e724d/go.mod h1:a2r0OkXqBR7MqsnIjEn1FVwZIGQO9ROnbjfV2ZelVvE= +github.com/RedHatInsights/insights-results-smart-proxy v0.0.0-20200619163313-7d5e376de430/go.mod h1:2fm8JFTklN33A6LiK+T0ld0fvBNtU5HrEKaLPsQE/Wc= github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= github.com/Shopify/sarama v1.26.0 h1:C+zFi+/NJdfeJgZWbu+WaLgk4NcsbmqfFTKsoJmR39U= github.com/Shopify/sarama v1.26.0/go.mod h1:y/CFFTO9eaMTNriwu/Q+W4eioLqiDMGkA1W+gmdfj8w= +github.com/Shopify/sarama v1.26.4 h1:+17TxUq/PJEAfZAll0T7XJjSgQWCpaQSoki/x5yN8o8= +github.com/Shopify/sarama v1.26.4/go.mod h1:NbSGBSSndYaIhRcBtY9V0U7AyH+x71bG668AuWys/yU= github.com/Shopify/toxiproxy v2.1.4+incompatible h1:TKdv8HiTLgE5wdJuEML90aBgNWsokNbMijUGhmcoBJc= github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= @@ -42,6 +58,7 @@ github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuy 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/andybalholm/cascadia v1.1.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y= github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= @@ -55,6 +72,8 @@ github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN github.com/aws/aws-sdk-go v1.30.11/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0= github.com/aws/aws-sdk-go v1.30.25 h1:89NXJkfpjnMEnsxkP8MVX+LDsoiLCSqevraLb5y4Mjk= github.com/aws/aws-sdk-go v1.30.25/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0= +github.com/aws/aws-sdk-go v1.32.6 h1:HoswAabUWgnrUF7X/9dr4WRgrr8DyscxXvTDm7Qw/5c= +github.com/aws/aws-sdk-go v1.32.6/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0= github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= 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= @@ -104,6 +123,8 @@ github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8 github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/eapache/go-resiliency v1.1.0 h1:1NtRmCAqadE2FN4ZcN6g90TP3uk8cg9rn9eNK2197aU= github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= +github.com/eapache/go-resiliency v1.2.0 h1:v7g92e/KSN71Rq7vSThKaWIq68fL4YHvWyiUKorFR1Q= +github.com/eapache/go-resiliency v1.2.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 h1:YEetp8/yCZMuEPMUDHG0CW/brkkEp8mzqk2+ODEitlw= github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= github.com/eapache/queue v1.1.0 h1:YOEu7KNc61ntiQlcEeUIoDTJ2o8mQznoNvUhiigpIqc= @@ -119,8 +140,11 @@ github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVB github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20= github.com/frankban/quicktest v1.4.1 h1:Wv2VwvNn73pAdFIVUQRXYDFp31lXKbqblIXo/Q5GPSg= github.com/frankban/quicktest v1.4.1/go.mod h1:36zfPVQyHxymz4cH7wlDmVwDrJuljRB60qkgn7rorfQ= +github.com/frankban/quicktest v1.7.2/go.mod h1:jaStnuzAqU1AJdCO0l53JDCJrVDKcS03DbaAcR7Ks/o= github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= 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/fzipp/gocyclo v0.0.0-20150627053110-6acd4345c835/go.mod h1:BjL/N0+C+j9uNX+1xcNuM9vdSIcXCZrQZUYbXOFbgN8= github.com/gchaincl/sqlhooks v1.3.0 h1:yKPXxW9a5CjXaVf2HkQn6wn7TZARvbAOAelr3H8vK2Y= github.com/gchaincl/sqlhooks v1.3.0/go.mod h1:9BypXnereMT0+Ys8WGWHqzgkkOfHIhyeUCqXC24ra34= @@ -159,6 +183,9 @@ github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrU github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= github.com/golang/protobuf v1.4.0 h1:oOuy+ugB+P/kBdUnG5QaMXSIyJ1q38wWSojYCb3z5VQ= 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 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= @@ -219,6 +246,8 @@ github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdv github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1BE= github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-uuid v1.0.2 h1:cfejS+Tpcp13yd5nYHWDI6qVCny6wyX2Mt5SGur2IGE= +github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= @@ -241,6 +270,8 @@ github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANyt github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= github.com/jcmturner/gofork v0.0.0-20190328161633-dc7c13fece03 h1:FUwcHNlEqkqLjLBdCp5PRlCFijNjvcYANOZXzCfXwCM= github.com/jcmturner/gofork v0.0.0-20190328161633-dc7c13fece03/go.mod h1:MK8+TM0La+2rjBD4jE12Kj1pCCxK7d2LK/UM3ncEo0o= +github.com/jcmturner/gofork v1.0.0 h1:J7uCkflzTEhUZ64xqKnkDxq3kzc96ajM1Gli5ktUem8= +github.com/jcmturner/gofork v1.0.0/go.mod h1:MK8+TM0La+2rjBD4jE12Kj1pCCxK7d2LK/UM3ncEo0o= github.com/jcxplorer/cwlogger v0.0.0-20170704082755-4e30a5a47e6a/go.mod h1:jqP/JbBwy+LLLUwzr8XTr9IrnaNxFD7kmaXZlvjH9nQ= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/jmespath/go-jmespath v0.3.0 h1:OS12ieG61fsCg5+qLJ+SsW9NicxNkg3b25OyT2yCeUc= @@ -250,6 +281,7 @@ github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCV github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= @@ -258,7 +290,11 @@ github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvW github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.9.7 h1:hYW1gP94JUmAhBtJ+LNz5My+gBobDxPR1iVuKug26aA= github.com/klauspost/compress v1.9.7/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= +github.com/klauspost/compress v1.9.8/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= +github.com/klauspost/compress v1.10.9 h1:pPRt1Z78crspaHISkpSSHjDlx+Tt9suHe519dsI0vF4= +github.com/klauspost/compress v1.10.9/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs= @@ -269,6 +305,8 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.3.0 h1:/qkRGz8zljWiDcFvgpwUpwIAPu3r07TDvs3Rws+o/pU= github.com/lib/pq v1.3.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/lib/pq v1.7.0 h1:h93mCPfUSkaul3Ka/VG8uZdmW1uMHDGxzu0NWHuJmHY= +github.com/lib/pq v1.7.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4= github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= @@ -282,6 +320,8 @@ github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hd github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-sqlite3 v1.10.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= +github.com/mattn/go-sqlite3 v1.14.0 h1:mLyGNKR8+Vv9CAU7PphKa2hkEqxxhn8i32J6FPj1/QA= +github.com/mattn/go-sqlite3 v1.14.0/go.mod h1:JIl7NbARA7phWnGvh0LKTyg7S9BA+6gx71ShQilpsus= github.com/mattn/go-sqlite3 v2.0.3+incompatible h1:gXHsfypPkaMZrKbD5209QV9jbUTJKjyR5WD3HYQSd+U= github.com/mattn/go-sqlite3 v2.0.3+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= @@ -295,6 +335,8 @@ github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0Qu github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/mitchellh/mapstructure v1.3.2 h1:mRS76wmkOn3KkKAyXDu42V+6ebnXWIztFSYGN7GeoRg= +github.com/mitchellh/mapstructure v1.3.2/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/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= @@ -337,15 +379,22 @@ github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144T github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= 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 v1.8.0 h1:Keo9qb7iRJs2voHvunFtuuYFsbWeOBh8/P9v/kVMFtw= +github.com/pelletier/go-toml v1.8.0/go.mod h1:D6yutnOGMveHEPV7VQOuvI/gXY61bv+9bAOTRnLElKs= github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= +github.com/pierrec/lz4 v1.0.1 h1:w6GMGWSsCI04fTM8wQRdnW74MuJISakuUU0onU0TYB4= github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pierrec/lz4 v2.2.6+incompatible h1:6aCX4/YZ9v8q69hTyiR7dNLnTA3fgtKHVVW5BCd5Znw= github.com/pierrec/lz4 v2.2.6+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= +github.com/pierrec/lz4 v2.4.1+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= +github.com/pierrec/lz4 v2.5.2+incompatible h1:WCjObylUIOlKy/+7Abdn34TLIkXiA4UWUMhxq9m9ZXI= +github.com/pierrec/lz4 v2.5.2+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= 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/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA= +github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI= 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/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= @@ -357,6 +406,8 @@ github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5Fsn github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= github.com/prometheus/client_golang v1.6.0 h1:YVPodQOcK15POxhgARIvnDRVpLcuK8mglnMrWfyrw6A= github.com/prometheus/client_golang v1.6.0/go.mod h1:ZLOG9ck3JLRdB5MgO8f+lLTe83AXG6ro35rLTxvnIl4= +github.com/prometheus/client_golang v1.7.0 h1:wCi7urQOGBsYcQROHqpUUX4ct84xp40t9R9JX0FuA/U= +github.com/prometheus/client_golang v1.7.0/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= @@ -372,6 +423,8 @@ github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y8 github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt26CguLLsqA= github.com/prometheus/common v0.9.1 h1:KOMtN28tlbam3/7ZKEYKHhKoJZYYj3gMH4uc62x7X7U= github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= +github.com/prometheus/common v0.10.0 h1:RyRA7RzGXQZiW+tGMr7sxa85G1z0yOpM1qq5c8lNawc= +github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= @@ -380,9 +433,14 @@ github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsT github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= github.com/prometheus/procfs v0.0.11 h1:DhHlBtkHWPYi8O2y31JkK0TF+DGM+51OopZjH/Ia5qI= github.com/prometheus/procfs v0.0.11/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= +github.com/prometheus/procfs v0.1.3 h1:F0+tqvhOksq22sc6iCHF5WGlWjdwj92p0udFh1VFBS8= +github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a h1:9ZKAASQSHhDYGoxY8uLVpewe1GDZ2vu2Tr/vTdVAkFQ= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= +github.com/rcrowley/go-metrics v0.0.0-20190826022208-cac0b30c2563/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= +github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 h1:MkV+77GLUNo5oJ0jf870itWm3D0Sjh7+Za9gazKc5LQ= +github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= @@ -407,14 +465,22 @@ github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasO github.com/spaolacci/murmur3 v1.1.0/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/afero v1.3.0 h1:Ysnmjh1Di8EaWaBv40CYR4IdaIsBc5996Gh1oZzCBKk= +github.com/spf13/afero v1.3.0/go.mod h1:5KUK8ByomD5Ti5Artl0RtHeI5pTF7MIDuXL3yY520V4= 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/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng= +github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= 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/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk= +github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +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.6.2/go.mod h1:t3iDnF5Jlj76alVNuyFBk5oUMCvsrkbvZK0WQdfDi5k= github.com/spf13/viper v1.7.0 h1:xVKxvI7ouOI5I+U9s2eeiUfMaWBVoXA3AWskkrqK0VM= github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= @@ -476,9 +542,13 @@ golang.org/x/crypto v0.0.0-20190404164418-38d8ce5564a5/go.mod h1:WFFai1msRO1wXaE 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-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191117063200-497ca9f6d64f h1:kz4KIr+xcPUsI3VMoqWfPMvtnJ6MGfiVwsWSVzphMO4= golang.org/x/crypto v0.0.0-20191117063200-497ca9f6d64f/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200204104054-c9f3fb736b72/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200604202706-70a84ac30bf9 h1:vEg9joUBmeBcK9iSJftGNf3coIG4HqZElCPehJsfAYM= +golang.org/x/crypto v0.0.0-20200604202706-70a84ac30bf9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= 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= @@ -500,6 +570,7 @@ golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCc 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/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 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-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -520,6 +591,7 @@ golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/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-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200602114024-627f9648deb9 h1:pNX+40auqi2JqRfOP1akLGtYcn15TUbkhwuCO3foqqM= golang.org/x/net v0.0.0-20200602114024-627f9648deb9/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -553,16 +625,22 @@ golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7w 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-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191220142924-d4481acd189f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200420163511-1957bb5e6d1f h1:gWF768j/LaZugp8dyS4UwsslYCYz9XgFxvlgsn0n9H8= golang.org/x/sys v0.0.0-20200420163511-1957bb5e6d1f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200620081246-981b61492c35 h1:wb/9mP8eUAmHfkM8RmpeLq6nUA7c2i5+bQOtcDftjaE= +golang.org/x/sys v0.0.0-20200620081246-981b61492c35/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 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 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= 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= @@ -617,6 +695,7 @@ google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98 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-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM= @@ -627,12 +706,18 @@ google.golang.org/grpc v1.22.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyac google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= 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/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 h1:qdOKuR/EIArgaWNjetjgTzgVTAZ+S/WXVrq9HW9zimw= 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 h1:UhZDfRO8JRQru4/+LlLE0BRKGF8L+PICnvYZmx/fEGA= +google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= 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= @@ -646,6 +731,8 @@ gopkg.in/h2non/gock.v1 v1.0.15 h1:SzLqcIlb/fDfg7UvukMpNcWsu7sI5tWwL+KCATZqks0= gopkg.in/h2non/gock.v1 v1.0.15/go.mod h1:sX4zAkdYX1TRGJ2JY156cFspQn4yRWn6p9EMdODlynE= gopkg.in/ini.v1 v1.51.0 h1:AQvPpx3LzTDM0AjnIRlVFwFFGC+npRopjZxLJj6gdno= gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/ini.v1 v1.57.0 h1:9unxIsFcTt4I55uWluz+UmL95q4kdJ0buvQ1ZIqVQww= +gopkg.in/ini.v1 v1.57.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/jcmturner/aescts.v1 v1.0.1 h1:cVVZBK2b1zY26haWB4vbBiZrfFQnfbTVrE3xZq6hrEw= gopkg.in/jcmturner/aescts.v1 v1.0.1/go.mod h1:nsR8qBOg+OucoIW+WMhB3GspUQXq9XorLnQb9XtvcOo= gopkg.in/jcmturner/dnsutils.v1 v1.0.1 h1:cIuC1OLRGZrld+16ZJvvZxVJeKPsvd5eUIvxfoN5hSM= @@ -654,6 +741,8 @@ gopkg.in/jcmturner/goidentity.v3 v3.0.0 h1:1duIyWiTaYvVx3YX2CYtpJbUFd7/UuPYCfgXt gopkg.in/jcmturner/goidentity.v3 v3.0.0/go.mod h1:oG2kH0IvSYNIu80dVAyu/yoefjq1mNfM5bm88whjWx4= gopkg.in/jcmturner/gokrb5.v7 v7.2.3 h1:hHMV/yKPwMnJhPuPx7pH2Uw/3Qyf+thJYlisUc44010= gopkg.in/jcmturner/gokrb5.v7 v7.2.3/go.mod h1:l8VISx+WGYp+Fp7KRbsiUuXTTOnxIc3Tuvyavf11/WM= +gopkg.in/jcmturner/gokrb5.v7 v7.5.0 h1:a9tsXlIDD9SKxotJMK3niV7rPZAJeX2aD/0yg3qlIrg= +gopkg.in/jcmturner/gokrb5.v7 v7.5.0/go.mod h1:l8VISx+WGYp+Fp7KRbsiUuXTTOnxIc3Tuvyavf11/WM= gopkg.in/jcmturner/rpc.v1 v1.1.0 h1:QHIUxTX1ISuAv9dD2wJ9HWQVuWDX/Zc0PfeC2tjc4rU= gopkg.in/jcmturner/rpc.v1 v1.1.0/go.mod h1:YIdkC4XfD6GXbzje11McwsDuOlZQSb9W4vfLvuNnlv8= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= @@ -665,6 +754,9 @@ gopkg.in/yaml.v2 v2.2.2/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 h1:ymVxjfMaHvXD8RqPRmzHHsB3VvucivSkIAvJFDI5O3c= gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= +gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/server/server_test.go b/server/server_test.go index ebda02b8..ff4b83cf 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -19,7 +19,9 @@ package server_test import ( "bytes" "encoding/gob" + "github.com/RedHatInsights/insights-operator-utils/types" "github.com/RedHatInsights/insights-results-smart-proxy/content" + proxy_types "github.com/RedHatInsights/insights-results-smart-proxy/types" "io/ioutil" "net/http" "testing" @@ -41,6 +43,76 @@ const ( testTimeout = 10 * time.Second ) +// TODO: consider moving to data repo +var ( + SmartProxyReportResponse3Rules = struct { + Status string `json:"status"` + Report *proxy_types.SmartProxyReport `json:"report"` + }{ + Status: "ok", + Report: &SmartProxyReport3Rules, + } + + SmartProxyReport3Rules = proxy_types.SmartProxyReport{ + Meta: types.ReportResponseMeta{ + Count: 3, + LastCheckedAt: types.Timestamp(testdata.LastCheckedAt.UTC().Format(time.RFC3339)), + }, + Data: []proxy_types.RuleWithContentResponse{ + { + RuleID: testdata.Rule1.Module, + ErrorKey: testdata.RuleErrorKey1.ErrorKey, + CreatedAt: testdata.RuleErrorKey1.PublishDate.UTC().Format(time.RFC3339), + Description: testdata.RuleErrorKey1.Description, + Generic: testdata.RuleErrorKey1.Generic, + Reason: testdata.Rule1.Reason, + Resolution: testdata.Rule1.Resolution, + TotalRisk: calculateTotalRisk(testdata.RuleErrorKey1.Impact, testdata.RuleErrorKey1.Likelihood), + RiskOfChange: 0, + Disabled: testdata.Rule1Disabled, + UserVote: types.UserVoteNone, + TemplateData: testdata.Rule1.MoreInfo, + Tags: testdata.RuleErrorKey1.Tags, + }, + { + RuleID: testdata.Rule2.Module, + ErrorKey: testdata.RuleErrorKey2.ErrorKey, + CreatedAt: testdata.RuleErrorKey2.PublishDate.UTC().Format(time.RFC3339), + Description: testdata.RuleErrorKey2.Description, + Generic: testdata.RuleErrorKey2.Generic, + Reason: testdata.Rule2.Reason, + Resolution: testdata.Rule2.Resolution, + TotalRisk: calculateTotalRisk(testdata.RuleErrorKey2.Impact, testdata.RuleErrorKey2.Likelihood), + RiskOfChange: 0, + Disabled: testdata.Rule2Disabled, + UserVote: types.UserVoteNone, + TemplateData: testdata.Rule2.MoreInfo, + Tags: testdata.RuleErrorKey2.Tags, + }, + { + RuleID: testdata.Rule3.Module, + ErrorKey: testdata.RuleErrorKey3.ErrorKey, + CreatedAt: testdata.RuleErrorKey3.PublishDate.UTC().Format(time.RFC3339), + Description: testdata.RuleErrorKey3.Description, + Generic: testdata.RuleErrorKey3.Generic, + Reason: testdata.Rule3.Reason, + Resolution: testdata.Rule3.Resolution, + TotalRisk: calculateTotalRisk(testdata.RuleErrorKey3.Impact, testdata.RuleErrorKey3.Likelihood), + RiskOfChange: 0, + Disabled: testdata.Rule3Disabled, + UserVote: types.UserVoteNone, + TemplateData: testdata.Rule3.MoreInfo, + Tags: testdata.RuleErrorKey3.Tags, + }, + }, + } +) + +// TODO: move to utils +func calculateTotalRisk(impact, likelihood int) int { + return (impact + likelihood) / 2 +} + func init() { zerolog.SetGlobalLevel(zerolog.WarnLevel) } @@ -98,7 +170,7 @@ func TestHTTPServer_ReportEndpoint(t *testing.T) { OrgID: testdata.OrgID, }, &helpers.APIResponse{ StatusCode: http.StatusOK, - Body: helpers.ToJSONString(testdata.SmartProxyReportResponse3Rules), + Body: helpers.ToJSONString(SmartProxyReportResponse3Rules), }) }, testTimeout) } diff --git a/tests/helpers/helpers.go b/tests/helpers/helpers.go index 6d7151ea..174a6cfa 100644 --- a/tests/helpers/helpers.go +++ b/tests/helpers/helpers.go @@ -1,3 +1,17 @@ +// Copyright 2020 Red Hat, Inc +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package helpers import "github.com/RedHatInsights/insights-operator-utils/tests/helpers" From 5c9fa0462a99d7eac5f204028fa734c5c673a512 Mon Sep 17 00:00:00 2001 From: Serhii Zakharov Date: Mon, 22 Jun 2020 14:44:23 +0200 Subject: [PATCH 06/14] fixed gosec --- content/content.go | 4 ++-- content/parsing.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/content/content.go b/content/content.go index b37bb6de..61a9ec54 100644 --- a/content/content.go +++ b/content/content.go @@ -84,12 +84,12 @@ func (s *RulesWithContentStorage) SetRuleWithContent( // SetRule sets content for rule func (s *RulesWithContentStorage) SetRule( - ruleID types.RuleID, ruleContent *ics_content.RuleContent, + ruleID types.RuleID, ruleContent ics_content.RuleContent, ) { s.Lock() defer s.Unlock() - s.rules[ruleID] = ruleContent + s.rules[ruleID] = &ruleContent } var rulesWithContentStorage = RulesWithContentStorage{ diff --git a/content/parsing.go b/content/parsing.go index 52985d02..66e06949 100644 --- a/content/parsing.go +++ b/content/parsing.go @@ -30,7 +30,7 @@ func loadRuleContent(contentDir *content.RuleContentDirectory) { for _, rule := range contentDir.Rules { ruleID := types.RuleID(rule.Plugin.PythonModule) - rulesWithContentStorage.SetRule(ruleID, &rule) + rulesWithContentStorage.SetRule(ruleID, rule) for errorKey, errorProperties := range rule.ErrorKeys { impact, found := contentDir.Config.Impact[errorProperties.Metadata.Impact] From 83282d4ea6149d619af590e5d407242aea993dfb Mon Sep 17 00:00:00 2001 From: Serhii Zakharov Date: Wed, 24 Jun 2020 22:44:00 +0200 Subject: [PATCH 07/14] fixed issue with condition variable --- content/content.go | 41 +++++++++++---- content/content_test.go | 108 ++++++++++++++++++++++++++++++++++++++++ content/export_test.go | 24 +++++++++ server/server_test.go | 29 +++-------- tests/helpers/http.go | 6 +++ types/types.go | 12 +++++ 6 files changed, 187 insertions(+), 33 deletions(-) create mode 100644 content/content_test.go create mode 100644 content/export_test.go diff --git a/content/content.go b/content/content.go index 61a9ec54..91c49a96 100644 --- a/content/content.go +++ b/content/content.go @@ -30,7 +30,8 @@ import ( var ( ruleContentDirectory *ics_content.RuleContentDirectory - ruleContentDirectoryReady = make(chan struct{}) + ruleContentDirectoryReady = sync.NewCond(&sync.Mutex{}) + stopUpdateContentLoop = make(chan struct{}) ) type ruleIDAndErrorKey struct { @@ -97,15 +98,23 @@ var rulesWithContentStorage = RulesWithContentStorage{ rules: map[types.RuleID]*ics_content.RuleContent{}, } +func waitForContentDirectoryToBeReady() { + // according to the example in the official dock, + // lock is required here + if ruleContentDirectory == nil { + ruleContentDirectoryReady.L.Lock() + ruleContentDirectoryReady.Wait() + ruleContentDirectoryReady.L.Unlock() + } +} + // GetRuleWithErrorKeyContent returns content for rule with provided `rule id` and `error key`. // Caching is done under the hood, don't worry about it. func GetRuleWithErrorKeyContent( ruleID types.RuleID, errorKey types.ErrorKey, ) (*types.RuleWithContent, error) { - // to be sure data is there - // it will wait only on opened channel - // something like condition variable - _, _ = <-ruleContentDirectoryReady + // to be sure the data is there + waitForContentDirectoryToBeReady() res, found := rulesWithContentStorage.GetRuleWithErrorKeyContent(ruleID, errorKey) if !found { @@ -118,10 +127,8 @@ func GetRuleWithErrorKeyContent( // GetRuleContent returns content for rule with provided `rule id` // Caching is done under the hood, don't worry about it. func GetRuleContent(ruleID types.RuleID) (*ics_content.RuleContent, error) { - // to be sure data is there - // it will wait only on opened channel - // something like condition variable - _, _ = <-ruleContentDirectoryReady + // to be sure the data is there + waitForContentDirectoryToBeReady() res, found := rulesWithContentStorage.GetRuleContent(ruleID) if !found { @@ -137,10 +144,20 @@ func RunUpdateContentLoop(servicesConf services.Configuration) { for { updateContent(servicesConf) - <-ticker.C + + select { + case <-ticker.C: + case <-stopUpdateContentLoop: + break + } } } +// StopUpdateContentLoop stops the loop +func StopUpdateContentLoop() { + stopUpdateContentLoop <- struct{}{} +} + func updateContent(servicesConf services.Configuration) { var err error @@ -152,5 +169,7 @@ func updateContent(servicesConf services.Configuration) { loadRuleContent(ruleContentDirectory) - close(ruleContentDirectoryReady) + ruleContentDirectoryReady.L.Lock() + ruleContentDirectoryReady.Broadcast() + ruleContentDirectoryReady.L.Unlock() } diff --git a/content/content_test.go b/content/content_test.go new file mode 100644 index 00000000..e03e117e --- /dev/null +++ b/content/content_test.go @@ -0,0 +1,108 @@ +// Copyright 2020 Red Hat, Inc +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package content_test + +import ( + "net/http" + "testing" + "time" + + ics_server "github.com/RedHatInsights/insights-content-service/server" + "github.com/RedHatInsights/insights-results-aggregator-data/testdata" + "github.com/stretchr/testify/assert" + + "github.com/RedHatInsights/insights-results-smart-proxy/content" + "github.com/RedHatInsights/insights-results-smart-proxy/tests/helpers" +) + +const ( + testTimeout = 10 * time.Second +) + +func TestGetRuleContent(t *testing.T) { + helpers.RunTestWithTimeout(t, func(t *testing.T) { + defer helpers.CleanAfterGock(t) + helpers.GockExpectAPIRequest(t, helpers.DefaultServicesConfig.ContentBaseEndpoint, &helpers.APIRequest{ + Method: http.MethodGet, + Endpoint: ics_server.AllContentEndpoint, + }, &helpers.APIResponse{ + StatusCode: http.StatusOK, + Body: helpers.MustGobSerialize(t, testdata.RuleContentDirectory3Rules), + }) + + content.UpdateContent(helpers.DefaultServicesConfig) + + ruleContent, err := content.GetRuleContent(testdata.Rule1ID) + helpers.FailOnError(t, err) + assert.NotNil(t, ruleContent) + + assert.Equal(t, testdata.RuleContent1, *ruleContent) + }, testTimeout) +} + +func TestGetRuleContent_CallMultipleTimes(t *testing.T) { + const N = 10 + + helpers.RunTestWithTimeout(t, func(t *testing.T) { + defer helpers.CleanAfterGock(t) + helpers.GockExpectAPIRequest(t, helpers.DefaultServicesConfig.ContentBaseEndpoint, &helpers.APIRequest{ + Method: http.MethodGet, + Endpoint: ics_server.AllContentEndpoint, + }, &helpers.APIResponse{ + StatusCode: http.StatusOK, + Body: helpers.MustGobSerialize(t, testdata.RuleContentDirectory3Rules), + }) + + content.UpdateContent(helpers.DefaultServicesConfig) + + for i := 0; i < N; i++ { + ruleContent, err := content.GetRuleContent(testdata.Rule1ID) + helpers.FailOnError(t, err) + assert.NotNil(t, ruleContent) + + assert.Equal(t, testdata.RuleContent1, *ruleContent) + } + }, testTimeout) +} + +func TestUpdateContent_CallMultipleTimes(t *testing.T) { + const N = 10 + + helpers.RunTestWithTimeout(t, func(t *testing.T) { + defer helpers.CleanAfterGock(t) + + for i := 0; i < N; i++ { + helpers.GockExpectAPIRequest(t, helpers.DefaultServicesConfig.ContentBaseEndpoint, &helpers.APIRequest{ + Method: http.MethodGet, + Endpoint: ics_server.AllContentEndpoint, + }, &helpers.APIResponse{ + StatusCode: http.StatusOK, + Body: helpers.MustGobSerialize(t, testdata.RuleContentDirectory3Rules), + }) + } + + for i := 0; i < N; i++ { + content.UpdateContent(helpers.DefaultServicesConfig) + } + + for i := 0; i < N; i++ { + ruleContent, err := content.GetRuleContent(testdata.Rule1ID) + helpers.FailOnError(t, err) + assert.NotNil(t, ruleContent) + + assert.Equal(t, testdata.RuleContent1, *ruleContent) + } + }, testTimeout) +} diff --git a/content/export_test.go b/content/export_test.go new file mode 100644 index 00000000..8d0244f5 --- /dev/null +++ b/content/export_test.go @@ -0,0 +1,24 @@ +// Copyright 2020 Red Hat, Inc +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package content + +// Export for testing +// +// Please look into the following blogpost: +// https://medium.com/@robiplus/golang-trick-export-for-test-aa16cbd7b8cd +// to see why this trick is needed. +var ( + UpdateContent = updateContent +) diff --git a/server/server_test.go b/server/server_test.go index ff4b83cf..e76f410d 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -18,11 +18,6 @@ package server_test import ( "bytes" - "encoding/gob" - "github.com/RedHatInsights/insights-operator-utils/types" - "github.com/RedHatInsights/insights-results-smart-proxy/content" - proxy_types "github.com/RedHatInsights/insights-results-smart-proxy/types" - "io/ioutil" "net/http" "testing" "time" @@ -34,9 +29,11 @@ import ( "github.com/stretchr/testify/assert" gock "gopkg.in/h2non/gock.v1" + "github.com/RedHatInsights/insights-results-smart-proxy/content" "github.com/RedHatInsights/insights-results-smart-proxy/server" "github.com/RedHatInsights/insights-results-smart-proxy/services" "github.com/RedHatInsights/insights-results-smart-proxy/tests/helpers" + "github.com/RedHatInsights/insights-results-smart-proxy/types" ) const ( @@ -46,19 +43,19 @@ const ( // TODO: consider moving to data repo var ( SmartProxyReportResponse3Rules = struct { - Status string `json:"status"` - Report *proxy_types.SmartProxyReport `json:"report"` + Status string `json:"status"` + Report *types.SmartProxyReport `json:"report"` }{ Status: "ok", Report: &SmartProxyReport3Rules, } - SmartProxyReport3Rules = proxy_types.SmartProxyReport{ + SmartProxyReport3Rules = types.SmartProxyReport{ Meta: types.ReportResponseMeta{ Count: 3, LastCheckedAt: types.Timestamp(testdata.LastCheckedAt.UTC().Format(time.RFC3339)), }, - Data: []proxy_types.RuleWithContentResponse{ + Data: []types.RuleWithContentResponse{ { RuleID: testdata.Rule1.Module, ErrorKey: testdata.RuleErrorKey1.ErrorKey, @@ -132,18 +129,6 @@ func TestServerStartError(t *testing.T) { assert.EqualError(t, err, "listen tcp: address 99999: invalid port") } -func MustGobSerialize(t testing.TB, obj interface{}) []byte { - buf := new(bytes.Buffer) - - err := gob.NewEncoder(buf).Encode(obj) - helpers.FailOnError(t, err) - - res, err := ioutil.ReadAll(buf) - helpers.FailOnError(t, err) - - return res -} - func TestHTTPServer_ReportEndpoint(t *testing.T) { helpers.RunTestWithTimeout(t, func(t *testing.T) { defer gock.Off() @@ -158,7 +143,7 @@ func TestHTTPServer_ReportEndpoint(t *testing.T) { Get("/"). AddMatcher(helpers.NewGockAPIEndpointMatcher(ics_server.AllContentEndpoint)). Reply(200). - Body(bytes.NewBuffer(MustGobSerialize(t, &testdata.RuleContentDirectory3Rules))) + Body(bytes.NewBuffer(helpers.MustGobSerialize(t, testdata.RuleContentDirectory3Rules))) go content.RunUpdateContentLoop(helpers.DefaultServicesConfig) diff --git a/tests/helpers/http.go b/tests/helpers/http.go index 2cf8454f..d7038c02 100644 --- a/tests/helpers/http.go +++ b/tests/helpers/http.go @@ -40,6 +40,12 @@ var ( AssertReportResponsesEqual = helpers.AssertReportResponsesEqual // NewGockAPIEndpointMatcher creates a matcher for a given endpoint for gock NewGockAPIEndpointMatcher = helpers.NewGockAPIEndpointMatcher + // GockExpectAPIRequest makes gock expect the request with the baseURL and sends back the response + GockExpectAPIRequest = helpers.GockExpectAPIRequest + // CleanAfterGock cleans after gock library and prints all unmatched requests + CleanAfterGock = helpers.CleanAfterGock + // MustGobSerialize serializes an object using gob or panics + MustGobSerialize = helpers.MustGobSerialize ) var ( diff --git a/types/types.go b/types/types.go index cae3e8d8..84d433a4 100644 --- a/types/types.go +++ b/types/types.go @@ -47,3 +47,15 @@ type SmartProxyReport struct { Meta types.ReportResponseMeta `json:"meta"` Data []RuleWithContentResponse `json:"data"` } + +// UserVote is a type for user's vote +type UserVote = types.UserVote + +const ( + // UserVoteDislike shows user's dislike + UserVoteDislike = types.UserVoteDislike + // UserVoteNone shows no vote from user + UserVoteNone = types.UserVoteNone + // UserVoteLike shows user's like + UserVoteLike = types.UserVoteLike +) From 3299c968d33e256a359195ea03415b4ab41a9b3c Mon Sep 17 00:00:00 2001 From: Serhii Zakharov Date: Wed, 24 Jun 2020 23:15:10 +0200 Subject: [PATCH 08/14] fixed style --- content/content.go | 2 +- go.mod | 1 - go.sum | 19 +++++++++++++++++++ server/server.go | 13 ++----------- server/server_test.go | 1 - 5 files changed, 22 insertions(+), 14 deletions(-) diff --git a/content/content.go b/content/content.go index 3d70f9e1..91c49a96 100644 --- a/content/content.go +++ b/content/content.go @@ -22,10 +22,10 @@ import ( "time" ics_content "github.com/RedHatInsights/insights-content-service/content" + "github.com/RedHatInsights/insights-operator-utils/types" "github.com/rs/zerolog/log" "github.com/RedHatInsights/insights-results-smart-proxy/services" - "github.com/RedHatInsights/insights-results-smart-proxy/types" ) var ( diff --git a/go.mod b/go.mod index f844e1f7..6745d46e 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,6 @@ require ( github.com/RedHatInsights/insights-operator-utils v1.2.0 github.com/RedHatInsights/insights-results-aggregator v0.0.0-20200622123018-31c3f8ac30bd github.com/RedHatInsights/insights-results-aggregator-data v0.0.0-20200622112651-e5a7c1d79015 - github.com/RedHatInsights/insights-results-aggregator-utils v0.0.0-20200616074815-67f30b0e724d // indirect github.com/Shopify/sarama v1.26.4 // indirect github.com/aws/aws-sdk-go v1.32.6 // indirect github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 diff --git a/go.sum b/go.sum index 0f4e23de..1d4020da 100644 --- a/go.sum +++ b/go.sum @@ -14,12 +14,14 @@ dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7 github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= +github.com/DATA-DOG/go-sqlmock v1.4.1 h1:ThlnYciV1iM/V0OSF/dtkqWb6xo5qITT1TJBG1MRDJM= github.com/DATA-DOG/go-sqlmock v1.4.1/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/DataDog/datadog-go v2.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/OneOfOne/xxhash v1.2.7/go.mod h1:eZbhyaAYD41SGSSsnmcpxVoRiQ/MPUTjUdIIOT9Um7Q= github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc= +github.com/RedHatInsights/cloudwatch v0.0.0-20200512151223-b0b55757a24b h1:IFT3csatW9XMCEi54wRo+GiFshT4E2V2vWCKYg7413w= github.com/RedHatInsights/cloudwatch v0.0.0-20200512151223-b0b55757a24b/go.mod h1:8l+HqU8iWM6hA9kSAHgY3ItSlpEsPr8fb2R0GBp9S0U= github.com/RedHatInsights/insights-content-service v0.0.0-20200610101541-f0c10d6d451d/go.mod h1:j3Mc+Xh2ospxJ+K2RIZjYlI6E6E4H2Qh3cgUzhstrfQ= github.com/RedHatInsights/insights-content-service v0.0.0-20200619153839-23a428468a08 h1:hsmKH/lhX5KW1IIvjicC1lyTOt4t9RMjrGJkHuSDHN8= @@ -40,6 +42,7 @@ github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWX github.com/Shopify/sarama v1.26.0/go.mod h1:y/CFFTO9eaMTNriwu/Q+W4eioLqiDMGkA1W+gmdfj8w= github.com/Shopify/sarama v1.26.4 h1:+17TxUq/PJEAfZAll0T7XJjSgQWCpaQSoki/x5yN8o8= github.com/Shopify/sarama v1.26.4/go.mod h1:NbSGBSSndYaIhRcBtY9V0U7AyH+x71bG668AuWys/yU= +github.com/Shopify/toxiproxy v2.1.4+incompatible h1:TKdv8HiTLgE5wdJuEML90aBgNWsokNbMijUGhmcoBJc= github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c= @@ -60,6 +63,7 @@ github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQ github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/aws/aws-sdk-go v1.30.11/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0= github.com/aws/aws-sdk-go v1.30.25/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0= +github.com/aws/aws-sdk-go v1.32.6 h1:HoswAabUWgnrUF7X/9dr4WRgrr8DyscxXvTDm7Qw/5c= github.com/aws/aws-sdk-go v1.32.6/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0= github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= @@ -102,6 +106,7 @@ github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7Do 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/deckarep/golang-set v1.7.1 h1:SCQV0S6gTtp6itiFrTqI+pfmJ4LN85S1YzhDf9rTHJQ= github.com/deckarep/golang-set v1.7.1/go.mod h1:93vsz/8Wt4joVM7c2AVqh+YRMiUSc14yDtF28KmMOgQ= github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= @@ -119,10 +124,12 @@ github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4s github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= +github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4= github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20= github.com/frankban/quicktest v1.4.1/go.mod h1:36zfPVQyHxymz4cH7wlDmVwDrJuljRB60qkgn7rorfQ= +github.com/frankban/quicktest v1.7.2 h1:2QxQoC1TS09S7fhCPsrvqYdvP1H5M1P1ih5ABm3BTYk= github.com/frankban/quicktest v1.7.2/go.mod h1:jaStnuzAqU1AJdCO0l53JDCJrVDKcS03DbaAcR7Ks/o= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= @@ -140,6 +147,7 @@ github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= +github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs= github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-yaml/yaml v2.1.0+incompatible h1:RYi2hDdss1u4YE7GwixGzWwVo47T8UQwnTLB6vQiq+o= @@ -174,6 +182,7 @@ github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ 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 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 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= @@ -185,6 +194,7 @@ github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= github.com/google/uuid v1.1.1/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/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= github.com/gorilla/handlers v1.4.2 h1:0QniY0USkHQ1RGCLfKxeNHK9bkDHGRYGNDFBCS+YARg= @@ -252,6 +262,7 @@ github.com/jcmturner/gofork v1.0.0 h1:J7uCkflzTEhUZ64xqKnkDxq3kzc96ajM1Gli5ktUem github.com/jcmturner/gofork v1.0.0/go.mod h1:MK8+TM0La+2rjBD4jE12Kj1pCCxK7d2LK/UM3ncEo0o= github.com/jcxplorer/cwlogger v0.0.0-20170704082755-4e30a5a47e6a/go.mod h1:jqP/JbBwy+LLLUwzr8XTr9IrnaNxFD7kmaXZlvjH9nQ= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= +github.com/jmespath/go-jmespath v0.3.0 h1:OS12ieG61fsCg5+qLJ+SsW9NicxNkg3b25OyT2yCeUc= github.com/jmespath/go-jmespath v0.3.0/go.mod h1:9QtRXoHjLGCJ5IBSaohpXITPlowMeeYCZ7fLUTSywik= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= @@ -260,6 +271,7 @@ github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/u github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= +github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= @@ -325,6 +337,7 @@ github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzE github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= +github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32 h1:W6apQkHrMkS0Muv8G/TipAy/FJl/rCYT0+EuS8+Z0z4= github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32/go.mod h1:9wM+0iRr9ahx58uYLpLIr5fm8diHn0JbqRycJi6w0Ms= github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= @@ -419,7 +432,9 @@ github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= +github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= +github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= github.com/sony/gobreaker v0.4.1/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJOjmxWY= @@ -446,6 +461,7 @@ github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3 github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= @@ -626,6 +642,7 @@ golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapK golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= 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 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk= google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= @@ -673,6 +690,7 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= 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 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= @@ -687,6 +705,7 @@ gopkg.in/jcmturner/aescts.v1 v1.0.1 h1:cVVZBK2b1zY26haWB4vbBiZrfFQnfbTVrE3xZq6hr gopkg.in/jcmturner/aescts.v1 v1.0.1/go.mod h1:nsR8qBOg+OucoIW+WMhB3GspUQXq9XorLnQb9XtvcOo= gopkg.in/jcmturner/dnsutils.v1 v1.0.1 h1:cIuC1OLRGZrld+16ZJvvZxVJeKPsvd5eUIvxfoN5hSM= gopkg.in/jcmturner/dnsutils.v1 v1.0.1/go.mod h1:m3v+5svpVOhtFAP/wSz+yzh4Mc0Fg7eRhxkJMWSIz9Q= +gopkg.in/jcmturner/goidentity.v3 v3.0.0 h1:1duIyWiTaYvVx3YX2CYtpJbUFd7/UuPYCfgXtQ3VTbI= gopkg.in/jcmturner/goidentity.v3 v3.0.0/go.mod h1:oG2kH0IvSYNIu80dVAyu/yoefjq1mNfM5bm88whjWx4= gopkg.in/jcmturner/gokrb5.v7 v7.2.3/go.mod h1:l8VISx+WGYp+Fp7KRbsiUuXTTOnxIc3Tuvyavf11/WM= gopkg.in/jcmturner/gokrb5.v7 v7.5.0 h1:a9tsXlIDD9SKxotJMK3niV7rPZAJeX2aD/0yg3qlIrg= diff --git a/server/server.go b/server/server.go index 1159b8c9..75199e9d 100644 --- a/server/server.go +++ b/server/server.go @@ -30,7 +30,6 @@ import ( "net/url" "strings" "time" - // we just have to import this package in order to expose pprof interface in debug mode // disable "G108 (CWE-): Profiling endpoint is automatically exposed on /debug/pprof" // #nosec G108 @@ -40,22 +39,14 @@ import ( "github.com/RedHatInsights/insights-content-service/groups" "github.com/RedHatInsights/insights-operator-utils/responses" "github.com/RedHatInsights/insights-operator-utils/types" + "github.com/gorilla/handlers" "github.com/gorilla/mux" "github.com/rs/zerolog/log" + httputils "github.com/RedHatInsights/insights-operator-utils/http" ira_server "github.com/RedHatInsights/insights-results-aggregator/server" - "github.com/RedHatInsights/insights-content-service/groups" - httputils "github.com/RedHatInsights/insights-operator-utils/http" - "github.com/RedHatInsights/insights-operator-utils/responses" - "github.com/RedHatInsights/insights-operator-utils/types" - ira_server "github.com/RedHatInsights/insights-results-aggregator/server" - "github.com/gorilla/handlers" - "github.com/gorilla/mux" - "github.com/rs/zerolog/log" "github.com/RedHatInsights/insights-results-smart-proxy/content" - "github.com/RedHatInsights/insights-results-smart-proxy/content" - "github.com/RedHatInsights/insights-results-smart-proxy/services" "github.com/RedHatInsights/insights-results-smart-proxy/services" proxy_types "github.com/RedHatInsights/insights-results-smart-proxy/types" diff --git a/server/server_test.go b/server/server_test.go index 78dae58a..77fa497e 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -23,7 +23,6 @@ import ( "time" ics_server "github.com/RedHatInsights/insights-content-service/server" - "github.com/RedHatInsights/insights-operator-utils/types" "github.com/RedHatInsights/insights-results-aggregator-data/testdata" ira_server "github.com/RedHatInsights/insights-results-aggregator/server" "github.com/rs/zerolog" From 961bfc7cb9414cbbbaaead509cc1f557dcf148be Mon Sep 17 00:00:00 2001 From: Serhii Zakharov Date: Thu, 25 Jun 2020 11:13:21 +0200 Subject: [PATCH 09/14] updated version of utils --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 6745d46e..1004ad20 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.13 require ( github.com/BurntSushi/toml v0.3.1 github.com/RedHatInsights/insights-content-service v0.0.0-20200619153839-23a428468a08 - github.com/RedHatInsights/insights-operator-utils v1.2.0 + github.com/RedHatInsights/insights-operator-utils v1.2.1 github.com/RedHatInsights/insights-results-aggregator v0.0.0-20200622123018-31c3f8ac30bd github.com/RedHatInsights/insights-results-aggregator-data v0.0.0-20200622112651-e5a7c1d79015 github.com/Shopify/sarama v1.26.4 // indirect diff --git a/go.sum b/go.sum index 1d4020da..5a358c5e 100644 --- a/go.sum +++ b/go.sum @@ -31,6 +31,8 @@ github.com/RedHatInsights/insights-operator-utils v1.0.2-0.20200610143236-c868b2 github.com/RedHatInsights/insights-operator-utils v1.1.0/go.mod h1:PHoCR0njiPXVArw+ooowqZgBjozu1h+8mYDoRoPVh6g= github.com/RedHatInsights/insights-operator-utils v1.2.0 h1:M1lEO5NSJnfwbs/IWyeAXoFcb0VE7XvdPa4bVJHOT74= github.com/RedHatInsights/insights-operator-utils v1.2.0/go.mod h1:PHoCR0njiPXVArw+ooowqZgBjozu1h+8mYDoRoPVh6g= +github.com/RedHatInsights/insights-operator-utils v1.2.1 h1:cls7FGRatQ6N1O2Op62idPSwIg0mBqN3Cy0M/XUxHLU= +github.com/RedHatInsights/insights-operator-utils v1.2.1/go.mod h1:PHoCR0njiPXVArw+ooowqZgBjozu1h+8mYDoRoPVh6g= github.com/RedHatInsights/insights-results-aggregator v0.0.0-20200604090056-3534f6dd9c1c/go.mod h1:7Pc15NYXErx7BMJ4rF1Hacm+29G6atzjhwBpXNFMt+0= github.com/RedHatInsights/insights-results-aggregator v0.0.0-20200622123018-31c3f8ac30bd h1:gdUaIRh8G8ud4Ir6S1nPMZ5I3p5PgQNzKlnMBFCKenA= github.com/RedHatInsights/insights-results-aggregator v0.0.0-20200622123018-31c3f8ac30bd/go.mod h1:ESr5qmC0Hvod77nud0qfAUFNFGp5wK2ddIyHvnTf8ag= From d242781db4e750fb0ba93dda6989f0aaaa4cbdd5 Mon Sep 17 00:00:00 2001 From: Serhii Zakharov Date: Thu, 25 Jun 2020 18:07:08 +0200 Subject: [PATCH 10/14] fixed dependencies --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 1c93d818..0cab4a7e 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.13 require ( github.com/BurntSushi/toml v0.3.1 github.com/RedHatInsights/insights-content-service v0.0.0-20200619153839-23a428468a08 - github.com/RedHatInsights/insights-operator-utils v1.2.1 + github.com/RedHatInsights/insights-operator-utils v1.2.2 github.com/RedHatInsights/insights-results-aggregator v0.0.0-20200622123018-31c3f8ac30bd github.com/RedHatInsights/insights-results-aggregator-data v0.0.0-20200624135606-84f78db90ac2 github.com/Shopify/sarama v1.26.4 // indirect diff --git a/go.sum b/go.sum index ec381b30..48e28a93 100644 --- a/go.sum +++ b/go.sum @@ -31,6 +31,8 @@ github.com/RedHatInsights/insights-operator-utils v1.0.2-0.20200610143236-c868b2 github.com/RedHatInsights/insights-operator-utils v1.1.0/go.mod h1:PHoCR0njiPXVArw+ooowqZgBjozu1h+8mYDoRoPVh6g= github.com/RedHatInsights/insights-operator-utils v1.2.1 h1:cls7FGRatQ6N1O2Op62idPSwIg0mBqN3Cy0M/XUxHLU= github.com/RedHatInsights/insights-operator-utils v1.2.1/go.mod h1:PHoCR0njiPXVArw+ooowqZgBjozu1h+8mYDoRoPVh6g= +github.com/RedHatInsights/insights-operator-utils v1.2.2 h1:1S4RhDfAQWBOc6VOdaBqgWoUVojejqhSlJAhit2Ciyo= +github.com/RedHatInsights/insights-operator-utils v1.2.2/go.mod h1:PHoCR0njiPXVArw+ooowqZgBjozu1h+8mYDoRoPVh6g= github.com/RedHatInsights/insights-results-aggregator v0.0.0-20200604090056-3534f6dd9c1c/go.mod h1:7Pc15NYXErx7BMJ4rF1Hacm+29G6atzjhwBpXNFMt+0= github.com/RedHatInsights/insights-results-aggregator v0.0.0-20200622123018-31c3f8ac30bd h1:gdUaIRh8G8ud4Ir6S1nPMZ5I3p5PgQNzKlnMBFCKenA= github.com/RedHatInsights/insights-results-aggregator v0.0.0-20200622123018-31c3f8ac30bd/go.mod h1:ESr5qmC0Hvod77nud0qfAUFNFGp5wK2ddIyHvnTf8ag= From ff765dc277b02a1ce024ad6dd04555f658dd1340 Mon Sep 17 00:00:00 2001 From: Serhii Zakharov Date: Fri, 26 Jun 2020 16:03:22 +0200 Subject: [PATCH 11/14] extract-user-id-from-token-to-url --- server/endpoints.go | 73 ++++++++++++++++------- server/endpoints_test.go | 52 +++++++++++++++++ server/server.go | 122 ++++++++++++++++++++++++++++++++++----- server/server_test.go | 29 +++++----- 4 files changed, 229 insertions(+), 47 deletions(-) diff --git a/server/endpoints.go b/server/endpoints.go index b270b2d4..1238eddb 100644 --- a/server/endpoints.go +++ b/server/endpoints.go @@ -34,37 +34,43 @@ const ( RuleContent = "rules/{rule_id}/content" // MetricsEndpoint returns prometheus metrics MetricsEndpoint = "metrics" - // LikeRuleEndpoint likes rule with {rule_id} for {cluster} using current user(from auth header) - LikeRuleEndpoint = ira_server.LikeRuleEndpoint + LikeRuleEndpoint = "clusters/{cluster}/rules/{rule_id}/like" // DislikeRuleEndpoint dislikes rule with {rule_id} for {cluster} using current user(from auth header) - DislikeRuleEndpoint = ira_server.DislikeRuleEndpoint + DislikeRuleEndpoint = "clusters/{cluster}/rules/{rule_id}/dislike" // ResetVoteOnRuleEndpoint resets vote on rule with {rule_id} for {cluster} using current user(from auth header) - ResetVoteOnRuleEndpoint = ira_server.ResetVoteOnRuleEndpoint - // ClustersForOrganizationEndpoint returns all clusters for {organization} - ClustersForOrganizationEndpoint = ira_server.ClustersForOrganizationEndpoint + ResetVoteOnRuleEndpoint = "clusters/{cluster}/rules/{rule_id}/reset_vote" + // GetVoteOnRuleEndpoint is an endpoint to get vote on rule. DEBUG only + GetVoteOnRuleEndpoint = "clusters/{cluster}/rules/{rule_id}/get_vote" // DisableRuleForClusterEndpoint disables a rule for specified cluster - DisableRuleForClusterEndpoint = ira_server.DisableRuleForClusterEndpoint + DisableRuleForClusterEndpoint = "clusters/{cluster}/rules/{rule_id}/disable" // EnableRuleForClusterEndpoint re-enables a rule for specified cluster - EnableRuleForClusterEndpoint = ira_server.EnableRuleForClusterEndpoint + EnableRuleForClusterEndpoint = "clusters/{cluster}/rules/{rule_id}/enable" + + // ClustersForOrganizationEndpoint returns all clusters for {organization} + ClustersForOrganizationEndpoint = ira_server.ClustersForOrganizationEndpoint // OrganizationsEndpoint returns all organizations OrganizationsEndpoint = ira_server.OrganizationsEndpoint // DeleteOrganizationsEndpoint deletes all {organizations}(comma separated array). DEBUG only DeleteOrganizationsEndpoint = ira_server.DeleteOrganizationsEndpoint // DeleteClustersEndpoint deletes all {clusters}(comma separated array). DEBUG only DeleteClustersEndpoint = ira_server.DeleteClustersEndpoint - // GetVoteOnRuleEndpoint is an endpoint to get vote on rule. DEBUG only - GetVoteOnRuleEndpoint = ira_server.GetVoteOnRuleEndpoint ) func (server *HTTPServer) addDebugEndpointsToRouter(router *mux.Router) { apiPrefix := server.Config.APIPrefix - aggregatorEndpoint := server.ServicesConfig.AggregatorBaseEndpoint + aggregatorBaseURL := server.ServicesConfig.AggregatorBaseEndpoint - router.HandleFunc(apiPrefix+OrganizationsEndpoint, server.proxyTo(aggregatorEndpoint)).Methods(http.MethodGet) - router.HandleFunc(apiPrefix+DeleteOrganizationsEndpoint, server.proxyTo(aggregatorEndpoint)).Methods(http.MethodDelete) - router.HandleFunc(apiPrefix+DeleteClustersEndpoint, server.proxyTo(aggregatorEndpoint)).Methods(http.MethodDelete) - router.HandleFunc(apiPrefix+GetVoteOnRuleEndpoint, server.proxyTo(aggregatorEndpoint)).Methods(http.MethodGet) + router.HandleFunc(apiPrefix+OrganizationsEndpoint, server.proxyTo(aggregatorBaseURL, nil)).Methods(http.MethodGet) + router.HandleFunc(apiPrefix+DeleteOrganizationsEndpoint, server.proxyTo(aggregatorBaseURL, nil)).Methods(http.MethodDelete) + router.HandleFunc(apiPrefix+DeleteClustersEndpoint, server.proxyTo(aggregatorBaseURL, nil)).Methods(http.MethodDelete) + router.HandleFunc(apiPrefix+GetVoteOnRuleEndpoint, server.proxyTo( + aggregatorBaseURL, + &ProxyOptions{RequestModifiers: []RequestModifier{ + server.newExtractUserIDFromTokenToURLRequestModifier(ira_server.GetVoteOnRuleEndpoint), + }}, + ), + ).Methods(http.MethodGet) // endpoints for pprof - needed for profiling, ie. usually in debug mode router.PathPrefix("/debug/pprof/").Handler(http.DefaultServeMux) @@ -83,12 +89,37 @@ func (server *HTTPServer) addEndpointsToRouter(router *mux.Router) { // common REST API endpoints router.HandleFunc(apiPrefix+MainEndpoint, server.mainEndpoint).Methods(http.MethodGet) router.HandleFunc(apiPrefix+ReportEndpoint, server.reportEndpoint).Methods(http.MethodGet, http.MethodOptions) - router.HandleFunc(apiPrefix+LikeRuleEndpoint, server.proxyTo(aggregatorEndpoint)).Methods(http.MethodPut, http.MethodOptions) - router.HandleFunc(apiPrefix+DislikeRuleEndpoint, server.proxyTo(aggregatorEndpoint)).Methods(http.MethodPut, http.MethodOptions) - router.HandleFunc(apiPrefix+ResetVoteOnRuleEndpoint, server.proxyTo(aggregatorEndpoint)).Methods(http.MethodPut, http.MethodOptions) - router.HandleFunc(apiPrefix+ClustersForOrganizationEndpoint, server.proxyTo(aggregatorEndpoint)).Methods(http.MethodGet) - router.HandleFunc(apiPrefix+DisableRuleForClusterEndpoint, server.proxyTo(aggregatorEndpoint)).Methods(http.MethodPut, http.MethodOptions) - router.HandleFunc(apiPrefix+EnableRuleForClusterEndpoint, server.proxyTo(aggregatorEndpoint)).Methods(http.MethodPut, http.MethodOptions) + router.HandleFunc(apiPrefix+LikeRuleEndpoint, server.proxyTo( + aggregatorEndpoint, + &ProxyOptions{RequestModifiers: []RequestModifier{ + server.newExtractUserIDFromTokenToURLRequestModifier(ira_server.LikeRuleEndpoint), + }}, + )).Methods(http.MethodPut, http.MethodOptions) + router.HandleFunc(apiPrefix+DislikeRuleEndpoint, server.proxyTo( + aggregatorEndpoint, + &ProxyOptions{RequestModifiers: []RequestModifier{ + server.newExtractUserIDFromTokenToURLRequestModifier(ira_server.DislikeRuleEndpoint), + }}, + )).Methods(http.MethodPut, http.MethodOptions) + router.HandleFunc(apiPrefix+ResetVoteOnRuleEndpoint, server.proxyTo( + aggregatorEndpoint, + &ProxyOptions{RequestModifiers: []RequestModifier{ + server.newExtractUserIDFromTokenToURLRequestModifier(ira_server.ResetVoteOnRuleEndpoint), + }}, + )).Methods(http.MethodPut, http.MethodOptions) + router.HandleFunc(apiPrefix+ClustersForOrganizationEndpoint, server.proxyTo(aggregatorEndpoint, nil)).Methods(http.MethodGet) + router.HandleFunc(apiPrefix+DisableRuleForClusterEndpoint, server.proxyTo( + aggregatorEndpoint, + &ProxyOptions{RequestModifiers: []RequestModifier{ + server.newExtractUserIDFromTokenToURLRequestModifier(ira_server.DisableRuleForClusterEndpoint), + }}, + )).Methods(http.MethodPut, http.MethodOptions) + router.HandleFunc(apiPrefix+EnableRuleForClusterEndpoint, server.proxyTo( + aggregatorEndpoint, + &ProxyOptions{RequestModifiers: []RequestModifier{ + server.newExtractUserIDFromTokenToURLRequestModifier(ira_server.EnableRuleForClusterEndpoint), + }}, + )).Methods(http.MethodPut, http.MethodOptions) router.HandleFunc(apiPrefix+RuleGroupsEndpoint, server.getGroups).Methods(http.MethodGet, http.MethodOptions) router.HandleFunc(apiPrefix+RuleContent, server.getContentForRule).Methods(http.MethodGet) diff --git a/server/endpoints_test.go b/server/endpoints_test.go index 28f346e1..f57e3346 100644 --- a/server/endpoints_test.go +++ b/server/endpoints_test.go @@ -15,10 +15,16 @@ package server_test import ( + "net/http" "testing" httputils "github.com/RedHatInsights/insights-operator-utils/http" + "github.com/RedHatInsights/insights-results-aggregator-data/testdata" + ira_server "github.com/RedHatInsights/insights-results-aggregator/server" "github.com/stretchr/testify/assert" + + "github.com/RedHatInsights/insights-results-smart-proxy/server" + "github.com/RedHatInsights/insights-results-smart-proxy/tests/helpers" ) func TestMakeURLToEndpointWithValidValue(t *testing.T) { @@ -29,3 +35,49 @@ func TestMakeURLToEndpointWithValidValue(t *testing.T) { assert.Equal(t, "api/v1/some_valid_endpoint", retval) } + +func TestHTTPServer_ProxyTo_VoteEndpointsExtractUserID(t *testing.T) { + testCases := []struct { + name string + method string + endpoint string + newEndpoint string + }{ + {"like", http.MethodPut, server.LikeRuleEndpoint, ira_server.LikeRuleEndpoint}, + {"dislike", http.MethodPut, server.DislikeRuleEndpoint, ira_server.DislikeRuleEndpoint}, + {"reset_vote", http.MethodPut, server.ResetVoteOnRuleEndpoint, ira_server.ResetVoteOnRuleEndpoint}, + {"enable", http.MethodPut, server.EnableRuleForClusterEndpoint, ira_server.EnableRuleForClusterEndpoint}, + {"disable", http.MethodPut, server.DisableRuleForClusterEndpoint, ira_server.DisableRuleForClusterEndpoint}, + {"get_vote", http.MethodGet, server.GetVoteOnRuleEndpoint, ira_server.GetVoteOnRuleEndpoint}, + } + + for _, testCase := range testCases { + t.Run(testCase.name, func(t *testing.T) { + helpers.RunTestWithTimeout(t, func(t *testing.T) { + defer helpers.CleanAfterGock(t) + + helpers.GockExpectAPIRequest(t, helpers.DefaultServicesConfig.AggregatorBaseEndpoint, &helpers.APIRequest{ + Method: testCase.method, + Endpoint: testCase.newEndpoint, + EndpointArgs: []interface{}{testdata.ClusterName, testdata.Rule1ID, testdata.UserID}, + }, &helpers.APIResponse{ + StatusCode: http.StatusOK, + Body: `{"status": "ok"}`, + }) + + helpers.AssertAPIRequest(t, nil, nil, nil, &helpers.APIRequest{ + Method: testCase.method, + Endpoint: testCase.endpoint, + EndpointArgs: []interface{}{testdata.ClusterName, testdata.Rule1ID}, + UserID: testdata.UserID, + OrgID: testdata.OrgID, + }, &helpers.APIResponse{ + StatusCode: http.StatusOK, + Body: `{"status": "ok"}`, + }) + }, testTimeout) + }) + } +} + +// TODO: test that proxying is done correctly including request / response modifiers for all endpoints diff --git a/server/server.go b/server/server.go index 75199e9d..7cbc6d2f 100644 --- a/server/server.go +++ b/server/server.go @@ -60,6 +60,19 @@ type HTTPServer struct { Serv *http.Server } +// RequestModifier is a type of function which modifies request when proxying +type RequestModifier func(request *http.Request) (*http.Request, error) + +// ResponseModifier is a type of function which modifies response when proxying +type ResponseModifier func(response *http.Response) (*http.Response, error) + +// ProxyOptions alters behaviour of proxy server for each endpoint. +// For example, you can set custom request and response modifiers +type ProxyOptions struct { + RequestModifiers []RequestModifier + ResponseModifiers []ResponseModifier +} + // New constructs new implementation of Server interface func New(config Configuration, servicesConfig services.Configuration, groupsChannel chan []groups.Group) *HTTPServer { return &HTTPServer{ @@ -208,40 +221,101 @@ func (server HTTPServer) redirectTo(baseURL string) func(http.ResponseWriter, *h } } -func (server HTTPServer) proxyTo(baseURL string) func(http.ResponseWriter, *http.Request) { +func modifyRequest(requestModifiers []RequestModifier, request *http.Request) (*http.Request, error) { + for _, modifier := range requestModifiers { + var err error + request, err = modifier(request) + if err != nil { + return nil, err + } + } + + return request, nil +} + +func modifyResponse(responseModifiers []ResponseModifier, response *http.Response) (*http.Response, error) { + for _, modifier := range responseModifiers { + var err error + response, err = modifier(response) + if err != nil { + return nil, err + } + } + + return response, nil +} + +func (server HTTPServer) proxyTo(baseURL string, options *ProxyOptions) func(http.ResponseWriter, *http.Request) { return func(writer http.ResponseWriter, request *http.Request) { + if options != nil { + var err error + request, err = modifyRequest(options.RequestModifiers, request) + if err != nil { + handleServerError(writer, err) + return + } + } + log.Info().Msg("Handling response as a proxy") - endpointURL, err := server.composeEndpoint(baseURL, request.RequestURI) + endpointURL, err := server.composeEndpoint(baseURL, request.RequestURI) if err != nil { log.Error().Err(err).Msgf("Error during endpoint %s URL parsing", request.RequestURI) handleServerError(writer, err) + return } client := http.Client{} - req, _ := http.NewRequest(request.Method, endpointURL.String(), request.Body) - copyHeader(request.Header, req.Header) - - log.Debug().Msgf("Connecting to %s", endpointURL.String()) - response, err := client.Do(req) + req, err := http.NewRequest(request.Method, endpointURL.String(), request.Body) if err != nil { - log.Error().Err(err).Msgf("Error during retrieve of %s", endpointURL.String()) - handleServerError(writer, err) + panic(err) } - body, err := ioutil.ReadAll(response.Body) + copyHeader(request.Header, req.Header) - if err != nil { - log.Error().Err(err).Msgf("Error while retrieving content from request to %s", endpointURL.String()) - handleServerError(writer, err) + response, body, successful := server.sendRequest(client, req, options, writer) + if !successful { + return } + // Maybe this code should be on responses.SendRaw or something like that err = responses.Send(response.StatusCode, writer, body) if err != nil { log.Error().Err(err).Msgf("Error writing the response") handleServerError(writer, err) + return + } + } +} + +func (server HTTPServer) sendRequest( + client http.Client, req *http.Request, options *ProxyOptions, writer http.ResponseWriter, +) (*http.Response, []byte, bool) { + log.Debug().Msgf("Connecting to %s", req.RequestURI) + response, err := client.Do(req) + if err != nil { + log.Error().Err(err).Msgf("Error during retrieve of %s", req.RequestURI) + handleServerError(writer, err) + return nil, nil, false + } + + if options != nil { + var err error + response, err = modifyResponse(options.ResponseModifiers, response) + if err != nil { + handleServerError(writer, err) + return nil, nil, false } } + + body, err := ioutil.ReadAll(response.Body) + if err != nil { + log.Error().Err(err).Msgf("Error while retrieving content from request to %s", req.RequestURI) + handleServerError(writer, err) + return nil, nil, false + } + + return response, body, true } func (server HTTPServer) composeEndpoint(baseEndpoint string, currentEndpoint string) (*url.URL, error) { @@ -367,3 +441,25 @@ func (server HTTPServer) reportEndpoint(writer http.ResponseWriter, request *htt log.Error().Err(err).Msg(responseDataError) } } + +func (server HTTPServer) newExtractUserIDFromTokenToURLRequestModifier(newEndpoint string) func(*http.Request) (*http.Request, error) { + return func(request *http.Request) (*http.Request, error) { + identity, err := server.GetAuthToken(request) + if err != nil { + return nil, err + } + + vars := mux.Vars(request) + vars["user_id"] = string(identity.AccountNumber) + + newURL := httputils.MakeURLToEndpointMapString(server.Config.APIPrefix, newEndpoint, vars) + request.URL, err = url.Parse(newURL) + if err != nil { + return nil, err + } + + request.RequestURI = request.URL.RequestURI() + + return request, nil + } +} diff --git a/server/server_test.go b/server/server_test.go index 77fa497e..a6265f0d 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -17,7 +17,6 @@ limitations under the License. package server_test import ( - "bytes" "net/http" "testing" "time" @@ -27,7 +26,6 @@ import ( ira_server "github.com/RedHatInsights/insights-results-aggregator/server" "github.com/rs/zerolog" "github.com/stretchr/testify/assert" - gock "gopkg.in/h2non/gock.v1" "github.com/RedHatInsights/insights-results-smart-proxy/content" "github.com/RedHatInsights/insights-results-smart-proxy/server" @@ -151,21 +149,26 @@ func TestAddCORSHeaders(t *testing.T) { func TestHTTPServer_ReportEndpoint(t *testing.T) { helpers.RunTestWithTimeout(t, func(t *testing.T) { - defer gock.Off() + defer helpers.CleanAfterGock(t) - gock.New(helpers.DefaultServicesConfig.AggregatorBaseEndpoint). - Get("/"). - AddMatcher(helpers.NewGockAPIEndpointMatcher(ira_server.ReportEndpoint)). - Reply(200). - JSON(testdata.Report3RulesExpectedResponse) + helpers.GockExpectAPIRequest(t, helpers.DefaultServicesConfig.AggregatorBaseEndpoint, &helpers.APIRequest{ + Method: http.MethodGet, + Endpoint: ira_server.ReportEndpoint, + }, &helpers.APIResponse{ + StatusCode: http.StatusOK, + Body: testdata.Report3RulesExpectedResponse, + }) - gock.New(helpers.DefaultServicesConfig.ContentBaseEndpoint). - Get("/"). - AddMatcher(helpers.NewGockAPIEndpointMatcher(ics_server.AllContentEndpoint)). - Reply(200). - Body(bytes.NewBuffer(helpers.MustGobSerialize(t, testdata.RuleContentDirectory3Rules))) + helpers.GockExpectAPIRequest(t, helpers.DefaultServicesConfig.AggregatorBaseEndpoint, &helpers.APIRequest{ + Method: http.MethodGet, + Endpoint: ics_server.AllContentEndpoint, + }, &helpers.APIResponse{ + StatusCode: http.StatusOK, + Body: testdata.RuleContentDirectory3Rules, + }) go content.RunUpdateContentLoop(helpers.DefaultServicesConfig) + defer content.StopUpdateContentLoop() helpers.AssertAPIRequest(t, nil, nil, nil, &helpers.APIRequest{ Method: http.MethodGet, From df59c1af94e8aa6cdab01657d48d4861868cbab9 Mon Sep 17 00:00:00 2001 From: Serhii Zakharov Date: Sun, 28 Jun 2020 14:38:13 +0200 Subject: [PATCH 12/14] few fixes --- content/parsing.go | 16 ++++++++++------ server/server_test.go | 9 +++++---- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/content/parsing.go b/content/parsing.go index 8afc927b..a942fafc 100644 --- a/content/parsing.go +++ b/content/parsing.go @@ -23,8 +23,11 @@ import ( "github.com/rs/zerolog/log" ) -const ( - timeParseFormat = "2006-01-02 15:04:05" +var ( + timeParseFormats = []string{ + "2006-01-02 15:04:05", + time.RFC3339, + } ) // TODO: consider moving parsing to content service @@ -54,7 +57,6 @@ func loadRuleContent(contentDir *content.RuleContentDirectory) { } publishDate, err := timeParse(errorProperties.Metadata.PublishDate) - if err != nil { return } @@ -103,18 +105,20 @@ func commaSeparatedStrToTags(str string) []string { func timeParse(value string) (time.Time, error) { var err error - for _, datetimeLayout := range []string{timeParseFormat, time.RFC3339} { + for _, datetimeLayout := range timeParseFormats { parsedDate, err := time.Parse(datetimeLayout, value) if err == nil { return parsedDate, nil } - log.Error().Msgf( - `invalid to parse time "%v" using layout "%v"`, + log.Info().Msgf( + `unable to parse time "%v" using layout "%v"`, value, datetimeLayout, ) } + log.Error().Err(err) + return time.Time{}, err } diff --git a/server/server_test.go b/server/server_test.go index a6265f0d..a8ad99ba 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -152,19 +152,20 @@ func TestHTTPServer_ReportEndpoint(t *testing.T) { defer helpers.CleanAfterGock(t) helpers.GockExpectAPIRequest(t, helpers.DefaultServicesConfig.AggregatorBaseEndpoint, &helpers.APIRequest{ - Method: http.MethodGet, - Endpoint: ira_server.ReportEndpoint, + Method: http.MethodGet, + Endpoint: ira_server.ReportEndpoint, + EndpointArgs: []interface{}{testdata.OrgID, testdata.ClusterName, testdata.UserID}, }, &helpers.APIResponse{ StatusCode: http.StatusOK, Body: testdata.Report3RulesExpectedResponse, }) - helpers.GockExpectAPIRequest(t, helpers.DefaultServicesConfig.AggregatorBaseEndpoint, &helpers.APIRequest{ + helpers.GockExpectAPIRequest(t, helpers.DefaultServicesConfig.ContentBaseEndpoint, &helpers.APIRequest{ Method: http.MethodGet, Endpoint: ics_server.AllContentEndpoint, }, &helpers.APIResponse{ StatusCode: http.StatusOK, - Body: testdata.RuleContentDirectory3Rules, + Body: helpers.MustGobSerialize(t, testdata.RuleContentDirectory3Rules), }) go content.RunUpdateContentLoop(helpers.DefaultServicesConfig) From 522ab8ce917d2eb1417f74bcc85a2a6c0e01b5c0 Mon Sep 17 00:00:00 2001 From: Serhii Zakharov Date: Mon, 29 Jun 2020 14:15:23 +0200 Subject: [PATCH 13/14] updated version --- go.mod | 20 ++++++++++---------- go.sum | 27 +++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 10 deletions(-) diff --git a/go.mod b/go.mod index 0cab4a7e..f4f6f394 100644 --- a/go.mod +++ b/go.mod @@ -4,35 +4,35 @@ go 1.13 require ( github.com/BurntSushi/toml v0.3.1 - github.com/RedHatInsights/insights-content-service v0.0.0-20200619153839-23a428468a08 - github.com/RedHatInsights/insights-operator-utils v1.2.2 - github.com/RedHatInsights/insights-results-aggregator v0.0.0-20200622123018-31c3f8ac30bd + github.com/RedHatInsights/insights-content-service v0.0.0-20200624083233-f39245e725f9 + github.com/RedHatInsights/insights-operator-utils v1.2.3 + github.com/RedHatInsights/insights-results-aggregator v0.0.0-20200629094804-3c27dab7158a github.com/RedHatInsights/insights-results-aggregator-data v0.0.0-20200624135606-84f78db90ac2 github.com/Shopify/sarama v1.26.4 // indirect - github.com/aws/aws-sdk-go v1.32.6 // indirect + github.com/aws/aws-sdk-go v1.32.11 // indirect github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 github.com/dgrijalva/jwt-go v3.2.0+incompatible github.com/fsnotify/fsnotify v1.4.9 // indirect github.com/google/uuid v1.1.1 github.com/gorilla/handlers v1.4.2 github.com/gorilla/mux v1.7.4 - github.com/klauspost/compress v1.10.9 // indirect + github.com/klauspost/compress v1.10.10 // indirect github.com/mitchellh/mapstructure v1.3.2 // indirect github.com/pelletier/go-toml v1.8.0 // indirect github.com/pierrec/lz4 v2.5.2+incompatible // indirect - github.com/prometheus/client_golang v1.7.0 + github.com/prometheus/client_golang v1.7.1 github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 // indirect github.com/rs/zerolog v1.19.0 - github.com/spf13/afero v1.3.0 // indirect + github.com/spf13/afero v1.3.1 // indirect github.com/spf13/cast v1.3.1 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/spf13/viper v1.7.0 github.com/stretchr/testify v1.6.1 - golang.org/x/crypto v0.0.0-20200604202706-70a84ac30bf9 // indirect - golang.org/x/sys v0.0.0-20200620081246-981b61492c35 // indirect + golang.org/x/net v0.0.0-20200625001655-4c5254603344 // indirect + golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae // indirect golang.org/x/text v0.3.3 // indirect - google.golang.org/protobuf v1.24.0 // indirect + google.golang.org/protobuf v1.25.0 // indirect gopkg.in/h2non/gock.v1 v1.0.15 gopkg.in/ini.v1 v1.57.0 // indirect ) diff --git a/go.sum b/go.sum index 48e28a93..578a073a 100644 --- a/go.sum +++ b/go.sum @@ -26,16 +26,23 @@ github.com/RedHatInsights/cloudwatch v0.0.0-20200512151223-b0b55757a24b/go.mod h github.com/RedHatInsights/insights-content-service v0.0.0-20200610101541-f0c10d6d451d/go.mod h1:j3Mc+Xh2ospxJ+K2RIZjYlI6E6E4H2Qh3cgUzhstrfQ= github.com/RedHatInsights/insights-content-service v0.0.0-20200619153839-23a428468a08 h1:hsmKH/lhX5KW1IIvjicC1lyTOt4t9RMjrGJkHuSDHN8= github.com/RedHatInsights/insights-content-service v0.0.0-20200619153839-23a428468a08/go.mod h1:CSzDwoJXMIPnRNOZfYn68YbXejRqSr0i4uqtB6oLYt4= +github.com/RedHatInsights/insights-content-service v0.0.0-20200624083233-f39245e725f9 h1:QmXSNG0sEvLJHC/wJ9Tt9Utoo3pYXbnSNacrI2sDM/k= +github.com/RedHatInsights/insights-content-service v0.0.0-20200624083233-f39245e725f9/go.mod h1:3oTuosLY7MXMi93ljKD39B0sOgtpB8jm1hI6r+f4sZw= github.com/RedHatInsights/insights-operator-utils v1.0.1/go.mod h1:gRzYBMY4csuOXgrxUuC10WUkz6STOm3mqVsQCb+AGOQ= github.com/RedHatInsights/insights-operator-utils v1.0.2-0.20200610143236-c868b2f93d2a/go.mod h1:0rhk13kn0BB+yKdfZjpMoQy0lXdXY3i4NJ1xGwGMcII= github.com/RedHatInsights/insights-operator-utils v1.1.0/go.mod h1:PHoCR0njiPXVArw+ooowqZgBjozu1h+8mYDoRoPVh6g= +github.com/RedHatInsights/insights-operator-utils v1.2.0/go.mod h1:PHoCR0njiPXVArw+ooowqZgBjozu1h+8mYDoRoPVh6g= github.com/RedHatInsights/insights-operator-utils v1.2.1 h1:cls7FGRatQ6N1O2Op62idPSwIg0mBqN3Cy0M/XUxHLU= github.com/RedHatInsights/insights-operator-utils v1.2.1/go.mod h1:PHoCR0njiPXVArw+ooowqZgBjozu1h+8mYDoRoPVh6g= github.com/RedHatInsights/insights-operator-utils v1.2.2 h1:1S4RhDfAQWBOc6VOdaBqgWoUVojejqhSlJAhit2Ciyo= github.com/RedHatInsights/insights-operator-utils v1.2.2/go.mod h1:PHoCR0njiPXVArw+ooowqZgBjozu1h+8mYDoRoPVh6g= +github.com/RedHatInsights/insights-operator-utils v1.2.3 h1:IcI1HH1fzlCxkS4HPUdTKYUdoJvXnLh1U9j0qa/517U= +github.com/RedHatInsights/insights-operator-utils v1.2.3/go.mod h1:PHoCR0njiPXVArw+ooowqZgBjozu1h+8mYDoRoPVh6g= github.com/RedHatInsights/insights-results-aggregator v0.0.0-20200604090056-3534f6dd9c1c/go.mod h1:7Pc15NYXErx7BMJ4rF1Hacm+29G6atzjhwBpXNFMt+0= github.com/RedHatInsights/insights-results-aggregator v0.0.0-20200622123018-31c3f8ac30bd h1:gdUaIRh8G8ud4Ir6S1nPMZ5I3p5PgQNzKlnMBFCKenA= github.com/RedHatInsights/insights-results-aggregator v0.0.0-20200622123018-31c3f8ac30bd/go.mod h1:ESr5qmC0Hvod77nud0qfAUFNFGp5wK2ddIyHvnTf8ag= +github.com/RedHatInsights/insights-results-aggregator v0.0.0-20200629094804-3c27dab7158a h1:IQAQG6cWeg8R4MFSr/ntgMHvf5szxG7tbvi9krU+Or8= +github.com/RedHatInsights/insights-results-aggregator v0.0.0-20200629094804-3c27dab7158a/go.mod h1:I+1AKI8JySBFUMnvUi8ss5XAm13w8n1K8BrWF8rQQBg= github.com/RedHatInsights/insights-results-aggregator-data v0.0.0-20200622112651-e5a7c1d79015/go.mod h1:1pHaSnEh5Bhc8IZNqP6vbBI3jtWd5/rv4x2Y2/zG90w= github.com/RedHatInsights/insights-results-aggregator-data v0.0.0-20200624135606-84f78db90ac2 h1:0VC80H7ubldJE50BNRxb/xyomzxJU1Ft1Fx5KihXOHY= github.com/RedHatInsights/insights-results-aggregator-data v0.0.0-20200624135606-84f78db90ac2/go.mod h1:1pHaSnEh5Bhc8IZNqP6vbBI3jtWd5/rv4x2Y2/zG90w= @@ -68,6 +75,8 @@ github.com/aws/aws-sdk-go v1.30.11/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZve github.com/aws/aws-sdk-go v1.30.25/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0= github.com/aws/aws-sdk-go v1.32.6 h1:HoswAabUWgnrUF7X/9dr4WRgrr8DyscxXvTDm7Qw/5c= github.com/aws/aws-sdk-go v1.32.6/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0= +github.com/aws/aws-sdk-go v1.32.11 h1:1nYF+Tfccn/hnAZsuwPPMSCVUVnx3j6LKOpx/WhgH0A= +github.com/aws/aws-sdk-go v1.32.11/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0= github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= 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= @@ -187,6 +196,7 @@ github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4= github.com/google/go-cmp v0.4.0/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/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/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= @@ -283,6 +293,8 @@ github.com/klauspost/compress v1.9.7/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0 github.com/klauspost/compress v1.9.8/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= github.com/klauspost/compress v1.10.9 h1:pPRt1Z78crspaHISkpSSHjDlx+Tt9suHe519dsI0vF4= github.com/klauspost/compress v1.10.9/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= +github.com/klauspost/compress v1.10.10 h1:a/y8CglcM7gLGYmlbP/stPE5sR3hbhFRUjCBfd/0B3I= +github.com/klauspost/compress v1.10.10/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= @@ -309,6 +321,7 @@ github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hd github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-sqlite3 v1.10.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= +github.com/mattn/go-sqlite3 v1.14.0 h1:mLyGNKR8+Vv9CAU7PphKa2hkEqxxhn8i32J6FPj1/QA= github.com/mattn/go-sqlite3 v1.14.0/go.mod h1:JIl7NbARA7phWnGvh0LKTyg7S9BA+6gx71ShQilpsus= github.com/mattn/go-sqlite3 v2.0.3+incompatible h1:gXHsfypPkaMZrKbD5209QV9jbUTJKjyR5WD3HYQSd+U= github.com/mattn/go-sqlite3 v2.0.3+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= @@ -368,6 +381,7 @@ github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/9 github.com/pelletier/go-toml v1.8.0 h1:Keo9qb7iRJs2voHvunFtuuYFsbWeOBh8/P9v/kVMFtw= github.com/pelletier/go-toml v1.8.0/go.mod h1:D6yutnOGMveHEPV7VQOuvI/gXY61bv+9bAOTRnLElKs= github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= +github.com/pierrec/lz4 v1.0.1 h1:w6GMGWSsCI04fTM8wQRdnW74MuJISakuUU0onU0TYB4= github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pierrec/lz4 v2.2.6+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= @@ -391,6 +405,8 @@ github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeD github.com/prometheus/client_golang v1.6.0/go.mod h1:ZLOG9ck3JLRdB5MgO8f+lLTe83AXG6ro35rLTxvnIl4= github.com/prometheus/client_golang v1.7.0 h1:wCi7urQOGBsYcQROHqpUUX4ct84xp40t9R9JX0FuA/U= github.com/prometheus/client_golang v1.7.0/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= +github.com/prometheus/client_golang v1.7.1 h1:NTGy1Ja9pByO+xAeH/qiWnLrKtr3hJPNjaVUwnjpdpA= +github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= @@ -446,6 +462,8 @@ github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2 github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= github.com/spf13/afero v1.3.0 h1:Ysnmjh1Di8EaWaBv40CYR4IdaIsBc5996Gh1oZzCBKk= github.com/spf13/afero v1.3.0/go.mod h1:5KUK8ByomD5Ti5Artl0RtHeI5pTF7MIDuXL3yY520V4= +github.com/spf13/afero v1.3.1 h1:GPTpEAuNr98px18yNQ66JllNil98wfRZ/5Ukny8FeQA= +github.com/spf13/afero v1.3.1/go.mod h1:5KUK8ByomD5Ti5Artl0RtHeI5pTF7MIDuXL3yY520V4= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng= github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= @@ -524,6 +542,8 @@ golang.org/x/crypto v0.0.0-20191117063200-497ca9f6d64f/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20200204104054-c9f3fb736b72/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200604202706-70a84ac30bf9 h1:vEg9joUBmeBcK9iSJftGNf3coIG4HqZElCPehJsfAYM= golang.org/x/crypto v0.0.0-20200604202706-70a84ac30bf9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= 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= @@ -569,6 +589,8 @@ golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200602114024-627f9648deb9 h1:pNX+40auqi2JqRfOP1akLGtYcn15TUbkhwuCO3foqqM= golang.org/x/net v0.0.0-20200602114024-627f9648deb9/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200625001655-4c5254603344 h1:vGXIOMxbNfDTk/aXCmfdLgkrSV+Z2tcbze+pEc3v5W4= +golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= 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= @@ -609,6 +631,8 @@ golang.org/x/sys v0.0.0-20200420163511-1957bb5e6d1f/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200620081246-981b61492c35 h1:wb/9mP8eUAmHfkM8RmpeLq6nUA7c2i5+bQOtcDftjaE= golang.org/x/sys v0.0.0-20200620081246-981b61492c35/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae h1:Ih9Yo4hSPImZOpfGuA4bR/ORKTAbhZo2AbWNRCnevdo= +golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 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= @@ -690,6 +714,8 @@ google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2 google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.24.0 h1:UhZDfRO8JRQru4/+LlLE0BRKGF8L+PICnvYZmx/fEGA= google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= +google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= 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= @@ -728,6 +754,7 @@ gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= 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= From 24b88e9006723cc3f8f225fee0270d2e69d5da23 Mon Sep 17 00:00:00 2001 From: Serhii Zakharov Date: Mon, 29 Jun 2020 14:33:18 +0200 Subject: [PATCH 14/14] fixed tests --- go.sum | 1 + server/server_test.go | 64 ++----------------------------------------- 2 files changed, 4 insertions(+), 61 deletions(-) diff --git a/go.sum b/go.sum index 578a073a..e76978f0 100644 --- a/go.sum +++ b/go.sum @@ -754,6 +754,7 @@ gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 h1:tQIYjPdBoyREyB9XMu+nnTclpTYkz2zFM+lzLJFO4gQ= gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/server/server_test.go b/server/server_test.go index af25225a..a8ad99ba 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -40,28 +40,6 @@ const ( // TODO: consider moving to data repo var ( - SmartProxySingleReportResponse1Rule = struct { - Status string `json:"status"` - Report *types.RuleWithContentResponse `json:"report"` - }{ - Status: "ok", - Report: &types.RuleWithContentResponse{ - RuleID: testdata.Rule1.Module, - ErrorKey: testdata.RuleErrorKey1.ErrorKey, - CreatedAt: testdata.RuleErrorKey1.PublishDate.UTC().Format(time.RFC3339), - Description: testdata.RuleErrorKey1.Description, - Generic: testdata.RuleErrorKey1.Generic, - Reason: testdata.Rule1.Reason, - Resolution: testdata.Rule1.Resolution, - TotalRisk: calculateTotalRisk(testdata.RuleErrorKey1.Impact, testdata.RuleErrorKey1.Likelihood), - RiskOfChange: 0, - Disabled: testdata.Rule1Disabled, - UserVote: types.UserVoteNone, - TemplateData: testdata.Rule1.MoreInfo, - Tags: testdata.RuleErrorKey1.Tags, - }, - } - SmartProxyReportResponse3Rules = struct { Status string `json:"status"` Report *types.SmartProxyReport `json:"report"` @@ -170,42 +148,6 @@ func TestAddCORSHeaders(t *testing.T) { } func TestHTTPServer_ReportEndpoint(t *testing.T) { - helpers.RunTestWithTimeout(t, func(t *testing.T) { - defer helpers.CleanAfterGock(t) - - helpers.GockExpectAPIRequest(t, helpers.DefaultServicesConfig.AggregatorBaseEndpoint, &helpers.APIRequest{ - Method: http.MethodGet, - Endpoint: ira_server.ReportEndpoint, - }, &helpers.APIResponse{ - StatusCode: http.StatusOK, - Body: testdata.Report3RulesExpectedResponse, - }) - - helpers.GockExpectAPIRequest(t, helpers.DefaultServicesConfig.ContentBaseEndpoint, &helpers.APIRequest{ - Method: http.MethodGet, - Endpoint: ics_server.AllContentEndpoint, - }, &helpers.APIResponse{ - StatusCode: http.StatusOK, - Body: helpers.MustGobSerialize(t, testdata.RuleContentDirectory3Rules), - }) - - go content.RunUpdateContentLoop(helpers.DefaultServicesConfig) - content.StopUpdateContentLoop() - - helpers.AssertAPIRequest(t, nil, nil, nil, &helpers.APIRequest{ - Method: http.MethodGet, - Endpoint: server.ReportEndpoint, - EndpointArgs: []interface{}{testdata.ClusterName}, - UserID: testdata.UserID, - OrgID: testdata.OrgID, - }, &helpers.APIResponse{ - StatusCode: http.StatusOK, - Body: helpers.ToJSONString(SmartProxyReportResponse3Rules), - }) - }, testTimeout) -} - -func TestHTTPServer_SingleRuleEndpoint(t *testing.T) { helpers.RunTestWithTimeout(t, func(t *testing.T) { defer helpers.CleanAfterGock(t) @@ -231,13 +173,13 @@ func TestHTTPServer_SingleRuleEndpoint(t *testing.T) { helpers.AssertAPIRequest(t, nil, nil, nil, &helpers.APIRequest{ Method: http.MethodGet, - Endpoint: server.SingleRuleEndpoint, - EndpointArgs: []interface{}{testdata.ClusterName, testdata.Rule1ID}, + Endpoint: server.ReportEndpoint, + EndpointArgs: []interface{}{testdata.ClusterName}, UserID: testdata.UserID, OrgID: testdata.OrgID, }, &helpers.APIResponse{ StatusCode: http.StatusOK, - Body: helpers.ToJSONString(SmartProxySingleReportResponse1Rule), + Body: helpers.ToJSONString(SmartProxyReportResponse3Rules), }) }, testTimeout) }