-
Notifications
You must be signed in to change notification settings - Fork 0
/
domain.go
98 lines (80 loc) · 3.49 KB
/
domain.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
package main
import "fmt"
type params struct {
Action string `json:"action,omitempty" yaml:"action,omitempty"`
AppVersion string `json:"appVersion,omitempty" yaml:"appVersion,omitempty"`
Chart string `json:"chart,omitempty" yaml:"chart,omitempty"`
Credentials string `json:"credentials,omitempty" yaml:"credentials,omitempty"`
FollowLogs bool `json:"followLogs,omitempty" yaml:"followLogs,omitempty"`
Force bool `json:"force,omitempty" yaml:"force,omitempty"`
HelmSubdirectory string `json:"helmSubdir,omitempty" yaml:"helmSubdir,omitempty"`
KindHost string `json:"kindHost,omitempty" yaml:"kindHost,omitempty"`
LabelSelectorOverride string `json:"labelSelector,omitempty" yaml:"labelSelector,omitempty"`
Namespace string `json:"namespace,omitempty" yaml:"namespace,omitempty"`
ReleaseName string `json:"release,omitempty" yaml:"release,omitempty"`
RepositoryDirectory string `json:"repoDir,omitempty" yaml:"repoDir,omitempty"`
RepositoryChartsSubdirectory string `json:"repoChartsSubdir,omitempty" yaml:"repoChartsSubdir,omitempty"`
RepositoryURL string `json:"repoUrl,omitempty" yaml:"repoUrl,omitempty"`
RepositoryBranch string `json:"repoBranch,omitempty" yaml:"repoBranch,omitempty"`
Bucket string `json:"bucket,omitempty" yaml:"bucket,omitempty"`
Timeout string `json:"timeout,omitempty" yaml:"timeout,omitempty"`
Values string `json:"values,omitempty" yaml:"values,omitempty"`
ValuesFile string `json:"valuesFile,omitempty" yaml:"valuesFile,omitempty"`
Version string `json:"version,omitempty" yaml:"version,omitempty"`
}
func (p *params) SetDefaults(gitName string, appLabel string, buildVersion string, releaseTargetName string, releaseAction string) {
if p.Action == "" && releaseAction != "" {
p.Action = releaseAction
}
// set chart name
if p.Chart == "" {
if appLabel != "" {
p.Chart = appLabel
} else if gitName != "" {
p.Chart = gitName
}
}
if p.AppVersion == "" && buildVersion != "" {
p.AppVersion = buildVersion
}
if p.Version == "" && buildVersion != "" {
p.Version = buildVersion
}
if p.KindHost == "" {
p.KindHost = "kubernetes"
}
if p.Timeout == "" {
p.Timeout = "300s"
}
if p.HelmSubdirectory == "" {
p.HelmSubdirectory = "helm"
}
if p.RepositoryDirectory == "" {
p.RepositoryDirectory = "helm-charts"
}
if p.RepositoryChartsSubdirectory == "" {
p.RepositoryChartsSubdirectory = "charts"
}
if p.RepositoryURL == "" {
p.RepositoryURL = "https://helm.estafette.io/"
}
if p.RepositoryBranch == "" {
p.RepositoryBranch = "master"
}
if p.ReleaseName == "" {
p.ReleaseName = p.Chart
}
// default credentials to release name prefixed with gke if no override in stage params
if p.Credentials == "" && releaseTargetName != "" {
p.Credentials = fmt.Sprintf("gke-%v", releaseTargetName)
}
}
type requirements struct {
Dependencies []dependency `json:"dependencies,omitempty" yaml:"dependencies,omitempty"`
}
type dependency struct {
Name string `json:"name,omitempty" yaml:"name,omitempty"`
Version string `json:"version,omitempty" yaml:"version,omitempty"`
Repository string `json:"repository,omitempty" yaml:"repository,omitempty"`
Alias string `json:"alias,omitempty" yaml:"alias,omitempty"`
}