From 4f87181ba9f5fb58f40d0b86c3b98e31f26437ab Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Mon, 13 Jun 2016 19:52:49 -0700 Subject: [PATCH] Add Swarm management backend As described in our ROADMAP.md, introduce new Swarm management API endpoints relying on swarmkit to deploy services. It currently vendors docker/engine-api changes. This PR is fully backward compatible (joining a Swarm is an optional feature of the Engine, and existing commands are not impacted). Signed-off-by: Tonis Tiigi Signed-off-by: Victor Vieux Signed-off-by: Daniel Nephin Signed-off-by: Jana Radhakrishnan Signed-off-by: Madhu Venugopal --- opts/opts.go | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/opts/opts.go b/opts/opts.go index 9bd8040d25..1b9d6b294a 100644 --- a/opts/opts.go +++ b/opts/opts.go @@ -5,6 +5,8 @@ import ( "net" "regexp" "strings" + + "github.com/docker/engine-api/types/filters" ) var ( @@ -282,3 +284,38 @@ func ValidateSysctl(val string) (string, error) { } return "", fmt.Errorf("sysctl '%s' is not whitelisted", val) } + +// FilterOpt is a flag type for validating filters +type FilterOpt struct { + filter filters.Args +} + +// NewFilterOpt returns a new FilterOpt +func NewFilterOpt() FilterOpt { + return FilterOpt{filter: filters.NewArgs()} +} + +func (o *FilterOpt) String() string { + repr, err := filters.ToParam(o.filter) + if err != nil { + return "invalid filters" + } + return repr +} + +// Set sets the value of the opt by parsing the command line value +func (o *FilterOpt) Set(value string) error { + var err error + o.filter, err = filters.ParseFlag(value, o.filter) + return err +} + +// Type returns the option type +func (o *FilterOpt) Type() string { + return "filter" +} + +// Value returns the value of this option +func (o *FilterOpt) Value() filters.Args { + return o.filter +}