-
Notifications
You must be signed in to change notification settings - Fork 1
/
models.go
151 lines (133 loc) · 5.15 KB
/
models.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
package main
import (
"strings"
)
type configType int
const (
typeSK8 configType = 1
typeKubectl configType = 2
)
// SK8config s the root of the YAML config for a service
type SK8config struct {
Name string `json:"name,omitempty"`
Namespace string `json:"namespace,omitempty"`
Site string `json:"site,omitempty"`
Image string `json:"image,omitempty"`
Version string `json:"version,omitempty"`
ImageVersion *string `json:"imageversion,omitempty"`
Registry Registry `json:"registry,omitempty"`
Args []string `json:"args,omitempty"`
Port int `json:"port,omitempty"`
Parents []string `json:"parents,omitempty"`
Custom interface{} `json:"custom,omitempty"`
Notes map[string]string `json:"notes,omitempty"`
Tags map[string]string `json:"tags,omitempty"`
Annotations map[string]string `json:"annotations,omitempty"`
Limits *Limits `json:"limits,omitempty"`
Extra Extra `json:"extra,omitempty"`
Env EnvMap `json:"env,omitempty"`
Volume []VolumeType `json:"volume,omitempty"`
Templates map[string]string `json:"templates,omitempty"`
Features []string `json:"features,omitempty"`
Override *SK8config `json:"override,omitempty"`
NodeSelectors map[string]string `json:"nodeSelectors,omitempty"`
Tolerations []Toleration `json:"tolerations,omitempty"`
cfgType configType
Kind string `json:"kind,omitempty"`
RawMetadata *rawMetadata `json:"metadata,omitempty"`
RawYAML []byte `json:"rawYaml,omitempty"`
Containers []Container `json:"containers,omitempty"`
}
type rawMetadata struct {
Name string `json:"name,omitempty"`
Namespace string `json:"namespace,omitempty"`
}
type Limits struct {
Request ResourceLimit `json:"request,omitempty"`
Limit ResourceLimit `json:"limit,omitempty"`
}
type ResourceLimit struct {
CPU string `json:"cpu,omitempty"`
Memory string `json:"memory,omitempty"`
}
type Container struct {
Name string `json:"name"`
Image string `json:"image,omitempty"`
Ports map[string]int `json:"ports,omitempty"`
Args []string `json:"args,omitempty"`
Env EnvMap `json:"env,omitempty"`
Liveness *Probe `json:"liveness,omitempty"`
Readyness *Probe `json:"readyness,omitempty"`
Volume []VolumeType `json:"volume,omitempty"`
Limits *Limits `json:"limits,omitempty"`
}
type Toleration struct {
Key string `json:"key,omitempty"`
Operator string `json:"operator"`
Value string `json:"value,omitempty"`
Effect string `json:"effect,omitempty"`
}
// HasFeature is a helper for the templating to test if a feature is used or not
func (sk8 *SK8config) HasFeature(feat string) bool {
if sk8.Features == nil {
return false
}
for _, f := range sk8.Features {
if strings.EqualFold(feat, f) {
return true
}
}
return false
}
// Registry is used to specified the Docker-image source
type Registry struct {
Host string `json:"host,omitempty"`
Path string `json:"path,omitempty"`
}
// EnvMap contains all the Enviroment-settings for the service, for all sources
type EnvMap struct {
Values map[string]string `json:"values,omitempty"`
Config map[string]EnvConfig `json:"config,omitempty"`
Secret map[string]EnvConfig `json:"secret,omitempty"`
Fields map[string]string `json:"fields,omitempty"`
}
// EnvConfig contains name and key for mapping env-vars from ConfigMaps and Secrets
type EnvConfig struct {
Name string `json:"name,omitempty"`
Key string `json:"key,omitempty"`
}
// Extra has properties for replica-count, history-length and probes
type Extra struct {
Replicas *int `json:"replicas,omitempty"`
History *int `json:"history,omitempty"`
Liveness *Probe `json:"liveness,omitempty"`
Readyness *Probe `json:"readyness,omitempty"`
}
// Probe describes the liveness/readyness-probe definition
type Probe struct {
Path string `json:"path,omitempty"`
Port *int `json:"port,omitempty"`
InitialDelaySeconds *int `json:"initialDelaySeconds,omitempty"`
TimeoutSeconds *int `json:"timeoutSeconds,omitempty"`
PeriodSeconds *int `json:"periodSeconds,omitempty"`
}
// VolumeType is how to get a "file" in the pod from various sources
type VolumeType struct {
Name string `json:"name,omitempty"`
Path string `json:"path,omitempty"`
HostDir string `json:"hostdir,omitempty"`
HostFile string `json:"hostfile,omitempty"`
ReadOnly bool `json:"readonly,omitempty"`
EmptyDir bool `json:"empty,omitempty"`
Config *VolumeSource `json:"config,omitempty"`
Secret *VolumeSource `json:"secret,omitempty"`
}
// VolumeSource is what files to actually map from a source-definition
type VolumeSource struct {
Name string `json:"name,omitempty"`
Items map[string]string `json:"items,omitempty"`
}
// type VolumeConfigItem struct {
// Key string `json:"key,omitempty"`
// Path string `json:"path,omitempty"`
// }