fake_shaper.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 bandwidth
  14. import (
  15. "errors"
  16. "k8s.io/apimachinery/pkg/api/resource"
  17. )
  18. // FakeShaper provides an implementation of the bandwith.Shaper.
  19. // Beware this is implementation has no features besides Reset and GetCIDRs.
  20. type FakeShaper struct {
  21. CIDRs []string
  22. ResetCIDRs []string
  23. }
  24. // Limit is not implemented
  25. func (f *FakeShaper) Limit(cidr string, egress, ingress *resource.Quantity) error {
  26. return errors.New("unimplemented")
  27. }
  28. // Reset appends a particular CIDR to the set of ResetCIDRs being managed by this shaper
  29. func (f *FakeShaper) Reset(cidr string) error {
  30. f.ResetCIDRs = append(f.ResetCIDRs, cidr)
  31. return nil
  32. }
  33. // ReconcileInterface is not implemented
  34. func (f *FakeShaper) ReconcileInterface() error {
  35. return errors.New("unimplemented")
  36. }
  37. // ReconcileCIDR is not implemented
  38. func (f *FakeShaper) ReconcileCIDR(cidr string, egress, ingress *resource.Quantity) error {
  39. return errors.New("unimplemented")
  40. }
  41. // GetCIDRs returns the set of CIDRs that are being managed by this shaper
  42. func (f *FakeShaper) GetCIDRs() ([]string, error) {
  43. return f.CIDRs, nil
  44. }