proto

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package proto implements utilities for managing GCP resource protos (e.g., copy, equal, merge).

Most of the implementations in this package are based on the implementations in the "official" proto package, i.e., "google.golang.org/protobuf/proto", with small modifications to serve Service Weaver GCP updating needs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Copy

func Copy(dst, src proto.Message, skipFields []string) ([]string, error)

Copy copies all populated message fields from src into dst, overwriting any existing values in dst. Fields in skipFields aren't copied, even if they are populated. Returns the list of all fields in dst that were modified during the copy, or nil otherwise.

func FromEnv

func FromEnv(in string, msg proto.Message) error

FromEnv fills msg from a string created by ToEnv.

func Merge

func Merge(dst, src proto.Message, cmpFields map[string]string) (bool, error)

Merge merges src into dst, using the following merge strategy:

  • Populated scalar fields in src are copied to dst.
  • Populated singular message fields in src are recursively merged into dst.
  • List fields in src are merged into dst as follows:
  • If an element in src "matches" an element in dst, the src element is recursively merged into the dst element. (If multiple elements in dst are matched, the src element is merged only into the first matched one.)
  • Otherwise, the src element is appended to the end of dst.
  • Whether two elements "match" depends on their type: # For message types, the elements match iff their messages' comparison fields (specified in cmpFields) are equal. # For all other types, the elements match if they are equal.
  • Map fields in src are merged into dst as follows:
  • If an entry with a given key exists in both src and dst, the src entry is recursively merged into the dst entry.
  • If an entry with a given key exists only in src, the src entry is inserted into dst.

Value true is returned iff dst was modified during the merge.

func ToEnv

func ToEnv(msg proto.Message) (string, error)

ToEnv converts msg to a string suitable for storing in the process's OS environment (i.e., os.Environ()).

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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