protodescriptor

package
v1.13.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 27, 2023 License: Apache-2.0 Imports: 7 Imported by: 12

Documentation

Index

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.

https://github.com/protocolbuffers/protobuf/blob/b99994d994e399174fe688a5efbcb6d91f36952a/src/google/protobuf/compiler/plugin.proto#L127

func ValidateFileDescriptor

func ValidateFileDescriptor(fileDescriptor FileDescriptor) error

ValidateFileDescriptor validates the FileDescriptor.

A *descriptorpb.FileDescriptorProto can be passed to this.

func ValidateProtoPath

func ValidateProtoPath(name string, path string) error

ValidateProtoPath validates the proto path.

This checks that the path is normalized and ends in .proto.

func ValidateProtoPaths

func ValidateProtoPaths(name string, paths []string) error

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL