Documentation ¶
Index ¶
- Constants
- Variables
- func DecodeNew[T any](node *Node) (protoreflect.Value, error)
- func Unmarshal(data []byte, message proto.Message) error
- type Bleeps
- type Blerp
- type Cache
- type CacheAccess
- func (CacheAccess) Descriptor() protoreflect.EnumDescriptor
- func (x CacheAccess) Enum() *CacheAccess
- func (CacheAccess) EnumDescriptor() ([]byte, []int)deprecated
- func (x CacheAccess) Number() protoreflect.EnumNumber
- func (x CacheAccess) String() string
- func (CacheAccess) Type() protoreflect.EnumType
- type Copy
- func (*Copy) Descriptor() ([]byte, []int)deprecated
- func (x *Copy) GetCtime() *Timestamp
- func (x *Copy) GetDestination() *Destination
- func (x *Copy) GetFrom() *Filesystem
- func (x *Copy) GetSource() string
- func (*Copy) ProtoMessage()
- func (x *Copy) ProtoReflect() protoreflect.Message
- func (x *Copy) Reset()
- func (x *Copy) String() string
- type DelegateMatch
- func (DelegateMatch) Descriptor() protoreflect.EnumDescriptor
- func (x DelegateMatch) Enum() *DelegateMatch
- func (DelegateMatch) EnumDescriptor() ([]byte, []int)deprecated
- func (x DelegateMatch) Number() protoreflect.EnumNumber
- func (x DelegateMatch) String() string
- func (DelegateMatch) Type() protoreflect.EnumType
- type Destination
- type Filesystem
- type Foo
- type Foo_Opt1
- type Foo_Opt2
- type Host
- type MessageDelegate
- type NoFields
- type Node
- func (node *Node) DecodeBytes() (protoreflect.Value, error)
- func (node *Node) DecodeEnum(field protoreflect.FieldDescriptor) (protoreflect.Value, error)
- func (node *Node) DecodeField(message protoreflect.Message, field protoreflect.FieldDescriptor) error
- func (node *Node) DecodeList(field protoreflect.FieldDescriptor, list protoreflect.List) error
- func (node *Node) DecodeMap(field protoreflect.FieldDescriptor, mmap protoreflect.Map) error
- func (node *Node) DecodeMessage(message protoreflect.Message) error
- func (node *Node) DecodeProto(pm proto.Message) error
- func (node *Node) DecodeScalar(kind protoreflect.Kind) (protoreflect.Value, error)
- func (node *Node) Entry(key string) (*Node, error)
- func (node *Node) Errorf(msg string, v ...any) error
- func (node *Node) Keys() []*Node
- func (node *Node) Len() int
- func (node *Node) MessageDelegate(message protoreflect.Message) MessageDelegate
- func (node *Node) WithEntry(key string, fn func(*Node) error) error
- func (node *Node) WithPairs(fn func(i int, k, v *Node) error) error
- type Op
- type Op_Copy
- type Op_Run
- type Opt1
- type Opt2
- type Pairs
- type Phrase
- type Run
- type Run_Option
- func (*Run_Option) Descriptor() ([]byte, []int)deprecated
- func (x *Run_Option) GetCache() *Cache
- func (x *Run_Option) GetHost() *Host
- func (x *Run_Option) GetLongName() string
- func (m *Run_Option) GetOpt() isRun_Option_Opt
- func (*Run_Option) ProtoMessage()
- func (x *Run_Option) ProtoReflect() protoreflect.Message
- func (x *Run_Option) Reset()
- func (x *Run_Option) String() string
- type Run_Option_Cache
- type Run_Option_Host
- type Run_Option_LongName
- type Timestamp
- type Unmarshaler
Constants ¶
const ( DelegateMatchUnspecified DelegateMatch = DelegateMatch_DELEGATE_MATCH_UNSPECIFIED DelegateMatchAllFields = DelegateMatch_DELEGATE_MATCH_ALL_FIELDS DelegateMatchFirstKey = DelegateMatch_DELEGATE_MATCH_FIRST_KEY )
const ( // WrapperFieldName is the name of the single field (`value`) used by // common wrapper types // // See https://protobuf.dev/reference/protobuf/google.protobuf/ WrapperFieldName protoreflect.Name = protoreflect.Name("value") )
Variables ¶
var ( DelegateMatch_name = map[int32]string{ 0: "DELEGATE_MATCH_UNSPECIFIED", 1: "DELEGATE_MATCH_ALL_FIELDS", 2: "DELEGATE_MATCH_FIRST_KEY", } DelegateMatch_value = map[string]int32{ "DELEGATE_MATCH_UNSPECIFIED": 0, "DELEGATE_MATCH_ALL_FIELDS": 1, "DELEGATE_MATCH_FIRST_KEY": 2, } )
Enum value maps for DelegateMatch.
var ( CacheAccess_name = map[int32]string{ 0: "CACHE_ACCESS_UNSPECIFIED", 1: "CACHE_ACCESS_SHARED", 2: "CACHE_ACCESS_PRIVATE", 3: "CACHE_ACCESS_LOCKED", } CacheAccess_value = map[string]int32{ "CACHE_ACCESS_UNSPECIFIED": 0, "CACHE_ACCESS_SHARED": 1, "CACHE_ACCESS_PRIVATE": 2, "CACHE_ACCESS_LOCKED": 3, } )
Enum value maps for CacheAccess.
var ( Blerp_name = map[int32]string{ 0: "BLERP_UNSPECIFIED", 1: "BLERP_BLERP", 2: "BLERP_BLORP", } Blerp_value = map[string]int32{ "BLERP_UNSPECIFIED": 0, "BLERP_BLERP": 1, "BLERP_BLORP": 2, } )
Enum value maps for Blerp.
var (
// optional string delegate = 8675309;
E_Delegate = &file_protoyaml_options_proto_extTypes[0]
)
Extension fields to descriptorpb.MessageOptions.
var (
// optional wikimedia.dduvall.protoyaml.DelegateMatch delegate_match = 8675309;
E_DelegateMatch = &file_protoyaml_options_proto_extTypes[1]
)
Extension fields to descriptorpb.OneofOptions.
var File_protoyaml_options_proto protoreflect.FileDescriptor
var File_protoyaml_test_proto protoreflect.FileDescriptor
Functions ¶
func DecodeNew ¶
func DecodeNew[T any](node *Node) (protoreflect.Value, error)
DecodeNew[T] takes a YAML node and returns a new protoreflect.Value based on a new T
Types ¶
type Bleeps ¶
type Bleeps struct { Blerps []Blerp `protobuf:"varint,1,rep,packed,name=blerps,proto3,enum=wikimedia.dduvall.protoyaml.test.Blerp" json:"blerps,omitempty"` // contains filtered or unexported fields }
func (*Bleeps) Descriptor
deprecated
func (*Bleeps) ProtoMessage ¶
func (*Bleeps) ProtoMessage()
func (*Bleeps) ProtoReflect ¶
func (x *Bleeps) ProtoReflect() protoreflect.Message
type Blerp ¶
type Blerp int32
func (Blerp) Descriptor ¶
func (Blerp) Descriptor() protoreflect.EnumDescriptor
func (Blerp) EnumDescriptor
deprecated
func (Blerp) Number ¶
func (x Blerp) Number() protoreflect.EnumNumber
func (Blerp) Type ¶
func (Blerp) Type() protoreflect.EnumType
type Cache ¶
type Cache struct { Target string `protobuf:"bytes,1,opt,name=target,proto3" json:"target,omitempty"` Access CacheAccess `protobuf:"varint,2,opt,name=access,proto3,enum=wikimedia.dduvall.protoyaml.test.CacheAccess" json:"access,omitempty"` // contains filtered or unexported fields }
func (*Cache) Descriptor
deprecated
func (*Cache) GetAccess ¶
func (x *Cache) GetAccess() CacheAccess
func (*Cache) ProtoMessage ¶
func (*Cache) ProtoMessage()
func (*Cache) ProtoReflect ¶
func (x *Cache) ProtoReflect() protoreflect.Message
type CacheAccess ¶
type CacheAccess int32
const ( CacheAccess_CACHE_ACCESS_UNSPECIFIED CacheAccess = 0 CacheAccess_CACHE_ACCESS_SHARED CacheAccess = 1 CacheAccess_CACHE_ACCESS_PRIVATE CacheAccess = 2 CacheAccess_CACHE_ACCESS_LOCKED CacheAccess = 3 )
func (CacheAccess) Descriptor ¶
func (CacheAccess) Descriptor() protoreflect.EnumDescriptor
func (CacheAccess) Enum ¶
func (x CacheAccess) Enum() *CacheAccess
func (CacheAccess) EnumDescriptor
deprecated
func (CacheAccess) EnumDescriptor() ([]byte, []int)
Deprecated: Use CacheAccess.Descriptor instead.
func (CacheAccess) Number ¶
func (x CacheAccess) Number() protoreflect.EnumNumber
func (CacheAccess) String ¶
func (x CacheAccess) String() string
func (CacheAccess) Type ¶
func (CacheAccess) Type() protoreflect.EnumType
type Copy ¶
type Copy struct { Source string `protobuf:"bytes,1,opt,name=source,proto3" json:"source,omitempty"` From *Filesystem `protobuf:"bytes,2,opt,name=from,proto3" json:"from,omitempty"` Destination *Destination `protobuf:"bytes,3,opt,name=destination,proto3" json:"destination,omitempty"` Ctime *Timestamp `protobuf:"bytes,4,opt,name=ctime,proto3" json:"ctime,omitempty"` // contains filtered or unexported fields }
func (*Copy) Descriptor
deprecated
func (*Copy) GetDestination ¶
func (x *Copy) GetDestination() *Destination
func (*Copy) GetFrom ¶
func (x *Copy) GetFrom() *Filesystem
func (*Copy) ProtoMessage ¶
func (*Copy) ProtoMessage()
func (*Copy) ProtoReflect ¶
func (x *Copy) ProtoReflect() protoreflect.Message
type DelegateMatch ¶
type DelegateMatch int32
const ( DelegateMatch_DELEGATE_MATCH_UNSPECIFIED DelegateMatch = 0 DelegateMatch_DELEGATE_MATCH_ALL_FIELDS DelegateMatch = 1 DelegateMatch_DELEGATE_MATCH_FIRST_KEY DelegateMatch = 2 )
func (DelegateMatch) Descriptor ¶
func (DelegateMatch) Descriptor() protoreflect.EnumDescriptor
func (DelegateMatch) Enum ¶
func (x DelegateMatch) Enum() *DelegateMatch
func (DelegateMatch) EnumDescriptor
deprecated
func (DelegateMatch) EnumDescriptor() ([]byte, []int)
Deprecated: Use DelegateMatch.Descriptor instead.
func (DelegateMatch) Number ¶
func (x DelegateMatch) Number() protoreflect.EnumNumber
func (DelegateMatch) String ¶
func (x DelegateMatch) String() string
func (DelegateMatch) Type ¶
func (DelegateMatch) Type() protoreflect.EnumType
type Destination ¶
type Destination struct { Path string `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"` // contains filtered or unexported fields }
func (*Destination) Descriptor
deprecated
func (*Destination) Descriptor() ([]byte, []int)
Deprecated: Use Destination.ProtoReflect.Descriptor instead.
func (*Destination) GetPath ¶
func (x *Destination) GetPath() string
func (*Destination) ProtoMessage ¶
func (*Destination) ProtoMessage()
func (*Destination) ProtoReflect ¶
func (x *Destination) ProtoReflect() protoreflect.Message
func (*Destination) Reset ¶
func (x *Destination) Reset()
func (*Destination) String ¶
func (x *Destination) String() string
type Filesystem ¶
type Filesystem struct { Ref string `protobuf:"bytes,1,opt,name=ref,proto3" json:"ref,omitempty"` // contains filtered or unexported fields }
func (*Filesystem) Descriptor
deprecated
func (*Filesystem) Descriptor() ([]byte, []int)
Deprecated: Use Filesystem.ProtoReflect.Descriptor instead.
func (*Filesystem) GetRef ¶
func (x *Filesystem) GetRef() string
func (*Filesystem) ProtoMessage ¶
func (*Filesystem) ProtoMessage()
func (*Filesystem) ProtoReflect ¶
func (x *Filesystem) ProtoReflect() protoreflect.Message
func (*Filesystem) Reset ¶
func (x *Filesystem) Reset()
func (*Filesystem) String ¶
func (x *Filesystem) String() string
type Foo ¶
type Foo struct { // Types that are assignable to Opt: // // *Foo_Opt1 // *Foo_Opt2 Opt isFoo_Opt `protobuf_oneof:"opt"` // contains filtered or unexported fields }
func (*Foo) Descriptor
deprecated
func (*Foo) ProtoMessage ¶
func (*Foo) ProtoMessage()
func (*Foo) ProtoReflect ¶
func (x *Foo) ProtoReflect() protoreflect.Message
type Host ¶
type Host struct { Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` Ip string `protobuf:"bytes,2,opt,name=ip,proto3" json:"ip,omitempty"` // contains filtered or unexported fields }
func (*Host) Descriptor
deprecated
func (*Host) ProtoMessage ¶
func (*Host) ProtoMessage()
func (*Host) ProtoReflect ¶
func (x *Host) ProtoReflect() protoreflect.Message
type MessageDelegate ¶
type MessageDelegate interface { // Field returns the descriptor for the field that should act as the message // delegate and by populated by the YAML node. Field() protoreflect.FieldDescriptor // MatchedBy returns the method by which a oneof field specified as the // message delegate was matched. MatchedBy() DelegateMatch }
MessageDelegate represents information about a message delegate, namely the message field that should be populated by the YAML node.
type NoFields ¶
type NoFields struct {
// contains filtered or unexported fields
}
func (*NoFields) Descriptor
deprecated
func (*NoFields) ProtoMessage ¶
func (*NoFields) ProtoMessage()
func (*NoFields) ProtoReflect ¶
func (x *NoFields) ProtoReflect() protoreflect.Message
type Node ¶
type Node struct {
*yaml.Node
}
Node encapsulates a yaml.Node and provides methods for parsing YAML nodes into protobuf types
func (*Node) DecodeBytes ¶
func (node *Node) DecodeBytes() (protoreflect.Value, error)
DecodeBytes decodes the YAML node with base64 encoded data and decodes it into a new protoreflect.Value.
func (*Node) DecodeEnum ¶
func (node *Node) DecodeEnum(field protoreflect.FieldDescriptor) (protoreflect.Value, error)
DecodeEnum decodes the YAML node to an enum field.
Rules ¶
## Node is a !!str
- Convert the node value to uppercase
- Resolve an enum value by name
- If not found, try to prefix the node value with upper underscore case version of enum name (e.g. `CACHE_ACCESS_` for `CacheAccess`)
- Resolve an enum value by name
## Node is an !!int
- Resolve an enum value by number
## Otherwise
- Error
func (*Node) DecodeField ¶
func (node *Node) DecodeField(message protoreflect.Message, field protoreflect.FieldDescriptor) error
DecodeField decodes the YAML node into the given field.
Rules ¶
## Field is a map
- Decode field using [DecodeMap]
## Field is a list
- Decode field using [DecodeList]
## Field is a message
- If underlying interface implements Unmarshaler, call UnmarshalProtoYAML on interface.
- If underlying interface implements yaml.Unmarshaler, call UnmarshalYAML on interface.
- Otherwise, recurse on field's protoreflect.Message with [DecodeMessage].
## Field is an enum
- Decode field using [DecodeEnum].
## Otherwise
- Decode field using [DecodeScalar].
func (*Node) DecodeList ¶
func (node *Node) DecodeList(field protoreflect.FieldDescriptor, list protoreflect.List) error
DecodeList decodes the YAML node to a mutable repeated (list) value.
Rules ¶
## Node is a sequence
- Decode each content node to a new list value and append.
## Otherwise, error
func (*Node) DecodeMap ¶
func (node *Node) DecodeMap(field protoreflect.FieldDescriptor, mmap protoreflect.Map) error
DecodeMap decodes the YAML node to a mutable repeated (map) value.
Rules ¶
## Node is a map
- Decode each content node pair into a key/value and append the map.
## Otherwise, error
func (*Node) DecodeMessage ¶
func (node *Node) DecodeMessage(message protoreflect.Message) error
DecodeMessage decodes the current YAML node into the given protoreflect.Message.
#Rules
## Message contains no fields
- Discard node
## Message contains a `protoyaml.delegate` option
- Resolve delegate
- Decode to delegate field using [DecodeField]
## Message contains single field called `value`
- Assume a wrapper message type
- Decode this node to single field
## Mapping
- Iterate over node pairs.
- Replace `-` in key name with `_`. Note case is not converted.
- Match key to message fields by name.
- Check oneof encapsulated fields first, disregarding oneof name.
- Check other fields next.
- Upon a match, decode pair value node to field. See [DecodeField] for field rules.
## Other
- Discard node
func (*Node) DecodeProto ¶
DecodeProto decodes the current YAML node into the given proto.Message implementation. See [DecodeMessage] for parsing rules.
func (*Node) DecodeScalar ¶
func (node *Node) DecodeScalar(kind protoreflect.Kind) (protoreflect.Value, error)
DecodeScalar decodes the YAML node to a new scalar protoreflect.Value.
func (*Node) Errorf ¶
Errorf returns an [error] with line/column information from the encapsulated yaml.Node
func (*Node) Len ¶
Len returns the _effective_ content length. For YAML mapping nodes, this is the number of entries. For YAML sequence nodes (and all other node types), this is the same as `len(node.Content)`.
func (*Node) MessageDelegate ¶
func (node *Node) MessageDelegate(message protoreflect.Message) MessageDelegate
MessageDelegate returns the field that has been assigned as the message delegate using the `protoyaml.delegate` message option.
Example proto ¶
message Option { option (protoyaml.delegate) = "opt"; oneof opt { option (protoyaml.match) = MATCH_FIRST_KEY; Host host = 1; Cache cache = 2; } }
type Op ¶
type Op struct { // Types that are assignable to Op: // // *Op_Run // *Op_Copy Op isOp_Op `protobuf_oneof:"op"` // contains filtered or unexported fields }
func (*Op) Descriptor
deprecated
func (*Op) ProtoMessage ¶
func (*Op) ProtoMessage()
func (*Op) ProtoReflect ¶
func (x *Op) ProtoReflect() protoreflect.Message
type Opt1 ¶
type Opt1 struct { Field1 string `protobuf:"bytes,1,opt,name=field1,proto3" json:"field1,omitempty"` Field2 string `protobuf:"bytes,2,opt,name=field2,proto3" json:"field2,omitempty"` // contains filtered or unexported fields }
func (*Opt1) Descriptor
deprecated
func (*Opt1) ProtoMessage ¶
func (*Opt1) ProtoMessage()
func (*Opt1) ProtoReflect ¶
func (x *Opt1) ProtoReflect() protoreflect.Message
type Opt2 ¶
type Opt2 struct { Field1 string `protobuf:"bytes,1,opt,name=field1,proto3" json:"field1,omitempty"` Field2 string `protobuf:"bytes,2,opt,name=field2,proto3" json:"field2,omitempty"` Field3 string `protobuf:"bytes,3,opt,name=field3,proto3" json:"field3,omitempty"` // contains filtered or unexported fields }
func (*Opt2) Descriptor
deprecated
func (*Opt2) ProtoMessage ¶
func (*Opt2) ProtoMessage()
func (*Opt2) ProtoReflect ¶
func (x *Opt2) ProtoReflect() protoreflect.Message
type Pairs ¶
type Pairs struct { Pairs map[string]string `` /* 151-byte string literal not displayed */ // contains filtered or unexported fields }
func (*Pairs) Descriptor
deprecated
func (*Pairs) ProtoMessage ¶
func (*Pairs) ProtoMessage()
func (*Pairs) ProtoReflect ¶
func (x *Pairs) ProtoReflect() protoreflect.Message
type Phrase ¶
type Phrase struct { Words []string `protobuf:"bytes,1,rep,name=words,proto3" json:"words,omitempty"` // contains filtered or unexported fields }
func (*Phrase) Descriptor
deprecated
func (*Phrase) ProtoMessage ¶
func (*Phrase) ProtoMessage()
func (*Phrase) ProtoReflect ¶
func (x *Phrase) ProtoReflect() protoreflect.Message
type Run ¶
type Run struct { Command string `protobuf:"bytes,1,opt,name=command,proto3" json:"command,omitempty"` Arguments []string `protobuf:"bytes,2,rep,name=arguments,proto3" json:"arguments,omitempty"` Options []*Run_Option `protobuf:"bytes,3,rep,name=options,proto3" json:"options,omitempty"` // contains filtered or unexported fields }
func (*Run) Descriptor
deprecated
func (*Run) GetArguments ¶
func (*Run) GetCommand ¶
func (*Run) GetOptions ¶
func (x *Run) GetOptions() []*Run_Option
func (*Run) ProtoMessage ¶
func (*Run) ProtoMessage()
func (*Run) ProtoReflect ¶
func (x *Run) ProtoReflect() protoreflect.Message
type Run_Option ¶
type Run_Option struct { // Types that are assignable to Opt: // // *Run_Option_Host // *Run_Option_Cache // *Run_Option_LongName Opt isRun_Option_Opt `protobuf_oneof:"opt"` // contains filtered or unexported fields }
func (*Run_Option) Descriptor
deprecated
func (*Run_Option) Descriptor() ([]byte, []int)
Deprecated: Use Run_Option.ProtoReflect.Descriptor instead.
func (*Run_Option) GetCache ¶
func (x *Run_Option) GetCache() *Cache
func (*Run_Option) GetHost ¶
func (x *Run_Option) GetHost() *Host
func (*Run_Option) GetLongName ¶
func (x *Run_Option) GetLongName() string
func (*Run_Option) GetOpt ¶
func (m *Run_Option) GetOpt() isRun_Option_Opt
func (*Run_Option) ProtoMessage ¶
func (*Run_Option) ProtoMessage()
func (*Run_Option) ProtoReflect ¶
func (x *Run_Option) ProtoReflect() protoreflect.Message
func (*Run_Option) Reset ¶
func (x *Run_Option) Reset()
func (*Run_Option) String ¶
func (x *Run_Option) String() string
type Run_Option_Cache ¶
type Run_Option_Cache struct {
Cache *Cache `protobuf:"bytes,2,opt,name=cache,proto3,oneof"`
}
type Run_Option_Host ¶
type Run_Option_Host struct {
Host *Host `protobuf:"bytes,1,opt,name=host,proto3,oneof"`
}
type Run_Option_LongName ¶
type Run_Option_LongName struct {
LongName string `protobuf:"bytes,3,opt,name=long_name,json=longName,proto3,oneof"`
}
type Timestamp ¶
type Timestamp struct { Value int64 `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"` // contains filtered or unexported fields }
func (*Timestamp) Descriptor
deprecated
func (*Timestamp) ProtoMessage ¶
func (*Timestamp) ProtoMessage()
func (*Timestamp) ProtoReflect ¶
func (x *Timestamp) ProtoReflect() protoreflect.Message
type Unmarshaler ¶
Unmarshaler describes an interface that can decode a Node