diff --git a/example/basic/go.mod b/example/basic/go.mod index a7d8aca7e8..1798c77e45 100644 --- a/example/basic/go.mod +++ b/example/basic/go.mod @@ -20,7 +20,7 @@ require ( k8s.io/kube-openapi v0.0.0-20200410145947-61e04a5be9a6 k8s.io/utils v0.0.0-20200324210504-a9aa75ae1b89 sigs.k8s.io/apiserver-builder-alpha v0.0.0-00010101000000-000000000000 - sigs.k8s.io/controller-runtime v0.5.1 + sigs.k8s.io/controller-runtime v0.6.0 sigs.k8s.io/kubebuilder v1.0.8 sigs.k8s.io/testing_frameworks v0.1.1 ) diff --git a/example/basic/go.sum b/example/basic/go.sum index ab3ef6169e..0e2a55777c 100644 --- a/example/basic/go.sum +++ b/example/basic/go.sum @@ -571,15 +571,18 @@ k8s.io/api v0.0.0-20190918155943-95b840bb6a1f/go.mod h1:uWuOHnjmNrtQomJrvEBg0c0H k8s.io/api v0.17.2/go.mod h1:BS9fjjLc4CMuqfSO8vgbHPKMt5+SF0ET6u/RVDihTo4= k8s.io/api v0.17.3 h1:XAm3PZp3wnEdzekNkcmj/9Y1zdmQYJ1I4GKSBBZ8aG0= k8s.io/api v0.17.3/go.mod h1:YZ0OTkuw7ipbe305fMpIdf3GLXZKRigjtZaV5gzC2J0= +k8s.io/api v0.18.2/go.mod h1:SJCWI7OLzhZSvbY7U8zwNl9UA4o1fizoug34OV/2r78= k8s.io/api v0.18.4 h1:8x49nBRxuXGUlDlwlWd3RMY1SayZrzFfxea3UZSkFw4= k8s.io/api v0.18.4/go.mod h1:lOIQAKYgai1+vz9J7YcDZwC26Z0zQewYOGWdyIPUUQ4= k8s.io/apiextensions-apiserver v0.0.0-20190918161926-8f644eb6e783/go.mod h1:xvae1SZB3E17UpV59AWc271W/Ph25N+bjPyR63X6tPY= k8s.io/apiextensions-apiserver v0.17.2/go.mod h1:4KdMpjkEjjDI2pPfBA15OscyNldHWdBCfsWMDWAmSTs= +k8s.io/apiextensions-apiserver v0.18.2/go.mod h1:q3faSnRGmYimiocj6cHQ1I3WpLqmDgJFlKL37fC4ZvY= k8s.io/apimachinery v0.0.0-20190913080033-27d36303b655 h1:CS1tBQz3HOXiseWZu6ZicKX361CZLT97UFnnPx0aqBw= k8s.io/apimachinery v0.0.0-20190913080033-27d36303b655/go.mod h1:nL6pwRT8NgfF8TT68DBI8uEePRt89cSvoXUVqbkWHq4= k8s.io/apimachinery v0.17.2/go.mod h1:b9qmWdKlLuU9EBh+06BtLcSf/Mu89rWL33naRxs1uZg= k8s.io/apimachinery v0.17.3 h1:f+uZV6rm4/tHE7xXgLyToprg6xWairaClGVkm2t8omg= k8s.io/apimachinery v0.17.3/go.mod h1:gxLnyZcGNdZTCLnq3fgzyg2A5BVCHTNDFrw8AmuJ+0g= +k8s.io/apimachinery v0.18.2/go.mod h1:9SnR/e11v5IbyPCGbvJViimtJ0SwHG4nfZFjU77ftcA= k8s.io/apimachinery v0.18.4 h1:ST2beySjhqwJoIFk6p7Hp5v5O0hYY6Gngq/gUYXTPIA= k8s.io/apimachinery v0.18.4/go.mod h1:OaXp26zu/5J7p0f92ASynJa1pZo06YlV9fG7BoWbCko= k8s.io/apiserver v0.0.0-20190918160949-bfa5e2e684ad h1:IMoNR9pilTBaCS5WpwWnAdmoVYVeXowOD3bLrwxIAtQ= @@ -587,6 +590,7 @@ k8s.io/apiserver v0.0.0-20190918160949-bfa5e2e684ad/go.mod h1:XPCXEwhjaFN29a8Nld k8s.io/apiserver v0.17.2/go.mod h1:lBmw/TtQdtxvrTk0e2cgtOxHizXI+d0mmGQURIHQZlo= k8s.io/apiserver v0.17.3 h1:faZbSuFtJ4dx09vctKZGHms/7bp3qFtbqb10Swswqfs= k8s.io/apiserver v0.17.3/go.mod h1:iJtsPpu1ZpEnHaNawpSV0nYTGBhhX2dUlnn7/QS7QiY= +k8s.io/apiserver v0.18.2/go.mod h1:Xbh066NqrZO8cbsoenCwyDJ1OSi8Ag8I2lezeHxzwzw= k8s.io/apiserver v0.18.4 h1:pn1jSQkfboPSirZopkVpEdLW4FcQLnYMaIY8LFxxj30= k8s.io/apiserver v0.18.4/go.mod h1:q+zoFct5ABNnYkGIaGQ3bcbUNdmPyOCoEBcg51LChY8= k8s.io/client-go v0.0.0-20190918160344-1fbdaa4c8d90 h1:mLmhKUm1X+pXu0zXMEzNsOF5E2kKFGe5o6BZBIIqA6A= @@ -594,17 +598,20 @@ k8s.io/client-go v0.0.0-20190918160344-1fbdaa4c8d90/go.mod h1:J69/JveO6XESwVgG53 k8s.io/client-go v0.17.2/go.mod h1:QAzRgsa0C2xl4/eVpeVAZMvikCn8Nm81yqVx3Kk9XYI= k8s.io/client-go v0.17.3 h1:deUna1Ksx05XeESH6XGCyONNFfiQmDdqeqUvicvP6nU= k8s.io/client-go v0.17.3/go.mod h1:cLXlTMtWHkuK4tD360KpWz2gG2KtdWEr/OT02i3emRQ= +k8s.io/client-go v0.18.2/go.mod h1:Xcm5wVGXX9HAA2JJ2sSBUn3tCJ+4SVlCbl2MNNv+CIU= k8s.io/client-go v0.18.4 h1:un55V1Q/B3JO3A76eS0kUSywgGK/WR3BQ8fHQjNa6Zc= k8s.io/client-go v0.18.4/go.mod h1:f5sXwL4yAZRkAtzOxRWUhA/N8XzGCb+nPZI8PfobZ9g= k8s.io/code-generator v0.0.0-20190912054826-cd179ad6a269/go.mod h1:V5BD6M4CyaN5m+VthcclXWsVcT1Hu+glwa1bi3MIsyE= k8s.io/code-generator v0.17.2/go.mod h1:DVmfPQgxQENqDIzVR2ddLXMH34qeszkKSdH/N+s+38s= k8s.io/code-generator v0.17.3/go.mod h1:l8BLVwASXQZTo2xamW5mQNFCe1XPiAesVq7Y1t7PiQQ= +k8s.io/code-generator v0.18.2/go.mod h1:+UHX5rSbxmR8kzS+FAv7um6dtYrZokQvjHpDSYRVkTc= k8s.io/code-generator v0.18.4/go.mod h1:TgNEVx9hCyPGpdtCWA34olQYLkh3ok9ar7XfSsr8b6c= k8s.io/component-base v0.0.0-20190918160511-547f6c5d7090 h1:0UWOjjag5IcVoAko0g+3qGhegdwWkRf4v4AHCIMVwnc= k8s.io/component-base v0.0.0-20190918160511-547f6c5d7090/go.mod h1:933PBGtQFJky3TEwYx4aEPZ4IxqhWh3R6DCmzqIn1hA= k8s.io/component-base v0.17.2/go.mod h1:zMPW3g5aH7cHJpKYQ/ZsGMcgbsA/VyhEugF3QT1awLs= k8s.io/component-base v0.17.3 h1:hQzTSshY14aLSR6WGIYvmw+w+u6V4d+iDR2iDGMrlUg= k8s.io/component-base v0.17.3/go.mod h1:GeQf4BrgelWm64PXkIXiPh/XS0hnO42d9gx9BtbZRp8= +k8s.io/component-base v0.18.2/go.mod h1:kqLlMuhJNHQ9lz8Z7V5bxUUtjFZnrypArGl58gmDfUM= k8s.io/component-base v0.18.4 h1:Kr53Fp1iCGNsl9Uv4VcRvLy7YyIqi9oaJOQ7SXtKI98= k8s.io/component-base v0.18.4/go.mod h1:7jr/Ef5PGmKwQhyAz/pjByxJbC58mhKAhiaDu0vXfPk= k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= @@ -624,6 +631,7 @@ k8s.io/kube-openapi v0.0.0-20190816220812-743ec37842bf h1:EYm5AW/UUDbnmnI+gK0TJD k8s.io/kube-openapi v0.0.0-20190816220812-743ec37842bf/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E= 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/kube-openapi v0.0.0-20200121204235-bf4fb3bd569c/go.mod h1:GRQhZsXIAJ1xR0C9bd8UpWHZ5plfAS9fzPjJuQ6JL3E= k8s.io/kube-openapi v0.0.0-20200410145947-61e04a5be9a6 h1:Oh3Mzx5pJ+yIumsAD0MOECPVeXsVot0UkiaCGVyfGQY= k8s.io/kube-openapi v0.0.0-20200410145947-61e04a5be9a6/go.mod h1:GRQhZsXIAJ1xR0C9bd8UpWHZ5plfAS9fzPjJuQ6JL3E= k8s.io/utils v0.0.0-20190809000727-6c36bc71fc4a h1:uy5HAgt4Ha5rEMbhZA+aM1j2cq5LmR6LQ71EYC2sVH4= @@ -642,6 +650,8 @@ sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.7/go.mod h1:PHgbrJT sigs.k8s.io/controller-runtime v0.3.1-0.20191029211253-40070e2a1958/go.mod h1:p2vzQ3RuSVv9YR4AcM0y8TKHQA+0oLXazKFt6Z0OdS8= sigs.k8s.io/controller-runtime v0.5.1 h1:TNidCfVoU/cs2i+9xoTcL/l7yhl0bDhYXU0NCG6wmiE= sigs.k8s.io/controller-runtime v0.5.1/go.mod h1:Uojny7gvg55YLQnEGnPzRE3dC4ik2tRlZJgOUCWXAV4= +sigs.k8s.io/controller-runtime v0.5.6/go.mod h1:JZUwSMVbxDupo0lTJSSFP5pimEyxGynROImSsqIOx1A= +sigs.k8s.io/controller-runtime v0.6.0/go.mod h1:CpYf5pdNY/B352A1TFLAS2JVSlnGQ5O2cftPHndTroo= sigs.k8s.io/controller-tools v0.1.11-0.20190405182121-56d42b19e55a/go.mod h1:5B/NyJEvqwZNl6sJgTvQJGlxRK4TOJMdELRFDsUwSeY= sigs.k8s.io/controller-tools v0.1.12/go.mod h1:6g08p9m9G/So3sBc1AOQifHfhxH/mb6Sc4z0LMI8XMw= sigs.k8s.io/kubebuilder v1.0.8/go.mod h1:tjcjlckQhPDkbbOw9sUkf1hB1EMiKvqVJhxMXh13npA= diff --git a/example/basic/pkg/apis/innsmouth/v1/deepone_types_test.go b/example/basic/pkg/apis/innsmouth/v1/deepone_types_test.go index b6813d4cbd..d4990b24f9 100644 --- a/example/basic/pkg/apis/innsmouth/v1/deepone_types_test.go +++ b/example/basic/pkg/apis/innsmouth/v1/deepone_types_test.go @@ -17,6 +17,7 @@ limitations under the License. package v1_test import ( + "context" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" @@ -39,7 +40,7 @@ var _ = Describe("Deepone", func() { }) AfterEach(func() { - client.Delete(instance.Name, &metav1.DeleteOptions{}) + client.Delete(context.TODO(), instance.Name, metav1.DeleteOptions{}) }) Describe("when sending a storage request", func() { @@ -48,27 +49,27 @@ var _ = Describe("Deepone", func() { client = cs.InnsmouthV1().DeepOnes("deepone-test-valid") By("returning success from the create request") - actual, err := client.Create(&instance) + actual, err := client.Create(context.TODO(), &instance, metav1.CreateOptions{}) Expect(err).ShouldNot(HaveOccurred()) By("defaulting the expected fields") Expect(actual.Spec).To(Equal(expected.Spec)) By("returning the item for list requests") - result, err := client.List(metav1.ListOptions{}) + result, err := client.List(context.TODO(), metav1.ListOptions{}) Expect(err).ShouldNot(HaveOccurred()) Expect(result.Items).To(HaveLen(1)) Expect(result.Items[0].Spec).To(Equal(expected.Spec)) By("returning the item for get requests") - actual, err = client.Get(instance.Name, metav1.GetOptions{}) + actual, err = client.Get(context.TODO(), instance.Name, metav1.GetOptions{}) Expect(err).ShouldNot(HaveOccurred()) Expect(actual.Spec).To(Equal(expected.Spec)) By("deleting the item for delete requests") - err = client.Delete(instance.Name, &metav1.DeleteOptions{}) + err = client.Delete(context.TODO(), instance.Name, metav1.DeleteOptions{}) Expect(err).ShouldNot(HaveOccurred()) - result, err = client.List(metav1.ListOptions{}) + result, err = client.List(context.TODO(), metav1.ListOptions{}) Expect(err).ShouldNot(HaveOccurred()) Expect(result.Items).To(HaveLen(0)) }) @@ -95,27 +96,27 @@ var _ = Describe("Deepone", func() { client = cs.InnsmouthV1().DeepOnes("deepone-test-valid") By("returning success from the create request") - _, err := client.Create(&instance1) + _, err := client.Create(context.TODO(), &instance1, metav1.CreateOptions{}) Expect(err).ShouldNot(HaveOccurred()) By("returning success from the create request") - _, err = client.Create(&instance2) + _, err = client.Create(context.TODO(), &instance2, metav1.CreateOptions{}) Expect(err).ShouldNot(HaveOccurred()) By("returning the item for list requests") - result, err := client.List(metav1.ListOptions{LabelSelector: "foo=1"}) + result, err := client.List(context.TODO(), metav1.ListOptions{LabelSelector: "foo=1"}) Expect(err).ShouldNot(HaveOccurred()) Expect(result.Items).To(HaveLen(1)) Expect(result.Items[0].Spec).To(Equal(expected1.Spec)) By("returning the item for list requests") - result, err = client.List(metav1.ListOptions{LabelSelector: "foo=2"}) + result, err = client.List(context.TODO(), metav1.ListOptions{LabelSelector: "foo=2"}) Expect(err).ShouldNot(HaveOccurred()) Expect(result.Items).To(HaveLen(1)) Expect(result.Items[0].Spec).To(Equal(expected2.Spec)) By("returning the item for list requests") - result, err = client.List(metav1.ListOptions{}) + result, err = client.List(context.TODO(), metav1.ListOptions{}) Expect(err).ShouldNot(HaveOccurred()) Expect(result.Items).To(HaveLen(2)) }) diff --git a/example/basic/pkg/apis/kingsport/v1/festival_types_test.go b/example/basic/pkg/apis/kingsport/v1/festival_types_test.go index 6184c6c455..bf417fe26d 100644 --- a/example/basic/pkg/apis/kingsport/v1/festival_types_test.go +++ b/example/basic/pkg/apis/kingsport/v1/festival_types_test.go @@ -17,6 +17,7 @@ limitations under the License. package v1_test import ( + "context" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" @@ -39,7 +40,7 @@ var _ = Describe("Festival", func() { }) AfterEach(func() { - client.Delete(instance.Name, &metav1.DeleteOptions{}) + client.Delete(context.TODO(), instance.Name, metav1.DeleteOptions{}) }) Describe("when sending a storage request", func() { @@ -48,27 +49,27 @@ var _ = Describe("Festival", func() { client = cs.KingsportV1().Festivals() By("returning success from the create request") - actual, err := client.Create(&instance) + actual, err := client.Create(context.TODO(), &instance, metav1.CreateOptions{}) Expect(err).ShouldNot(HaveOccurred()) By("defaulting the expected fields") Expect(actual.Spec).To(Equal(expected.Spec)) By("returning the item for list requests") - result, err := client.List(metav1.ListOptions{}) + result, err := client.List(context.TODO(), metav1.ListOptions{}) Expect(err).ShouldNot(HaveOccurred()) Expect(result.Items).To(HaveLen(1)) Expect(result.Items[0].Spec).To(Equal(expected.Spec)) By("returning the item for get requests") - actual, err = client.Get(instance.Name, metav1.GetOptions{}) + actual, err = client.Get(context.TODO(), instance.Name, metav1.GetOptions{}) Expect(err).ShouldNot(HaveOccurred()) Expect(actual.Spec).To(Equal(expected.Spec)) By("deleting the item for delete requests") - err = client.Delete(instance.Name, &metav1.DeleteOptions{}) + err = client.Delete(context.TODO(), instance.Name, metav1.DeleteOptions{}) Expect(err).ShouldNot(HaveOccurred()) - result, err = client.List(metav1.ListOptions{}) + result, err = client.List(context.TODO(), metav1.ListOptions{}) Expect(err).ShouldNot(HaveOccurred()) Expect(result.Items).To(HaveLen(0)) }) @@ -79,7 +80,7 @@ var _ = Describe("Festival", func() { client = cs.KingsportV1().Festivals() By("returning success from the create request") - _, err := client.Create(&instance) + _, err := client.Create(context.TODO(), &instance, metav1.CreateOptions{}) Expect(err).Should(HaveOccurred()) }) }) diff --git a/example/basic/pkg/apis/miskatonic/v1beta1/campus_university_types_test.go b/example/basic/pkg/apis/miskatonic/v1beta1/campus_university_types_test.go index 232c54ffbf..f01323db8a 100644 --- a/example/basic/pkg/apis/miskatonic/v1beta1/campus_university_types_test.go +++ b/example/basic/pkg/apis/miskatonic/v1beta1/campus_university_types_test.go @@ -17,6 +17,7 @@ limitations under the License. package v1beta1_test import ( + "context" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" @@ -42,13 +43,13 @@ var _ = Describe("University", func() { }) AfterEach(func() { - client.Delete(instance.Name, &metav1.DeleteOptions{}) + client.Delete(context.TODO(), instance.Name, metav1.DeleteOptions{}) }) Describe("when sending a campus request", func() { It("should return success", func() { client = cs.MiskatonicV1beta1().Universities("university-test-campus") - _, err := client.Create(&instance) + _, err := client.Create(context.TODO(), &instance, metav1.CreateOptions{}) Expect(err).ShouldNot(HaveOccurred()) campus := &UniversityCampus{ @@ -60,11 +61,11 @@ var _ = Describe("University", func() { Name(instance.Name). Resource("universities"). SubResource("campus"). - Body(campus).Do().Error() + Body(campus).Do(context.TODO()).Error() Expect(err).ShouldNot(HaveOccurred()) expected.Spec.FacultySize = 30 - actual, err := client.Get(instance.Name, metav1.GetOptions{}) + actual, err := client.Get(context.TODO(), instance.Name, metav1.GetOptions{}) Expect(err).ShouldNot(HaveOccurred()) Expect(actual.Spec).Should(Equal(expected.Spec)) }) diff --git a/example/basic/pkg/apis/miskatonic/v1beta1/computer_student_types_test.go b/example/basic/pkg/apis/miskatonic/v1beta1/computer_student_types_test.go index f95e694f80..003c6047c9 100644 --- a/example/basic/pkg/apis/miskatonic/v1beta1/computer_student_types_test.go +++ b/example/basic/pkg/apis/miskatonic/v1beta1/computer_student_types_test.go @@ -17,6 +17,7 @@ limitations under the License. package v1beta1_test import ( + "context" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" @@ -39,13 +40,13 @@ var _ = Describe("Student", func() { }) AfterEach(func() { - client.Delete(instance.Name, &metav1.DeleteOptions{}) + client.Delete(context.TODO(), instance.Name, metav1.DeleteOptions{}) }) Describe("when sending a computer request", func() { It("should return success", func() { client = cs.MiskatonicV1beta1().Students("student-test-computer") - _, err := client.Create(&instance) + _, err := client.Create(context.TODO(), &instance, metav1.CreateOptions{}) Expect(err).ShouldNot(HaveOccurred()) computer := &StudentComputer{} @@ -55,7 +56,7 @@ var _ = Describe("Student", func() { Name(instance.Name). Resource("students"). SubResource("computer"). - Body(computer).Do().Error() + Body(computer).Do(context.TODO()).Error() Expect(err).ShouldNot(HaveOccurred()) }) }) diff --git a/example/basic/pkg/apis/miskatonic/v1beta1/student_types_test.go b/example/basic/pkg/apis/miskatonic/v1beta1/student_types_test.go index 806f4d2ab0..f80477a578 100644 --- a/example/basic/pkg/apis/miskatonic/v1beta1/student_types_test.go +++ b/example/basic/pkg/apis/miskatonic/v1beta1/student_types_test.go @@ -17,6 +17,8 @@ limitations under the License. package v1beta1_test import ( + "context" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" . "sigs.k8s.io/apiserver-builder-alpha/example/basic/pkg/apis/miskatonic/v1beta1" . "github.com/onsi/ginkgo" @@ -38,7 +40,7 @@ var _ = Describe("Student", func() { Describe("when sending a storage request", func() { It("should return the instance with an incremented the ID", func() { client := cs.MiskatonicV1beta1().Students("test-create-delete-students") - actual, err := client.Create(&instance) + actual, err := client.Create(context.TODO(), &instance, metav1.CreateOptions{}) Expect(err).NotTo(HaveOccurred()) expected.Spec.ID = instance.Spec.ID + 1 Expect(actual.Spec).To(Equal(expected.Spec)) diff --git a/example/basic/pkg/apis/miskatonic/v1beta1/university_types_test.go b/example/basic/pkg/apis/miskatonic/v1beta1/university_types_test.go index d588b41c2a..4824f21c4b 100644 --- a/example/basic/pkg/apis/miskatonic/v1beta1/university_types_test.go +++ b/example/basic/pkg/apis/miskatonic/v1beta1/university_types_test.go @@ -17,6 +17,8 @@ limitations under the License. package v1beta1_test import ( + "context" + . "sigs.k8s.io/apiserver-builder-alpha/example/basic/pkg/apis/miskatonic/v1beta1" . "sigs.k8s.io/apiserver-builder-alpha/example/basic/pkg/client/clientset_generated/clientset/typed/miskatonic/v1beta1" corev1 "k8s.io/api/core/v1" @@ -46,7 +48,7 @@ var _ = Describe("University", func() { }) AfterEach(func() { - client.Delete(instance.Name, &metav1.DeleteOptions{}) + client.Delete(context.TODO(), instance.Name, metav1.DeleteOptions{}) }) Describe("when sending a storage request", func() { @@ -55,27 +57,27 @@ var _ = Describe("University", func() { client = cs.MiskatonicV1beta1().Universities("university-test-valid") By("returning success from the create request") - actual, err := client.Create(&instance) + actual, err := client.Create(context.TODO(), &instance, metav1.CreateOptions{}) Expect(err).ShouldNot(HaveOccurred()) By("defaulting the expected fields") Expect(actual.Spec).To(Equal(expected.Spec)) By("returning the item for list requests") - result, err := client.List(metav1.ListOptions{}) + result, err := client.List(context.TODO(), metav1.ListOptions{}) Expect(err).ShouldNot(HaveOccurred()) Expect(result.Items).To(HaveLen(1)) Expect(result.Items[0].Spec).To(Equal(expected.Spec)) By("returning the item for get requests") - actual, err = client.Get(instance.Name, metav1.GetOptions{}) + actual, err = client.Get(context.TODO(), instance.Name, metav1.GetOptions{}) Expect(err).ShouldNot(HaveOccurred()) Expect(actual.Spec).To(Equal(expected.Spec)) By("deleting the item for delete requests") - err = client.Delete(instance.Name, &metav1.DeleteOptions{}) + err = client.Delete(context.TODO(), instance.Name, metav1.DeleteOptions{}) Expect(err).ShouldNot(HaveOccurred()) - result, err = client.List(metav1.ListOptions{}) + result, err = client.List(context.TODO(), metav1.ListOptions{}) Expect(err).ShouldNot(HaveOccurred()) Expect(result.Items).To(HaveLen(0)) }) @@ -85,7 +87,7 @@ var _ = Describe("University", func() { client = cs.MiskatonicV1beta1().Universities("university-test-too-many") val := 151 instance.Spec.MaxStudents = &val - _, err := client.Create(&instance) + _, err := client.Create(context.TODO(), &instance, metav1.CreateOptions{}) Expect(err).Should(HaveOccurred()) }) @@ -93,7 +95,7 @@ var _ = Describe("University", func() { client = cs.MiskatonicV1beta1().Universities("university-test-not-enough") val := 0 instance.Spec.MaxStudents = &val - _, err := client.Create(&instance) + _, err := client.Create(context.TODO(), &instance, metav1.CreateOptions{}) Expect(err).Should(HaveOccurred()) }) }) @@ -102,7 +104,7 @@ var _ = Describe("University", func() { Describe("when sending a campus request", func() { It("should set the faculty count", func() { client = cs.MiskatonicV1beta1().Universities("university-test-campus") - _, err := client.Create(&instance) + _, err := client.Create(context.TODO(), &instance, metav1.CreateOptions{}) Expect(err).ShouldNot(HaveOccurred()) campus := &UniversityCampus{ @@ -114,11 +116,11 @@ var _ = Describe("University", func() { Name(instance.Name). Resource("universities"). SubResource("campus"). - Body(campus).Do().Error() + Body(campus).Do(context.TODO()).Error() Expect(err).ShouldNot(HaveOccurred()) expected.Spec.FacultySize = 30 - actual, err := client.Get(instance.Name, metav1.GetOptions{}) + actual, err := client.Get(context.TODO(), instance.Name, metav1.GetOptions{}) Expect(err).ShouldNot(HaveOccurred()) Expect(actual.Spec).Should(Equal(expected.Spec)) }) diff --git a/example/basic/pkg/apis/olympus/v1beta1/poseidon_types_test.go b/example/basic/pkg/apis/olympus/v1beta1/poseidon_types_test.go index 7eae085ae6..f8bcabec67 100644 --- a/example/basic/pkg/apis/olympus/v1beta1/poseidon_types_test.go +++ b/example/basic/pkg/apis/olympus/v1beta1/poseidon_types_test.go @@ -17,6 +17,7 @@ limitations under the License. package v1beta1_test import ( + "context" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" @@ -39,7 +40,7 @@ var _ = Describe("Poseidon", func() { }) AfterEach(func() { - client.Delete(instance.Name, &metav1.DeleteOptions{}) + client.Delete(context.TODO(), instance.Name, metav1.DeleteOptions{}) }) Describe("when sending a storage request", func() { @@ -48,27 +49,27 @@ var _ = Describe("Poseidon", func() { client = cs.OlympusV1beta1().Poseidons("poseidon-test-valid") By("returning success from the create request") - actual, err := client.Create(&instance) + actual, err := client.Create(context.TODO(), &instance, metav1.CreateOptions{}) Expect(err).ShouldNot(HaveOccurred()) By("defaulting the expected fields") Expect(actual.Spec).To(Equal(expected.Spec)) By("returning the item for list requests") - result, err := client.List(metav1.ListOptions{}) + result, err := client.List(context.TODO(), metav1.ListOptions{}) Expect(err).ShouldNot(HaveOccurred()) Expect(result.Items).To(HaveLen(1)) Expect(result.Items[0].Spec).To(Equal(expected.Spec)) By("returning the item for get requests") - actual, err = client.Get(instance.Name, metav1.GetOptions{}) + actual, err = client.Get(context.TODO(), instance.Name, metav1.GetOptions{}) Expect(err).ShouldNot(HaveOccurred()) Expect(actual.Spec).To(Equal(expected.Spec)) By("deleting the item for delete requests") - err = client.Delete(instance.Name, &metav1.DeleteOptions{}) + err = client.Delete(context.TODO(), instance.Name, metav1.DeleteOptions{}) Expect(err).ShouldNot(HaveOccurred()) - result, err = client.List(metav1.ListOptions{}) + result, err = client.List(context.TODO(), metav1.ListOptions{}) Expect(err).ShouldNot(HaveOccurred()) Expect(result.Items).To(HaveLen(0)) }) @@ -93,27 +94,27 @@ var _ = Describe("Poseidon", func() { expected2 := instance2 By("returning success from the create request") - _, err := client.Create(&instance1) + _, err := client.Create(context.TODO(), &instance1, metav1.CreateOptions{}) Expect(err).ShouldNot(HaveOccurred()) By("returning success from the create request") - _, err = client.Create(&instance2) + _, err = client.Create(context.TODO(), &instance2, metav1.CreateOptions{}) Expect(err).ShouldNot(HaveOccurred()) By("returning the item for list requests") - result, err := client.List(metav1.ListOptions{FieldSelector: "spec.deployment.name=i1"}) + result, err := client.List(context.TODO(), metav1.ListOptions{FieldSelector: "spec.deployment.name=i1"}) Expect(err).ShouldNot(HaveOccurred()) Expect(result.Items).To(HaveLen(1)) Expect(result.Items[0].Name).To(Equal(expected1.Name)) By("returning the item for list requests") - result, err = client.List(metav1.ListOptions{FieldSelector: "spec.deployment.name=i2"}) + result, err = client.List(context.TODO(), metav1.ListOptions{FieldSelector: "spec.deployment.name=i2"}) Expect(err).ShouldNot(HaveOccurred()) Expect(result.Items).To(HaveLen(1)) Expect(result.Items[0].Name).To(Equal(expected2.Name)) By("returning the item for list requests") - result, err = client.List(metav1.ListOptions{}) + result, err = client.List(context.TODO(), metav1.ListOptions{}) Expect(err).ShouldNot(HaveOccurred()) Expect(result.Items).To(HaveLen(2)) })