etcd/pkg/flags/proxy.go
Brandon Philips 78a9bba276 pkg/types/flags: introduce flags package
I want to use the Addrs type in another experimental proxy that I am
implementing. Pull it out into a separate package.
2014-09-28 14:56:30 -07:00

40 lines
633 B
Go

package flags
import (
"errors"
)
const (
ProxyValueOff = "off"
ProxyValueReadonly = "readonly"
ProxyValueOn = "on"
)
var (
ProxyValues = []string{
ProxyValueOff,
ProxyValueReadonly,
ProxyValueOn,
}
)
// ProxyFlag implements the flag.Value interface.
type Proxy string
// Set verifies the argument to be a valid member of proxyFlagValues
// before setting the underlying flag value.
func (pf *Proxy) Set(s string) error {
for _, v := range ProxyValues {
if s == v {
*pf = Proxy(s)
return nil
}
}
return errors.New("invalid value")
}
func (pf *Proxy) String() string {
return string(*pf)
}