diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-09-30 13:59:54 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-30 13:59:54 -0700 |
commit | b063383390f8b23f69357d781784582e4d93c706 (patch) | |
tree | 86706e3405f01eccafd6af897784b7fe3e1c26ca /vendor/github.com/spf13/pflag/ip_slice.go | |
parent | 92a489bcdfcb16a8fa74f08b539696be2f6bd0ab (diff) | |
parent | c245ef9d1b2322a35344bbf837baaf3892378bef (diff) | |
download | podman-b063383390f8b23f69357d781784582e4d93c706.tar.gz podman-b063383390f8b23f69357d781784582e4d93c706.tar.bz2 podman-b063383390f8b23f69357d781784582e4d93c706.zip |
Merge pull request #4144 from containers/dependabot/go_modules/github.com/spf13/pflag-1.0.5
Bump github.com/spf13/pflag from 1.0.3 to 1.0.5
Diffstat (limited to 'vendor/github.com/spf13/pflag/ip_slice.go')
-rw-r--r-- | vendor/github.com/spf13/pflag/ip_slice.go | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/vendor/github.com/spf13/pflag/ip_slice.go b/vendor/github.com/spf13/pflag/ip_slice.go index 7dd196fe3..775faae4f 100644 --- a/vendor/github.com/spf13/pflag/ip_slice.go +++ b/vendor/github.com/spf13/pflag/ip_slice.go @@ -72,9 +72,47 @@ func (s *ipSliceValue) String() string { return "[" + out + "]" } +func (s *ipSliceValue) fromString(val string) (net.IP, error) { + return net.ParseIP(strings.TrimSpace(val)), nil +} + +func (s *ipSliceValue) toString(val net.IP) string { + return val.String() +} + +func (s *ipSliceValue) Append(val string) error { + i, err := s.fromString(val) + if err != nil { + return err + } + *s.value = append(*s.value, i) + return nil +} + +func (s *ipSliceValue) Replace(val []string) error { + out := make([]net.IP, len(val)) + for i, d := range val { + var err error + out[i], err = s.fromString(d) + if err != nil { + return err + } + } + *s.value = out + return nil +} + +func (s *ipSliceValue) GetSlice() []string { + out := make([]string, len(*s.value)) + for i, d := range *s.value { + out[i] = s.toString(d) + } + return out +} + func ipSliceConv(val string) (interface{}, error) { val = strings.Trim(val, "[]") - // Emtpy string would cause a slice with one (empty) entry + // Empty string would cause a slice with one (empty) entry if len(val) == 0 { return []net.IP{}, nil } |