buf: github.com/bufbuild/buf/internal/buf/bufcore/bufimage Index | Files | Directories

package bufimage

import "github.com/bufbuild/buf/internal/buf/bufcore/bufimage"

Index

Package Files

bufimage.go image.go image_file.go util.go validate.go

func ImageToCodeGeneratorRequest Uses

func ImageToCodeGeneratorRequest(image Image, parameter string) *pluginpb.CodeGeneratorRequest

ImageToCodeGeneratorRequest returns a new CodeGeneratorRequest for the Image.

All non-imports are added as files to generate.

func ImageToFileDescriptorProtos Uses

func ImageToFileDescriptorProtos(image Image) []*descriptorpb.FileDescriptorProto

ImageToFileDescriptorProtos returns a the FileDescriptorProtos for the Image.

func ImageToFileDescriptorSet Uses

func ImageToFileDescriptorSet(image Image) *descriptorpb.FileDescriptorSet

ImageToFileDescriptorSet returns a new FileDescriptorSet for the Image.

func ImageToProtoImage Uses

func ImageToProtoImage(image Image) *imagev1.Image

ImageToProtoImage returns a new ProtoImage for the Image.

func ImagesToCodeGeneratorRequests Uses

func ImagesToCodeGeneratorRequests(images []Image, parameter string) []*pluginpb.CodeGeneratorRequest

ImagesToCodeGeneratorRequests converts the Images to CodeGeneratorRequests.

All non-imports are added as files to generate.

type Image Uses

type Image interface {
    // Files are the files that comprise the image.
    //
    // This contains all files, including imports if available.
    // The returned files are in correct DAG order.
    Files() []ImageFile
    // GetFile gets the file for the root relative file path.
    //
    // If the file does not exist, nil is returned.
    // The path is expected to be normalized and validated.
    // Note that all values of GetDependency() can be used here.
    GetFile(path string) ImageFile
    // contains filtered or unexported methods
}

Image is a buf image.

func ImageByDir Uses

func ImageByDir(image Image) ([]Image, error)

ImageByDir returns multiple images that have non-imports split by directory.

That is, each Image will only contain a single directoy's files as it's non-imports, along with all required imports for the files in that directory.

func ImageWithOnlyPaths Uses

func ImageWithOnlyPaths(
    image Image,
    paths []string,
) (Image, error)

ImageWithOnlyPaths returns a copy of the Image that only includes the files with the given root relative file paths or directories.

Note that paths can be either files or directories - whether or not a path is included is a result of normalpath.EqualsOrContainsPath.

If a root relative file path does not exist, this errors.

func ImageWithOnlyPathsAllowNotExist Uses

func ImageWithOnlyPathsAllowNotExist(
    image Image,
    paths []string,
) (Image, error)

ImageWithOnlyPathsAllowNotExist returns a copy of the Image that only includes the files with the given root relative file paths.

Note that paths can be either files or directories - whether or not a path is included is a result of normalpath.EqualsOrContainsPath.

If a root relative file path does not exist, this skips this path.

func ImageWithoutImports Uses

func ImageWithoutImports(image Image) Image

ImageWithoutImports returns a copy of the Image without imports.

The backing Files are not copied.

func NewImage Uses

func NewImage(imageFiles []ImageFile) (Image, error)

NewImage returns a new Image for the given ImageFiles.

The input ImageFiles are expected to be in correct DAG order! TODO: Consider checking the above, and if not, reordering the Files. If imageFiles is empty, returns error

func NewImageForCodeGeneratorRequest Uses

func NewImageForCodeGeneratorRequest(request *pluginpb.CodeGeneratorRequest) (Image, error)

NewImageForCodeGeneratorRequest returns a new Image from a given CodeGeneratorRequest.

The input Files are expected to be in correct DAG order! TODO: Consider checking the above, and if not, reordering the Files.

func NewImageForProto Uses

func NewImageForProto(protoImage *imagev1.Image) (Image, error)

NewImageForProto returns a new Image for the given proto Image.

The input Files are expected to be in correct DAG order! TODO: Consider checking the above, and if not, reordering the Files.

TODO: do we want to add the ability to do external path resolution here?

func NewMultiImage Uses

func NewMultiImage(images ...Image) (Image, error)

NewMultiImage returns a new Image for the given Images.

Reorders the ImageFiles to be in DAG order. Duplicates cannot exist across the Images.

type ImageFile Uses

type ImageFile interface {
    bufcore.FileInfo
    // Proto is the backing FileDescriptorProto for this File.
    //
    // This will never be nil.
    // The value Path() is equal to Proto.GetName() .
    // The value ImportPaths() is equal to Proto().GetDependency().
    Proto() *descriptorpb.FileDescriptorProto
    // ImportPaths returns the root relative file paths of the imports.
    //
    // The values will be normalized, validated, and never empty.
    // This is equal to Proto.GetDependency().
    ImportPaths() []string
    // contains filtered or unexported methods
}

ImageFile is a Protobuf file within an image.

func NewImageFile Uses

func NewImageFile(
    fileDescriptorProto *descriptorpb.FileDescriptorProto,
    externalPath string,
    isImport bool,
) (ImageFile, error)

NewImageFile returns a new ImageFile.

If externalPath is empty, path is used.

Directories

PathSynopsis
bufimagebuild
bufimagebuild/bufimagebuildtesting
bufimagetesting
bufimageutil

Package bufimage imports 11 packages (graph) and is imported by 6 packages. Updated 2020-11-28. Refresh now. Tools for package owners.