FilterImage returns a minimal image containing only the descriptors required to define the set of types provided by the filter options. If no filter options are provided, the original image is returned. The filtered image will contain only the files that contain the definitions of the specified typ
(image bufimage.Image, options ...ImageFilterOption)
| 247 | // messages: [pkg.Baz, other.Quux, other.Qux] |
| 248 | // extensions: [other.my_option] |
| 249 | func FilterImage(image bufimage.Image, options ...ImageFilterOption) (bufimage.Image, error) { |
| 250 | if len(options) == 0 { |
| 251 | return image, nil |
| 252 | } |
| 253 | filterOptions := newImageFilterOptions() |
| 254 | for _, option := range options { |
| 255 | option(filterOptions) |
| 256 | } |
| 257 | // Check for defaults that would result in no filtering. |
| 258 | if len(filterOptions.excludeTypes) == 0 && |
| 259 | len(filterOptions.includeTypes) == 0 { |
| 260 | return image, nil |
| 261 | } |
| 262 | return filterImage(image, filterOptions) |
| 263 | } |
| 264 | |
| 265 | // StripSourceRetentionOptions strips any options with a retention of "source" from |
| 266 | // the descriptors in the given image. The image is not mutated but instead a new |
searching dependent graphs…