fake.go 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. Copyright 2015 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 "k8s.io/kubernetes/pkg/util/iptables"
  15. // no-op implementation of iptables Interface
  16. type fake struct{}
  17. func NewFake() *fake {
  18. return &fake{}
  19. }
  20. func (*fake) GetVersion() (string, error) {
  21. return "0.0.0", nil
  22. }
  23. func (*fake) EnsureChain(table iptables.Table, chain iptables.Chain) (bool, error) {
  24. return true, nil
  25. }
  26. func (*fake) FlushChain(table iptables.Table, chain iptables.Chain) error {
  27. return nil
  28. }
  29. func (*fake) DeleteChain(table iptables.Table, chain iptables.Chain) error {
  30. return nil
  31. }
  32. func (*fake) EnsureRule(position iptables.RulePosition, table iptables.Table, chain iptables.Chain, args ...string) (bool, error) {
  33. return true, nil
  34. }
  35. func (*fake) DeleteRule(table iptables.Table, chain iptables.Chain, args ...string) error {
  36. return nil
  37. }
  38. func (*fake) IsIpv6() bool {
  39. return false
  40. }
  41. func (*fake) Save(table iptables.Table) ([]byte, error) {
  42. return make([]byte, 0), nil
  43. }
  44. func (*fake) SaveAll() ([]byte, error) {
  45. return make([]byte, 0), nil
  46. }
  47. func (*fake) Restore(table iptables.Table, data []byte, flush iptables.FlushFlag, counters iptables.RestoreCountersFlag) error {
  48. return nil
  49. }
  50. func (*fake) RestoreAll(data []byte, flush iptables.FlushFlag, counters iptables.RestoreCountersFlag) error {
  51. return nil
  52. }
  53. func (*fake) AddReloadFunc(reloadFunc func()) {}
  54. func (*fake) Destroy() {}
  55. var _ = iptables.Interface(&fake{})