MCPcopy Create free account
hub / github.com/docker/cli / updateGroups

Function updateGroups

cli/command/service/update.go:969–987  ·  view source on GitHub ↗
(flags *pflag.FlagSet, groups *[]string)

Source from the content-addressed store, hash-verified

967}
968
969func updateGroups(flags *pflag.FlagSet, groups *[]string) error {
970 if flags.Changed(flagGroupAdd) {
971 values := flags.Lookup(flagGroupAdd).Value.(*opts.ListOpts).GetSlice()
972 *groups = append(*groups, values...)
973 }
974 toRemove := buildToRemoveSet(flags, flagGroupRemove)
975
976 newGroups := []string{}
977 for _, group := range *groups {
978 if _, exists := toRemove[group]; !exists {
979 newGroups = append(newGroups, group)
980 }
981 }
982 // Sort so that result is predictable.
983 sort.Strings(newGroups)
984
985 *groups = newGroups
986 return nil
987}
988
989func removeDuplicates[T comparable](entries []T) []T {
990 hit := map[T]bool{}

Callers 2

updateServiceFunction · 0.85
TestUpdateGroupsFunction · 0.85

Calls 2

buildToRemoveSetFunction · 0.85
GetSliceMethod · 0.80

Tested by 1

TestUpdateGroupsFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…