@@ -22,7 +22,6 @@ import (
2222 "github.com/moby/moby/api/types/mount"
2323 "github.com/moby/moby/api/types/network"
2424 "github.com/moby/moby/api/types/swarm"
25- "github.com/moby/moby/api/types/versions"
2625 "github.com/moby/moby/client"
2726 "github.com/moby/swarmkit/v2/api/defaults"
2827 "github.com/spf13/cobra"
@@ -165,14 +164,6 @@ func runUpdate(ctx context.Context, dockerCLI command.Cli, flags *pflag.FlagSet,
165164 return err
166165 }
167166
168- // There are two ways to do user-requested rollback. The old way is
169- // client-side, but with a sufficiently recent daemon we prefer
170- // server-side, because it will honor the rollback parameters.
171- var (
172- clientSideRollback bool
173- serverSideRollback bool
174- )
175-
176167 spec := & service .Spec
177168 if rollback {
178169 // Rollback can't be combined with other flags.
@@ -188,20 +179,10 @@ func runUpdate(ctx context.Context, dockerCLI command.Cli, flags *pflag.FlagSet,
188179 if otherFlagsPassed {
189180 return errors .New ("other flags may not be combined with --rollback" )
190181 }
191-
192- if versions .LessThan (apiClient .ClientVersion (), "1.28" ) {
193- clientSideRollback = true
194- spec = service .PreviousSpec
195- if spec == nil {
196- return errors .New ("service does not have a previous specification to roll back to" )
197- }
198- } else {
199- serverSideRollback = true
200- }
201182 }
202183
203184 updateOpts := client.ServiceUpdateOptions {}
204- if serverSideRollback {
185+ if rollback {
205186 updateOpts .Rollback = "previous"
206187 }
207188
@@ -214,9 +195,7 @@ func runUpdate(ctx context.Context, dockerCLI command.Cli, flags *pflag.FlagSet,
214195 if err := resolveServiceImageDigestContentTrust (dockerCLI , spec ); err != nil {
215196 return err
216197 }
217- if ! options .noResolveImage && versions .GreaterThanOrEqualTo (apiClient .ClientVersion (), "1.30" ) {
218- updateOpts .QueryRegistry = true
219- }
198+ updateOpts .QueryRegistry = ! options .noResolveImage
220199 }
221200
222201 updatedSecrets , err := getUpdatedSecrets (ctx , apiClient , flags , spec .TaskTemplate .ContainerSpec .Secrets )
@@ -243,8 +222,7 @@ func runUpdate(ctx context.Context, dockerCLI command.Cli, flags *pflag.FlagSet,
243222 if err != nil {
244223 return err
245224 }
246- switch {
247- case sendAuth :
225+ if sendAuth {
248226 // Retrieve encoded auth token from the image reference
249227 // This would be the old image if it didn't change in this update
250228 image := spec .TaskTemplate .ContainerSpec .Image
@@ -253,9 +231,7 @@ func runUpdate(ctx context.Context, dockerCLI command.Cli, flags *pflag.FlagSet,
253231 return err
254232 }
255233 updateOpts .EncodedRegistryAuth = encodedAuth
256- case clientSideRollback :
257- updateOpts .RegistryAuthFrom = swarm .RegistryAuthFromPreviousSpec
258- default :
234+ } else {
259235 updateOpts .RegistryAuthFrom = swarm .RegistryAuthFromSpec
260236 }
261237
@@ -270,7 +246,7 @@ func runUpdate(ctx context.Context, dockerCLI command.Cli, flags *pflag.FlagSet,
270246
271247 _ , _ = fmt .Fprintln (dockerCLI .Out (), serviceID )
272248
273- if options .detach || versions . LessThan ( apiClient . ClientVersion (), "1.29" ) {
249+ if options .detach {
274250 return nil
275251 }
276252
0 commit comments