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

Function removeGenericResources

cli/command/service/update.go:591–622  ·  view source on GitHub ↗
(flags *pflag.FlagSet, spec *swarm.TaskSpec)

Source from the content-addressed store, hash-verified

589}
590
591func removeGenericResources(flags *pflag.FlagSet, spec *swarm.TaskSpec) error {
592 // Can only be Discrete Resources
593 if !flags.Changed(flagGenericResourcesRemove) {
594 return nil
595 }
596
597 if spec.Resources == nil {
598 spec.Resources = &swarm.ResourceRequirements{}
599 }
600
601 if spec.Resources.Reservations == nil {
602 spec.Resources.Reservations = &swarm.Resources{}
603 }
604
605 values := flags.Lookup(flagGenericResourcesRemove).Value.(*opts.ListOpts).GetSlice()
606
607 m, err := buildGenericResourceMap(spec.Resources.Reservations.GenericResources)
608 if err != nil {
609 return err
610 }
611
612 for _, toRemoveRes := range values {
613 if _, ok := m[toRemoveRes]; !ok {
614 return fmt.Errorf("could not find generic-resource `%s` to remove it", toRemoveRes)
615 }
616
617 delete(m, toRemoveRes)
618 }
619
620 spec.Resources.Reservations.GenericResources = buildGenericResourceList(m)
621 return nil
622}
623
624func updatePlacementConstraints(flags *pflag.FlagSet, placement *swarm.Placement) {
625 if flags.Changed(flagConstraintAdd) {

Callers 2

updateServiceFunction · 0.85

Calls 3

buildGenericResourceMapFunction · 0.85
buildGenericResourceListFunction · 0.85
GetSliceMethod · 0.80

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…