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

Function NewImageForCodeGeneratorRequest

private/bufpkg/bufimage/bufimage.go:424–445  ·  view source on GitHub ↗

NewImageForCodeGeneratorRequest returns a new Image from a given CodeGeneratorRequest. The input Files are expected to be in correct DAG order! TODO FUTURE: Consider checking the above, and if not, reordering the Files.

(request *pluginpb.CodeGeneratorRequest, options ...NewImageForProtoOption)

Source from the content-addressed store, hash-verified

422// The input Files are expected to be in correct DAG order!
423// TODO FUTURE: Consider checking the above, and if not, reordering the Files.
424func NewImageForCodeGeneratorRequest(request *pluginpb.CodeGeneratorRequest, options ...NewImageForProtoOption) (Image, error) {
425 protoImageFiles := make([]*imagev1.ImageFile, len(request.GetProtoFile()))
426 for i, fileDescriptorProto := range request.GetProtoFile() {
427 // we filter whether something is an import or not in ImageWithOnlyPaths
428 // we cannot determine if the syntax was unset
429 protoImageFiles[i] = fileDescriptorProtoToProtoImageFile(fileDescriptorProto, false, false, nil, nil, "")
430 }
431 image, err := NewImageForProto(
432 imagev1.Image_builder{
433 File: protoImageFiles,
434 }.Build(),
435 options...,
436 )
437 if err != nil {
438 return nil, err
439 }
440 return ImageWithOnlyPaths(
441 image,
442 request.GetFileToGenerate(),
443 nil,
444 )
445}
446
447// NewImageForProtoOption is an option for use with NewImageForProto.
448type NewImageForProtoOption func(*newImageForProtoOptions)

Callers 3

handleFunction · 0.92
handleFunction · 0.92
TestBasicFunction · 0.92

Calls 4

NewImageForProtoFunction · 0.85
ImageWithOnlyPathsFunction · 0.85
BuildMethod · 0.65

Tested by 1

TestBasicFunction · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…