-
Notifications
You must be signed in to change notification settings - Fork 169
/
config.go
53 lines (42 loc) · 1.43 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
44
45
46
47
48
49
50
51
52
53
package v1alpha1
import "strings"
// New creates a new Config object with internal values already set
func New() *Config {
c := Config{}
// constants
c.APIVersion = "tanka.dev/v1alpha1"
c.Kind = "Environment"
// defaults
c.Spec.Namespace = "default"
c.Spec.InjectLabels.Environment = true
c.Metadata.Labels = make(map[string]string)
return &c
}
// Config holds the configuration variables for config version v1alpha1
// ApiVersion and Kind are currently unused, this may change in the future.
type Config struct {
APIVersion string `json:"apiVersion"`
Kind string `json:"kind"`
Metadata Metadata `json:"metadata"`
Spec Spec `json:"spec"`
}
// Metadata is meant for humans and not parsed Name is an exception to this
// rule, as it's value is discovered at runtime from the directories name.
type Metadata struct {
Name string `json:"name,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
}
func (m Metadata) NameLabel() string {
return strings.Replace(m.Name, "/", ".", -1)
}
// Spec defines Kubernetes properties
type Spec struct {
APIServer string `json:"apiServer"`
Namespace string `json:"namespace"`
DiffStrategy string `json:"diffStrategy,omitempty"`
InjectLabels InjectLabels `json:"injectLabels,omitempty"`
}
// InjectLabels defines labels that Tanka will inject into manifests
type InjectLabels struct {
Environment bool `json:"environment,omitempty"`
}