Documentation
¶
Index ¶
- func FileRefFullRelFilePath(fileRef FileRef) string
- func ImageToCodeGeneratorRequest(image Image, parameter string) *pluginpb.CodeGeneratorRequest
- func ImageToFileDescriptorProtos(image Image) []*descriptorpb.FileDescriptorProto
- func ImageToFileDescriptorSet(image Image) *descriptorpb.FileDescriptorSet
- func ImageToProtoImage(image Image) *imagev1beta1.Image
- type File
- type FileRef
- type Image
- func ImageWithOnlyRootRelFilePaths(image Image, rootRelFilePaths []string) (Image, error)
- func ImageWithOnlyRootRelFilePathsAllowNotExist(image Image, rootRelFilePaths []string) (Image, error)
- func ImageWithoutImports(image Image) Image
- func NewImage(files []File) (Image, error)
- func NewImageForCodeGeneratorRequest(request *pluginpb.CodeGeneratorRequest) (Image, error)
- func NewImageForProto(protoImage *imagev1beta1.Image) (Image, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FileRefFullRelFilePath ¶
FileRefFullRelFilePath returns the full relative file path.
This is the root directory path joined with the root relative file path.
Example:
RootRelFilePath: one/one.proto RootDirPath: proto FullRelFilePath: proto/one/one.proto
func ImageToCodeGeneratorRequest ¶
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 ¶
func ImageToFileDescriptorProtos(image Image) []*descriptorpb.FileDescriptorProto
ImageToFileDescriptorProtos returns a the FileDescriptorProtos for the Image.
func ImageToFileDescriptorSet ¶
func ImageToFileDescriptorSet(image Image) *descriptorpb.FileDescriptorSet
ImageToFileDescriptorSet returns a new FileDescriptorSet for the Image.
func ImageToProtoImage ¶
func ImageToProtoImage(image Image) *imagev1beta1.Image
ImageToProtoImage returns a new ProtoImage for the Image.
Types ¶
type File ¶
type File interface {
FileRef
// ImportRootRelFilePaths returns the root relative file paths of the imports.
//
// The values will be normalized, validated, and never empty.
// This is equal to Proto.GetDependency().
ImportRootRelFilePaths() []string
// Proto is the backing FileDescriptorProto for this File.
//
// This will never be nil.
// The value RootRelFilePath() is equal to Proto.GetName() .
// The value ImportRootRelFilePaths() is equal to Proto().GetDependency().
Proto() *descriptorpb.FileDescriptorProto
// IsImport returns true if this file is an import in the context of the enclosing Image.
IsImport() bool
// contains filtered or unexported methods
}
File is a Protobuf file within an image.
func NewDirectFile ¶
func NewDirectFile( fileDescriptorProto *descriptorpb.FileDescriptorProto, rootDirPath string, externalFilePath string, isImport bool, ) (File, error)
NewDirectFile returns a new File created with a direct external file path.
This should only be used in testing.
func NewFile ¶
func NewFile( fileDescriptorProto *descriptorpb.FileDescriptorProto, rootDirPath string, externalPathResolver bufpath.ExternalPathResolver, isImport bool, ) (File, error)
NewFile returns a new File.
type FileRef ¶
type FileRef interface {
// RootRelFilePath is the path of the file relative to the root it is contained within.
// This will be normalized, validated and never empty,
// This will be unique within a given Image.
RootRelFilePath() string
// RootDirPath is the directory path of the root that contains this file.
//
// This will be normalized, validated and never empty,
// The full relative path to the file within a given context is normalpath.Join(RootDirPath(), RootRelFilePath())
// For FileRefs created from external images, this will always be ".".
//
// This path should be used for informational purposes only and not
// used to help uniquely identify a file within an Image.
RootDirPath() string
// ExternalFilePath returns the path that identifies this file externally.
//
// Example:
// RootRelFilePath: one/one.proto
// RootDirPath: proto
// DirectoryPath: /foo/bar
// ExternalFilePath: /foo/bar/proto/one/one.proto
ExternalFilePath() string
// contains filtered or unexported methods
}
FileRef is a Protobuf file reference.
func NewDirectFileRef ¶
func NewDirectFileRef( rootRelFilePath string, rootDirPath string, externalFilePath string, ) (FileRef, error)
NewDirectFileRef returns a new FileRef created with a direct external file path.
This should only be used in testing.
func NewFileRef ¶
func NewFileRef( rootRelFilePath string, rootDirPath string, externalPathResolver bufpath.ExternalPathResolver, ) (FileRef, error)
NewFileRef returns a new FileRef.
type Image ¶
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() []File
// GetFile gets the file for the root relative file path.
//
// If the file does not exist, nil is returned.
// The rootRelFilePath is expected to be normalized and validated.
// Note that all values of GetDependency() can be used here.
GetFile(rootRelFilePath string) File
}
Image is a buf image.
func ImageWithOnlyRootRelFilePaths ¶
ImageWithOnlyRootRelFilePaths returns a copy of the Image that only includes the Files with the given root relative file paths.
If a root relative file path does not exist, this errors.
func ImageWithOnlyRootRelFilePathsAllowNotExist ¶
func ImageWithOnlyRootRelFilePathsAllowNotExist( image Image, rootRelFilePaths []string, ) (Image, error)
ImageWithOnlyRootRelFilePathsAllowNotExist returns a copy of the Image that only includes the Files with the given root relative file paths.
If a root relative file path does not exist, this skips this path.
func ImageWithoutImports ¶
ImageWithoutImports returns a copy of the Image without imports.
The backing Files are not copied.
func NewImage ¶
NewImage returns a new Image for the given Files.
The input Files are expected to be in correct DAG order! TODO: Consider checking the above, and if not, reordering the Files.
func NewImageForCodeGeneratorRequest ¶
func NewImageForCodeGeneratorRequest(request *pluginpb.CodeGeneratorRequest) (Image, error)
NewImageForCodeGeneratorRequest returns a new Image from a given CodeGeneratorRequest.
externalPathResolver may be nil.
The input Files are expected to be in correct DAG order! TODO: Consider checking the above, and if not, reordering the Files.
func NewImageForProto ¶
func NewImageForProto(protoImage *imagev1beta1.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.