-
Notifications
You must be signed in to change notification settings - Fork 2.9k
/
getters.go
67 lines (56 loc) · 2.13 KB
/
getters.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// SPDX-License-Identifier: Apache-2.0
// Copyright 2019 Authors of Hubble
package getters
import (
"net"
"k8s.io/client-go/tools/cache"
flowpb "github.com/cilium/cilium/api/v1/flow"
"github.com/cilium/cilium/api/v1/models"
v1 "github.com/cilium/cilium/pkg/hubble/api/v1"
"github.com/cilium/cilium/pkg/ipcache"
"github.com/cilium/cilium/pkg/policy"
)
// DNSGetter ...
type DNSGetter interface {
// GetNamesOf fetches FQDNs of a given IP from the perspective of
// the endpoint with ID sourceEpID. The returned names must not have
// trailing dots.
GetNamesOf(sourceEpID uint32, ip net.IP) (names []string)
}
// EndpointGetter ...
type EndpointGetter interface {
// GetEndpointInfo looks up endpoint by IP address.
GetEndpointInfo(ip net.IP) (endpoint v1.EndpointInfo, ok bool)
// GetEndpointInfo looks up endpoint by id
GetEndpointInfoByID(id uint16) (endpoint v1.EndpointInfo, ok bool)
}
type EndpointsGetter interface {
// GetEndpoints returns a map of the current policy.Endpoint(s).
GetEndpoints() map[policy.Endpoint]struct{}
}
// IdentityGetter ...
type IdentityGetter interface {
// GetIdentity fetches a full identity object given a numeric security id.
GetIdentity(id uint32) (*models.Identity, error)
}
// IPGetter fetches per-IP metadata
type IPGetter interface {
// GetK8sMetadata returns Kubernetes metadata for the given IP address.
GetK8sMetadata(ip net.IP) *ipcache.K8sMetadata
// LookupSecIDByIP returns the corresponding security identity that
// endpoint IP maps to as well as if the corresponding entry exists.
LookupSecIDByIP(ip net.IP) (ipcache.Identity, bool)
}
// ServiceGetter fetches service metadata.
type ServiceGetter interface {
GetServiceByAddr(ip net.IP, port uint16) *flowpb.Service
}
// StoreGetter ...
type StoreGetter interface {
// GetK8sStore return the k8s watcher cache store for the given resource name.
// Currently only resource networkpolicy and namespace are supported.
// WARNING: the objects returned by these stores can't be used to create
// update objects into k8s as well as the objects returned by these stores
// should only be used for reading.
GetK8sStore(name string) cache.Store
}