kv

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: May 24, 2024 License: MPL-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package kv implements core key-value type as a base for labels and annotations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KV

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

KV is a set free-form of key-value pairs.

Order of keys is not guaranteed.

KV support copy-on-write semantics, so metadata copies share common labels as long as possible.

func (*KV) Delete

func (kv *KV) Delete(key string)

Delete the key.

Deleting the key copies the map, so metadata copies share common storage as long as possible.

func (*KV) Do added in v0.3.1

func (kv *KV) Do(ts func(temp kvutils.TempKV))

Do executes a function with a temporary copy of the map. It copies the map back only if the function modifies it.

func (KV) Empty

func (kv KV) Empty() bool

Empty if there are no pairs.

func (KV) Equal

func (kv KV) Equal(other KV) bool

Equal checks kv for equality.

func (*KV) Get

func (kv *KV) Get(key string) (string, bool)

Get the value.

func (KV) Keys

func (kv KV) Keys() []string

Keys returns a sorted list of keys.

func (KV) Len

func (kv KV) Len() int

Len returns the number of keys.

func (*KV) Raw

func (kv *KV) Raw() map[string]string

Raw returns the raw map.

Raw map should not be modified outside of the call.

func (*KV) Set

func (kv *KV) Set(key, value string)

Set the key value.

Setting the value copies the map, so metadata copies share common storage as long as possible.

func (KV) ToYAML

func (kv KV) ToYAML(label string) []*yaml.Node

ToYAML returns a set of YAML nodes.

Jump to

Keyboard shortcuts

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