github.com/cilium/cilium@v1.16.2/pkg/maps/ctmap/fake/per_cluster.go (about) 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright Authors of Cilium 3 4 package ctmap 5 6 import ( 7 "k8s.io/apimachinery/pkg/util/sets" 8 9 "github.com/cilium/cilium/pkg/lock" 10 "github.com/cilium/cilium/pkg/maps/ctmap" 11 ) 12 13 // A structure that implements PerClusterCTMapper for testing purposes. 14 type PerClusterMaps struct { 15 lock.RWMutex 16 ids sets.Set[uint32] 17 } 18 19 var _ ctmap.PerClusterCTMapper = (*PerClusterMaps)(nil) 20 21 func NewPerClusterMaps() *PerClusterMaps { 22 return &PerClusterMaps{ids: sets.New[uint32]()} 23 } 24 25 func (maps *PerClusterMaps) OpenOrCreate() error { return nil } 26 func (maps *PerClusterMaps) Close() error { return nil } 27 28 func (maps *PerClusterMaps) GetAllClusterCTMaps() []*ctmap.Map { return nil } 29 30 func (maps *PerClusterMaps) CreateClusterCTMaps(clusterID uint32) error { 31 maps.Lock() 32 defer maps.Unlock() 33 maps.ids.Insert(clusterID) 34 return nil 35 } 36 37 func (maps *PerClusterMaps) DeleteClusterCTMaps(clusterID uint32) error { 38 maps.Lock() 39 defer maps.Unlock() 40 maps.ids.Delete(clusterID) 41 return nil 42 } 43 44 func (maps *PerClusterMaps) Has(clusterID uint32) bool { 45 maps.RLock() 46 defer maps.RUnlock() 47 return maps.ids.Has(clusterID) 48 }