util

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2021 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Overview

Package util util consists of general utility functions and structures.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package util util consists of general utility functions and structures.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package util util consists of general utility functions and structures.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package util util consists of general utility functions and structures.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package util util consists of general utility functions and structures.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package util util consists of general utility functions and structures.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package util util consists of general utility functions and structures.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package util util consists of general utility functions and structures.

This code is taken from file encoding/json/encoding.go (1.15.8) and has been modified.

Copyright 2010 The Go Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

Package util util consists of general utility functions and structures.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package util util consists of general utility functions and structures.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package util util consists of general utility functions and structures.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package util util consists of general utility functions and structures.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package util util consists of general utility functions and structures.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package util util consists of general utility functions and structures.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package util util consists of general utility functions and structures.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package util util consists of general utility functions and structures.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package util util consists of general utility functions and structures.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package util util consists of general utility functions and structures.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package util util consists of general utility functions and structures.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package util util consists of general utility functions and structures.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package util util consists of general utility functions and structures.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package util util consists of general utility functions and structures.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package util util consists of general utility functions and structures.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package util util consists of general utility functions and structures.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package util util consists of general utility functions and structures.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	JSONS_UNDEFINED jsonState = iota
	JSONS_OPEN
	JSONS_DONE
	JSONS_O  // object attribute, expecting string or }
	JSONS_OV // object value, expecting {, [ VALUE or }
	JSONS_A  // array value, expecting {, [ VALUE or ]
	JSONS_AV // close array value, required for simple values
)

Variables

This section is empty.

Functions

func AddDollar

func AddDollar(s string) string

AddDollar prepends a dollar sign to the string if it

func ByteCountIEC added in v0.1.1

func ByteCountIEC(b int64) string

ByteCountIEC returns the byte size in IEC units

func ByteCountSI added in v0.1.1

func ByteCountSI(b int64) string

ByteCountSI returns the byte size in SI units

func Comma added in v0.2.0

func Comma(ar ...string) string

func Concat added in v0.2.0

func Concat(sep string, ar ...string) string

func ConsoleWidth added in v0.3.0

func ConsoleWidth() (int, error)

func Contains

func Contains(value string, ar []string) bool

Contains checks for the existence of the passed value in the array

func ContainsS

func ContainsS(value string, ar []string) string

ContainsS checks for the existence of the passed value in the array

func Dashed

func Dashed(str string) string

Dashed returns the string "-" if passed string is empty.

func Difference

func Difference(a, b []string) []string

Difference substitues the array of strings b from a

func Example

func Example(s string) string

Example normalizes the example section

func Form added in v0.1.1

func Form(s string) string

Form normalizes the form text

func GetInt

func GetInt(value interface{}) (result int)

GetInt returns the int value for the passed value or -1 for invalid input.

func GetString

func GetString(value interface{}) (result string)

GetString accepts a value and tries to return a string representation. If a conversion is not possible, then this function returns an error.

func HasPipe added in v0.3.0

func HasPipe() bool

func IsNumeric added in v0.2.0

func IsNumeric(value string) bool

func JSONFloat added in v0.2.0

func JSONFloat(f float64, bits int) string

JSONFloat encodes a float to JSON format

func JSONPrintPretty added in v0.2.0

func JSONPrintPretty(dec *json.Decoder, out io.Writer) error

JSONPrintPretty streams the dec JSON content in an indented format to out

func JSONPrintPrettyln added in v0.3.1

func JSONPrintPrettyln(dec *json.Decoder, out io.Writer) error

func JSONString added in v0.2.0

func JSONString(s string) string

JSONString encodes a string to JSON format

func LineCount added in v0.1.1

func LineCount(str string) int

LineCount returns the number of lines

func LoadPrivateKeyPEM

func LoadPrivateKeyPEM(path string) (*rsa.PrivateKey, error)

LoadPrivateKeyPEM reads the private key from the passed file in PEM format.

func LocalTimeStr

func LocalTimeStr(str string) string

LocalTimeStr converts time string in RFC3339 to local time in RFC822

func LocalTimeStrCustom

func LocalTimeStrCustom(str, fmt string) string

LocalTimeStrCustom converts time string in RFC3339 to local time in custom format

func LongDesc

func LongDesc(s string) string

LongDesc normalizes the long description

func NewJSONPathAttribute added in v0.2.0

func NewJSONPathAttribute(name string) *jsonPathElement

func NewJSONPathIndex added in v0.2.0

func NewJSONPathIndex(index int) *jsonPathElement

func Paste added in v0.1.1

