From d28778f944e353fdeb92304a680d5963c4c8f393 Mon Sep 17 00:00:00 2001 From: Max Claus Nunes Date: Wed, 6 Dec 2023 21:26:12 -0300 Subject: [PATCH 1/4] Migrate mongo driver --- checkers/mongo/mongo.go | 58 ++++++++++++++++++------------------ checkers/mongo/mongo_test.go | 25 +++++----------- go.mod | 3 +- go.sum | 57 ++++++++++++++++++++++++++++++++--- 4 files changed, 91 insertions(+), 52 deletions(-) diff --git a/checkers/mongo/mongo.go b/checkers/mongo/mongo.go index 9a5c905..1fbb402 100644 --- a/checkers/mongo/mongo.go +++ b/checkers/mongo/mongo.go @@ -1,10 +1,13 @@ package mongochk import ( + "context" "fmt" "time" - "github.com/globalsign/mgo" + "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/mongo/options" ) const ( @@ -32,16 +35,14 @@ type MongoConfig struct { } // MongoAuthConfig, used to setup connection params for go-mongo check -// Url format is localhost:27017 or mongo://localhost:27017 -// Credential has format described at https://godoc.org/github.com/globalsign/mgo#Credential +// Url mongodb://localhost:27017 type MongoAuthConfig struct { - Url string - Credentials mgo.Credential + Url string } type Mongo struct { - Config *MongoConfig - Session *mgo.Session + Config *MongoConfig + Client *mongo.Client } func NewMongo(cfg *MongoConfig) (*Mongo, error) { @@ -50,34 +51,46 @@ func NewMongo(cfg *MongoConfig) (*Mongo, error) { return nil, fmt.Errorf("unable to validate mongodb config: %v", err) } - session, err := mgo.DialWithTimeout(cfg.Auth.Url, cfg.DialTimeout) + ctx, cancel := context.WithTimeout(context.Background(), cfg.DialTimeout*time.Second) + defer cancel() + + client, err := mongo.Connect(ctx, options.Client().ApplyURI(cfg.Auth.Url)) if err != nil { return nil, err } - if err := session.Ping(); err != nil { + if err := client.Ping(context.Background(), nil); err != nil { return nil, fmt.Errorf("unable to establish initial connection to mongodb: %v", err) } return &Mongo{ - Config: cfg, - Session: session, + Config: cfg, + Client: client, }, nil } -func (m *Mongo) Status() (interface{}, error) { +func (m *Mongo) Status(ctx context.Context) (interface{}, error) { if m.Config.Ping { - if err := m.Session.Ping(); err != nil { + if err := m.Client.Ping(ctx, nil); err != nil { return nil, fmt.Errorf("ping failed: %v", err) } } - if m.Config.Collection != "" { - collections, err := m.Session.DB(m.Config.DB).CollectionNames() + if m.Config.DB != "" && m.Config.Collection != "" { + cur, err := m.Client.Database(m.Config.DB). + ListCollections(ctx, bson.D{{"name", m.Config.Collection}}, options.ListCollections().SetNameOnly(true)) + if err != nil { return nil, fmt.Errorf("unable to complete set: %v", err) } - if !contains(collections, m.Config.Collection) { + + defer cur.Close(ctx) + + if !cur.Next(ctx) { + if err := cur.Err(); err != nil { + return nil, err + } + return nil, fmt.Errorf("mongo db %v collection not found", m.Config.Collection) } } @@ -85,15 +98,6 @@ func (m *Mongo) Status() (interface{}, error) { return nil, nil } -func contains(data []string, needle string) bool { - for _, item := range data { - if item == needle { - return true - } - } - return false -} - func validateMongoConfig(cfg *MongoConfig) error { if cfg == nil { return fmt.Errorf("Main config cannot be nil") @@ -107,10 +111,6 @@ func validateMongoConfig(cfg *MongoConfig) error { return fmt.Errorf("Url string must be set in auth config") } - if _, err := mgo.ParseURL(cfg.Auth.Url); err != nil { - return fmt.Errorf("Unable to parse URL: %v", err) - } - if !cfg.Ping && cfg.Collection == "" { return fmt.Errorf("At minimum, either cfg.Ping or cfg.Collection") } diff --git a/checkers/mongo/mongo_test.go b/checkers/mongo/mongo_test.go index cb7f90c..f84aa81 100644 --- a/checkers/mongo/mongo_test.go +++ b/checkers/mongo/mongo_test.go @@ -3,6 +3,7 @@ package mongochk import ( + "context" "fmt" "testing" "time" @@ -35,14 +36,14 @@ func TestNewMongo(t *testing.T) { cfg := &MongoConfig{ Ping: true, Auth: &MongoAuthConfig{ - Url: "foobar:42848", + Url: "mongodb://foobar:42848", }, DialTimeout: 20 * time.Millisecond, } r, err := NewMongo(cfg) Expect(err).To(HaveOccurred()) - Expect(err.Error()).To(ContainSubstring("no reachable servers")) + Expect(err.Error()).To(ContainSubstring("unable to establish initial connection to mongodb")) Expect(r).To(BeNil()) }) } @@ -76,7 +77,7 @@ func TestValidateMongoConfig(t *testing.T) { t.Run("Should error if none of the check methods are enabled", func(t *testing.T) { cfg := &MongoConfig{ Auth: &MongoAuthConfig{ - Url: "localhost:6379", + Url: "mongodb://localhost:6379", }, } @@ -84,19 +85,6 @@ func TestValidateMongoConfig(t *testing.T) { Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("At minimum, either cfg.Ping or cfg.Collection")) }) - - t.Run("Should error if url has wrong format", func(t *testing.T) { - cfg := &MongoConfig{ - Auth: &MongoAuthConfig{ - Url: "localhost:40001?foo=1&bar=2", - }, - } - - err := validateMongoConfig(cfg) - Expect(err).To(HaveOccurred()) - Expect(err.Error()).To(ContainSubstring("Unable to parse URL")) - }) - } func TestMongoStatus(t *testing.T) { @@ -113,13 +101,14 @@ func TestMongoStatus(t *testing.T) { Expect(err).ToNot(HaveOccurred()) - _, err = checker.Status() + _, err = checker.Status(context.TODO()) Expect(err).To(BeNil()) }) t.Run("Should error if collection not found(available)", func(t *testing.T) { cfg := &MongoConfig{ + DB: "test_db", Collection: "go-check", } checker, _, err := setupMongo(cfg) @@ -127,7 +116,7 @@ func TestMongoStatus(t *testing.T) { t.Fatal(err) } - _, err = checker.Status() + _, err = checker.Status(context.TODO()) Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("collection not found")) diff --git a/go.mod b/go.mod index b5dc4a8..d721dc8 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/alicebob/miniredis v2.5.0+incompatible github.com/boltdb/bolt v1.3.1 // indirect github.com/bradfitz/gomemcache v0.0.0-20190913173617-a41fca850d0b - github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8 + github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8 // indirect github.com/go-ole/go-ole v1.2.4 // indirect github.com/go-redis/redis v6.15.5+incompatible github.com/gomodule/redigo v1.8.9 // indirect @@ -18,6 +18,7 @@ require ( github.com/stretchr/testify v1.7.0 github.com/yuin/gopher-lua v0.0.0-20190514113301-1cd887cd7036 // indirect github.com/zaffka/mongodb-boltdb-mock v0.0.0-20221014194232-b4bb03fbe3a0 + go.mongodb.org/mongo-driver v1.13.1 gopkg.in/yaml.v2 v2.2.2 // indirect ) diff --git a/go.sum b/go.sum index 93bf439..dd5610a 100644 --- a/go.sum +++ b/go.sum @@ -28,12 +28,20 @@ github.com/go-redis/redis v6.15.5+incompatible h1:pLky8I0rgiblWfa8C1EV7fPEUv0aH6 github.com/go-redis/redis v6.15.5+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA= github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4= +github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/gomodule/redigo v1.8.9 h1:Sl3u+2BI/kk+VEatbj0scLdrFhjPmbxOc1myhDP41ws= github.com/gomodule/redigo v1.8.9/go.mod h1:7ArFNvsTjH8GMMzB4uy1snslv2BwmginuMs06a1uzZE= +github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM= +github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc= +github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe h1:iruDEfMl2E6fbMZ9s0scYfZQ84/6SPL6zC8ACM2oIL0= +github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= github.com/onsi/ginkgo v1.6.0 h1:Ix8l273rp3QzYgXSR+c8d1fTG7UPgYkOSELPhiY/YGw= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/gomega v1.7.0 h1:XPnZz8VVBHjVsy1vzJmRwIcSwiUO+JFfrv/xGiigmME= @@ -49,20 +57,61 @@ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c= +github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= +github.com/xdg-go/scram v1.1.2 h1:FHX5I5B4i4hKRVRBCFRxq1iQRej7WO3hhBuJf+UUySY= +github.com/xdg-go/scram v1.1.2/go.mod h1:RT/sEzTbU5y00aCK8UOx6R7YryM0iF1N2MOmC3kKLN4= +github.com/xdg-go/stringprep v1.0.4 h1:XLI/Ng3O1Atzq0oBs3TWm+5ZVgkq2aqdlvP9JtoZ6c8= +github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gijq1dTyGkM= +github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d h1:splanxYIlg+5LfHAM6xpdFEAYOk8iySO56hMFq6uLyA= +github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yuin/gopher-lua v0.0.0-20190514113301-1cd887cd7036 h1:1b6PAtenNyhsmo/NKXVe34h7JEZKva1YB/ne7K7mqKM= github.com/yuin/gopher-lua v0.0.0-20190514113301-1cd887cd7036/go.mod h1:gqRgreBUhTSL0GeU64rtZ3Uq3wtjOa/TB2YfrtkCbVQ= github.com/zaffka/mongodb-boltdb-mock v0.0.0-20221014194232-b4bb03fbe3a0 h1:25CxwNe/bwECkbtsSKrh3XWF3lg59JTIjfwttIW6gyY= github.com/zaffka/mongodb-boltdb-mock v0.0.0-20221014194232-b4bb03fbe3a0/go.mod h1:GsDD1qsG+86MeeCG7ndi6Ei3iGthKL3wQ7PTFigDfNY= -golang.org/x/net v0.0.0-20180906233101-161cd47e91fd h1:nTDtHvHSdCn1m6ITfMRqtOd/9+7a3s8RBNOZ3eYZzJA= +go.mongodb.org/mongo-driver v1.13.1 h1:YIc7HTYsKndGK4RFzJ3covLz1byri52x0IoMB0Pt/vk= +go.mongodb.org/mongo-driver v1.13.1/go.mod h1:wcDf1JBCXy2mOW0bWHwO/IOYqdca1MPCwDtFu/Z9+eo= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d h1:sK3txAijHtOK88l68nt020reeT1ZdKLIYetKl95FzVY= +golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f h1:wMNYb4v58l5UBM7MYRLPG6ZhfOqbKu7X5eyFl8ZhKvA= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b h1:PxfKdU9lEEDYjdIzOtC4qFWgkU2rGHdKlKowJSMN9h0= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 h1:uVc8UZUe6tr40fFVnUP5Oj+veunVezqYl9z7DYw9xzw= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190204203706-41f3e6584952/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190422165155-953cdadca894 h1:Cz4ceDQGXuKRnVBDTS23GTn/pU5OE2C0WrNTOYK1Uuc= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= +golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/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= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= From 9c1543693e52142d96d5b2cf0e3fcbbde4c1c50a Mon Sep 17 00:00:00 2001 From: Max Claus Nunes Date: Thu, 7 Dec 2023 14:48:12 -0300 Subject: [PATCH 2/4] Add context to all Status funcs --- checkers/README.md | 15 ++++++---- checkers/disk/disk_usage.go | 10 +++++-- checkers/disk/disk_usage_test.go | 9 +++--- checkers/http.go | 3 +- checkers/http_test.go | 14 +++++---- checkers/memcache/memcached.go | 3 +- checkers/memcache/memcached_test.go | 23 +++++++------- checkers/reachable.go | 3 +- checkers/reachable_test.go | 14 +++++---- checkers/redis/redis.go | 3 +- checkers/redis/redis_test.go | 19 ++++++------ checkers/sql.go | 5 +--- checkers/sql_test.go | 12 ++++---- .../custom-checker-server.go | 4 ++- fakes/icheckable.go | 30 ++++++++++++++----- fakes/isqlexecer.go | 2 +- fakes/isqlpinger.go | 2 +- fakes/isqlqueryer.go | 2 +- go.mod | 1 + health.go | 7 +++-- 20 files changed, 108 insertions(+), 73 deletions(-) diff --git a/checkers/README.md b/checkers/README.md index ec8338c..230f8f1 100644 --- a/checkers/README.md +++ b/checkers/README.md @@ -5,7 +5,7 @@ types of dependencies. If a pre-built checker is not available, you can create your own checkers by implementing the `ICheckable` interface (which consists of a single method - -`Status() (interface{}, error)`). +`Status(context.Context) (interface{}, error)`). If you do create a custom-checker - consider opening a PR and adding it to the list of built-in checkers. @@ -44,17 +44,19 @@ The SQL DB checker has implementations for the following interfaces: - `SQLExecer`, which encloses `ExecContext` in [`sql.DB`](https://golang.org/pkg/database/sql/#DB.ExecContext), [`sql.Conn`](https://golang.org/pkg/database/sql/#Conn.ExecContext), [`sql.Stmt`](https://golang.org/pkg/database/sql/#Stmt.ExecContext), and [`sql.Tx`](https://golang.org/pkg/database/sql/#Tx.ExecContext) #### SQLConfig -The `SQLConfig` struct is required when using the SQL DB health check. It **must** contain an inplementation of one of either `SQLPinger`, `SQLQueryer`, or `SQLExecer`. + +The `SQLConfig` struct is required when using the SQL DB health check. It **must** contain an inplementation of one of either `SQLPinger`, `SQLQueryer`, or `SQLExecer`. If `SQLQueryer` or `SQLExecer` are implemented, then `Query` must be valid (len > 0). -Additionally, if `SQLQueryer` or `SQLExecer` are implemented, you have the option to also set either the `QueryerResultHandler` or `ExecerResultHandler` functions. These functions allow you to evaluate the result of a query or exec operation. If you choose not to implement these yourself, the default handlers are used. +Additionally, if `SQLQueryer` or `SQLExecer` are implemented, you have the option to also set either the `QueryerResultHandler` or `ExecerResultHandler` functions. These functions allow you to evaluate the result of a query or exec operation. If you choose not to implement these yourself, the default handlers are used. The default `ExecerResultHandler` is successful if the passed exec operation affected one and only one row. The default `QueryerResultHandler` is successful if the passed query operation returned one and only one row. #### SQLPinger + Use the `SQLPinger` interface if your health check is only concerned with your application's database connectivity. All you need to do is set the `Pinger` value in your `SQLConfig`. ```golang @@ -80,11 +82,13 @@ Use the `SQLPinger` interface if your health check is only concerned with your a ``` #### SQLQueryer -Use the `SQLQueryer` interface if your health check requires you to read rows from your database. You can optionally supply a query result handler function. If you don't supply one, the default function will be used. The function signature for the handler is: + +Use the `SQLQueryer` interface if your health check requires you to read rows from your database. You can optionally supply a query result handler function. If you don't supply one, the default function will be used. The function signature for the handler is: ```golang type SQLQueryerResultHandler func(rows *sql.Rows) (bool, error) ``` + The default query handler returns true if there was exactly one row in the resultset: ```golang @@ -146,7 +150,8 @@ Sample `SQLQueryer` implementation: ``` #### SQLExecer -Use the `SQLExecer` interface if your health check requires you to update or insert to your database. You can optionally supply an exec result handler function. If you don't supply one, the default function will be used. The function signature for the handler is: + +Use the `SQLExecer` interface if your health check requires you to update or insert to your database. You can optionally supply an exec result handler function. If you don't supply one, the default function will be used. The function signature for the handler is: ```golang type SQLExecerResultHandler func(result sql.Result) (bool, error) diff --git a/checkers/disk/disk_usage.go b/checkers/disk/disk_usage.go index 4e6afab..8412104 100644 --- a/checkers/disk/disk_usage.go +++ b/checkers/disk/disk_usage.go @@ -1,6 +1,7 @@ package diskchk import ( + "context" "fmt" "github.com/shirou/gopsutil/disk" @@ -10,9 +11,12 @@ import ( // // "Path" is _required_; path to check directory/drive (ex. /home/user) // "WarningThreshold" is _required_; set percent (more than 0 and less 100) of free space at specified path, -// which triggers warning. +// +// which triggers warning. +// // "CriticalThreshold" is _required_; set percent (more than 0 and less 100) of free space at specified path, -// which triggers critical. +// +// which triggers critical. type DiskUsageConfig struct { Path string WarningThreshold float64 @@ -40,7 +44,7 @@ func NewDiskUsage(cfg *DiskUsageConfig) (*DiskUsage, error) { // Status is used for performing a diskusage check against a dependency; it satisfies // the "ICheckable" interface. -func (d *DiskUsage) Status() (interface{}, error) { +func (d *DiskUsage) Status(ctx context.Context) (interface{}, error) { stats, err := disk.Usage(d.Config.Path) if err != nil { diff --git a/checkers/disk/disk_usage_test.go b/checkers/disk/disk_usage_test.go index e259a3c..e207378 100644 --- a/checkers/disk/disk_usage_test.go +++ b/checkers/disk/disk_usage_test.go @@ -1,6 +1,7 @@ package diskchk import ( + "context" "os" "testing" @@ -98,7 +99,7 @@ func TestDiskUsageStatus(t *testing.T) { t.Fatal(err) } - _, err = du.Status() + _, err = du.Status(context.TODO()) Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("Error getting disk usage")) }) @@ -115,7 +116,7 @@ func TestDiskUsageStatus(t *testing.T) { t.Fatal(err) } - _, err = du.Status() + _, err = du.Status(context.TODO()) Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("Critical: disk usage too high")) }) @@ -131,7 +132,7 @@ func TestDiskUsageStatus(t *testing.T) { if err != nil { t.Fatal(err) } - _, err = du.Status() + _, err = du.Status(context.TODO()) Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("Warning: disk usage too high")) }) @@ -147,7 +148,7 @@ func TestDiskUsageStatus(t *testing.T) { if err != nil { t.Fatal(err) } - _, err = du.Status() + _, err = du.Status(context.TODO()) Expect(err).To(BeNil()) }) } diff --git a/checkers/http.go b/checkers/http.go index 43298a9..61c939a 100644 --- a/checkers/http.go +++ b/checkers/http.go @@ -2,6 +2,7 @@ package checkers import ( "bytes" + "context" "encoding/json" "errors" "fmt" @@ -63,7 +64,7 @@ func NewHTTP(cfg *HTTPConfig) (*HTTP, error) { // Status is used for performing an HTTP check against a dependency; it satisfies // the "ICheckable" interface. -func (h *HTTP) Status() (interface{}, error) { +func (h *HTTP) Status(ctx context.Context) (interface{}, error) { resp, err := h.do() if err != nil { return nil, err diff --git a/checkers/http_test.go b/checkers/http_test.go index ff5b2a4..a132c6a 100644 --- a/checkers/http_test.go +++ b/checkers/http_test.go @@ -1,6 +1,7 @@ package checkers import ( + "context" "math" "net/http" "net/http/httptest" @@ -9,6 +10,7 @@ import ( "time" "fmt" + . "github.com/onsi/gomega" ) @@ -164,7 +166,7 @@ func TestHTTPStatus(t *testing.T) { checker, err := NewHTTP(cfg) Expect(err).ToNot(HaveOccurred()) - data, err := checker.Status() + data, err := checker.Status(context.TODO()) Expect(err).ToNot(HaveOccurred()) Expect(data).To(BeNil()) }) @@ -179,7 +181,7 @@ func TestHTTPStatus(t *testing.T) { checker, err := NewHTTP(cfg) Expect(err).ToNot(HaveOccurred()) - data, err := checker.Status() + data, err := checker.Status(context.TODO()) Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("unsupported protocol")) Expect(data).To(BeNil()) @@ -201,7 +203,7 @@ func TestHTTPStatus(t *testing.T) { checker, err := NewHTTP(cfg) Expect(err).ToNot(HaveOccurred()) - data, err := checker.Status() + data, err := checker.Status(context.TODO()) Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("does not match expected status code")) Expect(data).To(BeNil()) @@ -225,7 +227,7 @@ func TestHTTPStatus(t *testing.T) { checker, err := NewHTTP(cfg) Expect(err).ToNot(HaveOccurred()) - data, err := checker.Status() + data, err := checker.Status(context.TODO()) Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("does not contain expected content")) Expect(data).To(BeNil()) @@ -249,7 +251,7 @@ func TestHTTPStatus(t *testing.T) { checker, err := NewHTTP(cfg) Expect(err).ToNot(HaveOccurred()) - data, err := checker.Status() + data, err := checker.Status(context.TODO()) Expect(err).ToNot(HaveOccurred()) Expect(data).To(BeNil()) }) @@ -277,7 +279,7 @@ func TestHTTPStatus(t *testing.T) { checker, err := NewHTTP(cfg) Expect(err).ToNot(HaveOccurred()) - data, err := checker.Status() + data, err := checker.Status(context.TODO()) Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("Unable to read response body to perform content expectancy check")) diff --git a/checkers/memcache/memcached.go b/checkers/memcache/memcached.go index 7a2a1df..4d14e0a 100644 --- a/checkers/memcache/memcached.go +++ b/checkers/memcache/memcached.go @@ -2,6 +2,7 @@ package memcachechk import ( "bytes" + "context" "fmt" "net" "net/url" @@ -83,7 +84,7 @@ func NewMemcached(cfg *MemcachedConfig) (*Memcached, error) { }, nil } -func (mc *Memcached) Status() (interface{}, error) { +func (mc *Memcached) Status(ctx context.Context) (interface{}, error) { if mc.Config.Ping { if _, err := net.Dial("tcp", mc.Config.Url); err != nil { diff --git a/checkers/memcache/memcached_test.go b/checkers/memcache/memcached_test.go index f01464e..6df97a4 100644 --- a/checkers/memcache/memcached_test.go +++ b/checkers/memcache/memcached_test.go @@ -1,6 +1,7 @@ package memcachechk import ( + "context" "fmt" "math/rand" "strconv" @@ -140,10 +141,10 @@ func TestMemcachedStatus(t *testing.T) { if err != nil { t.Fatal(err) } - _, err = checker.Status() + _, err = checker.Status(context.TODO()) Expect(err).To(HaveOccurred()) - _, err = checker.Status() + _, err = checker.Status(context.TODO()) Expect(err.Error()).To(ContainSubstring("Ping failed")) }) @@ -162,7 +163,7 @@ func TestMemcachedStatus(t *testing.T) { // Mark server is stoppped server.Close() - _, err = checker.Status() + _, err = checker.Status(context.TODO()) Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("Unable to complete set")) }) @@ -180,7 +181,7 @@ func TestMemcachedStatus(t *testing.T) { } defer server.Close() - _, err = checker.Status() + _, err = checker.Status(context.TODO()) Expect(err).ToNot(HaveOccurred()) val, err := checker.wrapper.GetClient().Get(cfg.Set.Key) @@ -200,7 +201,7 @@ func TestMemcachedStatus(t *testing.T) { } defer server.Close() - _, err = checker.Status() + _, err = checker.Status(context.TODO()) Expect(err).ToNot(HaveOccurred()) val, err := checker.wrapper.GetClient().Get(cfg.Set.Key) @@ -221,7 +222,7 @@ func TestMemcachedStatus(t *testing.T) { } defer server.Close() - _, err = checker.Status() + _, err = checker.Status(context.TODO()) Expect(err).ToNot(HaveOccurred()) val, err := checker.wrapper.GetClient().Get(cfg.Set.Key) @@ -243,7 +244,7 @@ func TestMemcachedStatus(t *testing.T) { } defer server.Close() - _, err = checker.Status() + _, err = checker.Status(context.TODO()) Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring(fmt.Sprintf("Unable to complete get: '%v' not found", cfg.Get.Key))) @@ -262,7 +263,7 @@ func TestMemcachedStatus(t *testing.T) { } defer server.Close() - _, err = checker.Status() + _, err = checker.Status(context.TODO()) Expect(err).ToNot(HaveOccurred()) }) @@ -281,7 +282,7 @@ func TestMemcachedStatus(t *testing.T) { // Close the server so the GET fails server.Close() - _, err = checker.Status() + _, err = checker.Status(context.TODO()) Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("Unable to complete get")) }) @@ -304,7 +305,7 @@ func TestMemcachedStatus(t *testing.T) { } defer server.Close() - _, err = checker.Status() + _, err = checker.Status(context.TODO()) Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("does not match expected value")) }) @@ -325,7 +326,7 @@ func TestMemcachedStatus(t *testing.T) { } defer server.Close() - _, err = checker.Status() + _, err = checker.Status(context.TODO()) Expect(err).ToNot(HaveOccurred()) }) }) diff --git a/checkers/reachable.go b/checkers/reachable.go index 30113fa..e158016 100644 --- a/checkers/reachable.go +++ b/checkers/reachable.go @@ -1,6 +1,7 @@ package checkers import ( + "context" "net" "net/url" "time" @@ -87,7 +88,7 @@ func NewReachableChecker(cfg *ReachableConfig) (*ReachableChecker, error) { } // Status checks if the endpoint is reachable -func (r *ReachableChecker) Status() (interface{}, error) { +func (r *ReachableChecker) Status(ctx context.Context) (interface{}, error) { // We must provide a port so when a port is not set in the URL provided use // the default port (80) port := r.url.Port() diff --git a/checkers/reachable_test.go b/checkers/reachable_test.go index 6de64c3..0adbe93 100644 --- a/checkers/reachable_test.go +++ b/checkers/reachable_test.go @@ -1,16 +1,18 @@ package checkers_test import ( + "context" "errors" "net" "net/url" "testing" "time" + "github.com/stretchr/testify/assert" + "github.com/InVisionApp/go-health/v2/checkers" "github.com/InVisionApp/go-health/v2/fakes" "github.com/InVisionApp/go-health/v2/fakes/netfakes" - "github.com/stretchr/testify/assert" ) func TestReachableSuccessUsingDefaults(t *testing.T) { @@ -34,7 +36,7 @@ func TestReachableSuccessUsingDefaults(t *testing.T) { assert.NoError(err) assert.NotNil(c) - _, err = c.Status() + _, err = c.Status(context.TODO()) assert.NoError(err) assert.Equal(0, dd.IncrCallCount()) } @@ -64,7 +66,7 @@ func TestReachableSuccess(t *testing.T) { assert.NoError(err) assert.NotNil(c) - _, err = c.Status() + _, err = c.Status(context.TODO()) assert.NoError(err) assert.Equal(0, dd.IncrCallCount()) } @@ -82,7 +84,7 @@ func TestReachableError(t *testing.T) { assert.NoError(err) assert.NotNil(c) - _, err = c.Status() + _, err = c.Status(context.TODO()) assert.Error(err) } @@ -102,7 +104,7 @@ func TestReachableConnError(t *testing.T) { assert.NoError(err) assert.NotNil(c) - _, err = c.Status() + _, err = c.Status(context.TODO()) assert.EqualError(err, expectedErr.Error()) } @@ -125,7 +127,7 @@ func TestReachableErrorWithDatadog(t *testing.T) { assert.NoError(err) assert.NotNil(c) - _, err = c.Status() + _, err = c.Status(context.TODO()) assert.Error(err) assert.Equal(1, dd.IncrCallCount()) name, tags, num := dd.IncrArgsForCall(0) diff --git a/checkers/redis/redis.go b/checkers/redis/redis.go index ac8dfbe..6b08ea3 100644 --- a/checkers/redis/redis.go +++ b/checkers/redis/redis.go @@ -1,6 +1,7 @@ package redischk import ( + "context" "crypto/tls" "fmt" "time" @@ -108,7 +109,7 @@ func NewRedis(cfg *RedisConfig) (*Redis, error) { // Status is used for performing a redis check against a dependency; it satisfies // the "ICheckable" interface. -func (r *Redis) Status() (interface{}, error) { +func (r *Redis) Status(ctx context.Context) (interface{}, error) { if r.Config.Ping { if _, err := r.client.Ping().Result(); err != nil { return nil, fmt.Errorf("Ping failed: %v", err) diff --git a/checkers/redis/redis_test.go b/checkers/redis/redis_test.go index 8e16e53..7010e3d 100644 --- a/checkers/redis/redis_test.go +++ b/checkers/redis/redis_test.go @@ -1,6 +1,7 @@ package redischk import ( + "context" "fmt" "testing" @@ -150,7 +151,7 @@ func TestRedisStatus(t *testing.T) { Expect(err).ToNot(HaveOccurred()) - _, err = checker.Status() + _, err = checker.Status(context.TODO()) Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("Ping failed")) }) @@ -170,7 +171,7 @@ func TestRedisStatus(t *testing.T) { // Stop the server, so ping check fails server.Close() - _, err = checker.Status() + _, err = checker.Status(context.TODO()) Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("Unable to complete set")) }) @@ -188,7 +189,7 @@ func TestRedisStatus(t *testing.T) { } defer server.Close() - _, err = checker.Status() + _, err = checker.Status(context.TODO()) Expect(err).ToNot(HaveOccurred()) val, err := server.Get(cfg.Set.Key) @@ -208,7 +209,7 @@ func TestRedisStatus(t *testing.T) { } defer server.Close() - _, err = checker.Status() + _, err = checker.Status(context.TODO()) Expect(err).ToNot(HaveOccurred()) val, err := server.Get(cfg.Set.Key) @@ -230,7 +231,7 @@ func TestRedisStatus(t *testing.T) { } defer server.Close() - _, err = checker.Status() + _, err = checker.Status(context.TODO()) Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring(fmt.Sprintf("Unable to complete get: '%v' not found", cfg.Get.Key))) }) @@ -248,7 +249,7 @@ func TestRedisStatus(t *testing.T) { } defer server.Close() - _, err = checker.Status() + _, err = checker.Status(context.TODO()) Expect(err).ToNot(HaveOccurred()) }) @@ -267,7 +268,7 @@ func TestRedisStatus(t *testing.T) { // Close the server so the GET fails server.Close() - _, err = checker.Status() + _, err = checker.Status(context.TODO()) Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("Unable to complete get")) }) @@ -290,7 +291,7 @@ func TestRedisStatus(t *testing.T) { } defer server.Close() - _, err = checker.Status() + _, err = checker.Status(context.TODO()) Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("does not match expected value")) }) @@ -311,7 +312,7 @@ func TestRedisStatus(t *testing.T) { } defer server.Close() - _, err = checker.Status() + _, err = checker.Status(context.TODO()) Expect(err).ToNot(HaveOccurred()) }) }) diff --git a/checkers/sql.go b/checkers/sql.go index 9b31b3d..51cad4e 100644 --- a/checkers/sql.go +++ b/checkers/sql.go @@ -36,7 +36,6 @@ type SQLExecerResultHandler func(result sql.Result) (bool, error) // SQLConfig is used for configuring a database check. // One of the Pinger, Queryer, or Execer fields is required. // -// // If Execer is set, it will take precedence over Queryer and Pinger, // Execer implements the SQLExecer interface in this package. // The sql.DB and sql.TX structs both implement this interface. @@ -44,7 +43,6 @@ type SQLExecerResultHandler func(result sql.Result) (bool, error) // Note that if the Execer is set, then the ExecerResultHandler // and Query values MUST also be set // -// // If Queryer is set, it will take precedence over Pinger. // SQLQueryer implements the SQLQueryer interface in this package. // The sql.DB and sql.TX structs both implement this interface. @@ -52,7 +50,6 @@ type SQLExecerResultHandler func(result sql.Result) (bool, error) // Note that if the Queryer is set, then the QueryerResultHandler // and Query values MUST also be set // -// // Pinger implements the SQLPinger interface in this package. // The sql.DB struct implements this interface. type SQLConfig struct { @@ -140,7 +137,7 @@ func validateSQLConfig(cfg *SQLConfig) error { // Status is used for performing a database ping against a dependency; it satisfies // the "ICheckable" interface. -func (s *SQL) Status() (interface{}, error) { +func (s *SQL) Status(ctx context.Context) (interface{}, error) { if err := validateSQLConfig(s.Config); err != nil { return nil, err } diff --git a/checkers/sql_test.go b/checkers/sql_test.go index 22de776..11b6f59 100644 --- a/checkers/sql_test.go +++ b/checkers/sql_test.go @@ -157,7 +157,7 @@ func TestSQLStatus(t *testing.T) { Expect(err).To(BeNil()) Expect(s).ToNot(BeNil()) - nothing, err := s.Status() + nothing, err := s.Status(context.TODO()) Expect(err).ToNot(HaveOccurred()) // status check returns no artifacts @@ -172,7 +172,7 @@ func TestSQLStatus(t *testing.T) { Expect(err).To(BeNil()) Expect(s).ToNot(BeNil()) - _, err = s.Status() + _, err = s.Status(context.TODO()) Expect(err).ToNot(HaveOccurred()) }) @@ -184,13 +184,13 @@ func TestSQLStatus(t *testing.T) { Expect(err).To(BeNil()) Expect(s).ToNot(BeNil()) - _, err = s.Status() + _, err = s.Status(context.TODO()) Expect(err).To(HaveOccurred()) }) t.Run("bad config", func(t *testing.T) { s := &SQL{} - _, err := s.Status() + _, err := s.Status(context.TODO()) Expect(err).To(HaveOccurred()) }) } @@ -210,7 +210,7 @@ func TestDefaultExecHandler(t *testing.T) { }) Expect(err).To(BeNil()) - _, err = s.Status() + _, err = s.Status(context.TODO()) Expect(err).To(BeNil()) }) @@ -301,7 +301,7 @@ func TestDefaultQueryHandler(t *testing.T) { }) Expect(err).To(BeNil()) - _, err = s.Status() + _, err = s.Status(context.TODO()) Expect(err).To(BeNil()) }) diff --git a/examples/custom-checker-server/custom-checker-server.go b/examples/custom-checker-server/custom-checker-server.go index 93641dc..53ddb70 100644 --- a/examples/custom-checker-server/custom-checker-server.go +++ b/examples/custom-checker-server/custom-checker-server.go @@ -6,6 +6,8 @@ import ( "net/http" "time" + "golang.org/x/net/context" + "github.com/InVisionApp/go-health/v2" "github.com/InVisionApp/go-health/v2/handlers" ) @@ -42,7 +44,7 @@ func main() { } // Satisfy the go-health.ICheckable interface -func (c *customCheck) Status() (interface{}, error) { +func (c *customCheck) Status(ctx context.Context) (interface{}, error) { // perform some sort of check if false { return nil, fmt.Errorf("Something major just broke") diff --git a/fakes/icheckable.go b/fakes/icheckable.go index 49e848e..6dddd07 100644 --- a/fakes/icheckable.go +++ b/fakes/icheckable.go @@ -1,16 +1,20 @@ // Code generated by counterfeiter. DO NOT EDIT. -// (with minor, manual edits) package fakes import ( + "context" "sync" + + "github.com/InVisionApp/go-health" ) type FakeICheckable struct { - StatusStub func() (interface{}, error) + StatusStub func(ctx context.Context) (interface{}, error) statusMutex sync.RWMutex - statusArgsForCall []struct{} - statusReturns struct { + statusArgsForCall []struct { + ctx context.Context + } + statusReturns struct { result1 interface{} result2 error } @@ -22,14 +26,16 @@ type FakeICheckable struct { invocationsMutex sync.RWMutex } -func (fake *FakeICheckable) Status() (interface{}, error) { +func (fake *FakeICheckable) Status(ctx context.Context) (interface{}, error) { fake.statusMutex.Lock() ret, specificReturn := fake.statusReturnsOnCall[len(fake.statusArgsForCall)] - fake.statusArgsForCall = append(fake.statusArgsForCall, struct{}{}) - fake.recordInvocation("Status", []interface{}{}) + fake.statusArgsForCall = append(fake.statusArgsForCall, struct { + ctx context.Context + }{ctx}) + fake.recordInvocation("Status", []interface{}{ctx}) fake.statusMutex.Unlock() if fake.StatusStub != nil { - return fake.StatusStub() + return fake.StatusStub(ctx) } if specificReturn { return ret.result1, ret.result2 @@ -43,6 +49,12 @@ func (fake *FakeICheckable) StatusCallCount() int { return len(fake.statusArgsForCall) } +func (fake *FakeICheckable) StatusArgsForCall(i int) context.Context { + fake.statusMutex.RLock() + defer fake.statusMutex.RUnlock() + return fake.statusArgsForCall[i].ctx +} + func (fake *FakeICheckable) StatusReturns(result1 interface{}, result2 error) { fake.StatusStub = nil fake.statusReturns = struct { @@ -88,3 +100,5 @@ func (fake *FakeICheckable) recordInvocation(key string, args []interface{}) { } fake.invocations[key] = append(fake.invocations[key], args) } + +var _ health.ICheckable = new(FakeICheckable) diff --git a/fakes/isqlexecer.go b/fakes/isqlexecer.go index 1a1cecf..f912fe8 100644 --- a/fakes/isqlexecer.go +++ b/fakes/isqlexecer.go @@ -6,7 +6,7 @@ import ( "database/sql" "sync" - "github.com/InVisionApp/go-health/v2/checkers" + "github.com/InVisionApp/go-health/checkers" ) type FakeSQLExecer struct { diff --git a/fakes/isqlpinger.go b/fakes/isqlpinger.go index e4aab8a..b4858b4 100644 --- a/fakes/isqlpinger.go +++ b/fakes/isqlpinger.go @@ -5,7 +5,7 @@ import ( "context" "sync" - "github.com/InVisionApp/go-health/v2/checkers" + "github.com/InVisionApp/go-health/checkers" ) type FakeSQLPinger struct { diff --git a/fakes/isqlqueryer.go b/fakes/isqlqueryer.go index 9106dde..34980be 100644 --- a/fakes/isqlqueryer.go +++ b/fakes/isqlqueryer.go @@ -6,7 +6,7 @@ import ( "database/sql" "sync" - "github.com/InVisionApp/go-health/v2/checkers" + "github.com/InVisionApp/go-health/checkers" ) type FakeSQLQueryer struct { diff --git a/go.mod b/go.mod index d721dc8..32dae65 100644 --- a/go.mod +++ b/go.mod @@ -19,6 +19,7 @@ require ( github.com/yuin/gopher-lua v0.0.0-20190514113301-1cd887cd7036 // indirect github.com/zaffka/mongodb-boltdb-mock v0.0.0-20221014194232-b4bb03fbe3a0 go.mongodb.org/mongo-driver v1.13.1 + golang.org/x/net v0.0.0-20220722155237-a158d28d115b gopkg.in/yaml.v2 v2.2.2 // indirect ) diff --git a/health.go b/health.go index f542236..695ccd4 100644 --- a/health.go +++ b/health.go @@ -6,11 +6,12 @@ package health import ( + "context" "errors" "sync" "time" - "github.com/InVisionApp/go-logger" + log "github.com/InVisionApp/go-logger" ) //go:generate counterfeiter -o ./fakes/icheckable.go . ICheckable @@ -48,7 +49,7 @@ type ICheckable interface { // Status allows you to return additional data as an "interface{}" and "error" // to signify that the check has failed. If "interface{}" is non-nil, it will // be exposed under "State.Details" for that particular check. - Status() (interface{}, error) + Status(ctx context.Context) (interface{}, error) } // IStatusListener is an interface that handles health check failures and @@ -249,7 +250,7 @@ func (h *Health) startRunner(cfg *Config, ticker *time.Ticker, stop <-chan struc // function to execute and collect check data checkFunc := func() { - data, err := cfg.Checker.Status() + data, err := cfg.Checker.Status(context.TODO()) stateEntry := &State{ Name: cfg.Name, From bfe30a796c3bfe81026c54045528a7a0e440ee6e Mon Sep 17 00:00:00 2001 From: Max Claus Nunes Date: Thu, 7 Dec 2023 15:04:11 -0300 Subject: [PATCH 3/4] Fix fakes --- fakes/icheckable.go | 4 ---- fakes/ireachabledatadogincrementer.go | 4 ---- fakes/isqlexecer.go | 4 ---- fakes/isqlpinger.go | 4 ---- fakes/isqlqueryer.go | 4 ---- 5 files changed, 20 deletions(-) diff --git a/fakes/icheckable.go b/fakes/icheckable.go index 6dddd07..626d5bc 100644 --- a/fakes/icheckable.go +++ b/fakes/icheckable.go @@ -4,8 +4,6 @@ package fakes import ( "context" "sync" - - "github.com/InVisionApp/go-health" ) type FakeICheckable struct { @@ -100,5 +98,3 @@ func (fake *FakeICheckable) recordInvocation(key string, args []interface{}) { } fake.invocations[key] = append(fake.invocations[key], args) } - -var _ health.ICheckable = new(FakeICheckable) diff --git a/fakes/ireachabledatadogincrementer.go b/fakes/ireachabledatadogincrementer.go index 4e27066..7108076 100644 --- a/fakes/ireachabledatadogincrementer.go +++ b/fakes/ireachabledatadogincrementer.go @@ -3,8 +3,6 @@ package fakes import ( "sync" - - "github.com/InVisionApp/go-health/v2/checkers" ) type FakeReachableDatadogIncrementer struct { @@ -103,5 +101,3 @@ func (fake *FakeReachableDatadogIncrementer) recordInvocation(key string, args [ } fake.invocations[key] = append(fake.invocations[key], args) } - -var _ checkers.ReachableDatadogIncrementer = new(FakeReachableDatadogIncrementer) diff --git a/fakes/isqlexecer.go b/fakes/isqlexecer.go index f912fe8..638bb66 100644 --- a/fakes/isqlexecer.go +++ b/fakes/isqlexecer.go @@ -5,8 +5,6 @@ import ( "context" "database/sql" "sync" - - "github.com/InVisionApp/go-health/checkers" ) type FakeSQLExecer struct { @@ -105,5 +103,3 @@ func (fake *FakeSQLExecer) recordInvocation(key string, args []interface{}) { } fake.invocations[key] = append(fake.invocations[key], args) } - -var _ checkers.SQLExecer = new(FakeSQLExecer) diff --git a/fakes/isqlpinger.go b/fakes/isqlpinger.go index b4858b4..8bb646f 100644 --- a/fakes/isqlpinger.go +++ b/fakes/isqlpinger.go @@ -4,8 +4,6 @@ package fakes import ( "context" "sync" - - "github.com/InVisionApp/go-health/checkers" ) type FakeSQLPinger struct { @@ -95,5 +93,3 @@ func (fake *FakeSQLPinger) recordInvocation(key string, args []interface{}) { } fake.invocations[key] = append(fake.invocations[key], args) } - -var _ checkers.SQLPinger = new(FakeSQLPinger) diff --git a/fakes/isqlqueryer.go b/fakes/isqlqueryer.go index 34980be..c79a9f9 100644 --- a/fakes/isqlqueryer.go +++ b/fakes/isqlqueryer.go @@ -5,8 +5,6 @@ import ( "context" "database/sql" "sync" - - "github.com/InVisionApp/go-health/checkers" ) type FakeSQLQueryer struct { @@ -105,5 +103,3 @@ func (fake *FakeSQLQueryer) recordInvocation(key string, args []interface{}) { } fake.invocations[key] = append(fake.invocations[key], args) } - -var _ checkers.SQLQueryer = new(FakeSQLQueryer) From f627eaf8775f2f39eced527c95dbefc6ff630937 Mon Sep 17 00:00:00 2001 From: Max Claus Nunes Date: Tue, 12 Dec 2023 14:55:52 -0300 Subject: [PATCH 4/4] Upgrade gosputil --- checkers/disk/disk_usage.go | 2 +- go.mod | 6 ++---- go.sum | 42 +++++++++++++++++++++++++++---------- 3 files changed, 34 insertions(+), 16 deletions(-) diff --git a/checkers/disk/disk_usage.go b/checkers/disk/disk_usage.go index 8412104..0e8b1a5 100644 --- a/checkers/disk/disk_usage.go +++ b/checkers/disk/disk_usage.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/shirou/gopsutil/disk" + "github.com/shirou/gopsutil/v3/disk" ) // DiskUsageConfig is used for configuring the go-diskusage check. diff --git a/go.mod b/go.mod index 32dae65..80f98b0 100644 --- a/go.mod +++ b/go.mod @@ -3,19 +3,17 @@ module github.com/InVisionApp/go-health/v2 require ( github.com/DATA-DOG/go-sqlmock v1.3.3 github.com/InVisionApp/go-logger v1.0.1 - github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d // indirect github.com/alicebob/gopher-json v0.0.0-20180125190556-5a6b3ba71ee6 // indirect github.com/alicebob/miniredis v2.5.0+incompatible github.com/boltdb/bolt v1.3.1 // indirect github.com/bradfitz/gomemcache v0.0.0-20190913173617-a41fca850d0b github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8 // indirect - github.com/go-ole/go-ole v1.2.4 // indirect github.com/go-redis/redis v6.15.5+incompatible github.com/gomodule/redigo v1.8.9 // indirect github.com/onsi/gomega v1.7.0 - github.com/shirou/gopsutil v2.18.12+incompatible + github.com/shirou/gopsutil/v3 v3.23.11 github.com/sirupsen/logrus v1.4.2 // indirect - github.com/stretchr/testify v1.7.0 + github.com/stretchr/testify v1.8.4 github.com/yuin/gopher-lua v0.0.0-20190514113301-1cd887cd7036 // indirect github.com/zaffka/mongodb-boltdb-mock v0.0.0-20221014194232-b4bb03fbe3a0 go.mongodb.org/mongo-driver v1.13.1 diff --git a/go.sum b/go.sum index dd5610a..bf1332b 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,6 @@ github.com/DATA-DOG/go-sqlmock v1.3.3 h1:CWUqKXe0s8A2z6qCgkP4Kru7wC11YoAnoupUKFD github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/InVisionApp/go-logger v1.0.1 h1:WFL19PViM1mHUmUWfsv5zMo379KSWj2MRmBlzMFDRiE= github.com/InVisionApp/go-logger v1.0.1/go.mod h1:+cGTDSn+P8105aZkeOfIhdd7vFO5X1afUHcjvanY0L8= -github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d h1:G0m3OIz70MZUWq3EgK3CesDbo8upS2Vm9/P3FtgI+Jk= -github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= github.com/alicebob/gopher-json v0.0.0-20180125190556-5a6b3ba71ee6 h1:45bxf7AZMwWcqkLzDAQugVEwedisr5nRJ1r+7LYnv0U= github.com/alicebob/gopher-json v0.0.0-20180125190556-5a6b3ba71ee6/go.mod h1:SGnFV6hVsYE877CKEZ6tDNTjaSXYUk6QqoIK6PrAtcc= github.com/alicebob/miniredis v2.5.0+incompatible h1:yBHoLpsyjupjz3NL3MhKMVkR41j82Yjf3KFv7ApYzUI= @@ -22,8 +20,8 @@ github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8 h1:DujepqpGd1hyOd7aW59XpK7Qymp8iy83xq74fLr21is= github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= -github.com/go-ole/go-ole v1.2.4 h1:nNBDSCOigTSiarFpYE9J/KtEA1IOW4CNeqT9TQDqCxI= -github.com/go-ole/go-ole v1.2.4/go.mod h1:XCwSNxSkXRo4vlyPy93sltvi/qJq0jqQhjqQNIwKuxM= +github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= +github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= github.com/go-redis/redis v6.15.5+incompatible h1:pLky8I0rgiblWfa8C1EV7fPEUv0aH6vKRaYHc/YRHVk= github.com/go-redis/redis v6.15.5+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA= github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= @@ -32,14 +30,18 @@ github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/gomodule/redigo v1.8.9 h1:Sl3u+2BI/kk+VEatbj0scLdrFhjPmbxOc1myhDP41ws= github.com/gomodule/redigo v1.8.9/go.mod h1:7ArFNvsTjH8GMMzB4uy1snslv2BwmginuMs06a1uzZE= -github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc= github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I= github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe h1:iruDEfMl2E6fbMZ9s0scYfZQ84/6SPL6zC8ACM2oIL0= github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= github.com/onsi/ginkgo v1.6.0 h1:Ix8l273rp3QzYgXSR+c8d1fTG7UPgYkOSELPhiY/YGw= @@ -48,15 +50,26 @@ github.com/onsi/gomega v1.7.0 h1:XPnZz8VVBHjVsy1vzJmRwIcSwiUO+JFfrv/xGiigmME= github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= 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/shirou/gopsutil v2.18.12+incompatible h1:1eaJvGomDnH74/5cF4CTmTbLHAriGFsTZppLXDX93OM= -github.com/shirou/gopsutil v2.18.12+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= +github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF4JjgDlrVEn3C11VoGHZN7m8qihwgMEtzYw= +github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE= +github.com/shirou/gopsutil/v3 v3.23.11 h1:i3jP9NjCPUz7FiZKxlMnODZkdSIp2gnzfrvsu9CuWEQ= +github.com/shirou/gopsutil/v3 v3.23.11/go.mod h1:1FrWgea594Jp7qmjHUUPlJDTPgcsb9mGnXDxavtikzM= +github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ= +github.com/shoenig/test v0.6.4/go.mod h1:byHiCGXqrVaflBLAMq/srcZIHynQPQgeyvkvXnjqq0k= github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= +github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY= github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c= github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= github.com/xdg-go/scram v1.1.2 h1:FHX5I5B4i4hKRVRBCFRxq1iQRej7WO3hhBuJf+UUySY= @@ -68,6 +81,8 @@ github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7Jul github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yuin/gopher-lua v0.0.0-20190514113301-1cd887cd7036 h1:1b6PAtenNyhsmo/NKXVe34h7JEZKva1YB/ne7K7mqKM= github.com/yuin/gopher-lua v0.0.0-20190514113301-1cd887cd7036/go.mod h1:gqRgreBUhTSL0GeU64rtZ3Uq3wtjOa/TB2YfrtkCbVQ= +github.com/yusufpapurcu/wmi v1.2.3 h1:E1ctvB7uKFMOJw3fdOW32DwGE9I7t++CRUEMKvFoFiw= +github.com/yusufpapurcu/wmi v1.2.3/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= github.com/zaffka/mongodb-boltdb-mock v0.0.0-20221014194232-b4bb03fbe3a0 h1:25CxwNe/bwECkbtsSKrh3XWF3lg59JTIjfwttIW6gyY= github.com/zaffka/mongodb-boltdb-mock v0.0.0-20221014194232-b4bb03fbe3a0/go.mod h1:GsDD1qsG+86MeeCG7ndi6Ei3iGthKL3wQ7PTFigDfNY= go.mongodb.org/mongo-driver v1.13.1 h1:YIc7HTYsKndGK4RFzJ3covLz1byri52x0IoMB0Pt/vk= @@ -91,12 +106,17 @@ golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190204203706-41f3e6584952/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= +golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -110,7 +130,6 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/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= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -121,5 +140,6 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWD gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/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.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=