parsing

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2017 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreatePath

func CreatePath(input []string) string

CreatePath Given an array, construct it into a jmespath expression (string with . separator)

func DoMapArrayKeysMatch

func DoMapArrayKeysMatch(o interface{}, m interface{}) bool

DoMapArrayKeysMatch Uses 'UnorderedKeyMatch' to return a bool for two interfaces if they're both maps

func GetSliceOfKeys

func GetSliceOfKeys(input KeyValue) []string

GetSliceOfKeys creates a slice of keys from an object

func IndexOf

func IndexOf(inputList []string, inputKey string) int

IndexOf Finds index of an object in a given array

func MapMatchAny

func MapMatchAny(a map[string]interface{}, b map[string]interface{}) bool

MapMatchAny check if map exists in larger map

func MatchAny

func MatchAny(compare interface{}, compareSlice []interface{}) bool

MatchAny check if an object exists anywhere in a slice

func PathSplit

func PathSplit(input string) []string

PathSplit Splits up jmespath format path into a slice, will ignore escaped '.' ; opposite of CreatePath

func SliceIndex

func SliceIndex(i int, path []string) []string

SliceIndex Adds an 'index' value to the last string in the slice, used for the 'path' to handle arrays.

func SliceIndexOf

func SliceIndexOf(item interface{}, list []interface{}) int

SliceIndexOf find index of item from in slice

func UnorderedKeyMatch

func UnorderedKeyMatch(o map[string]interface{}, m map[string]interface{}) bool

UnorderedKeyMatch Returns a bool dependant on all 'keys' in a map matching.

Types

type AddedDifference

type AddedDifference struct {
	Key   string `json:",omitempty"`
	Path  string
	Value interface{}
	// contains filtered or unexported fields
}

AddedDifference sub struct for added objects

type ChangedDifference

type ChangedDifference struct {
	Key      string `json:",omitempty"`
	Path     string
	NewValue interface{}
	OldValue interface{}
	// contains filtered or unexported fields
}

ChangedDifference sub struct for changed objects

type ConsumableDifference

type ConsumableDifference struct {
	Changed []ChangedDifference `json:",omitempty"`
	Added   []AddedDifference   `json:",omitempty"`
	Removed []RemovedDifference `json:",omitempty"`
	Indexes []IndexDifference   `json:",omitempty"`
}

ConsumableDifference eventual return object

func (*ConsumableDifference) Read

func (c *ConsumableDifference) Read(file string) error

Read helper to read file that handles bom and unmarshals for our patch

func (*ConsumableDifference) Sort

func (c *ConsumableDifference) Sort() error

Sort each key in our object so marshaled object is also consistent

type Gaussian

type Gaussian struct {
	Data interface{} // What we read into the struct
	Type string      // Json/Yaml
}

Gaussian wrapper to handle inputs

func (*Gaussian) Read

func (g *Gaussian) Read(file string) error

Read gaussian type reader method for raw json or yaml

func (*Gaussian) Write

func (g *Gaussian) Write(output io.Writer) error

Write marshals data based on type and outputs to writer

type IndexDifference

type IndexDifference struct {
	NewIndex int
	OldIndex int
	Path     string
	Value    interface{}
	// contains filtered or unexported fields
}

IndexDifference sub struct for list index changes

type KeySlice

type KeySlice map[string][]KeyValue

KeySlice map of string to slice of KeyValue

var FormattedDiff KeySlice

FormattedDiff difference visualized as object

type KeyValue

type KeyValue map[string]interface{}

KeyValue map of string to interface

func Format

func Format(input ConsumableDifference) KeyValue

Format formatting function

func Remarshal

func Remarshal(input interface{}) KeyValue

Remarshal deprecated

type RemovedDifference

type RemovedDifference struct {
	Key   string `json:",omitempty"`
	Path  string
	Value interface{}
	// contains filtered or unexported fields
}

RemovedDifference sub struct for removed objects

Jump to

Keyboard shortcuts

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