traefik/provider/kubernetes/namespace.go

33 lines
700 B
Go
Raw Normal View History

package kubernetes
import (
"fmt"
"strings"
)
// Namespaces holds kubernetes namespaces
type Namespaces []string
2018-07-03 08:02:03 +00:00
// 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
}
2018-07-03 08:02:03 +00:00
// Get []string
2017-12-18 08:14:03 +00:00
func (ns *Namespaces) Get() interface{} { return *ns }
2018-07-03 08:02:03 +00:00
// String return slice in a string
func (ns *Namespaces) String() string { return fmt.Sprintf("%v", *ns) }
2018-07-03 08:02:03 +00:00
// SetValue sets []string into the parser
func (ns *Namespaces) SetValue(val interface{}) {
2017-12-18 08:14:03 +00:00
*ns = val.(Namespaces)
}