(ctx context.Context, dockerCLI command.Cli, flags *pflag.FlagSet, opts swarmOptions)
| 41 | } |
| 42 | |
| 43 | func runUpdate(ctx context.Context, dockerCLI command.Cli, flags *pflag.FlagSet, opts swarmOptions) error { |
| 44 | apiClient := dockerCLI.Client() |
| 45 | |
| 46 | sw, err := apiClient.SwarmInspect(ctx, client.SwarmInspectOptions{}) |
| 47 | if err != nil { |
| 48 | return err |
| 49 | } |
| 50 | |
| 51 | prevAutoLock := sw.Swarm.Spec.EncryptionConfig.AutoLockManagers |
| 52 | |
| 53 | opts.mergeSwarmSpec(&sw.Swarm.Spec, flags, &sw.Swarm.ClusterInfo.TLSInfo.TrustRoot) |
| 54 | |
| 55 | curAutoLock := sw.Swarm.Spec.EncryptionConfig.AutoLockManagers |
| 56 | |
| 57 | _, err = apiClient.SwarmUpdate(ctx, client.SwarmUpdateOptions{ |
| 58 | Version: sw.Swarm.Version, |
| 59 | Spec: sw.Swarm.Spec, |
| 60 | }) |
| 61 | if err != nil { |
| 62 | return err |
| 63 | } |
| 64 | |
| 65 | _, _ = fmt.Fprintln(dockerCLI.Out(), "Swarm updated.") |
| 66 | |
| 67 | if curAutoLock && !prevAutoLock { |
| 68 | resp, err := apiClient.SwarmGetUnlockKey(ctx) |
| 69 | if err != nil { |
| 70 | return fmt.Errorf("could not fetch unlock key: %w", err) |
| 71 | } |
| 72 | printUnlockCommand(dockerCLI.Out(), resp.Key) |
| 73 | } |
| 74 | |
| 75 | return nil |
| 76 | } |
no test coverage detected
searching dependent graphs…