diff --git a/cmd/flagger/main.go b/cmd/flagger/main.go index 1c31f677..cfb53443 100644 --- a/cmd/flagger/main.go +++ b/cmd/flagger/main.go @@ -336,17 +336,17 @@ func fromEnv(envVar string, defaultVal string) string { } func verifyCRDs(flaggerClient clientset.Interface, logger *zap.SugaredLogger) { - _, err := flaggerClient.FlaggerV1beta1().Canaries(namespace).List(metav1.ListOptions{Limit: 1}) + _, err := flaggerClient.FlaggerV1beta1().Canaries(namespace).List(context.TODO(), metav1.ListOptions{Limit: 1}) if err != nil { logger.Fatalf("Canary CRD is not registered %v", err) } - _, err = flaggerClient.FlaggerV1beta1().MetricTemplates(namespace).List(metav1.ListOptions{Limit: 1}) + _, err = flaggerClient.FlaggerV1beta1().MetricTemplates(namespace).List(context.TODO(), metav1.ListOptions{Limit: 1}) if err != nil { logger.Fatalf("MetricTemplate CRD is not registered %v", err) } - _, err = flaggerClient.FlaggerV1beta1().AlertProviders(namespace).List(metav1.ListOptions{Limit: 1}) + _, err = flaggerClient.FlaggerV1beta1().AlertProviders(namespace).List(context.TODO(), metav1.ListOptions{Limit: 1}) if err != nil { logger.Fatalf("AlertProvider CRD is not registered %v", err) } diff --git a/go.mod b/go.mod index 1649ca6b..00258f92 100644 --- a/go.mod +++ b/go.mod @@ -11,11 +11,11 @@ require ( github.com/stretchr/testify v1.5.1 go.uber.org/zap v1.14.1 gopkg.in/h2non/gock.v1 v1.0.15 - k8s.io/api v0.17.4 - k8s.io/apimachinery v0.17.4 - k8s.io/client-go v0.17.4 - k8s.io/code-generator v0.17.4 - k8s.io/utils v0.0.0-20191114184206-e782cd3c129f + k8s.io/api v0.18.0 + k8s.io/apimachinery v0.18.0 + k8s.io/client-go v0.18.0 + k8s.io/code-generator v0.18.0 + k8s.io/utils v0.0.0-20200324210504-a9aa75ae1b89 ) replace k8s.io/klog => github.com/stefanprodan/klog v0.0.0-20190418165334-9cbb78b20423 diff --git a/go.sum b/go.sum index 307f361d..f0a120e8 100644 --- a/go.sum +++ b/go.sum @@ -11,7 +11,6 @@ github.com/Azure/go-autorest/logger v0.1.0/go.mod h1:oExouG+K6PryycPJfVSxi/koC6L github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbtp2fGCgRFtBroKn4Dk= 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/Masterminds/semver/v3 v3.0.3 h1:znjIyLfpXEDQjOIEWh+ehwpTU14UzUPub3c3sm36u14= github.com/Masterminds/semver/v3 v3.0.3/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= @@ -33,13 +32,12 @@ github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6r github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/davecgh/go-spew v0.0.0-20151105211317-5215b55f46b2/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM= -github.com/elazarl/goproxy v0.0.0-20170405201442-c4fc26588b6e/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= +github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= github.com/emicklei/go-restful v2.9.5+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= github.com/evanphx/json-patch v4.2.0+incompatible h1:fUDGZCv/7iAN7u0puUVhvKCcsR6vRfwrJatElLBEf0I= @@ -69,8 +67,8 @@ github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= -github.com/gogo/protobuf v1.2.2-0.20190723190241-65acae22fc9d h1:3PaI8p3seN09VjbTYC/QWlUZdZ1qS1zGjy7LH2Wt07I= -github.com/gogo/protobuf v1.2.2-0.20190723190241-65acae22fc9d/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= +github.com/gogo/protobuf v1.3.1 h1:DqDEcV5aeaTmdFBePNpYsp3FlcVH/2ISVVM9Qf8PSls= +github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= 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 h1:LbsanbbD6LieFkXbj9YNNBupiGHJgFeLpO0j0Fza1h8= @@ -91,9 +89,10 @@ github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/gofuzz v0.0.0-20161122191042-44d81051d367/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/gofuzz v1.1.0 h1:Hsa8mG0dQ46ij8Sl2AYJDUv1oA9/d6Vk+3LG99Oe02g= +github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= @@ -102,6 +101,8 @@ github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+ github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d h1:7XGaL1e6bYS1yIonGp9761ExpPPV1ui0SAC59Yube9k= github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= +github.com/googleapis/gnostic v0.1.0 h1:rVsPeBmXbYv4If/cumu1AzZPwV58q433hvONV1UEZoI= +github.com/googleapis/gnostic v0.1.0/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= github.com/gophercloud/gophercloud v0.1.0/go.mod h1:vxM41WHh5uqHVBMZHzuwNOHh8XEoIEcSTewFxm1c5g8= github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 h1:2VTzZjLZBgl62/EtslCrtky5vbi9dd7HrQPQIx6wqiw= @@ -115,7 +116,6 @@ github.com/imdario/mergo v0.3.5 h1:JboBksRwiiAJWvIYJVo46AfV+IAIKZpfrSzVKj42R4Q= github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5imkbgOkpRUYLnmbU7UEFbjtDA2hxJ1ichM= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= -github.com/json-iterator/go v0.0.0-20180612202835-f2b4162afba3/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.6 h1:MrUvLMLTMxbqFJ9kzlvat/rYZqZnW3u4wkLzWTaFwKs= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.8 h1:QiWkFLKq0T7mpzwOTu6BzNDbfTE8OLrYhVKYMLF46Ok= @@ -143,7 +143,6 @@ github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5 github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v0.0.0-20180320133207-05fbef0ca5da/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= @@ -154,8 +153,8 @@ github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32 h1:W6apQkHrMkS0Muv8G/TipAy github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32/go.mod h1:9wM+0iRr9ahx58uYLpLIr5fm8diHn0JbqRycJi6w0Ms= github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.10.1 h1:q/mM8GF/n0shIN8SaAZ0V+jnLPzen6WIVZdiwrRlMlo= -github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.11.0 h1:JAKSXpt1YjtLA7YpPiqO9ss6sNXEsPfSGdwN0UHqzrw= +github.com/onsi/ginkgo v1.11.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= 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= @@ -165,7 +164,6 @@ github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 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/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= @@ -187,7 +185,6 @@ github.com/prometheus/procfs v0.0.2 h1:6LJUbpNm42llc4HRCuvApCSWB/WfhuNo9K98Q9sNG github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.8 h1:+fpWZdT24pJBiqJdAwYBjPSk+5YmQzYNPYzQsdzLkt8= github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= -github.com/remyoudompheng/bigfft v0.0.0-20170806203942-52369c62f446/go.mod h1:uYEyJGbgTkfkS4+E/PavXkNJcbFIpEtjt2B0KDQ5+9M= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= @@ -201,7 +198,6 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= -github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= @@ -226,16 +222,11 @@ golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20200220183623-bac4c82f6975 h1:/Tl7pH94bvbAAHBdZJT947M/+gp0+CqQXDtMRC0fseo= golang.org/x/crypto v0.0.0-20200220183623-bac4c82f6975/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190125153040-c74c464bbbf2/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190312203227-4b39c73a6495 h1:I6A9Ag9FpEKOjcKrRNjQkPHawoXIhKyTGfvvjFAiiAk= -golang.org/x/exp v0.0.0-20190312203227-4b39c73a6495/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= -golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190930215403-16217165b5de h1:5hukYrvBGR8/eNkX5mdUezrA6JiaEZDtJb9Ei+1LlBs= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -273,12 +264,10 @@ golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190209173611-3b5209105503 h1:5SvYFrOM3W8Mexn9/oA44Ji7vhXAZQ9hiP+1Q/DMrWg= golang.org/x/sys v0.0.0-20190209173611-3b5209105503/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-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456 h1:ng0gs1AKnRRuEMZoTLLlbOd+C17zUDepwGQBb/n+JVg= -golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191022100944-742c48ecaeb7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200122134326-e047566fdf82 h1:ywK/j/KkyTHcdyYSZNXGjMwgmDSfjglYZ3vStQ/gSCU= golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -293,10 +282,8 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20181011042414-1f849cf54d09/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190206041539-40960b6deb8e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= @@ -308,11 +295,6 @@ golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtn 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= -gonum.org/v1/gonum v0.0.0-20190331200053-3d26580ed485 h1:OB/uP/Puiu5vS5QMRPrXCDWUPb+kt8f1KW8oQzFejQw= -gonum.org/v1/gonum v0.0.0-20190331200053-3d26580ed485/go.mod h1:2ltnJ7xHfj0zHS40VVPYEAAMTa3ZGguvHGBSJeRWqE0= -gonum.org/v1/netlib v0.0.0-20190313105609-8cb42192e0e0/go.mod h1:wa6Ws7BG/ESfp6dHfk7C6KdzKA7wR7u/rKwOGE66zvw= -gonum.org/v1/netlib v0.0.0-20190331212654-76723241ea4e h1:jRyg0XfpwWlhEV8mDfdNGBeSJM2fuyh9Yjrnd8kF2Ts= -gonum.org/v1/netlib v0.0.0-20190331212654-76723241ea4e/go.mod h1:kS+toOQn6AQKjmKJ7gzohV1XkqsFehRA2FbsbkopSuQ= google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508= @@ -351,27 +333,26 @@ honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.1-2019.2.3 h1:3JgtbtFHMiCmsznwGVTUWbgGov+pVqnlf1dEJTNAXeM= honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= -k8s.io/api v0.17.4 h1:HbwOhDapkguO8lTAE8OX3hdF2qp8GtpC9CW/MQATXXo= -k8s.io/api v0.17.4/go.mod h1:5qxx6vjmwUVG2nHQTKGlLts8Tbok8PzHl4vHtVFuZCA= -k8s.io/apimachinery v0.17.4 h1:UzM+38cPUJnzqSQ+E1PY4YxMHIzQyCg29LOoGfo79Zw= -k8s.io/apimachinery v0.17.4/go.mod h1:gxLnyZcGNdZTCLnq3fgzyg2A5BVCHTNDFrw8AmuJ+0g= -k8s.io/client-go v0.17.4 h1:VVdVbpTY70jiNHS1eiFkUt7ZIJX3txd29nDxxXH4en8= -k8s.io/client-go v0.17.4/go.mod h1:ouF6o5pz3is8qU0/qYL2RnoxOPqgfuidYLowytyLJmc= -k8s.io/code-generator v0.17.4 h1:C3uu/IvQclEIO4ouUOXuoKWfc4765mYe0uebStg9CaY= -k8s.io/code-generator v0.17.4/go.mod h1:l8BLVwASXQZTo2xamW5mQNFCe1XPiAesVq7Y1t7PiQQ= +k8s.io/api v0.18.0 h1:lwYk8Vt7rsVTwjRU6pzEsa9YNhThbmbocQlKvNBB4EQ= +k8s.io/api v0.18.0/go.mod h1:q2HRQkfDzHMBZL9l/y9rH63PkQl4vae0xRT+8prbrK8= +k8s.io/apimachinery v0.18.0 h1:fuPfYpk3cs1Okp/515pAf0dNhL66+8zk8RLbSX+EgAE= +k8s.io/apimachinery v0.18.0/go.mod h1:9SnR/e11v5IbyPCGbvJViimtJ0SwHG4nfZFjU77ftcA= +k8s.io/client-go v0.18.0 h1:yqKw4cTUQraZK3fcVCMeSa+lqKwcjZ5wtcOIPnxQno4= +k8s.io/client-go v0.18.0/go.mod h1:uQSYDYs4WhVZ9i6AIoEZuwUggLVEF64HOD37boKAtF8= +k8s.io/code-generator v0.18.0 h1:0xIRWzym+qMgVpGmLESDeMfz/orwgxwxFFAo1xfGNtQ= +k8s.io/code-generator v0.18.0/go.mod h1:+UHX5rSbxmR8kzS+FAv7um6dtYrZokQvjHpDSYRVkTc= k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6 h1:4s3/R4+OYYYUKptXPhZKjQ04WJ6EhQQVFdjOFvCazDk= k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= -k8s.io/gengo v0.0.0-20190822140433-26a664648505 h1:ZY6yclUKVbZ+SdWnkfY+Je5vrMpKOxmGeKRbsXVmqYM= -k8s.io/gengo v0.0.0-20190822140433-26a664648505/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= -k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a h1:UcxjrRMyNx/i/y8G7kPvLyy7rfbeuf1PYyBf973pgyU= -k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E= -k8s.io/utils v0.0.0-20191114184206-e782cd3c129f h1:GiPwtSzdP43eI1hpPCbROQCCIgCuiMMNF8YUVLF3vJo= -k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= -modernc.org/cc v1.0.0/go.mod h1:1Sk4//wdnYJiUIxnW8ddKpaOJCF37yAdqYnkxUpaYxw= -modernc.org/golex v1.0.0/go.mod h1:b/QX9oBD/LhixY6NDh+IdGv17hgB+51fET1i2kPSmvk= -modernc.org/mathutil v1.0.0/go.mod h1:wU0vUrJsVWBZ4P6e7xtFJEhFSNsfRLJ8H458uRjg03k= -modernc.org/strutil v1.0.0/go.mod h1:lstksw84oURvj9y3tn8lGvRxyRC1S2+g5uuIzNfIOBs= -modernc.org/xc v1.0.0/go.mod h1:mRNCo0bvLjGhHO9WsyuKVU4q0ceiDDDoEeWDJHrNx8I= -sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= +k8s.io/gengo v0.0.0-20200114144118-36b2048a9120 h1:RPscN6KhmG54S33L+lr3GS+oD1jmchIU0ll519K6FA4= +k8s.io/gengo v0.0.0-20200114144118-36b2048a9120/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= +k8s.io/kube-openapi v0.0.0-20200121204235-bf4fb3bd569c h1:/KUFqjjqAcY4Us6luF5RDNZ16KJtb49HfR3ZHB9qYXM= +k8s.io/kube-openapi v0.0.0-20200121204235-bf4fb3bd569c/go.mod h1:GRQhZsXIAJ1xR0C9bd8UpWHZ5plfAS9fzPjJuQ6JL3E= +k8s.io/utils v0.0.0-20200324210504-a9aa75ae1b89 h1:d4vVOjXm687F1iLSP2q3lyPPuyvTUt3aVoBpi2DqRsU= +k8s.io/utils v0.0.0-20200324210504-a9aa75ae1b89/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= +sigs.k8s.io/structured-merge-diff/v3 v3.0.0-20200116222232-67a7b8c61874/go.mod h1:PlARxl6Hbt/+BC80dRLi1qAmnMqwqDg62YvvVkZjemw= +sigs.k8s.io/structured-merge-diff/v3 v3.0.0 h1:dOmIZBMfhcHS09XZkMyUgkq5trg3/jRyJYFZUiaOp8E= +sigs.k8s.io/structured-merge-diff/v3 v3.0.0/go.mod h1:PlARxl6Hbt/+BC80dRLi1qAmnMqwqDg62YvvVkZjemw= sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= +sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q= +sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc= diff --git a/pkg/canary/config_tracker.go b/pkg/canary/config_tracker.go index 75c6102b..2f939be9 100644 --- a/pkg/canary/config_tracker.go +++ b/pkg/canary/config_tracker.go @@ -1,6 +1,7 @@ package canary import ( + "context" "crypto/sha256" "encoding/json" "fmt" @@ -52,7 +53,7 @@ func checksum(data interface{}) string { // getRefFromConfigMap transforms a Kubernetes ConfigMap into a ConfigRef // and computes the checksum of the ConfigMap data func (ct *ConfigTracker) getRefFromConfigMap(name string, namespace string) (*ConfigRef, error) { - config, err := ct.KubeClient.CoreV1().ConfigMaps(namespace).Get(name, metav1.GetOptions{}) + config, err := ct.KubeClient.CoreV1().ConfigMaps(namespace).Get(context.TODO(), name, metav1.GetOptions{}) if err != nil { return nil, fmt.Errorf("configmap %s.%s get query error: %w", name, namespace, err) } @@ -67,7 +68,7 @@ func (ct *ConfigTracker) getRefFromConfigMap(name string, namespace string) (*Co // getRefFromConfigMap transforms a Kubernetes Secret into a ConfigRef // and computes the checksum of the Secret data func (ct *ConfigTracker) getRefFromSecret(name string, namespace string) (*ConfigRef, error) { - secret, err := ct.KubeClient.CoreV1().Secrets(namespace).Get(name, metav1.GetOptions{}) + secret, err := ct.KubeClient.CoreV1().Secrets(namespace).Get(context.TODO(), name, metav1.GetOptions{}) if err != nil { return nil, fmt.Errorf("secret %s.%s get query error: %w", name, namespace, err) } @@ -98,14 +99,14 @@ func (ct *ConfigTracker) GetTargetConfigs(cd *flaggerv1.Canary) (map[string]Conf var cs []corev1.Container switch cd.Spec.TargetRef.Kind { case "Deployment": - targetDep, err := ct.KubeClient.AppsV1().Deployments(cd.Namespace).Get(targetName, metav1.GetOptions{}) + targetDep, err := ct.KubeClient.AppsV1().Deployments(cd.Namespace).Get(context.TODO(), targetName, metav1.GetOptions{}) if err != nil { return res, fmt.Errorf("deployment %s.%s get query error: %w", targetName, cd.Namespace, err) } vs = targetDep.Spec.Template.Spec.Volumes cs = targetDep.Spec.Template.Spec.Containers case "DaemonSet": - targetDae, err := ct.KubeClient.AppsV1().DaemonSets(cd.Namespace).Get(targetName, metav1.GetOptions{}) + targetDae, err := ct.KubeClient.AppsV1().DaemonSets(cd.Namespace).Get(context.TODO(), targetName, metav1.GetOptions{}) if err != nil { return res, fmt.Errorf("daemonset %s.%s get query error: %w", targetName, cd.Namespace, err) } @@ -270,7 +271,7 @@ func (ct *ConfigTracker) CreatePrimaryConfigs(cd *flaggerv1.Canary, refs map[str for _, ref := range refs { switch ref.Type { case ConfigRefMap: - config, err := ct.KubeClient.CoreV1().ConfigMaps(cd.Namespace).Get(ref.Name, metav1.GetOptions{}) + config, err := ct.KubeClient.CoreV1().ConfigMaps(cd.Namespace).Get(context.TODO(), ref.Name, metav1.GetOptions{}) if err != nil { return fmt.Errorf("configmap %s.%s get query failed : %w", ref.Name, cd.Name, err) } @@ -292,10 +293,10 @@ func (ct *ConfigTracker) CreatePrimaryConfigs(cd *flaggerv1.Canary, refs map[str } // update or insert primary ConfigMap - _, err = ct.KubeClient.CoreV1().ConfigMaps(cd.Namespace).Update(primaryConfigMap) + _, err = ct.KubeClient.CoreV1().ConfigMaps(cd.Namespace).Update(context.TODO(), primaryConfigMap, metav1.UpdateOptions{}) if err != nil { if errors.IsNotFound(err) { - _, err = ct.KubeClient.CoreV1().ConfigMaps(cd.Namespace).Create(primaryConfigMap) + _, err = ct.KubeClient.CoreV1().ConfigMaps(cd.Namespace).Create(context.TODO(), primaryConfigMap, metav1.CreateOptions{}) if err != nil { return fmt.Errorf("creating configmap %s.%s failed: %w", primaryConfigMap.Name, cd.Namespace, err) } @@ -307,7 +308,7 @@ func (ct *ConfigTracker) CreatePrimaryConfigs(cd *flaggerv1.Canary, refs map[str ct.Logger.With("canary", fmt.Sprintf("%s.%s", cd.Name, cd.Namespace)). Infof("ConfigMap %s synced", primaryConfigMap.GetName()) case ConfigRefSecret: - secret, err := ct.KubeClient.CoreV1().Secrets(cd.Namespace).Get(ref.Name, metav1.GetOptions{}) + secret, err := ct.KubeClient.CoreV1().Secrets(cd.Namespace).Get(context.TODO(), ref.Name, metav1.GetOptions{}) if err != nil { return fmt.Errorf("secret %s.%s get query failed : %w", ref.Name, cd.Name, err) } @@ -330,10 +331,10 @@ func (ct *ConfigTracker) CreatePrimaryConfigs(cd *flaggerv1.Canary, refs map[str } // update or insert primary Secret - _, err = ct.KubeClient.CoreV1().Secrets(cd.Namespace).Update(primarySecret) + _, err = ct.KubeClient.CoreV1().Secrets(cd.Namespace).Update(context.TODO(), primarySecret, metav1.UpdateOptions{}) if err != nil { if errors.IsNotFound(err) { - _, err = ct.KubeClient.CoreV1().Secrets(cd.Namespace).Create(primarySecret) + _, err = ct.KubeClient.CoreV1().Secrets(cd.Namespace).Create(context.TODO(), primarySecret, metav1.CreateOptions{}) if err != nil { return fmt.Errorf("creating secret %s.%s failed: %w", primarySecret.Name, cd.Namespace, err) } diff --git a/pkg/canary/config_tracker_test.go b/pkg/canary/config_tracker_test.go index e5f1affb..fb8d0d05 100644 --- a/pkg/canary/config_tracker_test.go +++ b/pkg/canary/config_tracker_test.go @@ -1,6 +1,7 @@ package canary import ( + "context" "testing" "github.com/stretchr/testify/assert" @@ -17,23 +18,23 @@ func TestConfigTracker_ConfigMaps(t *testing.T) { mocks.initializeCanary(t) - depPrimary, err := mocks.kubeClient.AppsV1().Deployments("default").Get("podinfo-primary", metav1.GetOptions{}) + depPrimary, err := mocks.kubeClient.AppsV1().Deployments("default").Get(context.TODO(), "podinfo-primary", metav1.GetOptions{}) require.NoError(t, err) configPrimaryVolName := depPrimary.Spec.Template.Spec.Volumes[0].VolumeSource.ConfigMap.LocalObjectReference.Name assert.Equal(t, "podinfo-config-vol-primary", configPrimaryVolName) - configPrimary, err := mocks.kubeClient.CoreV1().ConfigMaps("default").Get("podinfo-config-env-primary", metav1.GetOptions{}) + configPrimary, err := mocks.kubeClient.CoreV1().ConfigMaps("default").Get(context.TODO(), "podinfo-config-env-primary", metav1.GetOptions{}) if assert.NoError(t, err) { assert.Equal(t, configMap.Data["color"], configPrimary.Data["color"]) } - configPrimaryEnv, err := mocks.kubeClient.CoreV1().ConfigMaps("default").Get("podinfo-config-all-env-primary", metav1.GetOptions{}) + configPrimaryEnv, err := mocks.kubeClient.CoreV1().ConfigMaps("default").Get(context.TODO(), "podinfo-config-all-env-primary", metav1.GetOptions{}) if assert.NoError(t, err) { assert.Equal(t, configMap.Data["color"], configPrimaryEnv.Data["color"]) } - configPrimaryVol, err := mocks.kubeClient.CoreV1().ConfigMaps("default").Get("podinfo-config-vol-primary", metav1.GetOptions{}) + configPrimaryVol, err := mocks.kubeClient.CoreV1().ConfigMaps("default").Get(context.TODO(), "podinfo-config-vol-primary", metav1.GetOptions{}) if assert.NoError(t, err) { assert.Equal(t, configMap.Data["color"], configPrimaryVol.Data["color"]) } @@ -41,7 +42,7 @@ func TestConfigTracker_ConfigMaps(t *testing.T) { configProjectedName := depPrimary.Spec.Template.Spec.Volumes[2].VolumeSource.Projected.Sources[0].ConfigMap.Name assert.Equal(t, "podinfo-config-projected-primary", configProjectedName) - configPrimaryProjected, err := mocks.kubeClient.CoreV1().ConfigMaps("default").Get("podinfo-config-vol-primary", metav1.GetOptions{}) + configPrimaryProjected, err := mocks.kubeClient.CoreV1().ConfigMaps("default").Get(context.TODO(), "podinfo-config-vol-primary", metav1.GetOptions{}) if assert.NoError(t, err) { assert.Equal(t, configMapProjected.Data["color"], configPrimaryProjected.Data["color"]) } @@ -55,23 +56,23 @@ func TestConfigTracker_ConfigMaps(t *testing.T) { err := mocks.controller.Initialize(mocks.canary) require.NoError(t, err) - depPrimary, err := mocks.kubeClient.AppsV1().DaemonSets("default").Get("podinfo-primary", metav1.GetOptions{}) + depPrimary, err := mocks.kubeClient.AppsV1().DaemonSets("default").Get(context.TODO(), "podinfo-primary", metav1.GetOptions{}) require.NoError(t, err) configPrimaryVolName := depPrimary.Spec.Template.Spec.Volumes[0].VolumeSource.ConfigMap.LocalObjectReference.Name assert.Equal(t, "podinfo-config-vol-primary", configPrimaryVolName) - configPrimary, err := mocks.kubeClient.CoreV1().ConfigMaps("default").Get("podinfo-config-env-primary", metav1.GetOptions{}) + configPrimary, err := mocks.kubeClient.CoreV1().ConfigMaps("default").Get(context.TODO(), "podinfo-config-env-primary", metav1.GetOptions{}) if assert.NoError(t, err) { assert.Equal(t, configMap.Data["color"], configPrimary.Data["color"]) } - configPrimaryEnv, err := mocks.kubeClient.CoreV1().ConfigMaps("default").Get("podinfo-config-all-env-primary", metav1.GetOptions{}) + configPrimaryEnv, err := mocks.kubeClient.CoreV1().ConfigMaps("default").Get(context.TODO(), "podinfo-config-all-env-primary", metav1.GetOptions{}) if assert.NoError(t, err) { assert.Equal(t, configMap.Data["color"], configPrimaryEnv.Data["color"]) } - configPrimaryVol, err := mocks.kubeClient.CoreV1().ConfigMaps("default").Get("podinfo-config-vol-primary", metav1.GetOptions{}) + configPrimaryVol, err := mocks.kubeClient.CoreV1().ConfigMaps("default").Get(context.TODO(), "podinfo-config-vol-primary", metav1.GetOptions{}) if assert.NoError(t, err) { assert.Equal(t, configMap.Data["color"], configPrimaryVol.Data["color"]) } @@ -79,7 +80,7 @@ func TestConfigTracker_ConfigMaps(t *testing.T) { configProjectedName := depPrimary.Spec.Template.Spec.Volumes[2].VolumeSource.Projected.Sources[0].ConfigMap.Name assert.Equal(t, "podinfo-config-projected-primary", configProjectedName) - configPrimaryProjected, err := mocks.kubeClient.CoreV1().ConfigMaps("default").Get("podinfo-config-vol-primary", metav1.GetOptions{}) + configPrimaryProjected, err := mocks.kubeClient.CoreV1().ConfigMaps("default").Get(context.TODO(), "podinfo-config-vol-primary", metav1.GetOptions{}) if assert.NoError(t, err) { assert.Equal(t, configMapProjected.Data["color"], configPrimaryProjected.Data["color"]) } @@ -94,23 +95,23 @@ func TestConfigTracker_Secrets(t *testing.T) { mocks.initializeCanary(t) - depPrimary, err := mocks.kubeClient.AppsV1().Deployments("default").Get("podinfo-primary", metav1.GetOptions{}) + depPrimary, err := mocks.kubeClient.AppsV1().Deployments("default").Get(context.TODO(), "podinfo-primary", metav1.GetOptions{}) if assert.NoError(t, err) { assert.Equal(t, "podinfo-secret-vol-primary", depPrimary.Spec.Template.Spec.Volumes[1].VolumeSource.Secret.SecretName) } - secretPrimary, err := mocks.kubeClient.CoreV1().Secrets("default").Get("podinfo-secret-env-primary", metav1.GetOptions{}) + secretPrimary, err := mocks.kubeClient.CoreV1().Secrets("default").Get(context.TODO(), "podinfo-secret-env-primary", metav1.GetOptions{}) if assert.NoError(t, err) { assert.Equal(t, string(secret.Data["apiKey"]), string(secretPrimary.Data["apiKey"])) } - secretPrimaryEnv, err := mocks.kubeClient.CoreV1().Secrets("default").Get("podinfo-secret-all-env-primary", metav1.GetOptions{}) + secretPrimaryEnv, err := mocks.kubeClient.CoreV1().Secrets("default").Get(context.TODO(), "podinfo-secret-all-env-primary", metav1.GetOptions{}) if assert.NoError(t, err) { assert.Equal(t, string(secret.Data["apiKey"]), string(secretPrimaryEnv.Data["apiKey"])) } - secretPrimaryVol, err := mocks.kubeClient.CoreV1().Secrets("default").Get("podinfo-secret-vol-primary", metav1.GetOptions{}) + secretPrimaryVol, err := mocks.kubeClient.CoreV1().Secrets("default").Get(context.TODO(), "podinfo-secret-vol-primary", metav1.GetOptions{}) if assert.NoError(t, err) { assert.Equal(t, string(secret.Data["apiKey"]), string(secretPrimaryVol.Data["apiKey"])) } @@ -118,7 +119,7 @@ func TestConfigTracker_Secrets(t *testing.T) { secretProjectedName := depPrimary.Spec.Template.Spec.Volumes[2].VolumeSource.Projected.Sources[1].Secret.Name assert.Equal(t, "podinfo-secret-projected-primary", secretProjectedName) - secretPrimaryProjected, err := mocks.kubeClient.CoreV1().Secrets("default").Get("podinfo-secret-projected-primary", metav1.GetOptions{}) + secretPrimaryProjected, err := mocks.kubeClient.CoreV1().Secrets("default").Get(context.TODO(), "podinfo-secret-projected-primary", metav1.GetOptions{}) if assert.NoError(t, err) { assert.Equal(t, string(secretProjected.Data["apiKey"]), string(secretPrimaryProjected.Data["apiKey"])) } @@ -131,23 +132,23 @@ func TestConfigTracker_Secrets(t *testing.T) { mocks.controller.Initialize(mocks.canary) - daePrimary, err := mocks.kubeClient.AppsV1().DaemonSets("default").Get("podinfo-primary", metav1.GetOptions{}) + daePrimary, err := mocks.kubeClient.AppsV1().DaemonSets("default").Get(context.TODO(), "podinfo-primary", metav1.GetOptions{}) if assert.NoError(t, err) { assert.Equal(t, "podinfo-secret-vol-primary", daePrimary.Spec.Template.Spec.Volumes[1].VolumeSource.Secret.SecretName) } - secretPrimary, err := mocks.kubeClient.CoreV1().Secrets("default").Get("podinfo-secret-env-primary", metav1.GetOptions{}) + secretPrimary, err := mocks.kubeClient.CoreV1().Secrets("default").Get(context.TODO(), "podinfo-secret-env-primary", metav1.GetOptions{}) if assert.NoError(t, err) { assert.Equal(t, string(secret.Data["apiKey"]), string(secretPrimary.Data["apiKey"])) } - secretPrimaryEnv, err := mocks.kubeClient.CoreV1().Secrets("default").Get("podinfo-secret-all-env-primary", metav1.GetOptions{}) + secretPrimaryEnv, err := mocks.kubeClient.CoreV1().Secrets("default").Get(context.TODO(), "podinfo-secret-all-env-primary", metav1.GetOptions{}) if assert.NoError(t, err) { assert.Equal(t, string(secret.Data["apiKey"]), string(secretPrimaryEnv.Data["apiKey"])) } - secretPrimaryVol, err := mocks.kubeClient.CoreV1().Secrets("default").Get("podinfo-secret-vol-primary", metav1.GetOptions{}) + secretPrimaryVol, err := mocks.kubeClient.CoreV1().Secrets("default").Get(context.TODO(), "podinfo-secret-vol-primary", metav1.GetOptions{}) if assert.NoError(t, err) { assert.Equal(t, string(secret.Data["apiKey"]), string(secretPrimaryVol.Data["apiKey"])) } @@ -155,7 +156,7 @@ func TestConfigTracker_Secrets(t *testing.T) { secretProjectedName := daePrimary.Spec.Template.Spec.Volumes[2].VolumeSource.Projected.Sources[1].Secret.Name assert.Equal(t, "podinfo-secret-projected-primary", secretProjectedName) - secretPrimaryProjected, err := mocks.kubeClient.CoreV1().Secrets("default").Get("podinfo-secret-projected-primary", metav1.GetOptions{}) + secretPrimaryProjected, err := mocks.kubeClient.CoreV1().Secrets("default").Get(context.TODO(), "podinfo-secret-projected-primary", metav1.GetOptions{}) if assert.NoError(t, err) { assert.Equal(t, string(secretProjected.Data["apiKey"]), string(secretPrimaryProjected.Data["apiKey"])) } diff --git a/pkg/canary/daemonset_controller.go b/pkg/canary/daemonset_controller.go index ea94fe79..7e0972cd 100644 --- a/pkg/canary/daemonset_controller.go +++ b/pkg/canary/daemonset_controller.go @@ -1,6 +1,7 @@ package canary import ( + "context" "fmt" "go.uber.org/zap" @@ -30,7 +31,7 @@ type DaemonSetController struct { func (c *DaemonSetController) ScaleToZero(cd *flaggerv1.Canary) error { targetName := cd.Spec.TargetRef.Name - dae, err := c.kubeClient.AppsV1().DaemonSets(cd.Namespace).Get(targetName, metav1.GetOptions{}) + dae, err := c.kubeClient.AppsV1().DaemonSets(cd.Namespace).Get(context.TODO(), targetName, metav1.GetOptions{}) if err != nil { return fmt.Errorf("daemonset %s.%s get query error: %w", targetName, cd.Namespace, err) } @@ -46,7 +47,7 @@ func (c *DaemonSetController) ScaleToZero(cd *flaggerv1.Canary) error { daeCopy.Spec.Template.Spec.NodeSelector[k] = v } - _, err = c.kubeClient.AppsV1().DaemonSets(dae.Namespace).Update(daeCopy) + _, err = c.kubeClient.AppsV1().DaemonSets(dae.Namespace).Update(context.TODO(), daeCopy, metav1.UpdateOptions{}) if err != nil { return fmt.Errorf("updating daemonset %s.%s failed: %w", daeCopy.GetName(), daeCopy.Namespace, err) } @@ -55,7 +56,7 @@ func (c *DaemonSetController) ScaleToZero(cd *flaggerv1.Canary) error { func (c *DaemonSetController) ScaleFromZero(cd *flaggerv1.Canary) error { targetName := cd.Spec.TargetRef.Name - dep, err := c.kubeClient.AppsV1().DaemonSets(cd.Namespace).Get(targetName, metav1.GetOptions{}) + dep, err := c.kubeClient.AppsV1().DaemonSets(cd.Namespace).Get(context.TODO(), targetName, metav1.GetOptions{}) if err != nil { return fmt.Errorf("daemonset %s.%s query error: %w", targetName, cd.Namespace, err) } @@ -65,7 +66,7 @@ func (c *DaemonSetController) ScaleFromZero(cd *flaggerv1.Canary) error { delete(depCopy.Spec.Template.Spec.NodeSelector, k) } - _, err = c.kubeClient.AppsV1().DaemonSets(dep.Namespace).Update(depCopy) + _, err = c.kubeClient.AppsV1().DaemonSets(dep.Namespace).Update(context.TODO(), depCopy, metav1.UpdateOptions{}) if err != nil { return fmt.Errorf("scaling up daemonset %s.%s failed: %w", depCopy.GetName(), depCopy.Namespace, err) } @@ -101,7 +102,7 @@ func (c *DaemonSetController) Promote(cd *flaggerv1.Canary) error { targetName := cd.Spec.TargetRef.Name primaryName := fmt.Sprintf("%s-primary", targetName) - canary, err := c.kubeClient.AppsV1().DaemonSets(cd.Namespace).Get(targetName, metav1.GetOptions{}) + canary, err := c.kubeClient.AppsV1().DaemonSets(cd.Namespace).Get(context.TODO(), targetName, metav1.GetOptions{}) if err != nil { return fmt.Errorf("damonset %s.%s get query error: %v", targetName, cd.Namespace, err) } @@ -111,7 +112,7 @@ func (c *DaemonSetController) Promote(cd *flaggerv1.Canary) error { return fmt.Errorf("getSelectorLabel failed: %w", err) } - primary, err := c.kubeClient.AppsV1().DaemonSets(cd.Namespace).Get(primaryName, metav1.GetOptions{}) + primary, err := c.kubeClient.AppsV1().DaemonSets(cd.Namespace).Get(context.TODO(), primaryName, metav1.GetOptions{}) if err != nil { return fmt.Errorf("daemonset %s.%s get query error: %w", primaryName, cd.Namespace, err) } @@ -148,7 +149,7 @@ func (c *DaemonSetController) Promote(cd *flaggerv1.Canary) error { primaryCopy.Spec.Template.Labels = makePrimaryLabels(canary.Spec.Template.Labels, primaryName, label) // apply update - _, err = c.kubeClient.AppsV1().DaemonSets(cd.Namespace).Update(primaryCopy) + _, err = c.kubeClient.AppsV1().DaemonSets(cd.Namespace).Update(context.TODO(), primaryCopy, metav1.UpdateOptions{}) if err != nil { return fmt.Errorf("updating daemonset %s.%s template spec failed: %w", primaryCopy.GetName(), primaryCopy.Namespace, err) @@ -159,7 +160,7 @@ func (c *DaemonSetController) Promote(cd *flaggerv1.Canary) error { // HasTargetChanged returns true if the canary DaemonSet pod spec has changed func (c *DaemonSetController) HasTargetChanged(cd *flaggerv1.Canary) (bool, error) { targetName := cd.Spec.TargetRef.Name - canary, err := c.kubeClient.AppsV1().DaemonSets(cd.Namespace).Get(targetName, metav1.GetOptions{}) + canary, err := c.kubeClient.AppsV1().DaemonSets(cd.Namespace).Get(context.TODO(), targetName, metav1.GetOptions{}) if err != nil { return false, fmt.Errorf("daemonset %s.%s get query error: %w", targetName, cd.Namespace, err) } @@ -181,7 +182,7 @@ func (c *DaemonSetController) HasTargetChanged(cd *flaggerv1.Canary) (bool, erro func (c *DaemonSetController) GetMetadata(cd *flaggerv1.Canary) (string, map[string]int32, error) { targetName := cd.Spec.TargetRef.Name - canaryDae, err := c.kubeClient.AppsV1().DaemonSets(cd.Namespace).Get(targetName, metav1.GetOptions{}) + canaryDae, err := c.kubeClient.AppsV1().DaemonSets(cd.Namespace).Get(context.TODO(), targetName, metav1.GetOptions{}) if err != nil { return "", nil, fmt.Errorf("daemonset %s.%s get query error: %w", targetName, cd.Namespace, err) } @@ -202,7 +203,7 @@ func (c *DaemonSetController) createPrimaryDaemonSet(cd *flaggerv1.Canary) error targetName := cd.Spec.TargetRef.Name primaryName := fmt.Sprintf("%s-primary", cd.Spec.TargetRef.Name) - canaryDae, err := c.kubeClient.AppsV1().DaemonSets(cd.Namespace).Get(targetName, metav1.GetOptions{}) + canaryDae, err := c.kubeClient.AppsV1().DaemonSets(cd.Namespace).Get(context.TODO(), targetName, metav1.GetOptions{}) if err != nil { return fmt.Errorf("daemonset %s.%s get query error: %w", targetName, cd.Namespace, err) } @@ -218,7 +219,7 @@ func (c *DaemonSetController) createPrimaryDaemonSet(cd *flaggerv1.Canary) error return fmt.Errorf("getSelectorLabel failed: %w", err) } - primaryDae, err := c.kubeClient.AppsV1().DaemonSets(cd.Namespace).Get(primaryName, metav1.GetOptions{}) + primaryDae, err := c.kubeClient.AppsV1().DaemonSets(cd.Namespace).Get(context.TODO(), primaryName, metav1.GetOptions{}) if errors.IsNotFound(err) { // create primary secrets and config maps configRefs, err := c.configTracker.GetTargetConfigs(cd) @@ -269,7 +270,7 @@ func (c *DaemonSetController) createPrimaryDaemonSet(cd *flaggerv1.Canary) error }, } - _, err = c.kubeClient.AppsV1().DaemonSets(cd.Namespace).Create(primaryDae) + _, err = c.kubeClient.AppsV1().DaemonSets(cd.Namespace).Create(context.TODO(), primaryDae, metav1.CreateOptions{}) if err != nil { return fmt.Errorf("creating daemonset %s.%s failed: %w", primaryDae.Name, cd.Namespace, err) } diff --git a/pkg/canary/daemonset_controller_test.go b/pkg/canary/daemonset_controller_test.go index cddfcd31..d7c67e88 100644 --- a/pkg/canary/daemonset_controller_test.go +++ b/pkg/canary/daemonset_controller_test.go @@ -1,6 +1,7 @@ package canary import ( + "context" "testing" "github.com/stretchr/testify/assert" @@ -18,7 +19,7 @@ func TestDaemonSetController_Sync(t *testing.T) { err := mocks.controller.Initialize(mocks.canary) require.NoError(t, err) - daePrimary, err := mocks.kubeClient.AppsV1().DaemonSets("default").Get("podinfo-primary", metav1.GetOptions{}) + daePrimary, err := mocks.kubeClient.AppsV1().DaemonSets("default").Get(context.TODO(), "podinfo-primary", metav1.GetOptions{}) require.NoError(t, err) dae := newDaemonSetControllerTestPodInfo() @@ -33,24 +34,24 @@ func TestDaemonSetController_Promote(t *testing.T) { require.NoError(t, err) dae2 := newDaemonSetControllerTestPodInfoV2() - _, err = mocks.kubeClient.AppsV1().DaemonSets("default").Update(dae2) + _, err = mocks.kubeClient.AppsV1().DaemonSets("default").Update(context.TODO(), dae2, metav1.UpdateOptions{}) require.NoError(t, err) config2 := newDaemonSetControllerTestConfigMapV2() - _, err = mocks.kubeClient.CoreV1().ConfigMaps("default").Update(config2) + _, err = mocks.kubeClient.CoreV1().ConfigMaps("default").Update(context.TODO(), config2, metav1.UpdateOptions{}) require.NoError(t, err) err = mocks.controller.Promote(mocks.canary) require.NoError(t, err) - daePrimary, err := mocks.kubeClient.AppsV1().DaemonSets("default").Get("podinfo-primary", metav1.GetOptions{}) + daePrimary, err := mocks.kubeClient.AppsV1().DaemonSets("default").Get(context.TODO(), "podinfo-primary", metav1.GetOptions{}) require.NoError(t, err) primaryImage := daePrimary.Spec.Template.Spec.Containers[0].Image sourceImage := dae2.Spec.Template.Spec.Containers[0].Image assert.Equal(t, primaryImage, sourceImage) - configPrimary, err := mocks.kubeClient.CoreV1().ConfigMaps("default").Get("podinfo-config-env-primary", metav1.GetOptions{}) + configPrimary, err := mocks.kubeClient.CoreV1().ConfigMaps("default").Get(context.TODO(), "podinfo-config-env-primary", metav1.GetOptions{}) if assert.NoError(t, err) { assert.Equal(t, configPrimary.Data["color"], config2.Data["color"]) } @@ -63,10 +64,10 @@ func TestDaemonSetController_NoConfigTracking(t *testing.T) { err := mocks.controller.Initialize(mocks.canary) require.NoError(t, err) - daePrimary, err := mocks.kubeClient.AppsV1().DaemonSets("default").Get("podinfo-primary", metav1.GetOptions{}) + daePrimary, err := mocks.kubeClient.AppsV1().DaemonSets("default").Get(context.TODO(), "podinfo-primary", metav1.GetOptions{}) require.NoError(t, err) - _, err = mocks.kubeClient.CoreV1().ConfigMaps("default").Get("podinfo-config-env-primary", metav1.GetOptions{}) + _, err = mocks.kubeClient.CoreV1().ConfigMaps("default").Get(context.TODO(), "podinfo-config-env-primary", metav1.GetOptions{}) require.True(t, errors.IsNotFound(err), "Primary ConfigMap shouldn't have been created") configName := daePrimary.Spec.Template.Spec.Volumes[0].VolumeSource.ConfigMap.LocalObjectReference.Name @@ -79,20 +80,20 @@ func TestDaemonSetController_HasTargetChanged(t *testing.T) { require.NoError(t, err) // save last applied hash - canary, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get("podinfo", metav1.GetOptions{}) + canary, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) err = mocks.controller.SyncStatus(canary, flaggerv1.CanaryStatus{Phase: flaggerv1.CanaryPhaseInitializing}) require.NoError(t, err) // save last promoted hash - canary, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get("podinfo", metav1.GetOptions{}) + canary, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) err = mocks.controller.SetStatusPhase(canary, flaggerv1.CanaryPhaseInitialized) require.NoError(t, err) - dep, err := mocks.kubeClient.AppsV1().DaemonSets("default").Get("podinfo", metav1.GetOptions{}) + dep, err := mocks.kubeClient.AppsV1().DaemonSets("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) depClone := dep.DeepCopy() @@ -103,10 +104,10 @@ func TestDaemonSetController_HasTargetChanged(t *testing.T) { } // update pod spec - _, err = mocks.kubeClient.AppsV1().DaemonSets("default").Update(depClone) + _, err = mocks.kubeClient.AppsV1().DaemonSets("default").Update(context.TODO(), depClone, metav1.UpdateOptions{}) require.NoError(t, err) - canary, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get("podinfo", metav1.GetOptions{}) + canary, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) // detect change in last applied spec @@ -118,7 +119,7 @@ func TestDaemonSetController_HasTargetChanged(t *testing.T) { err = mocks.controller.SyncStatus(canary, flaggerv1.CanaryStatus{Phase: flaggerv1.CanaryPhaseProgressing}) require.NoError(t, err) - dep, err = mocks.kubeClient.AppsV1().DaemonSets("default").Get("podinfo", metav1.GetOptions{}) + dep, err = mocks.kubeClient.AppsV1().DaemonSets("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) depClone = dep.DeepCopy() @@ -129,10 +130,10 @@ func TestDaemonSetController_HasTargetChanged(t *testing.T) { } // update pod spec - _, err = mocks.kubeClient.AppsV1().DaemonSets("default").Update(depClone) + _, err = mocks.kubeClient.AppsV1().DaemonSets("default").Update(context.TODO(), depClone, metav1.UpdateOptions{}) require.NoError(t, err) - canary, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get("podinfo", metav1.GetOptions{}) + canary, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) // ignore change as hash should be the same with last promoted @@ -148,10 +149,10 @@ func TestDaemonSetController_HasTargetChanged(t *testing.T) { } // update pod spec - _, err = mocks.kubeClient.AppsV1().DaemonSets("default").Update(depClone) + _, err = mocks.kubeClient.AppsV1().DaemonSets("default").Update(context.TODO(), depClone, metav1.UpdateOptions{}) require.NoError(t, err) - canary, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get("podinfo", metav1.GetOptions{}) + canary, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) // detect change @@ -169,7 +170,7 @@ func TestDaemonSetController_Scale(t *testing.T) { err = mocks.controller.ScaleToZero(mocks.canary) require.NoError(t, err) - c, err := mocks.kubeClient.AppsV1().DaemonSets("default").Get("podinfo", metav1.GetOptions{}) + c, err := mocks.kubeClient.AppsV1().DaemonSets("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) for k := range daemonSetScaleDownNodeSelector { @@ -185,7 +186,7 @@ func TestDaemonSetController_Scale(t *testing.T) { err = mocks.controller.ScaleFromZero(mocks.canary) require.NoError(t, err) - c, err := mocks.kubeClient.AppsV1().DaemonSets("default").Get("podinfo", metav1.GetOptions{}) + c, err := mocks.kubeClient.AppsV1().DaemonSets("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) for k := range daemonSetScaleDownNodeSelector { @@ -203,7 +204,7 @@ func TestDaemonSetController_Finalize(t *testing.T) { err = mocks.controller.Finalize(mocks.canary) require.NoError(t, err) - dep, err := mocks.kubeClient.AppsV1().DaemonSets("default").Get("podinfo", metav1.GetOptions{}) + dep, err := mocks.kubeClient.AppsV1().DaemonSets("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) _, ok := dep.Spec.Template.Spec.NodeSelector["flagger.app/scale-to-zero"] diff --git a/pkg/canary/daemonset_ready.go b/pkg/canary/daemonset_ready.go index a8790ba9..0a5e6d5f 100644 --- a/pkg/canary/daemonset_ready.go +++ b/pkg/canary/daemonset_ready.go @@ -1,6 +1,7 @@ package canary import ( + "context" "fmt" "time" @@ -14,7 +15,7 @@ import ( // the daemonset is in the middle of a rolling update func (c *DaemonSetController) IsPrimaryReady(cd *flaggerv1.Canary) error { primaryName := fmt.Sprintf("%s-primary", cd.Spec.TargetRef.Name) - primary, err := c.kubeClient.AppsV1().DaemonSets(cd.Namespace).Get(primaryName, metav1.GetOptions{}) + primary, err := c.kubeClient.AppsV1().DaemonSets(cd.Namespace).Get(context.TODO(), primaryName, metav1.GetOptions{}) if err != nil { return fmt.Errorf("daemonset %s.%s get query error: %w", primaryName, cd.Namespace, err) } @@ -30,7 +31,7 @@ func (c *DaemonSetController) IsPrimaryReady(cd *flaggerv1.Canary) error { // the daemonset is in the middle of a rolling update func (c *DaemonSetController) IsCanaryReady(cd *flaggerv1.Canary) (bool, error) { targetName := cd.Spec.TargetRef.Name - canary, err := c.kubeClient.AppsV1().DaemonSets(cd.Namespace).Get(targetName, metav1.GetOptions{}) + canary, err := c.kubeClient.AppsV1().DaemonSets(cd.Namespace).Get(context.TODO(), targetName, metav1.GetOptions{}) if err != nil { return true, fmt.Errorf("daemonset %s.%s get query error: %w", targetName, cd.Namespace, err) } diff --git a/pkg/canary/daemonset_status.go b/pkg/canary/daemonset_status.go index dd558f96..f15a0ec9 100644 --- a/pkg/canary/daemonset_status.go +++ b/pkg/canary/daemonset_status.go @@ -1,6 +1,7 @@ package canary import ( + "context" "fmt" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -10,7 +11,7 @@ import ( // SyncStatus encodes the canary pod spec and updates the canary status func (c *DaemonSetController) SyncStatus(cd *flaggerv1.Canary, status flaggerv1.CanaryStatus) error { - dae, err := c.kubeClient.AppsV1().DaemonSets(cd.Namespace).Get(cd.Spec.TargetRef.Name, metav1.GetOptions{}) + dae, err := c.kubeClient.AppsV1().DaemonSets(cd.Namespace).Get(context.TODO(), cd.Spec.TargetRef.Name, metav1.GetOptions{}) if err != nil { return fmt.Errorf("daemonset %s.%s get query error: %w", cd.Spec.TargetRef.Name, cd.Namespace, err) } diff --git a/pkg/canary/daemonset_status_test.go b/pkg/canary/daemonset_status_test.go index 42e449a8..12f822d5 100644 --- a/pkg/canary/daemonset_status_test.go +++ b/pkg/canary/daemonset_status_test.go @@ -1,6 +1,7 @@ package canary import ( + "context" "testing" "github.com/stretchr/testify/assert" @@ -22,7 +23,7 @@ func TestDaemonSetController_SyncStatus(t *testing.T) { err = mocks.controller.SyncStatus(mocks.canary, status) require.NoError(t, err) - res, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get("podinfo", metav1.GetOptions{}) + res, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) assert.Equal(t, status.Phase, res.Status.Phase) assert.Equal(t, status.FailedChecks, res.Status.FailedChecks) @@ -42,7 +43,7 @@ func TestDaemonSetController_SetFailedChecks(t *testing.T) { err = mocks.controller.SetStatusFailedChecks(mocks.canary, 1) require.NoError(t, err) - res, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get("podinfo", metav1.GetOptions{}) + res, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) assert.Equal(t, 1, res.Status.FailedChecks) } @@ -55,7 +56,7 @@ func TestDaemonSetController_SetState(t *testing.T) { err = mocks.controller.SetStatusPhase(mocks.canary, flaggerv1.CanaryPhaseProgressing) require.NoError(t, err) - res, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get("podinfo", metav1.GetOptions{}) + res, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) assert.Equal(t, flaggerv1.CanaryPhaseProgressing, res.Status.Phase) } diff --git a/pkg/canary/deployment_controller.go b/pkg/canary/deployment_controller.go index 6e3e2984..a9d0cd5f 100644 --- a/pkg/canary/deployment_controller.go +++ b/pkg/canary/deployment_controller.go @@ -1,6 +1,7 @@ package canary import ( + "context" "fmt" "github.com/google/go-cmp/cmp" @@ -66,7 +67,7 @@ func (c *DeploymentController) Promote(cd *flaggerv1.Canary) error { targetName := cd.Spec.TargetRef.Name primaryName := fmt.Sprintf("%s-primary", targetName) - canary, err := c.kubeClient.AppsV1().Deployments(cd.Namespace).Get(targetName, metav1.GetOptions{}) + canary, err := c.kubeClient.AppsV1().Deployments(cd.Namespace).Get(context.TODO(), targetName, metav1.GetOptions{}) if err != nil { return fmt.Errorf("deployment %s.%s get query error: %w", targetName, cd.Namespace, err) } @@ -76,7 +77,7 @@ func (c *DeploymentController) Promote(cd *flaggerv1.Canary) error { return fmt.Errorf("getSelectorLabel failed: %w", err) } - primary, err := c.kubeClient.AppsV1().Deployments(cd.Namespace).Get(primaryName, metav1.GetOptions{}) + primary, err := c.kubeClient.AppsV1().Deployments(cd.Namespace).Get(context.TODO(), primaryName, metav1.GetOptions{}) if err != nil { return fmt.Errorf("deployment %s.%s get query error: %w", primaryName, cd.Namespace, err) } @@ -109,7 +110,7 @@ func (c *DeploymentController) Promote(cd *flaggerv1.Canary) error { primaryCopy.Spec.Template.Labels = makePrimaryLabels(canary.Spec.Template.Labels, primaryName, label) // apply update - _, err = c.kubeClient.AppsV1().Deployments(cd.Namespace).Update(primaryCopy) + _, err = c.kubeClient.AppsV1().Deployments(cd.Namespace).Update(context.TODO(), primaryCopy, metav1.UpdateOptions{}) if err != nil { return fmt.Errorf("updating deployment %s.%s template spec failed: %w", primaryCopy.GetName(), primaryCopy.Namespace, err) @@ -132,7 +133,7 @@ func (c *DeploymentController) Promote(cd *flaggerv1.Canary) error { // HasTargetChanged returns true if the canary deployment pod spec has changed func (c *DeploymentController) HasTargetChanged(cd *flaggerv1.Canary) (bool, error) { targetName := cd.Spec.TargetRef.Name - canary, err := c.kubeClient.AppsV1().Deployments(cd.Namespace).Get(targetName, metav1.GetOptions{}) + canary, err := c.kubeClient.AppsV1().Deployments(cd.Namespace).Get(context.TODO(), targetName, metav1.GetOptions{}) if err != nil { return false, fmt.Errorf("deployment %s.%s get query error: %w", targetName, cd.Namespace, err) } @@ -143,7 +144,7 @@ func (c *DeploymentController) HasTargetChanged(cd *flaggerv1.Canary) (bool, err // Scale sets the canary deployment replicas func (c *DeploymentController) ScaleToZero(cd *flaggerv1.Canary) error { targetName := cd.Spec.TargetRef.Name - dep, err := c.kubeClient.AppsV1().Deployments(cd.Namespace).Get(targetName, metav1.GetOptions{}) + dep, err := c.kubeClient.AppsV1().Deployments(cd.Namespace).Get(context.TODO(), targetName, metav1.GetOptions{}) if err != nil { return fmt.Errorf("deployment %s.%s get query error: %w", targetName, cd.Namespace, err) } @@ -151,7 +152,7 @@ func (c *DeploymentController) ScaleToZero(cd *flaggerv1.Canary) error { depCopy := dep.DeepCopy() depCopy.Spec.Replicas = int32p(0) - _, err = c.kubeClient.AppsV1().Deployments(dep.Namespace).Update(depCopy) + _, err = c.kubeClient.AppsV1().Deployments(dep.Namespace).Update(context.TODO(), depCopy, metav1.UpdateOptions{}) if err != nil { return fmt.Errorf("deployment %s.%s update query error: %w", targetName, cd.Namespace, err) } @@ -160,7 +161,7 @@ func (c *DeploymentController) ScaleToZero(cd *flaggerv1.Canary) error { func (c *DeploymentController) ScaleFromZero(cd *flaggerv1.Canary) error { targetName := cd.Spec.TargetRef.Name - dep, err := c.kubeClient.AppsV1().Deployments(cd.Namespace).Get(targetName, metav1.GetOptions{}) + dep, err := c.kubeClient.AppsV1().Deployments(cd.Namespace).Get(context.TODO(), targetName, metav1.GetOptions{}) if err != nil { return fmt.Errorf("deployment %s.%s get query error: %w", targetName, cd.Namespace, err) } @@ -172,7 +173,7 @@ func (c *DeploymentController) ScaleFromZero(cd *flaggerv1.Canary) error { depCopy := dep.DeepCopy() depCopy.Spec.Replicas = replicas - _, err = c.kubeClient.AppsV1().Deployments(dep.Namespace).Update(depCopy) + _, err = c.kubeClient.AppsV1().Deployments(dep.Namespace).Update(context.TODO(), depCopy, metav1.UpdateOptions{}) if err != nil { return fmt.Errorf("scaling up %s.%s to %v failed: %v", depCopy.GetName(), depCopy.Namespace, replicas, err) } @@ -183,7 +184,7 @@ func (c *DeploymentController) ScaleFromZero(cd *flaggerv1.Canary) error { func (c *DeploymentController) GetMetadata(cd *flaggerv1.Canary) (string, map[string]int32, error) { targetName := cd.Spec.TargetRef.Name - canaryDep, err := c.kubeClient.AppsV1().Deployments(cd.Namespace).Get(targetName, metav1.GetOptions{}) + canaryDep, err := c.kubeClient.AppsV1().Deployments(cd.Namespace).Get(context.TODO(), targetName, metav1.GetOptions{}) if err != nil { return "", nil, fmt.Errorf("deployment %s.%s get query error: %w", targetName, cd.Namespace, err) } @@ -204,7 +205,7 @@ func (c *DeploymentController) createPrimaryDeployment(cd *flaggerv1.Canary) err targetName := cd.Spec.TargetRef.Name primaryName := fmt.Sprintf("%s-primary", cd.Spec.TargetRef.Name) - canaryDep, err := c.kubeClient.AppsV1().Deployments(cd.Namespace).Get(targetName, metav1.GetOptions{}) + canaryDep, err := c.kubeClient.AppsV1().Deployments(cd.Namespace).Get(context.TODO(), targetName, metav1.GetOptions{}) if err != nil { return fmt.Errorf("deplyoment %s.%s get query error: %w", targetName, cd.Namespace, err) } @@ -214,7 +215,7 @@ func (c *DeploymentController) createPrimaryDeployment(cd *flaggerv1.Canary) err return fmt.Errorf("getSelectorLabel failed: %w", err) } - primaryDep, err := c.kubeClient.AppsV1().Deployments(cd.Namespace).Get(primaryName, metav1.GetOptions{}) + primaryDep, err := c.kubeClient.AppsV1().Deployments(cd.Namespace).Get(context.TODO(), primaryName, metav1.GetOptions{}) if errors.IsNotFound(err) { // create primary secrets and config maps configRefs, err := c.configTracker.GetTargetConfigs(cd) @@ -272,7 +273,7 @@ func (c *DeploymentController) createPrimaryDeployment(cd *flaggerv1.Canary) err }, } - _, err = c.kubeClient.AppsV1().Deployments(cd.Namespace).Create(primaryDep) + _, err = c.kubeClient.AppsV1().Deployments(cd.Namespace).Create(context.TODO(), primaryDep, metav1.CreateOptions{}) if err != nil { return fmt.Errorf("creating deployment %s.%s failed: %w", primaryDep.Name, cd.Namespace, err) } @@ -286,7 +287,7 @@ func (c *DeploymentController) createPrimaryDeployment(cd *flaggerv1.Canary) err func (c *DeploymentController) reconcilePrimaryHpa(cd *flaggerv1.Canary, init bool) error { primaryName := fmt.Sprintf("%s-primary", cd.Spec.TargetRef.Name) - hpa, err := c.kubeClient.AutoscalingV2beta1().HorizontalPodAutoscalers(cd.Namespace).Get(cd.Spec.AutoscalerRef.Name, metav1.GetOptions{}) + hpa, err := c.kubeClient.AutoscalingV2beta1().HorizontalPodAutoscalers(cd.Namespace).Get(context.TODO(), cd.Spec.AutoscalerRef.Name, metav1.GetOptions{}) if err != nil { return fmt.Errorf("HorizontalPodAutoscaler %s.%s get query error: %w", cd.Spec.AutoscalerRef.Name, cd.Namespace, err) @@ -304,7 +305,7 @@ func (c *DeploymentController) reconcilePrimaryHpa(cd *flaggerv1.Canary, init bo } primaryHpaName := fmt.Sprintf("%s-primary", cd.Spec.AutoscalerRef.Name) - primaryHpa, err := c.kubeClient.AutoscalingV2beta1().HorizontalPodAutoscalers(cd.Namespace).Get(primaryHpaName, metav1.GetOptions{}) + primaryHpa, err := c.kubeClient.AutoscalingV2beta1().HorizontalPodAutoscalers(cd.Namespace).Get(context.TODO(), primaryHpaName, metav1.GetOptions{}) // create HPA if errors.IsNotFound(err) { @@ -324,7 +325,7 @@ func (c *DeploymentController) reconcilePrimaryHpa(cd *flaggerv1.Canary, init bo Spec: hpaSpec, } - _, err = c.kubeClient.AutoscalingV2beta1().HorizontalPodAutoscalers(cd.Namespace).Create(primaryHpa) + _, err = c.kubeClient.AutoscalingV2beta1().HorizontalPodAutoscalers(cd.Namespace).Create(context.TODO(), primaryHpa, metav1.CreateOptions{}) if err != nil { return fmt.Errorf("creating HorizontalPodAutoscaler %s.%s failed: %w", primaryHpa.Name, primaryHpa.Namespace, err) @@ -347,7 +348,7 @@ func (c *DeploymentController) reconcilePrimaryHpa(cd *flaggerv1.Canary, init bo hpaClone.Spec.MinReplicas = hpaSpec.MinReplicas hpaClone.Spec.Metrics = hpaSpec.Metrics - _, err := c.kubeClient.AutoscalingV2beta1().HorizontalPodAutoscalers(cd.Namespace).Update(hpaClone) + _, err := c.kubeClient.AutoscalingV2beta1().HorizontalPodAutoscalers(cd.Namespace).Update(context.TODO(), hpaClone, metav1.UpdateOptions{}) if err != nil { return fmt.Errorf("updating HorizontalPodAutoscaler %s.%s failed: %w", hpaClone.Name, hpaClone.Namespace, err) @@ -383,14 +384,14 @@ func (c *DeploymentController) HaveDependenciesChanged(cd *flaggerv1.Canary) (bo func (c *DeploymentController) Finalize(cd *flaggerv1.Canary) error { // get ref deployment - refDep, err := c.kubeClient.AppsV1().Deployments(cd.Namespace).Get(cd.Spec.TargetRef.Name, metav1.GetOptions{}) + refDep, err := c.kubeClient.AppsV1().Deployments(cd.Namespace).Get(context.TODO(), cd.Spec.TargetRef.Name, metav1.GetOptions{}) if err != nil { return fmt.Errorf("deplyoment %s.%s get query error: %w", cd.Spec.TargetRef.Name, cd.Namespace, err) } // get primary if possible, if not scale from zero primaryName := fmt.Sprintf("%s-primary", cd.Spec.TargetRef.Name) - primaryDep, err := c.kubeClient.AppsV1().Deployments(cd.Namespace).Get(primaryName, metav1.GetOptions{}) + primaryDep, err := c.kubeClient.AppsV1().Deployments(cd.Namespace).Get(context.TODO(), primaryName, metav1.GetOptions{}) if err != nil { if errors.IsNotFound(err) { if err := c.ScaleFromZero(cd); err != nil { @@ -414,14 +415,14 @@ func (c *DeploymentController) Finalize(cd *flaggerv1.Canary) error { // Scale sets the canary deployment replicas func (c *DeploymentController) scale(cd *flaggerv1.Canary, replicas int32) error { targetName := cd.Spec.TargetRef.Name - dep, err := c.kubeClient.AppsV1().Deployments(cd.Namespace).Get(targetName, metav1.GetOptions{}) + dep, err := c.kubeClient.AppsV1().Deployments(cd.Namespace).Get(context.TODO(), targetName, metav1.GetOptions{}) if err != nil { return fmt.Errorf("deployment %s.%s query error: %w", targetName, cd.Namespace, err) } depCopy := dep.DeepCopy() depCopy.Spec.Replicas = int32p(replicas) - _, err = c.kubeClient.AppsV1().Deployments(dep.Namespace).Update(depCopy) + _, err = c.kubeClient.AppsV1().Deployments(dep.Namespace).Update(context.TODO(), depCopy, metav1.UpdateOptions{}) if err != nil { return fmt.Errorf("scaling %s.%s to %v failed: %w", depCopy.GetName(), depCopy.Namespace, replicas, err) } diff --git a/pkg/canary/deployment_controller_test.go b/pkg/canary/deployment_controller_test.go index 969df006..7dcfe7a4 100644 --- a/pkg/canary/deployment_controller_test.go +++ b/pkg/canary/deployment_controller_test.go @@ -1,6 +1,7 @@ package canary import ( + "context" "testing" "github.com/stretchr/testify/assert" @@ -17,7 +18,7 @@ func TestDeploymentController_Sync(t *testing.T) { mocks := newDeploymentFixture() mocks.initializeCanary(t) - depPrimary, err := mocks.kubeClient.AppsV1().Deployments("default").Get("podinfo-primary", metav1.GetOptions{}) + depPrimary, err := mocks.kubeClient.AppsV1().Deployments("default").Get(context.TODO(), "podinfo-primary", metav1.GetOptions{}) require.NoError(t, err) dep := newDeploymentControllerTest() @@ -25,7 +26,7 @@ func TestDeploymentController_Sync(t *testing.T) { sourceImage := dep.Spec.Template.Spec.Containers[0].Image assert.Equal(t, sourceImage, primaryImage) - hpaPrimary, err := mocks.kubeClient.AutoscalingV2beta1().HorizontalPodAutoscalers("default").Get("podinfo-primary", metav1.GetOptions{}) + hpaPrimary, err := mocks.kubeClient.AutoscalingV2beta1().HorizontalPodAutoscalers("default").Get(context.TODO(), "podinfo-primary", metav1.GetOptions{}) require.NoError(t, err) assert.Equal(t, depPrimary.Name, hpaPrimary.Spec.ScaleTargetRef.Name) } @@ -35,37 +36,37 @@ func TestDeploymentController_Promote(t *testing.T) { mocks.initializeCanary(t) dep2 := newDeploymentControllerTestV2() - _, err := mocks.kubeClient.AppsV1().Deployments("default").Update(dep2) + _, err := mocks.kubeClient.AppsV1().Deployments("default").Update(context.TODO(), dep2, metav1.UpdateOptions{}) require.NoError(t, err) config2 := newDeploymentControllerTestConfigMapV2() - _, err = mocks.kubeClient.CoreV1().ConfigMaps("default").Update(config2) + _, err = mocks.kubeClient.CoreV1().ConfigMaps("default").Update(context.TODO(), config2, metav1.UpdateOptions{}) require.NoError(t, err) - hpa, err := mocks.kubeClient.AutoscalingV2beta1().HorizontalPodAutoscalers("default").Get("podinfo", metav1.GetOptions{}) + hpa, err := mocks.kubeClient.AutoscalingV2beta1().HorizontalPodAutoscalers("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) hpaClone := hpa.DeepCopy() hpaClone.Spec.MaxReplicas = 2 - _, err = mocks.kubeClient.AutoscalingV2beta1().HorizontalPodAutoscalers("default").Update(hpaClone) + _, err = mocks.kubeClient.AutoscalingV2beta1().HorizontalPodAutoscalers("default").Update(context.TODO(), hpaClone, metav1.UpdateOptions{}) require.NoError(t, err) err = mocks.controller.Promote(mocks.canary) require.NoError(t, err) - depPrimary, err := mocks.kubeClient.AppsV1().Deployments("default").Get("podinfo-primary", metav1.GetOptions{}) + depPrimary, err := mocks.kubeClient.AppsV1().Deployments("default").Get(context.TODO(), "podinfo-primary", metav1.GetOptions{}) require.NoError(t, err) primaryImage := depPrimary.Spec.Template.Spec.Containers[0].Image sourceImage := dep2.Spec.Template.Spec.Containers[0].Image assert.Equal(t, sourceImage, primaryImage) - configPrimary, err := mocks.kubeClient.CoreV1().ConfigMaps("default").Get("podinfo-config-env-primary", metav1.GetOptions{}) + configPrimary, err := mocks.kubeClient.CoreV1().ConfigMaps("default").Get(context.TODO(), "podinfo-config-env-primary", metav1.GetOptions{}) require.NoError(t, err) assert.Equal(t, config2.Data["color"], configPrimary.Data["color"]) - hpaPrimary, err := mocks.kubeClient.AutoscalingV2beta1().HorizontalPodAutoscalers("default").Get("podinfo-primary", metav1.GetOptions{}) + hpaPrimary, err := mocks.kubeClient.AutoscalingV2beta1().HorizontalPodAutoscalers("default").Get(context.TODO(), "podinfo-primary", metav1.GetOptions{}) require.NoError(t, err) assert.Equal(t, int32(2), hpaPrimary.Spec.MaxReplicas) } @@ -77,7 +78,7 @@ func TestDeploymentController_ScaleToZero(t *testing.T) { err := mocks.controller.ScaleToZero(mocks.canary) require.NoError(t, err) - c, err := mocks.kubeClient.AppsV1().Deployments("default").Get("podinfo", metav1.GetOptions{}) + c, err := mocks.kubeClient.AppsV1().Deployments("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) assert.Equal(t, int32(0), *c.Spec.Replicas) } @@ -87,10 +88,10 @@ func TestDeploymentController_NoConfigTracking(t *testing.T) { mocks.controller.configTracker = &NopTracker{} mocks.initializeCanary(t) - depPrimary, err := mocks.kubeClient.AppsV1().Deployments("default").Get("podinfo-primary", metav1.GetOptions{}) + depPrimary, err := mocks.kubeClient.AppsV1().Deployments("default").Get(context.TODO(), "podinfo-primary", metav1.GetOptions{}) require.NoError(t, err) - _, err = mocks.kubeClient.CoreV1().ConfigMaps("default").Get("podinfo-config-env-primary", metav1.GetOptions{}) + _, err = mocks.kubeClient.CoreV1().ConfigMaps("default").Get(context.TODO(), "podinfo-config-env-primary", metav1.GetOptions{}) require.True(t, errors.IsNotFound(err), "Primary ConfigMap shouldn't have been created") configName := depPrimary.Spec.Template.Spec.Volumes[0].VolumeSource.ConfigMap.LocalObjectReference.Name @@ -102,20 +103,20 @@ func TestDeploymentController_HasTargetChanged(t *testing.T) { mocks.initializeCanary(t) // save last applied hash - canary, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get("podinfo", metav1.GetOptions{}) + canary, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) err = mocks.controller.SyncStatus(canary, flaggerv1.CanaryStatus{Phase: flaggerv1.CanaryPhaseInitializing}) require.NoError(t, err) // save last promoted hash - canary, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get("podinfo", metav1.GetOptions{}) + canary, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) err = mocks.controller.SetStatusPhase(canary, flaggerv1.CanaryPhaseInitialized) require.NoError(t, err) - dep, err := mocks.kubeClient.AppsV1().Deployments("default").Get("podinfo", metav1.GetOptions{}) + dep, err := mocks.kubeClient.AppsV1().Deployments("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) depClone := dep.DeepCopy() @@ -126,10 +127,10 @@ func TestDeploymentController_HasTargetChanged(t *testing.T) { } // update pod spec - _, err = mocks.kubeClient.AppsV1().Deployments("default").Update(depClone) + _, err = mocks.kubeClient.AppsV1().Deployments("default").Update(context.TODO(), depClone, metav1.UpdateOptions{}) require.NoError(t, err) - canary, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get("podinfo", metav1.GetOptions{}) + canary, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) // detect change in last applied spec @@ -141,7 +142,7 @@ func TestDeploymentController_HasTargetChanged(t *testing.T) { err = mocks.controller.SyncStatus(canary, flaggerv1.CanaryStatus{Phase: flaggerv1.CanaryPhaseProgressing}) require.NoError(t, err) - dep, err = mocks.kubeClient.AppsV1().Deployments("default").Get("podinfo", metav1.GetOptions{}) + dep, err = mocks.kubeClient.AppsV1().Deployments("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) depClone = dep.DeepCopy() @@ -152,10 +153,10 @@ func TestDeploymentController_HasTargetChanged(t *testing.T) { } // update pod spec - _, err = mocks.kubeClient.AppsV1().Deployments("default").Update(depClone) + _, err = mocks.kubeClient.AppsV1().Deployments("default").Update(context.TODO(), depClone, metav1.UpdateOptions{}) require.NoError(t, err) - canary, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get("podinfo", metav1.GetOptions{}) + canary, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) // ignore change as hash should be the same with last promoted @@ -171,10 +172,10 @@ func TestDeploymentController_HasTargetChanged(t *testing.T) { } // update pod spec - _, err = mocks.kubeClient.AppsV1().Deployments("default").Update(depClone) + _, err = mocks.kubeClient.AppsV1().Deployments("default").Update(context.TODO(), depClone, metav1.UpdateOptions{}) require.NoError(t, err) - canary, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get("podinfo", metav1.GetOptions{}) + canary, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) // detect change @@ -203,7 +204,7 @@ func TestDeploymentController_Finalize(t *testing.T) { err := mocks.controller.Finalize(tc.canary) require.NoError(t, err) - c, err := mocks.kubeClient.AppsV1().Deployments(mocks.canary.Namespace).Get(mocks.canary.Name, metav1.GetOptions{}) + c, err := mocks.kubeClient.AppsV1().Deployments(mocks.canary.Namespace).Get(context.TODO(), mocks.canary.Name, metav1.GetOptions{}) require.NoError(t, err) require.Equal(t, int32(1), *c.Spec.Replicas) } diff --git a/pkg/canary/deployment_fixture_test.go b/pkg/canary/deployment_fixture_test.go index 92db6d16..c8ab873d 100644 --- a/pkg/canary/deployment_fixture_test.go +++ b/pkg/canary/deployment_fixture_test.go @@ -1,6 +1,7 @@ package canary import ( + "context" "fmt" "testing" @@ -34,7 +35,7 @@ func (d deploymentControllerFixture) initializeCanary(t *testing.T) { primaryName := fmt.Sprintf("%s-primary", d.canary.Spec.TargetRef.Name) p, err := d.controller.kubeClient.AppsV1(). - Deployments(d.canary.Namespace).Get(primaryName, metav1.GetOptions{}) + Deployments(d.canary.Namespace).Get(context.TODO(), primaryName, metav1.GetOptions{}) require.NoError(t, err) p.Status = appsv1.DeploymentStatus{ @@ -44,7 +45,7 @@ func (d deploymentControllerFixture) initializeCanary(t *testing.T) { AvailableReplicas: 1, } - _, err = d.controller.kubeClient.AppsV1().Deployments(d.canary.Namespace).Update(p) + _, err = d.controller.kubeClient.AppsV1().Deployments(d.canary.Namespace).Update(context.TODO(), p, metav1.UpdateOptions{}) require.NoError(t, err) require.NoError(t, d.controller.Initialize(d.canary)) diff --git a/pkg/canary/deployment_ready.go b/pkg/canary/deployment_ready.go index 293d8f83..fb2098cd 100644 --- a/pkg/canary/deployment_ready.go +++ b/pkg/canary/deployment_ready.go @@ -1,6 +1,7 @@ package canary import ( + "context" "fmt" "time" @@ -15,7 +16,7 @@ import ( // it will return a non retryable error if the rolling update is stuck func (c *DeploymentController) IsPrimaryReady(cd *flaggerv1.Canary) error { primaryName := fmt.Sprintf("%s-primary", cd.Spec.TargetRef.Name) - primary, err := c.kubeClient.AppsV1().Deployments(cd.Namespace).Get(primaryName, metav1.GetOptions{}) + primary, err := c.kubeClient.AppsV1().Deployments(cd.Namespace).Get(context.TODO(), primaryName, metav1.GetOptions{}) if err != nil { return fmt.Errorf("deployment %s.%s get query error: %w", primaryName, cd.Namespace, err) } @@ -37,7 +38,7 @@ func (c *DeploymentController) IsPrimaryReady(cd *flaggerv1.Canary) error { // it will return a non retriable error if the rolling update is stuck func (c *DeploymentController) IsCanaryReady(cd *flaggerv1.Canary) (bool, error) { targetName := cd.Spec.TargetRef.Name - canary, err := c.kubeClient.AppsV1().Deployments(cd.Namespace).Get(targetName, metav1.GetOptions{}) + canary, err := c.kubeClient.AppsV1().Deployments(cd.Namespace).Get(context.TODO(), targetName, metav1.GetOptions{}) if err != nil { return true, fmt.Errorf("deployment %s.%s get query error: %w", targetName, cd.Namespace, err) } diff --git a/pkg/canary/deployment_status.go b/pkg/canary/deployment_status.go index 6c2babe6..0746ce2d 100644 --- a/pkg/canary/deployment_status.go +++ b/pkg/canary/deployment_status.go @@ -1,6 +1,7 @@ package canary import ( + "context" "fmt" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -10,7 +11,7 @@ import ( // SyncStatus encodes the canary pod spec and updates the canary status func (c *DeploymentController) SyncStatus(cd *flaggerv1.Canary, status flaggerv1.CanaryStatus) error { - dep, err := c.kubeClient.AppsV1().Deployments(cd.Namespace).Get(cd.Spec.TargetRef.Name, metav1.GetOptions{}) + dep, err := c.kubeClient.AppsV1().Deployments(cd.Namespace).Get(context.TODO(), cd.Spec.TargetRef.Name, metav1.GetOptions{}) if err != nil { return fmt.Errorf("deployment %s.%s get query error: %w", cd.Spec.TargetRef.Name, cd.Namespace, err) } diff --git a/pkg/canary/deployment_status_test.go b/pkg/canary/deployment_status_test.go index 45c590ca..26b291a3 100644 --- a/pkg/canary/deployment_status_test.go +++ b/pkg/canary/deployment_status_test.go @@ -1,6 +1,7 @@ package canary import ( + "context" "testing" "github.com/stretchr/testify/assert" @@ -21,7 +22,7 @@ func TestDeploymentController_SyncStatus(t *testing.T) { err := mocks.controller.SyncStatus(mocks.canary, status) require.NoError(t, err) - res, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get("podinfo", metav1.GetOptions{}) + res, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) assert.Equal(t, status.Phase, res.Status.Phase) assert.Equal(t, status.FailedChecks, res.Status.FailedChecks) @@ -40,7 +41,7 @@ func TestDeploymentController_SetFailedChecks(t *testing.T) { err := mocks.controller.SetStatusFailedChecks(mocks.canary, 1) require.NoError(t, err) - res, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get("podinfo", metav1.GetOptions{}) + res, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) assert.Equal(t, 1, res.Status.FailedChecks) } @@ -52,7 +53,7 @@ func TestDeploymentController_SetState(t *testing.T) { err := mocks.controller.SetStatusPhase(mocks.canary, flaggerv1.CanaryPhaseProgressing) require.NoError(t, err) - res, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get("podinfo", metav1.GetOptions{}) + res, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) assert.Equal(t, flaggerv1.CanaryPhaseProgressing, res.Status.Phase) } diff --git a/pkg/canary/service_controller.go b/pkg/canary/service_controller.go index 75671308..1961b6cb 100644 --- a/pkg/canary/service_controller.go +++ b/pkg/canary/service_controller.go @@ -1,6 +1,7 @@ package canary import ( + "context" "fmt" "go.uber.org/zap" @@ -52,7 +53,7 @@ func (c *ServiceController) Initialize(cd *flaggerv1.Canary) (err error) { primaryName := fmt.Sprintf("%s-primary", targetName) canaryName := fmt.Sprintf("%s-canary", targetName) - svc, err := c.kubeClient.CoreV1().Services(cd.Namespace).Get(targetName, metav1.GetOptions{}) + svc, err := c.kubeClient.CoreV1().Services(cd.Namespace).Get(context.TODO(), targetName, metav1.GetOptions{}) if err != nil { return fmt.Errorf("service %s.%s get query error: %w", primaryName, cd.Namespace, err) } @@ -69,7 +70,7 @@ func (c *ServiceController) Initialize(cd *flaggerv1.Canary) (err error) { } func (c *ServiceController) reconcileCanaryService(canary *flaggerv1.Canary, name string, src *corev1.Service) error { - current, err := c.kubeClient.CoreV1().Services(canary.Namespace).Get(name, metav1.GetOptions{}) + current, err := c.kubeClient.CoreV1().Services(canary.Namespace).Get(context.TODO(), name, metav1.GetOptions{}) if errors.IsNotFound(err) { return c.createService(canary, name, src) } else if err != nil { @@ -88,7 +89,7 @@ func (c *ServiceController) reconcileCanaryService(canary *flaggerv1.Canary, nam ns.ObjectMeta.ResourceVersion = current.ObjectMeta.ResourceVersion - _, err = c.kubeClient.CoreV1().Services(canary.Namespace).Update(ns) + _, err = c.kubeClient.CoreV1().Services(canary.Namespace).Update(context.TODO(), ns, metav1.UpdateOptions{}) if err != nil { return fmt.Errorf("updating service %s.%s failed: %w", name, canary.Namespace, err) } @@ -99,7 +100,7 @@ func (c *ServiceController) reconcileCanaryService(canary *flaggerv1.Canary, nam } func (c *ServiceController) reconcilePrimaryService(canary *flaggerv1.Canary, name string, src *corev1.Service) error { - _, err := c.kubeClient.CoreV1().Services(canary.Namespace).Get(name, metav1.GetOptions{}) + _, err := c.kubeClient.CoreV1().Services(canary.Namespace).Get(context.TODO(), name, metav1.GetOptions{}) if errors.IsNotFound(err) { return c.createService(canary, name, src) } else if err != nil { @@ -119,7 +120,7 @@ func (c *ServiceController) createService(canary *flaggerv1.Canary, name string, // Let K8s set this. Otherwise K8s API complains with "resourceVersion should not be set on objects to be created" svc.ObjectMeta.ResourceVersion = "" - _, err := c.kubeClient.CoreV1().Services(canary.Namespace).Create(svc) + _, err := c.kubeClient.CoreV1().Services(canary.Namespace).Create(context.TODO(), svc, metav1.CreateOptions{}) if err != nil { return fmt.Errorf("creating service %s.%s query error: %w", canary.Name, canary.Namespace, err) } @@ -154,12 +155,12 @@ func (c *ServiceController) Promote(cd *flaggerv1.Canary) error { targetName := cd.Spec.TargetRef.Name primaryName := fmt.Sprintf("%s-primary", targetName) - canary, err := c.kubeClient.CoreV1().Services(cd.Namespace).Get(targetName, metav1.GetOptions{}) + canary, err := c.kubeClient.CoreV1().Services(cd.Namespace).Get(context.TODO(), targetName, metav1.GetOptions{}) if err != nil { return fmt.Errorf("service %s.%s get query error: %w", targetName, cd.Namespace, err) } - primary, err := c.kubeClient.CoreV1().Services(cd.Namespace).Get(primaryName, metav1.GetOptions{}) + primary, err := c.kubeClient.CoreV1().Services(cd.Namespace).Get(context.TODO(), primaryName, metav1.GetOptions{}) if err != nil { return fmt.Errorf("service %s.%s get query error: %w", primaryName, cd.Namespace, err) } @@ -173,7 +174,7 @@ func (c *ServiceController) Promote(cd *flaggerv1.Canary) error { primaryCopy.ObjectMeta.UID = primary.ObjectMeta.UID // apply update - _, err = c.kubeClient.CoreV1().Services(cd.Namespace).Update(primaryCopy) + _, err = c.kubeClient.CoreV1().Services(cd.Namespace).Update(context.TODO(), primaryCopy, metav1.UpdateOptions{}) if err != nil { return fmt.Errorf("updating service %s.%s spec failed: %w", primaryCopy.GetName(), primaryCopy.Namespace, err) @@ -185,7 +186,7 @@ func (c *ServiceController) Promote(cd *flaggerv1.Canary) error { // HasServiceChanged returns true if the canary service spec has changed func (c *ServiceController) HasTargetChanged(cd *flaggerv1.Canary) (bool, error) { targetName := cd.Spec.TargetRef.Name - canary, err := c.kubeClient.CoreV1().Services(cd.Namespace).Get(targetName, metav1.GetOptions{}) + canary, err := c.kubeClient.CoreV1().Services(cd.Namespace).Get(context.TODO(), targetName, metav1.GetOptions{}) if err != nil { return false, fmt.Errorf("service %s.%s get query error: %w", targetName, cd.Namespace, err) } @@ -202,7 +203,7 @@ func (c *ServiceController) ScaleFromZero(_ *flaggerv1.Canary) error { } func (c *ServiceController) SyncStatus(cd *flaggerv1.Canary, status flaggerv1.CanaryStatus) error { - dep, err := c.kubeClient.CoreV1().Services(cd.Namespace).Get(cd.Spec.TargetRef.Name, metav1.GetOptions{}) + dep, err := c.kubeClient.CoreV1().Services(cd.Namespace).Get(context.TODO(), cd.Spec.TargetRef.Name, metav1.GetOptions{}) if err != nil { return fmt.Errorf("service %s.%s get query error: %w", cd.Spec.TargetRef.Name, cd.Namespace, err) } diff --git a/pkg/canary/status.go b/pkg/canary/status.go index 274ba430..4073021d 100644 --- a/pkg/canary/status.go +++ b/pkg/canary/status.go @@ -1,6 +1,7 @@ package canary import ( + "context" "fmt" "strings" @@ -19,7 +20,7 @@ func syncCanaryStatus(flaggerClient clientset.Interface, cd *flaggerv1.Canary, s name, ns := cd.GetName(), cd.GetNamespace() err := retry.RetryOnConflict(retry.DefaultBackoff, func() (err error) { if !firstTry { - cd, err = flaggerClient.FlaggerV1beta1().Canaries(ns).Get(name, metav1.GetOptions{}) + cd, err = flaggerClient.FlaggerV1beta1().Canaries(ns).Get(context.TODO(), name, metav1.GetOptions{}) if err != nil { return fmt.Errorf("canary %s.%s get query failed: %w", name, ns, err) } @@ -54,7 +55,7 @@ func setStatusFailedChecks(flaggerClient clientset.Interface, cd *flaggerv1.Cana name, ns := cd.GetName(), cd.GetNamespace() err := retry.RetryOnConflict(retry.DefaultBackoff, func() (err error) { if !firstTry { - cd, err = flaggerClient.FlaggerV1beta1().Canaries(ns).Get(name, metav1.GetOptions{}) + cd, err = flaggerClient.FlaggerV1beta1().Canaries(ns).Get(context.TODO(), name, metav1.GetOptions{}) if err != nil { return fmt.Errorf("canary %s.%s get query failed: %w", name, ns, err) } @@ -78,7 +79,7 @@ func setStatusWeight(flaggerClient clientset.Interface, cd *flaggerv1.Canary, va name, ns := cd.GetName(), cd.GetNamespace() err := retry.RetryOnConflict(retry.DefaultBackoff, func() (err error) { if !firstTry { - cd, err = flaggerClient.FlaggerV1beta1().Canaries(ns).Get(name, metav1.GetOptions{}) + cd, err = flaggerClient.FlaggerV1beta1().Canaries(ns).Get(context.TODO(), name, metav1.GetOptions{}) if err != nil { return fmt.Errorf("canary %s.%s get query failed: %w", name, ns, err) } @@ -102,7 +103,7 @@ func setStatusIterations(flaggerClient clientset.Interface, cd *flaggerv1.Canary name, ns := cd.GetName(), cd.GetNamespace() err := retry.RetryOnConflict(retry.DefaultBackoff, func() (err error) { if !firstTry { - cd, err = flaggerClient.FlaggerV1beta1().Canaries(ns).Get(name, metav1.GetOptions{}) + cd, err = flaggerClient.FlaggerV1beta1().Canaries(ns).Get(context.TODO(), name, metav1.GetOptions{}) if err != nil { return fmt.Errorf("canary %s.%s get query failed: %w", name, ns, err) } @@ -128,7 +129,7 @@ func setStatusPhase(flaggerClient clientset.Interface, cd *flaggerv1.Canary, pha name, ns := cd.GetName(), cd.GetNamespace() err := retry.RetryOnConflict(retry.DefaultBackoff, func() (err error) { if !firstTry { - cd, err = flaggerClient.FlaggerV1beta1().Canaries(ns).Get(name, metav1.GetOptions{}) + cd, err = flaggerClient.FlaggerV1beta1().Canaries(ns).Get(context.TODO(), name, metav1.GetOptions{}) if err != nil { return fmt.Errorf("canary %s.%s get query failed: %w", name, ns, err) } @@ -234,14 +235,14 @@ func MakeStatusConditions(cd *flaggerv1.Canary, // Canary.flagger.app is invalid: apiVersion: Invalid value: flagger.app/v1alpha3: must be flagger.app/v1beta1 // then the canary object will be updated to the latest API version func updateStatusWithUpgrade(flaggerClient clientset.Interface, cd *flaggerv1.Canary) error { - _, err := flaggerClient.FlaggerV1beta1().Canaries(cd.Namespace).UpdateStatus(cd) + _, err := flaggerClient.FlaggerV1beta1().Canaries(cd.Namespace).UpdateStatus(context.TODO(), cd, metav1.UpdateOptions{}) if err != nil && strings.Contains(err.Error(), "flagger.app/v1alpha") { // upgrade alpha resource - if _, updateErr := flaggerClient.FlaggerV1beta1().Canaries(cd.Namespace).Update(cd); updateErr != nil { + if _, updateErr := flaggerClient.FlaggerV1beta1().Canaries(cd.Namespace).Update(context.TODO(), cd, metav1.UpdateOptions{}); updateErr != nil { return fmt.Errorf("updating canary %s.%s from v1alpha to v1beta failed: %w", cd.Name, cd.Namespace, updateErr) } // retry status update - _, err = flaggerClient.FlaggerV1beta1().Canaries(cd.Namespace).UpdateStatus(cd) + _, err = flaggerClient.FlaggerV1beta1().Canaries(cd.Namespace).UpdateStatus(context.TODO(), cd, metav1.UpdateOptions{}) } if err != nil { diff --git a/pkg/client/clientset/versioned/clientset.go b/pkg/client/clientset/versioned/clientset.go index 792fa6b7..b6b73b42 100644 --- a/pkg/client/clientset/versioned/clientset.go +++ b/pkg/client/clientset/versioned/clientset.go @@ -107,7 +107,7 @@ func NewForConfig(c *rest.Config) (*Clientset, error) { configShallowCopy := *c if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 { if configShallowCopy.Burst <= 0 { - return nil, fmt.Errorf("Burst is required to be greater than 0 when RateLimiter is not set and QPS is set to greater than 0") + return nil, fmt.Errorf("burst is required to be greater than 0 when RateLimiter is not set and QPS is set to greater than 0") } configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst) } diff --git a/pkg/client/clientset/versioned/typed/appmesh/v1beta1/fake/fake_mesh.go b/pkg/client/clientset/versioned/typed/appmesh/v1beta1/fake/fake_mesh.go index d35a1a54..64ab88ac 100644 --- a/pkg/client/clientset/versioned/typed/appmesh/v1beta1/fake/fake_mesh.go +++ b/pkg/client/clientset/versioned/typed/appmesh/v1beta1/fake/fake_mesh.go @@ -19,6 +19,8 @@ limitations under the License. package fake import ( + "context" + v1beta1 "github.com/weaveworks/flagger/pkg/apis/appmesh/v1beta1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" @@ -38,7 +40,7 @@ var meshesResource = schema.GroupVersionResource{Group: "appmesh.k8s.aws", Versi var meshesKind = schema.GroupVersionKind{Group: "appmesh.k8s.aws", Version: "v1beta1", Kind: "Mesh"} // Get takes name of the mesh, and returns the corresponding mesh object, and an error if there is any. -func (c *FakeMeshes) Get(name string, options v1.GetOptions) (result *v1beta1.Mesh, err error) { +func (c *FakeMeshes) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.Mesh, err error) { obj, err := c.Fake. Invokes(testing.NewRootGetAction(meshesResource, name), &v1beta1.Mesh{}) if obj == nil { @@ -48,7 +50,7 @@ func (c *FakeMeshes) Get(name string, options v1.GetOptions) (result *v1beta1.Me } // List takes label and field selectors, and returns the list of Meshes that match those selectors. -func (c *FakeMeshes) List(opts v1.ListOptions) (result *v1beta1.MeshList, err error) { +func (c *FakeMeshes) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.MeshList, err error) { obj, err := c.Fake. Invokes(testing.NewRootListAction(meshesResource, meshesKind, opts), &v1beta1.MeshList{}) if obj == nil { @@ -69,13 +71,13 @@ func (c *FakeMeshes) List(opts v1.ListOptions) (result *v1beta1.MeshList, err er } // Watch returns a watch.Interface that watches the requested meshes. -func (c *FakeMeshes) Watch(opts v1.ListOptions) (watch.Interface, error) { +func (c *FakeMeshes) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.Fake. InvokesWatch(testing.NewRootWatchAction(meshesResource, opts)) } // Create takes the representation of a mesh and creates it. Returns the server's representation of the mesh, and an error, if there is any. -func (c *FakeMeshes) Create(mesh *v1beta1.Mesh) (result *v1beta1.Mesh, err error) { +func (c *FakeMeshes) Create(ctx context.Context, mesh *v1beta1.Mesh, opts v1.CreateOptions) (result *v1beta1.Mesh, err error) { obj, err := c.Fake. Invokes(testing.NewRootCreateAction(meshesResource, mesh), &v1beta1.Mesh{}) if obj == nil { @@ -85,7 +87,7 @@ func (c *FakeMeshes) Create(mesh *v1beta1.Mesh) (result *v1beta1.Mesh, err error } // Update takes the representation of a mesh and updates it. Returns the server's representation of the mesh, and an error, if there is any. -func (c *FakeMeshes) Update(mesh *v1beta1.Mesh) (result *v1beta1.Mesh, err error) { +func (c *FakeMeshes) Update(ctx context.Context, mesh *v1beta1.Mesh, opts v1.UpdateOptions) (result *v1beta1.Mesh, err error) { obj, err := c.Fake. Invokes(testing.NewRootUpdateAction(meshesResource, mesh), &v1beta1.Mesh{}) if obj == nil { @@ -96,7 +98,7 @@ func (c *FakeMeshes) Update(mesh *v1beta1.Mesh) (result *v1beta1.Mesh, err error // UpdateStatus was generated because the type contains a Status member. // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *FakeMeshes) UpdateStatus(mesh *v1beta1.Mesh) (*v1beta1.Mesh, error) { +func (c *FakeMeshes) UpdateStatus(ctx context.Context, mesh *v1beta1.Mesh, opts v1.UpdateOptions) (*v1beta1.Mesh, error) { obj, err := c.Fake. Invokes(testing.NewRootUpdateSubresourceAction(meshesResource, "status", mesh), &v1beta1.Mesh{}) if obj == nil { @@ -106,22 +108,22 @@ func (c *FakeMeshes) UpdateStatus(mesh *v1beta1.Mesh) (*v1beta1.Mesh, error) { } // Delete takes name of the mesh and deletes it. Returns an error if one occurs. -func (c *FakeMeshes) Delete(name string, options *v1.DeleteOptions) error { +func (c *FakeMeshes) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { _, err := c.Fake. Invokes(testing.NewRootDeleteAction(meshesResource, name), &v1beta1.Mesh{}) return err } // DeleteCollection deletes a collection of objects. -func (c *FakeMeshes) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { - action := testing.NewRootDeleteCollectionAction(meshesResource, listOptions) +func (c *FakeMeshes) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewRootDeleteCollectionAction(meshesResource, listOpts) _, err := c.Fake.Invokes(action, &v1beta1.MeshList{}) return err } // Patch applies the patch and returns the patched mesh. -func (c *FakeMeshes) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Mesh, err error) { +func (c *FakeMeshes) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.Mesh, err error) { obj, err := c.Fake. Invokes(testing.NewRootPatchSubresourceAction(meshesResource, name, pt, data, subresources...), &v1beta1.Mesh{}) if obj == nil { diff --git a/pkg/client/clientset/versioned/typed/appmesh/v1beta1/fake/fake_virtualnode.go b/pkg/client/clientset/versioned/typed/appmesh/v1beta1/fake/fake_virtualnode.go index a253cdc8..f2d590ee 100644 --- a/pkg/client/clientset/versioned/typed/appmesh/v1beta1/fake/fake_virtualnode.go +++ b/pkg/client/clientset/versioned/typed/appmesh/v1beta1/fake/fake_virtualnode.go @@ -19,6 +19,8 @@ limitations under the License. package fake import ( + "context" + v1beta1 "github.com/weaveworks/flagger/pkg/apis/appmesh/v1beta1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" @@ -39,7 +41,7 @@ var virtualnodesResource = schema.GroupVersionResource{Group: "appmesh.k8s.aws", var virtualnodesKind = schema.GroupVersionKind{Group: "appmesh.k8s.aws", Version: "v1beta1", Kind: "VirtualNode"} // Get takes name of the virtualNode, and returns the corresponding virtualNode object, and an error if there is any. -func (c *FakeVirtualNodes) Get(name string, options v1.GetOptions) (result *v1beta1.VirtualNode, err error) { +func (c *FakeVirtualNodes) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.VirtualNode, err error) { obj, err := c.Fake. Invokes(testing.NewGetAction(virtualnodesResource, c.ns, name), &v1beta1.VirtualNode{}) @@ -50,7 +52,7 @@ func (c *FakeVirtualNodes) Get(name string, options v1.GetOptions) (result *v1be } // List takes label and field selectors, and returns the list of VirtualNodes that match those selectors. -func (c *FakeVirtualNodes) List(opts v1.ListOptions) (result *v1beta1.VirtualNodeList, err error) { +func (c *FakeVirtualNodes) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.VirtualNodeList, err error) { obj, err := c.Fake. Invokes(testing.NewListAction(virtualnodesResource, virtualnodesKind, c.ns, opts), &v1beta1.VirtualNodeList{}) @@ -72,14 +74,14 @@ func (c *FakeVirtualNodes) List(opts v1.ListOptions) (result *v1beta1.VirtualNod } // Watch returns a watch.Interface that watches the requested virtualNodes. -func (c *FakeVirtualNodes) Watch(opts v1.ListOptions) (watch.Interface, error) { +func (c *FakeVirtualNodes) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.Fake. InvokesWatch(testing.NewWatchAction(virtualnodesResource, c.ns, opts)) } // Create takes the representation of a virtualNode and creates it. Returns the server's representation of the virtualNode, and an error, if there is any. -func (c *FakeVirtualNodes) Create(virtualNode *v1beta1.VirtualNode) (result *v1beta1.VirtualNode, err error) { +func (c *FakeVirtualNodes) Create(ctx context.Context, virtualNode *v1beta1.VirtualNode, opts v1.CreateOptions) (result *v1beta1.VirtualNode, err error) { obj, err := c.Fake. Invokes(testing.NewCreateAction(virtualnodesResource, c.ns, virtualNode), &v1beta1.VirtualNode{}) @@ -90,7 +92,7 @@ func (c *FakeVirtualNodes) Create(virtualNode *v1beta1.VirtualNode) (result *v1b } // Update takes the representation of a virtualNode and updates it. Returns the server's representation of the virtualNode, and an error, if there is any. -func (c *FakeVirtualNodes) Update(virtualNode *v1beta1.VirtualNode) (result *v1beta1.VirtualNode, err error) { +func (c *FakeVirtualNodes) Update(ctx context.Context, virtualNode *v1beta1.VirtualNode, opts v1.UpdateOptions) (result *v1beta1.VirtualNode, err error) { obj, err := c.Fake. Invokes(testing.NewUpdateAction(virtualnodesResource, c.ns, virtualNode), &v1beta1.VirtualNode{}) @@ -102,7 +104,7 @@ func (c *FakeVirtualNodes) Update(virtualNode *v1beta1.VirtualNode) (result *v1b // UpdateStatus was generated because the type contains a Status member. // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *FakeVirtualNodes) UpdateStatus(virtualNode *v1beta1.VirtualNode) (*v1beta1.VirtualNode, error) { +func (c *FakeVirtualNodes) UpdateStatus(ctx context.Context, virtualNode *v1beta1.VirtualNode, opts v1.UpdateOptions) (*v1beta1.VirtualNode, error) { obj, err := c.Fake. Invokes(testing.NewUpdateSubresourceAction(virtualnodesResource, "status", c.ns, virtualNode), &v1beta1.VirtualNode{}) @@ -113,7 +115,7 @@ func (c *FakeVirtualNodes) UpdateStatus(virtualNode *v1beta1.VirtualNode) (*v1be } // Delete takes name of the virtualNode and deletes it. Returns an error if one occurs. -func (c *FakeVirtualNodes) Delete(name string, options *v1.DeleteOptions) error { +func (c *FakeVirtualNodes) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { _, err := c.Fake. Invokes(testing.NewDeleteAction(virtualnodesResource, c.ns, name), &v1beta1.VirtualNode{}) @@ -121,15 +123,15 @@ func (c *FakeVirtualNodes) Delete(name string, options *v1.DeleteOptions) error } // DeleteCollection deletes a collection of objects. -func (c *FakeVirtualNodes) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(virtualnodesResource, c.ns, listOptions) +func (c *FakeVirtualNodes) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(virtualnodesResource, c.ns, listOpts) _, err := c.Fake.Invokes(action, &v1beta1.VirtualNodeList{}) return err } // Patch applies the patch and returns the patched virtualNode. -func (c *FakeVirtualNodes) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.VirtualNode, err error) { +func (c *FakeVirtualNodes) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.VirtualNode, err error) { obj, err := c.Fake. Invokes(testing.NewPatchSubresourceAction(virtualnodesResource, c.ns, name, pt, data, subresources...), &v1beta1.VirtualNode{}) diff --git a/pkg/client/clientset/versioned/typed/appmesh/v1beta1/fake/fake_virtualservice.go b/pkg/client/clientset/versioned/typed/appmesh/v1beta1/fake/fake_virtualservice.go index 17ee309c..b8e4d067 100644 --- a/pkg/client/clientset/versioned/typed/appmesh/v1beta1/fake/fake_virtualservice.go +++ b/pkg/client/clientset/versioned/typed/appmesh/v1beta1/fake/fake_virtualservice.go @@ -19,6 +19,8 @@ limitations under the License. package fake import ( + "context" + v1beta1 "github.com/weaveworks/flagger/pkg/apis/appmesh/v1beta1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" @@ -39,7 +41,7 @@ var virtualservicesResource = schema.GroupVersionResource{Group: "appmesh.k8s.aw var virtualservicesKind = schema.GroupVersionKind{Group: "appmesh.k8s.aws", Version: "v1beta1", Kind: "VirtualService"} // Get takes name of the virtualService, and returns the corresponding virtualService object, and an error if there is any. -func (c *FakeVirtualServices) Get(name string, options v1.GetOptions) (result *v1beta1.VirtualService, err error) { +func (c *FakeVirtualServices) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.VirtualService, err error) { obj, err := c.Fake. Invokes(testing.NewGetAction(virtualservicesResource, c.ns, name), &v1beta1.VirtualService{}) @@ -50,7 +52,7 @@ func (c *FakeVirtualServices) Get(name string, options v1.GetOptions) (result *v } // List takes label and field selectors, and returns the list of VirtualServices that match those selectors. -func (c *FakeVirtualServices) List(opts v1.ListOptions) (result *v1beta1.VirtualServiceList, err error) { +func (c *FakeVirtualServices) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.VirtualServiceList, err error) { obj, err := c.Fake. Invokes(testing.NewListAction(virtualservicesResource, virtualservicesKind, c.ns, opts), &v1beta1.VirtualServiceList{}) @@ -72,14 +74,14 @@ func (c *FakeVirtualServices) List(opts v1.ListOptions) (result *v1beta1.Virtual } // Watch returns a watch.Interface that watches the requested virtualServices. -func (c *FakeVirtualServices) Watch(opts v1.ListOptions) (watch.Interface, error) { +func (c *FakeVirtualServices) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.Fake. InvokesWatch(testing.NewWatchAction(virtualservicesResource, c.ns, opts)) } // Create takes the representation of a virtualService and creates it. Returns the server's representation of the virtualService, and an error, if there is any. -func (c *FakeVirtualServices) Create(virtualService *v1beta1.VirtualService) (result *v1beta1.VirtualService, err error) { +func (c *FakeVirtualServices) Create(ctx context.Context, virtualService *v1beta1.VirtualService, opts v1.CreateOptions) (result *v1beta1.VirtualService, err error) { obj, err := c.Fake. Invokes(testing.NewCreateAction(virtualservicesResource, c.ns, virtualService), &v1beta1.VirtualService{}) @@ -90,7 +92,7 @@ func (c *FakeVirtualServices) Create(virtualService *v1beta1.VirtualService) (re } // Update takes the representation of a virtualService and updates it. Returns the server's representation of the virtualService, and an error, if there is any. -func (c *FakeVirtualServices) Update(virtualService *v1beta1.VirtualService) (result *v1beta1.VirtualService, err error) { +func (c *FakeVirtualServices) Update(ctx context.Context, virtualService *v1beta1.VirtualService, opts v1.UpdateOptions) (result *v1beta1.VirtualService, err error) { obj, err := c.Fake. Invokes(testing.NewUpdateAction(virtualservicesResource, c.ns, virtualService), &v1beta1.VirtualService{}) @@ -102,7 +104,7 @@ func (c *FakeVirtualServices) Update(virtualService *v1beta1.VirtualService) (re // UpdateStatus was generated because the type contains a Status member. // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *FakeVirtualServices) UpdateStatus(virtualService *v1beta1.VirtualService) (*v1beta1.VirtualService, error) { +func (c *FakeVirtualServices) UpdateStatus(ctx context.Context, virtualService *v1beta1.VirtualService, opts v1.UpdateOptions) (*v1beta1.VirtualService, error) { obj, err := c.Fake. Invokes(testing.NewUpdateSubresourceAction(virtualservicesResource, "status", c.ns, virtualService), &v1beta1.VirtualService{}) @@ -113,7 +115,7 @@ func (c *FakeVirtualServices) UpdateStatus(virtualService *v1beta1.VirtualServic } // Delete takes name of the virtualService and deletes it. Returns an error if one occurs. -func (c *FakeVirtualServices) Delete(name string, options *v1.DeleteOptions) error { +func (c *FakeVirtualServices) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { _, err := c.Fake. Invokes(testing.NewDeleteAction(virtualservicesResource, c.ns, name), &v1beta1.VirtualService{}) @@ -121,15 +123,15 @@ func (c *FakeVirtualServices) Delete(name string, options *v1.DeleteOptions) err } // DeleteCollection deletes a collection of objects. -func (c *FakeVirtualServices) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(virtualservicesResource, c.ns, listOptions) +func (c *FakeVirtualServices) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(virtualservicesResource, c.ns, listOpts) _, err := c.Fake.Invokes(action, &v1beta1.VirtualServiceList{}) return err } // Patch applies the patch and returns the patched virtualService. -func (c *FakeVirtualServices) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.VirtualService, err error) { +func (c *FakeVirtualServices) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.VirtualService, err error) { obj, err := c.Fake. Invokes(testing.NewPatchSubresourceAction(virtualservicesResource, c.ns, name, pt, data, subresources...), &v1beta1.VirtualService{}) diff --git a/pkg/client/clientset/versioned/typed/appmesh/v1beta1/mesh.go b/pkg/client/clientset/versioned/typed/appmesh/v1beta1/mesh.go index 4b1c71cd..763dabd2 100644 --- a/pkg/client/clientset/versioned/typed/appmesh/v1beta1/mesh.go +++ b/pkg/client/clientset/versioned/typed/appmesh/v1beta1/mesh.go @@ -19,6 +19,7 @@ limitations under the License. package v1beta1 import ( + "context" "time" v1beta1 "github.com/weaveworks/flagger/pkg/apis/appmesh/v1beta1" @@ -37,15 +38,15 @@ type MeshesGetter interface { // MeshInterface has methods to work with Mesh resources. type MeshInterface interface { - Create(*v1beta1.Mesh) (*v1beta1.Mesh, error) - Update(*v1beta1.Mesh) (*v1beta1.Mesh, error) - UpdateStatus(*v1beta1.Mesh) (*v1beta1.Mesh, error) - Delete(name string, options *v1.DeleteOptions) error - DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error - Get(name string, options v1.GetOptions) (*v1beta1.Mesh, error) - List(opts v1.ListOptions) (*v1beta1.MeshList, error) - Watch(opts v1.ListOptions) (watch.Interface, error) - Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Mesh, err error) + Create(ctx context.Context, mesh *v1beta1.Mesh, opts v1.CreateOptions) (*v1beta1.Mesh, error) + Update(ctx context.Context, mesh *v1beta1.Mesh, opts v1.UpdateOptions) (*v1beta1.Mesh, error) + UpdateStatus(ctx context.Context, mesh *v1beta1.Mesh, opts v1.UpdateOptions) (*v1beta1.Mesh, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1beta1.Mesh, error) + List(ctx context.Context, opts v1.ListOptions) (*v1beta1.MeshList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.Mesh, err error) MeshExpansion } @@ -62,19 +63,19 @@ func newMeshes(c *AppmeshV1beta1Client) *meshes { } // Get takes name of the mesh, and returns the corresponding mesh object, and an error if there is any. -func (c *meshes) Get(name string, options v1.GetOptions) (result *v1beta1.Mesh, err error) { +func (c *meshes) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.Mesh, err error) { result = &v1beta1.Mesh{} err = c.client.Get(). Resource("meshes"). Name(name). VersionedParams(&options, scheme.ParameterCodec). - Do(). + Do(ctx). Into(result) return } // List takes label and field selectors, and returns the list of Meshes that match those selectors. -func (c *meshes) List(opts v1.ListOptions) (result *v1beta1.MeshList, err error) { +func (c *meshes) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.MeshList, err error) { var timeout time.Duration if opts.TimeoutSeconds != nil { timeout = time.Duration(*opts.TimeoutSeconds) * time.Second @@ -84,13 +85,13 @@ func (c *meshes) List(opts v1.ListOptions) (result *v1beta1.MeshList, err error) Resource("meshes"). VersionedParams(&opts, scheme.ParameterCodec). Timeout(timeout). - Do(). + Do(ctx). Into(result) return } // Watch returns a watch.Interface that watches the requested meshes. -func (c *meshes) Watch(opts v1.ListOptions) (watch.Interface, error) { +func (c *meshes) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration if opts.TimeoutSeconds != nil { timeout = time.Duration(*opts.TimeoutSeconds) * time.Second @@ -100,81 +101,84 @@ func (c *meshes) Watch(opts v1.ListOptions) (watch.Interface, error) { Resource("meshes"). VersionedParams(&opts, scheme.ParameterCodec). Timeout(timeout). - Watch() + Watch(ctx) } // Create takes the representation of a mesh and creates it. Returns the server's representation of the mesh, and an error, if there is any. -func (c *meshes) Create(mesh *v1beta1.Mesh) (result *v1beta1.Mesh, err error) { +func (c *meshes) Create(ctx context.Context, mesh *v1beta1.Mesh, opts v1.CreateOptions) (result *v1beta1.Mesh, err error) { result = &v1beta1.Mesh{} err = c.client.Post(). Resource("meshes"). + VersionedParams(&opts, scheme.ParameterCodec). Body(mesh). - Do(). + Do(ctx). Into(result) return } // Update takes the representation of a mesh and updates it. Returns the server's representation of the mesh, and an error, if there is any. -func (c *meshes) Update(mesh *v1beta1.Mesh) (result *v1beta1.Mesh, err error) { +func (c *meshes) Update(ctx context.Context, mesh *v1beta1.Mesh, opts v1.UpdateOptions) (result *v1beta1.Mesh, err error) { result = &v1beta1.Mesh{} err = c.client.Put(). Resource("meshes"). Name(mesh.Name). + VersionedParams(&opts, scheme.ParameterCodec). Body(mesh). - Do(). + Do(ctx). Into(result) return } // UpdateStatus was generated because the type contains a Status member. // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). - -func (c *meshes) UpdateStatus(mesh *v1beta1.Mesh) (result *v1beta1.Mesh, err error) { +func (c *meshes) UpdateStatus(ctx context.Context, mesh *v1beta1.Mesh, opts v1.UpdateOptions) (result *v1beta1.Mesh, err error) { result = &v1beta1.Mesh{} err = c.client.Put(). Resource("meshes"). Name(mesh.Name). SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). Body(mesh). - Do(). + Do(ctx). Into(result) return } // Delete takes name of the mesh and deletes it. Returns an error if one occurs. -func (c *meshes) Delete(name string, options *v1.DeleteOptions) error { +func (c *meshes) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { return c.client.Delete(). Resource("meshes"). Name(name). - Body(options). - Do(). + Body(&opts). + Do(ctx). Error() } // DeleteCollection deletes a collection of objects. -func (c *meshes) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { +func (c *meshes) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { var timeout time.Duration - if listOptions.TimeoutSeconds != nil { - timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second } return c.client.Delete(). Resource("meshes"). - VersionedParams(&listOptions, scheme.ParameterCodec). + VersionedParams(&listOpts, scheme.ParameterCodec). Timeout(timeout). - Body(options). - Do(). + Body(&opts). + Do(ctx). Error() } // Patch applies the patch and returns the patched mesh. -func (c *meshes) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Mesh, err error) { +func (c *meshes) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.Mesh, err error) { result = &v1beta1.Mesh{} err = c.client.Patch(pt). Resource("meshes"). - SubResource(subresources...). Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). Body(data). - Do(). + Do(ctx). Into(result) return } diff --git a/pkg/client/clientset/versioned/typed/appmesh/v1beta1/virtualnode.go b/pkg/client/clientset/versioned/typed/appmesh/v1beta1/virtualnode.go index fb97d12f..511659d9 100644 --- a/pkg/client/clientset/versioned/typed/appmesh/v1beta1/virtualnode.go +++ b/pkg/client/clientset/versioned/typed/appmesh/v1beta1/virtualnode.go @@ -19,6 +19,7 @@ limitations under the License. package v1beta1 import ( + "context" "time" v1beta1 "github.com/weaveworks/flagger/pkg/apis/appmesh/v1beta1" @@ -37,15 +38,15 @@ type VirtualNodesGetter interface { // VirtualNodeInterface has methods to work with VirtualNode resources. type VirtualNodeInterface interface { - Create(*v1beta1.VirtualNode) (*v1beta1.VirtualNode, error) - Update(*v1beta1.VirtualNode) (*v1beta1.VirtualNode, error) - UpdateStatus(*v1beta1.VirtualNode) (*v1beta1.VirtualNode, error) - Delete(name string, options *v1.DeleteOptions) error - DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error - Get(name string, options v1.GetOptions) (*v1beta1.VirtualNode, error) - List(opts v1.ListOptions) (*v1beta1.VirtualNodeList, error) - Watch(opts v1.ListOptions) (watch.Interface, error) - Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.VirtualNode, err error) + Create(ctx context.Context, virtualNode *v1beta1.VirtualNode, opts v1.CreateOptions) (*v1beta1.VirtualNode, error) + Update(ctx context.Context, virtualNode *v1beta1.VirtualNode, opts v1.UpdateOptions) (*v1beta1.VirtualNode, error) + UpdateStatus(ctx context.Context, virtualNode *v1beta1.VirtualNode, opts v1.UpdateOptions) (*v1beta1.VirtualNode, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1beta1.VirtualNode, error) + List(ctx context.Context, opts v1.ListOptions) (*v1beta1.VirtualNodeList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.VirtualNode, err error) VirtualNodeExpansion } @@ -64,20 +65,20 @@ func newVirtualNodes(c *AppmeshV1beta1Client, namespace string) *virtualNodes { } // Get takes name of the virtualNode, and returns the corresponding virtualNode object, and an error if there is any. -func (c *virtualNodes) Get(name string, options v1.GetOptions) (result *v1beta1.VirtualNode, err error) { +func (c *virtualNodes) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.VirtualNode, err error) { result = &v1beta1.VirtualNode{} err = c.client.Get(). Namespace(c.ns). Resource("virtualnodes"). Name(name). VersionedParams(&options, scheme.ParameterCodec). - Do(). + Do(ctx). Into(result) return } // List takes label and field selectors, and returns the list of VirtualNodes that match those selectors. -func (c *virtualNodes) List(opts v1.ListOptions) (result *v1beta1.VirtualNodeList, err error) { +func (c *virtualNodes) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.VirtualNodeList, err error) { var timeout time.Duration if opts.TimeoutSeconds != nil { timeout = time.Duration(*opts.TimeoutSeconds) * time.Second @@ -88,13 +89,13 @@ func (c *virtualNodes) List(opts v1.ListOptions) (result *v1beta1.VirtualNodeLis Resource("virtualnodes"). VersionedParams(&opts, scheme.ParameterCodec). Timeout(timeout). - Do(). + Do(ctx). Into(result) return } // Watch returns a watch.Interface that watches the requested virtualNodes. -func (c *virtualNodes) Watch(opts v1.ListOptions) (watch.Interface, error) { +func (c *virtualNodes) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration if opts.TimeoutSeconds != nil { timeout = time.Duration(*opts.TimeoutSeconds) * time.Second @@ -105,87 +106,90 @@ func (c *virtualNodes) Watch(opts v1.ListOptions) (watch.Interface, error) { Resource("virtualnodes"). VersionedParams(&opts, scheme.ParameterCodec). Timeout(timeout). - Watch() + Watch(ctx) } // Create takes the representation of a virtualNode and creates it. Returns the server's representation of the virtualNode, and an error, if there is any. -func (c *virtualNodes) Create(virtualNode *v1beta1.VirtualNode) (result *v1beta1.VirtualNode, err error) { +func (c *virtualNodes) Create(ctx context.Context, virtualNode *v1beta1.VirtualNode, opts v1.CreateOptions) (result *v1beta1.VirtualNode, err error) { result = &v1beta1.VirtualNode{} err = c.client.Post(). Namespace(c.ns). Resource("virtualnodes"). + VersionedParams(&opts, scheme.ParameterCodec). Body(virtualNode). - Do(). + Do(ctx). Into(result) return } // Update takes the representation of a virtualNode and updates it. Returns the server's representation of the virtualNode, and an error, if there is any. -func (c *virtualNodes) Update(virtualNode *v1beta1.VirtualNode) (result *v1beta1.VirtualNode, err error) { +func (c *virtualNodes) Update(ctx context.Context, virtualNode *v1beta1.VirtualNode, opts v1.UpdateOptions) (result *v1beta1.VirtualNode, err error) { result = &v1beta1.VirtualNode{} err = c.client.Put(). Namespace(c.ns). Resource("virtualnodes"). Name(virtualNode.Name). + VersionedParams(&opts, scheme.ParameterCodec). Body(virtualNode). - Do(). + Do(ctx). Into(result) return } // UpdateStatus was generated because the type contains a Status member. // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). - -func (c *virtualNodes) UpdateStatus(virtualNode *v1beta1.VirtualNode) (result *v1beta1.VirtualNode, err error) { +func (c *virtualNodes) UpdateStatus(ctx context.Context, virtualNode *v1beta1.VirtualNode, opts v1.UpdateOptions) (result *v1beta1.VirtualNode, err error) { result = &v1beta1.VirtualNode{} err = c.client.Put(). Namespace(c.ns). Resource("virtualnodes"). Name(virtualNode.Name). SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). Body(virtualNode). - Do(). + Do(ctx). Into(result) return } // Delete takes name of the virtualNode and deletes it. Returns an error if one occurs. -func (c *virtualNodes) Delete(name string, options *v1.DeleteOptions) error { +func (c *virtualNodes) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { return c.client.Delete(). Namespace(c.ns). Resource("virtualnodes"). Name(name). - Body(options). - Do(). + Body(&opts). + Do(ctx). Error() } // DeleteCollection deletes a collection of objects. -func (c *virtualNodes) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { +func (c *virtualNodes) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { var timeout time.Duration - if listOptions.TimeoutSeconds != nil { - timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second } return c.client.Delete(). Namespace(c.ns). Resource("virtualnodes"). - VersionedParams(&listOptions, scheme.ParameterCodec). + VersionedParams(&listOpts, scheme.ParameterCodec). Timeout(timeout). - Body(options). - Do(). + Body(&opts). + Do(ctx). Error() } // Patch applies the patch and returns the patched virtualNode. -func (c *virtualNodes) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.VirtualNode, err error) { +func (c *virtualNodes) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.VirtualNode, err error) { result = &v1beta1.VirtualNode{} err = c.client.Patch(pt). Namespace(c.ns). Resource("virtualnodes"). - SubResource(subresources...). Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). Body(data). - Do(). + Do(ctx). Into(result) return } diff --git a/pkg/client/clientset/versioned/typed/appmesh/v1beta1/virtualservice.go b/pkg/client/clientset/versioned/typed/appmesh/v1beta1/virtualservice.go index 1ce926c9..cda35467 100644 --- a/pkg/client/clientset/versioned/typed/appmesh/v1beta1/virtualservice.go +++ b/pkg/client/clientset/versioned/typed/appmesh/v1beta1/virtualservice.go @@ -19,6 +19,7 @@ limitations under the License. package v1beta1 import ( + "context" "time" v1beta1 "github.com/weaveworks/flagger/pkg/apis/appmesh/v1beta1" @@ -37,15 +38,15 @@ type VirtualServicesGetter interface { // VirtualServiceInterface has methods to work with VirtualService resources. type VirtualServiceInterface interface { - Create(*v1beta1.VirtualService) (*v1beta1.VirtualService, error) - Update(*v1beta1.VirtualService) (*v1beta1.VirtualService, error) - UpdateStatus(*v1beta1.VirtualService) (*v1beta1.VirtualService, error) - Delete(name string, options *v1.DeleteOptions) error - DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error - Get(name string, options v1.GetOptions) (*v1beta1.VirtualService, error) - List(opts v1.ListOptions) (*v1beta1.VirtualServiceList, error) - Watch(opts v1.ListOptions) (watch.Interface, error) - Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.VirtualService, err error) + Create(ctx context.Context, virtualService *v1beta1.VirtualService, opts v1.CreateOptions) (*v1beta1.VirtualService, error) + Update(ctx context.Context, virtualService *v1beta1.VirtualService, opts v1.UpdateOptions) (*v1beta1.VirtualService, error) + UpdateStatus(ctx context.Context, virtualService *v1beta1.VirtualService, opts v1.UpdateOptions) (*v1beta1.VirtualService, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1beta1.VirtualService, error) + List(ctx context.Context, opts v1.ListOptions) (*v1beta1.VirtualServiceList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.VirtualService, err error) VirtualServiceExpansion } @@ -64,20 +65,20 @@ func newVirtualServices(c *AppmeshV1beta1Client, namespace string) *virtualServi } // Get takes name of the virtualService, and returns the corresponding virtualService object, and an error if there is any. -func (c *virtualServices) Get(name string, options v1.GetOptions) (result *v1beta1.VirtualService, err error) { +func (c *virtualServices) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.VirtualService, err error) { result = &v1beta1.VirtualService{} err = c.client.Get(). Namespace(c.ns). Resource("virtualservices"). Name(name). VersionedParams(&options, scheme.ParameterCodec). - Do(). + Do(ctx). Into(result) return } // List takes label and field selectors, and returns the list of VirtualServices that match those selectors. -func (c *virtualServices) List(opts v1.ListOptions) (result *v1beta1.VirtualServiceList, err error) { +func (c *virtualServices) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.VirtualServiceList, err error) { var timeout time.Duration if opts.TimeoutSeconds != nil { timeout = time.Duration(*opts.TimeoutSeconds) * time.Second @@ -88,13 +89,13 @@ func (c *virtualServices) List(opts v1.ListOptions) (result *v1beta1.VirtualServ Resource("virtualservices"). VersionedParams(&opts, scheme.ParameterCodec). Timeout(timeout). - Do(). + Do(ctx). Into(result) return } // Watch returns a watch.Interface that watches the requested virtualServices. -func (c *virtualServices) Watch(opts v1.ListOptions) (watch.Interface, error) { +func (c *virtualServices) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration if opts.TimeoutSeconds != nil { timeout = time.Duration(*opts.TimeoutSeconds) * time.Second @@ -105,87 +106,90 @@ func (c *virtualServices) Watch(opts v1.ListOptions) (watch.Interface, error) { Resource("virtualservices"). VersionedParams(&opts, scheme.ParameterCodec). Timeout(timeout). - Watch() + Watch(ctx) } // Create takes the representation of a virtualService and creates it. Returns the server's representation of the virtualService, and an error, if there is any. -func (c *virtualServices) Create(virtualService *v1beta1.VirtualService) (result *v1beta1.VirtualService, err error) { +func (c *virtualServices) Create(ctx context.Context, virtualService *v1beta1.VirtualService, opts v1.CreateOptions) (result *v1beta1.VirtualService, err error) { result = &v1beta1.VirtualService{} err = c.client.Post(). Namespace(c.ns). Resource("virtualservices"). + VersionedParams(&opts, scheme.ParameterCodec). Body(virtualService). - Do(). + Do(ctx). Into(result) return } // Update takes the representation of a virtualService and updates it. Returns the server's representation of the virtualService, and an error, if there is any. -func (c *virtualServices) Update(virtualService *v1beta1.VirtualService) (result *v1beta1.VirtualService, err error) { +func (c *virtualServices) Update(ctx context.Context, virtualService *v1beta1.VirtualService, opts v1.UpdateOptions) (result *v1beta1.VirtualService, err error) { result = &v1beta1.VirtualService{} err = c.client.Put(). Namespace(c.ns). Resource("virtualservices"). Name(virtualService.Name). + VersionedParams(&opts, scheme.ParameterCodec). Body(virtualService). - Do(). + Do(ctx). Into(result) return } // UpdateStatus was generated because the type contains a Status member. // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). - -func (c *virtualServices) UpdateStatus(virtualService *v1beta1.VirtualService) (result *v1beta1.VirtualService, err error) { +func (c *virtualServices) UpdateStatus(ctx context.Context, virtualService *v1beta1.VirtualService, opts v1.UpdateOptions) (result *v1beta1.VirtualService, err error) { result = &v1beta1.VirtualService{} err = c.client.Put(). Namespace(c.ns). Resource("virtualservices"). Name(virtualService.Name). SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). Body(virtualService). - Do(). + Do(ctx). Into(result) return } // Delete takes name of the virtualService and deletes it. Returns an error if one occurs. -func (c *virtualServices) Delete(name string, options *v1.DeleteOptions) error { +func (c *virtualServices) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { return c.client.Delete(). Namespace(c.ns). Resource("virtualservices"). Name(name). - Body(options). - Do(). + Body(&opts). + Do(ctx). Error() } // DeleteCollection deletes a collection of objects. -func (c *virtualServices) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { +func (c *virtualServices) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { var timeout time.Duration - if listOptions.TimeoutSeconds != nil { - timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second } return c.client.Delete(). Namespace(c.ns). Resource("virtualservices"). - VersionedParams(&listOptions, scheme.ParameterCodec). + VersionedParams(&listOpts, scheme.ParameterCodec). Timeout(timeout). - Body(options). - Do(). + Body(&opts). + Do(ctx). Error() } // Patch applies the patch and returns the patched virtualService. -func (c *virtualServices) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.VirtualService, err error) { +func (c *virtualServices) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.VirtualService, err error) { result = &v1beta1.VirtualService{} err = c.client.Patch(pt). Namespace(c.ns). Resource("virtualservices"). - SubResource(subresources...). Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). Body(data). - Do(). + Do(ctx). Into(result) return } diff --git a/pkg/client/clientset/versioned/typed/flagger/v1beta1/alertprovider.go b/pkg/client/clientset/versioned/typed/flagger/v1beta1/alertprovider.go index 99ba1478..12451147 100644 --- a/pkg/client/clientset/versioned/typed/flagger/v1beta1/alertprovider.go +++ b/pkg/client/clientset/versioned/typed/flagger/v1beta1/alertprovider.go @@ -19,6 +19,7 @@ limitations under the License. package v1beta1 import ( + "context" "time" v1beta1 "github.com/weaveworks/flagger/pkg/apis/flagger/v1beta1" @@ -37,15 +38,15 @@ type AlertProvidersGetter interface { // AlertProviderInterface has methods to work with AlertProvider resources. type AlertProviderInterface interface { - Create(*v1beta1.AlertProvider) (*v1beta1.AlertProvider, error) - Update(*v1beta1.AlertProvider) (*v1beta1.AlertProvider, error) - UpdateStatus(*v1beta1.AlertProvider) (*v1beta1.AlertProvider, error) - Delete(name string, options *v1.DeleteOptions) error - DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error - Get(name string, options v1.GetOptions) (*v1beta1.AlertProvider, error) - List(opts v1.ListOptions) (*v1beta1.AlertProviderList, error) - Watch(opts v1.ListOptions) (watch.Interface, error) - Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.AlertProvider, err error) + Create(ctx context.Context, alertProvider *v1beta1.AlertProvider, opts v1.CreateOptions) (*v1beta1.AlertProvider, error) + Update(ctx context.Context, alertProvider *v1beta1.AlertProvider, opts v1.UpdateOptions) (*v1beta1.AlertProvider, error) + UpdateStatus(ctx context.Context, alertProvider *v1beta1.AlertProvider, opts v1.UpdateOptions) (*v1beta1.AlertProvider, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1beta1.AlertProvider, error) + List(ctx context.Context, opts v1.ListOptions) (*v1beta1.AlertProviderList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.AlertProvider, err error) AlertProviderExpansion } @@ -64,20 +65,20 @@ func newAlertProviders(c *FlaggerV1beta1Client, namespace string) *alertProvider } // Get takes name of the alertProvider, and returns the corresponding alertProvider object, and an error if there is any. -func (c *alertProviders) Get(name string, options v1.GetOptions) (result *v1beta1.AlertProvider, err error) { +func (c *alertProviders) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.AlertProvider, err error) { result = &v1beta1.AlertProvider{} err = c.client.Get(). Namespace(c.ns). Resource("alertproviders"). Name(name). VersionedParams(&options, scheme.ParameterCodec). - Do(). + Do(ctx). Into(result) return } // List takes label and field selectors, and returns the list of AlertProviders that match those selectors. -func (c *alertProviders) List(opts v1.ListOptions) (result *v1beta1.AlertProviderList, err error) { +func (c *alertProviders) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.AlertProviderList, err error) { var timeout time.Duration if opts.TimeoutSeconds != nil { timeout = time.Duration(*opts.TimeoutSeconds) * time.Second @@ -88,13 +89,13 @@ func (c *alertProviders) List(opts v1.ListOptions) (result *v1beta1.AlertProvide Resource("alertproviders"). VersionedParams(&opts, scheme.ParameterCodec). Timeout(timeout). - Do(). + Do(ctx). Into(result) return } // Watch returns a watch.Interface that watches the requested alertProviders. -func (c *alertProviders) Watch(opts v1.ListOptions) (watch.Interface, error) { +func (c *alertProviders) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration if opts.TimeoutSeconds != nil { timeout = time.Duration(*opts.TimeoutSeconds) * time.Second @@ -105,87 +106,90 @@ func (c *alertProviders) Watch(opts v1.ListOptions) (watch.Interface, error) { Resource("alertproviders"). VersionedParams(&opts, scheme.ParameterCodec). Timeout(timeout). - Watch() + Watch(ctx) } // Create takes the representation of a alertProvider and creates it. Returns the server's representation of the alertProvider, and an error, if there is any. -func (c *alertProviders) Create(alertProvider *v1beta1.AlertProvider) (result *v1beta1.AlertProvider, err error) { +func (c *alertProviders) Create(ctx context.Context, alertProvider *v1beta1.AlertProvider, opts v1.CreateOptions) (result *v1beta1.AlertProvider, err error) { result = &v1beta1.AlertProvider{} err = c.client.Post(). Namespace(c.ns). Resource("alertproviders"). + VersionedParams(&opts, scheme.ParameterCodec). Body(alertProvider). - Do(). + Do(ctx). Into(result) return } // Update takes the representation of a alertProvider and updates it. Returns the server's representation of the alertProvider, and an error, if there is any. -func (c *alertProviders) Update(alertProvider *v1beta1.AlertProvider) (result *v1beta1.AlertProvider, err error) { +func (c *alertProviders) Update(ctx context.Context, alertProvider *v1beta1.AlertProvider, opts v1.UpdateOptions) (result *v1beta1.AlertProvider, err error) { result = &v1beta1.AlertProvider{} err = c.client.Put(). Namespace(c.ns). Resource("alertproviders"). Name(alertProvider.Name). + VersionedParams(&opts, scheme.ParameterCodec). Body(alertProvider). - Do(). + Do(ctx). Into(result) return } // UpdateStatus was generated because the type contains a Status member. // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). - -func (c *alertProviders) UpdateStatus(alertProvider *v1beta1.AlertProvider) (result *v1beta1.AlertProvider, err error) { +func (c *alertProviders) UpdateStatus(ctx context.Context, alertProvider *v1beta1.AlertProvider, opts v1.UpdateOptions) (result *v1beta1.AlertProvider, err error) { result = &v1beta1.AlertProvider{} err = c.client.Put(). Namespace(c.ns). Resource("alertproviders"). Name(alertProvider.Name). SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). Body(alertProvider). - Do(). + Do(ctx). Into(result) return } // Delete takes name of the alertProvider and deletes it. Returns an error if one occurs. -func (c *alertProviders) Delete(name string, options *v1.DeleteOptions) error { +func (c *alertProviders) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { return c.client.Delete(). Namespace(c.ns). Resource("alertproviders"). Name(name). - Body(options). - Do(). + Body(&opts). + Do(ctx). Error() } // DeleteCollection deletes a collection of objects. -func (c *alertProviders) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { +func (c *alertProviders) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { var timeout time.Duration - if listOptions.TimeoutSeconds != nil { - timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second } return c.client.Delete(). Namespace(c.ns). Resource("alertproviders"). - VersionedParams(&listOptions, scheme.ParameterCodec). + VersionedParams(&listOpts, scheme.ParameterCodec). Timeout(timeout). - Body(options). - Do(). + Body(&opts). + Do(ctx). Error() } // Patch applies the patch and returns the patched alertProvider. -func (c *alertProviders) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.AlertProvider, err error) { +func (c *alertProviders) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.AlertProvider, err error) { result = &v1beta1.AlertProvider{} err = c.client.Patch(pt). Namespace(c.ns). Resource("alertproviders"). - SubResource(subresources...). Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). Body(data). - Do(). + Do(ctx). Into(result) return } diff --git a/pkg/client/clientset/versioned/typed/flagger/v1beta1/canary.go b/pkg/client/clientset/versioned/typed/flagger/v1beta1/canary.go index 58415d4a..9852db85 100644 --- a/pkg/client/clientset/versioned/typed/flagger/v1beta1/canary.go +++ b/pkg/client/clientset/versioned/typed/flagger/v1beta1/canary.go @@ -19,6 +19,7 @@ limitations under the License. package v1beta1 import ( + "context" "time" v1beta1 "github.com/weaveworks/flagger/pkg/apis/flagger/v1beta1" @@ -37,15 +38,15 @@ type CanariesGetter interface { // CanaryInterface has methods to work with Canary resources. type CanaryInterface interface { - Create(*v1beta1.Canary) (*v1beta1.Canary, error) - Update(*v1beta1.Canary) (*v1beta1.Canary, error) - UpdateStatus(*v1beta1.Canary) (*v1beta1.Canary, error) - Delete(name string, options *v1.DeleteOptions) error - DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error - Get(name string, options v1.GetOptions) (*v1beta1.Canary, error) - List(opts v1.ListOptions) (*v1beta1.CanaryList, error) - Watch(opts v1.ListOptions) (watch.Interface, error) - Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Canary, err error) + Create(ctx context.Context, canary *v1beta1.Canary, opts v1.CreateOptions) (*v1beta1.Canary, error) + Update(ctx context.Context, canary *v1beta1.Canary, opts v1.UpdateOptions) (*v1beta1.Canary, error) + UpdateStatus(ctx context.Context, canary *v1beta1.Canary, opts v1.UpdateOptions) (*v1beta1.Canary, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1beta1.Canary, error) + List(ctx context.Context, opts v1.ListOptions) (*v1beta1.CanaryList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.Canary, err error) CanaryExpansion } @@ -64,20 +65,20 @@ func newCanaries(c *FlaggerV1beta1Client, namespace string) *canaries { } // Get takes name of the canary, and returns the corresponding canary object, and an error if there is any. -func (c *canaries) Get(name string, options v1.GetOptions) (result *v1beta1.Canary, err error) { +func (c *canaries) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.Canary, err error) { result = &v1beta1.Canary{} err = c.client.Get(). Namespace(c.ns). Resource("canaries"). Name(name). VersionedParams(&options, scheme.ParameterCodec). - Do(). + Do(ctx). Into(result) return } // List takes label and field selectors, and returns the list of Canaries that match those selectors. -func (c *canaries) List(opts v1.ListOptions) (result *v1beta1.CanaryList, err error) { +func (c *canaries) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.CanaryList, err error) { var timeout time.Duration if opts.TimeoutSeconds != nil { timeout = time.Duration(*opts.TimeoutSeconds) * time.Second @@ -88,13 +89,13 @@ func (c *canaries) List(opts v1.ListOptions) (result *v1beta1.CanaryList, err er Resource("canaries"). VersionedParams(&opts, scheme.ParameterCodec). Timeout(timeout). - Do(). + Do(ctx). Into(result) return } // Watch returns a watch.Interface that watches the requested canaries. -func (c *canaries) Watch(opts v1.ListOptions) (watch.Interface, error) { +func (c *canaries) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration if opts.TimeoutSeconds != nil { timeout = time.Duration(*opts.TimeoutSeconds) * time.Second @@ -105,87 +106,90 @@ func (c *canaries) Watch(opts v1.ListOptions) (watch.Interface, error) { Resource("canaries"). VersionedParams(&opts, scheme.ParameterCodec). Timeout(timeout). - Watch() + Watch(ctx) } // Create takes the representation of a canary and creates it. Returns the server's representation of the canary, and an error, if there is any. -func (c *canaries) Create(canary *v1beta1.Canary) (result *v1beta1.Canary, err error) { +func (c *canaries) Create(ctx context.Context, canary *v1beta1.Canary, opts v1.CreateOptions) (result *v1beta1.Canary, err error) { result = &v1beta1.Canary{} err = c.client.Post(). Namespace(c.ns). Resource("canaries"). + VersionedParams(&opts, scheme.ParameterCodec). Body(canary). - Do(). + Do(ctx). Into(result) return } // Update takes the representation of a canary and updates it. Returns the server's representation of the canary, and an error, if there is any. -func (c *canaries) Update(canary *v1beta1.Canary) (result *v1beta1.Canary, err error) { +func (c *canaries) Update(ctx context.Context, canary *v1beta1.Canary, opts v1.UpdateOptions) (result *v1beta1.Canary, err error) { result = &v1beta1.Canary{} err = c.client.Put(). Namespace(c.ns). Resource("canaries"). Name(canary.Name). + VersionedParams(&opts, scheme.ParameterCodec). Body(canary). - Do(). + Do(ctx). Into(result) return } // UpdateStatus was generated because the type contains a Status member. // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). - -func (c *canaries) UpdateStatus(canary *v1beta1.Canary) (result *v1beta1.Canary, err error) { +func (c *canaries) UpdateStatus(ctx context.Context, canary *v1beta1.Canary, opts v1.UpdateOptions) (result *v1beta1.Canary, err error) { result = &v1beta1.Canary{} err = c.client.Put(). Namespace(c.ns). Resource("canaries"). Name(canary.Name). SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). Body(canary). - Do(). + Do(ctx). Into(result) return } // Delete takes name of the canary and deletes it. Returns an error if one occurs. -func (c *canaries) Delete(name string, options *v1.DeleteOptions) error { +func (c *canaries) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { return c.client.Delete(). Namespace(c.ns). Resource("canaries"). Name(name). - Body(options). - Do(). + Body(&opts). + Do(ctx). Error() } // DeleteCollection deletes a collection of objects. -func (c *canaries) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { +func (c *canaries) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { var timeout time.Duration - if listOptions.TimeoutSeconds != nil { - timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second } return c.client.Delete(). Namespace(c.ns). Resource("canaries"). - VersionedParams(&listOptions, scheme.ParameterCodec). + VersionedParams(&listOpts, scheme.ParameterCodec). Timeout(timeout). - Body(options). - Do(). + Body(&opts). + Do(ctx). Error() } // Patch applies the patch and returns the patched canary. -func (c *canaries) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Canary, err error) { +func (c *canaries) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.Canary, err error) { result = &v1beta1.Canary{} err = c.client.Patch(pt). Namespace(c.ns). Resource("canaries"). - SubResource(subresources...). Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). Body(data). - Do(). + Do(ctx). Into(result) return } diff --git a/pkg/client/clientset/versioned/typed/flagger/v1beta1/fake/fake_alertprovider.go b/pkg/client/clientset/versioned/typed/flagger/v1beta1/fake/fake_alertprovider.go index f746e39e..d9cbbcff 100644 --- a/pkg/client/clientset/versioned/typed/flagger/v1beta1/fake/fake_alertprovider.go +++ b/pkg/client/clientset/versioned/typed/flagger/v1beta1/fake/fake_alertprovider.go @@ -19,6 +19,8 @@ limitations under the License. package fake import ( + "context" + v1beta1 "github.com/weaveworks/flagger/pkg/apis/flagger/v1beta1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" @@ -39,7 +41,7 @@ var alertprovidersResource = schema.GroupVersionResource{Group: "flagger.app", V var alertprovidersKind = schema.GroupVersionKind{Group: "flagger.app", Version: "v1beta1", Kind: "AlertProvider"} // Get takes name of the alertProvider, and returns the corresponding alertProvider object, and an error if there is any. -func (c *FakeAlertProviders) Get(name string, options v1.GetOptions) (result *v1beta1.AlertProvider, err error) { +func (c *FakeAlertProviders) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.AlertProvider, err error) { obj, err := c.Fake. Invokes(testing.NewGetAction(alertprovidersResource, c.ns, name), &v1beta1.AlertProvider{}) @@ -50,7 +52,7 @@ func (c *FakeAlertProviders) Get(name string, options v1.GetOptions) (result *v1 } // List takes label and field selectors, and returns the list of AlertProviders that match those selectors. -func (c *FakeAlertProviders) List(opts v1.ListOptions) (result *v1beta1.AlertProviderList, err error) { +func (c *FakeAlertProviders) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.AlertProviderList, err error) { obj, err := c.Fake. Invokes(testing.NewListAction(alertprovidersResource, alertprovidersKind, c.ns, opts), &v1beta1.AlertProviderList{}) @@ -72,14 +74,14 @@ func (c *FakeAlertProviders) List(opts v1.ListOptions) (result *v1beta1.AlertPro } // Watch returns a watch.Interface that watches the requested alertProviders. -func (c *FakeAlertProviders) Watch(opts v1.ListOptions) (watch.Interface, error) { +func (c *FakeAlertProviders) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.Fake. InvokesWatch(testing.NewWatchAction(alertprovidersResource, c.ns, opts)) } // Create takes the representation of a alertProvider and creates it. Returns the server's representation of the alertProvider, and an error, if there is any. -func (c *FakeAlertProviders) Create(alertProvider *v1beta1.AlertProvider) (result *v1beta1.AlertProvider, err error) { +func (c *FakeAlertProviders) Create(ctx context.Context, alertProvider *v1beta1.AlertProvider, opts v1.CreateOptions) (result *v1beta1.AlertProvider, err error) { obj, err := c.Fake. Invokes(testing.NewCreateAction(alertprovidersResource, c.ns, alertProvider), &v1beta1.AlertProvider{}) @@ -90,7 +92,7 @@ func (c *FakeAlertProviders) Create(alertProvider *v1beta1.AlertProvider) (resul } // Update takes the representation of a alertProvider and updates it. Returns the server's representation of the alertProvider, and an error, if there is any. -func (c *FakeAlertProviders) Update(alertProvider *v1beta1.AlertProvider) (result *v1beta1.AlertProvider, err error) { +func (c *FakeAlertProviders) Update(ctx context.Context, alertProvider *v1beta1.AlertProvider, opts v1.UpdateOptions) (result *v1beta1.AlertProvider, err error) { obj, err := c.Fake. Invokes(testing.NewUpdateAction(alertprovidersResource, c.ns, alertProvider), &v1beta1.AlertProvider{}) @@ -102,7 +104,7 @@ func (c *FakeAlertProviders) Update(alertProvider *v1beta1.AlertProvider) (resul // UpdateStatus was generated because the type contains a Status member. // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *FakeAlertProviders) UpdateStatus(alertProvider *v1beta1.AlertProvider) (*v1beta1.AlertProvider, error) { +func (c *FakeAlertProviders) UpdateStatus(ctx context.Context, alertProvider *v1beta1.AlertProvider, opts v1.UpdateOptions) (*v1beta1.AlertProvider, error) { obj, err := c.Fake. Invokes(testing.NewUpdateSubresourceAction(alertprovidersResource, "status", c.ns, alertProvider), &v1beta1.AlertProvider{}) @@ -113,7 +115,7 @@ func (c *FakeAlertProviders) UpdateStatus(alertProvider *v1beta1.AlertProvider) } // Delete takes name of the alertProvider and deletes it. Returns an error if one occurs. -func (c *FakeAlertProviders) Delete(name string, options *v1.DeleteOptions) error { +func (c *FakeAlertProviders) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { _, err := c.Fake. Invokes(testing.NewDeleteAction(alertprovidersResource, c.ns, name), &v1beta1.AlertProvider{}) @@ -121,15 +123,15 @@ func (c *FakeAlertProviders) Delete(name string, options *v1.DeleteOptions) erro } // DeleteCollection deletes a collection of objects. -func (c *FakeAlertProviders) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(alertprovidersResource, c.ns, listOptions) +func (c *FakeAlertProviders) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(alertprovidersResource, c.ns, listOpts) _, err := c.Fake.Invokes(action, &v1beta1.AlertProviderList{}) return err } // Patch applies the patch and returns the patched alertProvider. -func (c *FakeAlertProviders) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.AlertProvider, err error) { +func (c *FakeAlertProviders) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.AlertProvider, err error) { obj, err := c.Fake. Invokes(testing.NewPatchSubresourceAction(alertprovidersResource, c.ns, name, pt, data, subresources...), &v1beta1.AlertProvider{}) diff --git a/pkg/client/clientset/versioned/typed/flagger/v1beta1/fake/fake_canary.go b/pkg/client/clientset/versioned/typed/flagger/v1beta1/fake/fake_canary.go index 9b37eab5..d9fa8ad2 100644 --- a/pkg/client/clientset/versioned/typed/flagger/v1beta1/fake/fake_canary.go +++ b/pkg/client/clientset/versioned/typed/flagger/v1beta1/fake/fake_canary.go @@ -19,6 +19,8 @@ limitations under the License. package fake import ( + "context" + v1beta1 "github.com/weaveworks/flagger/pkg/apis/flagger/v1beta1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" @@ -39,7 +41,7 @@ var canariesResource = schema.GroupVersionResource{Group: "flagger.app", Version var canariesKind = schema.GroupVersionKind{Group: "flagger.app", Version: "v1beta1", Kind: "Canary"} // Get takes name of the canary, and returns the corresponding canary object, and an error if there is any. -func (c *FakeCanaries) Get(name string, options v1.GetOptions) (result *v1beta1.Canary, err error) { +func (c *FakeCanaries) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.Canary, err error) { obj, err := c.Fake. Invokes(testing.NewGetAction(canariesResource, c.ns, name), &v1beta1.Canary{}) @@ -50,7 +52,7 @@ func (c *FakeCanaries) Get(name string, options v1.GetOptions) (result *v1beta1. } // List takes label and field selectors, and returns the list of Canaries that match those selectors. -func (c *FakeCanaries) List(opts v1.ListOptions) (result *v1beta1.CanaryList, err error) { +func (c *FakeCanaries) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.CanaryList, err error) { obj, err := c.Fake. Invokes(testing.NewListAction(canariesResource, canariesKind, c.ns, opts), &v1beta1.CanaryList{}) @@ -72,14 +74,14 @@ func (c *FakeCanaries) List(opts v1.ListOptions) (result *v1beta1.CanaryList, er } // Watch returns a watch.Interface that watches the requested canaries. -func (c *FakeCanaries) Watch(opts v1.ListOptions) (watch.Interface, error) { +func (c *FakeCanaries) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.Fake. InvokesWatch(testing.NewWatchAction(canariesResource, c.ns, opts)) } // Create takes the representation of a canary and creates it. Returns the server's representation of the canary, and an error, if there is any. -func (c *FakeCanaries) Create(canary *v1beta1.Canary) (result *v1beta1.Canary, err error) { +func (c *FakeCanaries) Create(ctx context.Context, canary *v1beta1.Canary, opts v1.CreateOptions) (result *v1beta1.Canary, err error) { obj, err := c.Fake. Invokes(testing.NewCreateAction(canariesResource, c.ns, canary), &v1beta1.Canary{}) @@ -90,7 +92,7 @@ func (c *FakeCanaries) Create(canary *v1beta1.Canary) (result *v1beta1.Canary, e } // Update takes the representation of a canary and updates it. Returns the server's representation of the canary, and an error, if there is any. -func (c *FakeCanaries) Update(canary *v1beta1.Canary) (result *v1beta1.Canary, err error) { +func (c *FakeCanaries) Update(ctx context.Context, canary *v1beta1.Canary, opts v1.UpdateOptions) (result *v1beta1.Canary, err error) { obj, err := c.Fake. Invokes(testing.NewUpdateAction(canariesResource, c.ns, canary), &v1beta1.Canary{}) @@ -102,7 +104,7 @@ func (c *FakeCanaries) Update(canary *v1beta1.Canary) (result *v1beta1.Canary, e // UpdateStatus was generated because the type contains a Status member. // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *FakeCanaries) UpdateStatus(canary *v1beta1.Canary) (*v1beta1.Canary, error) { +func (c *FakeCanaries) UpdateStatus(ctx context.Context, canary *v1beta1.Canary, opts v1.UpdateOptions) (*v1beta1.Canary, error) { obj, err := c.Fake. Invokes(testing.NewUpdateSubresourceAction(canariesResource, "status", c.ns, canary), &v1beta1.Canary{}) @@ -113,7 +115,7 @@ func (c *FakeCanaries) UpdateStatus(canary *v1beta1.Canary) (*v1beta1.Canary, er } // Delete takes name of the canary and deletes it. Returns an error if one occurs. -func (c *FakeCanaries) Delete(name string, options *v1.DeleteOptions) error { +func (c *FakeCanaries) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { _, err := c.Fake. Invokes(testing.NewDeleteAction(canariesResource, c.ns, name), &v1beta1.Canary{}) @@ -121,15 +123,15 @@ func (c *FakeCanaries) Delete(name string, options *v1.DeleteOptions) error { } // DeleteCollection deletes a collection of objects. -func (c *FakeCanaries) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(canariesResource, c.ns, listOptions) +func (c *FakeCanaries) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(canariesResource, c.ns, listOpts) _, err := c.Fake.Invokes(action, &v1beta1.CanaryList{}) return err } // Patch applies the patch and returns the patched canary. -func (c *FakeCanaries) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Canary, err error) { +func (c *FakeCanaries) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.Canary, err error) { obj, err := c.Fake. Invokes(testing.NewPatchSubresourceAction(canariesResource, c.ns, name, pt, data, subresources...), &v1beta1.Canary{}) diff --git a/pkg/client/clientset/versioned/typed/flagger/v1beta1/fake/fake_metrictemplate.go b/pkg/client/clientset/versioned/typed/flagger/v1beta1/fake/fake_metrictemplate.go index 7bb5702c..e8b644b1 100644 --- a/pkg/client/clientset/versioned/typed/flagger/v1beta1/fake/fake_metrictemplate.go +++ b/pkg/client/clientset/versioned/typed/flagger/v1beta1/fake/fake_metrictemplate.go @@ -19,6 +19,8 @@ limitations under the License. package fake import ( + "context" + v1beta1 "github.com/weaveworks/flagger/pkg/apis/flagger/v1beta1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" @@ -39,7 +41,7 @@ var metrictemplatesResource = schema.GroupVersionResource{Group: "flagger.app", var metrictemplatesKind = schema.GroupVersionKind{Group: "flagger.app", Version: "v1beta1", Kind: "MetricTemplate"} // Get takes name of the metricTemplate, and returns the corresponding metricTemplate object, and an error if there is any. -func (c *FakeMetricTemplates) Get(name string, options v1.GetOptions) (result *v1beta1.MetricTemplate, err error) { +func (c *FakeMetricTemplates) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.MetricTemplate, err error) { obj, err := c.Fake. Invokes(testing.NewGetAction(metrictemplatesResource, c.ns, name), &v1beta1.MetricTemplate{}) @@ -50,7 +52,7 @@ func (c *FakeMetricTemplates) Get(name string, options v1.GetOptions) (result *v } // List takes label and field selectors, and returns the list of MetricTemplates that match those selectors. -func (c *FakeMetricTemplates) List(opts v1.ListOptions) (result *v1beta1.MetricTemplateList, err error) { +func (c *FakeMetricTemplates) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.MetricTemplateList, err error) { obj, err := c.Fake. Invokes(testing.NewListAction(metrictemplatesResource, metrictemplatesKind, c.ns, opts), &v1beta1.MetricTemplateList{}) @@ -72,14 +74,14 @@ func (c *FakeMetricTemplates) List(opts v1.ListOptions) (result *v1beta1.MetricT } // Watch returns a watch.Interface that watches the requested metricTemplates. -func (c *FakeMetricTemplates) Watch(opts v1.ListOptions) (watch.Interface, error) { +func (c *FakeMetricTemplates) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.Fake. InvokesWatch(testing.NewWatchAction(metrictemplatesResource, c.ns, opts)) } // Create takes the representation of a metricTemplate and creates it. Returns the server's representation of the metricTemplate, and an error, if there is any. -func (c *FakeMetricTemplates) Create(metricTemplate *v1beta1.MetricTemplate) (result *v1beta1.MetricTemplate, err error) { +func (c *FakeMetricTemplates) Create(ctx context.Context, metricTemplate *v1beta1.MetricTemplate, opts v1.CreateOptions) (result *v1beta1.MetricTemplate, err error) { obj, err := c.Fake. Invokes(testing.NewCreateAction(metrictemplatesResource, c.ns, metricTemplate), &v1beta1.MetricTemplate{}) @@ -90,7 +92,7 @@ func (c *FakeMetricTemplates) Create(metricTemplate *v1beta1.MetricTemplate) (re } // Update takes the representation of a metricTemplate and updates it. Returns the server's representation of the metricTemplate, and an error, if there is any. -func (c *FakeMetricTemplates) Update(metricTemplate *v1beta1.MetricTemplate) (result *v1beta1.MetricTemplate, err error) { +func (c *FakeMetricTemplates) Update(ctx context.Context, metricTemplate *v1beta1.MetricTemplate, opts v1.UpdateOptions) (result *v1beta1.MetricTemplate, err error) { obj, err := c.Fake. Invokes(testing.NewUpdateAction(metrictemplatesResource, c.ns, metricTemplate), &v1beta1.MetricTemplate{}) @@ -102,7 +104,7 @@ func (c *FakeMetricTemplates) Update(metricTemplate *v1beta1.MetricTemplate) (re // UpdateStatus was generated because the type contains a Status member. // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *FakeMetricTemplates) UpdateStatus(metricTemplate *v1beta1.MetricTemplate) (*v1beta1.MetricTemplate, error) { +func (c *FakeMetricTemplates) UpdateStatus(ctx context.Context, metricTemplate *v1beta1.MetricTemplate, opts v1.UpdateOptions) (*v1beta1.MetricTemplate, error) { obj, err := c.Fake. Invokes(testing.NewUpdateSubresourceAction(metrictemplatesResource, "status", c.ns, metricTemplate), &v1beta1.MetricTemplate{}) @@ -113,7 +115,7 @@ func (c *FakeMetricTemplates) UpdateStatus(metricTemplate *v1beta1.MetricTemplat } // Delete takes name of the metricTemplate and deletes it. Returns an error if one occurs. -func (c *FakeMetricTemplates) Delete(name string, options *v1.DeleteOptions) error { +func (c *FakeMetricTemplates) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { _, err := c.Fake. Invokes(testing.NewDeleteAction(metrictemplatesResource, c.ns, name), &v1beta1.MetricTemplate{}) @@ -121,15 +123,15 @@ func (c *FakeMetricTemplates) Delete(name string, options *v1.DeleteOptions) err } // DeleteCollection deletes a collection of objects. -func (c *FakeMetricTemplates) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(metrictemplatesResource, c.ns, listOptions) +func (c *FakeMetricTemplates) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(metrictemplatesResource, c.ns, listOpts) _, err := c.Fake.Invokes(action, &v1beta1.MetricTemplateList{}) return err } // Patch applies the patch and returns the patched metricTemplate. -func (c *FakeMetricTemplates) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.MetricTemplate, err error) { +func (c *FakeMetricTemplates) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.MetricTemplate, err error) { obj, err := c.Fake. Invokes(testing.NewPatchSubresourceAction(metrictemplatesResource, c.ns, name, pt, data, subresources...), &v1beta1.MetricTemplate{}) diff --git a/pkg/client/clientset/versioned/typed/flagger/v1beta1/metrictemplate.go b/pkg/client/clientset/versioned/typed/flagger/v1beta1/metrictemplate.go index 41037829..2ded7f8e 100644 --- a/pkg/client/clientset/versioned/typed/flagger/v1beta1/metrictemplate.go +++ b/pkg/client/clientset/versioned/typed/flagger/v1beta1/metrictemplate.go @@ -19,6 +19,7 @@ limitations under the License. package v1beta1 import ( + "context" "time" v1beta1 "github.com/weaveworks/flagger/pkg/apis/flagger/v1beta1" @@ -37,15 +38,15 @@ type MetricTemplatesGetter interface { // MetricTemplateInterface has methods to work with MetricTemplate resources. type MetricTemplateInterface interface { - Create(*v1beta1.MetricTemplate) (*v1beta1.MetricTemplate, error) - Update(*v1beta1.MetricTemplate) (*v1beta1.MetricTemplate, error) - UpdateStatus(*v1beta1.MetricTemplate) (*v1beta1.MetricTemplate, error) - Delete(name string, options *v1.DeleteOptions) error - DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error - Get(name string, options v1.GetOptions) (*v1beta1.MetricTemplate, error) - List(opts v1.ListOptions) (*v1beta1.MetricTemplateList, error) - Watch(opts v1.ListOptions) (watch.Interface, error) - Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.MetricTemplate, err error) + Create(ctx context.Context, metricTemplate *v1beta1.MetricTemplate, opts v1.CreateOptions) (*v1beta1.MetricTemplate, error) + Update(ctx context.Context, metricTemplate *v1beta1.MetricTemplate, opts v1.UpdateOptions) (*v1beta1.MetricTemplate, error) + UpdateStatus(ctx context.Context, metricTemplate *v1beta1.MetricTemplate, opts v1.UpdateOptions) (*v1beta1.MetricTemplate, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1beta1.MetricTemplate, error) + List(ctx context.Context, opts v1.ListOptions) (*v1beta1.MetricTemplateList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.MetricTemplate, err error) MetricTemplateExpansion } @@ -64,20 +65,20 @@ func newMetricTemplates(c *FlaggerV1beta1Client, namespace string) *metricTempla } // Get takes name of the metricTemplate, and returns the corresponding metricTemplate object, and an error if there is any. -func (c *metricTemplates) Get(name string, options v1.GetOptions) (result *v1beta1.MetricTemplate, err error) { +func (c *metricTemplates) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.MetricTemplate, err error) { result = &v1beta1.MetricTemplate{} err = c.client.Get(). Namespace(c.ns). Resource("metrictemplates"). Name(name). VersionedParams(&options, scheme.ParameterCodec). - Do(). + Do(ctx). Into(result) return } // List takes label and field selectors, and returns the list of MetricTemplates that match those selectors. -func (c *metricTemplates) List(opts v1.ListOptions) (result *v1beta1.MetricTemplateList, err error) { +func (c *metricTemplates) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.MetricTemplateList, err error) { var timeout time.Duration if opts.TimeoutSeconds != nil { timeout = time.Duration(*opts.TimeoutSeconds) * time.Second @@ -88,13 +89,13 @@ func (c *metricTemplates) List(opts v1.ListOptions) (result *v1beta1.MetricTempl Resource("metrictemplates"). VersionedParams(&opts, scheme.ParameterCodec). Timeout(timeout). - Do(). + Do(ctx). Into(result) return } // Watch returns a watch.Interface that watches the requested metricTemplates. -func (c *metricTemplates) Watch(opts v1.ListOptions) (watch.Interface, error) { +func (c *metricTemplates) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration if opts.TimeoutSeconds != nil { timeout = time.Duration(*opts.TimeoutSeconds) * time.Second @@ -105,87 +106,90 @@ func (c *metricTemplates) Watch(opts v1.ListOptions) (watch.Interface, error) { Resource("metrictemplates"). VersionedParams(&opts, scheme.ParameterCodec). Timeout(timeout). - Watch() + Watch(ctx) } // Create takes the representation of a metricTemplate and creates it. Returns the server's representation of the metricTemplate, and an error, if there is any. -func (c *metricTemplates) Create(metricTemplate *v1beta1.MetricTemplate) (result *v1beta1.MetricTemplate, err error) { +func (c *metricTemplates) Create(ctx context.Context, metricTemplate *v1beta1.MetricTemplate, opts v1.CreateOptions) (result *v1beta1.MetricTemplate, err error) { result = &v1beta1.MetricTemplate{} err = c.client.Post(). Namespace(c.ns). Resource("metrictemplates"). + VersionedParams(&opts, scheme.ParameterCodec). Body(metricTemplate). - Do(). + Do(ctx). Into(result) return } // Update takes the representation of a metricTemplate and updates it. Returns the server's representation of the metricTemplate, and an error, if there is any. -func (c *metricTemplates) Update(metricTemplate *v1beta1.MetricTemplate) (result *v1beta1.MetricTemplate, err error) { +func (c *metricTemplates) Update(ctx context.Context, metricTemplate *v1beta1.MetricTemplate, opts v1.UpdateOptions) (result *v1beta1.MetricTemplate, err error) { result = &v1beta1.MetricTemplate{} err = c.client.Put(). Namespace(c.ns). Resource("metrictemplates"). Name(metricTemplate.Name). + VersionedParams(&opts, scheme.ParameterCodec). Body(metricTemplate). - Do(). + Do(ctx). Into(result) return } // UpdateStatus was generated because the type contains a Status member. // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). - -func (c *metricTemplates) UpdateStatus(metricTemplate *v1beta1.MetricTemplate) (result *v1beta1.MetricTemplate, err error) { +func (c *metricTemplates) UpdateStatus(ctx context.Context, metricTemplate *v1beta1.MetricTemplate, opts v1.UpdateOptions) (result *v1beta1.MetricTemplate, err error) { result = &v1beta1.MetricTemplate{} err = c.client.Put(). Namespace(c.ns). Resource("metrictemplates"). Name(metricTemplate.Name). SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). Body(metricTemplate). - Do(). + Do(ctx). Into(result) return } // Delete takes name of the metricTemplate and deletes it. Returns an error if one occurs. -func (c *metricTemplates) Delete(name string, options *v1.DeleteOptions) error { +func (c *metricTemplates) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { return c.client.Delete(). Namespace(c.ns). Resource("metrictemplates"). Name(name). - Body(options). - Do(). + Body(&opts). + Do(ctx). Error() } // DeleteCollection deletes a collection of objects. -func (c *metricTemplates) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { +func (c *metricTemplates) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { var timeout time.Duration - if listOptions.TimeoutSeconds != nil { - timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second } return c.client.Delete(). Namespace(c.ns). Resource("metrictemplates"). - VersionedParams(&listOptions, scheme.ParameterCodec). + VersionedParams(&listOpts, scheme.ParameterCodec). Timeout(timeout). - Body(options). - Do(). + Body(&opts). + Do(ctx). Error() } // Patch applies the patch and returns the patched metricTemplate. -func (c *metricTemplates) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.MetricTemplate, err error) { +func (c *metricTemplates) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.MetricTemplate, err error) { result = &v1beta1.MetricTemplate{} err = c.client.Patch(pt). Namespace(c.ns). Resource("metrictemplates"). - SubResource(subresources...). Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). Body(data). - Do(). + Do(ctx). Into(result) return } diff --git a/pkg/client/clientset/versioned/typed/gloo/v1/fake/fake_upstreamgroup.go b/pkg/client/clientset/versioned/typed/gloo/v1/fake/fake_upstreamgroup.go index 264f8ff6..61aab3f8 100644 --- a/pkg/client/clientset/versioned/typed/gloo/v1/fake/fake_upstreamgroup.go +++ b/pkg/client/clientset/versioned/typed/gloo/v1/fake/fake_upstreamgroup.go @@ -19,6 +19,8 @@ limitations under the License. package fake import ( + "context" + gloov1 "github.com/weaveworks/flagger/pkg/apis/gloo/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" @@ -39,7 +41,7 @@ var upstreamgroupsResource = schema.GroupVersionResource{Group: "gloo.solo.io", var upstreamgroupsKind = schema.GroupVersionKind{Group: "gloo.solo.io", Version: "v1", Kind: "UpstreamGroup"} // Get takes name of the upstreamGroup, and returns the corresponding upstreamGroup object, and an error if there is any. -func (c *FakeUpstreamGroups) Get(name string, options v1.GetOptions) (result *gloov1.UpstreamGroup, err error) { +func (c *FakeUpstreamGroups) Get(ctx context.Context, name string, options v1.GetOptions) (result *gloov1.UpstreamGroup, err error) { obj, err := c.Fake. Invokes(testing.NewGetAction(upstreamgroupsResource, c.ns, name), &gloov1.UpstreamGroup{}) @@ -50,7 +52,7 @@ func (c *FakeUpstreamGroups) Get(name string, options v1.GetOptions) (result *gl } // List takes label and field selectors, and returns the list of UpstreamGroups that match those selectors. -func (c *FakeUpstreamGroups) List(opts v1.ListOptions) (result *gloov1.UpstreamGroupList, err error) { +func (c *FakeUpstreamGroups) List(ctx context.Context, opts v1.ListOptions) (result *gloov1.UpstreamGroupList, err error) { obj, err := c.Fake. Invokes(testing.NewListAction(upstreamgroupsResource, upstreamgroupsKind, c.ns, opts), &gloov1.UpstreamGroupList{}) @@ -72,14 +74,14 @@ func (c *FakeUpstreamGroups) List(opts v1.ListOptions) (result *gloov1.UpstreamG } // Watch returns a watch.Interface that watches the requested upstreamGroups. -func (c *FakeUpstreamGroups) Watch(opts v1.ListOptions) (watch.Interface, error) { +func (c *FakeUpstreamGroups) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.Fake. InvokesWatch(testing.NewWatchAction(upstreamgroupsResource, c.ns, opts)) } // Create takes the representation of a upstreamGroup and creates it. Returns the server's representation of the upstreamGroup, and an error, if there is any. -func (c *FakeUpstreamGroups) Create(upstreamGroup *gloov1.UpstreamGroup) (result *gloov1.UpstreamGroup, err error) { +func (c *FakeUpstreamGroups) Create(ctx context.Context, upstreamGroup *gloov1.UpstreamGroup, opts v1.CreateOptions) (result *gloov1.UpstreamGroup, err error) { obj, err := c.Fake. Invokes(testing.NewCreateAction(upstreamgroupsResource, c.ns, upstreamGroup), &gloov1.UpstreamGroup{}) @@ -90,7 +92,7 @@ func (c *FakeUpstreamGroups) Create(upstreamGroup *gloov1.UpstreamGroup) (result } // Update takes the representation of a upstreamGroup and updates it. Returns the server's representation of the upstreamGroup, and an error, if there is any. -func (c *FakeUpstreamGroups) Update(upstreamGroup *gloov1.UpstreamGroup) (result *gloov1.UpstreamGroup, err error) { +func (c *FakeUpstreamGroups) Update(ctx context.Context, upstreamGroup *gloov1.UpstreamGroup, opts v1.UpdateOptions) (result *gloov1.UpstreamGroup, err error) { obj, err := c.Fake. Invokes(testing.NewUpdateAction(upstreamgroupsResource, c.ns, upstreamGroup), &gloov1.UpstreamGroup{}) @@ -101,7 +103,7 @@ func (c *FakeUpstreamGroups) Update(upstreamGroup *gloov1.UpstreamGroup) (result } // Delete takes name of the upstreamGroup and deletes it. Returns an error if one occurs. -func (c *FakeUpstreamGroups) Delete(name string, options *v1.DeleteOptions) error { +func (c *FakeUpstreamGroups) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { _, err := c.Fake. Invokes(testing.NewDeleteAction(upstreamgroupsResource, c.ns, name), &gloov1.UpstreamGroup{}) @@ -109,15 +111,15 @@ func (c *FakeUpstreamGroups) Delete(name string, options *v1.DeleteOptions) erro } // DeleteCollection deletes a collection of objects. -func (c *FakeUpstreamGroups) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(upstreamgroupsResource, c.ns, listOptions) +func (c *FakeUpstreamGroups) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(upstreamgroupsResource, c.ns, listOpts) _, err := c.Fake.Invokes(action, &gloov1.UpstreamGroupList{}) return err } // Patch applies the patch and returns the patched upstreamGroup. -func (c *FakeUpstreamGroups) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *gloov1.UpstreamGroup, err error) { +func (c *FakeUpstreamGroups) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *gloov1.UpstreamGroup, err error) { obj, err := c.Fake. Invokes(testing.NewPatchSubresourceAction(upstreamgroupsResource, c.ns, name, pt, data, subresources...), &gloov1.UpstreamGroup{}) diff --git a/pkg/client/clientset/versioned/typed/gloo/v1/upstreamgroup.go b/pkg/client/clientset/versioned/typed/gloo/v1/upstreamgroup.go index 06c254fa..3ee89217 100644 --- a/pkg/client/clientset/versioned/typed/gloo/v1/upstreamgroup.go +++ b/pkg/client/clientset/versioned/typed/gloo/v1/upstreamgroup.go @@ -19,6 +19,7 @@ limitations under the License. package v1 import ( + "context" "time" v1 "github.com/weaveworks/flagger/pkg/apis/gloo/v1" @@ -37,14 +38,14 @@ type UpstreamGroupsGetter interface { // UpstreamGroupInterface has methods to work with UpstreamGroup resources. type UpstreamGroupInterface interface { - Create(*v1.UpstreamGroup) (*v1.UpstreamGroup, error) - Update(*v1.UpstreamGroup) (*v1.UpstreamGroup, error) - Delete(name string, options *metav1.DeleteOptions) error - DeleteCollection(options *metav1.DeleteOptions, listOptions metav1.ListOptions) error - Get(name string, options metav1.GetOptions) (*v1.UpstreamGroup, error) - List(opts metav1.ListOptions) (*v1.UpstreamGroupList, error) - Watch(opts metav1.ListOptions) (watch.Interface, error) - Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.UpstreamGroup, err error) + Create(ctx context.Context, upstreamGroup *v1.UpstreamGroup, opts metav1.CreateOptions) (*v1.UpstreamGroup, error) + Update(ctx context.Context, upstreamGroup *v1.UpstreamGroup, opts metav1.UpdateOptions) (*v1.UpstreamGroup, error) + Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error + Get(ctx context.Context, name string, opts metav1.GetOptions) (*v1.UpstreamGroup, error) + List(ctx context.Context, opts metav1.ListOptions) (*v1.UpstreamGroupList, error) + Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.UpstreamGroup, err error) UpstreamGroupExpansion } @@ -63,20 +64,20 @@ func newUpstreamGroups(c *GlooV1Client, namespace string) *upstreamGroups { } // Get takes name of the upstreamGroup, and returns the corresponding upstreamGroup object, and an error if there is any. -func (c *upstreamGroups) Get(name string, options metav1.GetOptions) (result *v1.UpstreamGroup, err error) { +func (c *upstreamGroups) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.UpstreamGroup, err error) { result = &v1.UpstreamGroup{} err = c.client.Get(). Namespace(c.ns). Resource("upstreamgroups"). Name(name). VersionedParams(&options, scheme.ParameterCodec). - Do(). + Do(ctx). Into(result) return } // List takes label and field selectors, and returns the list of UpstreamGroups that match those selectors. -func (c *upstreamGroups) List(opts metav1.ListOptions) (result *v1.UpstreamGroupList, err error) { +func (c *upstreamGroups) List(ctx context.Context, opts metav1.ListOptions) (result *v1.UpstreamGroupList, err error) { var timeout time.Duration if opts.TimeoutSeconds != nil { timeout = time.Duration(*opts.TimeoutSeconds) * time.Second @@ -87,13 +88,13 @@ func (c *upstreamGroups) List(opts metav1.ListOptions) (result *v1.UpstreamGroup Resource("upstreamgroups"). VersionedParams(&opts, scheme.ParameterCodec). Timeout(timeout). - Do(). + Do(ctx). Into(result) return } // Watch returns a watch.Interface that watches the requested upstreamGroups. -func (c *upstreamGroups) Watch(opts metav1.ListOptions) (watch.Interface, error) { +func (c *upstreamGroups) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration if opts.TimeoutSeconds != nil { timeout = time.Duration(*opts.TimeoutSeconds) * time.Second @@ -104,71 +105,74 @@ func (c *upstreamGroups) Watch(opts metav1.ListOptions) (watch.Interface, error) Resource("upstreamgroups"). VersionedParams(&opts, scheme.ParameterCodec). Timeout(timeout). - Watch() + Watch(ctx) } // Create takes the representation of a upstreamGroup and creates it. Returns the server's representation of the upstreamGroup, and an error, if there is any. -func (c *upstreamGroups) Create(upstreamGroup *v1.UpstreamGroup) (result *v1.UpstreamGroup, err error) { +func (c *upstreamGroups) Create(ctx context.Context, upstreamGroup *v1.UpstreamGroup, opts metav1.CreateOptions) (result *v1.UpstreamGroup, err error) { result = &v1.UpstreamGroup{} err = c.client.Post(). Namespace(c.ns). Resource("upstreamgroups"). + VersionedParams(&opts, scheme.ParameterCodec). Body(upstreamGroup). - Do(). + Do(ctx). Into(result) return } // Update takes the representation of a upstreamGroup and updates it. Returns the server's representation of the upstreamGroup, and an error, if there is any. -func (c *upstreamGroups) Update(upstreamGroup *v1.UpstreamGroup) (result *v1.UpstreamGroup, err error) { +func (c *upstreamGroups) Update(ctx context.Context, upstreamGroup *v1.UpstreamGroup, opts metav1.UpdateOptions) (result *v1.UpstreamGroup, err error) { result = &v1.UpstreamGroup{} err = c.client.Put(). Namespace(c.ns). Resource("upstreamgroups"). Name(upstreamGroup.Name). + VersionedParams(&opts, scheme.ParameterCodec). Body(upstreamGroup). - Do(). + Do(ctx). Into(result) return } // Delete takes name of the upstreamGroup and deletes it. Returns an error if one occurs. -func (c *upstreamGroups) Delete(name string, options *metav1.DeleteOptions) error { +func (c *upstreamGroups) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { return c.client.Delete(). Namespace(c.ns). Resource("upstreamgroups"). Name(name). - Body(options). - Do(). + Body(&opts). + Do(ctx). Error() } // DeleteCollection deletes a collection of objects. -func (c *upstreamGroups) DeleteCollection(options *metav1.DeleteOptions, listOptions metav1.ListOptions) error { +func (c *upstreamGroups) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { var timeout time.Duration - if listOptions.TimeoutSeconds != nil { - timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second } return c.client.Delete(). Namespace(c.ns). Resource("upstreamgroups"). - VersionedParams(&listOptions, scheme.ParameterCodec). + VersionedParams(&listOpts, scheme.ParameterCodec). Timeout(timeout). - Body(options). - Do(). + Body(&opts). + Do(ctx). Error() } // Patch applies the patch and returns the patched upstreamGroup. -func (c *upstreamGroups) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.UpstreamGroup, err error) { +func (c *upstreamGroups) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.UpstreamGroup, err error) { result = &v1.UpstreamGroup{} err = c.client.Patch(pt). Namespace(c.ns). Resource("upstreamgroups"). - SubResource(subresources...). Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). Body(data). - Do(). + Do(ctx). Into(result) return } diff --git a/pkg/client/clientset/versioned/typed/istio/v1alpha3/destinationrule.go b/pkg/client/clientset/versioned/typed/istio/v1alpha3/destinationrule.go index 5328b3ce..38de5db6 100644 --- a/pkg/client/clientset/versioned/typed/istio/v1alpha3/destinationrule.go +++ b/pkg/client/clientset/versioned/typed/istio/v1alpha3/destinationrule.go @@ -19,6 +19,7 @@ limitations under the License. package v1alpha3 import ( + "context" "time" v1alpha3 "github.com/weaveworks/flagger/pkg/apis/istio/v1alpha3" @@ -37,14 +38,14 @@ type DestinationRulesGetter interface { // DestinationRuleInterface has methods to work with DestinationRule resources. type DestinationRuleInterface interface { - Create(*v1alpha3.DestinationRule) (*v1alpha3.DestinationRule, error) - Update(*v1alpha3.DestinationRule) (*v1alpha3.DestinationRule, error) - Delete(name string, options *v1.DeleteOptions) error - DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error - Get(name string, options v1.GetOptions) (*v1alpha3.DestinationRule, error) - List(opts v1.ListOptions) (*v1alpha3.DestinationRuleList, error) - Watch(opts v1.ListOptions) (watch.Interface, error) - Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha3.DestinationRule, err error) + Create(ctx context.Context, destinationRule *v1alpha3.DestinationRule, opts v1.CreateOptions) (*v1alpha3.DestinationRule, error) + Update(ctx context.Context, destinationRule *v1alpha3.DestinationRule, opts v1.UpdateOptions) (*v1alpha3.DestinationRule, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha3.DestinationRule, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha3.DestinationRuleList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha3.DestinationRule, err error) DestinationRuleExpansion } @@ -63,20 +64,20 @@ func newDestinationRules(c *NetworkingV1alpha3Client, namespace string) *destina } // Get takes name of the destinationRule, and returns the corresponding destinationRule object, and an error if there is any. -func (c *destinationRules) Get(name string, options v1.GetOptions) (result *v1alpha3.DestinationRule, err error) { +func (c *destinationRules) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha3.DestinationRule, err error) { result = &v1alpha3.DestinationRule{} err = c.client.Get(). Namespace(c.ns). Resource("destinationrules"). Name(name). VersionedParams(&options, scheme.ParameterCodec). - Do(). + Do(ctx). Into(result) return } // List takes label and field selectors, and returns the list of DestinationRules that match those selectors. -func (c *destinationRules) List(opts v1.ListOptions) (result *v1alpha3.DestinationRuleList, err error) { +func (c *destinationRules) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha3.DestinationRuleList, err error) { var timeout time.Duration if opts.TimeoutSeconds != nil { timeout = time.Duration(*opts.TimeoutSeconds) * time.Second @@ -87,13 +88,13 @@ func (c *destinationRules) List(opts v1.ListOptions) (result *v1alpha3.Destinati Resource("destinationrules"). VersionedParams(&opts, scheme.ParameterCodec). Timeout(timeout). - Do(). + Do(ctx). Into(result) return } // Watch returns a watch.Interface that watches the requested destinationRules. -func (c *destinationRules) Watch(opts v1.ListOptions) (watch.Interface, error) { +func (c *destinationRules) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration if opts.TimeoutSeconds != nil { timeout = time.Duration(*opts.TimeoutSeconds) * time.Second @@ -104,71 +105,74 @@ func (c *destinationRules) Watch(opts v1.ListOptions) (watch.Interface, error) { Resource("destinationrules"). VersionedParams(&opts, scheme.ParameterCodec). Timeout(timeout). - Watch() + Watch(ctx) } // Create takes the representation of a destinationRule and creates it. Returns the server's representation of the destinationRule, and an error, if there is any. -func (c *destinationRules) Create(destinationRule *v1alpha3.DestinationRule) (result *v1alpha3.DestinationRule, err error) { +func (c *destinationRules) Create(ctx context.Context, destinationRule *v1alpha3.DestinationRule, opts v1.CreateOptions) (result *v1alpha3.DestinationRule, err error) { result = &v1alpha3.DestinationRule{} err = c.client.Post(). Namespace(c.ns). Resource("destinationrules"). + VersionedParams(&opts, scheme.ParameterCodec). Body(destinationRule). - Do(). + Do(ctx). Into(result) return } // Update takes the representation of a destinationRule and updates it. Returns the server's representation of the destinationRule, and an error, if there is any. -func (c *destinationRules) Update(destinationRule *v1alpha3.DestinationRule) (result *v1alpha3.DestinationRule, err error) { +func (c *destinationRules) Update(ctx context.Context, destinationRule *v1alpha3.DestinationRule, opts v1.UpdateOptions) (result *v1alpha3.DestinationRule, err error) { result = &v1alpha3.DestinationRule{} err = c.client.Put(). Namespace(c.ns). Resource("destinationrules"). Name(destinationRule.Name). + VersionedParams(&opts, scheme.ParameterCodec). Body(destinationRule). - Do(). + Do(ctx). Into(result) return } // Delete takes name of the destinationRule and deletes it. Returns an error if one occurs. -func (c *destinationRules) Delete(name string, options *v1.DeleteOptions) error { +func (c *destinationRules) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { return c.client.Delete(). Namespace(c.ns). Resource("destinationrules"). Name(name). - Body(options). - Do(). + Body(&opts). + Do(ctx). Error() } // DeleteCollection deletes a collection of objects. -func (c *destinationRules) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { +func (c *destinationRules) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { var timeout time.Duration - if listOptions.TimeoutSeconds != nil { - timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second } return c.client.Delete(). Namespace(c.ns). Resource("destinationrules"). - VersionedParams(&listOptions, scheme.ParameterCodec). + VersionedParams(&listOpts, scheme.ParameterCodec). Timeout(timeout). - Body(options). - Do(). + Body(&opts). + Do(ctx). Error() } // Patch applies the patch and returns the patched destinationRule. -func (c *destinationRules) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha3.DestinationRule, err error) { +func (c *destinationRules) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha3.DestinationRule, err error) { result = &v1alpha3.DestinationRule{} err = c.client.Patch(pt). Namespace(c.ns). Resource("destinationrules"). - SubResource(subresources...). Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). Body(data). - Do(). + Do(ctx). Into(result) return } diff --git a/pkg/client/clientset/versioned/typed/istio/v1alpha3/fake/fake_destinationrule.go b/pkg/client/clientset/versioned/typed/istio/v1alpha3/fake/fake_destinationrule.go index 12197a07..b9c56eac 100644 --- a/pkg/client/clientset/versioned/typed/istio/v1alpha3/fake/fake_destinationrule.go +++ b/pkg/client/clientset/versioned/typed/istio/v1alpha3/fake/fake_destinationrule.go @@ -19,6 +19,8 @@ limitations under the License. package fake import ( + "context" + v1alpha3 "github.com/weaveworks/flagger/pkg/apis/istio/v1alpha3" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" @@ -39,7 +41,7 @@ var destinationrulesResource = schema.GroupVersionResource{Group: "networking.is var destinationrulesKind = schema.GroupVersionKind{Group: "networking.istio.io", Version: "v1alpha3", Kind: "DestinationRule"} // Get takes name of the destinationRule, and returns the corresponding destinationRule object, and an error if there is any. -func (c *FakeDestinationRules) Get(name string, options v1.GetOptions) (result *v1alpha3.DestinationRule, err error) { +func (c *FakeDestinationRules) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha3.DestinationRule, err error) { obj, err := c.Fake. Invokes(testing.NewGetAction(destinationrulesResource, c.ns, name), &v1alpha3.DestinationRule{}) @@ -50,7 +52,7 @@ func (c *FakeDestinationRules) Get(name string, options v1.GetOptions) (result * } // List takes label and field selectors, and returns the list of DestinationRules that match those selectors. -func (c *FakeDestinationRules) List(opts v1.ListOptions) (result *v1alpha3.DestinationRuleList, err error) { +func (c *FakeDestinationRules) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha3.DestinationRuleList, err error) { obj, err := c.Fake. Invokes(testing.NewListAction(destinationrulesResource, destinationrulesKind, c.ns, opts), &v1alpha3.DestinationRuleList{}) @@ -72,14 +74,14 @@ func (c *FakeDestinationRules) List(opts v1.ListOptions) (result *v1alpha3.Desti } // Watch returns a watch.Interface that watches the requested destinationRules. -func (c *FakeDestinationRules) Watch(opts v1.ListOptions) (watch.Interface, error) { +func (c *FakeDestinationRules) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.Fake. InvokesWatch(testing.NewWatchAction(destinationrulesResource, c.ns, opts)) } // Create takes the representation of a destinationRule and creates it. Returns the server's representation of the destinationRule, and an error, if there is any. -func (c *FakeDestinationRules) Create(destinationRule *v1alpha3.DestinationRule) (result *v1alpha3.DestinationRule, err error) { +func (c *FakeDestinationRules) Create(ctx context.Context, destinationRule *v1alpha3.DestinationRule, opts v1.CreateOptions) (result *v1alpha3.DestinationRule, err error) { obj, err := c.Fake. Invokes(testing.NewCreateAction(destinationrulesResource, c.ns, destinationRule), &v1alpha3.DestinationRule{}) @@ -90,7 +92,7 @@ func (c *FakeDestinationRules) Create(destinationRule *v1alpha3.DestinationRule) } // Update takes the representation of a destinationRule and updates it. Returns the server's representation of the destinationRule, and an error, if there is any. -func (c *FakeDestinationRules) Update(destinationRule *v1alpha3.DestinationRule) (result *v1alpha3.DestinationRule, err error) { +func (c *FakeDestinationRules) Update(ctx context.Context, destinationRule *v1alpha3.DestinationRule, opts v1.UpdateOptions) (result *v1alpha3.DestinationRule, err error) { obj, err := c.Fake. Invokes(testing.NewUpdateAction(destinationrulesResource, c.ns, destinationRule), &v1alpha3.DestinationRule{}) @@ -101,7 +103,7 @@ func (c *FakeDestinationRules) Update(destinationRule *v1alpha3.DestinationRule) } // Delete takes name of the destinationRule and deletes it. Returns an error if one occurs. -func (c *FakeDestinationRules) Delete(name string, options *v1.DeleteOptions) error { +func (c *FakeDestinationRules) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { _, err := c.Fake. Invokes(testing.NewDeleteAction(destinationrulesResource, c.ns, name), &v1alpha3.DestinationRule{}) @@ -109,15 +111,15 @@ func (c *FakeDestinationRules) Delete(name string, options *v1.DeleteOptions) er } // DeleteCollection deletes a collection of objects. -func (c *FakeDestinationRules) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(destinationrulesResource, c.ns, listOptions) +func (c *FakeDestinationRules) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(destinationrulesResource, c.ns, listOpts) _, err := c.Fake.Invokes(action, &v1alpha3.DestinationRuleList{}) return err } // Patch applies the patch and returns the patched destinationRule. -func (c *FakeDestinationRules) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha3.DestinationRule, err error) { +func (c *FakeDestinationRules) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha3.DestinationRule, err error) { obj, err := c.Fake. Invokes(testing.NewPatchSubresourceAction(destinationrulesResource, c.ns, name, pt, data, subresources...), &v1alpha3.DestinationRule{}) diff --git a/pkg/client/clientset/versioned/typed/istio/v1alpha3/fake/fake_virtualservice.go b/pkg/client/clientset/versioned/typed/istio/v1alpha3/fake/fake_virtualservice.go index c49ae2f5..d56eb741 100644 --- a/pkg/client/clientset/versioned/typed/istio/v1alpha3/fake/fake_virtualservice.go +++ b/pkg/client/clientset/versioned/typed/istio/v1alpha3/fake/fake_virtualservice.go @@ -19,6 +19,8 @@ limitations under the License. package fake import ( + "context" + v1alpha3 "github.com/weaveworks/flagger/pkg/apis/istio/v1alpha3" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" @@ -39,7 +41,7 @@ var virtualservicesResource = schema.GroupVersionResource{Group: "networking.ist var virtualservicesKind = schema.GroupVersionKind{Group: "networking.istio.io", Version: "v1alpha3", Kind: "VirtualService"} // Get takes name of the virtualService, and returns the corresponding virtualService object, and an error if there is any. -func (c *FakeVirtualServices) Get(name string, options v1.GetOptions) (result *v1alpha3.VirtualService, err error) { +func (c *FakeVirtualServices) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha3.VirtualService, err error) { obj, err := c.Fake. Invokes(testing.NewGetAction(virtualservicesResource, c.ns, name), &v1alpha3.VirtualService{}) @@ -50,7 +52,7 @@ func (c *FakeVirtualServices) Get(name string, options v1.GetOptions) (result *v } // List takes label and field selectors, and returns the list of VirtualServices that match those selectors. -func (c *FakeVirtualServices) List(opts v1.ListOptions) (result *v1alpha3.VirtualServiceList, err error) { +func (c *FakeVirtualServices) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha3.VirtualServiceList, err error) { obj, err := c.Fake. Invokes(testing.NewListAction(virtualservicesResource, virtualservicesKind, c.ns, opts), &v1alpha3.VirtualServiceList{}) @@ -72,14 +74,14 @@ func (c *FakeVirtualServices) List(opts v1.ListOptions) (result *v1alpha3.Virtua } // Watch returns a watch.Interface that watches the requested virtualServices. -func (c *FakeVirtualServices) Watch(opts v1.ListOptions) (watch.Interface, error) { +func (c *FakeVirtualServices) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.Fake. InvokesWatch(testing.NewWatchAction(virtualservicesResource, c.ns, opts)) } // Create takes the representation of a virtualService and creates it. Returns the server's representation of the virtualService, and an error, if there is any. -func (c *FakeVirtualServices) Create(virtualService *v1alpha3.VirtualService) (result *v1alpha3.VirtualService, err error) { +func (c *FakeVirtualServices) Create(ctx context.Context, virtualService *v1alpha3.VirtualService, opts v1.CreateOptions) (result *v1alpha3.VirtualService, err error) { obj, err := c.Fake. Invokes(testing.NewCreateAction(virtualservicesResource, c.ns, virtualService), &v1alpha3.VirtualService{}) @@ -90,7 +92,7 @@ func (c *FakeVirtualServices) Create(virtualService *v1alpha3.VirtualService) (r } // Update takes the representation of a virtualService and updates it. Returns the server's representation of the virtualService, and an error, if there is any. -func (c *FakeVirtualServices) Update(virtualService *v1alpha3.VirtualService) (result *v1alpha3.VirtualService, err error) { +func (c *FakeVirtualServices) Update(ctx context.Context, virtualService *v1alpha3.VirtualService, opts v1.UpdateOptions) (result *v1alpha3.VirtualService, err error) { obj, err := c.Fake. Invokes(testing.NewUpdateAction(virtualservicesResource, c.ns, virtualService), &v1alpha3.VirtualService{}) @@ -101,7 +103,7 @@ func (c *FakeVirtualServices) Update(virtualService *v1alpha3.VirtualService) (r } // Delete takes name of the virtualService and deletes it. Returns an error if one occurs. -func (c *FakeVirtualServices) Delete(name string, options *v1.DeleteOptions) error { +func (c *FakeVirtualServices) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { _, err := c.Fake. Invokes(testing.NewDeleteAction(virtualservicesResource, c.ns, name), &v1alpha3.VirtualService{}) @@ -109,15 +111,15 @@ func (c *FakeVirtualServices) Delete(name string, options *v1.DeleteOptions) err } // DeleteCollection deletes a collection of objects. -func (c *FakeVirtualServices) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(virtualservicesResource, c.ns, listOptions) +func (c *FakeVirtualServices) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(virtualservicesResource, c.ns, listOpts) _, err := c.Fake.Invokes(action, &v1alpha3.VirtualServiceList{}) return err } // Patch applies the patch and returns the patched virtualService. -func (c *FakeVirtualServices) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha3.VirtualService, err error) { +func (c *FakeVirtualServices) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha3.VirtualService, err error) { obj, err := c.Fake. Invokes(testing.NewPatchSubresourceAction(virtualservicesResource, c.ns, name, pt, data, subresources...), &v1alpha3.VirtualService{}) diff --git a/pkg/client/clientset/versioned/typed/istio/v1alpha3/virtualservice.go b/pkg/client/clientset/versioned/typed/istio/v1alpha3/virtualservice.go index 82ff4462..f270c0a1 100644 --- a/pkg/client/clientset/versioned/typed/istio/v1alpha3/virtualservice.go +++ b/pkg/client/clientset/versioned/typed/istio/v1alpha3/virtualservice.go @@ -19,6 +19,7 @@ limitations under the License. package v1alpha3 import ( + "context" "time" v1alpha3 "github.com/weaveworks/flagger/pkg/apis/istio/v1alpha3" @@ -37,14 +38,14 @@ type VirtualServicesGetter interface { // VirtualServiceInterface has methods to work with VirtualService resources. type VirtualServiceInterface interface { - Create(*v1alpha3.VirtualService) (*v1alpha3.VirtualService, error) - Update(*v1alpha3.VirtualService) (*v1alpha3.VirtualService, error) - Delete(name string, options *v1.DeleteOptions) error - DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error - Get(name string, options v1.GetOptions) (*v1alpha3.VirtualService, error) - List(opts v1.ListOptions) (*v1alpha3.VirtualServiceList, error) - Watch(opts v1.ListOptions) (watch.Interface, error) - Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha3.VirtualService, err error) + Create(ctx context.Context, virtualService *v1alpha3.VirtualService, opts v1.CreateOptions) (*v1alpha3.VirtualService, error) + Update(ctx context.Context, virtualService *v1alpha3.VirtualService, opts v1.UpdateOptions) (*v1alpha3.VirtualService, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha3.VirtualService, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha3.VirtualServiceList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha3.VirtualService, err error) VirtualServiceExpansion } @@ -63,20 +64,20 @@ func newVirtualServices(c *NetworkingV1alpha3Client, namespace string) *virtualS } // Get takes name of the virtualService, and returns the corresponding virtualService object, and an error if there is any. -func (c *virtualServices) Get(name string, options v1.GetOptions) (result *v1alpha3.VirtualService, err error) { +func (c *virtualServices) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha3.VirtualService, err error) { result = &v1alpha3.VirtualService{} err = c.client.Get(). Namespace(c.ns). Resource("virtualservices"). Name(name). VersionedParams(&options, scheme.ParameterCodec). - Do(). + Do(ctx). Into(result) return } // List takes label and field selectors, and returns the list of VirtualServices that match those selectors. -func (c *virtualServices) List(opts v1.ListOptions) (result *v1alpha3.VirtualServiceList, err error) { +func (c *virtualServices) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha3.VirtualServiceList, err error) { var timeout time.Duration if opts.TimeoutSeconds != nil { timeout = time.Duration(*opts.TimeoutSeconds) * time.Second @@ -87,13 +88,13 @@ func (c *virtualServices) List(opts v1.ListOptions) (result *v1alpha3.VirtualSer Resource("virtualservices"). VersionedParams(&opts, scheme.ParameterCodec). Timeout(timeout). - Do(). + Do(ctx). Into(result) return } // Watch returns a watch.Interface that watches the requested virtualServices. -func (c *virtualServices) Watch(opts v1.ListOptions) (watch.Interface, error) { +func (c *virtualServices) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration if opts.TimeoutSeconds != nil { timeout = time.Duration(*opts.TimeoutSeconds) * time.Second @@ -104,71 +105,74 @@ func (c *virtualServices) Watch(opts v1.ListOptions) (watch.Interface, error) { Resource("virtualservices"). VersionedParams(&opts, scheme.ParameterCodec). Timeout(timeout). - Watch() + Watch(ctx) } // Create takes the representation of a virtualService and creates it. Returns the server's representation of the virtualService, and an error, if there is any. -func (c *virtualServices) Create(virtualService *v1alpha3.VirtualService) (result *v1alpha3.VirtualService, err error) { +func (c *virtualServices) Create(ctx context.Context, virtualService *v1alpha3.VirtualService, opts v1.CreateOptions) (result *v1alpha3.VirtualService, err error) { result = &v1alpha3.VirtualService{} err = c.client.Post(). Namespace(c.ns). Resource("virtualservices"). + VersionedParams(&opts, scheme.ParameterCodec). Body(virtualService). - Do(). + Do(ctx). Into(result) return } // Update takes the representation of a virtualService and updates it. Returns the server's representation of the virtualService, and an error, if there is any. -func (c *virtualServices) Update(virtualService *v1alpha3.VirtualService) (result *v1alpha3.VirtualService, err error) { +func (c *virtualServices) Update(ctx context.Context, virtualService *v1alpha3.VirtualService, opts v1.UpdateOptions) (result *v1alpha3.VirtualService, err error) { result = &v1alpha3.VirtualService{} err = c.client.Put(). Namespace(c.ns). Resource("virtualservices"). Name(virtualService.Name). + VersionedParams(&opts, scheme.ParameterCodec). Body(virtualService). - Do(). + Do(ctx). Into(result) return } // Delete takes name of the virtualService and deletes it. Returns an error if one occurs. -func (c *virtualServices) Delete(name string, options *v1.DeleteOptions) error { +func (c *virtualServices) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { return c.client.Delete(). Namespace(c.ns). Resource("virtualservices"). Name(name). - Body(options). - Do(). + Body(&opts). + Do(ctx). Error() } // DeleteCollection deletes a collection of objects. -func (c *virtualServices) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { +func (c *virtualServices) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { var timeout time.Duration - if listOptions.TimeoutSeconds != nil { - timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second } return c.client.Delete(). Namespace(c.ns). Resource("virtualservices"). - VersionedParams(&listOptions, scheme.ParameterCodec). + VersionedParams(&listOpts, scheme.ParameterCodec). Timeout(timeout). - Body(options). - Do(). + Body(&opts). + Do(ctx). Error() } // Patch applies the patch and returns the patched virtualService. -func (c *virtualServices) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha3.VirtualService, err error) { +func (c *virtualServices) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha3.VirtualService, err error) { result = &v1alpha3.VirtualService{} err = c.client.Patch(pt). Namespace(c.ns). Resource("virtualservices"). - SubResource(subresources...). Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). Body(data). - Do(). + Do(ctx). Into(result) return } diff --git a/pkg/client/clientset/versioned/typed/projectcontour/v1/fake/fake_httpproxy.go b/pkg/client/clientset/versioned/typed/projectcontour/v1/fake/fake_httpproxy.go index 4e046078..40e85c82 100644 --- a/pkg/client/clientset/versioned/typed/projectcontour/v1/fake/fake_httpproxy.go +++ b/pkg/client/clientset/versioned/typed/projectcontour/v1/fake/fake_httpproxy.go @@ -19,6 +19,8 @@ limitations under the License. package fake import ( + "context" + projectcontourv1 "github.com/weaveworks/flagger/pkg/apis/projectcontour/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" @@ -39,7 +41,7 @@ var httpproxiesResource = schema.GroupVersionResource{Group: "projectcontour.io" var httpproxiesKind = schema.GroupVersionKind{Group: "projectcontour.io", Version: "v1", Kind: "HTTPProxy"} // Get takes name of the hTTPProxy, and returns the corresponding hTTPProxy object, and an error if there is any. -func (c *FakeHTTPProxies) Get(name string, options v1.GetOptions) (result *projectcontourv1.HTTPProxy, err error) { +func (c *FakeHTTPProxies) Get(ctx context.Context, name string, options v1.GetOptions) (result *projectcontourv1.HTTPProxy, err error) { obj, err := c.Fake. Invokes(testing.NewGetAction(httpproxiesResource, c.ns, name), &projectcontourv1.HTTPProxy{}) @@ -50,7 +52,7 @@ func (c *FakeHTTPProxies) Get(name string, options v1.GetOptions) (result *proje } // List takes label and field selectors, and returns the list of HTTPProxies that match those selectors. -func (c *FakeHTTPProxies) List(opts v1.ListOptions) (result *projectcontourv1.HTTPProxyList, err error) { +func (c *FakeHTTPProxies) List(ctx context.Context, opts v1.ListOptions) (result *projectcontourv1.HTTPProxyList, err error) { obj, err := c.Fake. Invokes(testing.NewListAction(httpproxiesResource, httpproxiesKind, c.ns, opts), &projectcontourv1.HTTPProxyList{}) @@ -72,14 +74,14 @@ func (c *FakeHTTPProxies) List(opts v1.ListOptions) (result *projectcontourv1.HT } // Watch returns a watch.Interface that watches the requested hTTPProxies. -func (c *FakeHTTPProxies) Watch(opts v1.ListOptions) (watch.Interface, error) { +func (c *FakeHTTPProxies) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.Fake. InvokesWatch(testing.NewWatchAction(httpproxiesResource, c.ns, opts)) } // Create takes the representation of a hTTPProxy and creates it. Returns the server's representation of the hTTPProxy, and an error, if there is any. -func (c *FakeHTTPProxies) Create(hTTPProxy *projectcontourv1.HTTPProxy) (result *projectcontourv1.HTTPProxy, err error) { +func (c *FakeHTTPProxies) Create(ctx context.Context, hTTPProxy *projectcontourv1.HTTPProxy, opts v1.CreateOptions) (result *projectcontourv1.HTTPProxy, err error) { obj, err := c.Fake. Invokes(testing.NewCreateAction(httpproxiesResource, c.ns, hTTPProxy), &projectcontourv1.HTTPProxy{}) @@ -90,7 +92,7 @@ func (c *FakeHTTPProxies) Create(hTTPProxy *projectcontourv1.HTTPProxy) (result } // Update takes the representation of a hTTPProxy and updates it. Returns the server's representation of the hTTPProxy, and an error, if there is any. -func (c *FakeHTTPProxies) Update(hTTPProxy *projectcontourv1.HTTPProxy) (result *projectcontourv1.HTTPProxy, err error) { +func (c *FakeHTTPProxies) Update(ctx context.Context, hTTPProxy *projectcontourv1.HTTPProxy, opts v1.UpdateOptions) (result *projectcontourv1.HTTPProxy, err error) { obj, err := c.Fake. Invokes(testing.NewUpdateAction(httpproxiesResource, c.ns, hTTPProxy), &projectcontourv1.HTTPProxy{}) @@ -102,7 +104,7 @@ func (c *FakeHTTPProxies) Update(hTTPProxy *projectcontourv1.HTTPProxy) (result // UpdateStatus was generated because the type contains a Status member. // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *FakeHTTPProxies) UpdateStatus(hTTPProxy *projectcontourv1.HTTPProxy) (*projectcontourv1.HTTPProxy, error) { +func (c *FakeHTTPProxies) UpdateStatus(ctx context.Context, hTTPProxy *projectcontourv1.HTTPProxy, opts v1.UpdateOptions) (*projectcontourv1.HTTPProxy, error) { obj, err := c.Fake. Invokes(testing.NewUpdateSubresourceAction(httpproxiesResource, "status", c.ns, hTTPProxy), &projectcontourv1.HTTPProxy{}) @@ -113,7 +115,7 @@ func (c *FakeHTTPProxies) UpdateStatus(hTTPProxy *projectcontourv1.HTTPProxy) (* } // Delete takes name of the hTTPProxy and deletes it. Returns an error if one occurs. -func (c *FakeHTTPProxies) Delete(name string, options *v1.DeleteOptions) error { +func (c *FakeHTTPProxies) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { _, err := c.Fake. Invokes(testing.NewDeleteAction(httpproxiesResource, c.ns, name), &projectcontourv1.HTTPProxy{}) @@ -121,15 +123,15 @@ func (c *FakeHTTPProxies) Delete(name string, options *v1.DeleteOptions) error { } // DeleteCollection deletes a collection of objects. -func (c *FakeHTTPProxies) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(httpproxiesResource, c.ns, listOptions) +func (c *FakeHTTPProxies) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(httpproxiesResource, c.ns, listOpts) _, err := c.Fake.Invokes(action, &projectcontourv1.HTTPProxyList{}) return err } // Patch applies the patch and returns the patched hTTPProxy. -func (c *FakeHTTPProxies) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *projectcontourv1.HTTPProxy, err error) { +func (c *FakeHTTPProxies) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *projectcontourv1.HTTPProxy, err error) { obj, err := c.Fake. Invokes(testing.NewPatchSubresourceAction(httpproxiesResource, c.ns, name, pt, data, subresources...), &projectcontourv1.HTTPProxy{}) diff --git a/pkg/client/clientset/versioned/typed/projectcontour/v1/httpproxy.go b/pkg/client/clientset/versioned/typed/projectcontour/v1/httpproxy.go index 4366e5a1..f8fb8169 100644 --- a/pkg/client/clientset/versioned/typed/projectcontour/v1/httpproxy.go +++ b/pkg/client/clientset/versioned/typed/projectcontour/v1/httpproxy.go @@ -19,6 +19,7 @@ limitations under the License. package v1 import ( + "context" "time" v1 "github.com/weaveworks/flagger/pkg/apis/projectcontour/v1" @@ -37,15 +38,15 @@ type HTTPProxiesGetter interface { // HTTPProxyInterface has methods to work with HTTPProxy resources. type HTTPProxyInterface interface { - Create(*v1.HTTPProxy) (*v1.HTTPProxy, error) - Update(*v1.HTTPProxy) (*v1.HTTPProxy, error) - UpdateStatus(*v1.HTTPProxy) (*v1.HTTPProxy, error) - Delete(name string, options *metav1.DeleteOptions) error - DeleteCollection(options *metav1.DeleteOptions, listOptions metav1.ListOptions) error - Get(name string, options metav1.GetOptions) (*v1.HTTPProxy, error) - List(opts metav1.ListOptions) (*v1.HTTPProxyList, error) - Watch(opts metav1.ListOptions) (watch.Interface, error) - Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.HTTPProxy, err error) + Create(ctx context.Context, hTTPProxy *v1.HTTPProxy, opts metav1.CreateOptions) (*v1.HTTPProxy, error) + Update(ctx context.Context, hTTPProxy *v1.HTTPProxy, opts metav1.UpdateOptions) (*v1.HTTPProxy, error) + UpdateStatus(ctx context.Context, hTTPProxy *v1.HTTPProxy, opts metav1.UpdateOptions) (*v1.HTTPProxy, error) + Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error + Get(ctx context.Context, name string, opts metav1.GetOptions) (*v1.HTTPProxy, error) + List(ctx context.Context, opts metav1.ListOptions) (*v1.HTTPProxyList, error) + Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.HTTPProxy, err error) HTTPProxyExpansion } @@ -64,20 +65,20 @@ func newHTTPProxies(c *ProjectcontourV1Client, namespace string) *hTTPProxies { } // Get takes name of the hTTPProxy, and returns the corresponding hTTPProxy object, and an error if there is any. -func (c *hTTPProxies) Get(name string, options metav1.GetOptions) (result *v1.HTTPProxy, err error) { +func (c *hTTPProxies) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.HTTPProxy, err error) { result = &v1.HTTPProxy{} err = c.client.Get(). Namespace(c.ns). Resource("httpproxies"). Name(name). VersionedParams(&options, scheme.ParameterCodec). - Do(). + Do(ctx). Into(result) return } // List takes label and field selectors, and returns the list of HTTPProxies that match those selectors. -func (c *hTTPProxies) List(opts metav1.ListOptions) (result *v1.HTTPProxyList, err error) { +func (c *hTTPProxies) List(ctx context.Context, opts metav1.ListOptions) (result *v1.HTTPProxyList, err error) { var timeout time.Duration if opts.TimeoutSeconds != nil { timeout = time.Duration(*opts.TimeoutSeconds) * time.Second @@ -88,13 +89,13 @@ func (c *hTTPProxies) List(opts metav1.ListOptions) (result *v1.HTTPProxyList, e Resource("httpproxies"). VersionedParams(&opts, scheme.ParameterCodec). Timeout(timeout). - Do(). + Do(ctx). Into(result) return } // Watch returns a watch.Interface that watches the requested hTTPProxies. -func (c *hTTPProxies) Watch(opts metav1.ListOptions) (watch.Interface, error) { +func (c *hTTPProxies) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { var timeout time.Duration if opts.TimeoutSeconds != nil { timeout = time.Duration(*opts.TimeoutSeconds) * time.Second @@ -105,87 +106,90 @@ func (c *hTTPProxies) Watch(opts metav1.ListOptions) (watch.Interface, error) { Resource("httpproxies"). VersionedParams(&opts, scheme.ParameterCodec). Timeout(timeout). - Watch() + Watch(ctx) } // Create takes the representation of a hTTPProxy and creates it. Returns the server's representation of the hTTPProxy, and an error, if there is any. -func (c *hTTPProxies) Create(hTTPProxy *v1.HTTPProxy) (result *v1.HTTPProxy, err error) { +func (c *hTTPProxies) Create(ctx context.Context, hTTPProxy *v1.HTTPProxy, opts metav1.CreateOptions) (result *v1.HTTPProxy, err error) { result = &v1.HTTPProxy{} err = c.client.Post(). Namespace(c.ns). Resource("httpproxies"). + VersionedParams(&opts, scheme.ParameterCodec). Body(hTTPProxy). - Do(). + Do(ctx). Into(result) return } // Update takes the representation of a hTTPProxy and updates it. Returns the server's representation of the hTTPProxy, and an error, if there is any. -func (c *hTTPProxies) Update(hTTPProxy *v1.HTTPProxy) (result *v1.HTTPProxy, err error) { +func (c *hTTPProxies) Update(ctx context.Context, hTTPProxy *v1.HTTPProxy, opts metav1.UpdateOptions) (result *v1.HTTPProxy, err error) { result = &v1.HTTPProxy{} err = c.client.Put(). Namespace(c.ns). Resource("httpproxies"). Name(hTTPProxy.Name). + VersionedParams(&opts, scheme.ParameterCodec). Body(hTTPProxy). - Do(). + Do(ctx). Into(result) return } // UpdateStatus was generated because the type contains a Status member. // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). - -func (c *hTTPProxies) UpdateStatus(hTTPProxy *v1.HTTPProxy) (result *v1.HTTPProxy, err error) { +func (c *hTTPProxies) UpdateStatus(ctx context.Context, hTTPProxy *v1.HTTPProxy, opts metav1.UpdateOptions) (result *v1.HTTPProxy, err error) { result = &v1.HTTPProxy{} err = c.client.Put(). Namespace(c.ns). Resource("httpproxies"). Name(hTTPProxy.Name). SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). Body(hTTPProxy). - Do(). + Do(ctx). Into(result) return } // Delete takes name of the hTTPProxy and deletes it. Returns an error if one occurs. -func (c *hTTPProxies) Delete(name string, options *metav1.DeleteOptions) error { +func (c *hTTPProxies) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { return c.client.Delete(). Namespace(c.ns). Resource("httpproxies"). Name(name). - Body(options). - Do(). + Body(&opts). + Do(ctx). Error() } // DeleteCollection deletes a collection of objects. -func (c *hTTPProxies) DeleteCollection(options *metav1.DeleteOptions, listOptions metav1.ListOptions) error { +func (c *hTTPProxies) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { var timeout time.Duration - if listOptions.TimeoutSeconds != nil { - timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second } return c.client.Delete(). Namespace(c.ns). Resource("httpproxies"). - VersionedParams(&listOptions, scheme.ParameterCodec). + VersionedParams(&listOpts, scheme.ParameterCodec). Timeout(timeout). - Body(options). - Do(). + Body(&opts). + Do(ctx). Error() } // Patch applies the patch and returns the patched hTTPProxy. -func (c *hTTPProxies) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.HTTPProxy, err error) { +func (c *hTTPProxies) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.HTTPProxy, err error) { result = &v1.HTTPProxy{} err = c.client.Patch(pt). Namespace(c.ns). Resource("httpproxies"). - SubResource(subresources...). Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). Body(data). - Do(). + Do(ctx). Into(result) return } diff --git a/pkg/client/clientset/versioned/typed/smi/v1alpha1/fake/fake_trafficsplit.go b/pkg/client/clientset/versioned/typed/smi/v1alpha1/fake/fake_trafficsplit.go index ac6b67cc..38cb075d 100644 --- a/pkg/client/clientset/versioned/typed/smi/v1alpha1/fake/fake_trafficsplit.go +++ b/pkg/client/clientset/versioned/typed/smi/v1alpha1/fake/fake_trafficsplit.go @@ -19,6 +19,8 @@ limitations under the License. package fake import ( + "context" + v1alpha1 "github.com/weaveworks/flagger/pkg/apis/smi/v1alpha1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" @@ -39,7 +41,7 @@ var trafficsplitsResource = schema.GroupVersionResource{Group: "split.smi-spec.i var trafficsplitsKind = schema.GroupVersionKind{Group: "split.smi-spec.io", Version: "v1alpha1", Kind: "TrafficSplit"} // Get takes name of the trafficSplit, and returns the corresponding trafficSplit object, and an error if there is any. -func (c *FakeTrafficSplits) Get(name string, options v1.GetOptions) (result *v1alpha1.TrafficSplit, err error) { +func (c *FakeTrafficSplits) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.TrafficSplit, err error) { obj, err := c.Fake. Invokes(testing.NewGetAction(trafficsplitsResource, c.ns, name), &v1alpha1.TrafficSplit{}) @@ -50,7 +52,7 @@ func (c *FakeTrafficSplits) Get(name string, options v1.GetOptions) (result *v1a } // List takes label and field selectors, and returns the list of TrafficSplits that match those selectors. -func (c *FakeTrafficSplits) List(opts v1.ListOptions) (result *v1alpha1.TrafficSplitList, err error) { +func (c *FakeTrafficSplits) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.TrafficSplitList, err error) { obj, err := c.Fake. Invokes(testing.NewListAction(trafficsplitsResource, trafficsplitsKind, c.ns, opts), &v1alpha1.TrafficSplitList{}) @@ -72,14 +74,14 @@ func (c *FakeTrafficSplits) List(opts v1.ListOptions) (result *v1alpha1.TrafficS } // Watch returns a watch.Interface that watches the requested trafficSplits. -func (c *FakeTrafficSplits) Watch(opts v1.ListOptions) (watch.Interface, error) { +func (c *FakeTrafficSplits) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.Fake. InvokesWatch(testing.NewWatchAction(trafficsplitsResource, c.ns, opts)) } // Create takes the representation of a trafficSplit and creates it. Returns the server's representation of the trafficSplit, and an error, if there is any. -func (c *FakeTrafficSplits) Create(trafficSplit *v1alpha1.TrafficSplit) (result *v1alpha1.TrafficSplit, err error) { +func (c *FakeTrafficSplits) Create(ctx context.Context, trafficSplit *v1alpha1.TrafficSplit, opts v1.CreateOptions) (result *v1alpha1.TrafficSplit, err error) { obj, err := c.Fake. Invokes(testing.NewCreateAction(trafficsplitsResource, c.ns, trafficSplit), &v1alpha1.TrafficSplit{}) @@ -90,7 +92,7 @@ func (c *FakeTrafficSplits) Create(trafficSplit *v1alpha1.TrafficSplit) (result } // Update takes the representation of a trafficSplit and updates it. Returns the server's representation of the trafficSplit, and an error, if there is any. -func (c *FakeTrafficSplits) Update(trafficSplit *v1alpha1.TrafficSplit) (result *v1alpha1.TrafficSplit, err error) { +func (c *FakeTrafficSplits) Update(ctx context.Context, trafficSplit *v1alpha1.TrafficSplit, opts v1.UpdateOptions) (result *v1alpha1.TrafficSplit, err error) { obj, err := c.Fake. Invokes(testing.NewUpdateAction(trafficsplitsResource, c.ns, trafficSplit), &v1alpha1.TrafficSplit{}) @@ -101,7 +103,7 @@ func (c *FakeTrafficSplits) Update(trafficSplit *v1alpha1.TrafficSplit) (result } // Delete takes name of the trafficSplit and deletes it. Returns an error if one occurs. -func (c *FakeTrafficSplits) Delete(name string, options *v1.DeleteOptions) error { +func (c *FakeTrafficSplits) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { _, err := c.Fake. Invokes(testing.NewDeleteAction(trafficsplitsResource, c.ns, name), &v1alpha1.TrafficSplit{}) @@ -109,15 +111,15 @@ func (c *FakeTrafficSplits) Delete(name string, options *v1.DeleteOptions) error } // DeleteCollection deletes a collection of objects. -func (c *FakeTrafficSplits) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(trafficsplitsResource, c.ns, listOptions) +func (c *FakeTrafficSplits) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(trafficsplitsResource, c.ns, listOpts) _, err := c.Fake.Invokes(action, &v1alpha1.TrafficSplitList{}) return err } // Patch applies the patch and returns the patched trafficSplit. -func (c *FakeTrafficSplits) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.TrafficSplit, err error) { +func (c *FakeTrafficSplits) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.TrafficSplit, err error) { obj, err := c.Fake. Invokes(testing.NewPatchSubresourceAction(trafficsplitsResource, c.ns, name, pt, data, subresources...), &v1alpha1.TrafficSplit{}) diff --git a/pkg/client/clientset/versioned/typed/smi/v1alpha1/trafficsplit.go b/pkg/client/clientset/versioned/typed/smi/v1alpha1/trafficsplit.go index 18f7bdc6..646625ca 100644 --- a/pkg/client/clientset/versioned/typed/smi/v1alpha1/trafficsplit.go +++ b/pkg/client/clientset/versioned/typed/smi/v1alpha1/trafficsplit.go @@ -19,6 +19,7 @@ limitations under the License. package v1alpha1 import ( + "context" "time" v1alpha1 "github.com/weaveworks/flagger/pkg/apis/smi/v1alpha1" @@ -37,14 +38,14 @@ type TrafficSplitsGetter interface { // TrafficSplitInterface has methods to work with TrafficSplit resources. type TrafficSplitInterface interface { - Create(*v1alpha1.TrafficSplit) (*v1alpha1.TrafficSplit, error) - Update(*v1alpha1.TrafficSplit) (*v1alpha1.TrafficSplit, error) - Delete(name string, options *v1.DeleteOptions) error - DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error - Get(name string, options v1.GetOptions) (*v1alpha1.TrafficSplit, error) - List(opts v1.ListOptions) (*v1alpha1.TrafficSplitList, error) - Watch(opts v1.ListOptions) (watch.Interface, error) - Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.TrafficSplit, err error) + Create(ctx context.Context, trafficSplit *v1alpha1.TrafficSplit, opts v1.CreateOptions) (*v1alpha1.TrafficSplit, error) + Update(ctx context.Context, trafficSplit *v1alpha1.TrafficSplit, opts v1.UpdateOptions) (*v1alpha1.TrafficSplit, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.TrafficSplit, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.TrafficSplitList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.TrafficSplit, err error) TrafficSplitExpansion } @@ -63,20 +64,20 @@ func newTrafficSplits(c *SplitV1alpha1Client, namespace string) *trafficSplits { } // Get takes name of the trafficSplit, and returns the corresponding trafficSplit object, and an error if there is any. -func (c *trafficSplits) Get(name string, options v1.GetOptions) (result *v1alpha1.TrafficSplit, err error) { +func (c *trafficSplits) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.TrafficSplit, err error) { result = &v1alpha1.TrafficSplit{} err = c.client.Get(). Namespace(c.ns). Resource("trafficsplits"). Name(name). VersionedParams(&options, scheme.ParameterCodec). - Do(). + Do(ctx). Into(result) return } // List takes label and field selectors, and returns the list of TrafficSplits that match those selectors. -func (c *trafficSplits) List(opts v1.ListOptions) (result *v1alpha1.TrafficSplitList, err error) { +func (c *trafficSplits) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.TrafficSplitList, err error) { var timeout time.Duration if opts.TimeoutSeconds != nil { timeout = time.Duration(*opts.TimeoutSeconds) * time.Second @@ -87,13 +88,13 @@ func (c *trafficSplits) List(opts v1.ListOptions) (result *v1alpha1.TrafficSplit Resource("trafficsplits"). VersionedParams(&opts, scheme.ParameterCodec). Timeout(timeout). - Do(). + Do(ctx). Into(result) return } // Watch returns a watch.Interface that watches the requested trafficSplits. -func (c *trafficSplits) Watch(opts v1.ListOptions) (watch.Interface, error) { +func (c *trafficSplits) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration if opts.TimeoutSeconds != nil { timeout = time.Duration(*opts.TimeoutSeconds) * time.Second @@ -104,71 +105,74 @@ func (c *trafficSplits) Watch(opts v1.ListOptions) (watch.Interface, error) { Resource("trafficsplits"). VersionedParams(&opts, scheme.ParameterCodec). Timeout(timeout). - Watch() + Watch(ctx) } // Create takes the representation of a trafficSplit and creates it. Returns the server's representation of the trafficSplit, and an error, if there is any. -func (c *trafficSplits) Create(trafficSplit *v1alpha1.TrafficSplit) (result *v1alpha1.TrafficSplit, err error) { +func (c *trafficSplits) Create(ctx context.Context, trafficSplit *v1alpha1.TrafficSplit, opts v1.CreateOptions) (result *v1alpha1.TrafficSplit, err error) { result = &v1alpha1.TrafficSplit{} err = c.client.Post(). Namespace(c.ns). Resource("trafficsplits"). + VersionedParams(&opts, scheme.ParameterCodec). Body(trafficSplit). - Do(). + Do(ctx). Into(result) return } // Update takes the representation of a trafficSplit and updates it. Returns the server's representation of the trafficSplit, and an error, if there is any. -func (c *trafficSplits) Update(trafficSplit *v1alpha1.TrafficSplit) (result *v1alpha1.TrafficSplit, err error) { +func (c *trafficSplits) Update(ctx context.Context, trafficSplit *v1alpha1.TrafficSplit, opts v1.UpdateOptions) (result *v1alpha1.TrafficSplit, err error) { result = &v1alpha1.TrafficSplit{} err = c.client.Put(). Namespace(c.ns). Resource("trafficsplits"). Name(trafficSplit.Name). + VersionedParams(&opts, scheme.ParameterCodec). Body(trafficSplit). - Do(). + Do(ctx). Into(result) return } // Delete takes name of the trafficSplit and deletes it. Returns an error if one occurs. -func (c *trafficSplits) Delete(name string, options *v1.DeleteOptions) error { +func (c *trafficSplits) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { return c.client.Delete(). Namespace(c.ns). Resource("trafficsplits"). Name(name). - Body(options). - Do(). + Body(&opts). + Do(ctx). Error() } // DeleteCollection deletes a collection of objects. -func (c *trafficSplits) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { +func (c *trafficSplits) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { var timeout time.Duration - if listOptions.TimeoutSeconds != nil { - timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second } return c.client.Delete(). Namespace(c.ns). Resource("trafficsplits"). - VersionedParams(&listOptions, scheme.ParameterCodec). + VersionedParams(&listOpts, scheme.ParameterCodec). Timeout(timeout). - Body(options). - Do(). + Body(&opts). + Do(ctx). Error() } // Patch applies the patch and returns the patched trafficSplit. -func (c *trafficSplits) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.TrafficSplit, err error) { +func (c *trafficSplits) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.TrafficSplit, err error) { result = &v1alpha1.TrafficSplit{} err = c.client.Patch(pt). Namespace(c.ns). Resource("trafficsplits"). - SubResource(subresources...). Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). Body(data). - Do(). + Do(ctx). Into(result) return } diff --git a/pkg/client/clientset/versioned/typed/smi/v1alpha2/fake/fake_trafficsplit.go b/pkg/client/clientset/versioned/typed/smi/v1alpha2/fake/fake_trafficsplit.go index 6f29ed46..ab5e8136 100644 --- a/pkg/client/clientset/versioned/typed/smi/v1alpha2/fake/fake_trafficsplit.go +++ b/pkg/client/clientset/versioned/typed/smi/v1alpha2/fake/fake_trafficsplit.go @@ -19,6 +19,8 @@ limitations under the License. package fake import ( + "context" + v1alpha2 "github.com/weaveworks/flagger/pkg/apis/smi/v1alpha2" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" @@ -39,7 +41,7 @@ var trafficsplitsResource = schema.GroupVersionResource{Group: "split.smi-spec.i var trafficsplitsKind = schema.GroupVersionKind{Group: "split.smi-spec.io", Version: "v1alpha2", Kind: "TrafficSplit"} // Get takes name of the trafficSplit, and returns the corresponding trafficSplit object, and an error if there is any. -func (c *FakeTrafficSplits) Get(name string, options v1.GetOptions) (result *v1alpha2.TrafficSplit, err error) { +func (c *FakeTrafficSplits) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha2.TrafficSplit, err error) { obj, err := c.Fake. Invokes(testing.NewGetAction(trafficsplitsResource, c.ns, name), &v1alpha2.TrafficSplit{}) @@ -50,7 +52,7 @@ func (c *FakeTrafficSplits) Get(name string, options v1.GetOptions) (result *v1a } // List takes label and field selectors, and returns the list of TrafficSplits that match those selectors. -func (c *FakeTrafficSplits) List(opts v1.ListOptions) (result *v1alpha2.TrafficSplitList, err error) { +func (c *FakeTrafficSplits) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha2.TrafficSplitList, err error) { obj, err := c.Fake. Invokes(testing.NewListAction(trafficsplitsResource, trafficsplitsKind, c.ns, opts), &v1alpha2.TrafficSplitList{}) @@ -72,14 +74,14 @@ func (c *FakeTrafficSplits) List(opts v1.ListOptions) (result *v1alpha2.TrafficS } // Watch returns a watch.Interface that watches the requested trafficSplits. -func (c *FakeTrafficSplits) Watch(opts v1.ListOptions) (watch.Interface, error) { +func (c *FakeTrafficSplits) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.Fake. InvokesWatch(testing.NewWatchAction(trafficsplitsResource, c.ns, opts)) } // Create takes the representation of a trafficSplit and creates it. Returns the server's representation of the trafficSplit, and an error, if there is any. -func (c *FakeTrafficSplits) Create(trafficSplit *v1alpha2.TrafficSplit) (result *v1alpha2.TrafficSplit, err error) { +func (c *FakeTrafficSplits) Create(ctx context.Context, trafficSplit *v1alpha2.TrafficSplit, opts v1.CreateOptions) (result *v1alpha2.TrafficSplit, err error) { obj, err := c.Fake. Invokes(testing.NewCreateAction(trafficsplitsResource, c.ns, trafficSplit), &v1alpha2.TrafficSplit{}) @@ -90,7 +92,7 @@ func (c *FakeTrafficSplits) Create(trafficSplit *v1alpha2.TrafficSplit) (result } // Update takes the representation of a trafficSplit and updates it. Returns the server's representation of the trafficSplit, and an error, if there is any. -func (c *FakeTrafficSplits) Update(trafficSplit *v1alpha2.TrafficSplit) (result *v1alpha2.TrafficSplit, err error) { +func (c *FakeTrafficSplits) Update(ctx context.Context, trafficSplit *v1alpha2.TrafficSplit, opts v1.UpdateOptions) (result *v1alpha2.TrafficSplit, err error) { obj, err := c.Fake. Invokes(testing.NewUpdateAction(trafficsplitsResource, c.ns, trafficSplit), &v1alpha2.TrafficSplit{}) @@ -101,7 +103,7 @@ func (c *FakeTrafficSplits) Update(trafficSplit *v1alpha2.TrafficSplit) (result } // Delete takes name of the trafficSplit and deletes it. Returns an error if one occurs. -func (c *FakeTrafficSplits) Delete(name string, options *v1.DeleteOptions) error { +func (c *FakeTrafficSplits) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { _, err := c.Fake. Invokes(testing.NewDeleteAction(trafficsplitsResource, c.ns, name), &v1alpha2.TrafficSplit{}) @@ -109,15 +111,15 @@ func (c *FakeTrafficSplits) Delete(name string, options *v1.DeleteOptions) error } // DeleteCollection deletes a collection of objects. -func (c *FakeTrafficSplits) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(trafficsplitsResource, c.ns, listOptions) +func (c *FakeTrafficSplits) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(trafficsplitsResource, c.ns, listOpts) _, err := c.Fake.Invokes(action, &v1alpha2.TrafficSplitList{}) return err } // Patch applies the patch and returns the patched trafficSplit. -func (c *FakeTrafficSplits) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha2.TrafficSplit, err error) { +func (c *FakeTrafficSplits) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha2.TrafficSplit, err error) { obj, err := c.Fake. Invokes(testing.NewPatchSubresourceAction(trafficsplitsResource, c.ns, name, pt, data, subresources...), &v1alpha2.TrafficSplit{}) diff --git a/pkg/client/clientset/versioned/typed/smi/v1alpha2/trafficsplit.go b/pkg/client/clientset/versioned/typed/smi/v1alpha2/trafficsplit.go index 196df171..95dc8f85 100644 --- a/pkg/client/clientset/versioned/typed/smi/v1alpha2/trafficsplit.go +++ b/pkg/client/clientset/versioned/typed/smi/v1alpha2/trafficsplit.go @@ -19,6 +19,7 @@ limitations under the License. package v1alpha2 import ( + "context" "time" v1alpha2 "github.com/weaveworks/flagger/pkg/apis/smi/v1alpha2" @@ -37,14 +38,14 @@ type TrafficSplitsGetter interface { // TrafficSplitInterface has methods to work with TrafficSplit resources. type TrafficSplitInterface interface { - Create(*v1alpha2.TrafficSplit) (*v1alpha2.TrafficSplit, error) - Update(*v1alpha2.TrafficSplit) (*v1alpha2.TrafficSplit, error) - Delete(name string, options *v1.DeleteOptions) error - DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error - Get(name string, options v1.GetOptions) (*v1alpha2.TrafficSplit, error) - List(opts v1.ListOptions) (*v1alpha2.TrafficSplitList, error) - Watch(opts v1.ListOptions) (watch.Interface, error) - Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha2.TrafficSplit, err error) + Create(ctx context.Context, trafficSplit *v1alpha2.TrafficSplit, opts v1.CreateOptions) (*v1alpha2.TrafficSplit, error) + Update(ctx context.Context, trafficSplit *v1alpha2.TrafficSplit, opts v1.UpdateOptions) (*v1alpha2.TrafficSplit, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha2.TrafficSplit, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha2.TrafficSplitList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha2.TrafficSplit, err error) TrafficSplitExpansion } @@ -63,20 +64,20 @@ func newTrafficSplits(c *SplitV1alpha2Client, namespace string) *trafficSplits { } // Get takes name of the trafficSplit, and returns the corresponding trafficSplit object, and an error if there is any. -func (c *trafficSplits) Get(name string, options v1.GetOptions) (result *v1alpha2.TrafficSplit, err error) { +func (c *trafficSplits) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha2.TrafficSplit, err error) { result = &v1alpha2.TrafficSplit{} err = c.client.Get(). Namespace(c.ns). Resource("trafficsplits"). Name(name). VersionedParams(&options, scheme.ParameterCodec). - Do(). + Do(ctx). Into(result) return } // List takes label and field selectors, and returns the list of TrafficSplits that match those selectors. -func (c *trafficSplits) List(opts v1.ListOptions) (result *v1alpha2.TrafficSplitList, err error) { +func (c *trafficSplits) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha2.TrafficSplitList, err error) { var timeout time.Duration if opts.TimeoutSeconds != nil { timeout = time.Duration(*opts.TimeoutSeconds) * time.Second @@ -87,13 +88,13 @@ func (c *trafficSplits) List(opts v1.ListOptions) (result *v1alpha2.TrafficSplit Resource("trafficsplits"). VersionedParams(&opts, scheme.ParameterCodec). Timeout(timeout). - Do(). + Do(ctx). Into(result) return } // Watch returns a watch.Interface that watches the requested trafficSplits. -func (c *trafficSplits) Watch(opts v1.ListOptions) (watch.Interface, error) { +func (c *trafficSplits) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { var timeout time.Duration if opts.TimeoutSeconds != nil { timeout = time.Duration(*opts.TimeoutSeconds) * time.Second @@ -104,71 +105,74 @@ func (c *trafficSplits) Watch(opts v1.ListOptions) (watch.Interface, error) { Resource("trafficsplits"). VersionedParams(&opts, scheme.ParameterCodec). Timeout(timeout). - Watch() + Watch(ctx) } // Create takes the representation of a trafficSplit and creates it. Returns the server's representation of the trafficSplit, and an error, if there is any. -func (c *trafficSplits) Create(trafficSplit *v1alpha2.TrafficSplit) (result *v1alpha2.TrafficSplit, err error) { +func (c *trafficSplits) Create(ctx context.Context, trafficSplit *v1alpha2.TrafficSplit, opts v1.CreateOptions) (result *v1alpha2.TrafficSplit, err error) { result = &v1alpha2.TrafficSplit{} err = c.client.Post(). Namespace(c.ns). Resource("trafficsplits"). + VersionedParams(&opts, scheme.ParameterCodec). Body(trafficSplit). - Do(). + Do(ctx). Into(result) return } // Update takes the representation of a trafficSplit and updates it. Returns the server's representation of the trafficSplit, and an error, if there is any. -func (c *trafficSplits) Update(trafficSplit *v1alpha2.TrafficSplit) (result *v1alpha2.TrafficSplit, err error) { +func (c *trafficSplits) Update(ctx context.Context, trafficSplit *v1alpha2.TrafficSplit, opts v1.UpdateOptions) (result *v1alpha2.TrafficSplit, err error) { result = &v1alpha2.TrafficSplit{} err = c.client.Put(). Namespace(c.ns). Resource("trafficsplits"). Name(trafficSplit.Name). + VersionedParams(&opts, scheme.ParameterCodec). Body(trafficSplit). - Do(). + Do(ctx). Into(result) return } // Delete takes name of the trafficSplit and deletes it. Returns an error if one occurs. -func (c *trafficSplits) Delete(name string, options *v1.DeleteOptions) error { +func (c *trafficSplits) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { return c.client.Delete(). Namespace(c.ns). Resource("trafficsplits"). Name(name). - Body(options). - Do(). + Body(&opts). + Do(ctx). Error() } // DeleteCollection deletes a collection of objects. -func (c *trafficSplits) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { +func (c *trafficSplits) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { var timeout time.Duration - if listOptions.TimeoutSeconds != nil { - timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second } return c.client.Delete(). Namespace(c.ns). Resource("trafficsplits"). - VersionedParams(&listOptions, scheme.ParameterCodec). + VersionedParams(&listOpts, scheme.ParameterCodec). Timeout(timeout). - Body(options). - Do(). + Body(&opts). + Do(ctx). Error() } // Patch applies the patch and returns the patched trafficSplit. -func (c *trafficSplits) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha2.TrafficSplit, err error) { +func (c *trafficSplits) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha2.TrafficSplit, err error) { result = &v1alpha2.TrafficSplit{} err = c.client.Patch(pt). Namespace(c.ns). Resource("trafficsplits"). - SubResource(subresources...). Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). Body(data). - Do(). + Do(ctx). Into(result) return } diff --git a/pkg/client/informers/externalversions/appmesh/v1beta1/mesh.go b/pkg/client/informers/externalversions/appmesh/v1beta1/mesh.go index ccb9c711..5cbf2405 100644 --- a/pkg/client/informers/externalversions/appmesh/v1beta1/mesh.go +++ b/pkg/client/informers/externalversions/appmesh/v1beta1/mesh.go @@ -19,6 +19,7 @@ limitations under the License. package v1beta1 import ( + "context" time "time" appmeshv1beta1 "github.com/weaveworks/flagger/pkg/apis/appmesh/v1beta1" @@ -60,13 +61,13 @@ func NewFilteredMeshInformer(client versioned.Interface, resyncPeriod time.Durat if tweakListOptions != nil { tweakListOptions(&options) } - return client.AppmeshV1beta1().Meshes().List(options) + return client.AppmeshV1beta1().Meshes().List(context.TODO(), options) }, WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AppmeshV1beta1().Meshes().Watch(options) + return client.AppmeshV1beta1().Meshes().Watch(context.TODO(), options) }, }, &appmeshv1beta1.Mesh{}, diff --git a/pkg/client/informers/externalversions/appmesh/v1beta1/virtualnode.go b/pkg/client/informers/externalversions/appmesh/v1beta1/virtualnode.go index bd87c5db..6efbf3e2 100644 --- a/pkg/client/informers/externalversions/appmesh/v1beta1/virtualnode.go +++ b/pkg/client/informers/externalversions/appmesh/v1beta1/virtualnode.go @@ -19,6 +19,7 @@ limitations under the License. package v1beta1 import ( + "context" time "time" appmeshv1beta1 "github.com/weaveworks/flagger/pkg/apis/appmesh/v1beta1" @@ -61,13 +62,13 @@ func NewFilteredVirtualNodeInformer(client versioned.Interface, namespace string if tweakListOptions != nil { tweakListOptions(&options) } - return client.AppmeshV1beta1().VirtualNodes(namespace).List(options) + return client.AppmeshV1beta1().VirtualNodes(namespace).List(context.TODO(), options) }, WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AppmeshV1beta1().VirtualNodes(namespace).Watch(options) + return client.AppmeshV1beta1().VirtualNodes(namespace).Watch(context.TODO(), options) }, }, &appmeshv1beta1.VirtualNode{}, diff --git a/pkg/client/informers/externalversions/appmesh/v1beta1/virtualservice.go b/pkg/client/informers/externalversions/appmesh/v1beta1/virtualservice.go index fe8174f3..e2270dce 100644 --- a/pkg/client/informers/externalversions/appmesh/v1beta1/virtualservice.go +++ b/pkg/client/informers/externalversions/appmesh/v1beta1/virtualservice.go @@ -19,6 +19,7 @@ limitations under the License. package v1beta1 import ( + "context" time "time" appmeshv1beta1 "github.com/weaveworks/flagger/pkg/apis/appmesh/v1beta1" @@ -61,13 +62,13 @@ func NewFilteredVirtualServiceInformer(client versioned.Interface, namespace str if tweakListOptions != nil { tweakListOptions(&options) } - return client.AppmeshV1beta1().VirtualServices(namespace).List(options) + return client.AppmeshV1beta1().VirtualServices(namespace).List(context.TODO(), options) }, WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.AppmeshV1beta1().VirtualServices(namespace).Watch(options) + return client.AppmeshV1beta1().VirtualServices(namespace).Watch(context.TODO(), options) }, }, &appmeshv1beta1.VirtualService{}, diff --git a/pkg/client/informers/externalversions/flagger/v1beta1/alertprovider.go b/pkg/client/informers/externalversions/flagger/v1beta1/alertprovider.go index 88b34223..4506b9a0 100644 --- a/pkg/client/informers/externalversions/flagger/v1beta1/alertprovider.go +++ b/pkg/client/informers/externalversions/flagger/v1beta1/alertprovider.go @@ -19,6 +19,7 @@ limitations under the License. package v1beta1 import ( + "context" time "time" flaggerv1beta1 "github.com/weaveworks/flagger/pkg/apis/flagger/v1beta1" @@ -61,13 +62,13 @@ func NewFilteredAlertProviderInformer(client versioned.Interface, namespace stri if tweakListOptions != nil { tweakListOptions(&options) } - return client.FlaggerV1beta1().AlertProviders(namespace).List(options) + return client.FlaggerV1beta1().AlertProviders(namespace).List(context.TODO(), options) }, WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.FlaggerV1beta1().AlertProviders(namespace).Watch(options) + return client.FlaggerV1beta1().AlertProviders(namespace).Watch(context.TODO(), options) }, }, &flaggerv1beta1.AlertProvider{}, diff --git a/pkg/client/informers/externalversions/flagger/v1beta1/canary.go b/pkg/client/informers/externalversions/flagger/v1beta1/canary.go index 884b0063..dfcf01bb 100644 --- a/pkg/client/informers/externalversions/flagger/v1beta1/canary.go +++ b/pkg/client/informers/externalversions/flagger/v1beta1/canary.go @@ -19,6 +19,7 @@ limitations under the License. package v1beta1 import ( + "context" time "time" flaggerv1beta1 "github.com/weaveworks/flagger/pkg/apis/flagger/v1beta1" @@ -61,13 +62,13 @@ func NewFilteredCanaryInformer(client versioned.Interface, namespace string, res if tweakListOptions != nil { tweakListOptions(&options) } - return client.FlaggerV1beta1().Canaries(namespace).List(options) + return client.FlaggerV1beta1().Canaries(namespace).List(context.TODO(), options) }, WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.FlaggerV1beta1().Canaries(namespace).Watch(options) + return client.FlaggerV1beta1().Canaries(namespace).Watch(context.TODO(), options) }, }, &flaggerv1beta1.Canary{}, diff --git a/pkg/client/informers/externalversions/flagger/v1beta1/metrictemplate.go b/pkg/client/informers/externalversions/flagger/v1beta1/metrictemplate.go index 43f965cb..a4761a22 100644 --- a/pkg/client/informers/externalversions/flagger/v1beta1/metrictemplate.go +++ b/pkg/client/informers/externalversions/flagger/v1beta1/metrictemplate.go @@ -19,6 +19,7 @@ limitations under the License. package v1beta1 import ( + "context" time "time" flaggerv1beta1 "github.com/weaveworks/flagger/pkg/apis/flagger/v1beta1" @@ -61,13 +62,13 @@ func NewFilteredMetricTemplateInformer(client versioned.Interface, namespace str if tweakListOptions != nil { tweakListOptions(&options) } - return client.FlaggerV1beta1().MetricTemplates(namespace).List(options) + return client.FlaggerV1beta1().MetricTemplates(namespace).List(context.TODO(), options) }, WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.FlaggerV1beta1().MetricTemplates(namespace).Watch(options) + return client.FlaggerV1beta1().MetricTemplates(namespace).Watch(context.TODO(), options) }, }, &flaggerv1beta1.MetricTemplate{}, diff --git a/pkg/client/informers/externalversions/gloo/v1/upstreamgroup.go b/pkg/client/informers/externalversions/gloo/v1/upstreamgroup.go index 8ec9b8f4..7932e004 100644 --- a/pkg/client/informers/externalversions/gloo/v1/upstreamgroup.go +++ b/pkg/client/informers/externalversions/gloo/v1/upstreamgroup.go @@ -19,6 +19,7 @@ limitations under the License. package v1 import ( + "context" time "time" gloov1 "github.com/weaveworks/flagger/pkg/apis/gloo/v1" @@ -61,13 +62,13 @@ func NewFilteredUpstreamGroupInformer(client versioned.Interface, namespace stri if tweakListOptions != nil { tweakListOptions(&options) } - return client.GlooV1().UpstreamGroups(namespace).List(options) + return client.GlooV1().UpstreamGroups(namespace).List(context.TODO(), options) }, WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.GlooV1().UpstreamGroups(namespace).Watch(options) + return client.GlooV1().UpstreamGroups(namespace).Watch(context.TODO(), options) }, }, &gloov1.UpstreamGroup{}, diff --git a/pkg/client/informers/externalversions/istio/v1alpha3/destinationrule.go b/pkg/client/informers/externalversions/istio/v1alpha3/destinationrule.go index c723573a..cf18e51a 100644 --- a/pkg/client/informers/externalversions/istio/v1alpha3/destinationrule.go +++ b/pkg/client/informers/externalversions/istio/v1alpha3/destinationrule.go @@ -19,6 +19,7 @@ limitations under the License. package v1alpha3 import ( + "context" time "time" istiov1alpha3 "github.com/weaveworks/flagger/pkg/apis/istio/v1alpha3" @@ -61,13 +62,13 @@ func NewFilteredDestinationRuleInformer(client versioned.Interface, namespace st if tweakListOptions != nil { tweakListOptions(&options) } - return client.NetworkingV1alpha3().DestinationRules(namespace).List(options) + return client.NetworkingV1alpha3().DestinationRules(namespace).List(context.TODO(), options) }, WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.NetworkingV1alpha3().DestinationRules(namespace).Watch(options) + return client.NetworkingV1alpha3().DestinationRules(namespace).Watch(context.TODO(), options) }, }, &istiov1alpha3.DestinationRule{}, diff --git a/pkg/client/informers/externalversions/istio/v1alpha3/virtualservice.go b/pkg/client/informers/externalversions/istio/v1alpha3/virtualservice.go index 6f022b51..5c81a460 100644 --- a/pkg/client/informers/externalversions/istio/v1alpha3/virtualservice.go +++ b/pkg/client/informers/externalversions/istio/v1alpha3/virtualservice.go @@ -19,6 +19,7 @@ limitations under the License. package v1alpha3 import ( + "context" time "time" istiov1alpha3 "github.com/weaveworks/flagger/pkg/apis/istio/v1alpha3" @@ -61,13 +62,13 @@ func NewFilteredVirtualServiceInformer(client versioned.Interface, namespace str if tweakListOptions != nil { tweakListOptions(&options) } - return client.NetworkingV1alpha3().VirtualServices(namespace).List(options) + return client.NetworkingV1alpha3().VirtualServices(namespace).List(context.TODO(), options) }, WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.NetworkingV1alpha3().VirtualServices(namespace).Watch(options) + return client.NetworkingV1alpha3().VirtualServices(namespace).Watch(context.TODO(), options) }, }, &istiov1alpha3.VirtualService{}, diff --git a/pkg/client/informers/externalversions/projectcontour/v1/httpproxy.go b/pkg/client/informers/externalversions/projectcontour/v1/httpproxy.go index a568c2d8..0963484a 100644 --- a/pkg/client/informers/externalversions/projectcontour/v1/httpproxy.go +++ b/pkg/client/informers/externalversions/projectcontour/v1/httpproxy.go @@ -19,6 +19,7 @@ limitations under the License. package v1 import ( + "context" time "time" projectcontourv1 "github.com/weaveworks/flagger/pkg/apis/projectcontour/v1" @@ -61,13 +62,13 @@ func NewFilteredHTTPProxyInformer(client versioned.Interface, namespace string, if tweakListOptions != nil { tweakListOptions(&options) } - return client.ProjectcontourV1().HTTPProxies(namespace).List(options) + return client.ProjectcontourV1().HTTPProxies(namespace).List(context.TODO(), options) }, WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.ProjectcontourV1().HTTPProxies(namespace).Watch(options) + return client.ProjectcontourV1().HTTPProxies(namespace).Watch(context.TODO(), options) }, }, &projectcontourv1.HTTPProxy{}, diff --git a/pkg/client/informers/externalversions/smi/v1alpha1/trafficsplit.go b/pkg/client/informers/externalversions/smi/v1alpha1/trafficsplit.go index feb6b703..d1024551 100644 --- a/pkg/client/informers/externalversions/smi/v1alpha1/trafficsplit.go +++ b/pkg/client/informers/externalversions/smi/v1alpha1/trafficsplit.go @@ -19,6 +19,7 @@ limitations under the License. package v1alpha1 import ( + "context" time "time" smiv1alpha1 "github.com/weaveworks/flagger/pkg/apis/smi/v1alpha1" @@ -61,13 +62,13 @@ func NewFilteredTrafficSplitInformer(client versioned.Interface, namespace strin if tweakListOptions != nil { tweakListOptions(&options) } - return client.SplitV1alpha1().TrafficSplits(namespace).List(options) + return client.SplitV1alpha1().TrafficSplits(namespace).List(context.TODO(), options) }, WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.SplitV1alpha1().TrafficSplits(namespace).Watch(options) + return client.SplitV1alpha1().TrafficSplits(namespace).Watch(context.TODO(), options) }, }, &smiv1alpha1.TrafficSplit{}, diff --git a/pkg/client/informers/externalversions/smi/v1alpha2/trafficsplit.go b/pkg/client/informers/externalversions/smi/v1alpha2/trafficsplit.go index c5181221..f73faa62 100644 --- a/pkg/client/informers/externalversions/smi/v1alpha2/trafficsplit.go +++ b/pkg/client/informers/externalversions/smi/v1alpha2/trafficsplit.go @@ -19,6 +19,7 @@ limitations under the License. package v1alpha2 import ( + "context" time "time" smiv1alpha2 "github.com/weaveworks/flagger/pkg/apis/smi/v1alpha2" @@ -61,13 +62,13 @@ func NewFilteredTrafficSplitInformer(client versioned.Interface, namespace strin if tweakListOptions != nil { tweakListOptions(&options) } - return client.SplitV1alpha2().TrafficSplits(namespace).List(options) + return client.SplitV1alpha2().TrafficSplits(namespace).List(context.TODO(), options) }, WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.SplitV1alpha2().TrafficSplits(namespace).Watch(options) + return client.SplitV1alpha2().TrafficSplits(namespace).Watch(context.TODO(), options) }, }, &smiv1alpha2.TrafficSplit{}, diff --git a/pkg/controller/controller.go b/pkg/controller/controller.go index fd623c5e..8728e3c7 100644 --- a/pkg/controller/controller.go +++ b/pkg/controller/controller.go @@ -1,6 +1,7 @@ package controller import ( + "context" "fmt" "sync" "time" @@ -269,7 +270,7 @@ func (c *Controller) syncHandler(key string) error { cdCopy.Status.Conditions = conditions cdCopy.Status.LastTransitionTime = metav1.Now() cdCopy.Status.Phase = flaggerv1.CanaryPhaseInitializing - _, err := c.flaggerClient.FlaggerV1beta1().Canaries(cd.Namespace).UpdateStatus(cdCopy) + _, err := c.flaggerClient.FlaggerV1beta1().Canaries(cd.Namespace).UpdateStatus(context.TODO(), cdCopy, metav1.UpdateOptions{}) if err != nil { c.logger.Errorf("%s status condition update error: %v", key, err) return fmt.Errorf("%s status condition update error: %w", key, err) diff --git a/pkg/controller/events.go b/pkg/controller/events.go index cc7bd22b..d7a449e1 100644 --- a/pkg/controller/events.go +++ b/pkg/controller/events.go @@ -1,6 +1,7 @@ package controller import ( + "context" "fmt" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -103,7 +104,7 @@ func (c *Controller) alert(canary *flaggerv1.Canary, message string, metadata bo // extract address from secret if provider.Spec.SecretRef != nil { - secret, err := c.kubeClient.CoreV1().Secrets(providerNamespace).Get(provider.Spec.SecretRef.Name, metav1.GetOptions{}) + secret, err := c.kubeClient.CoreV1().Secrets(providerNamespace).Get(context.TODO(), provider.Spec.SecretRef.Name, metav1.GetOptions{}) if err != nil { c.logger.With("canary", fmt.Sprintf("%s.%s", canary.Name, canary.Namespace)). Errorf("alert provider %s.%s secretRef error: %v", alert.ProviderRef.Name, providerNamespace, err) diff --git a/pkg/controller/finalizer.go b/pkg/controller/finalizer.go index f085273e..7c4a4be7 100644 --- a/pkg/controller/finalizer.go +++ b/pkg/controller/finalizer.go @@ -1,6 +1,7 @@ package controller import ( + "context" "fmt" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -17,7 +18,7 @@ func (c *Controller) finalize(old interface{}) error { return fmt.Errorf("received unexpected object: %v", old) } - _, err := c.flaggerClient.FlaggerV1beta1().Canaries(canary.Namespace).Get(canary.Name, metav1.GetOptions{}) + _, err := c.flaggerClient.FlaggerV1beta1().Canaries(canary.Namespace).Get(context.TODO(), canary.Name, metav1.GetOptions{}) if err != nil { return fmt.Errorf("get query error: %w", err) } @@ -106,7 +107,7 @@ func (c *Controller) addFinalizer(canary *flaggerv1.Canary) error { name, ns := canary.GetName(), canary.GetNamespace() err := retry.RetryOnConflict(retry.DefaultBackoff, func() (err error) { if !firstTry { - canary, err = c.flaggerClient.FlaggerV1beta1().Canaries(ns).Get(name, metav1.GetOptions{}) + canary, err = c.flaggerClient.FlaggerV1beta1().Canaries(ns).Get(context.TODO(), name, metav1.GetOptions{}) if err != nil { return fmt.Errorf("canary %s.%s get query failed: %w", name, ns, err) } @@ -114,7 +115,7 @@ func (c *Controller) addFinalizer(canary *flaggerv1.Canary) error { cCopy := canary.DeepCopy() cCopy.ObjectMeta.Finalizers = append(cCopy.ObjectMeta.Finalizers, finalizer) - _, err = c.flaggerClient.FlaggerV1beta1().Canaries(canary.Namespace).Update(cCopy) + _, err = c.flaggerClient.FlaggerV1beta1().Canaries(canary.Namespace).Update(context.TODO(), cCopy, metav1.UpdateOptions{}) firstTry = false return }) @@ -133,7 +134,7 @@ func (c *Controller) removeFinalizer(canary *flaggerv1.Canary) error { name, ns := canary.GetName(), canary.GetNamespace() err := retry.RetryOnConflict(retry.DefaultBackoff, func() (err error) { if !firstTry { - canary, err = c.flaggerClient.FlaggerV1beta1().Canaries(ns).Get(name, metav1.GetOptions{}) + canary, err = c.flaggerClient.FlaggerV1beta1().Canaries(ns).Get(context.TODO(), name, metav1.GetOptions{}) if err != nil { return fmt.Errorf("canary %s.%s get query failed: %w", name, ns, err) } @@ -153,7 +154,7 @@ func (c *Controller) removeFinalizer(canary *flaggerv1.Canary) error { } cCopy.ObjectMeta.Finalizers = nfs - _, err = c.flaggerClient.FlaggerV1beta1().Canaries(canary.Namespace).Update(cCopy) + _, err = c.flaggerClient.FlaggerV1beta1().Canaries(canary.Namespace).Update(context.TODO(), cCopy, metav1.UpdateOptions{}) firstTry = false return }) diff --git a/pkg/controller/scheduler.go b/pkg/controller/scheduler.go index ed68722d..7de4bb8a 100644 --- a/pkg/controller/scheduler.go +++ b/pkg/controller/scheduler.go @@ -1,6 +1,7 @@ package controller import ( + "context" "fmt" "time" @@ -86,7 +87,7 @@ func (c *Controller) scheduleCanaries() { func (c *Controller) advanceCanary(name string, namespace string) { begin := time.Now() // check if the canary exists - cd, err := c.flaggerClient.FlaggerV1beta1().Canaries(namespace).Get(name, metav1.GetOptions{}) + cd, err := c.flaggerClient.FlaggerV1beta1().Canaries(namespace).Get(context.TODO(), name, metav1.GetOptions{}) if err != nil { c.logger.With("canary", fmt.Sprintf("%s.%s", name, namespace)). Errorf("Canary %s.%s not found", name, namespace) @@ -633,7 +634,7 @@ func (c *Controller) checkCanaryStatus(canary *flaggerv1.Canary, canaryControlle } var err error - canary, err = c.flaggerClient.FlaggerV1beta1().Canaries(canary.Namespace).Get(canary.Name, metav1.GetOptions{}) + canary, err = c.flaggerClient.FlaggerV1beta1().Canaries(canary.Namespace).Get(context.TODO(), canary.Name, metav1.GetOptions{}) if err != nil { c.logger.With("canary", fmt.Sprintf("%s.%s", canary.Name, canary.Namespace)).Errorf("%v", err) return false diff --git a/pkg/controller/scheduler_common_test.go b/pkg/controller/scheduler_common_test.go index 9bda8fb1..970fcec9 100644 --- a/pkg/controller/scheduler_common_test.go +++ b/pkg/controller/scheduler_common_test.go @@ -1,6 +1,7 @@ package controller import ( + "context" "fmt" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -10,7 +11,7 @@ import ( ) func assertPhase(flaggerClient clientset.Interface, canary string, phase flaggerv1.CanaryPhase) error { - c, err := flaggerClient.FlaggerV1beta1().Canaries("default").Get(canary, metav1.GetOptions{}) + c, err := flaggerClient.FlaggerV1beta1().Canaries("default").Get(context.TODO(), canary, metav1.GetOptions{}) if err != nil { return err } diff --git a/pkg/controller/scheduler_daemonset_test.go b/pkg/controller/scheduler_daemonset_test.go index 22fe19c4..1cbb64c3 100644 --- a/pkg/controller/scheduler_daemonset_test.go +++ b/pkg/controller/scheduler_daemonset_test.go @@ -1,6 +1,7 @@ package controller import ( + "context" "encoding/json" "fmt" "io/ioutil" @@ -21,7 +22,7 @@ func TestScheduler_DaemonSetInit(t *testing.T) { mocks := newDaemonSetFixture(nil) mocks.ctrl.advanceCanary("podinfo", "default") - _, err := mocks.kubeClient.AppsV1().DaemonSets("default").Get("podinfo-primary", metav1.GetOptions{}) + _, err := mocks.kubeClient.AppsV1().DaemonSets("default").Get(context.TODO(), "podinfo-primary", metav1.GetOptions{}) require.NoError(t, err) } @@ -31,13 +32,13 @@ func TestScheduler_DaemonSetNewRevision(t *testing.T) { // update dae2 := newDaemonSetTestDaemonSetV2() - _, err := mocks.kubeClient.AppsV1().DaemonSets("default").Update(dae2) + _, err := mocks.kubeClient.AppsV1().DaemonSets("default").Update(context.TODO(), dae2, metav1.UpdateOptions{}) require.NoError(t, err) // detect changes mocks.ctrl.advanceCanary("podinfo", "default") - _, err = mocks.kubeClient.AppsV1().DaemonSets("default").Get("podinfo", metav1.GetOptions{}) + _, err = mocks.kubeClient.AppsV1().DaemonSets("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) } @@ -51,7 +52,7 @@ func TestScheduler_DaemonSetRollback(t *testing.T) { require.NoError(t, err) // set a metric check to fail - c, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get("podinfo", metav1.GetOptions{}) + c, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) cd := c.DeepCopy() @@ -64,7 +65,7 @@ func TestScheduler_DaemonSetRollback(t *testing.T) { }, Query: "fail", }) - _, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Update(cd) + _, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Update(context.TODO(), cd, metav1.UpdateOptions{}) require.NoError(t, err) // run metric checks @@ -74,7 +75,7 @@ func TestScheduler_DaemonSetRollback(t *testing.T) { mocks.ctrl.advanceCanary("podinfo", "default") // check status - c, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get("podinfo", metav1.GetOptions{}) + c, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) assert.Equal(t, flaggerv1.CanaryPhaseFailed, c.Status.Phase) } @@ -85,16 +86,16 @@ func TestScheduler_DaemonSetSkipAnalysis(t *testing.T) { mocks.ctrl.advanceCanary("podinfo", "default") // enable skip - cd, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get("podinfo", metav1.GetOptions{}) + cd, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) cd.Spec.SkipAnalysis = true - _, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Update(cd) + _, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Update(context.TODO(), cd, metav1.UpdateOptions{}) require.NoError(t, err) // update dae2 := newDaemonSetTestDaemonSetV2() - _, err = mocks.kubeClient.AppsV1().DaemonSets("default").Update(dae2) + _, err = mocks.kubeClient.AppsV1().DaemonSets("default").Update(context.TODO(), dae2, metav1.UpdateOptions{}) require.NoError(t, err) // detect changes @@ -102,7 +103,7 @@ func TestScheduler_DaemonSetSkipAnalysis(t *testing.T) { // advance mocks.ctrl.advanceCanary("podinfo", "default") - c, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get("podinfo", metav1.GetOptions{}) + c, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) assert.True(t, c.Spec.SkipAnalysis) assert.Equal(t, flaggerv1.CanaryPhaseSucceeded, c.Status.Phase) @@ -115,7 +116,7 @@ func TestScheduler_DaemonSetNewRevisionReset(t *testing.T) { // first update dae2 := newDaemonSetTestDaemonSetV2() - _, err := mocks.kubeClient.AppsV1().DaemonSets("default").Update(dae2) + _, err := mocks.kubeClient.AppsV1().DaemonSets("default").Update(context.TODO(), dae2, metav1.UpdateOptions{}) require.NoError(t, err) // detect changes @@ -131,7 +132,7 @@ func TestScheduler_DaemonSetNewRevisionReset(t *testing.T) { // second update dae2.Spec.Template.Spec.ServiceAccountName = "test" - _, err = mocks.kubeClient.AppsV1().DaemonSets("default").Update(dae2) + _, err = mocks.kubeClient.AppsV1().DaemonSets("default").Update(context.TODO(), dae2, metav1.UpdateOptions{}) require.NoError(t, err) // detect changes @@ -151,24 +152,24 @@ func TestScheduler_DaemonSetPromotion(t *testing.T) { mocks.ctrl.advanceCanary("podinfo", "default") // check initialized status - c, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get("podinfo", metav1.GetOptions{}) + c, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) assert.Equal(t, flaggerv1.CanaryPhaseInitialized, c.Status.Phase) // update dae2 := newDaemonSetTestDaemonSetV2() - _, err = mocks.kubeClient.AppsV1().DaemonSets("default").Update(dae2) + _, err = mocks.kubeClient.AppsV1().DaemonSets("default").Update(context.TODO(), dae2, metav1.UpdateOptions{}) require.NoError(t, err) // detect pod spec changes mocks.ctrl.advanceCanary("podinfo", "default") config2 := newDaemonSetTestConfigMapV2() - _, err = mocks.kubeClient.CoreV1().ConfigMaps("default").Update(config2) + _, err = mocks.kubeClient.CoreV1().ConfigMaps("default").Update(context.TODO(), config2, metav1.UpdateOptions{}) require.NoError(t, err) secret2 := newDaemonSetTestSecretV2() - _, err = mocks.kubeClient.CoreV1().Secrets("default").Update(secret2) + _, err = mocks.kubeClient.CoreV1().Secrets("default").Update(context.TODO(), secret2, metav1.UpdateOptions{}) require.NoError(t, err) // detect configs changes @@ -186,7 +187,7 @@ func TestScheduler_DaemonSetPromotion(t *testing.T) { mocks.ctrl.advanceCanary("podinfo", "default") // check progressing status - c, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get("podinfo", metav1.GetOptions{}) + c, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) assert.Equal(t, flaggerv1.CanaryPhaseProgressing, c.Status.Phase) @@ -194,7 +195,7 @@ func TestScheduler_DaemonSetPromotion(t *testing.T) { mocks.ctrl.advanceCanary("podinfo", "default") // check promoting status - c, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get("podinfo", metav1.GetOptions{}) + c, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) assert.Equal(t, flaggerv1.CanaryPhasePromoting, c.Status.Phase) @@ -207,30 +208,30 @@ func TestScheduler_DaemonSetPromotion(t *testing.T) { assert.Equal(t, 0, canaryWeight) assert.False(t, mirrored) - primaryDae, err := mocks.kubeClient.AppsV1().DaemonSets("default").Get("podinfo-primary", metav1.GetOptions{}) + primaryDae, err := mocks.kubeClient.AppsV1().DaemonSets("default").Get(context.TODO(), "podinfo-primary", metav1.GetOptions{}) require.NoError(t, err) primaryImage := primaryDae.Spec.Template.Spec.Containers[0].Image canaryImage := dae2.Spec.Template.Spec.Containers[0].Image assert.Equal(t, canaryImage, primaryImage) - configPrimary, err := mocks.kubeClient.CoreV1().ConfigMaps("default").Get("podinfo-config-env-primary", metav1.GetOptions{}) + configPrimary, err := mocks.kubeClient.CoreV1().ConfigMaps("default").Get(context.TODO(), "podinfo-config-env-primary", metav1.GetOptions{}) require.NoError(t, err) assert.Equal(t, config2.Data["color"], configPrimary.Data["color"]) - secretPrimary, err := mocks.kubeClient.CoreV1().Secrets("default").Get("podinfo-secret-env-primary", metav1.GetOptions{}) + secretPrimary, err := mocks.kubeClient.CoreV1().Secrets("default").Get(context.TODO(), "podinfo-secret-env-primary", metav1.GetOptions{}) require.NoError(t, err) assert.Equal(t, string(secret2.Data["apiKey"]), string(secretPrimary.Data["apiKey"])) // check finalising status - c, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get("podinfo", metav1.GetOptions{}) + c, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) assert.Equal(t, flaggerv1.CanaryPhaseFinalising, c.Status.Phase) // scale canary to zero mocks.ctrl.advanceCanary("podinfo", "default") - c, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get("podinfo", metav1.GetOptions{}) + c, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) assert.Equal(t, flaggerv1.CanaryPhaseSucceeded, c.Status.Phase) } @@ -242,7 +243,7 @@ func TestScheduler_DaemonSetMirroring(t *testing.T) { // update dae2 := newDaemonSetTestDaemonSetV2() - _, err := mocks.kubeClient.AppsV1().DaemonSets("default").Update(dae2) + _, err := mocks.kubeClient.AppsV1().DaemonSets("default").Update(context.TODO(), dae2, metav1.UpdateOptions{}) require.NoError(t, err) // detect pod spec changes @@ -276,7 +277,7 @@ func TestScheduler_DaemonSetABTesting(t *testing.T) { // update dae2 := newDaemonSetTestDaemonSetV2() - _, err := mocks.kubeClient.AppsV1().DaemonSets("default").Update(dae2) + _, err := mocks.kubeClient.AppsV1().DaemonSets("default").Update(context.TODO(), dae2, metav1.UpdateOptions{}) require.NoError(t, err) // detect pod spec changes @@ -292,7 +293,7 @@ func TestScheduler_DaemonSetABTesting(t *testing.T) { assert.Equal(t, 100, canaryWeight) assert.False(t, mirrored) - cd, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get("podinfo", metav1.GetOptions{}) + cd, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) // set max iterations @@ -306,12 +307,12 @@ func TestScheduler_DaemonSetABTesting(t *testing.T) { mocks.ctrl.advanceCanary("podinfo", "default") // check finalising status - c, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get("podinfo", metav1.GetOptions{}) + c, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) assert.Equal(t, flaggerv1.CanaryPhaseFinalising, c.Status.Phase) // check if the container image tag was updated - primaryDae, err := mocks.kubeClient.AppsV1().DaemonSets("default").Get("podinfo-primary", metav1.GetOptions{}) + primaryDae, err := mocks.kubeClient.AppsV1().DaemonSets("default").Get(context.TODO(), "podinfo-primary", metav1.GetOptions{}) require.NoError(t, err) primaryImage := primaryDae.Spec.Template.Spec.Containers[0].Image @@ -322,7 +323,7 @@ func TestScheduler_DaemonSetABTesting(t *testing.T) { mocks.ctrl.advanceCanary("podinfo", "default") // check rollout status - c, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get("podinfo", metav1.GetOptions{}) + c, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) assert.Equal(t, flaggerv1.CanaryPhaseSucceeded, c.Status.Phase) } @@ -331,15 +332,15 @@ func TestScheduler_DaemonSetPortDiscovery(t *testing.T) { mocks := newDaemonSetFixture(nil) // enable port discovery - cd, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get("podinfo", metav1.GetOptions{}) + cd, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) cd.Spec.Service.PortDiscovery = true - _, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Update(cd) + _, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Update(context.TODO(), cd, metav1.UpdateOptions{}) require.NoError(t, err) mocks.ctrl.advanceCanary("podinfo", "default") - canarySvc, err := mocks.kubeClient.CoreV1().Services("default").Get("podinfo-canary", metav1.GetOptions{}) + canarySvc, err := mocks.kubeClient.CoreV1().Services("default").Get(context.TODO(), "podinfo-canary", metav1.GetOptions{}) require.NoError(t, err) require.Len(t, canarySvc.Spec.Ports, 3) @@ -362,17 +363,17 @@ func TestScheduler_DaemonSetPortDiscovery(t *testing.T) { func TestScheduler_DaemonSetTargetPortNumber(t *testing.T) { mocks := newDaemonSetFixture(nil) - cd, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get("podinfo", metav1.GetOptions{}) + cd, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) cd.Spec.Service.Port = 80 cd.Spec.Service.TargetPort = intstr.FromInt(9898) cd.Spec.Service.PortDiscovery = true - _, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Update(cd) + _, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Update(context.TODO(), cd, metav1.UpdateOptions{}) require.NoError(t, err) mocks.ctrl.advanceCanary("podinfo", "default") - canarySvc, err := mocks.kubeClient.CoreV1().Services("default").Get("podinfo-canary", metav1.GetOptions{}) + canarySvc, err := mocks.kubeClient.CoreV1().Services("default").Get(context.TODO(), "podinfo-canary", metav1.GetOptions{}) require.NoError(t, err) require.Len(t, canarySvc.Spec.Ports, 3) @@ -395,17 +396,17 @@ func TestScheduler_DaemonSetTargetPortNumber(t *testing.T) { func TestScheduler_DaemonSetTargetPortName(t *testing.T) { mocks := newDaemonSetFixture(nil) - cd, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get("podinfo", metav1.GetOptions{}) + cd, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) cd.Spec.Service.Port = 8080 cd.Spec.Service.TargetPort = intstr.FromString("http") cd.Spec.Service.PortDiscovery = true - _, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Update(cd) + _, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Update(context.TODO(), cd, metav1.UpdateOptions{}) require.NoError(t, err) mocks.ctrl.advanceCanary("podinfo", "default") - canarySvc, err := mocks.kubeClient.CoreV1().Services("default").Get("podinfo-canary", metav1.GetOptions{}) + canarySvc, err := mocks.kubeClient.CoreV1().Services("default").Get(context.TODO(), "podinfo-canary", metav1.GetOptions{}) require.NoError(t, err) require.Len(t, canarySvc.Spec.Ports, 3) @@ -460,7 +461,7 @@ func TestScheduler_DaemonSetAlerts(t *testing.T) { secret.Data = map[string][]byte{ "address": []byte(ts.URL), } - _, err := mocks.kubeClient.CoreV1().Secrets("default").Update(secret) + _, err := mocks.kubeClient.CoreV1().Secrets("default").Update(context.TODO(), secret, metav1.UpdateOptions{}) require.NoError(t, err) // init canary and send alerts diff --git a/pkg/controller/scheduler_deployment_fixture_test.go b/pkg/controller/scheduler_deployment_fixture_test.go index 136a6647..f44415d6 100644 --- a/pkg/controller/scheduler_deployment_fixture_test.go +++ b/pkg/controller/scheduler_deployment_fixture_test.go @@ -1,6 +1,7 @@ package controller import ( + "context" "fmt" "sync" "testing" @@ -55,13 +56,13 @@ func (f fixture) makeCanaryReady(t *testing.T) { func (f fixture) makeReady(t *testing.T, name string) { p, err := f.kubeClient.AppsV1(). Deployments("default"). - Get(name, metav1.GetOptions{}) + Get(context.TODO(), name, metav1.GetOptions{}) require.NoError(t, err) p.Status = appsv1.DeploymentStatus{Replicas: 1, UpdatedReplicas: 1, ReadyReplicas: 1, AvailableReplicas: 1} - _, err = f.kubeClient.AppsV1().Deployments("default").Update(p) + _, err = f.kubeClient.AppsV1().Deployments("default").Update(context.TODO(), p, metav1.UpdateOptions{}) require.NoError(t, err) } diff --git a/pkg/controller/scheduler_deployment_test.go b/pkg/controller/scheduler_deployment_test.go index b6774f76..74772091 100644 --- a/pkg/controller/scheduler_deployment_test.go +++ b/pkg/controller/scheduler_deployment_test.go @@ -1,6 +1,7 @@ package controller import ( + "context" "encoding/json" "fmt" "io/ioutil" @@ -21,7 +22,7 @@ func TestScheduler_DeploymentInit(t *testing.T) { mocks := newDeploymentFixture(nil) mocks.ctrl.advanceCanary("podinfo", "default") - _, err := mocks.kubeClient.AppsV1().Deployments("default").Get("podinfo-primary", metav1.GetOptions{}) + _, err := mocks.kubeClient.AppsV1().Deployments("default").Get(context.TODO(), "podinfo-primary", metav1.GetOptions{}) require.NoError(t, err) } @@ -39,13 +40,13 @@ func TestScheduler_DeploymentNewRevision(t *testing.T) { // update dep2 := newDeploymentTestDeploymentV2() - _, err := mocks.kubeClient.AppsV1().Deployments("default").Update(dep2) + _, err := mocks.kubeClient.AppsV1().Deployments("default").Update(context.TODO(), dep2, metav1.UpdateOptions{}) require.NoError(t, err) // detect changes mocks.ctrl.advanceCanary("podinfo", "default") - c, err := mocks.kubeClient.AppsV1().Deployments("default").Get("podinfo", metav1.GetOptions{}) + c, err := mocks.kubeClient.AppsV1().Deployments("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) assert.Equal(t, int32(1), *c.Spec.Replicas) } @@ -66,7 +67,7 @@ func TestScheduler_DeploymentRollback(t *testing.T) { require.NoError(t, err) // set a metric check to fail - c, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get("podinfo", metav1.GetOptions{}) + c, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) cd := c.DeepCopy() cd.Spec.Analysis.Metrics = append(c.Spec.Analysis.Metrics, flaggerv1.CanaryMetric{ @@ -78,7 +79,7 @@ func TestScheduler_DeploymentRollback(t *testing.T) { }, Query: "fail", }) - _, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Update(cd) + _, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Update(context.TODO(), cd, metav1.UpdateOptions{}) require.NoError(t, err) // run metric checks @@ -90,7 +91,7 @@ func TestScheduler_DeploymentRollback(t *testing.T) { require.NoError(t, err) // check status - c, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get("podinfo", metav1.GetOptions{}) + c, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) assert.Equal(t, flaggerv1.CanaryPhaseFailed, c.Status.Phase) @@ -108,15 +109,15 @@ func TestScheduler_DeploymentSkipAnalysis(t *testing.T) { mocks.ctrl.advanceCanary("podinfo", "default") // enable skip - cd, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get("podinfo", metav1.GetOptions{}) + cd, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) cd.Spec.SkipAnalysis = true - _, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Update(cd) + _, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Update(context.TODO(), cd, metav1.UpdateOptions{}) require.NoError(t, err) // update dep2 := newDeploymentTestDeploymentV2() - _, err = mocks.kubeClient.AppsV1().Deployments("default").Update(dep2) + _, err = mocks.kubeClient.AppsV1().Deployments("default").Update(context.TODO(), dep2, metav1.UpdateOptions{}) require.NoError(t, err) // detect changes @@ -126,7 +127,7 @@ func TestScheduler_DeploymentSkipAnalysis(t *testing.T) { // advance mocks.ctrl.advanceCanary("podinfo", "default") - c, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get("podinfo", metav1.GetOptions{}) + c, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) assert.True(t, c.Spec.SkipAnalysis) assert.Equal(t, flaggerv1.CanaryPhaseSucceeded, c.Status.Phase) @@ -152,7 +153,7 @@ func TestScheduler_DeploymentAnalysisPhases(t *testing.T) { // update dep2 := newDeploymentTestDeploymentV2() - _, err := mocks.kubeClient.AppsV1().Deployments("default").Update(dep2) + _, err := mocks.kubeClient.AppsV1().Deployments("default").Update(context.TODO(), dep2, metav1.UpdateOptions{}) require.NoError(t, err) // detect changes @@ -197,7 +198,7 @@ func TestScheduler_DeploymentBlueGreenAnalysisPhases(t *testing.T) { // update dep2 := newDeploymentTestDeploymentV2() - _, err := mocks.kubeClient.AppsV1().Deployments("default").Update(dep2) + _, err := mocks.kubeClient.AppsV1().Deployments("default").Update(context.TODO(), dep2, metav1.UpdateOptions{}) require.NoError(t, err) // detect changes (progressing) @@ -240,7 +241,7 @@ func TestScheduler_DeploymentNewRevisionReset(t *testing.T) { // first update dep2 := newDeploymentTestDeploymentV2() - _, err := mocks.kubeClient.AppsV1().Deployments("default").Update(dep2) + _, err := mocks.kubeClient.AppsV1().Deployments("default").Update(context.TODO(), dep2, metav1.UpdateOptions{}) require.NoError(t, err) // detect changes @@ -258,7 +259,7 @@ func TestScheduler_DeploymentNewRevisionReset(t *testing.T) { // second update dep2.Spec.Template.Spec.ServiceAccountName = "test" - _, err = mocks.kubeClient.AppsV1().Deployments("default").Update(dep2) + _, err = mocks.kubeClient.AppsV1().Deployments("default").Update(context.TODO(), dep2, metav1.UpdateOptions{}) require.NoError(t, err) // detect changes @@ -284,13 +285,13 @@ func TestScheduler_DeploymentPromotion(t *testing.T) { mocks.ctrl.advanceCanary("podinfo", "default") // check initialized status - c, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get("podinfo", metav1.GetOptions{}) + c, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) assert.Equal(t, flaggerv1.CanaryPhaseInitialized, c.Status.Phase) // update dep2 := newDeploymentTestDeploymentV2() - _, err = mocks.kubeClient.AppsV1().Deployments("default").Update(dep2) + _, err = mocks.kubeClient.AppsV1().Deployments("default").Update(context.TODO(), dep2, metav1.UpdateOptions{}) require.NoError(t, err) // detect pod spec changes @@ -298,11 +299,11 @@ func TestScheduler_DeploymentPromotion(t *testing.T) { mocks.makeCanaryReady(t) config2 := newDeploymentTestConfigMapV2() - _, err = mocks.kubeClient.CoreV1().ConfigMaps("default").Update(config2) + _, err = mocks.kubeClient.CoreV1().ConfigMaps("default").Update(context.TODO(), config2, metav1.UpdateOptions{}) require.NoError(t, err) secret2 := newDeploymentTestSecretV2() - _, err = mocks.kubeClient.CoreV1().Secrets("default").Update(secret2) + _, err = mocks.kubeClient.CoreV1().Secrets("default").Update(context.TODO(), secret2, metav1.UpdateOptions{}) require.NoError(t, err) // detect configs changes @@ -320,7 +321,7 @@ func TestScheduler_DeploymentPromotion(t *testing.T) { mocks.ctrl.advanceCanary("podinfo", "default") // check progressing status - c, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get("podinfo", metav1.GetOptions{}) + c, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) assert.Equal(t, flaggerv1.CanaryPhaseProgressing, c.Status.Phase) @@ -328,7 +329,7 @@ func TestScheduler_DeploymentPromotion(t *testing.T) { mocks.ctrl.advanceCanary("podinfo", "default") // check promoting status - c, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get("podinfo", metav1.GetOptions{}) + c, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) assert.Equal(t, flaggerv1.CanaryPhasePromoting, c.Status.Phase) @@ -341,30 +342,30 @@ func TestScheduler_DeploymentPromotion(t *testing.T) { assert.Equal(t, 0, canaryWeight) assert.False(t, mirrored) - primaryDep, err := mocks.kubeClient.AppsV1().Deployments("default").Get("podinfo-primary", metav1.GetOptions{}) + primaryDep, err := mocks.kubeClient.AppsV1().Deployments("default").Get(context.TODO(), "podinfo-primary", metav1.GetOptions{}) require.NoError(t, err) primaryImage := primaryDep.Spec.Template.Spec.Containers[0].Image canaryImage := dep2.Spec.Template.Spec.Containers[0].Image assert.Equal(t, canaryImage, primaryImage) - configPrimary, err := mocks.kubeClient.CoreV1().ConfigMaps("default").Get("podinfo-config-env-primary", metav1.GetOptions{}) + configPrimary, err := mocks.kubeClient.CoreV1().ConfigMaps("default").Get(context.TODO(), "podinfo-config-env-primary", metav1.GetOptions{}) require.NoError(t, err) assert.Equal(t, config2.Data["color"], configPrimary.Data["color"]) - secretPrimary, err := mocks.kubeClient.CoreV1().Secrets("default").Get("podinfo-secret-env-primary", metav1.GetOptions{}) + secretPrimary, err := mocks.kubeClient.CoreV1().Secrets("default").Get(context.TODO(), "podinfo-secret-env-primary", metav1.GetOptions{}) require.NoError(t, err) assert.Equal(t, string(secret2.Data["apiKey"]), string(secretPrimary.Data["apiKey"])) // check finalising status - c, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get("podinfo", metav1.GetOptions{}) + c, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) assert.Equal(t, flaggerv1.CanaryPhaseFinalising, c.Status.Phase) // scale canary to zero mocks.ctrl.advanceCanary("podinfo", "default") - c, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get("podinfo", metav1.GetOptions{}) + c, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) assert.Equal(t, flaggerv1.CanaryPhaseSucceeded, c.Status.Phase) } @@ -383,7 +384,7 @@ func TestScheduler_DeploymentMirroring(t *testing.T) { // update dep2 := newDeploymentTestDeploymentV2() - _, err := mocks.kubeClient.AppsV1().Deployments("default").Update(dep2) + _, err := mocks.kubeClient.AppsV1().Deployments("default").Update(context.TODO(), dep2, metav1.UpdateOptions{}) require.NoError(t, err) // detect pod spec changes @@ -424,7 +425,7 @@ func TestScheduler_DeploymentABTesting(t *testing.T) { // update dep2 := newDeploymentTestDeploymentV2() - _, err := mocks.kubeClient.AppsV1().Deployments("default").Update(dep2) + _, err := mocks.kubeClient.AppsV1().Deployments("default").Update(context.TODO(), dep2, metav1.UpdateOptions{}) require.NoError(t, err) // detect pod spec changes @@ -441,7 +442,7 @@ func TestScheduler_DeploymentABTesting(t *testing.T) { assert.Equal(t, 100, canaryWeight) assert.False(t, mirrored) - cd, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get("podinfo", metav1.GetOptions{}) + cd, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) // set max iterations @@ -455,12 +456,12 @@ func TestScheduler_DeploymentABTesting(t *testing.T) { mocks.ctrl.advanceCanary("podinfo", "default") // check finalising status - c, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get("podinfo", metav1.GetOptions{}) + c, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) assert.Equal(t, flaggerv1.CanaryPhaseFinalising, c.Status.Phase) // check if the container image tag was updated - primaryDep, err := mocks.kubeClient.AppsV1().Deployments("default").Get("podinfo-primary", metav1.GetOptions{}) + primaryDep, err := mocks.kubeClient.AppsV1().Deployments("default").Get(context.TODO(), "podinfo-primary", metav1.GetOptions{}) require.NoError(t, err) primaryImage := primaryDep.Spec.Template.Spec.Containers[0].Image @@ -471,7 +472,7 @@ func TestScheduler_DeploymentABTesting(t *testing.T) { mocks.ctrl.advanceCanary("podinfo", "default") // check rollout status - c, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get("podinfo", metav1.GetOptions{}) + c, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) assert.Equal(t, flaggerv1.CanaryPhaseSucceeded, c.Status.Phase) } @@ -480,15 +481,15 @@ func TestScheduler_DeploymentPortDiscovery(t *testing.T) { mocks := newDeploymentFixture(nil) // enable port discovery - cd, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get("podinfo", metav1.GetOptions{}) + cd, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) cd.Spec.Service.PortDiscovery = true - _, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Update(cd) + _, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Update(context.TODO(), cd, metav1.UpdateOptions{}) require.NoError(t, err) mocks.ctrl.advanceCanary("podinfo", "default") - canarySvc, err := mocks.kubeClient.CoreV1().Services("default").Get("podinfo-canary", metav1.GetOptions{}) + canarySvc, err := mocks.kubeClient.CoreV1().Services("default").Get(context.TODO(), "podinfo-canary", metav1.GetOptions{}) require.NoError(t, err) require.Len(t, canarySvc.Spec.Ports, 3) @@ -511,17 +512,17 @@ func TestScheduler_DeploymentPortDiscovery(t *testing.T) { func TestScheduler_DeploymentTargetPortNumber(t *testing.T) { mocks := newDeploymentFixture(nil) - cd, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get("podinfo", metav1.GetOptions{}) + cd, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) cd.Spec.Service.Port = 80 cd.Spec.Service.TargetPort = intstr.FromInt(9898) cd.Spec.Service.PortDiscovery = true - _, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Update(cd) + _, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Update(context.TODO(), cd, metav1.UpdateOptions{}) require.NoError(t, err) mocks.ctrl.advanceCanary("podinfo", "default") - canarySvc, err := mocks.kubeClient.CoreV1().Services("default").Get("podinfo-canary", metav1.GetOptions{}) + canarySvc, err := mocks.kubeClient.CoreV1().Services("default").Get(context.TODO(), "podinfo-canary", metav1.GetOptions{}) require.NoError(t, err) require.Len(t, canarySvc.Spec.Ports, 3) @@ -544,17 +545,17 @@ func TestScheduler_DeploymentTargetPortNumber(t *testing.T) { func TestScheduler_DeploymentTargetPortName(t *testing.T) { mocks := newDeploymentFixture(nil) - cd, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get("podinfo", metav1.GetOptions{}) + cd, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) cd.Spec.Service.Port = 8080 cd.Spec.Service.TargetPort = intstr.FromString("http") cd.Spec.Service.PortDiscovery = true - _, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Update(cd) + _, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Update(context.TODO(), cd, metav1.UpdateOptions{}) require.NoError(t, err) mocks.ctrl.advanceCanary("podinfo", "default") - canarySvc, err := mocks.kubeClient.CoreV1().Services("default").Get("podinfo-canary", metav1.GetOptions{}) + canarySvc, err := mocks.kubeClient.CoreV1().Services("default").Get(context.TODO(), "podinfo-canary", metav1.GetOptions{}) require.NoError(t, err) require.Len(t, canarySvc.Spec.Ports, 3) @@ -609,7 +610,7 @@ func TestScheduler_DeploymentAlerts(t *testing.T) { secret.Data = map[string][]byte{ "address": []byte(ts.URL), } - _, err := mocks.kubeClient.CoreV1().Secrets("default").Update(secret) + _, err := mocks.kubeClient.CoreV1().Secrets("default").Update(context.TODO(), secret, metav1.UpdateOptions{}) require.NoError(t, err) // init canary and send alerts diff --git a/pkg/controller/scheduler_metrics.go b/pkg/controller/scheduler_metrics.go index 16731f09..0c370ce6 100644 --- a/pkg/controller/scheduler_metrics.go +++ b/pkg/controller/scheduler_metrics.go @@ -1,6 +1,7 @@ package controller import ( + "context" "errors" "strings" "time" @@ -169,7 +170,7 @@ func (c *Controller) runMetricChecks(canary *flaggerv1.Canary) bool { var credentials map[string][]byte if template.Spec.Provider.SecretRef != nil { - secret, err := c.kubeClient.CoreV1().Secrets(namespace).Get(template.Spec.Provider.SecretRef.Name, metav1.GetOptions{}) + secret, err := c.kubeClient.CoreV1().Secrets(namespace).Get(context.TODO(), template.Spec.Provider.SecretRef.Name, metav1.GetOptions{}) if err != nil { c.recordEventErrorf(canary, "Metric template %s.%s secret %s error: %v", metric.TemplateRef.Name, namespace, template.Spec.Provider.SecretRef.Name, err) diff --git a/pkg/controller/scheduler_svc_test.go b/pkg/controller/scheduler_svc_test.go index 15da4d2e..77b92ae5 100644 --- a/pkg/controller/scheduler_svc_test.go +++ b/pkg/controller/scheduler_svc_test.go @@ -1,6 +1,7 @@ package controller import ( + "context" "testing" "github.com/stretchr/testify/assert" @@ -17,13 +18,13 @@ func TestScheduler_ServicePromotion(t *testing.T) { mocks.ctrl.advanceCanary("podinfo", "default") // check initialized status - c, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get("podinfo", metav1.GetOptions{}) + c, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) assert.Equal(t, flaggerv1.CanaryPhaseInitialized, c.Status.Phase) // update svc2 := newDeploymentTestServiceV2() - _, err = mocks.kubeClient.CoreV1().Services("default").Update(svc2) + _, err = mocks.kubeClient.CoreV1().Services("default").Update(context.TODO(), svc2, metav1.UpdateOptions{}) require.NoError(t, err) // detect service spec changes @@ -41,7 +42,7 @@ func TestScheduler_ServicePromotion(t *testing.T) { mocks.ctrl.advanceCanary("podinfo", "default") // check progressing status - c, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get("podinfo", metav1.GetOptions{}) + c, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) assert.Equal(t, flaggerv1.CanaryPhaseProgressing, c.Status.Phase) @@ -49,7 +50,7 @@ func TestScheduler_ServicePromotion(t *testing.T) { mocks.ctrl.advanceCanary("podinfo", "default") // check promoting status - c, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get("podinfo", metav1.GetOptions{}) + c, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) assert.Equal(t, flaggerv1.CanaryPhasePromoting, c.Status.Phase) @@ -62,7 +63,7 @@ func TestScheduler_ServicePromotion(t *testing.T) { assert.Equal(t, 0, canaryWeight) assert.False(t, mirrored) - primarySvc, err := mocks.kubeClient.CoreV1().Services("default").Get("podinfo-primary", metav1.GetOptions{}) + primarySvc, err := mocks.kubeClient.CoreV1().Services("default").Get(context.TODO(), "podinfo-primary", metav1.GetOptions{}) require.NoError(t, err) primaryLabelValue := primarySvc.Spec.Selector["app"] @@ -70,14 +71,14 @@ func TestScheduler_ServicePromotion(t *testing.T) { assert.Equal(t, canaryLabelValue, primaryLabelValue) // check finalising status - c, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get("podinfo", metav1.GetOptions{}) + c, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) assert.Equal(t, flaggerv1.CanaryPhaseFinalising, c.Status.Phase) // scale canary to zero mocks.ctrl.advanceCanary("podinfo", "default") - c, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get("podinfo", metav1.GetOptions{}) + c, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) assert.Equal(t, flaggerv1.CanaryPhaseSucceeded, c.Status.Phase) } diff --git a/pkg/metrics/providers/prometheus_test.go b/pkg/metrics/providers/prometheus_test.go index 4aae8c9c..b5cae79a 100644 --- a/pkg/metrics/providers/prometheus_test.go +++ b/pkg/metrics/providers/prometheus_test.go @@ -1,6 +1,7 @@ package providers import ( + "context" "errors" "net/http" "net/http/httptest" @@ -69,10 +70,10 @@ func prometheusFake() fakeClients { func TestNewPrometheusProvider(t *testing.T) { clients := prometheusFake() - template, err := clients.flaggerClient.FlaggerV1beta1().MetricTemplates("default").Get("prometheus", metav1.GetOptions{}) + template, err := clients.flaggerClient.FlaggerV1beta1().MetricTemplates("default").Get(context.TODO(), "prometheus", metav1.GetOptions{}) require.NoError(t, err) - secret, err := clients.kubeClient.CoreV1().Secrets("default").Get("prometheus", metav1.GetOptions{}) + secret, err := clients.kubeClient.CoreV1().Secrets("default").Get(context.TODO(), "prometheus", metav1.GetOptions{}) require.NoError(t, err) prom, err := NewPrometheusProvider(template.Spec.Provider, secret.Data) @@ -104,11 +105,11 @@ func TestPrometheusProvider_RunQueryWithBasicAuth(t *testing.T) { clients := prometheusFake() - template, err := clients.flaggerClient.FlaggerV1beta1().MetricTemplates("default").Get("prometheus", metav1.GetOptions{}) + template, err := clients.flaggerClient.FlaggerV1beta1().MetricTemplates("default").Get(context.TODO(), "prometheus", metav1.GetOptions{}) require.NoError(t, err) template.Spec.Provider.Address = ts.URL - secret, err := clients.kubeClient.CoreV1().Secrets("default").Get("prometheus", metav1.GetOptions{}) + secret, err := clients.kubeClient.CoreV1().Secrets("default").Get(context.TODO(), "prometheus", metav1.GetOptions{}) require.NoError(t, err) prom, err := NewPrometheusProvider(template.Spec.Provider, secret.Data) @@ -130,11 +131,11 @@ func TestPrometheusProvider_RunQueryWithBasicAuth(t *testing.T) { clients := prometheusFake() template, err := clients.flaggerClient.FlaggerV1beta1(). - MetricTemplates("default").Get("prometheus", metav1.GetOptions{}) + MetricTemplates("default").Get(context.TODO(), "prometheus", metav1.GetOptions{}) require.NoError(t, err) template.Spec.Provider.Address = ts.URL - secret, err := clients.kubeClient.CoreV1().Secrets("default").Get("prometheus", metav1.GetOptions{}) + secret, err := clients.kubeClient.CoreV1().Secrets("default").Get(context.TODO(), "prometheus", metav1.GetOptions{}) require.NoError(t, err) prom, err := NewPrometheusProvider(template.Spec.Provider, secret.Data) @@ -153,7 +154,7 @@ func TestPrometheusProvider_IsOnline(t *testing.T) { clients := prometheusFake() - template, err := clients.flaggerClient.FlaggerV1beta1().MetricTemplates("default").Get("prometheus", metav1.GetOptions{}) + template, err := clients.flaggerClient.FlaggerV1beta1().MetricTemplates("default").Get(context.TODO(), "prometheus", metav1.GetOptions{}) require.NoError(t, err) template.Spec.Provider.Address = ts.URL template.Spec.Provider.SecretRef = nil diff --git a/pkg/router/appmesh.go b/pkg/router/appmesh.go index 9ec1e144..56690261 100644 --- a/pkg/router/appmesh.go +++ b/pkg/router/appmesh.go @@ -1,6 +1,7 @@ package router import ( + "context" "fmt" "strconv" "strings" @@ -110,7 +111,7 @@ func (ar *AppMeshRouter) reconcileVirtualNode(canary *flaggerv1.Canary, name str vnSpec.Backends = backends } - virtualnode, err := ar.appmeshClient.AppmeshV1beta1().VirtualNodes(canary.Namespace).Get(name, metav1.GetOptions{}) + virtualnode, err := ar.appmeshClient.AppmeshV1beta1().VirtualNodes(canary.Namespace).Get(context.TODO(), name, metav1.GetOptions{}) // create virtual node if errors.IsNotFound(err) { @@ -128,7 +129,7 @@ func (ar *AppMeshRouter) reconcileVirtualNode(canary *flaggerv1.Canary, name str }, Spec: vnSpec, } - _, err = ar.appmeshClient.AppmeshV1beta1().VirtualNodes(canary.Namespace).Create(virtualnode) + _, err = ar.appmeshClient.AppmeshV1beta1().VirtualNodes(canary.Namespace).Create(context.TODO(), virtualnode, metav1.CreateOptions{}) if err != nil { return fmt.Errorf("VirtualNode %s.%s create error %w", name, canary.Namespace, err) } @@ -144,7 +145,7 @@ func (ar *AppMeshRouter) reconcileVirtualNode(canary *flaggerv1.Canary, name str if diff := cmp.Diff(vnSpec, virtualnode.Spec); diff != "" { vnClone := virtualnode.DeepCopy() vnClone.Spec = vnSpec - _, err = ar.appmeshClient.AppmeshV1beta1().VirtualNodes(canary.Namespace).Update(vnClone) + _, err = ar.appmeshClient.AppmeshV1beta1().VirtualNodes(canary.Namespace).Update(context.TODO(), vnClone, metav1.UpdateOptions{}) if err != nil { return fmt.Errorf("VirtualNode %s update error %w", name, err) } @@ -263,7 +264,7 @@ func (ar *AppMeshRouter) reconcileVirtualService(canary *flaggerv1.Canary, name Routes: routes, } - virtualService, err := ar.appmeshClient.AppmeshV1beta1().VirtualServices(canary.Namespace).Get(name, metav1.GetOptions{}) + virtualService, err := ar.appmeshClient.AppmeshV1beta1().VirtualServices(canary.Namespace).Get(context.TODO(), name, metav1.GetOptions{}) // create virtual service if errors.IsNotFound(err) { @@ -290,7 +291,7 @@ func (ar *AppMeshRouter) reconcileVirtualService(canary *flaggerv1.Canary, name } } - _, err = ar.appmeshClient.AppmeshV1beta1().VirtualServices(canary.Namespace).Create(virtualService) + _, err = ar.appmeshClient.AppmeshV1beta1().VirtualServices(canary.Namespace).Create(context.TODO(), virtualService, metav1.CreateOptions{}) if err != nil { return fmt.Errorf("VirtualService %s create error %w", name, err) } @@ -316,7 +317,7 @@ func (ar *AppMeshRouter) reconcileVirtualService(canary *flaggerv1.Canary, name } } - _, err = ar.appmeshClient.AppmeshV1beta1().VirtualServices(canary.Namespace).Update(vsClone) + _, err = ar.appmeshClient.AppmeshV1beta1().VirtualServices(canary.Namespace).Update(context.TODO(), vsClone, metav1.UpdateOptions{}) if err != nil { return fmt.Errorf("VirtualService %s update error: %w", name, err) } @@ -337,7 +338,7 @@ func (ar *AppMeshRouter) GetRoutes(canary *flaggerv1.Canary) ( ) { apexName, _, _ := canary.GetServiceNames() vsName := fmt.Sprintf("%s.%s", apexName, canary.Namespace) - vs, err := ar.appmeshClient.AppmeshV1beta1().VirtualServices(canary.Namespace).Get(vsName, metav1.GetOptions{}) + vs, err := ar.appmeshClient.AppmeshV1beta1().VirtualServices(canary.Namespace).Get(context.TODO(), vsName, metav1.GetOptions{}) if err != nil { err = fmt.Errorf("VirtualService %s get query error: %w", vsName, err) return @@ -377,7 +378,7 @@ func (ar *AppMeshRouter) SetRoutes( ) error { apexName, _, _ := canary.GetServiceNames() vsName := fmt.Sprintf("%s.%s", apexName, canary.Namespace) - vs, err := ar.appmeshClient.AppmeshV1beta1().VirtualServices(canary.Namespace).Get(vsName, metav1.GetOptions{}) + vs, err := ar.appmeshClient.AppmeshV1beta1().VirtualServices(canary.Namespace).Get(context.TODO(), vsName, metav1.GetOptions{}) if err != nil { return fmt.Errorf("VirtualService %s get query error: %w", vsName, err) } @@ -396,7 +397,7 @@ func (ar *AppMeshRouter) SetRoutes( }, } - _, err = ar.appmeshClient.AppmeshV1beta1().VirtualServices(canary.Namespace).Update(vsClone) + _, err = ar.appmeshClient.AppmeshV1beta1().VirtualServices(canary.Namespace).Update(context.TODO(), vsClone, metav1.UpdateOptions{}) if err != nil { return fmt.Errorf("VirtualService %s update error: %w", vsName, err) } diff --git a/pkg/router/appmesh_test.go b/pkg/router/appmesh_test.go index 6b5fc3c1..80470749 100644 --- a/pkg/router/appmesh_test.go +++ b/pkg/router/appmesh_test.go @@ -1,6 +1,7 @@ package router import ( + "context" "fmt" "strconv" "strings" @@ -26,14 +27,14 @@ func TestAppmeshRouter_Reconcile(t *testing.T) { // check virtual service vsName := fmt.Sprintf("%s.%s", mocks.appmeshCanary.Spec.TargetRef.Name, mocks.appmeshCanary.Namespace) - vs, err := router.appmeshClient.AppmeshV1beta1().VirtualServices("default").Get(vsName, metav1.GetOptions{}) + vs, err := router.appmeshClient.AppmeshV1beta1().VirtualServices("default").Get(context.TODO(), vsName, metav1.GetOptions{}) require.NoError(t, err) assert.Equal(t, mocks.appmeshCanary.Spec.Service.MeshName, vs.Spec.MeshName) assert.Len(t, vs.Spec.Routes[0].Http.Action.WeightedTargets, 2) // check canary virtual service vsCanaryName := fmt.Sprintf("%s-canary.%s", mocks.appmeshCanary.Spec.TargetRef.Name, mocks.appmeshCanary.Namespace) - vsCanary, err := router.appmeshClient.AppmeshV1beta1().VirtualServices("default").Get(vsCanaryName, metav1.GetOptions{}) + vsCanary, err := router.appmeshClient.AppmeshV1beta1().VirtualServices("default").Get(context.TODO(), vsCanaryName, metav1.GetOptions{}) require.NoError(t, err) // check if the canary virtual service routes all traffic to the canary virtual node @@ -44,21 +45,21 @@ func TestAppmeshRouter_Reconcile(t *testing.T) { // check virtual node vnName := mocks.appmeshCanary.Spec.TargetRef.Name - vn, err := router.appmeshClient.AppmeshV1beta1().VirtualNodes("default").Get(vnName, metav1.GetOptions{}) + vn, err := router.appmeshClient.AppmeshV1beta1().VirtualNodes("default").Get(context.TODO(), vnName, metav1.GetOptions{}) require.NoError(t, err) primaryDNS := fmt.Sprintf("%s-primary.%s", mocks.appmeshCanary.Spec.TargetRef.Name, mocks.appmeshCanary.Namespace) assert.Equal(t, primaryDNS, vn.Spec.ServiceDiscovery.Dns.HostName) // test backends update - cd, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get("appmesh", metav1.GetOptions{}) + cd, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get(context.TODO(), "appmesh", metav1.GetOptions{}) require.NoError(t, err) cdClone := cd.DeepCopy() hosts := cdClone.Spec.Service.Backends hosts = append(hosts, "test.example.com") cdClone.Spec.Service.Backends = hosts - canary, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Update(cdClone) + canary, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Update(context.TODO(), cdClone, metav1.UpdateOptions{}) require.NoError(t, err) // apply change @@ -67,7 +68,7 @@ func TestAppmeshRouter_Reconcile(t *testing.T) { // verify vnCanaryName := fmt.Sprintf("%s-canary", mocks.appmeshCanary.Spec.TargetRef.Name) - vnCanary, err := router.appmeshClient.AppmeshV1beta1().VirtualNodes("default").Get(vnCanaryName, metav1.GetOptions{}) + vnCanary, err := router.appmeshClient.AppmeshV1beta1().VirtualNodes("default").Get(context.TODO(), vnCanaryName, metav1.GetOptions{}) require.NoError(t, err) require.Len(t, vnCanary.Spec.Backends, 2) @@ -75,27 +76,27 @@ func TestAppmeshRouter_Reconcile(t *testing.T) { vsClone := vs.DeepCopy() vsClone.Spec.Routes[0].Http.Action.WeightedTargets[0].Weight = 50 vsClone.Spec.Routes[0].Http.Action.WeightedTargets[1].Weight = 50 - vs, err = mocks.meshClient.AppmeshV1beta1().VirtualServices("default").Update(vsClone) + vs, err = mocks.meshClient.AppmeshV1beta1().VirtualServices("default").Update(context.TODO(), vsClone, metav1.UpdateOptions{}) require.NoError(t, err) // apply change err = router.Reconcile(canary) require.NoError(t, err) - vs, err = router.appmeshClient.AppmeshV1beta1().VirtualServices("default").Get(vsName, metav1.GetOptions{}) + vs, err = router.appmeshClient.AppmeshV1beta1().VirtualServices("default").Get(context.TODO(), vsName, metav1.GetOptions{}) require.NoError(t, err) assert.Equal(t, int64(50), vs.Spec.Routes[0].Http.Action.WeightedTargets[0].Weight) // test URI update vsClone = vs.DeepCopy() vsClone.Spec.Routes[0].Http.Match.Prefix = "api" - vs, err = mocks.meshClient.AppmeshV1beta1().VirtualServices("default").Update(vsClone) + vs, err = mocks.meshClient.AppmeshV1beta1().VirtualServices("default").Update(context.TODO(), vsClone, metav1.UpdateOptions{}) require.NoError(t, err) // apply change err = router.Reconcile(canary) require.NoError(t, err) - vs, err = router.appmeshClient.AppmeshV1beta1().VirtualServices("default").Get(vsName, metav1.GetOptions{}) + vs, err = router.appmeshClient.AppmeshV1beta1().VirtualServices("default").Get(context.TODO(), vsName, metav1.GetOptions{}) require.NoError(t, err) assert.Equal(t, "/", vs.Spec.Routes[0].Http.Match.Prefix) } @@ -136,7 +137,7 @@ func TestAppmeshRouter_ABTest(t *testing.T) { // check virtual service vsName := fmt.Sprintf("%s.%s", mocks.abtest.Spec.TargetRef.Name, mocks.abtest.Namespace) - vs, err := router.appmeshClient.AppmeshV1beta1().VirtualServices("default").Get(vsName, metav1.GetOptions{}) + vs, err := router.appmeshClient.AppmeshV1beta1().VirtualServices("default").Get(context.TODO(), vsName, metav1.GetOptions{}) require.NoError(t, err) // check virtual service @@ -162,7 +163,7 @@ func TestAppmeshRouter_Gateway(t *testing.T) { // check virtual service vsName := fmt.Sprintf("%s.%s", mocks.appmeshCanary.Spec.TargetRef.Name, mocks.appmeshCanary.Namespace) - vs, err := router.appmeshClient.AppmeshV1beta1().VirtualServices("default").Get(vsName, metav1.GetOptions{}) + vs, err := router.appmeshClient.AppmeshV1beta1().VirtualServices("default").Get(context.TODO(), vsName, metav1.GetOptions{}) require.NoError(t, err) assert.Equal(t, "true", vs.Annotations["gateway.appmesh.k8s.aws/expose"]) diff --git a/pkg/router/contour.go b/pkg/router/contour.go index 8540b1de..bf3079af 100644 --- a/pkg/router/contour.go +++ b/pkg/router/contour.go @@ -1,6 +1,7 @@ package router import ( + "context" "fmt" "github.com/google/go-cmp/cmp" @@ -129,7 +130,7 @@ func (cr *ContourRouter) Reconcile(canary *flaggerv1.Canary) error { } } - proxy, err := cr.contourClient.ProjectcontourV1().HTTPProxies(canary.Namespace).Get(apexName, metav1.GetOptions{}) + proxy, err := cr.contourClient.ProjectcontourV1().HTTPProxies(canary.Namespace).Get(context.TODO(), apexName, metav1.GetOptions{}) if errors.IsNotFound(err) { proxy = &contourv1.HTTPProxy{ ObjectMeta: metav1.ObjectMeta{ @@ -150,7 +151,7 @@ func (cr *ContourRouter) Reconcile(canary *flaggerv1.Canary) error { }, } - _, err = cr.contourClient.ProjectcontourV1().HTTPProxies(canary.Namespace).Create(proxy) + _, err = cr.contourClient.ProjectcontourV1().HTTPProxies(canary.Namespace).Create(context.TODO(), proxy, metav1.CreateOptions{}) if err != nil { return fmt.Errorf("HTTPProxy %s.%s create error: %w", apexName, canary.Namespace, err) } @@ -171,7 +172,7 @@ func (cr *ContourRouter) Reconcile(canary *flaggerv1.Canary) error { clone := proxy.DeepCopy() clone.Spec = newSpec - _, err = cr.contourClient.ProjectcontourV1().HTTPProxies(canary.Namespace).Update(clone) + _, err = cr.contourClient.ProjectcontourV1().HTTPProxies(canary.Namespace).Update(context.TODO(), clone, metav1.UpdateOptions{}) if err != nil { return fmt.Errorf("HTTPProxy %s.%s update error: %w", apexName, canary.Namespace, err) } @@ -192,7 +193,7 @@ func (cr *ContourRouter) GetRoutes(canary *flaggerv1.Canary) ( ) { apexName, primaryName, _ := canary.GetServiceNames() - proxy, err := cr.contourClient.ProjectcontourV1().HTTPProxies(canary.Namespace).Get(apexName, metav1.GetOptions{}) + proxy, err := cr.contourClient.ProjectcontourV1().HTTPProxies(canary.Namespace).Get(context.TODO(), apexName, metav1.GetOptions{}) if err != nil { err = fmt.Errorf("HTTPProxy %s.%s get query error %w", apexName, canary.Namespace, err) return @@ -227,7 +228,7 @@ func (cr *ContourRouter) SetRoutes( return fmt.Errorf("HTTPProxy %s.%s update failed: no valid weights", apexName, canary.Namespace) } - proxy, err := cr.contourClient.ProjectcontourV1().HTTPProxies(canary.Namespace).Get(apexName, metav1.GetOptions{}) + proxy, err := cr.contourClient.ProjectcontourV1().HTTPProxies(canary.Namespace).Get(context.TODO(), apexName, metav1.GetOptions{}) if err != nil { return fmt.Errorf("HTTPProxy %s.%s query error: %w", apexName, canary.Namespace, err) } @@ -332,7 +333,7 @@ func (cr *ContourRouter) SetRoutes( } } - _, err = cr.contourClient.ProjectcontourV1().HTTPProxies(canary.Namespace).Update(proxy) + _, err = cr.contourClient.ProjectcontourV1().HTTPProxies(canary.Namespace).Update(context.TODO(), proxy, metav1.UpdateOptions{}) if err != nil { return fmt.Errorf("HTTPProxy %s.%s update error: %w", apexName, canary.Namespace, err) } diff --git a/pkg/router/contour_test.go b/pkg/router/contour_test.go index 2c0c6c6b..e54e70b7 100644 --- a/pkg/router/contour_test.go +++ b/pkg/router/contour_test.go @@ -1,6 +1,7 @@ package router import ( + "context" "testing" "github.com/stretchr/testify/assert" @@ -23,7 +24,7 @@ func TestContourRouter_Reconcile(t *testing.T) { require.NoError(t, err) // test insert - proxy, err := router.contourClient.ProjectcontourV1().HTTPProxies("default").Get("podinfo", metav1.GetOptions{}) + proxy, err := router.contourClient.ProjectcontourV1().HTTPProxies("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) services := proxy.Spec.Routes[0].Services @@ -32,20 +33,20 @@ func TestContourRouter_Reconcile(t *testing.T) { assert.Equal(t, uint32(0), services[1].Weight) // test update - cd, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get("podinfo", metav1.GetOptions{}) + cd, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) cdClone := cd.DeepCopy() cdClone.Spec.Service.Port = 8080 cdClone.Spec.Service.Timeout = "1m" - canary, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Update(cdClone) + canary, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Update(context.TODO(), cdClone, metav1.UpdateOptions{}) require.NoError(t, err) // apply change err = router.Reconcile(canary) require.NoError(t, err) - proxy, err = router.contourClient.ProjectcontourV1().HTTPProxies("default").Get("podinfo", metav1.GetOptions{}) + proxy, err = router.contourClient.ProjectcontourV1().HTTPProxies("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) assert.Equal(t, 8080, proxy.Spec.Routes[0].Services[0].Port) assert.Equal(t, "1m", proxy.Spec.Routes[0].TimeoutPolicy.Response) @@ -53,20 +54,20 @@ func TestContourRouter_Reconcile(t *testing.T) { assert.Equal(t, uint32(10), proxy.Spec.Routes[0].RetryPolicy.NumRetries) // test headers update - cd, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get("podinfo", metav1.GetOptions{}) + cd, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) cdClone = cd.DeepCopy() cdClone.Spec.Analysis.Iterations = 5 cdClone.Spec.Analysis.Match = newTestABTest().Spec.Analysis.Match - canary, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Update(cdClone) + canary, err = mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Update(context.TODO(), cdClone, metav1.UpdateOptions{}) require.NoError(t, err) // apply change err = router.Reconcile(canary) require.NoError(t, err) - proxy, err = router.contourClient.ProjectcontourV1().HTTPProxies("default").Get("podinfo", metav1.GetOptions{}) + proxy, err = router.contourClient.ProjectcontourV1().HTTPProxies("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) assert.Equal(t, "test", proxy.Spec.Routes[0].Conditions[0].Header.Exact) } @@ -88,13 +89,13 @@ func TestContourRouter_Routes(t *testing.T) { err = router.SetRoutes(mocks.canary, 50, 50, false) require.NoError(t, err) - proxy, err := router.contourClient.ProjectcontourV1().HTTPProxies("default").Get("podinfo", metav1.GetOptions{}) + proxy, err := router.contourClient.ProjectcontourV1().HTTPProxies("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) primary := proxy.Spec.Routes[0].Services[0] assert.Equal(t, uint32(50), primary.Weight) - cd, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get("podinfo", metav1.GetOptions{}) + cd, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) // test get routers @@ -106,13 +107,13 @@ func TestContourRouter_Routes(t *testing.T) { cdClone := cd.DeepCopy() cdClone.Spec.Analysis.Iterations = 5 cdClone.Spec.Analysis.Match = newTestABTest().Spec.Analysis.Match - canary, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Update(cdClone) + canary, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Update(context.TODO(), cdClone, metav1.UpdateOptions{}) require.NoError(t, err) err = router.Reconcile(canary) require.NoError(t, err) - proxy, err = router.contourClient.ProjectcontourV1().HTTPProxies("default").Get("podinfo", metav1.GetOptions{}) + proxy, err = router.contourClient.ProjectcontourV1().HTTPProxies("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) primary = proxy.Spec.Routes[0].Services[0] @@ -125,7 +126,7 @@ func TestContourRouter_Routes(t *testing.T) { err = router.SetRoutes(canary, 0, 100, false) require.NoError(t, err) - proxy, err = router.contourClient.ProjectcontourV1().HTTPProxies("default").Get("podinfo", metav1.GetOptions{}) + proxy, err = router.contourClient.ProjectcontourV1().HTTPProxies("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) primary = proxy.Spec.Routes[0].Services[0] diff --git a/pkg/router/gloo.go b/pkg/router/gloo.go index 2f224a5d..5d0aa53d 100644 --- a/pkg/router/gloo.go +++ b/pkg/router/gloo.go @@ -1,6 +1,7 @@ package router import ( + "context" "fmt" "github.com/google/go-cmp/cmp" @@ -54,7 +55,7 @@ func (gr *GlooRouter) Reconcile(canary *flaggerv1.Canary) error { }, } - upstreamGroup, err := gr.glooClient.GlooV1().UpstreamGroups(canary.Namespace).Get(apexName, metav1.GetOptions{}) + upstreamGroup, err := gr.glooClient.GlooV1().UpstreamGroups(canary.Namespace).Get(context.TODO(), apexName, metav1.GetOptions{}) if errors.IsNotFound(err) { upstreamGroup = &gloov1.UpstreamGroup{ ObjectMeta: metav1.ObjectMeta{ @@ -71,7 +72,7 @@ func (gr *GlooRouter) Reconcile(canary *flaggerv1.Canary) error { Spec: newSpec, } - _, err = gr.glooClient.GlooV1().UpstreamGroups(canary.Namespace).Create(upstreamGroup) + _, err = gr.glooClient.GlooV1().UpstreamGroups(canary.Namespace).Create(context.TODO(), upstreamGroup, metav1.CreateOptions{}) if err != nil { return fmt.Errorf("UpstreamGroup %s.%s create error: %w", apexName, canary.Namespace, err) } @@ -92,7 +93,7 @@ func (gr *GlooRouter) Reconcile(canary *flaggerv1.Canary) error { clone := upstreamGroup.DeepCopy() clone.Spec = newSpec - _, err = gr.glooClient.GlooV1().UpstreamGroups(canary.Namespace).Update(clone) + _, err = gr.glooClient.GlooV1().UpstreamGroups(canary.Namespace).Update(context.TODO(), clone, metav1.UpdateOptions{}) if err != nil { return fmt.Errorf("UpstreamGroup %s.%s update error: %w", apexName, canary.Namespace, err) } @@ -114,7 +115,7 @@ func (gr *GlooRouter) GetRoutes(canary *flaggerv1.Canary) ( apexName := canary.Spec.TargetRef.Name primaryName := fmt.Sprintf("%s-%s-primary-%v", canary.Namespace, canary.Spec.TargetRef.Name, canary.Spec.Service.Port) - upstreamGroup, err := gr.glooClient.GlooV1().UpstreamGroups(canary.Namespace).Get(apexName, metav1.GetOptions{}) + upstreamGroup, err := gr.glooClient.GlooV1().UpstreamGroups(canary.Namespace).Get(context.TODO(), apexName, metav1.GetOptions{}) if err != nil { err = fmt.Errorf("UpstreamGroup %s.%s get query error: %w", apexName, canary.Namespace, err) return @@ -151,7 +152,7 @@ func (gr *GlooRouter) SetRoutes( return fmt.Errorf("RoutingRule %s.%s update failed: no valid weights", apexName, canary.Namespace) } - upstreamGroup, err := gr.glooClient.GlooV1().UpstreamGroups(canary.Namespace).Get(apexName, metav1.GetOptions{}) + upstreamGroup, err := gr.glooClient.GlooV1().UpstreamGroups(canary.Namespace).Get(context.TODO(), apexName, metav1.GetOptions{}) if err != nil { return fmt.Errorf("UpstreamGroup %s.%s query error: %w", apexName, canary.Namespace, err) } @@ -179,7 +180,7 @@ func (gr *GlooRouter) SetRoutes( }, } - _, err = gr.glooClient.GlooV1().UpstreamGroups(canary.Namespace).Update(upstreamGroup) + _, err = gr.glooClient.GlooV1().UpstreamGroups(canary.Namespace).Update(context.TODO(), upstreamGroup, metav1.UpdateOptions{}) if err != nil { return fmt.Errorf("UpstreamGroup %s.%s update error: %w", apexName, canary.Namespace, err) } diff --git a/pkg/router/gloo_test.go b/pkg/router/gloo_test.go index beeece26..150d0924 100644 --- a/pkg/router/gloo_test.go +++ b/pkg/router/gloo_test.go @@ -1,6 +1,7 @@ package router import ( + "context" "fmt" "testing" @@ -24,7 +25,7 @@ func TestGlooRouter_Sync(t *testing.T) { require.NoError(t, err) // test insert - ug, err := router.glooClient.GlooV1().UpstreamGroups("default").Get("podinfo", metav1.GetOptions{}) + ug, err := router.glooClient.GlooV1().UpstreamGroups("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) dests := ug.Spec.Destinations assert.Len(t, dests, 2) @@ -54,7 +55,7 @@ func TestGlooRouter_SetRoutes(t *testing.T) { err = router.SetRoutes(mocks.canary, p, c, m) require.NoError(t, err) - ug, err := router.glooClient.GlooV1().UpstreamGroups("default").Get("podinfo", metav1.GetOptions{}) + ug, err := router.glooClient.GlooV1().UpstreamGroups("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) var pRoute gloov1.WeightedDestination diff --git a/pkg/router/ingress.go b/pkg/router/ingress.go index 928fce7a..1eeeecb5 100644 --- a/pkg/router/ingress.go +++ b/pkg/router/ingress.go @@ -1,6 +1,7 @@ package router import ( + "context" "fmt" "strconv" "strings" @@ -31,7 +32,7 @@ func (i *IngressRouter) Reconcile(canary *flaggerv1.Canary) error { canaryName := fmt.Sprintf("%s-canary", apexName) canaryIngressName := fmt.Sprintf("%s-canary", canary.Spec.IngressRef.Name) - ingress, err := i.kubeClient.NetworkingV1beta1().Ingresses(canary.Namespace).Get(canary.Spec.IngressRef.Name, metav1.GetOptions{}) + ingress, err := i.kubeClient.NetworkingV1beta1().Ingresses(canary.Namespace).Get(context.TODO(), canary.Spec.IngressRef.Name, metav1.GetOptions{}) if err != nil { return fmt.Errorf("ingress %s.%s get query error: %w", canary.Spec.IngressRef.Name, canary.Namespace, err) } @@ -54,7 +55,7 @@ func (i *IngressRouter) Reconcile(canary *flaggerv1.Canary) error { return fmt.Errorf("backend %s not found in ingress %s", apexName, canary.Spec.IngressRef.Name) } - canaryIngress, err := i.kubeClient.NetworkingV1beta1().Ingresses(canary.Namespace).Get(canaryIngressName, metav1.GetOptions{}) + canaryIngress, err := i.kubeClient.NetworkingV1beta1().Ingresses(canary.Namespace).Get(context.TODO(), canaryIngressName, metav1.GetOptions{}) if errors.IsNotFound(err) { ing := &v1beta1.Ingress{ @@ -74,7 +75,7 @@ func (i *IngressRouter) Reconcile(canary *flaggerv1.Canary) error { Spec: ingressClone.Spec, } - _, err := i.kubeClient.NetworkingV1beta1().Ingresses(canary.Namespace).Create(ing) + _, err := i.kubeClient.NetworkingV1beta1().Ingresses(canary.Namespace).Create(context.TODO(), ing, metav1.CreateOptions{}) if err != nil { return fmt.Errorf("ingress %s.%s create error: %w", ing.Name, ing.Namespace, err) } @@ -90,7 +91,7 @@ func (i *IngressRouter) Reconcile(canary *flaggerv1.Canary) error { iClone := canaryIngress.DeepCopy() iClone.Spec = ingressClone.Spec - _, err := i.kubeClient.NetworkingV1beta1().Ingresses(canary.Namespace).Update(iClone) + _, err := i.kubeClient.NetworkingV1beta1().Ingresses(canary.Namespace).Update(context.TODO(), iClone, metav1.UpdateOptions{}) if err != nil { return fmt.Errorf("ingress %s.%s update error: %w", canaryIngressName, iClone.Namespace, err) } @@ -109,7 +110,7 @@ func (i *IngressRouter) GetRoutes(canary *flaggerv1.Canary) ( err error, ) { canaryIngressName := fmt.Sprintf("%s-canary", canary.Spec.IngressRef.Name) - canaryIngress, err := i.kubeClient.NetworkingV1beta1().Ingresses(canary.Namespace).Get(canaryIngressName, metav1.GetOptions{}) + canaryIngress, err := i.kubeClient.NetworkingV1beta1().Ingresses(canary.Namespace).Get(context.TODO(), canaryIngressName, metav1.GetOptions{}) if err != nil { err = fmt.Errorf("ingress %s.%s get query error: %w", canaryIngressName, canary.Namespace, err) return @@ -150,7 +151,7 @@ func (i *IngressRouter) SetRoutes( _ bool, ) error { canaryIngressName := fmt.Sprintf("%s-canary", canary.Spec.IngressRef.Name) - canaryIngress, err := i.kubeClient.NetworkingV1beta1().Ingresses(canary.Namespace).Get(canaryIngressName, metav1.GetOptions{}) + canaryIngress, err := i.kubeClient.NetworkingV1beta1().Ingresses(canary.Namespace).Get(context.TODO(), canaryIngressName, metav1.GetOptions{}) if err != nil { return fmt.Errorf("ingress %s.%s get query error: %w", canaryIngressName, canary.Namespace, err) } @@ -185,7 +186,7 @@ func (i *IngressRouter) SetRoutes( iClone.Annotations = i.makeAnnotations(iClone.Annotations) } - _, err = i.kubeClient.NetworkingV1beta1().Ingresses(canary.Namespace).Update(iClone) + _, err = i.kubeClient.NetworkingV1beta1().Ingresses(canary.Namespace).Update(context.TODO(), iClone, metav1.UpdateOptions{}) if err != nil { return fmt.Errorf("ingress %s.%s update error %v", iClone.Name, iClone.Namespace, err) } diff --git a/pkg/router/ingress_test.go b/pkg/router/ingress_test.go index b1fe5f38..9c2253c8 100644 --- a/pkg/router/ingress_test.go +++ b/pkg/router/ingress_test.go @@ -1,6 +1,7 @@ package router import ( + "context" "fmt" "testing" @@ -27,7 +28,7 @@ func TestIngressRouter_Reconcile(t *testing.T) { canaryAn := "custom.ingress.kubernetes.io/canary" canaryName := fmt.Sprintf("%s-canary", mocks.ingressCanary.Spec.IngressRef.Name) - inCanary, err := router.kubeClient.NetworkingV1beta1().Ingresses("default").Get(canaryName, metav1.GetOptions{}) + inCanary, err := router.kubeClient.NetworkingV1beta1().Ingresses("default").Get(context.TODO(), canaryName, metav1.GetOptions{}) require.NoError(t, err) // test initialisation @@ -59,7 +60,7 @@ func TestIngressRouter_GetSetRoutes(t *testing.T) { canaryWeightAn := "prefix1.nginx.ingress.kubernetes.io/canary-weight" canaryName := fmt.Sprintf("%s-canary", mocks.ingressCanary.Spec.IngressRef.Name) - inCanary, err := router.kubeClient.NetworkingV1beta1().Ingresses("default").Get(canaryName, metav1.GetOptions{}) + inCanary, err := router.kubeClient.NetworkingV1beta1().Ingresses("default").Get(context.TODO(), canaryName, metav1.GetOptions{}) require.NoError(t, err) // test rollout @@ -73,7 +74,7 @@ func TestIngressRouter_GetSetRoutes(t *testing.T) { err = router.SetRoutes(mocks.ingressCanary, p, c, m) require.NoError(t, err) - inCanary, err = router.kubeClient.NetworkingV1beta1().Ingresses("default").Get(canaryName, metav1.GetOptions{}) + inCanary, err = router.kubeClient.NetworkingV1beta1().Ingresses("default").Get(context.TODO(), canaryName, metav1.GetOptions{}) require.NoError(t, err) // test promotion @@ -155,7 +156,7 @@ func TestIngressRouter_ABTest(t *testing.T) { canaryAn := router.GetAnnotationWithPrefix("canary") canaryName := fmt.Sprintf("%s-canary", table.makeCanary().Spec.IngressRef.Name) - inCanary, err := router.kubeClient.NetworkingV1beta1().Ingresses("default").Get(canaryName, metav1.GetOptions{}) + inCanary, err := router.kubeClient.NetworkingV1beta1().Ingresses("default").Get(context.TODO(), canaryName, metav1.GetOptions{}) require.NoError(t, err) // test initialisation diff --git a/pkg/router/istio.go b/pkg/router/istio.go index 8ac3cf66..bb15c4b6 100644 --- a/pkg/router/istio.go +++ b/pkg/router/istio.go @@ -1,6 +1,7 @@ package router import ( + "context" "encoding/json" "fmt" @@ -49,7 +50,7 @@ func (ir *IstioRouter) reconcileDestinationRule(canary *flaggerv1.Canary, name s TrafficPolicy: canary.Spec.Service.TrafficPolicy, } - destinationRule, err := ir.istioClient.NetworkingV1alpha3().DestinationRules(canary.Namespace).Get(name, metav1.GetOptions{}) + destinationRule, err := ir.istioClient.NetworkingV1alpha3().DestinationRules(canary.Namespace).Get(context.TODO(), name, metav1.GetOptions{}) // insert if errors.IsNotFound(err) { destinationRule = &istiov1alpha3.DestinationRule{ @@ -66,7 +67,7 @@ func (ir *IstioRouter) reconcileDestinationRule(canary *flaggerv1.Canary, name s }, Spec: newSpec, } - _, err = ir.istioClient.NetworkingV1alpha3().DestinationRules(canary.Namespace).Create(destinationRule) + _, err = ir.istioClient.NetworkingV1alpha3().DestinationRules(canary.Namespace).Create(context.TODO(), destinationRule, metav1.CreateOptions{}) if err != nil { return fmt.Errorf("DestinationRule %s.%s create error: %w", name, canary.Namespace, err) } @@ -82,7 +83,7 @@ func (ir *IstioRouter) reconcileDestinationRule(canary *flaggerv1.Canary, name s if diff := cmp.Diff(newSpec, destinationRule.Spec); diff != "" { clone := destinationRule.DeepCopy() clone.Spec = newSpec - _, err = ir.istioClient.NetworkingV1alpha3().DestinationRules(canary.Namespace).Update(clone) + _, err = ir.istioClient.NetworkingV1alpha3().DestinationRules(canary.Namespace).Update(context.TODO(), clone, metav1.UpdateOptions{}) if err != nil { return fmt.Errorf("DestinationRule %s.%s update error: %w", name, canary.Namespace, err) } @@ -173,7 +174,7 @@ func (ir *IstioRouter) reconcileVirtualService(canary *flaggerv1.Canary) error { } } - virtualService, err := ir.istioClient.NetworkingV1alpha3().VirtualServices(canary.Namespace).Get(apexName, metav1.GetOptions{}) + virtualService, err := ir.istioClient.NetworkingV1alpha3().VirtualServices(canary.Namespace).Get(context.TODO(), apexName, metav1.GetOptions{}) // insert if errors.IsNotFound(err) { virtualService = &istiov1alpha3.VirtualService{ @@ -190,7 +191,7 @@ func (ir *IstioRouter) reconcileVirtualService(canary *flaggerv1.Canary) error { }, Spec: newSpec, } - _, err = ir.istioClient.NetworkingV1alpha3().VirtualServices(canary.Namespace).Create(virtualService) + _, err = ir.istioClient.NetworkingV1alpha3().VirtualServices(canary.Namespace).Create(context.TODO(), virtualService, metav1.CreateOptions{}) if err != nil { return fmt.Errorf("VirtualService %s.%s create error: %w", apexName, canary.Namespace, err) } @@ -228,7 +229,7 @@ func (ir *IstioRouter) reconcileVirtualService(canary *flaggerv1.Canary) error { vtClone.ObjectMeta.Annotations[configAnnotation] = string(b) } - _, err = ir.istioClient.NetworkingV1alpha3().VirtualServices(canary.Namespace).Update(vtClone) + _, err = ir.istioClient.NetworkingV1alpha3().VirtualServices(canary.Namespace).Update(context.TODO(), vtClone, metav1.UpdateOptions{}) if err != nil { return fmt.Errorf("VirtualService %s.%s update error: %w", apexName, canary.Namespace, err) } @@ -249,7 +250,7 @@ func (ir *IstioRouter) GetRoutes(canary *flaggerv1.Canary) ( ) { apexName, primaryName, canaryName := canary.GetServiceNames() vs := &istiov1alpha3.VirtualService{} - vs, err = ir.istioClient.NetworkingV1alpha3().VirtualServices(canary.Namespace).Get(apexName, metav1.GetOptions{}) + vs, err = ir.istioClient.NetworkingV1alpha3().VirtualServices(canary.Namespace).Get(context.TODO(), apexName, metav1.GetOptions{}) if err != nil { err = fmt.Errorf("VirtualService %s.%s get query error %v", apexName, canary.Namespace, err) return @@ -294,7 +295,7 @@ func (ir *IstioRouter) SetRoutes( ) error { apexName, primaryName, canaryName := canary.GetServiceNames() - vs, err := ir.istioClient.NetworkingV1alpha3().VirtualServices(canary.Namespace).Get(apexName, metav1.GetOptions{}) + vs, err := ir.istioClient.NetworkingV1alpha3().VirtualServices(canary.Namespace).Get(context.TODO(), apexName, metav1.GetOptions{}) if err != nil { return fmt.Errorf("VirtualService %s.%s get query error %v", apexName, canary.Namespace, err) } @@ -358,7 +359,7 @@ func (ir *IstioRouter) SetRoutes( } } - vs, err = ir.istioClient.NetworkingV1alpha3().VirtualServices(canary.Namespace).Update(vsCopy) + vs, err = ir.istioClient.NetworkingV1alpha3().VirtualServices(canary.Namespace).Update(context.TODO(), vsCopy, metav1.UpdateOptions{}) if err != nil { return fmt.Errorf("VirtualService %s.%s update failed: %w", apexName, canary.Namespace, err) } @@ -369,7 +370,7 @@ func (ir *IstioRouter) Finalize(canary *flaggerv1.Canary) error { // Need to see if I can get the annotation orig-configuration apexName, _, _ := canary.GetServiceNames() - vs, err := ir.istioClient.NetworkingV1alpha3().VirtualServices(canary.Namespace).Get(apexName, metav1.GetOptions{}) + vs, err := ir.istioClient.NetworkingV1alpha3().VirtualServices(canary.Namespace).Get(context.TODO(), apexName, metav1.GetOptions{}) if err != nil { return fmt.Errorf("VirtualService %s.%s get query error: %w", apexName, canary.Namespace, err) } @@ -395,7 +396,7 @@ func (ir *IstioRouter) Finalize(canary *flaggerv1.Canary) error { clone := vs.DeepCopy() clone.Spec = storedSpec - _, err = ir.istioClient.NetworkingV1alpha3().VirtualServices(canary.Namespace).Update(clone) + _, err = ir.istioClient.NetworkingV1alpha3().VirtualServices(canary.Namespace).Update(context.TODO(), clone, metav1.UpdateOptions{}) if err != nil { return fmt.Errorf("VirtualService %s.%s update error: %w", apexName, canary.Namespace, err) } diff --git a/pkg/router/istio_test.go b/pkg/router/istio_test.go index cfe55785..b3457ad1 100644 --- a/pkg/router/istio_test.go +++ b/pkg/router/istio_test.go @@ -1,6 +1,7 @@ package router import ( + "context" "encoding/json" "fmt" "testing" @@ -26,26 +27,26 @@ func TestIstioRouter_Sync(t *testing.T) { require.NoError(t, err) // test insert - _, err = mocks.meshClient.NetworkingV1alpha3().DestinationRules("default").Get("podinfo-canary", metav1.GetOptions{}) + _, err = mocks.meshClient.NetworkingV1alpha3().DestinationRules("default").Get(context.TODO(), "podinfo-canary", metav1.GetOptions{}) require.NoError(t, err) - _, err = mocks.meshClient.NetworkingV1alpha3().DestinationRules("default").Get("podinfo-primary", metav1.GetOptions{}) + _, err = mocks.meshClient.NetworkingV1alpha3().DestinationRules("default").Get(context.TODO(), "podinfo-primary", metav1.GetOptions{}) require.NoError(t, err) - vs, err := mocks.meshClient.NetworkingV1alpha3().VirtualServices("default").Get("podinfo", metav1.GetOptions{}) + vs, err := mocks.meshClient.NetworkingV1alpha3().VirtualServices("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) require.Len(t, vs.Spec.Http, 1) require.Len(t, vs.Spec.Http[0].Route, 2) // test update - cd, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get("podinfo", metav1.GetOptions{}) + cd, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) cdClone := cd.DeepCopy() hosts := cdClone.Spec.Service.Hosts hosts = append(hosts, "test.example.com") cdClone.Spec.Service.Hosts = hosts - canary, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Update(cdClone) + canary, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Update(context.TODO(), cdClone, metav1.UpdateOptions{}) require.NoError(t, err) // apply change @@ -53,7 +54,7 @@ func TestIstioRouter_Sync(t *testing.T) { require.NoError(t, err) // verify - vs, err = mocks.meshClient.NetworkingV1alpha3().VirtualServices("default").Get("podinfo", metav1.GetOptions{}) + vs, err = mocks.meshClient.NetworkingV1alpha3().VirtualServices("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) assert.Len(t, vs.Spec.Hosts, 2) @@ -64,7 +65,7 @@ func TestIstioRouter_Sync(t *testing.T) { vsClone.Spec.Gateways = gateways totalGateways := len(mocks.canary.Spec.Service.Gateways) - vsGateways, err := mocks.meshClient.NetworkingV1alpha3().VirtualServices("default").Update(vsClone) + vsGateways, err := mocks.meshClient.NetworkingV1alpha3().VirtualServices("default").Update(context.TODO(), vsClone, metav1.UpdateOptions{}) require.NoError(t, err) totalGateways++ @@ -76,7 +77,7 @@ func TestIstioRouter_Sync(t *testing.T) { require.NoError(t, err) // verify - vs, err = mocks.meshClient.NetworkingV1alpha3().VirtualServices("default").Get("podinfo", metav1.GetOptions{}) + vs, err = mocks.meshClient.NetworkingV1alpha3().VirtualServices("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) assert.Len(t, vs.Spec.Gateways, totalGateways) } @@ -101,7 +102,7 @@ func TestIstioRouter_SetRoutes(t *testing.T) { err := router.SetRoutes(mocks.canary, p, c, false) require.NoError(t, err) - vs, err := mocks.meshClient.NetworkingV1alpha3().VirtualServices("default").Get("podinfo", metav1.GetOptions{}) + vs, err := mocks.meshClient.NetworkingV1alpha3().VirtualServices("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) var pRoute, cRoute istiov1alpha3.DestinationWeight @@ -133,7 +134,7 @@ func TestIstioRouter_SetRoutes(t *testing.T) { err := router.SetRoutes(mocks.canary, p, c, true) require.NoError(t, err) - vs, err := mocks.meshClient.NetworkingV1alpha3().VirtualServices("default").Get("podinfo", metav1.GetOptions{}) + vs, err := mocks.meshClient.NetworkingV1alpha3().VirtualServices("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) var pRoute, cRoute istiov1alpha3.DestinationWeight @@ -200,7 +201,7 @@ func TestIstioRouter_GetRoutes(t *testing.T) { assert.False(t, m) // Adjust vs to activate mirroring. - vs, err := mocks.meshClient.NetworkingV1alpha3().VirtualServices("default").Get("podinfo", metav1.GetOptions{}) + vs, err := mocks.meshClient.NetworkingV1alpha3().VirtualServices("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) cHost := fmt.Sprintf("%s-canary", mocks.canary.Spec.TargetRef.Name) @@ -213,7 +214,7 @@ func TestIstioRouter_GetRoutes(t *testing.T) { } } } - _, err = mocks.meshClient.NetworkingV1alpha3().VirtualServices(mocks.canary.Namespace).Update(vs) + _, err = mocks.meshClient.NetworkingV1alpha3().VirtualServices(mocks.canary.Namespace).Update(context.TODO(), vs, metav1.UpdateOptions{}) require.NoError(t, err) p, c, m, err = router.GetRoutes(mocks.canary) @@ -235,7 +236,7 @@ func TestIstioRouter_HTTPRequestHeaders(t *testing.T) { err := router.Reconcile(mocks.canary) require.NoError(t, err) - vs, err := mocks.meshClient.NetworkingV1alpha3().VirtualServices("default").Get("podinfo", metav1.GetOptions{}) + vs, err := mocks.meshClient.NetworkingV1alpha3().VirtualServices("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) require.Len(t, vs.Spec.Http, 1) assert.Equal(t, "15000", vs.Spec.Http[0].Headers.Request.Add["x-envoy-upstream-rq-timeout-ms"]) @@ -255,7 +256,7 @@ func TestIstioRouter_CORS(t *testing.T) { err := router.Reconcile(mocks.canary) require.NoError(t, err) - vs, err := mocks.meshClient.NetworkingV1alpha3().VirtualServices("default").Get("podinfo", metav1.GetOptions{}) + vs, err := mocks.meshClient.NetworkingV1alpha3().VirtualServices("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) require.NoError(t, err) require.Len(t, vs.Spec.Http, 1) @@ -276,7 +277,7 @@ func TestIstioRouter_ABTest(t *testing.T) { require.NoError(t, err) // test insert - vs, err := mocks.meshClient.NetworkingV1alpha3().VirtualServices("default").Get("abtest", metav1.GetOptions{}) + vs, err := mocks.meshClient.NetworkingV1alpha3().VirtualServices("default").Get(context.TODO(), "abtest", metav1.GetOptions{}) require.NoError(t, err) assert.Len(t, vs.Spec.Http, 2) @@ -287,7 +288,7 @@ func TestIstioRouter_ABTest(t *testing.T) { err = router.SetRoutes(mocks.abtest, p, c, m) require.NoError(t, err) - vs, err = mocks.meshClient.NetworkingV1alpha3().VirtualServices("default").Get("abtest", metav1.GetOptions{}) + vs, err = mocks.meshClient.NetworkingV1alpha3().VirtualServices("default").Get(context.TODO(), "abtest", metav1.GetOptions{}) require.NoError(t, err) pHost := fmt.Sprintf("%s-primary", mocks.abtest.Spec.TargetRef.Name) @@ -325,7 +326,7 @@ func TestIstioRouter_GatewayPort(t *testing.T) { err := router.Reconcile(mocks.canary) require.NoError(t, err) - vs, err := mocks.meshClient.NetworkingV1alpha3().VirtualServices("default").Get("podinfo", metav1.GetOptions{}) + vs, err := mocks.meshClient.NetworkingV1alpha3().VirtualServices("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) port := vs.Spec.Http[0].Route[0].Destination.Port.Number @@ -390,7 +391,7 @@ func TestIstioRouter_Finalize(t *testing.T) { for _, table := range tables { var err error if table.createVS { - vs, err := router.istioClient.NetworkingV1alpha3().VirtualServices(table.canary.Namespace).Get(table.canary.Name, metav1.GetOptions{}) + vs, err := router.istioClient.NetworkingV1alpha3().VirtualServices(table.canary.Namespace).Get(context.TODO(), table.canary.Name, metav1.GetOptions{}) require.NoError(t, err) if vs.Annotations == nil { @@ -405,7 +406,7 @@ func TestIstioRouter_Finalize(t *testing.T) { case "kubectl": vs.Annotations[kubectlAnnotation] = `{"apiVersion": "networking.istio.io/v1alpha3","kind": "VirtualService","metadata": {"annotations": {},"name": "podinfo","namespace": "test"}, "spec": {"gateways": ["ingressgateway.istio-system.svc.cluster.local"],"hosts": ["podinfo"],"http": [{"route": [{"destination": {"host": "podinfo"}}]}]}}` } - _, err = router.istioClient.NetworkingV1alpha3().VirtualServices(table.canary.Namespace).Update(vs) + _, err = router.istioClient.NetworkingV1alpha3().VirtualServices(table.canary.Namespace).Update(context.TODO(), vs, metav1.UpdateOptions{}) require.NoError(t, err) } @@ -422,7 +423,7 @@ func TestIstioRouter_Finalize(t *testing.T) { } if table.spec != nil { - vs, err := router.istioClient.NetworkingV1alpha3().VirtualServices(table.canary.Namespace).Get(table.canary.Name, metav1.GetOptions{}) + vs, err := router.istioClient.NetworkingV1alpha3().VirtualServices(table.canary.Namespace).Get(context.TODO(), table.canary.Name, metav1.GetOptions{}) require.NoError(t, err) require.Equal(t, *table.spec, vs.Spec) } diff --git a/pkg/router/kubernetes_default.go b/pkg/router/kubernetes_default.go index 67992d08..2d1c556e 100644 --- a/pkg/router/kubernetes_default.go +++ b/pkg/router/kubernetes_default.go @@ -1,6 +1,7 @@ package router import ( + "context" "encoding/json" "fmt" @@ -113,7 +114,7 @@ func (c *KubernetesDefaultRouter) reconcileService(canary *flaggerv1.Canary, nam } // create service if it doesn't exists - svc, err := c.kubeClient.CoreV1().Services(canary.Namespace).Get(name, metav1.GetOptions{}) + svc, err := c.kubeClient.CoreV1().Services(canary.Namespace).Get(context.TODO(), name, metav1.GetOptions{}) if errors.IsNotFound(err) { svc = &corev1.Service{ ObjectMeta: metav1.ObjectMeta{ @@ -132,7 +133,7 @@ func (c *KubernetesDefaultRouter) reconcileService(canary *flaggerv1.Canary, nam Spec: svcSpec, } - _, err := c.kubeClient.CoreV1().Services(canary.Namespace).Create(svc) + _, err := c.kubeClient.CoreV1().Services(canary.Namespace).Create(context.TODO(), svc, metav1.CreateOptions{}) if err != nil { return fmt.Errorf("service %s.%s create error: %w", svc.Name, canary.Namespace, err) } @@ -166,7 +167,7 @@ func (c *KubernetesDefaultRouter) reconcileService(canary *flaggerv1.Canary, nam svcClone := svc.DeepCopy() svcClone.Spec.Ports = svcSpec.Ports svcClone.Spec.Selector = svcSpec.Selector - _, err = c.kubeClient.CoreV1().Services(canary.Namespace).Update(svcClone) + _, err = c.kubeClient.CoreV1().Services(canary.Namespace).Update(context.TODO(), svcClone, metav1.UpdateOptions{}) if err != nil { return fmt.Errorf("service %s update error: %w", name, err) } @@ -182,7 +183,7 @@ func (c *KubernetesDefaultRouter) reconcileService(canary *flaggerv1.Canary, nam func (c *KubernetesDefaultRouter) Finalize(canary *flaggerv1.Canary) error { apexName, _, _ := canary.GetServiceNames() - svc, err := c.kubeClient.CoreV1().Services(canary.Namespace).Get(apexName, metav1.GetOptions{}) + svc, err := c.kubeClient.CoreV1().Services(canary.Namespace).Get(context.TODO(), apexName, metav1.GetOptions{}) if err != nil { return fmt.Errorf("service %s.%s get query error: %w", apexName, canary.Namespace, err) } @@ -199,7 +200,7 @@ func (c *KubernetesDefaultRouter) Finalize(canary *flaggerv1.Canary) error { clone := svc.DeepCopy() clone.Spec.Selector = storedSvc.Spec.Selector - if _, err := c.kubeClient.CoreV1().Services(canary.Namespace).Update(clone); err != nil { + if _, err := c.kubeClient.CoreV1().Services(canary.Namespace).Update(context.TODO(), clone, metav1.UpdateOptions{}); err != nil { return fmt.Errorf("service %s update error: %w", clone.Name, err) } } else { diff --git a/pkg/router/kubernetes_default_test.go b/pkg/router/kubernetes_default_test.go index 87293eed..e43d2797 100644 --- a/pkg/router/kubernetes_default_test.go +++ b/pkg/router/kubernetes_default_test.go @@ -1,6 +1,7 @@ package router import ( + "context" "fmt" "testing" @@ -29,13 +30,13 @@ func TestServiceRouter_Create(t *testing.T) { err = router.Reconcile(mocks.canary) require.NoError(t, err) - canarySvc, err := mocks.kubeClient.CoreV1().Services("default").Get("podinfo-canary", metav1.GetOptions{}) + canarySvc, err := mocks.kubeClient.CoreV1().Services("default").Get(context.TODO(), "podinfo-canary", metav1.GetOptions{}) require.NoError(t, err) assert.Equal(t, "http", canarySvc.Spec.Ports[0].Name) assert.Equal(t, int32(9898), canarySvc.Spec.Ports[0].Port) - primarySvc, err := mocks.kubeClient.CoreV1().Services("default").Get("podinfo-primary", metav1.GetOptions{}) + primarySvc, err := mocks.kubeClient.CoreV1().Services("default").Get(context.TODO(), "podinfo-primary", metav1.GetOptions{}) require.NoError(t, err) assert.Equal(t, "http", primarySvc.Spec.Ports[0].Name) assert.Equal(t, int32(9898), primarySvc.Spec.Ports[0].Port) @@ -55,13 +56,13 @@ func TestServiceRouter_Update(t *testing.T) { err = router.Reconcile(mocks.canary) require.NoError(t, err) - canary, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get("podinfo", metav1.GetOptions{}) + canary, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) canaryClone := canary.DeepCopy() canaryClone.Spec.Service.PortName = "grpc" - c, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Update(canaryClone) + c, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Update(context.TODO(), canaryClone, metav1.UpdateOptions{}) require.NoError(t, err) // apply changes @@ -70,7 +71,7 @@ func TestServiceRouter_Update(t *testing.T) { err = router.Reconcile(c) require.NoError(t, err) - canarySvc, err := mocks.kubeClient.CoreV1().Services("default").Get("podinfo-canary", metav1.GetOptions{}) + canarySvc, err := mocks.kubeClient.CoreV1().Services("default").Get(context.TODO(), "podinfo-canary", metav1.GetOptions{}) require.NoError(t, err) assert.Equal(t, "grpc", canarySvc.Spec.Ports[0].Name) } @@ -89,14 +90,14 @@ func TestServiceRouter_Undo(t *testing.T) { err = router.Reconcile(mocks.canary) require.NoError(t, err) - canarySvc, err := mocks.kubeClient.CoreV1().Services("default").Get("podinfo-canary", metav1.GetOptions{}) + canarySvc, err := mocks.kubeClient.CoreV1().Services("default").Get(context.TODO(), "podinfo-canary", metav1.GetOptions{}) require.NoError(t, err) svcClone := canarySvc.DeepCopy() svcClone.Spec.Ports[0].Name = "http2-podinfo" svcClone.Spec.Ports[0].Port = 8080 - _, err = mocks.kubeClient.CoreV1().Services("default").Update(svcClone) + _, err = mocks.kubeClient.CoreV1().Services("default").Update(context.TODO(), svcClone, metav1.UpdateOptions{}) require.NoError(t, err) // undo changes @@ -105,7 +106,7 @@ func TestServiceRouter_Undo(t *testing.T) { err = router.Reconcile(mocks.canary) require.NoError(t, err) - canarySvc, err = mocks.kubeClient.CoreV1().Services("default").Get("podinfo-canary", metav1.GetOptions{}) + canarySvc, err = mocks.kubeClient.CoreV1().Services("default").Get(context.TODO(), "podinfo-canary", metav1.GetOptions{}) require.NoError(t, err) assert.Equal(t, "http", canarySvc.Spec.Ports[0].Name) assert.Equal(t, int32(9898), canarySvc.Spec.Ports[0].Port) @@ -331,7 +332,7 @@ func TestServiceRouter_Finalize(t *testing.T) { require.NoError(t, err) } - svc, err := table.router.kubeClient.CoreV1().Services(table.canary.Namespace).Get(table.canary.Name, metav1.GetOptions{}) + svc, err := table.router.kubeClient.CoreV1().Services(table.canary.Namespace).Get(context.TODO(), table.canary.Name, metav1.GetOptions{}) if err != nil { if !errors.IsNotFound(err) { require.Equal(t, "http", svc.Spec.Ports[0].Name) diff --git a/pkg/router/smi.go b/pkg/router/smi.go index a9a4071e..01e8f9ec 100644 --- a/pkg/router/smi.go +++ b/pkg/router/smi.go @@ -1,6 +1,7 @@ package router import ( + "context" "encoding/json" "fmt" @@ -52,7 +53,7 @@ func (sr *SmiRouter) Reconcile(canary *flaggerv1.Canary) error { }, } - ts, err := sr.smiClient.SplitV1alpha1().TrafficSplits(canary.Namespace).Get(apexName, metav1.GetOptions{}) + ts, err := sr.smiClient.SplitV1alpha1().TrafficSplits(canary.Namespace).Get(context.TODO(), apexName, metav1.GetOptions{}) // create traffic split if errors.IsNotFound(err) { t := &smiv1alpha1.TrafficSplit{ @@ -71,7 +72,7 @@ func (sr *SmiRouter) Reconcile(canary *flaggerv1.Canary) error { Spec: tsSpec, } - _, err := sr.smiClient.SplitV1alpha1().TrafficSplits(canary.Namespace).Create(t) + _, err := sr.smiClient.SplitV1alpha1().TrafficSplits(canary.Namespace).Create(context.TODO(), t, metav1.CreateOptions{}) if err != nil { return fmt.Errorf("TrafficSplit %s.%s create error: %w", apexName, canary.Namespace, err) } @@ -88,7 +89,7 @@ func (sr *SmiRouter) Reconcile(canary *flaggerv1.Canary) error { tsClone := ts.DeepCopy() tsClone.Spec = tsSpec - _, err := sr.smiClient.SplitV1alpha1().TrafficSplits(canary.Namespace).Update(tsClone) + _, err := sr.smiClient.SplitV1alpha1().TrafficSplits(canary.Namespace).Update(context.TODO(), tsClone, metav1.UpdateOptions{}) if err != nil { return fmt.Errorf("TrafficSplit %s.%s update error: %w", apexName, canary.Namespace, err) } @@ -109,7 +110,7 @@ func (sr *SmiRouter) GetRoutes(canary *flaggerv1.Canary) ( err error, ) { apexName, primaryName, canaryName := canary.GetServiceNames() - ts, err := sr.smiClient.SplitV1alpha1().TrafficSplits(canary.Namespace).Get(apexName, metav1.GetOptions{}) + ts, err := sr.smiClient.SplitV1alpha1().TrafficSplits(canary.Namespace).Get(context.TODO(), apexName, metav1.GetOptions{}) if err != nil { err = fmt.Errorf("TrafficSplit %s.%s get query error %v", apexName, canary.Namespace, err) return @@ -143,7 +144,7 @@ func (sr *SmiRouter) SetRoutes( _ bool, ) error { apexName, primaryName, canaryName := canary.GetServiceNames() - ts, err := sr.smiClient.SplitV1alpha1().TrafficSplits(canary.Namespace).Get(apexName, metav1.GetOptions{}) + ts, err := sr.smiClient.SplitV1alpha1().TrafficSplits(canary.Namespace).Get(context.TODO(), apexName, metav1.GetOptions{}) if err != nil { return fmt.Errorf("TrafficSplit %s.%s get query error %v", apexName, canary.Namespace, err) } @@ -162,7 +163,7 @@ func (sr *SmiRouter) SetRoutes( tsClone := ts.DeepCopy() tsClone.Spec.Backends = backends - _, err = sr.smiClient.SplitV1alpha1().TrafficSplits(canary.Namespace).Update(tsClone) + _, err = sr.smiClient.SplitV1alpha1().TrafficSplits(canary.Namespace).Update(context.TODO(), tsClone, metav1.UpdateOptions{}) if err != nil { return fmt.Errorf("TrafficSplit %s.%s update error %v", apexName, canary.Namespace, err) } @@ -182,7 +183,7 @@ func (sr *SmiRouter) makeAnnotations(gateways []string) map[string]string { // getWithConvert overrides invalid traffic split and sets weight based on the canary status func (sr *SmiRouter) getWithConvert(canary *flaggerv1.Canary, host string) (*smiv1alpha2.TrafficSplit, error) { apexName, primaryName, canaryName := canary.GetServiceNames() - ts, err := sr.smiClient.SplitV1alpha2().TrafficSplits(canary.Namespace).Get(apexName, metav1.GetOptions{}) + ts, err := sr.smiClient.SplitV1alpha2().TrafficSplits(canary.Namespace).Get(context.TODO(), apexName, metav1.GetOptions{}) if errors.IsInvalid(err) { t := &smiv1alpha2.TrafficSplit{ ObjectMeta: metav1.ObjectMeta{ @@ -212,7 +213,7 @@ func (sr *SmiRouter) getWithConvert(canary *flaggerv1.Canary, host string) (*smi }, } - _, err := sr.smiClient.SplitV1alpha2().TrafficSplits(canary.Namespace).Update(t) + _, err := sr.smiClient.SplitV1alpha2().TrafficSplits(canary.Namespace).Update(context.TODO(), t, metav1.UpdateOptions{}) if err != nil { return nil, fmt.Errorf("TrafficSplit %s.%s update error: %w", apexName, canary.Namespace, err) } diff --git a/pkg/router/smi_test.go b/pkg/router/smi_test.go index f73ab8ab..042689c1 100644 --- a/pkg/router/smi_test.go +++ b/pkg/router/smi_test.go @@ -1,6 +1,7 @@ package router import ( + "context" "strconv" "testing" @@ -25,7 +26,7 @@ func TestSmiRouter_Sync(t *testing.T) { require.NoError(t, err) // test insert - ts, err := router.smiClient.SplitV1alpha1().TrafficSplits("default").Get("podinfo", metav1.GetOptions{}) + ts, err := router.smiClient.SplitV1alpha1().TrafficSplits("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) dests := ts.Spec.Backends assert.Len(t, dests, 2) @@ -54,7 +55,7 @@ func TestSmiRouter_Sync(t *testing.T) { err = router.Reconcile(canary) require.NoError(t, err) - ts, err = router.smiClient.SplitV1alpha1().TrafficSplits("default").Get("test", metav1.GetOptions{}) + ts, err = router.smiClient.SplitV1alpha1().TrafficSplits("default").Get(context.TODO(), "test", metav1.GetOptions{}) require.NoError(t, err) assert.Equal(t, host, ts.Spec.Service) } @@ -82,7 +83,7 @@ func TestSmiRouter_SetRoutes(t *testing.T) { err = router.SetRoutes(mocks.canary, p, c, m) require.NoError(t, err) - ts, err := router.smiClient.SplitV1alpha1().TrafficSplits("default").Get("podinfo", metav1.GetOptions{}) + ts, err := router.smiClient.SplitV1alpha1().TrafficSplits("default").Get(context.TODO(), "podinfo", metav1.GetOptions{}) require.NoError(t, err) var pRoute smiv1.TrafficSplitBackend