-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.go
72 lines (58 loc) · 1.36 KB
/
types.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
package ezdeploy
import "encoding/json"
// Helm
type Chart struct {
Name string
Path string
Checksum string
}
type Release struct {
ID string
Name string
Chart Chart
ValuesFile string
Checksum string
}
func CreateReleaseID(namespace string, name string) string {
return namespace + "::" + "Helm" + "::" + name
}
// List
type List struct {
APIVersion string `json:"apiVersion"`
Kind string `json:"kind"`
Items []json.RawMessage `json:"items"`
}
func NewList(items []json.RawMessage) *List {
return &List{
APIVersion: "v1",
Kind: "List",
Items: items,
}
}
func (l List) Valid() bool {
return l.APIVersion == "v1" && l.Kind == "List"
}
// Resource
type Resource struct {
ID string
Namespace string
Object Object
Raw json.RawMessage
Checksum string
Path string
}
type ObjectMeta struct {
Name string `json:"name,omitempty"`
Namespace string `json:"namespace,omitempty"`
}
type Object struct {
Metadata ObjectMeta `json:"metadata"`
Kind string `json:"kind"`
APIVersion string `json:"apiVersion"`
}
func CreateResourceID(namespace string, object Object) string {
if object.Metadata.Namespace != "" {
namespace = object.Metadata.Namespace
}
return namespace + "::" + object.APIVersion + "/" + object.Kind + "/" + object.Metadata.Name
}