-
Notifications
You must be signed in to change notification settings - Fork 173
/
namespace.go
67 lines (61 loc) · 2.41 KB
/
namespace.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
package main
import (
"fmt"
)
// resources type
type resources struct {
CPU string `yaml:"cpu,omitempty"`
Memory string `yaml:"memory,omitempty"`
}
// limits type
type limits []struct {
Max resources `yaml:"max,omitempty"`
Min resources `yaml:"min,omitempty"`
Default resources `yaml:"default,omitempty"`
DefaultRequest resources `yaml:"defaultRequest,omitempty"`
MaxLimitRequestRatio resources `yaml:"maxLimitRequestRatio,omitempty"`
LimitType string `yaml:"type"`
}
// namespace type represents the fields of a namespace
type namespace struct {
Protected bool `yaml:"protected"`
InstallTiller bool `yaml:"installTiller"`
UseTiller bool `yaml:"useTiller"`
TillerServiceAccount string `yaml:"tillerServiceAccount"`
TillerRole string `yaml:"tillerRole"`
TillerRoleTemplateFile string `yaml:"tillerRoleTemplateFile"`
TillerMaxHistory int `yaml:"tillerMaxHistory"`
CaCert string `yaml:"caCert"`
TillerCert string `yaml:"tillerCert"`
TillerKey string `yaml:"tillerKey"`
ClientCert string `yaml:"clientCert"`
ClientKey string `yaml:"clientKey"`
Limits limits `yaml:"limits,omitempty"`
Labels map[string]string `yaml:"labels"`
Annotations map[string]string `yaml:"annotations"`
}
// checkNamespaceDefined checks if a given namespace is defined in the namespaces section of the desired state file
func checkNamespaceDefined(ns string, s state) bool {
_, ok := s.Namespaces[ns]
if !ok {
return false
}
return true
}
// print prints the namespace
func (n namespace) print() {
fmt.Println("")
fmt.Println("\tprotected : ", n.Protected)
fmt.Println("\tinstallTiller : ", n.InstallTiller)
fmt.Println("\tuseTiller : ", n.UseTiller)
fmt.Println("\ttillerServiceAccount : ", n.TillerServiceAccount)
fmt.Println("\ttillerRole: ", n.TillerRole)
fmt.Println("\tcaCert : ", n.CaCert)
fmt.Println("\ttillerCert : ", n.TillerCert)
fmt.Println("\ttillerKey : ", n.TillerKey)
fmt.Println("\tclientCert : ", n.ClientCert)
fmt.Println("\tclientKey : ", n.ClientKey)
fmt.Println("\tlabels : ")
printMap(n.Labels, 2)
fmt.Println("------------------- ")
}