kmap

package
v0.0.0-...-7d52a43 Latest Latest
Warning

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

Go to latest
Published: May 29, 2024 License: Apache-2.0 Imports: 0 Imported by: 28

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Copy

func Copy(a map[string]string) map[string]string

Copy makes a copy of the map.

func ExcludeKeyList

func ExcludeKeyList(in map[string]string, keys []string) map[string]string

ExcludeKeyList creates a copy of the provided map filtering out excluded `keys`

func ExcludeKeys

func ExcludeKeys(in map[string]string, keys ...string) map[string]string

ExcludeKeys creates a copy of the provided map filtering out the excluded `keys`

func Filter

func Filter(in map[string]string, filter func(string) bool) map[string]string

Filter creates a copy of the provided map, filtering out the elements that match `filter`. nil `filter` is accepted.

func Union

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

Union returns a map constructed from the union of input maps. where values from latter maps win.

func UpdateKeys

func UpdateKeys(m map[string]string, keys ...KeyPriority) map[string]string

UpdateKeys iterates over the lookups and updates entries in the map to use the default key

Types

type KeyPriority

type KeyPriority []string

KeyPriority is a utility struct for getting values from a map given a list of ordered keys

This is to help the migration/renaming of annotations & labels

func (KeyPriority) Get

func (p KeyPriority) Get(m map[string]string) (string, string, bool)

Get iterates over the ordered keys and looks up the corresponding values in the map

It returns the key, value, and true|false signaling whether the key was present in the map

If no key is present the default key (lowest ordinal) is returned with an empty string as the value

func (KeyPriority) Key

func (p KeyPriority) Key() string

Key returns the default key that should be used for accessing the map

func (KeyPriority) UpdateKey

func (p KeyPriority) UpdateKey(m map[string]string)

UpdateKey will update the map with the KeyPriority's default key iff any of the other synonym keys are present

func (KeyPriority) Value

func (p KeyPriority) Value(m map[string]string) string

Value iterates looks up the ordered keys in the map and returns a string value. An empty string will be returned if the keys are not present in the map

Jump to

Keyboard shortcuts

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