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

Function newModuleReadBucketForModule

private/bufpkg/bufmodule/module_read_bucket.go:289–315  ·  view source on GitHub ↗

module cannot be assumed to be functional yet. Do not call any functions on module.

(
	ctx context.Context,
	// This function must already be filtered to include only module files and must be sync.OnceValues wrapped!
	syncOnceValuesGetBucketWithStorageMatcherApplied func() (storage.ReadBucket, error),
	module Module,
	targetPaths []string,
	targetExcludePaths []string,
	protoFileTargetPath string,
	includePackageFiles bool,
)

Source from the content-addressed store, hash-verified

287// module cannot be assumed to be functional yet.
288// Do not call any functions on module.
289func newModuleReadBucketForModule(
290 ctx context.Context,
291 // This function must already be filtered to include only module files and must be sync.OnceValues wrapped!
292 syncOnceValuesGetBucketWithStorageMatcherApplied func() (storage.ReadBucket, error),
293 module Module,
294 targetPaths []string,
295 targetExcludePaths []string,
296 protoFileTargetPath string,
297 includePackageFiles bool,
298) (*moduleReadBucket, error) {
299 // TODO FUTURE: get these validations into a common place
300 if protoFileTargetPath != "" && (len(targetPaths) > 0 || len(targetExcludePaths) > 0) {
301 return nil, syserror.Newf("cannot set both protoFileTargetPath %q and either targetPaths %v or targetExcludePaths %v", protoFileTargetPath, targetPaths, targetExcludePaths)
302 }
303 if protoFileTargetPath != "" && normalpath.Ext(protoFileTargetPath) != ".proto" {
304 return nil, syserror.Newf("protoFileTargetPath %q is not a .proto file", protoFileTargetPath)
305 }
306 return &moduleReadBucket{
307 getBucket: syncOnceValuesGetBucketWithStorageMatcherApplied,
308 module: module,
309 targetPaths: targetPaths,
310 targetPathMap: xslices.ToStructMap(targetPaths),
311 targetExcludePathMap: xslices.ToStructMap(targetExcludePaths),
312 protoFileTargetPath: protoFileTargetPath,
313 includePackageFiles: includePackageFiles,
314 }, nil
315}
316
317func (b *moduleReadBucket) GetFile(ctx context.Context, path string) (File, error) {
318 fileInfo, err := b.StatFileInfo(ctx, path)

Callers 1

newModuleFunction · 0.85

Calls 2

NewfFunction · 0.92
ExtFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…