forked from argoproj/gitops-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
testdata.go
91 lines (82 loc) · 1.6 KB
/
testdata.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
package testing
import (
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
)
const (
FakeArgoCDNamespace = "fake-argocd-ns"
)
func HelmHook(obj *unstructured.Unstructured, hookType string) *unstructured.Unstructured {
return Annotate(obj, "helm.sh/hook", hookType)
}
func Annotate(obj *unstructured.Unstructured, key, val string) *unstructured.Unstructured {
annotations := obj.GetAnnotations()
if annotations == nil {
annotations = map[string]string{}
}
annotations[key] = val
obj.SetAnnotations(annotations)
return obj
}
var PodManifest = `
{
"apiVersion": "v1",
"kind": "Pod",
"metadata": {
"name": "my-pod"
},
"spec": {
"containers": [
{
"image": "nginx:1.7.9",
"name": "nginx",
"resources": {
"requests": {
"cpu": 0.2
}
}
}
]
}
}
`
func NewPod() *unstructured.Unstructured {
return Unstructured(PodManifest)
}
var ServiceManifest = `
{
"apiVersion": "v1",
"kind": "Service",
"metadata": {
"name": "my-service"
},
"spec": {
"ports": [
{
"name": "http",
"protocol": "TCP",
"port": 80,
"targetPort": 8080
}
],
"selector": {
"app": "my-service"
}
}
}
`
func NewService() *unstructured.Unstructured {
return Unstructured(ServiceManifest)
}
func NewCRD() *unstructured.Unstructured {
return Unstructured(`apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: testcrds.argoproj.io
spec:
group: argoproj.io
version: v1
scope: Namespaced
names:
plural: testcrds
kind: TestCrd`)
}