-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathstructed.go
80 lines (70 loc) · 1.64 KB
/
structed.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
package kubernetes
import (
"encoding/json"
coreV1 "k8s.io/api/core/v1"
rbacV1 "k8s.io/api/rbac/v1"
)
func StructedPod(data []byte) (*coreV1.Pod, error) {
pod := &coreV1.Pod{}
err := json.Unmarshal(data, pod)
if err != nil {
return nil, err
}
return pod, nil
}
func StructedService(data []byte) (*coreV1.Service, error) {
service := &coreV1.Service{}
err := json.Unmarshal(data, service)
if err != nil {
return nil, err
}
return service, nil
}
func StructedNode(data []byte) (*coreV1.Node, error) {
node := &coreV1.Node{}
err := json.Unmarshal(data, node)
if err != nil {
return nil, err
}
return node, nil
}
func StructedSecret(data []byte) (*coreV1.Secret, error) {
secret := &coreV1.Secret{}
err := json.Unmarshal(data, secret)
if err != nil {
return nil, err
}
return secret, nil
}
func StructedRole(data []byte) (*rbacV1.Role, error) {
role := &rbacV1.Role{}
err := json.Unmarshal(data, role)
if err != nil {
return nil, err
}
return role, nil
}
func StructedRoleBinding(data []byte) (*rbacV1.RoleBinding, error) {
roleBinding := &rbacV1.RoleBinding{}
err := json.Unmarshal(data, roleBinding)
if err != nil {
return nil, err
}
return roleBinding, nil
}
func StructedClusterRole(data []byte) (*rbacV1.ClusterRole, error) {
clusterRole := &rbacV1.ClusterRole{}
err := json.Unmarshal(data, clusterRole)
if err != nil {
return nil, err
}
return clusterRole, nil
}
func StructedClusterRoleBinding(data []byte) (*rbacV1.ClusterRoleBinding, error) {
clusterRoleBinding := &rbacV1.ClusterRoleBinding{}
err := json.Unmarshal(data, clusterRoleBinding)
if err != nil {
return nil, err
}
return clusterRoleBinding, nil
}