func Paste() string

Paste returns the textual content stored in the clipboard

func Plural

func Plural(str string) string

Plural generates the English plural of the passed string

func RemoveQuotes

func RemoveQuotes(s string) string

RemoveQuotes removes embracing quotes, e.g. "hello" becomes hello and 'world' becomes world

func StringOr added in v0.1.1

func StringOr(a, b string) string

StringOr returns the first string if it is not empty, otherwise the last one

func Truncate added in v0.3.0

func Truncate(value string, max int) string

Types

type Claim

type Claim struct {
	Iss string // iss (issuer):identifies the principal that issued the JWT
	Sub string // sub (subject): identifies the principal that is the subject of the JWT
	Aud string // aud (audience): identifies the recipients that the JWT is intended for
}

Claim contains the three regisitered claims required for authentication. See https://tools.ietf.org/html/rfc7519 for more details.

func (*Claim) JWT

func (claim *Claim) JWT(key *rsa.PrivateKey) (string, error)

JWT calculates the signature of the claim and returns the JSON Web Token.

type ConfigFile added in v0.1.1

type ConfigFile struct {
	Node *yaml.Node
	Path string
}

ConfigFile represents a configuration file in YAML format

func LoadConfigFile added in v0.1.1

func LoadConfigFile(cfg *RootConfig) (*ConfigFile, error)

LoadConfigFile loads the configuration file in YAML format for the passed path

func (*ConfigFile) ClientID added in v0.1.1

func (f *ConfigFile) ClientID() string

ClientID returns the current client id value

func (*ConfigFile) ClientSecret added in v0.1.1

func (f *ConfigFile) ClientSecret() string

ClientSecret returns the current client secret value

func (*ConfigFile) Key added in v0.1.1

func (f *ConfigFile) Key() string

Key returns the current private key path value

func (*ConfigFile) Organization added in v0.1.1

func (f *ConfigFile) Organization() string

Organization returns the current organization value

func (*ConfigFile) Query added in v0.1.1

func (f *ConfigFile) Query() *YAMLQuery

Query returns this configuraion as YAMLQuery

func (*ConfigFile) Sandbox added in v0.1.1

func (f *ConfigFile) Sandbox() string

Sandbox returns the current sandbox value

func (*ConfigFile) Save added in v0.1.1

func (f *ConfigFile) Save() error

Save saves the configuration in YAML format

func (*ConfigFile) SetClientID added in v0.1.1

func (f *ConfigFile) SetClientID(id string)

SetClientID sets the new client id value

func (*ConfigFile) SetClientSecret added in v0.1.1

func (f *ConfigFile) SetClientSecret(secret string)

SetClientSecret sets the new client secret value

func (*ConfigFile) SetKey added in v0.1.1

func (f *ConfigFile) SetKey(key string)

SetKey sets the new private key path value

func (*ConfigFile) SetOrganization added in v0.1.1

func (f *ConfigFile) SetOrganization(org string)

SetOrganization sets the new organization value

func (*ConfigFile) SetSandbox added in v0.1.1

func (f *ConfigFile) SetSandbox(sandbox string)

SetSandbox sets the new sandbox value

func (*ConfigFile) SetTechAccount added in v0.1.1

func (f *ConfigFile) SetTechAccount(account string)

SetTechAccount sets the new technical account value

func (*ConfigFile) TechAccount added in v0.1.1

func (f *ConfigFile) TechAccount() string

TechAccount returns the current technical account value

type DescriptorRange added in v0.2.0

type DescriptorRange struct {
	Vars    []*DescriptorVars        `json:"vars,omitempty" yaml:"vars,omitempty"`
	Columns []*TableColumnDescriptor `json:"columns,omitempty" yaml:"columns,omitempty"`
	Post    *RangePost               `json:"post,omitempty" yaml:"post,omitempty"`
	Type    string                   `json:"type,omitempty" yaml:"type,omitempty"`
	Path    []string                 `json:"path,omitempty" yaml:"path,omitempty"`
}

DescriptorRange represents a range. Usually used to extract sub-values in multiple rows

type DescriptorVars added in v0.2.0

type DescriptorVars struct {
	Name  string   `json:"name,omitempty" yaml:"name,omitempty"`
	Type  string   `json:"type,omitempty" yaml:"type,omitempty"`
	Meta  string   `json:"meta,omitempty" yaml:"meta,omitempty"`
	Cast  string   `json:"cast,omitempty" yaml:"cast,omitempty"`
	Value string   `json:"value,omitempty" yaml:"value,omitempty"`
	Path  []string `json:"path,omitempty" yaml:"path,omitempty"`
}

