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)
| 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. |
| 424 | func 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. |
| 448 | type NewImageForProtoOption func(*newImageForProtoOptions) |
searching dependent graphs…