Skip to content

Commit 2066dbc

Browse files
committed
cli/command/stack/swarm: inline validateResolveImageFlag
It was only used in a single place, and possibly incorrect. Let's inline it to put the logic where it's used. Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent c3be589 commit 2066dbc

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

cli/command/stack/swarm/deploy.go

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,17 @@ const (
2626
//
2727
// Deprecated: this function was for internal use and will be removed in the next release.
2828
func RunDeploy(ctx context.Context, dockerCLI command.Cli, flags *pflag.FlagSet, opts *options.Deploy, cfg *composetypes.Config) error {
29-
if err := validateResolveImageFlag(opts); err != nil {
30-
return err
29+
switch opts.ResolveImage {
30+
case ResolveImageAlways, ResolveImageChanged, ResolveImageNever:
31+
// valid options.
32+
default:
33+
return errors.Errorf("Invalid option %s for flag --resolve-image", opts.ResolveImage)
3134
}
35+
3236
// client side image resolution should not be done when the supported
3337
// server version is older than 1.30
3438
if versions.LessThan(dockerCLI.Client().ClientVersion(), "1.30") {
39+
// TODO(thaJeztah): should this error if "opts.ResolveImage" is already other (unsupported) values?
3540
opts.ResolveImage = ResolveImageNever
3641
}
3742

@@ -43,16 +48,6 @@ func RunDeploy(ctx context.Context, dockerCLI command.Cli, flags *pflag.FlagSet,
4348
return deployCompose(ctx, dockerCLI, opts, cfg)
4449
}
4550

46-
// validateResolveImageFlag validates the opts.resolveImage command line option
47-
func validateResolveImageFlag(opts *options.Deploy) error {
48-
switch opts.ResolveImage {
49-
case ResolveImageAlways, ResolveImageChanged, ResolveImageNever:
50-
return nil
51-
default:
52-
return errors.Errorf("Invalid option %s for flag --resolve-image", opts.ResolveImage)
53-
}
54-
}
55-
5651
// checkDaemonIsSwarmManager does an Info API call to verify that the daemon is
5752
// a swarm manager. This is necessary because we must create networks before we
5853
// create services, but the API call for creating a network does not return a

0 commit comments

Comments
 (0)