-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathresources.go
99 lines (85 loc) · 2.09 KB
/
resources.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package test
import (
imagev1 "github.com/fluxcd/image-reflector-controller/api/v1beta2"
sourcev1beta2 "github.com/fluxcd/source-controller/api/v1beta2"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
const testNamespace = "default"
// NewImagePolicy creates and returns a new Flux ImagePolicy.
func NewImagePolicy(opts ...func(*imagev1.ImagePolicy)) *imagev1.ImagePolicy {
ip := &imagev1.ImagePolicy{
TypeMeta: metav1.TypeMeta{
APIVersion: "image.toolkit.fluxcd.io/v1beta2",
Kind: "ImagePolicy",
},
ObjectMeta: metav1.ObjectMeta{
Name: "test-policy",
Namespace: testNamespace,
},
}
for _, opt := range opts {
opt(ip)
}
return ip
}
// NewConfigMap creates and returns a new ConfigMap.
func NewConfigMap(opts ...func(*corev1.ConfigMap)) *corev1.ConfigMap {
cm := &corev1.ConfigMap{
TypeMeta: metav1.TypeMeta{
APIVersion: "v1",
Kind: "ConfigMap",
},
ObjectMeta: metav1.ObjectMeta{
Name: "demo-cm",
Namespace: "default",
},
Data: map[string]string{
"testing": "test",
},
}
for _, o := range opts {
o(cm)
}
return cm
}
// NewSecret creates and returns a new Secret.
func NewSecret(opts ...func(*corev1.Secret)) *corev1.Secret {
cm := &corev1.Secret{
TypeMeta: metav1.TypeMeta{
APIVersion: "v1",
Kind: "Secret",
},
ObjectMeta: metav1.ObjectMeta{
Name: "demo-secret",
Namespace: "default",
},
Data: map[string][]byte{
"testing": []byte("test"),
},
}
for _, o := range opts {
o(cm)
}
return cm
}
// NewGitRepository creates and returns a new GitRepository.
func NewGitRepository(opts ...func(*sourcev1beta2.GitRepository)) *sourcev1beta2.GitRepository {
gr := &sourcev1beta2.GitRepository{
TypeMeta: metav1.TypeMeta{
APIVersion: "source.toolkit.fluxcd.io/v1beta2",
Kind: "GitRepository",
},
ObjectMeta: metav1.ObjectMeta{
Name: "test-repository",
Namespace: testNamespace,
},
Spec: sourcev1beta2.GitRepositorySpec{
URL: "https://github.com/weaveworks/gitopssets-controller",
},
}
for _, opt := range opts {
opt(gr)
}
return gr
}