github.com/cilium/cilium@v1.16.2/operator/auth/spire/fake_client.go (about) 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright Authors of Cilium 3 4 package spire 5 6 import ( 7 "context" 8 9 "github.com/cilium/cilium/operator/auth/identity" 10 ) 11 12 // NewFakeClient creates a new fake SPIRE client. 13 func NewFakeClient() identity.Provider { 14 return fakeClient{ 15 ids: map[string]struct{}{}, 16 } 17 } 18 19 type fakeClient struct { 20 ids map[string]struct{} 21 } 22 23 func (n fakeClient) Upsert(_ context.Context, id string) error { 24 n.ids[id] = struct{}{} 25 return nil 26 } 27 28 func (n fakeClient) Delete(_ context.Context, id string) error { 29 delete(n.ids, id) 30 return nil 31 } 32 33 func (n fakeClient) List(_ context.Context) ([]string, error) { 34 ids := make([]string, 0, len(n.ids)) 35 for id := range n.ids { 36 ids = append(ids, id) 37 } 38 return ids, nil 39 }