(flags *pflag.FlagSet, groups *[]string)
| 967 | } |
| 968 | |
| 969 | func 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 | |
| 989 | func removeDuplicates[T comparable](entries []T) []T { |
| 990 | hit := map[T]bool{} |
searching dependent graphs…