Documentation ¶
Index ¶
- func FileDescriptorProtoForFileDescriptor(fileDescriptor FileDescriptor) *descriptorpb.FileDescriptorProto
- func FileDescriptorProtosForFileDescriptors(fileDescriptors ...FileDescriptor) []*descriptorpb.FileDescriptorProto
- func FileDescriptorSetForFileDescriptors(fileDescriptors ...FileDescriptor) *descriptorpb.FileDescriptorSet
- func ValidateCodeGeneratorRequest(request *pluginpb.CodeGeneratorRequest) error
- func ValidateCodeGeneratorRequestExceptFileDescriptorProtos(request *pluginpb.CodeGeneratorRequest) error
- func ValidateCodeGeneratorResponse(response *pluginpb.CodeGeneratorResponse) error
- func ValidateFileDescriptor(fileDescriptor FileDescriptor) error
- func ValidateProtoPath(name string, path string) error
- func ValidateProtoPaths(name string, paths []string) error
- type FileDescriptor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FileDescriptorProtoForFileDescriptor ¶
func FileDescriptorProtoForFileDescriptor(fileDescriptor FileDescriptor) *descriptorpb.FileDescriptorProto
FileDescriptorProtoForFileDescriptor creates a new *descriptorpb.FileDescriptorProto for the fileDescriptor.
If the FileDescriptor is already a *descriptorpb.FileDescriptorProto, this returns the input value.
Note that this will not round trip exactly. If a *descriptorpb.FileDescriptorProto is turned into another object that is a FileDescriptor, and then passed to this function, the return value will not be equal if name, package, or syntax are set but empty. Instead, the return value will have these values unset. For our/most purposes, this is fine.
func FileDescriptorProtosForFileDescriptors ¶
func FileDescriptorProtosForFileDescriptors(fileDescriptors ...FileDescriptor) []*descriptorpb.FileDescriptorProto
FileDescriptorProtosForFileDescriptors is a convenience function since Go does not have generics.
Note that this will not round trip exactly. If a *descriptorpb.FileDescriptorProto is turned into another object that is a FileDescriptor, and then passed to this function, the return value will not be equal if name, package, or syntax are set but empty. Instead, the return value will have these values unset. For our/most purposes, this is fine.
func FileDescriptorSetForFileDescriptors ¶
func FileDescriptorSetForFileDescriptors(fileDescriptors ...FileDescriptor) *descriptorpb.FileDescriptorSet
FileDescriptorSetForFileDescriptors returns a new *descriptorpb.FileDescriptorSet for the given FileDescriptors.
Note that this will not round trip exactly. If a *descriptorpb.FileDescriptorProto is turned into another object that is a FileDescriptor, and then passed to this function, the return value will not be equal if name, package, or syntax are set but empty. Instead, the return value will have these values unset. For our/most purposes, this is fine.
func ValidateCodeGeneratorRequest ¶
func ValidateCodeGeneratorRequest(request *pluginpb.CodeGeneratorRequest) error
ValidateCodeGeneratorRequest validates the CodeGeneratorRequest.
func ValidateCodeGeneratorRequestExceptFileDescriptorProtos ¶
func ValidateCodeGeneratorRequestExceptFileDescriptorProtos(request *pluginpb.CodeGeneratorRequest) error
ValidateCodeGeneratorRequestExceptFileDescriptorProtos validates the CodeGeneratorRequest minus the FileDescriptorProtos.
func ValidateCodeGeneratorResponse ¶
func ValidateCodeGeneratorResponse(response *pluginpb.CodeGeneratorResponse) error
ValidateCodeGeneratorResponse validates the CodeGeneratorResponse.
This validates that names are set.
It is actually OK per the plugin.proto specs to not have the name set, and if this is empty, the content should be combined with the previous file. However, for our handlers, we do not support this, and for our binary handlers, we combine CodeGeneratorResponse.File contents.
func ValidateFileDescriptor ¶
func ValidateFileDescriptor(fileDescriptor FileDescriptor) error
ValidateFileDescriptor validates the FileDescriptor.
A *descriptorpb.FileDescriptorProto can be passed to this.
func ValidateProtoPath ¶
ValidateProtoPath validates the proto path.
This checks that the path is normalized and ends in .proto.
func ValidateProtoPaths ¶
ValidateProtoPaths validates the proto paths.
This checks that the paths are normalized and end in .proto.
Types ¶
type FileDescriptor ¶
type FileDescriptor interface { GetName() string GetPackage() string GetDependency() []string GetPublicDependency() []int32 GetWeakDependency() []int32 GetMessageType() []*descriptorpb.DescriptorProto GetEnumType() []*descriptorpb.EnumDescriptorProto GetService() []*descriptorpb.ServiceDescriptorProto GetExtension() []*descriptorpb.FieldDescriptorProto GetOptions() *descriptorpb.FileOptions GetSourceCodeInfo() *descriptorpb.SourceCodeInfo GetSyntax() string }
FileDescriptor is an interface that matches the methods on a *descriptorpb.FileDescriptorProto.
Note that a FileDescriptor is not necessarily validated, unlike other interfaces in buf.
func FileDescriptorsForFileDescriptorProtos ¶
func FileDescriptorsForFileDescriptorProtos(fileDescriptorProtos ...*descriptorpb.FileDescriptorProto) []FileDescriptor
FileDescriptorsForFileDescriptorProtos is a convenience function since Go does not have generics.
func FileDescriptorsForFileDescriptorSet ¶
func FileDescriptorsForFileDescriptorSet(fileDescriptorSet *descriptorpb.FileDescriptorSet) []FileDescriptor
FileDescriptorsForFileDescriptorSet is a convenience function since Go does not have generics.