DescriptorVars represents a variable

type Dir added in v0.1.1

type Dir struct {
	Path string
	// contains filtered or unexported fields
}

Dir helps to browse directories

func NewDir added in v0.1.1

func NewDir() (*Dir, error)

NewDir creates an initialized Dir object for the current directory

func NewDirPath added in v0.1.1

func NewDirPath(dir string) (*Dir, error)

NewDirPath creates an initialized Dir object for the passed path

func (*Dir) Child added in v0.1.1

func (d *Dir) Child(name string) (*Dir, error)

Child returns the Dir object for the child with the passed name

func (*Dir) ChildI added in v0.1.1

func (d *Dir) ChildI(i int) (*Dir, error)

ChildI returns the Dir object of the ith child

func (*Dir) HasParent added in v0.1.1

func (d *Dir) HasParent() bool

HasParent returns true if this Dir object is not root

func (*Dir) IsDir added in v0.1.1

func (d *Dir) IsDir(i int) bool

IsDir returns true if the ith child is a directory

func (*Dir) Parent added in v0.1.1

func (d *Dir) Parent() (*Dir, error)

Parent returns the parent Dir object or nil if this Dir object is root

func (*Dir) PathI added in v0.1.1

func (d *Dir) PathI(i int) string

PathI returns the full path for the ith child

func (*Dir) SortedByModTime added in v0.1.1

func (d *Dir) SortedByModTime(hidden, sep, asc bool) []os.FileInfo

SortedByModTime returns a list of FileInfo objects sorted by modification date

func (*Dir) SortedByName added in v0.1.1

func (d *Dir) SortedByName(hidden, sep, asc bool) []os.FileInfo

SortedByName returns a list of FileInfo objects sorted by name

func (*Dir) SortedBySize added in v0.1.1

func (d *Dir) SortedBySize(hidden, sep, asc bool) []os.FileInfo

SortedBySize returns a list of FileInfo objects sorted by size

type JSONCursor added in v0.2.0

type JSONCursor struct {
	// contains filtered or unexported fields
}

func NewJSONCursor added in v0.2.0

func NewJSONCursor(stream io.ReadCloser) *JSONCursor

func (*JSONCursor) Decode added in v0.2.0

func (j *JSONCursor) Decode(v interface{}) error

func (*JSONCursor) End added in v0.3.0

func (j *JSONCursor) End() error

func (*JSONCursor) More added in v0.2.0

func (j *JSONCursor) More() bool

func (*JSONCursor) MoreTokens added in v0.2.0

func (j *JSONCursor) MoreTokens() bool

func (*JSONCursor) New added in v0.3.0

func (j *JSONCursor) New() (*JSONCursor, error)

func (*JSONCursor) NextValue added in v0.2.0

func (j *JSONCursor) NextValue() (*Query, error)

func (*JSONCursor) NextValueF added in v0.2.0

func (j *JSONCursor) NextValueF(filter []string) (*Query, error)

func (*JSONCursor) Offset added in v0.2.0

func (j *JSONCursor) Offset() int64

func (*JSONCursor) PathInfo added in v0.2.0

func (j *JSONCursor) PathInfo() (string, string)

func (*JSONCursor) PrintPretty added in v0.2.0

func (j *JSONCursor) PrintPretty() error

PrintPretty prints the raw data with indention to standard out

func (*JSONCursor) PrintRaw added in v0.2.0

func (j *JSONCursor) PrintRaw() error

PrintRaw copies the raw data to standard out

func (*JSONCursor) Skip added in v0.2.0

func (j *JSONCursor) Skip() error

Skip skips the next element like for example a string, object or array

func (*JSONCursor) Token added in v0.2.0

func (j *JSONCursor) Token() (json.Token, error)

type JSONFile added in v0.2.0

type JSONFile struct {
	// contains filtered or unexported fields
}

JSONFile stores json objects in a file

func NewJSONFile added in v0.2.0

func NewJSONFile(path Path) *JSONFile

NewJSONFile returns an initialzed JSONCache object

func (*JSONFile) Delete added in v0.2.0

func (jc *JSONFile) Delete() error

Delete deletes the related file

func (*JSONFile) Exists added in v0.2.0

func (jc *JSONFile) Exists() bool

Exists returns true if the related file exists

func (*JSONFile) Load added in v0.2.0

func (jc *JSONFile) Load(obj interface{}) error

Load loads the json file into the passed object

func (*JSONFile) Save added in v0.2.0

