-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
manager_options_test.go
54 lines (43 loc) · 1.29 KB
/
manager_options_test.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
package manager
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"sigs.k8s.io/controller-runtime/pkg/config"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
configv1alpha1 "sigs.k8s.io/controller-runtime/pkg/config/v1alpha1"
)
var _ = Describe("manager.Options", func() {
Describe("AndFrom", func() {
Describe("reading custom type using OfKind", func() {
var (
o Options
c customConfig
err error
)
JustBeforeEach(func() {
s := runtime.NewScheme()
o = Options{Scheme: s}
c = customConfig{}
_, err = o.AndFrom(config.File().AtPath("./testdata/custom-config.yaml").OfKind(&c))
})
It("should not panic or fail", func() {
Expect(err).To(Succeed())
})
It("should set custom properties", func() {
Expect(c.CustomValue).To(Equal("foo"))
})
})
})
})
type customConfig struct {
metav1.TypeMeta `json:",inline"`
configv1alpha1.ControllerManagerConfigurationSpec `json:",inline"`
CustomValue string `json:"customValue"`
}
func (in *customConfig) DeepCopyObject() runtime.Object {
out := &customConfig{}
*out = *in
in.ControllerManagerConfigurationSpec.DeepCopyInto(&out.ControllerManagerConfigurationSpec)
return out
}