mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 14:37:00 +00:00
export serviceKey and realServerKey in fake ipvs for easier test fixtures
Signed-off-by: Andrew Sy Kim <kiman@vmware.com>
This commit is contained in:
parent
c854f72dcb
commit
15682dfc2a
@ -27,47 +27,49 @@ import (
|
|||||||
//FakeIPVS no-op implementation of ipvs Interface
|
//FakeIPVS no-op implementation of ipvs Interface
|
||||||
type FakeIPVS struct {
|
type FakeIPVS struct {
|
||||||
Scheduler string
|
Scheduler string
|
||||||
Services map[serviceKey]*utilipvs.VirtualServer
|
Services map[ServiceKey]*utilipvs.VirtualServer
|
||||||
Destinations map[serviceKey][]*utilipvs.RealServer
|
Destinations map[ServiceKey][]*utilipvs.RealServer
|
||||||
}
|
}
|
||||||
|
|
||||||
type serviceKey struct {
|
// ServiceKey uniquely identifies a Service for an IPVS virtual server
|
||||||
|
type ServiceKey struct {
|
||||||
IP string
|
IP string
|
||||||
Port uint16
|
Port uint16
|
||||||
Protocol string
|
Protocol string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *serviceKey) String() string {
|
func (s *ServiceKey) String() string {
|
||||||
return fmt.Sprintf("%s:%d/%s", s.IP, s.Port, s.Protocol)
|
return fmt.Sprintf("%s:%d/%s", s.IP, s.Port, s.Protocol)
|
||||||
}
|
}
|
||||||
|
|
||||||
type realServerKey struct {
|
// RealServerKey uniquely identifies an Endpoint for an IPVS real server
|
||||||
|
type RealServerKey struct {
|
||||||
Address net.IP
|
Address net.IP
|
||||||
Port uint16
|
Port uint16
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *realServerKey) String() string {
|
func (r *RealServerKey) String() string {
|
||||||
return net.JoinHostPort(r.Address.String(), strconv.Itoa(int(r.Port)))
|
return net.JoinHostPort(r.Address.String(), strconv.Itoa(int(r.Port)))
|
||||||
}
|
}
|
||||||
|
|
||||||
//NewFake creates a fake ipvs implementation - a cache store.
|
//NewFake creates a fake ipvs implementation - a cache store.
|
||||||
func NewFake() *FakeIPVS {
|
func NewFake() *FakeIPVS {
|
||||||
return &FakeIPVS{
|
return &FakeIPVS{
|
||||||
Services: make(map[serviceKey]*utilipvs.VirtualServer),
|
Services: make(map[ServiceKey]*utilipvs.VirtualServer),
|
||||||
Destinations: make(map[serviceKey][]*utilipvs.RealServer),
|
Destinations: make(map[ServiceKey][]*utilipvs.RealServer),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func toServiceKey(serv *utilipvs.VirtualServer) serviceKey {
|
func toServiceKey(serv *utilipvs.VirtualServer) ServiceKey {
|
||||||
return serviceKey{
|
return ServiceKey{
|
||||||
IP: serv.Address.String(),
|
IP: serv.Address.String(),
|
||||||
Port: serv.Port,
|
Port: serv.Port,
|
||||||
Protocol: serv.Protocol,
|
Protocol: serv.Protocol,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func toRealServerKey(rs *utilipvs.RealServer) *realServerKey {
|
func toRealServerKey(rs *utilipvs.RealServer) *RealServerKey {
|
||||||
return &realServerKey{
|
return &RealServerKey{
|
||||||
Address: rs.Address,
|
Address: rs.Address,
|
||||||
Port: rs.Port,
|
Port: rs.Port,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user