func (jc *JSONFile) Save(obj interface{}) error

Save stores the passed object in json format to a file

type JSONFinder added in v0.2.0

type JSONFinder struct {
	// contains filtered or unexported fields
}

func NewJSONFinder added in v0.2.0

func NewJSONFinder() *JSONFinder

func (*JSONFinder) Add added in v0.2.0

func (j *JSONFinder) Add(f func(JSONResponse) error, path ...string)

func (*JSONFinder) Run added in v0.2.0

func (j *JSONFinder) Run() error

Path skips all element along the path

func (*JSONFinder) SetIterator added in v0.2.0

func (j *JSONFinder) SetIterator(i JSONResponse)

type JSONIterator added in v0.2.0

type JSONIterator struct {
	// contains filtered or unexported fields
}

JSONIterator implements the JSONResponse interface

func NewJSONIterator added in v0.2.0

func NewJSONIterator(c *JSONCursor) *JSONIterator

func (*JSONIterator) Bool added in v0.2.0

func (j *JSONIterator) Bool() (bool, error)

Bool returns the boolean at the current position

func (*JSONIterator) Cursor added in v0.3.0

func (j *JSONIterator) Cursor() *JSONCursor

func (*JSONIterator) Delim added in v0.2.0

func (j *JSONIterator) Delim() (json.Delim, error)

Delim returns the delimiter like [,],{ or} at the current position

func (*JSONIterator) Enter added in v0.2.0

func (j *JSONIterator) Enter() error

Enter moves forward to the first element

func (*JSONIterator) EnterArray added in v0.2.0

func (j *JSONIterator) EnterArray() error

EnterArray moves forward to the first element in the array

func (*JSONIterator) EnterObject added in v0.2.0

func (j *JSONIterator) EnterObject() error

EnterObject moves forward to the first element in the object

func (*JSONIterator) Float added in v0.2.0

func (j *JSONIterator) Float() (float64, error)

Float returns the floating point number at the current position

func (*JSONIterator) Interface added in v0.2.0

func (j *JSONIterator) Interface() (interface{}, error)

Interface returns any element at the current position

func (*JSONIterator) Leave added in v0.2.0

func (j *JSONIterator) Leave() error

Enter moves forward to the first element

func (*JSONIterator) More added in v0.2.0

func (j *JSONIterator) More() bool

More checks if there is another element in the current object or array

func (*JSONIterator) Next added in v0.2.0

func (j *JSONIterator) Next() (*Query, error)

Next returns the next element

func (*JSONIterator) Offset added in v0.2.0

func (j *JSONIterator) Offset() int64

func (*JSONIterator) Path added in v0.2.0

func (j *JSONIterator) Path(path ...string) error

Path skips all element along the path

func (*JSONIterator) PrintPretty added in v0.2.0

func (j *JSONIterator) PrintPretty() error

PrintPretty prints the raw data with indention to standard out

func (*JSONIterator) PrintRaw added in v0.2.0

func (j *JSONIterator) PrintRaw() error

PrintRaw copies the raw data to standard out

func (*JSONIterator) Query added in v0.2.0

func (j *JSONIterator) Query() (*Query, error)

func (*JSONIterator) Range added in v0.2.0

func (j *JSONIterator) Range(f func(*Query) error) error

Range iterates over all elements of the current JSON object or array and calls the passed function

func (*JSONIterator) Skip added in v0.2.0

func (j *JSONIterator) Skip() error

Skip skips the next element like for example a string, object or array

func (*JSONIterator) String added in v0.2.0

func (j *JSONIterator) String() (string, error)

String returns the string at the current position

func (*JSONIterator) Token added in v0.2.0

func (j *JSONIterator) Token() (json.Token, error)

type JSONMapIterator added in v0.2.0

type JSONMapIterator struct {
	*JSONIterator
}

JSONMapIterator is a specialized JSONIterator. It returns the attribute name and content in an array. Use it to iterate JSON objects.

func NewJSONMapIterator added in v0.2.0

func NewJSONMapIterator(c *JSONCursor) *JSONMapIterator

NewJSONMapIterator creates an initialized JSONMapIterator

func (*JSONMapIterator) Next added in v0.2.0

func (j *JSONMapIterator) Next() (*Query, error)

Next returns the name and the content of the current attribute.

func (*JSONMapIterator) Range added in v0.2.0

func (j *JSONMapIterator) Range(f func(*Query) error) error

type JSONResponse added in v0.2.0

