Documentation
¶
Index ¶
- Variables
- func CreateL3L4Payload(message interface{}, layers ...gopacket.SerializableLayer) ([]byte, error)
- func MustCreateL3L4Payload(message interface{}, layers ...gopacket.SerializableLayer) []byte
- type FakeClientConn
- func (c FakeClientConn) Close() error
- func (c FakeClientConn) GetState() connectivity.State
- func (c FakeClientConn) Invoke(ctx context.Context, method string, args interface{}, reply interface{}, ...) error
- func (c FakeClientConn) NewStream(ctx context.Context, desc *grpc.StreamDesc, method string, ...) (grpc.ClientStream, error)
- type FakeEndpointGetter
- type FakeEndpointInfo
- func (e *FakeEndpointInfo) GetID() uint64
- func (e *FakeEndpointInfo) GetIdentity() identity.NumericIdentity
- func (e *FakeEndpointInfo) GetK8sNamespace() string
- func (e *FakeEndpointInfo) GetK8sPodName() string
- func (e *FakeEndpointInfo) GetLabels() []string
- func (e *FakeEndpointInfo) GetRealizedPolicyRuleLabelsForKey(key policy.Key) (derivedFrom labels.LabelArrayList, revision uint64, ok bool)
- type FakeFQDNCache
- type FakeFlow
- func (f *FakeFlow) GetDestination() *flowpb.Endpoint
- func (f *FakeFlow) GetDestinationNames() []string
- func (f *FakeFlow) GetDestinationService() *flowpb.Service
- func (f *FakeFlow) GetDropReason() uint32
- func (f *FakeFlow) GetDropReasonDesc() flowpb.DropReason
- func (f *FakeFlow) GetEthernet() *flowpb.Ethernet
- func (f *FakeFlow) GetEventType() *flowpb.CiliumEventType
- func (f *FakeFlow) GetIP() *flowpb.IP
- func (f *FakeFlow) GetIsReply() *wrappers.BoolValue
- func (f *FakeFlow) GetL4() *flowpb.Layer4
- func (f *FakeFlow) GetL7() *flowpb.Layer7
- func (f *FakeFlow) GetNodeName() string
- func (f *FakeFlow) GetPolicyMatchType() uint32
- func (f *FakeFlow) GetSource() *flowpb.Endpoint
- func (f *FakeFlow) GetSourceNames() []string
- func (f *FakeFlow) GetSourceService() *flowpb.Service
- func (f *FakeFlow) GetSummary() string
- func (f *FakeFlow) GetTime() *timestamp.Timestamp
- func (f *FakeFlow) GetTrafficDirection() flowpb.TrafficDirection
- func (f *FakeFlow) GetType() flowpb.FlowType
- func (f *FakeFlow) GetVerdict() flowpb.Verdict
- func (f *FakeFlow) ProtoMessage()
- func (f *FakeFlow) Reset()
- func (f *FakeFlow) String() string
- type FakeGRPCClientStream
- func (c *FakeGRPCClientStream) CloseSend() error
- func (c *FakeGRPCClientStream) Context() context.Context
- func (c *FakeGRPCClientStream) Header() (metadata.MD, error)
- func (c *FakeGRPCClientStream) RecvMsg(m interface{}) error
- func (c *FakeGRPCClientStream) SendMsg(m interface{}) error
- func (c *FakeGRPCClientStream) Trailer() metadata.MD
- type FakeGRPCServerStream
- func (s *FakeGRPCServerStream) Context() context.Context
- func (s *FakeGRPCServerStream) RecvMsg(m interface{}) error
- func (s *FakeGRPCServerStream) SendHeader(m metadata.MD) error
- func (s *FakeGRPCServerStream) SendMsg(m interface{}) error
- func (s *FakeGRPCServerStream) SetHeader(m metadata.MD) error
- func (s *FakeGRPCServerStream) SetTrailer(m metadata.MD)
- type FakeGetFlowsClient
- type FakeGetFlowsServer
- type FakeIPGetter
- type FakeIdentityGetter
- type FakeObserverClient
- func (c *FakeObserverClient) GetFlows(ctx context.Context, in *observerpb.GetFlowsRequest, opts ...grpc.CallOption) (observerpb.Observer_GetFlowsClient, error)
- func (c *FakeObserverClient) ServerStatus(ctx context.Context, in *observerpb.ServerStatusRequest, ...) (*observerpb.ServerStatusResponse, error)
- type FakePeerClient
- type FakePeerClientBuilder
- type FakePeerListReporter
- type FakePeerNotifyClient
- type FakePeerNotifyServer
- type FakeServiceGetter
Constants ¶
This section is empty.
Variables ¶
var NoopDNSGetter = FakeFQDNCache{ OnGetNamesOf: func(sourceEpID uint32, ip net.IP) (fqdns []string) { return nil }, }
NoopDNSGetter always returns an empty response.
var NoopEndpointGetter = FakeEndpointGetter{ OnGetEndpointInfo: func(ip net.IP) (endpoint v1.EndpointInfo, ok bool) { return nil, false }, }
NoopEndpointGetter always returns an empty response.
var NoopIPGetter = FakeIPGetter{ OnGetK8sMetadata: func(ip net.IP) *ipcache.K8sMetadata { return nil }, OnLookupSecIDByIP: func(ip net.IP) (ipcache.Identity, bool) { return ipcache.Identity{}, false }, }
NoopIPGetter always returns an empty response.
var NoopIdentityGetter = FakeIdentityGetter{ OnGetIdentity: func(securityIdentity uint32) (*models.Identity, error) { return &models.Identity{}, nil }, }
NoopIdentityGetter always returns an empty response.
var NoopServiceGetter = FakeServiceGetter{ OnGetServiceByAddr: func(ip net.IP, port uint16) (service flowpb.Service, ok bool) { return flowpb.Service{}, false }, }
NoopServiceGetter always returns an empty response.
Functions ¶
func CreateL3L4Payload ¶
func CreateL3L4Payload(message interface{}, layers ...gopacket.SerializableLayer) ([]byte, error)
CreateL3L4Payload assembles a L3/L4 payload for testing purposes
func MustCreateL3L4Payload ¶
func MustCreateL3L4Payload(message interface{}, layers ...gopacket.SerializableLayer) []byte
MustCreateL3L4Payload wraps CreateL3L4Payload, but panics on error
Types ¶
type FakeClientConn ¶
type FakeClientConn struct {
OnGetState func() connectivity.State
OnClose func() error
OnInvoke func(ctx context.Context, method string, args interface{}, reply interface{}, opts ...grpc.CallOption) error
OnNewStream func(ctx context.Context, desc *grpc.StreamDesc, method string, opts ...grpc.CallOption) (grpc.ClientStream, error)
}
FakeClientConn is used for unit tests and implements the poolTypes.ClientConn interface.
func (FakeClientConn) Close ¶
func (c FakeClientConn) Close() error
Close implements poolTypes.ClientConn.Close.
func (FakeClientConn) GetState ¶
func (c FakeClientConn) GetState() connectivity.State
GetState implements poolTypes.ClientConn.GetState.
func (FakeClientConn) Invoke ¶
func (c FakeClientConn) Invoke(ctx context.Context, method string, args interface{}, reply interface{}, opts ...grpc.CallOption) error
Invoke implements poolTypes.ClientConn.Invoke.
func (FakeClientConn) NewStream ¶
func (c FakeClientConn) NewStream(ctx context.Context, desc *grpc.StreamDesc, method string, opts ...grpc.CallOption) (grpc.ClientStream, error)
NewStream implements poolTypes.ClientConn.NewStream.
type FakeEndpointGetter ¶
type FakeEndpointGetter struct {
OnGetEndpointInfo func(ip net.IP) (endpoint v1.EndpointInfo, ok bool)
}
FakeEndpointGetter is used for unit tests that needs EndpointGetter.
func (*FakeEndpointGetter) GetEndpointInfo ¶
func (f *FakeEndpointGetter) GetEndpointInfo(ip net.IP) (endpoint v1.EndpointInfo, ok bool)
GetEndpointInfo implements EndpointGetter.GetEndpointInfo.
type FakeEndpointInfo ¶
type FakeEndpointInfo struct {
ContainerIDs []string
ID uint64
Identity identity.NumericIdentity
IPv4 net.IP
IPv6 net.IP
PodName string
PodNamespace string
Labels []string
PolicyMap map[policy.Key]labels.LabelArrayList
PolicyRevision uint64
}
FakeEndpointInfo implements v1.EndpointInfo for unit tests. All interface methods return values exposed in the fields.
func (*FakeEndpointInfo) GetID ¶
func (e *FakeEndpointInfo) GetID() uint64
GetID returns the ID of the endpoint.
func (*FakeEndpointInfo) GetIdentity ¶
func (e *FakeEndpointInfo) GetIdentity() identity.NumericIdentity
GetIdentity returns the numerical security identity of the endpoint.
func (*FakeEndpointInfo) GetK8sNamespace ¶
func (e *FakeEndpointInfo) GetK8sNamespace() string
GetK8sNamespace returns the pod namespace of the endpoint.
func (*FakeEndpointInfo) GetK8sPodName ¶
func (e *FakeEndpointInfo) GetK8sPodName() string
GetK8sPodName returns the pod name of the endpoint.
func (*FakeEndpointInfo) GetLabels ¶
func (e *FakeEndpointInfo) GetLabels() []string
GetLabels returns the labels of the endpoint.
func (*FakeEndpointInfo) GetRealizedPolicyRuleLabelsForKey ¶
func (e *FakeEndpointInfo) GetRealizedPolicyRuleLabelsForKey(key policy.Key) ( derivedFrom labels.LabelArrayList, revision uint64, ok bool, )
type FakeFQDNCache ¶
type FakeFQDNCache struct {
OnInitializeFrom func(entries []*models.DNSLookup)
OnAddDNSLookup func(epID uint32, lookupTime time.Time, domainName string, ips []net.IP, ttl uint32)
OnGetNamesOf func(epID uint32, ip net.IP) []string
}
FakeFQDNCache is used for unit tests that needs FQDNCache and/or DNSGetter.
func (*FakeFQDNCache) AddDNSLookup ¶
func (f *FakeFQDNCache) AddDNSLookup(epID uint32, lookupTime time.Time, domainName string, ips []net.IP, ttl uint32)
AddDNSLookup implements FQDNCache.AddDNSLookup.
func (*FakeFQDNCache) GetNamesOf ¶
func (f *FakeFQDNCache) GetNamesOf(epID uint32, ip net.IP) []string
GetNamesOf implements FQDNCache.GetNameOf.
func (*FakeFQDNCache) InitializeFrom ¶
func (f *FakeFQDNCache) InitializeFrom(entries []*models.DNSLookup)
InitializeFrom implements FQDNCache.InitializeFrom.
type FakeFlow ¶ added in v1.8.0
type FakeFlow struct {
Time *timestamp.Timestamp
Verdict flowpb.Verdict
DropReason uint32
Ethernet *flowpb.Ethernet
IP *flowpb.IP
L4 *flowpb.Layer4
Source *flowpb.Endpoint
Destination *flowpb.Endpoint
Type flowpb.FlowType
NodeName string
SourceNames []string
DestinationNames []string
L7 *flowpb.Layer7
IsReply *wrappers.BoolValue
EventType *flowpb.CiliumEventType
SourceService *flowpb.Service
DestinationService *flowpb.Service
TrafficDirection flowpb.TrafficDirection
PolicyMatchType uint32
DropReasonDesc flowpb.DropReason
}
FakeFlow implements v1.Flow for unit tests. All interface methods return values exposed in the fields.
func (*FakeFlow) GetDestination ¶ added in v1.8.0
GetDestination implements v1.Flow for the FakeFlow.
func (*FakeFlow) GetDestinationNames ¶ added in v1.8.0
GetDestinationNames implements v1.Flow for the FakeFlow.
func (*FakeFlow) GetDestinationService ¶ added in v1.8.0
GetDestinationService implements v1.Flow for the FakeFlow.
func (*FakeFlow) GetDropReason ¶ added in v1.8.0
GetDropReason implements v1.Flow for the FakeFlow.
func (*FakeFlow) GetDropReasonDesc ¶ added in v1.9.0
func (f *FakeFlow) GetDropReasonDesc() flowpb.DropReason
GetDropReasonDesc implements v1.Flow for the FakeFlow.
func (*FakeFlow) GetEthernet ¶ added in v1.8.0
GetEthernet implements v1.Flow for the FakeFlow.
func (*FakeFlow) GetEventType ¶ added in v1.8.0
func (f *FakeFlow) GetEventType() *flowpb.CiliumEventType
GetEventType implements v1.Flow for the FakeFlow.
func (*FakeFlow) GetIsReply ¶ added in v1.8.6
GetIsReply implements v1.Flow for the FakeFlow.
func (*FakeFlow) GetNodeName ¶ added in v1.8.0
GetNodeName implements v1.Flow for the FakeFlow.
func (*FakeFlow) GetPolicyMatchType ¶ added in v1.8.0
GetPolicyMatchType implements v1.Flow for the FakeFlow.
func (*FakeFlow) GetSourceNames ¶ added in v1.8.0
GetSourceNames implements v1.Flow for the FakeFlow.
func (*FakeFlow) GetSourceService ¶ added in v1.8.0
GetSourceService implements v1.Flow for the FakeFlow.
func (*FakeFlow) GetSummary ¶ added in v1.8.0
GetSummary implements v1.Flow for the FakeFlow.
func (*FakeFlow) GetTrafficDirection ¶ added in v1.8.0
func (f *FakeFlow) GetTrafficDirection() flowpb.TrafficDirection
GetTrafficDirection implements v1.Flow for the FakeFlow.
func (*FakeFlow) GetVerdict ¶ added in v1.8.0
GetVerdict implements v1.Flow for the FakeFlow.
func (*FakeFlow) ProtoMessage ¶ added in v1.8.0
func (f *FakeFlow) ProtoMessage()
ProtoMessage implements flowpb.Message for the FakeFlow.
type FakeGRPCClientStream ¶
type FakeGRPCClientStream struct {
OnHeader func() (metadata.MD, error)
OnTrailer func() metadata.MD
OnCloseSend func() error
OnContext func() context.Context
OnSendMsg func(m interface{}) error
OnRecvMsg func(m interface{}) error
}
FakeGRPCClientStream implements google.golang.org/grpc.ClientStream interface for unit tests.
func (*FakeGRPCClientStream) CloseSend ¶
func (c *FakeGRPCClientStream) CloseSend() error
CloseSend implements grpc.ClientStream.CloseSend.
func (*FakeGRPCClientStream) Context ¶
func (c *FakeGRPCClientStream) Context() context.Context
Context implements grpc.ClientStream.Context.
func (*FakeGRPCClientStream) Header ¶
func (c *FakeGRPCClientStream) Header() (metadata.MD, error)
Header implements grpc.ClientStream.Header.
func (*FakeGRPCClientStream) RecvMsg ¶
func (c *FakeGRPCClientStream) RecvMsg(m interface{}) error
RecvMsg implements grpc.ClientStream.RecvMsg.
func (*FakeGRPCClientStream) SendMsg ¶
func (c *FakeGRPCClientStream) SendMsg(m interface{}) error
SendMsg implements grpc.ClientStream.SendMsg.
func (*FakeGRPCClientStream) Trailer ¶
func (c *FakeGRPCClientStream) Trailer() metadata.MD
Trailer implements grpc.ClientStream.Trailer.
type FakeGRPCServerStream ¶
type FakeGRPCServerStream struct {
OnSetHeader func(metadata.MD) error
OnSendHeader func(metadata.MD) error
OnSetTrailer func(m metadata.MD)
OnContext func() context.Context
OnSendMsg func(m interface{}) error
OnRecvMsg func(m interface{}) error
}
FakeGRPCServerStream implements google.golang.org/grpc.ServerStream interface for unit tests.
func (*FakeGRPCServerStream) Context ¶
func (s *FakeGRPCServerStream) Context() context.Context
Context implements grpc.ServerStream.Context.
func (*FakeGRPCServerStream) RecvMsg ¶
func (s *FakeGRPCServerStream) RecvMsg(m interface{}) error
RecvMsg implements grpc.ServerStream.RecvMsg.
func (*FakeGRPCServerStream) SendHeader ¶
func (s *FakeGRPCServerStream) SendHeader(m metadata.MD) error
SendHeader implements grpc.ServerStream.SendHeader.
func (*FakeGRPCServerStream) SendMsg ¶
func (s *FakeGRPCServerStream) SendMsg(m interface{}) error
SendMsg implements grpc.ServerStream.SendMsg.
func (*FakeGRPCServerStream) SetHeader ¶
func (s *FakeGRPCServerStream) SetHeader(m metadata.MD) error
SetHeader implements grpc.ServerStream.SetHeader.
func (*FakeGRPCServerStream) SetTrailer ¶
func (s *FakeGRPCServerStream) SetTrailer(m metadata.MD)
SetTrailer implements grpc.ServerStream.SetTrailer.
type FakeGetFlowsClient ¶
type FakeGetFlowsClient struct {
OnRecv func() (*observerpb.GetFlowsResponse, error)
*FakeGRPCClientStream
}
FakeGetFlowsClient is used for unit tests and implements the observerpb.Observer_GetFlowsClient interface.
func (*FakeGetFlowsClient) Recv ¶
func (c *FakeGetFlowsClient) Recv() (*observerpb.GetFlowsResponse, error)
Recv implements observerpb.Observer_GetFlowsClient.Recv.
type FakeGetFlowsServer ¶
type FakeGetFlowsServer struct {
OnSend func(response *observerpb.GetFlowsResponse) error
*FakeGRPCServerStream
}
FakeGetFlowsServer is used for unit tests and implements the observerpb.Observer_GetFlowsServer interface.
func (*FakeGetFlowsServer) Send ¶
func (s *FakeGetFlowsServer) Send(response *observerpb.GetFlowsResponse) error
Send implements observerpb.Observer_GetFlowsServer.Send.
type FakeIPGetter ¶
type FakeIPGetter struct {
OnGetK8sMetadata func(ip net.IP) *ipcache.K8sMetadata
OnLookupSecIDByIP func(ip net.IP) (ipcache.Identity, bool)
}
FakeIPGetter is used for unit tests that needs IPGetter.
func (*FakeIPGetter) GetK8sMetadata ¶
func (f *FakeIPGetter) GetK8sMetadata(ip net.IP) *ipcache.K8sMetadata
GetK8sMetadata implements FakeIPGetter.GetK8sMetadata.
func (*FakeIPGetter) LookupSecIDByIP ¶
LookupSecIDByIP implements FakeIPGetter.LookupSecIDByIP.
type FakeIdentityGetter ¶
type FakeIdentityGetter struct {
OnGetIdentity func(securityIdentity uint32) (*models.Identity, error)
}
FakeIdentityGetter is used for unit tests that need IdentityGetter.
func (*FakeIdentityGetter) GetIdentity ¶
func (f *FakeIdentityGetter) GetIdentity(securityIdentity uint32) (*models.Identity, error)
GetIdentity implements IdentityGetter.GetIPIdentity.
type FakeObserverClient ¶
type FakeObserverClient struct {
OnGetFlows func(ctx context.Context, in *observerpb.GetFlowsRequest, opts ...grpc.CallOption) (observerpb.Observer_GetFlowsClient, error)
OnServerStatus func(ctx context.Context, in *observerpb.ServerStatusRequest, opts ...grpc.CallOption) (*observerpb.ServerStatusResponse, error)
}
FakeObserverClient is used for unit tests and implements the observerpb.ObserverClient interface.
func (*FakeObserverClient) GetFlows ¶
func (c *FakeObserverClient) GetFlows(ctx context.Context, in *observerpb.GetFlowsRequest, opts ...grpc.CallOption) (observerpb.Observer_GetFlowsClient, error)
GetFlows implements observerpb.ObserverClient.GetFlows.
func (*FakeObserverClient) ServerStatus ¶
func (c *FakeObserverClient) ServerStatus(ctx context.Context, in *observerpb.ServerStatusRequest, opts ...grpc.CallOption) (*observerpb.ServerStatusResponse, error)
ServerStatus implements observerpb.ObserverClient.ServerStatus.
type FakePeerClient ¶
type FakePeerClient struct {
OnNotify func(ctx context.Context, in *peerpb.NotifyRequest, opts ...grpc.CallOption) (peerpb.Peer_NotifyClient, error)
OnClose func() error
}
FakePeerClient is used for unit tests and implements the peerTypes.Client interface.
func (*FakePeerClient) Close ¶
func (c *FakePeerClient) Close() error
Close implements peerTypes.Client.Close.
func (*FakePeerClient) Notify ¶
func (c *FakePeerClient) Notify(ctx context.Context, in *peerpb.NotifyRequest, opts ...grpc.CallOption) (peerpb.Peer_NotifyClient, error)
Notify implements peerTypes.Client.Notify.
type FakePeerClientBuilder ¶
FakePeerClientBuilder is used for unit tests and implements the peerTypes.ClientBuilder interface.
type FakePeerListReporter ¶
type FakePeerListReporter struct {
OnList func() []poolTypes.Peer
OnReportOffline func(name string)
}
FakePeerListReporter is used for unit tests and implements the relay/observer.PeerListReporter interface.
func (*FakePeerListReporter) List ¶
func (r *FakePeerListReporter) List() []poolTypes.Peer
List implements relay/observer.PeerListReporter.List.
func (*FakePeerListReporter) ReportOffline ¶
func (r *FakePeerListReporter) ReportOffline(name string)
ReportOffline implements relay/observer.PeerListReporter.ReportOffline.
type FakePeerNotifyClient ¶
type FakePeerNotifyClient struct {
OnRecv func() (*peerpb.ChangeNotification, error)
*FakeGRPCClientStream
}
FakePeerNotifyClient is used for unit tests and implements the peerpb.Peer_NotifyClient interface.
func (*FakePeerNotifyClient) Recv ¶
func (c *FakePeerNotifyClient) Recv() (*peerpb.ChangeNotification, error)
Recv implements peerpb.Peer_NotifyClient.Recv.
type FakePeerNotifyServer ¶
type FakePeerNotifyServer struct {
OnSend func(response *peerpb.ChangeNotification) error
*FakeGRPCServerStream
}
FakePeerNotifyServer is used for unit tests and implements the peerpb.Peer_NotifyServer interface.
func (*FakePeerNotifyServer) Send ¶
func (s *FakePeerNotifyServer) Send(response *peerpb.ChangeNotification) error
Send implements peerpb.Peer_NotifyServer.Send.
type FakeServiceGetter ¶
type FakeServiceGetter struct {
OnGetServiceByAddr func(ip net.IP, port uint16) (service flowpb.Service, ok bool)
}
FakeServiceGetter is used for unit tests that need ServiceGetter.
func (*FakeServiceGetter) GetServiceByAddr ¶
func (f *FakeServiceGetter) GetServiceByAddr(ip net.IP, port uint16) (service flowpb.Service, ok bool)
GetServiceByAddr implements FakeServiceGetter.GetServiceByAddr.