(ctx context.Context, collectors map[gc.ResourceType]Collector)
| 198 | } |
| 199 | |
| 200 | func startGCContext(ctx context.Context, collectors map[gc.ResourceType]Collector) *gcContext { |
| 201 | var contexts map[gc.ResourceType]CollectionContext |
| 202 | labelHandlers := []referenceLabelHandler{ |
| 203 | { |
| 204 | key: labelGCContainerBackRef, |
| 205 | bref: func(ns string, k, v []byte, fn func(gc.Node)) { |
| 206 | if ks := string(k); ks != string(labelGCContainerBackRef) { |
| 207 | // Allow reference naming separated by . or /, ignore names |
| 208 | if ks[len(labelGCContainerBackRef)] != '.' && ks[len(labelGCContainerBackRef)] != '/' { |
| 209 | return |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | fn(gcnode(ResourceContainer, ns, string(v))) |
| 214 | }, |
| 215 | }, |
| 216 | { |
| 217 | key: labelGCContentBackRef, |
| 218 | bref: func(ns string, k, v []byte, fn func(gc.Node)) { |
| 219 | if ks := string(k); ks != string(labelGCContentBackRef) { |
| 220 | // Allow reference naming separated by . or /, ignore names |
| 221 | if ks[len(labelGCContentBackRef)] != '.' && ks[len(labelGCContentBackRef)] != '/' { |
| 222 | return |
| 223 | } |
| 224 | } |
| 225 | |
| 226 | fn(gcnode(ResourceContent, ns, string(v))) |
| 227 | }, |
| 228 | }, |
| 229 | { |
| 230 | key: labelGCImageBackRef, |
| 231 | bref: func(ns string, k, v []byte, fn func(gc.Node)) { |
| 232 | if ks := string(k); ks != string(labelGCImageBackRef) { |
| 233 | // Allow reference naming separated by . or /, ignore names |
| 234 | if ks[len(labelGCImageBackRef)] != '.' && ks[len(labelGCImageBackRef)] != '/' { |
| 235 | return |
| 236 | } |
| 237 | } |
| 238 | |
| 239 | fn(gcnode(ResourceImage, ns, string(v))) |
| 240 | }, |
| 241 | }, |
| 242 | { |
| 243 | key: labelGCSnapBackRef, |
| 244 | bref: func(ns string, k, v []byte, fn func(gc.Node)) { |
| 245 | snapshotter := k[len(labelGCSnapBackRef):] |
| 246 | if i := bytes.IndexByte(snapshotter, '/'); i >= 0 { |
| 247 | snapshotter = snapshotter[:i] |
| 248 | } |
| 249 | fn(gcnode(ResourceSnapshot, ns, fmt.Sprintf("%s/%s", snapshotter, v))) |
| 250 | }, |
| 251 | }, |
| 252 | { |
| 253 | key: labelGCContentRef, |
| 254 | fn: func(ns string, k, v []byte, fn func(gc.Node)) { |
| 255 | if ks := string(k); ks != string(labelGCContentRef) { |
| 256 | // Allow reference naming separated by . or /, ignore names |
| 257 | if ks[len(labelGCContentRef)] != '.' && ks[len(labelGCContentRef)] != '/' { |
searching dependent graphs…