interface.go 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. Copyright 2021 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. package testing
  14. import (
  15. "k8s.io/apimachinery/pkg/runtime"
  16. "k8s.io/apimachinery/pkg/watch"
  17. restclient "k8s.io/client-go/rest"
  18. )
  19. type FakeClient interface {
  20. // Tracker gives access to the ObjectTracker internal to the fake client.
  21. Tracker() ObjectTracker
  22. // AddReactor appends a reactor to the end of the chain.
  23. AddReactor(verb, resource string, reaction ReactionFunc)
  24. // PrependReactor adds a reactor to the beginning of the chain.
  25. PrependReactor(verb, resource string, reaction ReactionFunc)
  26. // AddWatchReactor appends a reactor to the end of the chain.
  27. AddWatchReactor(resource string, reaction WatchReactionFunc)
  28. // PrependWatchReactor adds a reactor to the beginning of the chain.
  29. PrependWatchReactor(resource string, reaction WatchReactionFunc)
  30. // AddProxyReactor appends a reactor to the end of the chain.
  31. AddProxyReactor(resource string, reaction ProxyReactionFunc)
  32. // PrependProxyReactor adds a reactor to the beginning of the chain.
  33. PrependProxyReactor(resource string, reaction ProxyReactionFunc)
  34. // Invokes records the provided Action and then invokes the ReactionFunc that
  35. // handles the action if one exists. defaultReturnObj is expected to be of the
  36. // same type a normal call would return.
  37. Invokes(action Action, defaultReturnObj runtime.Object) (runtime.Object, error)
  38. // InvokesWatch records the provided Action and then invokes the ReactionFunc
  39. // that handles the action if one exists.
  40. InvokesWatch(action Action) (watch.Interface, error)
  41. // InvokesProxy records the provided Action and then invokes the ReactionFunc
  42. // that handles the action if one exists.
  43. InvokesProxy(action Action) restclient.ResponseWrapper
  44. // ClearActions clears the history of actions called on the fake client.
  45. ClearActions()
  46. // Actions returns a chronologically ordered slice fake actions called on the
  47. // fake client.
  48. Actions() []Action
  49. }