This repository was archived by the owner on Oct 11, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathtypes.go
79 lines (65 loc) · 1.55 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
73
74
75
76
77
78
79
package voyager
import (
"fmt"
)
const (
Domain = "voyager.atl-paas.net"
ScopeGlobal = "global"
ServiceNameLabel = Domain + "/serviceName"
ServiceLabelLabel = Domain + "/label"
)
type Region string
type EnvType string
type Account string
type Label string
const (
EnvTypeDev EnvType = "dev"
EnvTypeStaging EnvType = "staging"
EnvTypeProduction EnvType = "prod"
)
type ServiceName string
// +genset=true
type Location struct {
EnvType EnvType `json:"envType"`
Account Account `json:"account"`
Region Region `json:"region"`
// This is an 'environment/namespace' label, NOT a kubernetes label.
Label Label `json:"label,omitempty"`
}
func (l Location) ClusterLocation() ClusterLocation {
return ClusterLocation{
Account: l.Account,
Region: l.Region,
EnvType: l.EnvType,
}
}
func (l Location) String() string {
// This echoes the domain name form in Micros.
s := fmt.Sprintf("%s.%s (account: %s)", l.Region, l.EnvType, l.Account)
if l.Label != "" {
s = string(l.Label) + "--" + s
}
return s
}
// This is basically an AWS tag.
type Tag string
type ResourceName string
type ResourceType string
// +genset=true
type ClusterLocation struct {
EnvType EnvType
Account Account
Region Region
}
func (cl ClusterLocation) String() string {
// This echoes the domain name form in Micros.
return fmt.Sprintf("%s.%s (account: %s)", cl.Region, cl.EnvType, cl.Account)
}
func (cl ClusterLocation) Location(label Label) Location {
return Location{
EnvType: cl.EnvType,
Region: cl.Region,
Account: cl.Account,
Label: label,
}
}