type JSONResponse interface {
	//Close() error
	//Delim() (json.Delim, error)
	Enter() error
	//EnterArray() error
	EnterObject() error
	//Leave() error
	More() bool
	Next() (*Query, error)
	//Obj() (map[string]interface{}, error)
	Offset() int64
	Path(...string) error
	PrintRaw() error
	PrintPretty() error
	Query() (*Query, error)
	//Range(func(*Query) error) error
	Skip() error
	Token() (json.Token, error)
	Cursor() *JSONCursor
}

JSONResponse is the interface for streaming JSON objects TODO remove this interface

type JSONValueIterator added in v0.2.0

type JSONValueIterator struct {
	*JSONIterator
	// contains filtered or unexported fields
}

func NewJSONValueIterator added in v0.2.0

func NewJSONValueIterator(c *JSONCursor, filter []string) *JSONValueIterator

func (*JSONValueIterator) More added in v0.2.0

func (j *JSONValueIterator) More() bool

func (*JSONValueIterator) Next added in v0.2.0

func (j *JSONValueIterator) Next() (*Query, error)

type LazyPath

type LazyPath struct {
	// contains filtered or unexported fields
}

LazyPath generates a file path on demand

func NewLazyPath

func NewLazyPath(pp PathProvider, path ...string) *LazyPath

NewLazyPath creates an initialzed LazyPath object

func (*LazyPath) Path

func (l *LazyPath) Path() string

Path generates the path

type Mapper

type Mapper map[string]string

Mapper is a map of strings

func (Mapper) GetL

func (m Mapper) GetL(key string) string

GetL normalizes the key to lower case before getting the value. If no value can be found the original key will be returned.

func (Mapper) Invert

func (m Mapper) Invert() Mapper

Invert creats a new mapper with inverted key value relation. Key -> Value becomes Value -> Key.

func (Mapper) Keys

func (m Mapper) Keys() []string

Keys returns a list of keys

func (Mapper) Lookup added in v0.2.0

func (m Mapper) Lookup(key string) string

Get returns the value for the passed key. If no value can be found the key will be returned.

func (Mapper) LookupE added in v0.2.0

func (m Mapper) LookupE(key string) (string, error)

func (Mapper) Values added in v0.2.0

func (m Mapper) Values() []string

Values returns a list of values

type MultiFileReader added in v0.3.1

type MultiFileReader struct {
	Files   []string
	Current int
}

func (*MultiFileReader) Read added in v0.3.1

func (m *MultiFileReader) Read() ([]byte, error)

func (*MultiFileReader) ReadAll added in v0.3.1

func (m *MultiFileReader) ReadAll(f func(data []byte) error) error

type NVPTransformer added in v0.3.0

type NVPTransformer struct{}

NVPTransformer is a generic transformer to Name, Value and Path

func (*NVPTransformer) Header added in v0.3.0

func (*NVPTransformer) Header(wide bool) []string

func (*NVPTransformer) Iterator added in v0.3.0

func (*NVPTransformer) Iterator(c *JSONCursor) (JSONResponse, error)

Iterator returns a JSONValueIterator returning all values

func (*NVPTransformer) Preprocess added in v0.3.0

func (*NVPTransformer) Preprocess(i JSONResponse) error

Preprocess has nothing to do

func (*NVPTransformer) WriteRow added in v0.3.0

func (t *NVPTransformer) WriteRow(q *Query, w *RowWriter, wide bool) error

WriteRow writes name, value and path TODO make Truncate configurable

type Path added in v0.2.0

type Path interface {
	Path() string
}

Path is the interface for objects providing a file path

type PathProvider added in v0.2.0

type PathProvider interface {
	Path(...string) string
}

PathProvider is the interface for objects providing dynamic file path concatenation

type Prefixes added in v0.2.0

type Prefixes struct {
	// contains filtered or unexported fields
}

func NewPrefixes added in v0.2.0

func NewPrefixes() *Prefixes

func (*Prefixes) Add added in v0.2.0

func (p *Prefixes) Add(f func(JSONResponse) error, path ...string)

func (*Prefixes) Matches added in v0.2.0

func (p *Prefixes) Matches(pos int, elem string) (bool, func(JSONResponse) error)

func (*Prefixes) Pop added in v0.2.0

func (p *Prefixes) Pop()

type Query

type Query struct {
	// contains filtered or unexported fields
}

Query supports queries on raw json objects

func NewQuery

func NewQuery(obj interface{}) *Query

NewQuery creates an initialized query object

func NewQueryM added in v0.2.0

func NewQueryM(obj interface{}, jp jsonPath) *Query

