model

package
v0.0.0-...-fa73266 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2019 License: Apache-2.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func KeyToDefaultDeletePath

func KeyToDefaultDeletePath(key Key) (string, error)

KeyToDefaultDeletePath converts one of the Keys from this package into a unique '/'-delimited path, which is suitable for use as the key when (recursively) deleting the value from a hierarchical (i.e. one with directories and leaves) key/value datastore such as etcd v3.

KeyToDefaultDeletePath returns a different path to KeyToDefaultPath when it is a passed a Key that represents a non-leaf which, for example, has its own metadata but also contains other resource types as children.

KeyToDefaultDeletePath returns the common prefix of the non-leaf key and its children so that a recursive delete of that key would delete the object itself and any children it has.

func KeyToDefaultPath

func KeyToDefaultPath(key Key) (string, error)

KeyToDefaultPath converts one of the Keys from this package into a unique '/'-delimited path, which is suitable for use as the key when storing the value in a hierarchical (i.e. one with directories and leaves) key/value datastore such as etcd v3.

Each unique key returns a unique path.

Keys with a hierarchical relationship share a common prefix. However, in order to support datastores that do not support storing data at non-leaf nodes in the hierarchy (such as etcd v3), the path returned for a "parent" key, is not a direct ancestor of its children.

func ParseValue

func ParseValue(key Key, rawData []byte) (interface{}, error)

ParseValue parses the default JSON representation of our data into one of our value structs, according to the type of key. I.e. if passed a PolicyKey as the first parameter, it will try to parse rawData into a Policy struct.

func SerializeValue

func SerializeValue(d *KVPair) ([]byte, error)

Serialize a value in the model to a []byte to stored in the datastore. This performs the opposite processing to ParseValue()

Types

type KVPair

type KVPair struct {
	Key      Key
	Value    interface{}
	Revision string
	UID      *types.UID
	TTL      time.Duration // For writes, if non-zero, key has a TTL.
}

KVPair holds a typed key and value object as well as datastore specific revision information.

The Value is dependent on the Key, but in general will be on of the following types:

  • A pointer to a struct
  • A slice or map
  • A bare string, boolean value or IP address (i.e. without quotes, so not JSON format).

type Key

type Key interface {

	// String returns a unique string representation of this key.  The string
	// returned by this method must uniquely identify this Key.
	String() string
	// contains filtered or unexported methods
}

type Node

type Node struct {
	Namespace  string            `json:"namespace,omitempty"`
	Name       string            `json:"name,omitempty"`
	InternalIP string            `json:"internalip,omitempty"`
	Hostname   string            `json:"hostname,omitempty"`
	PodCIDR    string            `json:"podCIDR,omitempty"`
	Labels     map[string]string `json:"labels,omitempty"`
	UID        types.UID         `json:"uid,omitempty"`
}

type NodeKey

type NodeKey struct {
	Hostname string
}

func (NodeKey) KeyToDefaultDeletePath

func (key NodeKey) KeyToDefaultDeletePath() (string, error)

func (NodeKey) String

func (key NodeKey) String() string

type UNPKey

type UNPKey struct {
	Name string
}

func (UNPKey) KeyToDefaultDeletePath

func (key UNPKey) KeyToDefaultDeletePath() (string, error)

func (UNPKey) String

func (key UNPKey) String() string

Jump to

Keyboard shortcuts

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