bufcheckopt

package
v1.45.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCommentExcludes

func GetCommentExcludes(options option.Options) ([]string, error)

CommentExcludes are lines of comments that should be excluded for the COMMENT.* Rules.

If a comment line starts with one of these excludes, it is not considered an actual comment.

The returned slice is guaranteed to have only non-empty elements.

func GetEnumZeroValueSuffix

func GetEnumZeroValueSuffix(options option.Options) (string, error)

GetEnumZeroValueSuffix gets the enum zero-value suffix.

Returns the default suffix if the option is not set.

func GetRPCAllowGoogleProtobufEmptyRequests

func GetRPCAllowGoogleProtobufEmptyRequests(options option.Options) (bool, error)

GetRPCAllowGoogleProtobufEmptyRequests returns true if the rpc_allow_google_protobuf_empty_requests option is set to true.

Returns error if the value was unrecognized.

func GetRPCAllowGoogleProtobufEmptyResponses

func GetRPCAllowGoogleProtobufEmptyResponses(options option.Options) (bool, error)

GetRPCAllowGoogleProtobufEmptyResponses returns true if the rpc_allow_google_protobuf_empty_responses option is set to true.

Returns error if the value was unrecognized.

func GetRPCAllowSameRequestResponse

func GetRPCAllowSameRequestResponse(options option.Options) (bool, error)

GetRPCAllowSameRequestResponse returns true if the rpc_allow_same_request_response option is set to true.

Returns error if the value was unrecognized.

func GetServiceSuffix

func GetServiceSuffix(options option.Options) (string, error)

GetServiceSuffix gets the service suffix.

Returns the default suffix if the option is not set.

Types

type OptionsSpec

type OptionsSpec struct {
	EnumZeroValueSuffix                  string
	RPCAllowSameRequestResponse          bool
	RPCAllowGoogleProtobufEmptyRequests  bool
	RPCAllowGoogleProtobufEmptyResponses bool
	ServiceSuffix                        string
	// CommentExcludes are lines of comments that should be excluded for the COMMENT.* Rules.
	//
	// If a comment line starts with one of these excludes, it is not considered an actual comment.
	//
	// Right now, this should just be []string{"buf:lint:ignore"}, however we do this as a proper option
	// to maintain the client/server split we want; the server (ie the Rules) should not have the lint comment
	// ignore strings as part of their logic, all lint comment ignore logic is a client-side concern. However,
	// it is concievable that a COMMENT.* Rule might want to say "I don't want to consider this generic
	// line to be a comment", which is exclusive of the lint comment ignore logic. We could even potentially
	// give users the ability to configure things to ignore as part of their buf.yaml configuration. So,
	// this feels OK to expose here.
	//
	// In practice, right now, the client-side should just set this to be []string{"buf:lint:ignore"}.
	//
	// All elements must be non-empty.
	CommentExcludes []string
}

OptionsSpec builds option.Options for clients.

These can then be sent over the wire to servers.

Note that we don't expose OptionsSpec for the server-side rules, instead we rely on the static functions, as we want to move our rules to be as native to bufplugin-go as possible. Instead of i.e. attaching an Options struct to bufcheckserverutil.Requests, we have individual rules go through the direct reading of option.Options using the static functions below.

Only use this on the client side.

func (*OptionsSpec) ToOptions

func (o *OptionsSpec) ToOptions() (option.Options, error)

ToOptions builds a option.Options.

Jump to

Keyboard shortcuts

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