MCPcopy Create free account
hub / github.com/bufbuild/buf / FilterImage

Function FilterImage

private/bufpkg/bufimage/bufimageutil/bufimageutil.go:249–263  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

247// messages: [pkg.Baz, other.Quux, other.Qux]
248// extensions: [other.my_option]
249func 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

Callers 15

runFunction · 0.92
wellKnownTypeImageFunction · 0.92
execPluginsMethod · 0.92
filterImageFunction · 0.92
TestTypesFunction · 0.85
TestNestingFunction · 0.85
TestPackagesFunction · 0.85
TestVersionedPackagesFunction · 0.85
TestTransitivePublicFunction · 0.85
TestTypesFromMainModuleFunction · 0.85
TestMutateInPlaceFunction · 0.85
TestConsecutiveFiltersFunction · 0.85

Calls 3

newImageFilterOptionsFunction · 0.85
optionStruct · 0.85
filterImageFunction · 0.70

Tested by 11

TestTypesFunction · 0.68
TestNestingFunction · 0.68
TestPackagesFunction · 0.68
TestVersionedPackagesFunction · 0.68
TestTransitivePublicFunction · 0.68
TestTypesFromMainModuleFunction · 0.68
TestMutateInPlaceFunction · 0.68
TestConsecutiveFiltersFunction · 0.68
runFilterImageFunction · 0.68
runSourceCodeInfoTestFunction · 0.68
benchmarkFilterImageFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…