summaryrefslogtreecommitdiff
path: root/vendor/github.com/spf13/pflag/duration_slice.go
diff options
context:
space:
mode:
authordependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>2019-09-30 12:40:08 +0000
committerValentin Rothberg <rothberg@redhat.com>2019-09-30 15:03:39 +0200
commitc245ef9d1b2322a35344bbf837baaf3892378bef (patch)
tree13b545f5743e8f047b1291d276334aeb11c0da97 /vendor/github.com/spf13/pflag/duration_slice.go
parent01b7af8ee9b3df1439c4da109ba11e7410108dab (diff)
downloadpodman-c245ef9d1b2322a35344bbf837baaf3892378bef.tar.gz
podman-c245ef9d1b2322a35344bbf837baaf3892378bef.tar.bz2
podman-c245ef9d1b2322a35344bbf837baaf3892378bef.zip
Bump github.com/spf13/pflag from 1.0.3 to 1.0.5
Bumps [github.com/spf13/pflag](https://github.com/spf13/pflag) from 1.0.3 to 1.0.5. - [Release notes](https://github.com/spf13/pflag/releases) - [Commits](https://github.com/spf13/pflag/compare/v1.0.3...v1.0.5) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'vendor/github.com/spf13/pflag/duration_slice.go')
-rw-r--r--vendor/github.com/spf13/pflag/duration_slice.go38
1 files changed, 38 insertions, 0 deletions
diff --git a/vendor/github.com/spf13/pflag/duration_slice.go b/vendor/github.com/spf13/pflag/duration_slice.go
index 52c6b6dc1..badadda53 100644
--- a/vendor/github.com/spf13/pflag/duration_slice.go
+++ b/vendor/github.com/spf13/pflag/duration_slice.go
@@ -51,6 +51,44 @@ func (s *durationSliceValue) String() string {
return "[" + strings.Join(out, ",") + "]"
}
+func (s *durationSliceValue) fromString(val string) (time.Duration, error) {
+ return time.ParseDuration(val)
+}
+
+func (s *durationSliceValue) toString(val time.Duration) string {
+ return fmt.Sprintf("%s", val)
+}
+
+func (s *durationSliceValue) Append(val string) error {
+ i, err := s.fromString(val)
+ if err != nil {
+ return err
+ }
+ *s.value = append(*s.value, i)
+ return nil
+}
+
+func (s *durationSliceValue) Replace(val []string) error {
+ out := make([]time.Duration, 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 *durationSliceValue) GetSlice() []string {
+ out := make([]string, len(*s.value))
+ for i, d := range *s.value {
+ out[i] = s.toString(d)
+ }
+ return out
+}
+
func durationSliceConv(val string) (interface{}, error) {
val = strings.Trim(val, "[]")
// Empty string would cause a slice with one (empty) entry