func NewQueryStream added in v0.2.0

func NewQueryStream(stream io.Reader) (*Query, error)

func UnmarshallQuery added in v0.1.1

func UnmarshallQuery(data []byte) (*Query, error)

UnmarshallQuery unmarshal JSON data and returns a Query object

func (*Query) Array added in v0.2.0

func (q *Query) Array() []interface{}

func (*Query) Bool added in v0.3.0

func (q *Query) Bool(path ...string) bool

func (*Query) Boolean added in v0.3.1

func (q *Query) Boolean() bool

func (*Query) Concat

func (q *Query) Concat(separator string, rf func(*Query) string) string

Concat calls the passed function on all children and concatenates the results separated by the passed separator.

func (*Query) Get

func (q *Query) Get(index int) *Query

Get returns the children at the passed index

func (*Query) Int

func (q *Query) Int(path ...string) int

Int returns the integer of the referenced path

func (*Query) Integer added in v0.2.0

func (q *Query) Integer() int

Integer returns the current object as integer

func (*Query) Interface

func (q *Query) Interface() interface{}

Interface returns the current object

func (*Query) JSONFullPath added in v0.2.0

func (q *Query) JSONFullPath() string

func (*Query) JSONName added in v0.2.0

func (q *Query) JSONName() string

func (*Query) JSONPath added in v0.2.0

func (q *Query) JSONPath() string

func (*Query) Len

func (q *Query) Len(path ...string) int

Len returns the length of the referenced path

func (*Query) Length

func (q *Query) Length() int

Length returns the length of the current object

func (*Query) Nil added in v0.3.0

func (q *Query) Nil() bool

func (*Query) Path

func (q *Query) Path(path ...string) *Query

Path queries nested objects, e.g. property a.b.c will be queried with Path("a","b","c")

func (*Query) Pretty added in v0.3.0

func (q *Query) Pretty() string

func (*Query) QueryArray added in v0.2.0

func (q *Query) QueryArray() []*Query

Range executes the passed function on all children of the current object

func (*Query) Range

func (q *Query) Range(rf func(*Query))

Range executes the passed function on all children of the current object

func (*Query) RangeAttributes

func (q *Query) RangeAttributes(rf func(string, *Query))

RangeAttributes executes the passed function on all children of the current object

func (*Query) RangeAttributesE added in v0.2.0

func (q *Query) RangeAttributesE(rf func(string, *Query) error) error

RangeAttributesE executes the passed function on all children of the current object

func (*Query) RangeAttributesRich added in v0.3.0

func (q *Query) RangeAttributesRich(rf func(name string, q *Query, index, size int))

func (*Query) RangeI

func (q *Query) RangeI(rf func(int, *Query))

RangeI executes the passed function on all children of the current object. It provides the index of the object.

func (*Query) RangeIE added in v0.3.0

func (q *Query) RangeIE(rf func(int, *Query) error) error

RangeIE executes the passed function on all children of the current object. It provides the index of the object.

func (*Query) RangeSortedAttributesRich added in v0.3.0

func (q *Query) RangeSortedAttributesRich(rf func(name string, q *Query, index, size int))

func (*Query) RangeSortedAttributesRichE added in v0.3.0

func (q *Query) RangeSortedAttributesRichE(rf func(name string, q *Query, index, size int) error) error

func (*Query) RangeValues added in v0.3.0

func (q *Query) RangeValues(rf func(*Query), exclude ...string)

func (*Query) RangeValuesE added in v0.3.0

func (q *Query) RangeValuesE(rf func(*Query) error, exclude ...string) error

func (*Query) ResetPath added in v0.3.0

func (q *Query) ResetPath() *Query

func (*Query) Str

func (q *Query) Str(path ...string) string

Str returns the string of the referenced path

func (*Query) String

func (q *Query) String() string

String returns the current object as string

func (*Query) Strings

func (q *Query) Strings() []string

Strings returns the current object as array of strings

func (*Query) Value

func (q *Query) Value(path ...string) interface{}

Value returns the object of the referenced path

type QueryDescription added in v0.3.0

type QueryDescription struct {
	CMD        string            `json:"cmd,omitempty" yaml:"cmd,omitempty"`
	Parameters []interface{}     `json:"parameters,omitempty" yaml:"parameters,omitempty"`
	Path       []string          `json:"path,omitempty" yaml:"path,omitempty"`
	Query      *QueryDescription `json:"query,omitempty" yaml:"query,omitempty"`
	Func       func(*Scope, *Query) *Query
}

QueryDescription represents a query

