protomap

package
v0.29.19 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 15 Imported by: 1

Documentation

Overview

Package protomap provides utilities that map ygen-generated protobuf messages to and from other types (e.g., gNMI Notification messages, or ygen-generated GoStructs).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IgnoreExtraPaths added in v0.10.14

func IgnoreExtraPaths() *ignoreExtraPaths

IgnoreExtraPaths indicates that unmapping should ignore any additional paths that are found in the gNMI Notifications that do not have corresponding fields in the protobuf.

This option is typically used in conjunction with path compression where there are some leaves that do not have corresponding fields.

func PathsFromProto

func PathsFromProto(p proto.Message) (map[*gpb.Path]interface{}, error)

PathsFromProto returns, from a populated proto, a map between the YANG schema path (as specified in the yext.schemapath extension) and the value populated in the message.

func ProtoFromPaths added in v0.10.13

func ProtoFromPaths(p proto.Message, vals map[*gpb.Path]interface{}, opt ...UnmapOpt) error

ProtoFromPaths takes an input ygot-generated protobuf and unmarshals the values provided in vals into the map. The vals map must be keyed by the gNMI path to the leaf, with the interface{} value being the value that the leaf at the field should be set to.

The protobuf p is modified in place to add the values.

The set of UnmapOpts that are provided (opt) are used to control the behaviour of unmarshalling the specified data.

ProtoFromPaths returns an error if the data cannot be unmarshalled.

func ProtobufMessagePrefix added in v0.10.14

func ProtobufMessagePrefix(path *gpb.Path) *protoMsgPrefix

ProtobufMessagePrefix specifies the path that the protobuf message supplied to ProtoFromPaths makes up. This is used in cases where the message itself is not the root - and hence unmarshalling should look for paths relative to the specified path in the vals map.

func ValuePathPrefix added in v0.10.14

func ValuePathPrefix(path *gpb.Path) *valuePathPrefix

ValuePathPrefix indicates that the values in the supplied map have a prefix which is equal to the supplied path. The prefix plus each path in the vals map must be equal to the absolute path for the supplied values.

Types

type UnmapOpt added in v0.10.14

type UnmapOpt interface {
	// contains filtered or unexported methods
}

UnmapOpt marks that a particular option can be supplied as an argument to the ProtoFromPaths function.

Directories

Path Synopsis
Package integration_tests performs tests against real-world schemas for protomap.
Package integration_tests performs tests against real-world schemas for protomap.

Jump to

Keyboard shortcuts

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