github.com/cilium/cilium@v1.16.2/pkg/testutils/ipcache/ipcache.go (about) 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright Authors of Cilium 3 4 package testipcache 5 6 import ( 7 "context" 8 "net" 9 "net/netip" 10 11 "github.com/cilium/cilium/pkg/identity" 12 "github.com/cilium/cilium/pkg/ipcache" 13 ipcacheTypes "github.com/cilium/cilium/pkg/ipcache/types" 14 "github.com/cilium/cilium/pkg/labels" 15 "github.com/cilium/cilium/pkg/source" 16 "github.com/cilium/cilium/pkg/types" 17 ) 18 19 type MockIPCache struct{} 20 21 func (m *MockIPCache) GetNamedPorts() types.NamedPortMultiMap { 22 return nil 23 } 24 25 func (m *MockIPCache) AddListener(listener ipcache.IPIdentityMappingListener) {} 26 27 func (m *MockIPCache) AllocateCIDRs(prefixes []netip.Prefix, newlyAllocatedIdentities map[netip.Prefix]*identity.Identity) ([]*identity.Identity, error) { 28 return nil, nil 29 } 30 31 func (m *MockIPCache) ReleaseCIDRIdentitiesByCIDR(prefixes []netip.Prefix) {} 32 33 func (m *MockIPCache) LookupByIP(IP string) (ipcache.Identity, bool) { 34 return ipcache.Identity{}, false 35 } 36 37 func (m *MockIPCache) Upsert(ip string, hostIP net.IP, hostKey uint8, k8sMeta *ipcache.K8sMetadata, newIdentity ipcache.Identity) (namedPortsChanged bool, err error) { 38 return false, nil 39 } 40 41 func (m *MockIPCache) Delete(IP string, source source.Source) (namedPortsChanged bool) { 42 return false 43 } 44 45 func (m *MockIPCache) UpsertLabels(prefix netip.Prefix, lbls labels.Labels, src source.Source, resource ipcacheTypes.ResourceID) { 46 } 47 48 func (m *MockIPCache) RemoveLabelsExcluded(lbls labels.Labels, toExclude map[netip.Prefix]struct{}, resource ipcacheTypes.ResourceID) { 49 } 50 51 func (m *MockIPCache) DeleteOnMetadataMatch(IP string, source source.Source, namespace, name string) (namedPortsChanged bool) { 52 return false 53 } 54 55 func (m *MockIPCache) UpsertPrefixes(prefixes []netip.Prefix, src source.Source, resource ipcacheTypes.ResourceID) uint64 { 56 return 0 57 } 58 59 func (m *MockIPCache) RemovePrefixes(prefixes []netip.Prefix, src source.Source, resource ipcacheTypes.ResourceID) { 60 } 61 62 func (m *MockIPCache) UpsertMetadataBatch(updates ...ipcache.MU) (revision uint64) { 63 return 0 64 } 65 66 func (m *MockIPCache) RemoveMetadataBatch(updates ...ipcache.MU) (revision uint64) { 67 return 0 68 } 69 70 func (m *MockIPCache) WaitForRevision(ctx context.Context, rev uint64) error { 71 return nil 72 } 73 74 func NewMockIPCache() *MockIPCache { 75 return &MockIPCache{} 76 }