func (*QueryDescription) Prepare added in v0.3.0

func (d *QueryDescription) Prepare() error

type RangePost added in v0.2.0

type RangePost struct {
	Vars []*DescriptorVars `json:"vars,omitempty" yaml:"vars,omitempty"`
}

RangePost represents the post phase of a range, usually for variable update

type Restreamable added in v0.2.0

type Restreamable struct {
	// contains filtered or unexported fields
}

func NewRestreamable added in v0.2.0

func NewRestreamable(r io.Reader) (*Restreamable, error)

func (*Restreamable) Reader added in v0.2.0

func (r *Restreamable) Reader() io.Reader

type RootConfig added in v0.2.0

type RootConfig struct {
	Name    string
	Version string
	Config  string
	Tenant  string
	Home    string
	Debug   bool
	Human   bool
}

RootConfig contains the global configuration

func NewRootConfig added in v0.2.0

func NewRootConfig(name, version string, cmd *cobra.Command) *RootConfig

NewRootConfig returns an initilized configuration.

func (*RootConfig) Configure added in v0.2.0

func (o *RootConfig) Configure(cmd *cobra.Command) error

Configure loads the configuration file encoded in json or yaml.

func (*RootConfig) JoinPath added in v0.2.0

func (o *RootConfig) JoinPath(path ...string) string

type RowWriter added in v0.2.0

type RowWriter struct {
	// contains filtered or unexported fields
}

RowWriter writes rows to a stream

func NewCSVWriter added in v0.2.0

func NewCSVWriter(out io.Writer) *RowWriter

NewCSVWriter creates an initialized RowWriter with commas as delimiter

func NewTableWriter added in v0.2.0

func NewTableWriter(out io.Writer) *RowWriter

NewTableWriter creates an initialized RowWriter with tabs as delimiter

func (*RowWriter) AutoFlush added in v0.2.0

func (t *RowWriter) AutoFlush(l int) *RowWriter

AutoFlush sets the limit for the automatic flush during writes

func (*RowWriter) Flush added in v0.2.0

func (t *RowWriter) Flush() error

Flush flushes the underlying stream

func (*RowWriter) Write added in v0.2.0

func (t *RowWriter) Write(v ...string) error

Write writes one row with mutliple lines and terminates it with a newline. v is a slice of columns separated by the delimiter, e.g. a tab.

func (*RowWriter) WriteSingle added in v0.3.0

func (t *RowWriter) WriteSingle(v ...string) error

Write writes one row and terminates it with a newline

type Scope added in v0.2.0

type Scope struct {
	// contains filtered or unexported fields
}

Scope represents the current variable scope

func NewScope added in v0.2.0

func NewScope(parent *Scope, vars []*DescriptorVars, mappings map[string]Mapper, q *Query) *Scope

NewScope creates an initialized Scope object

func (*Scope) Get added in v0.2.0

func (s *Scope) Get(name string) *Query

Get returns the value of a variable

func (*Scope) Mapping added in v0.3.0

func (s *Scope) Mapping(name string) Mapper

Get returns the value of a variable

func (*Scope) Set added in v0.2.0

func (s *Scope) Set(name, value string) bool

Set changes an existing variable in this or a parent scope or creates a new one

type StackInt added in v0.2.0

type StackInt []int

StackInt is a simple int stack (lifo)

func (*StackInt) Pop added in v0.2.0

func (s *StackInt) Pop() (int, bool)

Pop removes the last element from the stack and returns it

func (*StackInt) Push added in v0.2.0

func (s *StackInt) Push(i int)

Push pushes the integer i to the stack

type TableColumnDescriptor added in v0.2.0

type TableColumnDescriptor struct {
	Name       string            `json:"name" yaml:"name"`
	Long       string            `json:"long" yaml:"long"`
	Type       string            `json:"type" yaml:"type"`
	Meta       string            `json:"meta,omitempty" yaml:"meta,omitempty"`
	Path       []string          `json:"path,omitempty" yaml:"path,omitempty"`
	AltPath    []string          `json:"altPath,omitempty" yaml:"altPath,omitempty"`
	Format     string            `json:"format,omitempty" yaml:"format,omitempty"`
	Parameters []string          `json:"parameters,omitempty" yaml:"parameters,omitempty"`
	Var        string            `json:"var,omitempty" yaml:"var,omitempty"`
	Mode       string            `json:"mode,omitempty" yaml:"mode,omitempty"`
	Query      *QueryDescription `json:"query,omitempty" yaml:"query,omitempty"`
	// contains filtered or unexported fields
}

