Skip to content

Commit 4c8a7f7

Browse files
authored
Merge pull request #399 from andyxning/sanity_check
sanity check
2 parents aaf8e2f + 5a45360 commit 4c8a7f7

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

main.go

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,14 @@ func (c *collectorSet) Set(value string) error {
112112
s := *c
113113
cols := strings.Split(value, ",")
114114
for _, col := range cols {
115-
_, ok := availableCollectors[col]
116-
if !ok {
117-
glog.Fatalf("Collector \"%s\" does not exist", col)
115+
col = strings.TrimSpace(col)
116+
if len(col) != 0 {
117+
_, ok := availableCollectors[col]
118+
if !ok {
119+
glog.Fatalf("Collector \"%s\" does not exist", col)
120+
}
121+
s[col] = struct{}{}
118122
}
119-
s[col] = struct{}{}
120123
}
121124
return nil
122125
}
@@ -149,12 +152,17 @@ func (n *namespaceList) IsAllNamespaces() bool {
149152

150153
func (n *namespaceList) Set(value string) error {
151154
splittedNamespaces := strings.Split(value, ",")
152-
*n = append(*n, splittedNamespaces...)
155+
for _, ns := range splittedNamespaces {
156+
ns = strings.TrimSpace(ns)
157+
if len(ns) != 0 {
158+
*n = append(*n, ns)
159+
}
160+
}
153161
return nil
154162
}
155163

156164
func (n *namespaceList) Type() string {
157-
return "namespaceList"
165+
return "string"
158166
}
159167

160168
type options struct {

0 commit comments

Comments
 (0)