k3s/vendor/k8s.io/kubernetes/pkg/util/bandwidth/fake_shaper.go

57 lines
1.6 KiB
Go
Raw Normal View History

2019-01-12 04:58:27 +00:00
/*
Copyright 2015 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package bandwidth
import (
"errors"
"k8s.io/apimachinery/pkg/api/resource"
)
2019-08-30 18:33:25 +00:00
// FakeShaper provides an implementation of the bandwith.Shaper.
// Beware this is implementation has no features besides Reset and GetCIDRs.
2019-01-12 04:58:27 +00:00
type FakeShaper struct {
CIDRs []string
ResetCIDRs []string
}
2019-08-30 18:33:25 +00:00
// Limit is not implemented
2019-01-12 04:58:27 +00:00
func (f *FakeShaper) Limit(cidr string, egress, ingress *resource.Quantity) error {
return errors.New("unimplemented")
}
2019-08-30 18:33:25 +00:00
// Reset appends a particular CIDR to the set of ResetCIDRs being managed by this shaper
2019-01-12 04:58:27 +00:00
func (f *FakeShaper) Reset(cidr string) error {
f.ResetCIDRs = append(f.ResetCIDRs, cidr)
return nil
}
2019-08-30 18:33:25 +00:00
// ReconcileInterface is not implemented
2019-01-12 04:58:27 +00:00
func (f *FakeShaper) ReconcileInterface() error {
return errors.New("unimplemented")
}
2019-08-30 18:33:25 +00:00
// ReconcileCIDR is not implemented
2019-01-12 04:58:27 +00:00
func (f *FakeShaper) ReconcileCIDR(cidr string, egress, ingress *resource.Quantity) error {
return errors.New("unimplemented")
}
2019-08-30 18:33:25 +00:00
// GetCIDRs returns the set of CIDRs that are being managed by this shaper
2019-01-12 04:58:27 +00:00
func (f *FakeShaper) GetCIDRs() ([]string, error) {
return f.CIDRs, nil
}