TableColumnDescriptor contains all information to extract a column value

func (*TableColumnDescriptor) Extract added in v0.2.0

func (t *TableColumnDescriptor) Extract(scope *Scope, q *Query) string

Extract retrieves the value from the JSON document and returns it as formatted string

type TableDescriptor added in v0.2.0

type TableDescriptor struct {
	Mappings map[string]Mapper        `json:"mappings,omitempty" yaml:"mappings,omitempty"`
	Columns  []*TableColumnDescriptor `json:"columns,omitempty" yaml:"columns,omitempty"`
	//	Wide    []*TableColumnDescriptor `json:"wide,omitempty" yaml:"wide,omitempty"`
	Path   []string          `json:"path,omitempty" yaml:"path,omitempty"`
	Select []string          `json:"select,omitempty" yaml:"select,omitempty"`
	Iter   string            `json:"iterator,omitempty" yaml:"iterator,omitempty"`
	Filter []string          `json:"filter,omitempty" yaml:"filter,omitempty"`
	Vars   []*DescriptorVars `json:"vars,omitempty" yaml:"vars,omitempty"`
	Range  *DescriptorRange  `json:"range,omitempty" yaml:"range,omitempty"`
	// contains filtered or unexported fields
}

TableDescriptor contains all information to transform a JSON object to a table

func NewTableDescriptor added in v0.2.0

func NewTableDescriptor(def string) (*TableDescriptor, error)

NewTableDescriptor creates an initialzed TableDescriptor. It accpets a definition encoded in YAML format.

func (*TableDescriptor) AddMapping added in v0.3.0

func (t *TableDescriptor) AddMapping(name string, m Mapper)

func (*TableDescriptor) Header added in v0.2.0

func (t *TableDescriptor) Header(wide bool) []string

Header extracts the table header

func (*TableDescriptor) Iterator added in v0.2.0

func (t *TableDescriptor) Iterator(c *JSONCursor) (JSONResponse, error)

Iterator selects the configured iterator for the passed JSON stream

func (*TableDescriptor) Preprocess added in v0.2.0

func (t *TableDescriptor) Preprocess(i JSONResponse) error

Preprocess goes down the path and enters the list or object

func (*TableDescriptor) WriteRow added in v0.2.0

func (t *TableDescriptor) WriteRow(q *Query, w *RowWriter, wide bool) error

WriteRow writes one or more rows out

type TruncateWriter added in v0.3.0

type TruncateWriter struct {
	// contains filtered or unexported fields
}

func NewTruncateWriter added in v0.3.0

func NewTruncateWriter(w io.Writer, max int) *TruncateWriter

func (*TruncateWriter) Write added in v0.3.0

func (t *TruncateWriter) Write(p []byte) (int, error)

type YAMLQuery added in v0.1.1

type YAMLQuery struct {
	// contains filtered or unexported fields
}

YAMLQuery supports the querying and editing of YAML documents without loosing the formating

func NewYAMLQuery added in v0.1.1

func NewYAMLQuery(node *yaml.Node) *YAMLQuery

NewYAMLQuery creates an initialized YAMLQuery object

func (*YAMLQuery) First added in v0.1.1

func (q *YAMLQuery) First() *YAMLQuery

First skips the document node if necessary and returns the first real object

func (*YAMLQuery) IsDocument added in v0.1.1

func (q *YAMLQuery) IsDocument() bool

IsDocument returns true if this object is a document

func (*YAMLQuery) IsMap added in v0.1.1

func (q *YAMLQuery) IsMap() bool

IsMap returns true if this object is a map

func (*YAMLQuery) IsNil added in v0.1.1

func (q *YAMLQuery) IsNil() bool

IsNil tests if the current object is nil

func (*YAMLQuery) Path added in v0.1.1

func (q *YAMLQuery) Path(path ...string) *YAMLQuery

Path queries the passed path. Each path element must match an entry in the current map, otherwise an empty object will be returned.

func (*YAMLQuery) Set added in v0.1.1

func (q *YAMLQuery) Set(value string)

Set sets the value of the current object

func (*YAMLQuery) SetMap added in v0.1.1

func (q *YAMLQuery) SetMap(key, value string)

SetMap sets the key-value pair

func (*YAMLQuery) Str added in v0.1.1

func (q *YAMLQuery) Str(path ...string) string

Str returns the string of the referenced path

func (*YAMLQuery) String added in v0.1.1

func (q *YAMLQuery) String() string

String returns the current object as string

Jump to

Keyboard shortcuts

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