2017-04-17 10:50:02 +00:00
|
|
|
package kubernetes
|
2016-11-11 22:50:20 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Namespaces holds kubernetes namespaces
|
|
|
|
type Namespaces []string
|
|
|
|
|
|
|
|
//Set adds strings elem into the the parser
|
|
|
|
//it splits str on , and ;
|
|
|
|
func (ns *Namespaces) Set(str string) error {
|
|
|
|
fargs := func(c rune) bool {
|
|
|
|
return c == ',' || c == ';'
|
|
|
|
}
|
|
|
|
// get function
|
|
|
|
slice := strings.FieldsFunc(str, fargs)
|
|
|
|
*ns = append(*ns, slice...)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
//Get []string
|
2017-12-18 08:14:03 +00:00
|
|
|
func (ns *Namespaces) Get() interface{} { return *ns }
|
2016-11-11 22:50:20 +00:00
|
|
|
|
|
|
|
//String return slice in a string
|
|
|
|
func (ns *Namespaces) String() string { return fmt.Sprintf("%v", *ns) }
|
|
|
|
|
|
|
|
//SetValue sets []string into the parser
|
|
|
|
func (ns *Namespaces) SetValue(val interface{}) {
|
2017-12-18 08:14:03 +00:00
|
|
|
*ns = val.(Namespaces)
|
2016-11-11 22:50:20 +00:00
|
|
|
}
|