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

Method GetImportableImageFileInfos

private/buf/bufctl/controller.go:573–667  ·  view source on GitHub ↗
(
	ctx context.Context,
	input string,
	options ...FunctionOption,
)

Source from the content-addressed store, hash-verified

571}
572
573func (c *controller) GetImportableImageFileInfos(
574 ctx context.Context,
575 input string,
576 options ...FunctionOption,
577) (_ []bufimage.ImageFileInfo, retErr error) {
578 defer c.handleFileAnnotationSetRetError(&retErr)
579 functionOptions := newFunctionOptions(c)
580 for _, option := range options {
581 option(functionOptions)
582 }
583 // We never care about SourceCodeInfo here.
584 functionOptions.imageExcludeSourceInfo = true
585 // We always want to include imports for images.
586 functionOptions.imageExcludeImports = false
587
588 ref, err := c.buffetchRefParser.GetRef(ctx, input)
589 if err != nil {
590 return nil, err
591 }
592 var imageFileInfos []bufimage.ImageFileInfo
593 // For images, we want to get a bucket with no local paths. For everything else,
594 // we want to get a bucket with local paths. datawkt.ReadBucket will result in
595 // no local paths, otherwise we get the bucket from the bufwktstore.Store to
596 // get local paths.
597 wktBucket := datawkt.ReadBucket
598 switch t := ref.(type) {
599 case buffetch.ProtoFileRef:
600 workspace, err := c.getWorkspaceForProtoFileRef(ctx, t, functionOptions)
601 if err != nil {
602 return nil, err
603 }
604 imageFileInfos, err = getImageFileInfosForModuleSet(ctx, workspace)
605 if err != nil {
606 return nil, err
607 }
608 wktBucket, err = c.wktStore.GetBucket(ctx)
609 if err != nil {
610 return nil, err
611 }
612 case buffetch.SourceRef:
613 workspace, err := c.getWorkspaceForSourceRef(ctx, t, functionOptions)
614 if err != nil {
615 return nil, err
616 }
617 imageFileInfos, err = getImageFileInfosForModuleSet(ctx, workspace)
618 if err != nil {
619 return nil, err
620 }
621 wktBucket, err = c.wktStore.GetBucket(ctx)
622 if err != nil {
623 return nil, err
624 }
625 case buffetch.ModuleRef:
626 workspace, err := c.getWorkspaceForModuleRef(ctx, t, functionOptions)
627 if err != nil {
628 return nil, err
629 }
630 imageFileInfos, err = getImageFileInfosForModuleSet(ctx, workspace)

Callers

nothing calls this directly

Calls 14

getImageForMessageRefMethod · 0.95
NewfFunction · 0.92
newFunctionOptionsFunction · 0.85
optionStruct · 0.85
GetRefMethod · 0.65
GetBucketMethod · 0.65

Tested by

no test coverage detected