getSubCgroupPaths parses --cgroup arguments, which can either be - a single "path" argument (for cgroup v2); - one or more controller[,controller[,...]]:path arguments (for cgroup v1). Returns a controller to path map. For cgroup v2, it's a single entity map with empty controller value.
(args []string)
| 124 | // Returns a controller to path map. For cgroup v2, it's a single entity map |
| 125 | // with empty controller value. |
| 126 | func getSubCgroupPaths(args []string) (map[string]string, error) { |
| 127 | if len(args) == 0 { |
| 128 | return nil, nil |
| 129 | } |
| 130 | paths := make(map[string]string, len(args)) |
| 131 | for _, c := range args { |
| 132 | // Split into controller:path. |
| 133 | if ctr, path, ok := strings.Cut(c, ":"); ok { |
| 134 | // There may be a few comma-separated controllers. |
| 135 | for ctrl := range strings.SplitSeq(ctr, ",") { |
| 136 | if ctrl == "" { |
| 137 | return nil, fmt.Errorf("invalid --cgroup argument: %s (empty <controller> prefix)", c) |
| 138 | } |
| 139 | if _, ok := paths[ctrl]; ok { |
| 140 | return nil, fmt.Errorf("invalid --cgroup argument(s): controller %s specified multiple times", ctrl) |
| 141 | } |
| 142 | paths[ctrl] = path |
| 143 | } |
| 144 | } else { |
| 145 | // No "controller:" prefix (cgroup v2, a single path). |
| 146 | if len(args) != 1 { |
| 147 | return nil, fmt.Errorf("invalid --cgroup argument: %s (missing <controller>: prefix)", c) |
| 148 | } |
| 149 | paths[""] = c |
| 150 | } |
| 151 | } |
| 152 | return paths, nil |
| 153 | } |
| 154 | |
| 155 | func execProcess(context *cli.Context) (int, error) { |
| 156 | container, err := getContainer(context) |
no outgoing calls
no test coverage detected
searching dependent graphs…