mirror of
https://github.com/vmware-tanzu/pinniped.git
synced 2026-01-07 05:57:02 +00:00
Add tests for the new cert controllers and some other small refactorings
- Add a unit test for each cert controller - Make DynamicTLSServingCertProvider an interface and use a mutex internally - Create a shared ToPEM function instead of having two very similar functions - Move the ObservableWithInformerOption test helper to testutils - Rename some variables and imports
This commit is contained in:
30
internal/testutil/observable_with_informer_option.go
Normal file
30
internal/testutil/observable_with_informer_option.go
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
Copyright 2020 VMware, Inc.
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package testutil
|
||||
|
||||
import "github.com/suzerain-io/controller-go"
|
||||
|
||||
type ObservableWithInformerOption struct {
|
||||
InformerToFilterMap map[controller.InformerGetter]controller.Filter
|
||||
}
|
||||
|
||||
func NewObservableWithInformerOption() *ObservableWithInformerOption {
|
||||
return &ObservableWithInformerOption{
|
||||
InformerToFilterMap: make(map[controller.InformerGetter]controller.Filter),
|
||||
}
|
||||
}
|
||||
|
||||
func (i *ObservableWithInformerOption) WithInformer(
|
||||
getter controller.InformerGetter,
|
||||
filter controller.Filter,
|
||||
opt controller.InformerOption) controller.Option {
|
||||
i.InformerToFilterMap[getter] = filter
|
||||
return controller.WithInformer(getter, filter, opt)
|
||||
}
|
||||
|
||||
func (i *ObservableWithInformerOption) GetFilterForInformer(getter controller.InformerGetter) controller.Filter {
|
||||
return i.InformerToFilterMap[getter]
|
||||
}
|
||||
Reference in New Issue
Block a user