Documentation
¶
Overview ¶
Package mapstore facilitates saving key value pairs into a Kubernetes ConfigMap.
package main import ( "fmt" "log" "github.com/unrolled/mapstore" ) func main() { mapStore, err := mapstore.NewKeyValue("my-custom-config-map-name", false) if err != nil { log.Fatalf("error creating mapstore: %v", err) } err = mapStore.Set("my-key", []byte("my value lives here")) if err != nil { log.Fatalf("error setting value: %v", err) } val, err := mapStore.Get("my-key") if err != nil { log.Fatalf("error getting value: %v", err) } fmt.Printf("Value from ConfigMap: %#v\n", val) }
Index ¶
- Constants
- Variables
- func VerifyConnection(testMapName string, client *KubeClient) error
- type ComplexInterface
- type KeyValue
- func (k *KeyValue) Delete(key string) error
- func (k *KeyValue) ForceSet(key string, value []byte) error
- func (k *KeyValue) Get(key string) ([]byte, error)
- func (k *KeyValue) Keys() ([]string, error)
- func (k *KeyValue) Raw() (map[string][]byte, error)
- func (k *KeyValue) Reset() error
- func (k *KeyValue) Set(key string, value []byte) error
- type KubeClient
- type SimpleInterface
Constants ¶
View Source
const MaxConfigMapSize = 1024
Variables ¶
View Source
var ErrKeyValueNotFound = fmt.Errorf("key was not found")
ErrKeyValueNotFound is returned when looking up a value that does not exist.
Functions ¶
func VerifyConnection ¶
func VerifyConnection(testMapName string, client *KubeClient) error
Types ¶
type ComplexInterface ¶ added in v0.0.3
type ComplexInterface interface { SimpleInterface Raw() (map[string][]byte, error) ForceSet(key string, value []byte) error }
ComplexInterface defines the required methods and a few optional methods for the KeyValue implementation.
type KeyValue ¶
KeyValue is a thread safe key value store backed by a Kubernetes ConfigMap.
func NewKeyValue ¶
NewKeyValue returns a newly setup instance of KeyValue.
func (*KeyValue) ForceSet ¶
ForceSet is the same as Set, but does not check if the values are equal first.
func (*KeyValue) Get ¶
Get uses the supplied key and attempts to return the coorsponding value from the ConfigMap.
type KubeClient ¶
type KubeClient struct {
// contains filtered or unexported fields
}
KubeClient wires up the connection to the cluster.
func GetKubeClient ¶
func GetKubeClient() (*KubeClient, error)
GetKubeClient returns the kubernetes client singleton.
func (*KubeClient) Delete ¶
func (k *KubeClient) Delete(name string) error
Click to show internal directories.
Click to hide internal directories.