-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.go
43 lines (38 loc) · 1.33 KB
/
config.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
package handlers
import (
"encoding/json"
"fmt"
"io/ioutil"
k8sv1 "k8s.io/api/core/v1"
)
// Container Struct to hold the configuration for Job Container
type Container struct {
Name string `json:"name"`
Image string `json:"image"`
PullPolicy k8sv1.PullPolicy `json:"pull_policy"`
Env []k8sv1.EnvVar `json:"env"`
VolumesMounts []k8sv1.VolumeMount `json:"volumeMounts"`
Labels map[string]string `json:"labels"`
CPULimit string `json:"cpu-limit"`
MemoryLimit string `json:"memory-limit"`
}
// SowerConfig Struct to hold all the configuration
type SowerConfig struct {
Name string `json:"name"`
Action string `json:"action"`
Container Container `json:"container"`
Volumes []k8sv1.Volume `json:"volumes"`
RestartPolicy k8sv1.RestartPolicy `json:"restart_policy"`
ServiceAccountName *string `json:"serviceAccountName"`
ActiveDeadlineSeconds *int64 `json:"activeDeadlineSeconds"`
}
func loadSowerConfigs(config string) []SowerConfig {
plan, _ := ioutil.ReadFile(config)
var data []SowerConfig
err := json.Unmarshal(plan, &data)
if err != nil {
fmt.Println("ERROR: ", err)
return nil
}
return data
}