utils

package
v0.5.7 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2020 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains

func Contains(s []string, e string) bool

func CopyMap

func CopyMap(o map[string]string) (r map[string]string)

func MakeBinaryLiteral added in v0.3.35

func MakeBinaryLiteral(v []byte) *core.Literal

func MakeDefaultLiteralForType added in v0.3.35

func MakeDefaultLiteralForType(typ *core.LiteralType) (*core.Literal, error)

func MakeGenericLiteral added in v0.3.35

func MakeGenericLiteral(v *structpb.Struct) *core.Literal

func MakeLiteral added in v0.3.35

func MakeLiteral(v interface{}) (*core.Literal, error)

func MakeLiteralForBlob added in v0.3.35

func MakeLiteralForBlob(path storage.DataReference, isDir bool, format string) *core.Literal

func MakeLiteralForCollection added in v0.3.35

func MakeLiteralForCollection(v []interface{}) (*core.Literal, error)

func MakeLiteralForMap added in v0.3.35

func MakeLiteralForMap(v map[string]interface{}) (*core.Literal, error)

func MakeLiteralForSimpleType added in v0.3.35

func MakeLiteralForSimpleType(t core.SimpleType, s string) (*core.Literal, error)

func MakeLiteralMap added in v0.3.35

func MakeLiteralMap(v map[string]interface{}) (*core.LiteralMap, error)

func MakePrimitive added in v0.3.35

func MakePrimitive(v interface{}) (*core.Primitive, error)

func MakePrimitiveForType added in v0.3.35

func MakePrimitiveForType(t core.SimpleType, s string) (*core.Primitive, error)

func MakePrimitiveLiteral added in v0.3.35

func MakePrimitiveLiteral(v interface{}) (*core.Literal, error)

func MarshalObjToStruct

func MarshalObjToStruct(input interface{}) (*structpb.Struct, error)

TODO: Use the stdlib version in the future, or move there if not there. Don't use this if input is a proto Message.

func MarshalStruct

func MarshalStruct(in proto.Message, out *structpb.Struct) error

func MarshalToString

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

func MustMakeDefaultLiteralForType added in v0.3.35

func MustMakeDefaultLiteralForType(typ *core.LiteralType) *core.Literal

func MustMakeLiteral added in v0.3.35

func MustMakeLiteral(v interface{}) *core.Literal

func MustMakePrimitive added in v0.3.35

func MustMakePrimitive(v interface{}) *core.Primitive

func MustMakePrimitiveLiteral added in v0.3.35

func MustMakePrimitiveLiteral(v interface{}) *core.Literal

func ReplaceTemplateCommandArgs

func ReplaceTemplateCommandArgs(ctx context.Context, command []string, in io.InputReader, out io.OutputFilePaths) ([]string, error)

Evaluates templates in each command with the equivalent value from passed args. Templates are case-insensitive Supported templates are:

  • {{ .InputFile }} to receive the input file path. The protocol used will depend on the underlying system configuration. E.g. s3://bucket/key/to/file.pb or /var/run/local.pb are both valid.
  • {{ .OutputPrefix }} to receive the path prefix for where to store the outputs.
  • {{ .Inputs.myInput }} to receive the actual value of the input passed. See docs on LiteralMapToTemplateArgs for how what to expect each literal type to be serialized as.

If a command isn't a valid template or failed to evaluate, it'll be returned as is. NOTE: I wanted to do in-place replacement, until I realized that in-place replacement will alter the definition of the graph. This is not desirable, as we may have to retry and in that case the replacement will not work and we want to create a new location for outputs

func UnionMaps

func UnionMaps(maps ...map[string]string) map[string]string

This function unions a list of maps (each can be nil or populated) by allocating a new map. Conflicting keys will always defer to the later input map's corresponding value.

func UnmarshalStruct

func UnmarshalStruct(structObj *structpb.Struct, msg proto.Message) error

Types

type ErrorCollection added in v0.3.28

type ErrorCollection struct {
	Errors []error
}

func (ErrorCollection) Error added in v0.3.28

func (e ErrorCollection) Error() string

Jump to

Keyboard shortcuts

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