traefik/pkg/provider/kubernetes/k8s/namespace.go
Ludovic Fernandez f1b085fa36 Move code to pkg
2019-03-15 09:42:03 +01:00

33 lines
698 B
Go

package k8s
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.
func (ns *Namespaces) Get() interface{} { return *ns }
// 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{}) {
*ns = val.(Namespaces)
}