MCPcopy Index your code
hub / github.com/docker/cli / runUpdate

Function runUpdate

cli/command/swarm/update.go:43–76  ·  view source on GitHub ↗
(ctx context.Context, dockerCLI command.Cli, flags *pflag.FlagSet, opts swarmOptions)

Source from the content-addressed store, hash-verified

41}
42
43func 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}

Callers 1

newUpdateCommandFunction · 0.70

Calls 7

printUnlockCommandFunction · 0.85
SwarmInspectMethod · 0.80
mergeSwarmSpecMethod · 0.80
SwarmUpdateMethod · 0.80
SwarmGetUnlockKeyMethod · 0.80
ClientMethod · 0.65
OutMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…