-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
options.go
83 lines (74 loc) · 2.02 KB
/
options.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
/*
Copyright 2019 The Skaffold Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package config
import (
"io"
"strings"
)
// Output defines which zones on the screen to print to
type Output struct {
Main io.Writer
Logs io.Writer
}
// SkaffoldOptions are options that are set by command line arguments not included
// in the config file itself
type SkaffoldOptions struct {
ConfigurationFile string
Cleanup bool
Notification bool
Tail bool
TailDev bool
PortForward bool
SkipTests bool
CacheArtifacts bool
ExperimentalGUI bool
EnableRPC bool
Profiles []string
CustomTag string
Namespace string
CacheFile string
TargetImages []string
Trigger string
CustomLabels []string
WatchPollInterval int
DefaultRepo string
PreBuiltImages []string
Command string
RPCPort string
}
// Labels returns a map of labels to be applied to all deployed
// k8s objects during the duration of the run
func (opts *SkaffoldOptions) Labels() map[string]string {
labels := map[string]string{}
if opts.Cleanup {
labels["cleanup"] = "true"
}
if opts.Tail || opts.TailDev {
labels["tail"] = "true"
}
if opts.Namespace != "" {
labels["namespace"] = opts.Namespace
}
if len(opts.Profiles) > 0 {
labels["profiles"] = strings.Join(opts.Profiles, "__")
}
for _, cl := range opts.CustomLabels {
l := strings.SplitN(cl, "=", 2)
if len(l) == 1 {
labels[l[0]] = ""
continue
}
labels[l[0]] = l[1]
}
return labels
}