kube-router/pkg/controllers/proxy/mock_ipvs_state_test.go
2026-02-01 11:07:13 -06:00

30 lines
615 B
Go

package proxy
import (
"net"
"github.com/moby/ipvs"
)
// mockIPVSState holds stateful IPVS data for tests that need to track services
type mockIPVSState struct {
services []*ipvs.Service
}
func newMockIPVSState() *mockIPVSState {
return &mockIPVSState{
services: make([]*ipvs.Service, 0, 64),
}
}
// addService adds an IPVS service to the mock state and returns the created service
func (m *mockIPVSState) addService(vip net.IP, protocol, port uint16) *ipvs.Service {
svc := &ipvs.Service{
Address: vip,
Protocol: protocol,
Port: port,
}
m.services = append(m.services, svc)
return svc
}