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

Function runUpdate

cli/command/service/update.go:155–258  ·  view source on GitHub ↗

nolint:gocyclo

(ctx context.Context, dockerCLI command.Cli, flags *pflag.FlagSet, options *serviceOptions, serviceID string)

Source from the content-addressed store, hash-verified

153
154//nolint:gocyclo
155func runUpdate(ctx context.Context, dockerCLI command.Cli, flags *pflag.FlagSet, options *serviceOptions, serviceID string) error {
156 apiClient := dockerCLI.Client()
157
158 res, err := apiClient.ServiceInspect(ctx, serviceID, client.ServiceInspectOptions{})
159 if err != nil {
160 return err
161 }
162
163 rollback, err := flags.GetBool(flagRollback)
164 if err != nil {
165 return err
166 }
167
168 if rollback {
169 // Rollback can't be combined with other flags.
170 otherFlagsPassed := false
171 flags.VisitAll(func(f *pflag.Flag) {
172 if f.Name == flagRollback || f.Name == flagDetach || f.Name == flagQuiet {
173 return
174 }
175 if flags.Changed(f.Name) {
176 otherFlagsPassed = true
177 }
178 })
179 if otherFlagsPassed {
180 return errors.New("other flags may not be combined with --rollback")
181 }
182 }
183
184 updateOpts := client.ServiceUpdateOptions{}
185 rollbackAction := "none"
186 if rollback {
187 rollbackAction = "previous"
188 }
189
190 spec := &res.Service.Spec
191 err = updateService(ctx, apiClient, flags, spec)
192 if err != nil {
193 return err
194 }
195
196 if flags.Changed("image") {
197 updateOpts.QueryRegistry = !options.noResolveImage
198 }
199
200 updatedSecrets, err := getUpdatedSecrets(ctx, apiClient, flags, spec.TaskTemplate.ContainerSpec.Secrets)
201 if err != nil {
202 return err
203 }
204 spec.TaskTemplate.ContainerSpec.Secrets = updatedSecrets
205
206 updatedConfigs, err := getUpdatedConfigs(ctx, apiClient, flags, spec.TaskTemplate.ContainerSpec)
207 if err != nil {
208 return err
209 }
210 spec.TaskTemplate.ContainerSpec.Configs = updatedConfigs
211
212 // set the credential spec value after get the updated configs, because we

Callers 1

newUpdateCommandFunction · 0.70

Calls 11

updateServiceFunction · 0.85
getUpdatedSecretsFunction · 0.85
getUpdatedConfigsFunction · 0.85
updateCredSpecConfigFunction · 0.85
WaitOnServiceFunction · 0.85
ClientMethod · 0.65
ConfigFileMethod · 0.65
ErrMethod · 0.65
OutMethod · 0.65
ServiceInspectMethod · 0.45
ServiceUpdateMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…