@@ -115,8 +115,6 @@ func runTests(admissionReviewVersion string) {
115115
116116 ctx , cancel := context .WithCancel (context .Background ())
117117 cancel ()
118- // TODO: we may want to improve it to make it be able to inject dependencies,
119- // but not always try to load certs and return not found error.
120118 err = svr .Start (ctx )
121119 if err != nil && ! os .IsNotExist (err ) {
122120 ExpectWithOffset (1 , err ).NotTo (HaveOccurred ())
@@ -191,8 +189,6 @@ func runTests(admissionReviewVersion string) {
191189
192190 ctx , cancel := context .WithCancel (context .Background ())
193191 cancel ()
194- // TODO: we may want to improve it to make it be able to inject dependencies,
195- // but not always try to load certs and return not found error.
196192 err = svr .Start (ctx )
197193 if err != nil && ! os .IsNotExist (err ) {
198194 ExpectWithOffset (1 , err ).NotTo (HaveOccurred ())
@@ -208,7 +204,7 @@ func runTests(admissionReviewVersion string) {
208204 By ("sanity checking the response contains reasonable fields" )
209205 ExpectWithOffset (1 , w .Body ).To (ContainSubstring (`"allowed":false` ))
210206 ExpectWithOffset (1 , w .Body ).To (ContainSubstring (`"code":500` ))
211- ExpectWithOffset (1 , w .Body ).To (ContainSubstring (`"message":"panic: injected panic [recovered]` ))
207+ ExpectWithOffset (1 , w .Body ).To (ContainSubstring (`"message":"panic: fake panic test [recovered]` ))
212208 })
213209
214210 It ("should scaffold a defaulting webhook with a custom defaulter" , func () {
@@ -260,8 +256,6 @@ func runTests(admissionReviewVersion string) {
260256
261257 ctx , cancel := context .WithCancel (context .Background ())
262258 cancel ()
263- // TODO: we may want to improve it to make it be able to inject dependencies,
264- // but not always try to load certs and return not found error.
265259 err = svr .Start (ctx )
266260 if err != nil && ! os .IsNotExist (err ) {
267261 ExpectWithOffset (1 , err ).NotTo (HaveOccurred ())
@@ -337,8 +331,6 @@ func runTests(admissionReviewVersion string) {
337331
338332 ctx , cancel := context .WithCancel (context .Background ())
339333 cancel ()
340- // TODO: we may want to improve it to make it be able to inject dependencies,
341- // but not always try to load certs and return not found error.
342334 err = svr .Start (ctx )
343335 if err != nil && ! os .IsNotExist (err ) {
344336 ExpectWithOffset (1 , err ).NotTo (HaveOccurred ())
@@ -411,8 +403,6 @@ func runTests(admissionReviewVersion string) {
411403
412404 ctx , cancel := context .WithCancel (context .Background ())
413405 cancel ()
414- // TODO: we may want to improve it to make it be able to inject dependencies,
415- // but not always try to load certs and return not found error.
416406 err = svr .Start (ctx )
417407 if err != nil && ! os .IsNotExist (err ) {
418408 ExpectWithOffset (1 , err ).NotTo (HaveOccurred ())
@@ -430,7 +420,7 @@ func runTests(admissionReviewVersion string) {
430420 By ("sanity checking the response contains reasonable field" )
431421 ExpectWithOffset (1 , w .Body ).To (ContainSubstring (`"allowed":false` ))
432422 ExpectWithOffset (1 , w .Body ).To (ContainSubstring (`"code":500` ))
433- ExpectWithOffset (1 , w .Body ).To (ContainSubstring (`"message":"panic: injected panic [recovered]` ))
423+ ExpectWithOffset (1 , w .Body ).To (ContainSubstring (`"message":"panic: fake panic test [recovered]` ))
434424 })
435425
436426 It ("should scaffold a validating webhook with a custom validator" , func () {
@@ -463,12 +453,12 @@ func runTests(admissionReviewVersion string) {
463453 "kind":{
464454 "group":"foo.test.org",
465455 "version":"v1",
466- "kind":"TestDefaulter "
456+ "kind":"TestValidator "
467457 },
468458 "resource":{
469459 "group":"foo.test.org",
470460 "version":"v1",
471- "resource":"testdefaulter "
461+ "resource":"testvalidator "
472462 },
473463 "namespace":"default",
474464 "name":"foo",
@@ -484,8 +474,6 @@ func runTests(admissionReviewVersion string) {
484474
485475 ctx , cancel := context .WithCancel (context .Background ())
486476 cancel ()
487- // TODO: we may want to improve it to make it be able to inject dependencies,
488- // but not always try to load certs and return not found error.
489477 err = svr .Start (ctx )
490478 if err != nil && ! os .IsNotExist (err ) {
491479 ExpectWithOffset (1 , err ).NotTo (HaveOccurred ())
@@ -511,7 +499,7 @@ func runTests(admissionReviewVersion string) {
511499 By ("sanity checking the response contains reasonable field" )
512500 ExpectWithOffset (1 , w .Body ).To (ContainSubstring (`"allowed":false` ))
513501 ExpectWithOffset (1 , w .Body ).To (ContainSubstring (`"code":403` ))
514- EventuallyWithOffset (1 , logBuffer ).Should (gbytes .Say (`"msg":"Validating object","object":{"name":"foo","namespace":"default"},"namespace":"default","name":"foo","resource":{"group":"foo.test.org","version":"v1","resource":"testdefaulter "},"user":"","requestID":"07e52e8d-4513-11e9-a716-42010a800270"` ))
502+ EventuallyWithOffset (1 , logBuffer ).Should (gbytes .Say (`"msg":"Validating object","object":{"name":"foo","namespace":"default"},"namespace":"default","name":"foo","resource":{"group":"foo.test.org","version":"v1","resource":"testvalidator "},"user":"","requestID":"07e52e8d-4513-11e9-a716-42010a800270"` ))
515503 })
516504
517505 It ("should scaffold defaulting and validating webhooks if the type implements both Defaulter and Validator interfaces" , func () {
@@ -558,8 +546,6 @@ func runTests(admissionReviewVersion string) {
558546
559547 ctx , cancel := context .WithCancel (context .Background ())
560548 cancel ()
561- // TODO: we may want to improve it to make it be able to inject dependencies,
562- // but not always try to load certs and return not found error.
563549 err = svr .Start (ctx )
564550 if err != nil && ! os .IsNotExist (err ) {
565551 ExpectWithOffset (1 , err ).NotTo (HaveOccurred ())
@@ -636,8 +622,6 @@ func runTests(admissionReviewVersion string) {
636622}` )
637623
638624 cancel ()
639- // TODO: we may want to improve it to make it be able to inject dependencies,
640- // but not always try to load certs and return not found error.
641625 err = svr .Start (ctx )
642626 if err != nil && ! os .IsNotExist (err ) {
643627 ExpectWithOffset (1 , err ).NotTo (HaveOccurred ())
@@ -724,7 +708,7 @@ func (*TestDefaulterList) DeepCopyObject() runtime.Object { return nil }
724708
725709func (d * TestDefaulter ) Default () {
726710 if d .Panic {
727- panic ("injected panic" )
711+ panic ("fake panic test " )
728712 }
729713 if d .Replica < 2 {
730714 d .Replica = 2
@@ -767,7 +751,7 @@ var _ admission.Validator = &TestValidator{}
767751
768752func (v * TestValidator ) ValidateCreate () error {
769753 if v .Panic {
770- panic ("injected panic" )
754+ panic ("fake panic test " )
771755 }
772756 if v .Replica < 0 {
773757 return errors .New ("number of replica should be greater than or equal to 0" )
@@ -777,7 +761,7 @@ func (v *TestValidator) ValidateCreate() error {
777761
778762func (v * TestValidator ) ValidateUpdate (old runtime.Object ) error {
779763 if v .Panic {
780- panic ("injected panic" )
764+ panic ("fake panic test " )
781765 }
782766 if v .Replica < 0 {
783767 return errors .New ("number of replica should be greater than or equal to 0" )
@@ -792,7 +776,7 @@ func (v *TestValidator) ValidateUpdate(old runtime.Object) error {
792776
793777func (v * TestValidator ) ValidateDelete () error {
794778 if v .Panic {
795- panic ("injected panic" )
779+ panic ("fake panic test " )
796780 }
797781 if v .Replica > 0 {
798782 return errors .New ("number of replica should be less than or equal to 0 to delete" )
0 commit comments