From 1b400f6284b17fffa0495e1c801155fdd0716e98 Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Thu, 18 Aug 2016 18:09:07 -0700 Subject: [PATCH] Return error for incorrect argument of `service update --publish-rm ` Currently `--publish-rm` only accepts `` or `[/Protocol]` though there are some confusions. Since `--publish-add` accepts `:[/Protocol]`, some user may provide `--publish-rm 80:80`. However, there is no error checking so the incorrect provided argument is ignored silently. This fix adds the check to make sure `--publish-rm` only accepts `[/Protocol]` and returns error if the format is invalid. The `--publish-rm` itself may needs to be revisited to have a better UI/UX experience, see discussions on: https://github.com/docker/swarmkit/issues/1396 https://github.com/docker/docker/issues/25200#issuecomment-236213242 https://github.com/docker/docker/issues/25338#issuecomment-240787002 This fix is short term measure so that end users are not misled by the silently ignored error of `--publish-rm`. This fix is related to (but is not a complete fix): https://github.com/docker/swarmkit/issues/1396 Signed-off-by: Yong Tang --- opts/opts.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/opts/opts.go b/opts/opts.go index ae851537ec..9f66c039e7 100644 --- a/opts/opts.go +++ b/opts/opts.go @@ -108,6 +108,12 @@ func (opts *ListOpts) Type() string { return "list" } +// WithValidator returns the ListOpts with validator set. +func (opts *ListOpts) WithValidator(validator ValidatorFctType) *ListOpts { + opts.validator = validator + return opts +} + // NamedOption is an interface that list and map options // with names implement. type NamedOption interface {