Documentation ¶
Overview ¶
Package util util consists of general utility functions and structures.
Copyright 2021 Michael Bungenstock ¶
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.
Copyright 2021 Michael Bungenstock ¶
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.
Copyright 2021 Michael Bungenstock ¶
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.
Copyright 2021 Michael Bungenstock ¶
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.
Copyright 2021 Michael Bungenstock ¶
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.
Copyright 2021 Michael Bungenstock ¶
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.
Copyright 2021 Michael Bungenstock ¶
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.
Copyright 2021 Michael Bungenstock ¶
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.
Copyright 2021 Michael Bungenstock ¶
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.
Copyright 2021 Michael Bungenstock ¶
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.
Copyright 2021 Michael Bungenstock ¶
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.
Copyright 2021 Michael Bungenstock ¶
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.
Copyright 2021 Michael Bungenstock ¶
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.
Copyright 2021 Michael Bungenstock ¶
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 ¶
- func AddDollar(s string) string
- func Contains(value string, ar []string) bool
- func ContainsS(value string, ar []string) string
- func Dashed(str string) string
- func Difference(a, b []string) []string
- func Example(s string) string
- func GetInt(value interface{}) (result int)
- func GetString(value interface{}) (result string)
- func LoadPrivateKeyPEM(path string) (*rsa.PrivateKey, error)
- func LocalTimeStr(str string) string
- func LocalTimeStrCustom(str, fmt string) string
- func LongDesc(s string) string
- func Par(pairs ...string) string
- func Plural(str string) string
- func RemoveQuotes(s string) string
- type Claim
- type Column
- type GlobalConfig
- type JSONCache
- type KVCache
- func (l *KVCache) GetValue(key string) string
- func (l *KVCache) GetValueE(key string) (string, error)
- func (l *KVCache) Invalidate()
- func (l *KVCache) Keys() ([]string, error)
- func (l *KVCache) Load() (*KVCacheData, error)
- func (l *KVCache) MapValues(m func(string) string)
- func (l *KVCache) Remove(key string)
- func (l *KVCache) Values() ([]string, error)
- type KVCacheData
- type LazyPath
- type Mapper
- type ObjectCache
- type ObjectCacheData
- type Query
- func (q *Query) Concat(separator string, rf func(*Query) string) string
- func (q *Query) Get(index int) *Query
- func (q *Query) Int(path ...string) int
- func (q *Query) Interface() interface{}
- func (q *Query) Len(path ...string) int
- func (q *Query) Length() int
- func (q *Query) Path(path ...string) *Query
- func (q *Query) Range(rf func(*Query))
- func (q *Query) RangeAttributes(rf func(string, *Query))
- func (q *Query) RangeI(rf func(int, *Query))
- func (q *Query) Str(path ...string) string
- func (q *Query) String() string
- func (q *Query) Strings() []string
- func (q *Query) Value(path ...string) interface{}
- type StringCache
- type StringCacheData
- type Table
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Difference ¶
Difference substitues the array of strings b from a
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 LoadPrivateKeyPEM ¶
func LoadPrivateKeyPEM(path string) (*rsa.PrivateKey, error)
LoadPrivateKeyPEM reads the private key from the passed file in PEM format.
func LocalTimeStr ¶
LocalTimeStr converts time string in RFC3339 to local time in RFC822
func LocalTimeStrCustom ¶
LocalTimeStrCustom converts time string in RFC3339 to local time in custom format
func RemoveQuotes ¶
RemoveQuotes removes embracing quotes, e.g. "hello" becomes hello and 'world' becomes world
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.
type Column ¶
type Column struct { Number int Name string Cells []interface{} Calc func(interface{}) interface{} }
Column represents one column in a table
type GlobalConfig ¶
GlobalConfig contains the global configuration
func NewGlobalConfig ¶
func NewGlobalConfig(name string, cmd *cobra.Command) *GlobalConfig
NewGlobalConfig returns an initilized configuration.
func (*GlobalConfig) Configure ¶
func (o *GlobalConfig) Configure(cmd *cobra.Command) error
Configure loads the configuration file encoded in json or yaml.
func (*GlobalConfig) GetPreRunE ¶
func (o *GlobalConfig) GetPreRunE() func(*cobra.Command, []string) error
GetPreRunE returns the function for PreRunE function of cobra.Comamand
type JSONCache ¶
type JSONCache struct {
// contains filtered or unexported fields
}
JSONCache stores json objects in a file
func NewJSONCache ¶
NewJSONCache returns an initialzed JSONCache object
func (*JSONCache) Invalidate ¶
func (jc *JSONCache) Invalidate()
Invalidate invalidates the cache by deleting the related file
type KVCache ¶
type KVCache struct {
// contains filtered or unexported fields
}
KVCache is a key value cache for strings with optional persistence
func NewKVCache ¶
func NewKVCache(cacheRead, cacheWrite func() bool, exec func() (map[string]string, error), path func() []string) *KVCache
NewKVCache creates an initialized KVCache object
func (*KVCache) GetValue ¶
GetValue returns the value for the passed key. If no value could be retrieved then the key will be returned.
func (*KVCache) GetValueE ¶
GetValueE returns the value for the passed key. If no value could be retrieved then an error will be returned.
func (*KVCache) MapValues ¶
MapValues calls the passed function for each value and stores the result
type KVCacheData ¶
KVCacheData stores the data of the KVCache with an expiry date
func (*KVCacheData) Get ¶
func (c *KVCacheData) Get(key string) string
Get returns the value for the passed key. If no value could be found then the key will be returned.
func (*KVCacheData) GetE ¶
func (c *KVCacheData) GetE(key string) (string, error)
GetE returns the value for the passed key. If no value could be found then an error will be returned.
func (*KVCacheData) ValidIn ¶
func (c *KVCacheData) ValidIn(d time.Duration) bool
ValidIn in checks if the token is still valid for passed duration
func (*KVCacheData) Values ¶
func (c *KVCacheData) Values() []string
Values returns a list of values
type LazyPath ¶
type LazyPath struct {
// contains filtered or unexported fields
}
LazyPath builds a path on the first call
func NewLazyPath ¶
NewLazyPath returns an initialized LazyPath object
type Mapper ¶
Mapper is a map of strings
func (Mapper) Get ¶
Get returns the value for the passed key. If no value can be found the key will be returned.
func (Mapper) GetL ¶
GetL normalizes the key to lower case before getting the value. If no value can be found the original key will be returned.
type ObjectCache ¶
type ObjectCache struct {
// contains filtered or unexported fields
}
ObjectCache is an object cache
func NewObjectCache ¶
func NewObjectCache(f func() ([]interface{}, error)) *ObjectCache
NewObjectCache creates an initialized ObjectCache object
func (*ObjectCache) Load ¶
func (c *ObjectCache) Load() (*ObjectCacheData, error)
Load loads the cache
func (*ObjectCache) Mapper ¶
func (c *ObjectCache) Mapper(key, value []string) Mapper
Mapper converts the stored objects to a Mapper. Parameters key and value are Query paths to the desired object attributes.
type ObjectCacheData ¶
ObjectCacheData stores the objects
func (*ObjectCacheData) Valid ¶
func (c *ObjectCacheData) Valid() bool
Valid in checks if the token is still valid for passed duration
type Query ¶
type Query struct {
// contains filtered or unexported fields
}
Query supports queries on raw json objects
func (*Query) Concat ¶
Concat calls the passed function on all children and concatenates the results separated by the passed separator.
func (*Query) Interface ¶
func (q *Query) Interface() interface{}
Interface returns the current object
func (*Query) Path ¶
Path queries nested objects, e.g. property a.b.c will be queried with Path("a","b","c")
func (*Query) RangeAttributes ¶
RangeAttributes executes the passed function on all children of the current object
func (*Query) RangeI ¶
RangeI executes the passed function on all children of the current object. It provides the index of the object.
type StringCache ¶
type StringCache struct {
// contains filtered or unexported fields
}
StringCache is a string cache
func NewStringCache ¶
func NewStringCache(cacheRead, cacheWrite func() bool, exec func() ([]string, error), path func() []string) *StringCache
NewStringCache creates an initialized StringCache object
func (*StringCache) GetList ¶
func (l *StringCache) GetList() ([]string, error)
GetList returns all stored values
func (*StringCache) Load ¶
func (l *StringCache) Load() (*StringCacheData, error)
Load loads the cache
type StringCacheData ¶
StringCacheData stores a list of strings with expiry date
type Table ¶
type Table struct { Columns []*Column Height int Width int HideHeader bool // contains filtered or unexported fields }
Table contains any object represented as table
func (*Table) Array ¶
func (t *Table) Array() [][]interface{}
Array converts the table to a two-dimensional array (row x column)