clientset_generated.go 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. Copyright The Kubernetes Authors.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. // Code generated by client-gen. DO NOT EDIT.
  14. package fake
  15. import (
  16. clientset "github.com/rook/rook/pkg/client/clientset/versioned"
  17. cephv1 "github.com/rook/rook/pkg/client/clientset/versioned/typed/ceph.rook.io/v1"
  18. fakecephv1 "github.com/rook/rook/pkg/client/clientset/versioned/typed/ceph.rook.io/v1/fake"
  19. "k8s.io/apimachinery/pkg/runtime"
  20. "k8s.io/apimachinery/pkg/watch"
  21. "k8s.io/client-go/discovery"
  22. fakediscovery "k8s.io/client-go/discovery/fake"
  23. "k8s.io/client-go/testing"
  24. )
  25. // NewSimpleClientset returns a clientset that will respond with the provided objects.
  26. // It's backed by a very simple object tracker that processes creates, updates and deletions as-is,
  27. // without applying any validations and/or defaults. It shouldn't be considered a replacement
  28. // for a real clientset and is mostly useful in simple unit tests.
  29. func NewSimpleClientset(objects ...runtime.Object) *Clientset {
  30. o := testing.NewObjectTracker(scheme, codecs.UniversalDecoder())
  31. for _, obj := range objects {
  32. if err := o.Add(obj); err != nil {
  33. panic(err)
  34. }
  35. }
  36. cs := &Clientset{tracker: o}
  37. cs.discovery = &fakediscovery.FakeDiscovery{Fake: &cs.Fake}
  38. cs.AddReactor("*", "*", testing.ObjectReaction(o))
  39. cs.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) {
  40. gvr := action.GetResource()
  41. ns := action.GetNamespace()
  42. watch, err := o.Watch(gvr, ns)
  43. if err != nil {
  44. return false, nil, err
  45. }
  46. return true, watch, nil
  47. })
  48. return cs
  49. }
  50. // Clientset implements clientset.Interface. Meant to be embedded into a
  51. // struct to get a default implementation. This makes faking out just the method
  52. // you want to test easier.
  53. type Clientset struct {
  54. testing.Fake
  55. discovery *fakediscovery.FakeDiscovery
  56. tracker testing.ObjectTracker
  57. }
  58. func (c *Clientset) Discovery() discovery.DiscoveryInterface {
  59. return c.discovery
  60. }
  61. func (c *Clientset) Tracker() testing.ObjectTracker {
  62. return c.tracker
  63. }
  64. var _ clientset.Interface = &Clientset{}
  65. // CephV1 retrieves the CephV1Client
  66. func (c *Clientset) CephV1() cephv1.CephV1Interface {
  67. return &fakecephv1.FakeCephV1{Fake: &c.Fake}
  68. }