diff --git a/Makefile b/Makefile index d01d357..3b21d67 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,3 @@ vet: test: fmtcheck vet go test -v ./... -coverprofile=coverage.txt -covermode atomic - -mocks: - go install github.com/maxbrunsfeld/counterfeiter/v6@v6.4.1 - COUNTERFEITER_NO_GENERATE_WARNING="true" go generate mocks/generate.go diff --git a/config/config.go b/config/config.go index 26a8fbc..817f343 100644 --- a/config/config.go +++ b/config/config.go @@ -16,12 +16,14 @@ package config import ( "flag" + "github.com/peterbourgon/ff/v3" + "github.com/rode/rode/common" ) type Config struct { - Port int - Debug bool - RodeConfig *RodeConfig + Port int + Debug bool + ClientConfig *common.ClientConfig } type RodeConfig struct { @@ -33,16 +35,13 @@ func Build(name string, args []string) (*Config, error) { flags := flag.NewFlagSet(name, flag.ContinueOnError) c := &Config{ - RodeConfig: &RodeConfig{}, + ClientConfig: common.SetupRodeClientFlags(flags), } flags.IntVar(&c.Port, "port", 8080, "the port that the sonarqube collector should listen on") flags.BoolVar(&c.Debug, "debug", false, "when set, debug mode will be enabled") - flags.StringVar(&c.RodeConfig.Host, "rode-host", "rode:50051", "the host to use to connect to rode") - flags.BoolVar(&c.RodeConfig.Insecure, "rode-insecure", false, "when set, the connection to rode will not use TLS") - - err := flags.Parse(args) + err := ff.Parse(flags, args, ff.WithEnvVarNoPrefix()) if err != nil { return nil, err } diff --git a/config/config_test.go b/config/config_test.go index 7b3f9a2..65363e2 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -16,6 +16,7 @@ package config import ( . "github.com/onsi/gomega" + "github.com/rode/rode/common" "testing" ) @@ -34,8 +35,12 @@ func TestConfig(t *testing.T) { expected: &Config{ Port: 8080, Debug: false, - RodeConfig: &RodeConfig{ - Host: "rode:50051", + ClientConfig: &common.ClientConfig{ + Rode: &common.RodeClientConfig{ + Host: "rode:50051", + }, + OIDCAuth: &common.OIDCAuthConfig{}, + BasicAuth: &common.BasicAuthConfig{}, }, }, }, @@ -55,8 +60,12 @@ func TestConfig(t *testing.T) { expected: &Config{ Port: 8080, Debug: false, - RodeConfig: &RodeConfig{ - Host: "bar", + ClientConfig: &common.ClientConfig{ + Rode: &common.RodeClientConfig{ + Host: "bar", + }, + OIDCAuth: &common.OIDCAuthConfig{}, + BasicAuth: &common.BasicAuthConfig{}, }, }, }, diff --git a/go.mod b/go.mod index 6b26860..34cd311 100644 --- a/go.mod +++ b/go.mod @@ -6,8 +6,8 @@ require ( github.com/brianvoe/gofakeit/v6 v6.4.1 github.com/onsi/ginkgo v1.16.2 github.com/onsi/gomega v1.12.0 - github.com/rode/rode v0.9.0 + github.com/peterbourgon/ff/v3 v3.1.0 + github.com/rode/rode v0.14.2 go.uber.org/zap v1.16.0 - google.golang.org/grpc v1.37.0 google.golang.org/protobuf v1.26.0 ) diff --git a/go.sum b/go.sum index 0c5de21..8f4d4e2 100644 --- a/go.sum +++ b/go.sum @@ -36,6 +36,7 @@ github.com/Bowery/prompt v0.0.0-20190916142128-fa8279994f75/go.mod h1:4/6eNcqZ09 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/Jeffail/gabs/v2 v2.6.1/go.mod h1:xCn81vdHKxFUuWWAaD5jCTQDNPBMh5pPs9IJ+NcziBI= 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.8/go.mod h1:eZbhyaAYD41SGSSsnmcpxVoRiQ/MPUTjUdIIOT9Um7Q= @@ -121,6 +122,7 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.m github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/evanphx/json-patch v0.5.2/go.mod h1:ZWS5hhDbVDyob71nXKNL0+PWn6ToqBHMikGIFbs31qQ= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= +github.com/fatih/set v0.2.1/go.mod h1:+RKtMCH+favT2+3YecHGxcc0b4KyVWA1QWWJUs4E0CI= github.com/fernet/fernet-go v0.0.0-20180830025343-9eac43b88a5e/go.mod h1:2H9hjfbpSMHwY503FclkV/lZTBh2YlOmLLSda12uL8c= 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= @@ -146,7 +148,7 @@ github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFG github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -224,6 +226,7 @@ github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/ad github.com/grafeas/grafeas v0.1.6/go.mod h1:TpiALoRgUv7C21r+Xa/xTLJW7I2QnEW201+6jPTmssM= github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= +github.com/grpc-ecosystem/go-grpc-middleware v1.2.2 h1:FlFbCRLd5Jr4iYXZufAvgWN6Ao0JrI5chLINnUXDDr0= github.com/grpc-ecosystem/go-grpc-middleware v1.2.2/go.mod h1:EaizFBKfUKtMIF5iaDEhniwNedqGo9FuLFzppDr3uwI= 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= @@ -262,6 +265,7 @@ github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmK github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= 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/jarcoal/httpmock v1.0.6 h1:e81vOSexXU3mJuJ4l//geOmKIt+Vkxerk1feQBC8D0g= github.com/jarcoal/httpmock v1.0.6/go.mod h1:ATjnClrvW/3tijVmpL/va5Z3aAyGvqU3gCT8nX0Txik= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= @@ -278,7 +282,6 @@ github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7V github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= github.com/kardianos/govendor v1.0.9/go.mod h1:yvmR6q9ZZ7nSF5Wvh40v0wfP+3TwwL8zYQp+itoZSVM= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= @@ -355,8 +358,11 @@ github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIw github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= +github.com/pelletier/go-toml v1.6.0/go.mod h1:5N711Q9dKgbdkxHL+MEfF31hpT7l0S0s/t2kKREewys= github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE= github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= +github.com/peterbourgon/ff/v3 v3.1.0 h1:5JAeDK5j/zhKFjyHEZQXwXBoDijERaos10RE+xamOsY= +github.com/peterbourgon/ff/v3 v3.1.0/go.mod h1:XNJLY8EIl6MjMVjBS4F0+G0LYoAqs0DTa4rmHHukKDE= github.com/peterh/liner v0.0.0-20170211195444-bf27d3ba8e1d/go.mod h1:xIteQHvHuaLYG9IFj6mSxM0fCKrs34IrEQUhOYuGPHc= 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= @@ -400,9 +406,10 @@ github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqn github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rode/es-index-manager v0.1.1/go.mod h1:QsnfBo0VUWWfOkXUHUdiWSiJghajbVwHjCA+OMqO0E8= -github.com/rode/grafeas-elasticsearch v0.8.1/go.mod h1:bu4sKOyP7/a/PZdywh5I16P+b8j+8GuaIUIECun6a60= -github.com/rode/rode v0.9.0 h1:79q8w/ZcJUvFz7xRTKw1DC7bUKn+2qxdpvYpgelIMb0= -github.com/rode/rode v0.9.0/go.mod h1:tfAOcHguxXuphATwaQs92WvpmCKKm8P1NtbnmZwwT7M= +github.com/rode/es-index-manager v0.1.2/go.mod h1:QsnfBo0VUWWfOkXUHUdiWSiJghajbVwHjCA+OMqO0E8= +github.com/rode/grafeas-elasticsearch v0.8.7/go.mod h1:bu4sKOyP7/a/PZdywh5I16P+b8j+8GuaIUIECun6a60= +github.com/rode/rode v0.14.2 h1:uyiDjkfetnfySXHTPZz8FJAnqPpucE9uKgrDrl+02AI= +github.com/rode/rode v0.14.2/go.mod h1:csOzhk3X9B80J0q6vkMn1H+8GH9LrHyptd2+k1B4OFM= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= @@ -411,6 +418,7 @@ github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= +github.com/scylladb/go-set v1.0.2/go.mod h1:DkpGd78rljTxKAnTDPFqXSGxvETQnJyuSOQwsHycqfs= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= @@ -574,6 +582,7 @@ golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4Iltr golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20210201163806-010130855d6c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210402161424-2e8d93401602 h1:0Ja1LBD+yisY6RWM/BH7TJVXWsSjs2VwBSmvSX4HdBc= golang.org/x/oauth2 v0.0.0-20210402161424-2e8d93401602/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -690,12 +699,10 @@ golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roY golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0 h1:po9/4sTYwZU9lPhi1tOrb4hCv3qrhiQ77LZfGa2OjwY= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -727,6 +734,7 @@ google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7 google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= diff --git a/listener/listener_test.go b/listener/listener_test.go index 372e60c..aaa55b5 100644 --- a/listener/listener_test.go +++ b/listener/listener_test.go @@ -20,9 +20,9 @@ import ( "fmt" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "github.com/rode/collector-sonarqube/mocks" "github.com/rode/collector-sonarqube/sonar" pb "github.com/rode/rode/proto/v1alpha1" + "github.com/rode/rode/proto/v1alpha1fakes" "github.com/rode/rode/protodeps/grafeas/proto/v1beta1/common_go_proto" "github.com/rode/rode/protodeps/grafeas/proto/v1beta1/discovery_go_proto" "github.com/rode/rode/protodeps/grafeas/proto/v1beta1/grafeas_go_proto" @@ -35,12 +35,12 @@ import ( var _ = Describe("listener", func() { var ( - rodeClient *mocks.FakeRodeClient + rodeClient *v1alpha1fakes.FakeRodeClient listener Listener ) BeforeEach(func() { - rodeClient = &mocks.FakeRodeClient{} + rodeClient = &v1alpha1fakes.FakeRodeClient{} }) JustBeforeEach(func() { diff --git a/main.go b/main.go index 299201b..91b9ebc 100644 --- a/main.go +++ b/main.go @@ -16,23 +16,17 @@ package main import ( "context" - "crypto/tls" "errors" "fmt" "github.com/rode/collector-sonarqube/config" - "google.golang.org/grpc/credentials" + "github.com/rode/collector-sonarqube/listener" + "github.com/rode/rode/common" + "go.uber.org/zap" "log" "net/http" "os" "os/signal" "syscall" - "time" - - pb "github.com/rode/rode/proto/v1alpha1" - "go.uber.org/zap" - "google.golang.org/grpc" - - "github.com/rode/collector-sonarqube/listener" ) func main() { @@ -46,24 +40,10 @@ func main() { log.Fatalf("failed to create logger: %v", err) } - dialOptions := []grpc.DialOption{ - grpc.WithBlock(), - } - if conf.RodeConfig.Insecure { - dialOptions = append(dialOptions, grpc.WithInsecure()) - } else { - dialOptions = append(dialOptions, grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{}))) - } - - ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) - defer cancel() - conn, err := grpc.DialContext(ctx, conf.RodeConfig.Host, dialOptions...) + rodeClient, err := common.NewRodeClient(conf.ClientConfig) if err != nil { - logger.Fatal("failed to establish grpc connection to Rode", zap.Error(err)) + logger.Fatal("could not create rode client", zap.Error(err)) } - defer conn.Close() - - rodeClient := pb.NewRodeClient(conn) l := listener.NewListener(logger.Named("listener"), rodeClient) diff --git a/mocks/generate.go b/mocks/generate.go deleted file mode 100644 index 638a090..0000000 --- a/mocks/generate.go +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2021 The Rode Authors -// -// 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 mocks - -//go:generate counterfeiter -o rode_client.go github.com/rode/rode/proto/v1alpha1.RodeClient diff --git a/mocks/rode_client.go b/mocks/rode_client.go deleted file mode 100644 index 158f69a..0000000 --- a/mocks/rode_client.go +++ /dev/null @@ -1,1369 +0,0 @@ -// Code generated by counterfeiter. DO NOT EDIT. -package mocks - -import ( - "context" - "sync" - - "github.com/rode/rode/proto/v1alpha1" - "github.com/rode/rode/protodeps/grafeas/proto/v1beta1/grafeas_go_proto" - "google.golang.org/grpc" - "google.golang.org/protobuf/types/known/emptypb" -) - -type FakeRodeClient struct { - BatchCreateOccurrencesStub func(context.Context, *v1alpha1.BatchCreateOccurrencesRequest, ...grpc.CallOption) (*v1alpha1.BatchCreateOccurrencesResponse, error) - batchCreateOccurrencesMutex sync.RWMutex - batchCreateOccurrencesArgsForCall []struct { - arg1 context.Context - arg2 *v1alpha1.BatchCreateOccurrencesRequest - arg3 []grpc.CallOption - } - batchCreateOccurrencesReturns struct { - result1 *v1alpha1.BatchCreateOccurrencesResponse - result2 error - } - batchCreateOccurrencesReturnsOnCall map[int]struct { - result1 *v1alpha1.BatchCreateOccurrencesResponse - result2 error - } - CreateNoteStub func(context.Context, *v1alpha1.CreateNoteRequest, ...grpc.CallOption) (*grafeas_go_proto.Note, error) - createNoteMutex sync.RWMutex - createNoteArgsForCall []struct { - arg1 context.Context - arg2 *v1alpha1.CreateNoteRequest - arg3 []grpc.CallOption - } - createNoteReturns struct { - result1 *grafeas_go_proto.Note - result2 error - } - createNoteReturnsOnCall map[int]struct { - result1 *grafeas_go_proto.Note - result2 error - } - CreatePolicyStub func(context.Context, *v1alpha1.PolicyEntity, ...grpc.CallOption) (*v1alpha1.Policy, error) - createPolicyMutex sync.RWMutex - createPolicyArgsForCall []struct { - arg1 context.Context - arg2 *v1alpha1.PolicyEntity - arg3 []grpc.CallOption - } - createPolicyReturns struct { - result1 *v1alpha1.Policy - result2 error - } - createPolicyReturnsOnCall map[int]struct { - result1 *v1alpha1.Policy - result2 error - } - DeletePolicyStub func(context.Context, *v1alpha1.DeletePolicyRequest, ...grpc.CallOption) (*emptypb.Empty, error) - deletePolicyMutex sync.RWMutex - deletePolicyArgsForCall []struct { - arg1 context.Context - arg2 *v1alpha1.DeletePolicyRequest - arg3 []grpc.CallOption - } - deletePolicyReturns struct { - result1 *emptypb.Empty - result2 error - } - deletePolicyReturnsOnCall map[int]struct { - result1 *emptypb.Empty - result2 error - } - EvaluatePolicyStub func(context.Context, *v1alpha1.EvaluatePolicyRequest, ...grpc.CallOption) (*v1alpha1.EvaluatePolicyResponse, error) - evaluatePolicyMutex sync.RWMutex - evaluatePolicyArgsForCall []struct { - arg1 context.Context - arg2 *v1alpha1.EvaluatePolicyRequest - arg3 []grpc.CallOption - } - evaluatePolicyReturns struct { - result1 *v1alpha1.EvaluatePolicyResponse - result2 error - } - evaluatePolicyReturnsOnCall map[int]struct { - result1 *v1alpha1.EvaluatePolicyResponse - result2 error - } - GetPolicyStub func(context.Context, *v1alpha1.GetPolicyRequest, ...grpc.CallOption) (*v1alpha1.Policy, error) - getPolicyMutex sync.RWMutex - getPolicyArgsForCall []struct { - arg1 context.Context - arg2 *v1alpha1.GetPolicyRequest - arg3 []grpc.CallOption - } - getPolicyReturns struct { - result1 *v1alpha1.Policy - result2 error - } - getPolicyReturnsOnCall map[int]struct { - result1 *v1alpha1.Policy - result2 error - } - ListGenericResourceVersionsStub func(context.Context, *v1alpha1.ListGenericResourceVersionsRequest, ...grpc.CallOption) (*v1alpha1.ListGenericResourceVersionsResponse, error) - listGenericResourceVersionsMutex sync.RWMutex - listGenericResourceVersionsArgsForCall []struct { - arg1 context.Context - arg2 *v1alpha1.ListGenericResourceVersionsRequest - arg3 []grpc.CallOption - } - listGenericResourceVersionsReturns struct { - result1 *v1alpha1.ListGenericResourceVersionsResponse - result2 error - } - listGenericResourceVersionsReturnsOnCall map[int]struct { - result1 *v1alpha1.ListGenericResourceVersionsResponse - result2 error - } - ListGenericResourcesStub func(context.Context, *v1alpha1.ListGenericResourcesRequest, ...grpc.CallOption) (*v1alpha1.ListGenericResourcesResponse, error) - listGenericResourcesMutex sync.RWMutex - listGenericResourcesArgsForCall []struct { - arg1 context.Context - arg2 *v1alpha1.ListGenericResourcesRequest - arg3 []grpc.CallOption - } - listGenericResourcesReturns struct { - result1 *v1alpha1.ListGenericResourcesResponse - result2 error - } - listGenericResourcesReturnsOnCall map[int]struct { - result1 *v1alpha1.ListGenericResourcesResponse - result2 error - } - ListOccurrencesStub func(context.Context, *v1alpha1.ListOccurrencesRequest, ...grpc.CallOption) (*v1alpha1.ListOccurrencesResponse, error) - listOccurrencesMutex sync.RWMutex - listOccurrencesArgsForCall []struct { - arg1 context.Context - arg2 *v1alpha1.ListOccurrencesRequest - arg3 []grpc.CallOption - } - listOccurrencesReturns struct { - result1 *v1alpha1.ListOccurrencesResponse - result2 error - } - listOccurrencesReturnsOnCall map[int]struct { - result1 *v1alpha1.ListOccurrencesResponse - result2 error - } - ListPoliciesStub func(context.Context, *v1alpha1.ListPoliciesRequest, ...grpc.CallOption) (*v1alpha1.ListPoliciesResponse, error) - listPoliciesMutex sync.RWMutex - listPoliciesArgsForCall []struct { - arg1 context.Context - arg2 *v1alpha1.ListPoliciesRequest - arg3 []grpc.CallOption - } - listPoliciesReturns struct { - result1 *v1alpha1.ListPoliciesResponse - result2 error - } - listPoliciesReturnsOnCall map[int]struct { - result1 *v1alpha1.ListPoliciesResponse - result2 error - } - ListResourcesStub func(context.Context, *v1alpha1.ListResourcesRequest, ...grpc.CallOption) (*v1alpha1.ListResourcesResponse, error) - listResourcesMutex sync.RWMutex - listResourcesArgsForCall []struct { - arg1 context.Context - arg2 *v1alpha1.ListResourcesRequest - arg3 []grpc.CallOption - } - listResourcesReturns struct { - result1 *v1alpha1.ListResourcesResponse - result2 error - } - listResourcesReturnsOnCall map[int]struct { - result1 *v1alpha1.ListResourcesResponse - result2 error - } - ListVersionedResourceOccurrencesStub func(context.Context, *v1alpha1.ListVersionedResourceOccurrencesRequest, ...grpc.CallOption) (*v1alpha1.ListVersionedResourceOccurrencesResponse, error) - listVersionedResourceOccurrencesMutex sync.RWMutex - listVersionedResourceOccurrencesArgsForCall []struct { - arg1 context.Context - arg2 *v1alpha1.ListVersionedResourceOccurrencesRequest - arg3 []grpc.CallOption - } - listVersionedResourceOccurrencesReturns struct { - result1 *v1alpha1.ListVersionedResourceOccurrencesResponse - result2 error - } - listVersionedResourceOccurrencesReturnsOnCall map[int]struct { - result1 *v1alpha1.ListVersionedResourceOccurrencesResponse - result2 error - } - RegisterCollectorStub func(context.Context, *v1alpha1.RegisterCollectorRequest, ...grpc.CallOption) (*v1alpha1.RegisterCollectorResponse, error) - registerCollectorMutex sync.RWMutex - registerCollectorArgsForCall []struct { - arg1 context.Context - arg2 *v1alpha1.RegisterCollectorRequest - arg3 []grpc.CallOption - } - registerCollectorReturns struct { - result1 *v1alpha1.RegisterCollectorResponse - result2 error - } - registerCollectorReturnsOnCall map[int]struct { - result1 *v1alpha1.RegisterCollectorResponse - result2 error - } - UpdateOccurrenceStub func(context.Context, *v1alpha1.UpdateOccurrenceRequest, ...grpc.CallOption) (*grafeas_go_proto.Occurrence, error) - updateOccurrenceMutex sync.RWMutex - updateOccurrenceArgsForCall []struct { - arg1 context.Context - arg2 *v1alpha1.UpdateOccurrenceRequest - arg3 []grpc.CallOption - } - updateOccurrenceReturns struct { - result1 *grafeas_go_proto.Occurrence - result2 error - } - updateOccurrenceReturnsOnCall map[int]struct { - result1 *grafeas_go_proto.Occurrence - result2 error - } - UpdatePolicyStub func(context.Context, *v1alpha1.UpdatePolicyRequest, ...grpc.CallOption) (*v1alpha1.Policy, error) - updatePolicyMutex sync.RWMutex - updatePolicyArgsForCall []struct { - arg1 context.Context - arg2 *v1alpha1.UpdatePolicyRequest - arg3 []grpc.CallOption - } - updatePolicyReturns struct { - result1 *v1alpha1.Policy - result2 error - } - updatePolicyReturnsOnCall map[int]struct { - result1 *v1alpha1.Policy - result2 error - } - ValidatePolicyStub func(context.Context, *v1alpha1.ValidatePolicyRequest, ...grpc.CallOption) (*v1alpha1.ValidatePolicyResponse, error) - validatePolicyMutex sync.RWMutex - validatePolicyArgsForCall []struct { - arg1 context.Context - arg2 *v1alpha1.ValidatePolicyRequest - arg3 []grpc.CallOption - } - validatePolicyReturns struct { - result1 *v1alpha1.ValidatePolicyResponse - result2 error - } - validatePolicyReturnsOnCall map[int]struct { - result1 *v1alpha1.ValidatePolicyResponse - result2 error - } - invocations map[string][][]interface{} - invocationsMutex sync.RWMutex -} - -func (fake *FakeRodeClient) BatchCreateOccurrences(arg1 context.Context, arg2 *v1alpha1.BatchCreateOccurrencesRequest, arg3 ...grpc.CallOption) (*v1alpha1.BatchCreateOccurrencesResponse, error) { - fake.batchCreateOccurrencesMutex.Lock() - ret, specificReturn := fake.batchCreateOccurrencesReturnsOnCall[len(fake.batchCreateOccurrencesArgsForCall)] - fake.batchCreateOccurrencesArgsForCall = append(fake.batchCreateOccurrencesArgsForCall, struct { - arg1 context.Context - arg2 *v1alpha1.BatchCreateOccurrencesRequest - arg3 []grpc.CallOption - }{arg1, arg2, arg3}) - stub := fake.BatchCreateOccurrencesStub - fakeReturns := fake.batchCreateOccurrencesReturns - fake.recordInvocation("BatchCreateOccurrences", []interface{}{arg1, arg2, arg3}) - fake.batchCreateOccurrencesMutex.Unlock() - if stub != nil { - return stub(arg1, arg2, arg3...) - } - if specificReturn { - return ret.result1, ret.result2 - } - return fakeReturns.result1, fakeReturns.result2 -} - -func (fake *FakeRodeClient) BatchCreateOccurrencesCallCount() int { - fake.batchCreateOccurrencesMutex.RLock() - defer fake.batchCreateOccurrencesMutex.RUnlock() - return len(fake.batchCreateOccurrencesArgsForCall) -} - -func (fake *FakeRodeClient) BatchCreateOccurrencesCalls(stub func(context.Context, *v1alpha1.BatchCreateOccurrencesRequest, ...grpc.CallOption) (*v1alpha1.BatchCreateOccurrencesResponse, error)) { - fake.batchCreateOccurrencesMutex.Lock() - defer fake.batchCreateOccurrencesMutex.Unlock() - fake.BatchCreateOccurrencesStub = stub -} - -func (fake *FakeRodeClient) BatchCreateOccurrencesArgsForCall(i int) (context.Context, *v1alpha1.BatchCreateOccurrencesRequest, []grpc.CallOption) { - fake.batchCreateOccurrencesMutex.RLock() - defer fake.batchCreateOccurrencesMutex.RUnlock() - argsForCall := fake.batchCreateOccurrencesArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 -} - -func (fake *FakeRodeClient) BatchCreateOccurrencesReturns(result1 *v1alpha1.BatchCreateOccurrencesResponse, result2 error) { - fake.batchCreateOccurrencesMutex.Lock() - defer fake.batchCreateOccurrencesMutex.Unlock() - fake.BatchCreateOccurrencesStub = nil - fake.batchCreateOccurrencesReturns = struct { - result1 *v1alpha1.BatchCreateOccurrencesResponse - result2 error - }{result1, result2} -} - -func (fake *FakeRodeClient) BatchCreateOccurrencesReturnsOnCall(i int, result1 *v1alpha1.BatchCreateOccurrencesResponse, result2 error) { - fake.batchCreateOccurrencesMutex.Lock() - defer fake.batchCreateOccurrencesMutex.Unlock() - fake.BatchCreateOccurrencesStub = nil - if fake.batchCreateOccurrencesReturnsOnCall == nil { - fake.batchCreateOccurrencesReturnsOnCall = make(map[int]struct { - result1 *v1alpha1.BatchCreateOccurrencesResponse - result2 error - }) - } - fake.batchCreateOccurrencesReturnsOnCall[i] = struct { - result1 *v1alpha1.BatchCreateOccurrencesResponse - result2 error - }{result1, result2} -} - -func (fake *FakeRodeClient) CreateNote(arg1 context.Context, arg2 *v1alpha1.CreateNoteRequest, arg3 ...grpc.CallOption) (*grafeas_go_proto.Note, error) { - fake.createNoteMutex.Lock() - ret, specificReturn := fake.createNoteReturnsOnCall[len(fake.createNoteArgsForCall)] - fake.createNoteArgsForCall = append(fake.createNoteArgsForCall, struct { - arg1 context.Context - arg2 *v1alpha1.CreateNoteRequest - arg3 []grpc.CallOption - }{arg1, arg2, arg3}) - stub := fake.CreateNoteStub - fakeReturns := fake.createNoteReturns - fake.recordInvocation("CreateNote", []interface{}{arg1, arg2, arg3}) - fake.createNoteMutex.Unlock() - if stub != nil { - return stub(arg1, arg2, arg3...) - } - if specificReturn { - return ret.result1, ret.result2 - } - return fakeReturns.result1, fakeReturns.result2 -} - -func (fake *FakeRodeClient) CreateNoteCallCount() int { - fake.createNoteMutex.RLock() - defer fake.createNoteMutex.RUnlock() - return len(fake.createNoteArgsForCall) -} - -func (fake *FakeRodeClient) CreateNoteCalls(stub func(context.Context, *v1alpha1.CreateNoteRequest, ...grpc.CallOption) (*grafeas_go_proto.Note, error)) { - fake.createNoteMutex.Lock() - defer fake.createNoteMutex.Unlock() - fake.CreateNoteStub = stub -} - -func (fake *FakeRodeClient) CreateNoteArgsForCall(i int) (context.Context, *v1alpha1.CreateNoteRequest, []grpc.CallOption) { - fake.createNoteMutex.RLock() - defer fake.createNoteMutex.RUnlock() - argsForCall := fake.createNoteArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 -} - -func (fake *FakeRodeClient) CreateNoteReturns(result1 *grafeas_go_proto.Note, result2 error) { - fake.createNoteMutex.Lock() - defer fake.createNoteMutex.Unlock() - fake.CreateNoteStub = nil - fake.createNoteReturns = struct { - result1 *grafeas_go_proto.Note - result2 error - }{result1, result2} -} - -func (fake *FakeRodeClient) CreateNoteReturnsOnCall(i int, result1 *grafeas_go_proto.Note, result2 error) { - fake.createNoteMutex.Lock() - defer fake.createNoteMutex.Unlock() - fake.CreateNoteStub = nil - if fake.createNoteReturnsOnCall == nil { - fake.createNoteReturnsOnCall = make(map[int]struct { - result1 *grafeas_go_proto.Note - result2 error - }) - } - fake.createNoteReturnsOnCall[i] = struct { - result1 *grafeas_go_proto.Note - result2 error - }{result1, result2} -} - -func (fake *FakeRodeClient) CreatePolicy(arg1 context.Context, arg2 *v1alpha1.PolicyEntity, arg3 ...grpc.CallOption) (*v1alpha1.Policy, error) { - fake.createPolicyMutex.Lock() - ret, specificReturn := fake.createPolicyReturnsOnCall[len(fake.createPolicyArgsForCall)] - fake.createPolicyArgsForCall = append(fake.createPolicyArgsForCall, struct { - arg1 context.Context - arg2 *v1alpha1.PolicyEntity - arg3 []grpc.CallOption - }{arg1, arg2, arg3}) - stub := fake.CreatePolicyStub - fakeReturns := fake.createPolicyReturns - fake.recordInvocation("CreatePolicy", []interface{}{arg1, arg2, arg3}) - fake.createPolicyMutex.Unlock() - if stub != nil { - return stub(arg1, arg2, arg3...) - } - if specificReturn { - return ret.result1, ret.result2 - } - return fakeReturns.result1, fakeReturns.result2 -} - -func (fake *FakeRodeClient) CreatePolicyCallCount() int { - fake.createPolicyMutex.RLock() - defer fake.createPolicyMutex.RUnlock() - return len(fake.createPolicyArgsForCall) -} - -func (fake *FakeRodeClient) CreatePolicyCalls(stub func(context.Context, *v1alpha1.PolicyEntity, ...grpc.CallOption) (*v1alpha1.Policy, error)) { - fake.createPolicyMutex.Lock() - defer fake.createPolicyMutex.Unlock() - fake.CreatePolicyStub = stub -} - -func (fake *FakeRodeClient) CreatePolicyArgsForCall(i int) (context.Context, *v1alpha1.PolicyEntity, []grpc.CallOption) { - fake.createPolicyMutex.RLock() - defer fake.createPolicyMutex.RUnlock() - argsForCall := fake.createPolicyArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 -} - -func (fake *FakeRodeClient) CreatePolicyReturns(result1 *v1alpha1.Policy, result2 error) { - fake.createPolicyMutex.Lock() - defer fake.createPolicyMutex.Unlock() - fake.CreatePolicyStub = nil - fake.createPolicyReturns = struct { - result1 *v1alpha1.Policy - result2 error - }{result1, result2} -} - -func (fake *FakeRodeClient) CreatePolicyReturnsOnCall(i int, result1 *v1alpha1.Policy, result2 error) { - fake.createPolicyMutex.Lock() - defer fake.createPolicyMutex.Unlock() - fake.CreatePolicyStub = nil - if fake.createPolicyReturnsOnCall == nil { - fake.createPolicyReturnsOnCall = make(map[int]struct { - result1 *v1alpha1.Policy - result2 error - }) - } - fake.createPolicyReturnsOnCall[i] = struct { - result1 *v1alpha1.Policy - result2 error - }{result1, result2} -} - -func (fake *FakeRodeClient) DeletePolicy(arg1 context.Context, arg2 *v1alpha1.DeletePolicyRequest, arg3 ...grpc.CallOption) (*emptypb.Empty, error) { - fake.deletePolicyMutex.Lock() - ret, specificReturn := fake.deletePolicyReturnsOnCall[len(fake.deletePolicyArgsForCall)] - fake.deletePolicyArgsForCall = append(fake.deletePolicyArgsForCall, struct { - arg1 context.Context - arg2 *v1alpha1.DeletePolicyRequest - arg3 []grpc.CallOption - }{arg1, arg2, arg3}) - stub := fake.DeletePolicyStub - fakeReturns := fake.deletePolicyReturns - fake.recordInvocation("DeletePolicy", []interface{}{arg1, arg2, arg3}) - fake.deletePolicyMutex.Unlock() - if stub != nil { - return stub(arg1, arg2, arg3...) - } - if specificReturn { - return ret.result1, ret.result2 - } - return fakeReturns.result1, fakeReturns.result2 -} - -func (fake *FakeRodeClient) DeletePolicyCallCount() int { - fake.deletePolicyMutex.RLock() - defer fake.deletePolicyMutex.RUnlock() - return len(fake.deletePolicyArgsForCall) -} - -func (fake *FakeRodeClient) DeletePolicyCalls(stub func(context.Context, *v1alpha1.DeletePolicyRequest, ...grpc.CallOption) (*emptypb.Empty, error)) { - fake.deletePolicyMutex.Lock() - defer fake.deletePolicyMutex.Unlock() - fake.DeletePolicyStub = stub -} - -func (fake *FakeRodeClient) DeletePolicyArgsForCall(i int) (context.Context, *v1alpha1.DeletePolicyRequest, []grpc.CallOption) { - fake.deletePolicyMutex.RLock() - defer fake.deletePolicyMutex.RUnlock() - argsForCall := fake.deletePolicyArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 -} - -func (fake *FakeRodeClient) DeletePolicyReturns(result1 *emptypb.Empty, result2 error) { - fake.deletePolicyMutex.Lock() - defer fake.deletePolicyMutex.Unlock() - fake.DeletePolicyStub = nil - fake.deletePolicyReturns = struct { - result1 *emptypb.Empty - result2 error - }{result1, result2} -} - -func (fake *FakeRodeClient) DeletePolicyReturnsOnCall(i int, result1 *emptypb.Empty, result2 error) { - fake.deletePolicyMutex.Lock() - defer fake.deletePolicyMutex.Unlock() - fake.DeletePolicyStub = nil - if fake.deletePolicyReturnsOnCall == nil { - fake.deletePolicyReturnsOnCall = make(map[int]struct { - result1 *emptypb.Empty - result2 error - }) - } - fake.deletePolicyReturnsOnCall[i] = struct { - result1 *emptypb.Empty - result2 error - }{result1, result2} -} - -func (fake *FakeRodeClient) EvaluatePolicy(arg1 context.Context, arg2 *v1alpha1.EvaluatePolicyRequest, arg3 ...grpc.CallOption) (*v1alpha1.EvaluatePolicyResponse, error) { - fake.evaluatePolicyMutex.Lock() - ret, specificReturn := fake.evaluatePolicyReturnsOnCall[len(fake.evaluatePolicyArgsForCall)] - fake.evaluatePolicyArgsForCall = append(fake.evaluatePolicyArgsForCall, struct { - arg1 context.Context - arg2 *v1alpha1.EvaluatePolicyRequest - arg3 []grpc.CallOption - }{arg1, arg2, arg3}) - stub := fake.EvaluatePolicyStub - fakeReturns := fake.evaluatePolicyReturns - fake.recordInvocation("EvaluatePolicy", []interface{}{arg1, arg2, arg3}) - fake.evaluatePolicyMutex.Unlock() - if stub != nil { - return stub(arg1, arg2, arg3...) - } - if specificReturn { - return ret.result1, ret.result2 - } - return fakeReturns.result1, fakeReturns.result2 -} - -func (fake *FakeRodeClient) EvaluatePolicyCallCount() int { - fake.evaluatePolicyMutex.RLock() - defer fake.evaluatePolicyMutex.RUnlock() - return len(fake.evaluatePolicyArgsForCall) -} - -func (fake *FakeRodeClient) EvaluatePolicyCalls(stub func(context.Context, *v1alpha1.EvaluatePolicyRequest, ...grpc.CallOption) (*v1alpha1.EvaluatePolicyResponse, error)) { - fake.evaluatePolicyMutex.Lock() - defer fake.evaluatePolicyMutex.Unlock() - fake.EvaluatePolicyStub = stub -} - -func (fake *FakeRodeClient) EvaluatePolicyArgsForCall(i int) (context.Context, *v1alpha1.EvaluatePolicyRequest, []grpc.CallOption) { - fake.evaluatePolicyMutex.RLock() - defer fake.evaluatePolicyMutex.RUnlock() - argsForCall := fake.evaluatePolicyArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 -} - -func (fake *FakeRodeClient) EvaluatePolicyReturns(result1 *v1alpha1.EvaluatePolicyResponse, result2 error) { - fake.evaluatePolicyMutex.Lock() - defer fake.evaluatePolicyMutex.Unlock() - fake.EvaluatePolicyStub = nil - fake.evaluatePolicyReturns = struct { - result1 *v1alpha1.EvaluatePolicyResponse - result2 error - }{result1, result2} -} - -func (fake *FakeRodeClient) EvaluatePolicyReturnsOnCall(i int, result1 *v1alpha1.EvaluatePolicyResponse, result2 error) { - fake.evaluatePolicyMutex.Lock() - defer fake.evaluatePolicyMutex.Unlock() - fake.EvaluatePolicyStub = nil - if fake.evaluatePolicyReturnsOnCall == nil { - fake.evaluatePolicyReturnsOnCall = make(map[int]struct { - result1 *v1alpha1.EvaluatePolicyResponse - result2 error - }) - } - fake.evaluatePolicyReturnsOnCall[i] = struct { - result1 *v1alpha1.EvaluatePolicyResponse - result2 error - }{result1, result2} -} - -func (fake *FakeRodeClient) GetPolicy(arg1 context.Context, arg2 *v1alpha1.GetPolicyRequest, arg3 ...grpc.CallOption) (*v1alpha1.Policy, error) { - fake.getPolicyMutex.Lock() - ret, specificReturn := fake.getPolicyReturnsOnCall[len(fake.getPolicyArgsForCall)] - fake.getPolicyArgsForCall = append(fake.getPolicyArgsForCall, struct { - arg1 context.Context - arg2 *v1alpha1.GetPolicyRequest - arg3 []grpc.CallOption - }{arg1, arg2, arg3}) - stub := fake.GetPolicyStub - fakeReturns := fake.getPolicyReturns - fake.recordInvocation("GetPolicy", []interface{}{arg1, arg2, arg3}) - fake.getPolicyMutex.Unlock() - if stub != nil { - return stub(arg1, arg2, arg3...) - } - if specificReturn { - return ret.result1, ret.result2 - } - return fakeReturns.result1, fakeReturns.result2 -} - -func (fake *FakeRodeClient) GetPolicyCallCount() int { - fake.getPolicyMutex.RLock() - defer fake.getPolicyMutex.RUnlock() - return len(fake.getPolicyArgsForCall) -} - -func (fake *FakeRodeClient) GetPolicyCalls(stub func(context.Context, *v1alpha1.GetPolicyRequest, ...grpc.CallOption) (*v1alpha1.Policy, error)) { - fake.getPolicyMutex.Lock() - defer fake.getPolicyMutex.Unlock() - fake.GetPolicyStub = stub -} - -func (fake *FakeRodeClient) GetPolicyArgsForCall(i int) (context.Context, *v1alpha1.GetPolicyRequest, []grpc.CallOption) { - fake.getPolicyMutex.RLock() - defer fake.getPolicyMutex.RUnlock() - argsForCall := fake.getPolicyArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 -} - -func (fake *FakeRodeClient) GetPolicyReturns(result1 *v1alpha1.Policy, result2 error) { - fake.getPolicyMutex.Lock() - defer fake.getPolicyMutex.Unlock() - fake.GetPolicyStub = nil - fake.getPolicyReturns = struct { - result1 *v1alpha1.Policy - result2 error - }{result1, result2} -} - -func (fake *FakeRodeClient) GetPolicyReturnsOnCall(i int, result1 *v1alpha1.Policy, result2 error) { - fake.getPolicyMutex.Lock() - defer fake.getPolicyMutex.Unlock() - fake.GetPolicyStub = nil - if fake.getPolicyReturnsOnCall == nil { - fake.getPolicyReturnsOnCall = make(map[int]struct { - result1 *v1alpha1.Policy - result2 error - }) - } - fake.getPolicyReturnsOnCall[i] = struct { - result1 *v1alpha1.Policy - result2 error - }{result1, result2} -} - -func (fake *FakeRodeClient) ListGenericResourceVersions(arg1 context.Context, arg2 *v1alpha1.ListGenericResourceVersionsRequest, arg3 ...grpc.CallOption) (*v1alpha1.ListGenericResourceVersionsResponse, error) { - fake.listGenericResourceVersionsMutex.Lock() - ret, specificReturn := fake.listGenericResourceVersionsReturnsOnCall[len(fake.listGenericResourceVersionsArgsForCall)] - fake.listGenericResourceVersionsArgsForCall = append(fake.listGenericResourceVersionsArgsForCall, struct { - arg1 context.Context - arg2 *v1alpha1.ListGenericResourceVersionsRequest - arg3 []grpc.CallOption - }{arg1, arg2, arg3}) - stub := fake.ListGenericResourceVersionsStub - fakeReturns := fake.listGenericResourceVersionsReturns - fake.recordInvocation("ListGenericResourceVersions", []interface{}{arg1, arg2, arg3}) - fake.listGenericResourceVersionsMutex.Unlock() - if stub != nil { - return stub(arg1, arg2, arg3...) - } - if specificReturn { - return ret.result1, ret.result2 - } - return fakeReturns.result1, fakeReturns.result2 -} - -func (fake *FakeRodeClient) ListGenericResourceVersionsCallCount() int { - fake.listGenericResourceVersionsMutex.RLock() - defer fake.listGenericResourceVersionsMutex.RUnlock() - return len(fake.listGenericResourceVersionsArgsForCall) -} - -func (fake *FakeRodeClient) ListGenericResourceVersionsCalls(stub func(context.Context, *v1alpha1.ListGenericResourceVersionsRequest, ...grpc.CallOption) (*v1alpha1.ListGenericResourceVersionsResponse, error)) { - fake.listGenericResourceVersionsMutex.Lock() - defer fake.listGenericResourceVersionsMutex.Unlock() - fake.ListGenericResourceVersionsStub = stub -} - -func (fake *FakeRodeClient) ListGenericResourceVersionsArgsForCall(i int) (context.Context, *v1alpha1.ListGenericResourceVersionsRequest, []grpc.CallOption) { - fake.listGenericResourceVersionsMutex.RLock() - defer fake.listGenericResourceVersionsMutex.RUnlock() - argsForCall := fake.listGenericResourceVersionsArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 -} - -func (fake *FakeRodeClient) ListGenericResourceVersionsReturns(result1 *v1alpha1.ListGenericResourceVersionsResponse, result2 error) { - fake.listGenericResourceVersionsMutex.Lock() - defer fake.listGenericResourceVersionsMutex.Unlock() - fake.ListGenericResourceVersionsStub = nil - fake.listGenericResourceVersionsReturns = struct { - result1 *v1alpha1.ListGenericResourceVersionsResponse - result2 error - }{result1, result2} -} - -func (fake *FakeRodeClient) ListGenericResourceVersionsReturnsOnCall(i int, result1 *v1alpha1.ListGenericResourceVersionsResponse, result2 error) { - fake.listGenericResourceVersionsMutex.Lock() - defer fake.listGenericResourceVersionsMutex.Unlock() - fake.ListGenericResourceVersionsStub = nil - if fake.listGenericResourceVersionsReturnsOnCall == nil { - fake.listGenericResourceVersionsReturnsOnCall = make(map[int]struct { - result1 *v1alpha1.ListGenericResourceVersionsResponse - result2 error - }) - } - fake.listGenericResourceVersionsReturnsOnCall[i] = struct { - result1 *v1alpha1.ListGenericResourceVersionsResponse - result2 error - }{result1, result2} -} - -func (fake *FakeRodeClient) ListGenericResources(arg1 context.Context, arg2 *v1alpha1.ListGenericResourcesRequest, arg3 ...grpc.CallOption) (*v1alpha1.ListGenericResourcesResponse, error) { - fake.listGenericResourcesMutex.Lock() - ret, specificReturn := fake.listGenericResourcesReturnsOnCall[len(fake.listGenericResourcesArgsForCall)] - fake.listGenericResourcesArgsForCall = append(fake.listGenericResourcesArgsForCall, struct { - arg1 context.Context - arg2 *v1alpha1.ListGenericResourcesRequest - arg3 []grpc.CallOption - }{arg1, arg2, arg3}) - stub := fake.ListGenericResourcesStub - fakeReturns := fake.listGenericResourcesReturns - fake.recordInvocation("ListGenericResources", []interface{}{arg1, arg2, arg3}) - fake.listGenericResourcesMutex.Unlock() - if stub != nil { - return stub(arg1, arg2, arg3...) - } - if specificReturn { - return ret.result1, ret.result2 - } - return fakeReturns.result1, fakeReturns.result2 -} - -func (fake *FakeRodeClient) ListGenericResourcesCallCount() int { - fake.listGenericResourcesMutex.RLock() - defer fake.listGenericResourcesMutex.RUnlock() - return len(fake.listGenericResourcesArgsForCall) -} - -func (fake *FakeRodeClient) ListGenericResourcesCalls(stub func(context.Context, *v1alpha1.ListGenericResourcesRequest, ...grpc.CallOption) (*v1alpha1.ListGenericResourcesResponse, error)) { - fake.listGenericResourcesMutex.Lock() - defer fake.listGenericResourcesMutex.Unlock() - fake.ListGenericResourcesStub = stub -} - -func (fake *FakeRodeClient) ListGenericResourcesArgsForCall(i int) (context.Context, *v1alpha1.ListGenericResourcesRequest, []grpc.CallOption) { - fake.listGenericResourcesMutex.RLock() - defer fake.listGenericResourcesMutex.RUnlock() - argsForCall := fake.listGenericResourcesArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 -} - -func (fake *FakeRodeClient) ListGenericResourcesReturns(result1 *v1alpha1.ListGenericResourcesResponse, result2 error) { - fake.listGenericResourcesMutex.Lock() - defer fake.listGenericResourcesMutex.Unlock() - fake.ListGenericResourcesStub = nil - fake.listGenericResourcesReturns = struct { - result1 *v1alpha1.ListGenericResourcesResponse - result2 error - }{result1, result2} -} - -func (fake *FakeRodeClient) ListGenericResourcesReturnsOnCall(i int, result1 *v1alpha1.ListGenericResourcesResponse, result2 error) { - fake.listGenericResourcesMutex.Lock() - defer fake.listGenericResourcesMutex.Unlock() - fake.ListGenericResourcesStub = nil - if fake.listGenericResourcesReturnsOnCall == nil { - fake.listGenericResourcesReturnsOnCall = make(map[int]struct { - result1 *v1alpha1.ListGenericResourcesResponse - result2 error - }) - } - fake.listGenericResourcesReturnsOnCall[i] = struct { - result1 *v1alpha1.ListGenericResourcesResponse - result2 error - }{result1, result2} -} - -func (fake *FakeRodeClient) ListOccurrences(arg1 context.Context, arg2 *v1alpha1.ListOccurrencesRequest, arg3 ...grpc.CallOption) (*v1alpha1.ListOccurrencesResponse, error) { - fake.listOccurrencesMutex.Lock() - ret, specificReturn := fake.listOccurrencesReturnsOnCall[len(fake.listOccurrencesArgsForCall)] - fake.listOccurrencesArgsForCall = append(fake.listOccurrencesArgsForCall, struct { - arg1 context.Context - arg2 *v1alpha1.ListOccurrencesRequest - arg3 []grpc.CallOption - }{arg1, arg2, arg3}) - stub := fake.ListOccurrencesStub - fakeReturns := fake.listOccurrencesReturns - fake.recordInvocation("ListOccurrences", []interface{}{arg1, arg2, arg3}) - fake.listOccurrencesMutex.Unlock() - if stub != nil { - return stub(arg1, arg2, arg3...) - } - if specificReturn { - return ret.result1, ret.result2 - } - return fakeReturns.result1, fakeReturns.result2 -} - -func (fake *FakeRodeClient) ListOccurrencesCallCount() int { - fake.listOccurrencesMutex.RLock() - defer fake.listOccurrencesMutex.RUnlock() - return len(fake.listOccurrencesArgsForCall) -} - -func (fake *FakeRodeClient) ListOccurrencesCalls(stub func(context.Context, *v1alpha1.ListOccurrencesRequest, ...grpc.CallOption) (*v1alpha1.ListOccurrencesResponse, error)) { - fake.listOccurrencesMutex.Lock() - defer fake.listOccurrencesMutex.Unlock() - fake.ListOccurrencesStub = stub -} - -func (fake *FakeRodeClient) ListOccurrencesArgsForCall(i int) (context.Context, *v1alpha1.ListOccurrencesRequest, []grpc.CallOption) { - fake.listOccurrencesMutex.RLock() - defer fake.listOccurrencesMutex.RUnlock() - argsForCall := fake.listOccurrencesArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 -} - -func (fake *FakeRodeClient) ListOccurrencesReturns(result1 *v1alpha1.ListOccurrencesResponse, result2 error) { - fake.listOccurrencesMutex.Lock() - defer fake.listOccurrencesMutex.Unlock() - fake.ListOccurrencesStub = nil - fake.listOccurrencesReturns = struct { - result1 *v1alpha1.ListOccurrencesResponse - result2 error - }{result1, result2} -} - -func (fake *FakeRodeClient) ListOccurrencesReturnsOnCall(i int, result1 *v1alpha1.ListOccurrencesResponse, result2 error) { - fake.listOccurrencesMutex.Lock() - defer fake.listOccurrencesMutex.Unlock() - fake.ListOccurrencesStub = nil - if fake.listOccurrencesReturnsOnCall == nil { - fake.listOccurrencesReturnsOnCall = make(map[int]struct { - result1 *v1alpha1.ListOccurrencesResponse - result2 error - }) - } - fake.listOccurrencesReturnsOnCall[i] = struct { - result1 *v1alpha1.ListOccurrencesResponse - result2 error - }{result1, result2} -} - -func (fake *FakeRodeClient) ListPolicies(arg1 context.Context, arg2 *v1alpha1.ListPoliciesRequest, arg3 ...grpc.CallOption) (*v1alpha1.ListPoliciesResponse, error) { - fake.listPoliciesMutex.Lock() - ret, specificReturn := fake.listPoliciesReturnsOnCall[len(fake.listPoliciesArgsForCall)] - fake.listPoliciesArgsForCall = append(fake.listPoliciesArgsForCall, struct { - arg1 context.Context - arg2 *v1alpha1.ListPoliciesRequest - arg3 []grpc.CallOption - }{arg1, arg2, arg3}) - stub := fake.ListPoliciesStub - fakeReturns := fake.listPoliciesReturns - fake.recordInvocation("ListPolicies", []interface{}{arg1, arg2, arg3}) - fake.listPoliciesMutex.Unlock() - if stub != nil { - return stub(arg1, arg2, arg3...) - } - if specificReturn { - return ret.result1, ret.result2 - } - return fakeReturns.result1, fakeReturns.result2 -} - -func (fake *FakeRodeClient) ListPoliciesCallCount() int { - fake.listPoliciesMutex.RLock() - defer fake.listPoliciesMutex.RUnlock() - return len(fake.listPoliciesArgsForCall) -} - -func (fake *FakeRodeClient) ListPoliciesCalls(stub func(context.Context, *v1alpha1.ListPoliciesRequest, ...grpc.CallOption) (*v1alpha1.ListPoliciesResponse, error)) { - fake.listPoliciesMutex.Lock() - defer fake.listPoliciesMutex.Unlock() - fake.ListPoliciesStub = stub -} - -func (fake *FakeRodeClient) ListPoliciesArgsForCall(i int) (context.Context, *v1alpha1.ListPoliciesRequest, []grpc.CallOption) { - fake.listPoliciesMutex.RLock() - defer fake.listPoliciesMutex.RUnlock() - argsForCall := fake.listPoliciesArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 -} - -func (fake *FakeRodeClient) ListPoliciesReturns(result1 *v1alpha1.ListPoliciesResponse, result2 error) { - fake.listPoliciesMutex.Lock() - defer fake.listPoliciesMutex.Unlock() - fake.ListPoliciesStub = nil - fake.listPoliciesReturns = struct { - result1 *v1alpha1.ListPoliciesResponse - result2 error - }{result1, result2} -} - -func (fake *FakeRodeClient) ListPoliciesReturnsOnCall(i int, result1 *v1alpha1.ListPoliciesResponse, result2 error) { - fake.listPoliciesMutex.Lock() - defer fake.listPoliciesMutex.Unlock() - fake.ListPoliciesStub = nil - if fake.listPoliciesReturnsOnCall == nil { - fake.listPoliciesReturnsOnCall = make(map[int]struct { - result1 *v1alpha1.ListPoliciesResponse - result2 error - }) - } - fake.listPoliciesReturnsOnCall[i] = struct { - result1 *v1alpha1.ListPoliciesResponse - result2 error - }{result1, result2} -} - -func (fake *FakeRodeClient) ListResources(arg1 context.Context, arg2 *v1alpha1.ListResourcesRequest, arg3 ...grpc.CallOption) (*v1alpha1.ListResourcesResponse, error) { - fake.listResourcesMutex.Lock() - ret, specificReturn := fake.listResourcesReturnsOnCall[len(fake.listResourcesArgsForCall)] - fake.listResourcesArgsForCall = append(fake.listResourcesArgsForCall, struct { - arg1 context.Context - arg2 *v1alpha1.ListResourcesRequest - arg3 []grpc.CallOption - }{arg1, arg2, arg3}) - stub := fake.ListResourcesStub - fakeReturns := fake.listResourcesReturns - fake.recordInvocation("ListResources", []interface{}{arg1, arg2, arg3}) - fake.listResourcesMutex.Unlock() - if stub != nil { - return stub(arg1, arg2, arg3...) - } - if specificReturn { - return ret.result1, ret.result2 - } - return fakeReturns.result1, fakeReturns.result2 -} - -func (fake *FakeRodeClient) ListResourcesCallCount() int { - fake.listResourcesMutex.RLock() - defer fake.listResourcesMutex.RUnlock() - return len(fake.listResourcesArgsForCall) -} - -func (fake *FakeRodeClient) ListResourcesCalls(stub func(context.Context, *v1alpha1.ListResourcesRequest, ...grpc.CallOption) (*v1alpha1.ListResourcesResponse, error)) { - fake.listResourcesMutex.Lock() - defer fake.listResourcesMutex.Unlock() - fake.ListResourcesStub = stub -} - -func (fake *FakeRodeClient) ListResourcesArgsForCall(i int) (context.Context, *v1alpha1.ListResourcesRequest, []grpc.CallOption) { - fake.listResourcesMutex.RLock() - defer fake.listResourcesMutex.RUnlock() - argsForCall := fake.listResourcesArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 -} - -func (fake *FakeRodeClient) ListResourcesReturns(result1 *v1alpha1.ListResourcesResponse, result2 error) { - fake.listResourcesMutex.Lock() - defer fake.listResourcesMutex.Unlock() - fake.ListResourcesStub = nil - fake.listResourcesReturns = struct { - result1 *v1alpha1.ListResourcesResponse - result2 error - }{result1, result2} -} - -func (fake *FakeRodeClient) ListResourcesReturnsOnCall(i int, result1 *v1alpha1.ListResourcesResponse, result2 error) { - fake.listResourcesMutex.Lock() - defer fake.listResourcesMutex.Unlock() - fake.ListResourcesStub = nil - if fake.listResourcesReturnsOnCall == nil { - fake.listResourcesReturnsOnCall = make(map[int]struct { - result1 *v1alpha1.ListResourcesResponse - result2 error - }) - } - fake.listResourcesReturnsOnCall[i] = struct { - result1 *v1alpha1.ListResourcesResponse - result2 error - }{result1, result2} -} - -func (fake *FakeRodeClient) ListVersionedResourceOccurrences(arg1 context.Context, arg2 *v1alpha1.ListVersionedResourceOccurrencesRequest, arg3 ...grpc.CallOption) (*v1alpha1.ListVersionedResourceOccurrencesResponse, error) { - fake.listVersionedResourceOccurrencesMutex.Lock() - ret, specificReturn := fake.listVersionedResourceOccurrencesReturnsOnCall[len(fake.listVersionedResourceOccurrencesArgsForCall)] - fake.listVersionedResourceOccurrencesArgsForCall = append(fake.listVersionedResourceOccurrencesArgsForCall, struct { - arg1 context.Context - arg2 *v1alpha1.ListVersionedResourceOccurrencesRequest - arg3 []grpc.CallOption - }{arg1, arg2, arg3}) - stub := fake.ListVersionedResourceOccurrencesStub - fakeReturns := fake.listVersionedResourceOccurrencesReturns - fake.recordInvocation("ListVersionedResourceOccurrences", []interface{}{arg1, arg2, arg3}) - fake.listVersionedResourceOccurrencesMutex.Unlock() - if stub != nil { - return stub(arg1, arg2, arg3...) - } - if specificReturn { - return ret.result1, ret.result2 - } - return fakeReturns.result1, fakeReturns.result2 -} - -func (fake *FakeRodeClient) ListVersionedResourceOccurrencesCallCount() int { - fake.listVersionedResourceOccurrencesMutex.RLock() - defer fake.listVersionedResourceOccurrencesMutex.RUnlock() - return len(fake.listVersionedResourceOccurrencesArgsForCall) -} - -func (fake *FakeRodeClient) ListVersionedResourceOccurrencesCalls(stub func(context.Context, *v1alpha1.ListVersionedResourceOccurrencesRequest, ...grpc.CallOption) (*v1alpha1.ListVersionedResourceOccurrencesResponse, error)) { - fake.listVersionedResourceOccurrencesMutex.Lock() - defer fake.listVersionedResourceOccurrencesMutex.Unlock() - fake.ListVersionedResourceOccurrencesStub = stub -} - -func (fake *FakeRodeClient) ListVersionedResourceOccurrencesArgsForCall(i int) (context.Context, *v1alpha1.ListVersionedResourceOccurrencesRequest, []grpc.CallOption) { - fake.listVersionedResourceOccurrencesMutex.RLock() - defer fake.listVersionedResourceOccurrencesMutex.RUnlock() - argsForCall := fake.listVersionedResourceOccurrencesArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 -} - -func (fake *FakeRodeClient) ListVersionedResourceOccurrencesReturns(result1 *v1alpha1.ListVersionedResourceOccurrencesResponse, result2 error) { - fake.listVersionedResourceOccurrencesMutex.Lock() - defer fake.listVersionedResourceOccurrencesMutex.Unlock() - fake.ListVersionedResourceOccurrencesStub = nil - fake.listVersionedResourceOccurrencesReturns = struct { - result1 *v1alpha1.ListVersionedResourceOccurrencesResponse - result2 error - }{result1, result2} -} - -func (fake *FakeRodeClient) ListVersionedResourceOccurrencesReturnsOnCall(i int, result1 *v1alpha1.ListVersionedResourceOccurrencesResponse, result2 error) { - fake.listVersionedResourceOccurrencesMutex.Lock() - defer fake.listVersionedResourceOccurrencesMutex.Unlock() - fake.ListVersionedResourceOccurrencesStub = nil - if fake.listVersionedResourceOccurrencesReturnsOnCall == nil { - fake.listVersionedResourceOccurrencesReturnsOnCall = make(map[int]struct { - result1 *v1alpha1.ListVersionedResourceOccurrencesResponse - result2 error - }) - } - fake.listVersionedResourceOccurrencesReturnsOnCall[i] = struct { - result1 *v1alpha1.ListVersionedResourceOccurrencesResponse - result2 error - }{result1, result2} -} - -func (fake *FakeRodeClient) RegisterCollector(arg1 context.Context, arg2 *v1alpha1.RegisterCollectorRequest, arg3 ...grpc.CallOption) (*v1alpha1.RegisterCollectorResponse, error) { - fake.registerCollectorMutex.Lock() - ret, specificReturn := fake.registerCollectorReturnsOnCall[len(fake.registerCollectorArgsForCall)] - fake.registerCollectorArgsForCall = append(fake.registerCollectorArgsForCall, struct { - arg1 context.Context - arg2 *v1alpha1.RegisterCollectorRequest - arg3 []grpc.CallOption - }{arg1, arg2, arg3}) - stub := fake.RegisterCollectorStub - fakeReturns := fake.registerCollectorReturns - fake.recordInvocation("RegisterCollector", []interface{}{arg1, arg2, arg3}) - fake.registerCollectorMutex.Unlock() - if stub != nil { - return stub(arg1, arg2, arg3...) - } - if specificReturn { - return ret.result1, ret.result2 - } - return fakeReturns.result1, fakeReturns.result2 -} - -func (fake *FakeRodeClient) RegisterCollectorCallCount() int { - fake.registerCollectorMutex.RLock() - defer fake.registerCollectorMutex.RUnlock() - return len(fake.registerCollectorArgsForCall) -} - -func (fake *FakeRodeClient) RegisterCollectorCalls(stub func(context.Context, *v1alpha1.RegisterCollectorRequest, ...grpc.CallOption) (*v1alpha1.RegisterCollectorResponse, error)) { - fake.registerCollectorMutex.Lock() - defer fake.registerCollectorMutex.Unlock() - fake.RegisterCollectorStub = stub -} - -func (fake *FakeRodeClient) RegisterCollectorArgsForCall(i int) (context.Context, *v1alpha1.RegisterCollectorRequest, []grpc.CallOption) { - fake.registerCollectorMutex.RLock() - defer fake.registerCollectorMutex.RUnlock() - argsForCall := fake.registerCollectorArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 -} - -func (fake *FakeRodeClient) RegisterCollectorReturns(result1 *v1alpha1.RegisterCollectorResponse, result2 error) { - fake.registerCollectorMutex.Lock() - defer fake.registerCollectorMutex.Unlock() - fake.RegisterCollectorStub = nil - fake.registerCollectorReturns = struct { - result1 *v1alpha1.RegisterCollectorResponse - result2 error - }{result1, result2} -} - -func (fake *FakeRodeClient) RegisterCollectorReturnsOnCall(i int, result1 *v1alpha1.RegisterCollectorResponse, result2 error) { - fake.registerCollectorMutex.Lock() - defer fake.registerCollectorMutex.Unlock() - fake.RegisterCollectorStub = nil - if fake.registerCollectorReturnsOnCall == nil { - fake.registerCollectorReturnsOnCall = make(map[int]struct { - result1 *v1alpha1.RegisterCollectorResponse - result2 error - }) - } - fake.registerCollectorReturnsOnCall[i] = struct { - result1 *v1alpha1.RegisterCollectorResponse - result2 error - }{result1, result2} -} - -func (fake *FakeRodeClient) UpdateOccurrence(arg1 context.Context, arg2 *v1alpha1.UpdateOccurrenceRequest, arg3 ...grpc.CallOption) (*grafeas_go_proto.Occurrence, error) { - fake.updateOccurrenceMutex.Lock() - ret, specificReturn := fake.updateOccurrenceReturnsOnCall[len(fake.updateOccurrenceArgsForCall)] - fake.updateOccurrenceArgsForCall = append(fake.updateOccurrenceArgsForCall, struct { - arg1 context.Context - arg2 *v1alpha1.UpdateOccurrenceRequest - arg3 []grpc.CallOption - }{arg1, arg2, arg3}) - stub := fake.UpdateOccurrenceStub - fakeReturns := fake.updateOccurrenceReturns - fake.recordInvocation("UpdateOccurrence", []interface{}{arg1, arg2, arg3}) - fake.updateOccurrenceMutex.Unlock() - if stub != nil { - return stub(arg1, arg2, arg3...) - } - if specificReturn { - return ret.result1, ret.result2 - } - return fakeReturns.result1, fakeReturns.result2 -} - -func (fake *FakeRodeClient) UpdateOccurrenceCallCount() int { - fake.updateOccurrenceMutex.RLock() - defer fake.updateOccurrenceMutex.RUnlock() - return len(fake.updateOccurrenceArgsForCall) -} - -func (fake *FakeRodeClient) UpdateOccurrenceCalls(stub func(context.Context, *v1alpha1.UpdateOccurrenceRequest, ...grpc.CallOption) (*grafeas_go_proto.Occurrence, error)) { - fake.updateOccurrenceMutex.Lock() - defer fake.updateOccurrenceMutex.Unlock() - fake.UpdateOccurrenceStub = stub -} - -func (fake *FakeRodeClient) UpdateOccurrenceArgsForCall(i int) (context.Context, *v1alpha1.UpdateOccurrenceRequest, []grpc.CallOption) { - fake.updateOccurrenceMutex.RLock() - defer fake.updateOccurrenceMutex.RUnlock() - argsForCall := fake.updateOccurrenceArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 -} - -func (fake *FakeRodeClient) UpdateOccurrenceReturns(result1 *grafeas_go_proto.Occurrence, result2 error) { - fake.updateOccurrenceMutex.Lock() - defer fake.updateOccurrenceMutex.Unlock() - fake.UpdateOccurrenceStub = nil - fake.updateOccurrenceReturns = struct { - result1 *grafeas_go_proto.Occurrence - result2 error - }{result1, result2} -} - -func (fake *FakeRodeClient) UpdateOccurrenceReturnsOnCall(i int, result1 *grafeas_go_proto.Occurrence, result2 error) { - fake.updateOccurrenceMutex.Lock() - defer fake.updateOccurrenceMutex.Unlock() - fake.UpdateOccurrenceStub = nil - if fake.updateOccurrenceReturnsOnCall == nil { - fake.updateOccurrenceReturnsOnCall = make(map[int]struct { - result1 *grafeas_go_proto.Occurrence - result2 error - }) - } - fake.updateOccurrenceReturnsOnCall[i] = struct { - result1 *grafeas_go_proto.Occurrence - result2 error - }{result1, result2} -} - -func (fake *FakeRodeClient) UpdatePolicy(arg1 context.Context, arg2 *v1alpha1.UpdatePolicyRequest, arg3 ...grpc.CallOption) (*v1alpha1.Policy, error) { - fake.updatePolicyMutex.Lock() - ret, specificReturn := fake.updatePolicyReturnsOnCall[len(fake.updatePolicyArgsForCall)] - fake.updatePolicyArgsForCall = append(fake.updatePolicyArgsForCall, struct { - arg1 context.Context - arg2 *v1alpha1.UpdatePolicyRequest - arg3 []grpc.CallOption - }{arg1, arg2, arg3}) - stub := fake.UpdatePolicyStub - fakeReturns := fake.updatePolicyReturns - fake.recordInvocation("UpdatePolicy", []interface{}{arg1, arg2, arg3}) - fake.updatePolicyMutex.Unlock() - if stub != nil { - return stub(arg1, arg2, arg3...) - } - if specificReturn { - return ret.result1, ret.result2 - } - return fakeReturns.result1, fakeReturns.result2 -} - -func (fake *FakeRodeClient) UpdatePolicyCallCount() int { - fake.updatePolicyMutex.RLock() - defer fake.updatePolicyMutex.RUnlock() - return len(fake.updatePolicyArgsForCall) -} - -func (fake *FakeRodeClient) UpdatePolicyCalls(stub func(context.Context, *v1alpha1.UpdatePolicyRequest, ...grpc.CallOption) (*v1alpha1.Policy, error)) { - fake.updatePolicyMutex.Lock() - defer fake.updatePolicyMutex.Unlock() - fake.UpdatePolicyStub = stub -} - -func (fake *FakeRodeClient) UpdatePolicyArgsForCall(i int) (context.Context, *v1alpha1.UpdatePolicyRequest, []grpc.CallOption) { - fake.updatePolicyMutex.RLock() - defer fake.updatePolicyMutex.RUnlock() - argsForCall := fake.updatePolicyArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 -} - -func (fake *FakeRodeClient) UpdatePolicyReturns(result1 *v1alpha1.Policy, result2 error) { - fake.updatePolicyMutex.Lock() - defer fake.updatePolicyMutex.Unlock() - fake.UpdatePolicyStub = nil - fake.updatePolicyReturns = struct { - result1 *v1alpha1.Policy - result2 error - }{result1, result2} -} - -func (fake *FakeRodeClient) UpdatePolicyReturnsOnCall(i int, result1 *v1alpha1.Policy, result2 error) { - fake.updatePolicyMutex.Lock() - defer fake.updatePolicyMutex.Unlock() - fake.UpdatePolicyStub = nil - if fake.updatePolicyReturnsOnCall == nil { - fake.updatePolicyReturnsOnCall = make(map[int]struct { - result1 *v1alpha1.Policy - result2 error - }) - } - fake.updatePolicyReturnsOnCall[i] = struct { - result1 *v1alpha1.Policy - result2 error - }{result1, result2} -} - -func (fake *FakeRodeClient) ValidatePolicy(arg1 context.Context, arg2 *v1alpha1.ValidatePolicyRequest, arg3 ...grpc.CallOption) (*v1alpha1.ValidatePolicyResponse, error) { - fake.validatePolicyMutex.Lock() - ret, specificReturn := fake.validatePolicyReturnsOnCall[len(fake.validatePolicyArgsForCall)] - fake.validatePolicyArgsForCall = append(fake.validatePolicyArgsForCall, struct { - arg1 context.Context - arg2 *v1alpha1.ValidatePolicyRequest - arg3 []grpc.CallOption - }{arg1, arg2, arg3}) - stub := fake.ValidatePolicyStub - fakeReturns := fake.validatePolicyReturns - fake.recordInvocation("ValidatePolicy", []interface{}{arg1, arg2, arg3}) - fake.validatePolicyMutex.Unlock() - if stub != nil { - return stub(arg1, arg2, arg3...) - } - if specificReturn { - return ret.result1, ret.result2 - } - return fakeReturns.result1, fakeReturns.result2 -} - -func (fake *FakeRodeClient) ValidatePolicyCallCount() int { - fake.validatePolicyMutex.RLock() - defer fake.validatePolicyMutex.RUnlock() - return len(fake.validatePolicyArgsForCall) -} - -func (fake *FakeRodeClient) ValidatePolicyCalls(stub func(context.Context, *v1alpha1.ValidatePolicyRequest, ...grpc.CallOption) (*v1alpha1.ValidatePolicyResponse, error)) { - fake.validatePolicyMutex.Lock() - defer fake.validatePolicyMutex.Unlock() - fake.ValidatePolicyStub = stub -} - -func (fake *FakeRodeClient) ValidatePolicyArgsForCall(i int) (context.Context, *v1alpha1.ValidatePolicyRequest, []grpc.CallOption) { - fake.validatePolicyMutex.RLock() - defer fake.validatePolicyMutex.RUnlock() - argsForCall := fake.validatePolicyArgsForCall[i] - return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 -} - -func (fake *FakeRodeClient) ValidatePolicyReturns(result1 *v1alpha1.ValidatePolicyResponse, result2 error) { - fake.validatePolicyMutex.Lock() - defer fake.validatePolicyMutex.Unlock() - fake.ValidatePolicyStub = nil - fake.validatePolicyReturns = struct { - result1 *v1alpha1.ValidatePolicyResponse - result2 error - }{result1, result2} -} - -func (fake *FakeRodeClient) ValidatePolicyReturnsOnCall(i int, result1 *v1alpha1.ValidatePolicyResponse, result2 error) { - fake.validatePolicyMutex.Lock() - defer fake.validatePolicyMutex.Unlock() - fake.ValidatePolicyStub = nil - if fake.validatePolicyReturnsOnCall == nil { - fake.validatePolicyReturnsOnCall = make(map[int]struct { - result1 *v1alpha1.ValidatePolicyResponse - result2 error - }) - } - fake.validatePolicyReturnsOnCall[i] = struct { - result1 *v1alpha1.ValidatePolicyResponse - result2 error - }{result1, result2} -} - -func (fake *FakeRodeClient) Invocations() map[string][][]interface{} { - fake.invocationsMutex.RLock() - defer fake.invocationsMutex.RUnlock() - fake.batchCreateOccurrencesMutex.RLock() - defer fake.batchCreateOccurrencesMutex.RUnlock() - fake.createNoteMutex.RLock() - defer fake.createNoteMutex.RUnlock() - fake.createPolicyMutex.RLock() - defer fake.createPolicyMutex.RUnlock() - fake.deletePolicyMutex.RLock() - defer fake.deletePolicyMutex.RUnlock() - fake.evaluatePolicyMutex.RLock() - defer fake.evaluatePolicyMutex.RUnlock() - fake.getPolicyMutex.RLock() - defer fake.getPolicyMutex.RUnlock() - fake.listGenericResourceVersionsMutex.RLock() - defer fake.listGenericResourceVersionsMutex.RUnlock() - fake.listGenericResourcesMutex.RLock() - defer fake.listGenericResourcesMutex.RUnlock() - fake.listOccurrencesMutex.RLock() - defer fake.listOccurrencesMutex.RUnlock() - fake.listPoliciesMutex.RLock() - defer fake.listPoliciesMutex.RUnlock() - fake.listResourcesMutex.RLock() - defer fake.listResourcesMutex.RUnlock() - fake.listVersionedResourceOccurrencesMutex.RLock() - defer fake.listVersionedResourceOccurrencesMutex.RUnlock() - fake.registerCollectorMutex.RLock() - defer fake.registerCollectorMutex.RUnlock() - fake.updateOccurrenceMutex.RLock() - defer fake.updateOccurrenceMutex.RUnlock() - fake.updatePolicyMutex.RLock() - defer fake.updatePolicyMutex.RUnlock() - fake.validatePolicyMutex.RLock() - defer fake.validatePolicyMutex.RUnlock() - copiedInvocations := map[string][][]interface{}{} - for key, value := range fake.invocations { - copiedInvocations[key] = value - } - return copiedInvocations -} - -func (fake *FakeRodeClient) recordInvocation(key string, args []interface{}) { - fake.invocationsMutex.Lock() - defer fake.invocationsMutex.Unlock() - if fake.invocations == nil { - fake.invocations = map[string][][]interface{}{} - } - if fake.invocations[key] == nil { - fake.invocations[key] = [][]interface{}{} - } - fake.invocations[key] = append(fake.invocations[key], args) -} - -var _ v1alpha1.RodeClient = new(FakeRodeClient)