extraconfig

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: May 4, 2018 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultTagName value
	DefaultTagName = "vic"
	// DefaultPrefix value
	DefaultPrefix = ""
	// DefaultGuestInfoPrefix value
	DefaultGuestInfoPrefix = "guestinfo.vice."
	//Separator for slice values and map keys
	Separator = "|"
)
View Source
const (
	// Invalid value
	Invalid = 1 << iota
	// Hidden value
	Hidden
	// ReadOnly value
	ReadOnly
	// ReadWrite value
	ReadWrite
	// NonPersistent value
	NonPersistent
	// Volatile value
	Volatile
	// Secret value
	Secret
)
View Source
const GuestInfoSecretKey = "guestinfo.ovfEnv"

The value of this key is hidden from API requests, but visible within the guest #nosec: Potential hardcoded credentials

Variables

View Source
var (
	ErrKeyNotFound = errors.New("key not found")
)
View Source
var Unbounded = recursion{/* contains filtered or unexported fields */}

Unbounded is the value used for unbounded recursion

Functions

func CalculateKeys

func CalculateKeys(obj interface{}, field string, prefix string) []string

CalculateKeys gets the keys in extraconfig corresponding to the field specification passed in for obj. Examples:

type struct A {
    I   int    `vic:"0.1" scope:"read-only" key:"i"`
    Str string `vic:"0.1" scope:"read-only" key:"str"`
}

type struct B {
    A A                      `vic:"0.1" scope:"read-only" key:"a"`
    Array []A                `vic:"0.1" scope:"read-only" key:"array"`
    Map   map[string]string  `vic:"0.1" scope:"read-only" key:"map"`
}

b := B{}
b.Array = []A{A{}}
b.Map = map[string]string{"foo": "", "bar": ""}
// returns []string{"a/str"}
CalculateKeys(b, "A.Str", "")

// returns []string{"array|0"}
CalculateKeys(b, "Array.0", "")

// returns []string{"array|0"}
CalculateKeys(b, "Array.*", "")

// returns []string{"map|foo", "map|bar"}
CalculateKeys(b, "Map.*", "")

// returns []string{"map|foo"}
CalculateKeys(b, "Map.foo", "")

// returns []string{"map|foo/str"}
CalculateKeys(b, "Map.foo.str", "")

func Decode

func Decode(src DataSource, dest interface{}) interface{}

Decode populates a destination with data from the supplied data source

func DecodeWithPrefix

func DecodeWithPrefix(src DataSource, dest interface{}, prefix string) interface{}

DecodeWithPrefix populates a destination with data from the supplied data source, using the specified prefix - this allows for decode into substructres.

func Encode

func Encode(sink DataSink, src interface{})

Encode serializes the given type to the supplied data sink

func EncodeWithPrefix

func EncodeWithPrefix(sink DataSink, src interface{}, prefix string)

EncodeWithPrefix serializes the given type to the supplied data sink, using the supplied prefix - this allows for serialization of subsections of a struct

func SetLogLevel

func SetLogLevel(level logrus.Level)

SetLogLevel for the extraconfig package

Types

type DataSink

type DataSink func(string, string) error

DataSink provides a function that, given a key/value will persist that in some manner suited for later retrieval

func GuestInfoSink

func GuestInfoSink() (DataSink, error)

GuestInfoSink uses the rpcvmx mechanism to update the guestinfo key/value map as the datasink for encoding target structures

func GuestInfoSinkWithPrefix

func GuestInfoSinkWithPrefix(prefix string) (DataSink, error)

GuestInfoSinkWithPrefix adds a prefix to all keys accessed. The key must not have leading or trailing separator characters, but may have separators in other positions. The separator (either . or /) will be replaced with the appropriate value for the key in question.

func MapSink

func MapSink(sink map[string]string) DataSink

MapSink takes a map and populates it with key/value pairs from the encode

func ScopeFilterSink

func ScopeFilterSink(filter uint, sink DataSink) DataSink

ScopeFilterSink will create a DataSink that only stores entries where the key scope matches one or more scopes in the filter. The filter is a bitwise composion of scope flags

type DataSource

type DataSource func(string) (string, error)

DataSource provides a function that, give a key will return a value this is to be used during extraConfig decode to obtain values. Should return ErrKeyNotFound if the key does not exist in the data source.

func GuestInfoSource

func GuestInfoSource() (DataSource, error)

GuestInfoSource uses the rpcvmx mechanism to access the guestinfo key/value map as the datasource for decoding into target structures

func GuestInfoSourceWithPrefix

func GuestInfoSourceWithPrefix(prefix string) (DataSource, error)

GuestInfoSourceWithPrefix adds a prefix to all keys accessed. The key must not have leading or trailing separator characters, but may have separators in other positions. The separator (either . or /) will be replaced with the appropriate value for the key in question.

func MapSource

func MapSource(src map[string]string) DataSource

MapSource takes a key/value map and uses that as the datasource for decoding into target structures

type MapStore

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

func New

func New() *MapStore

func (*MapStore) Get

func (t *MapStore) Get(key string) (string, error)

func (*MapStore) Put

func (t *MapStore) Put(key, value string) error

type SecretKey

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

SecretKey provides helpers to encrypt/decrypt extraconfig values

func NewSecretKey

func NewSecretKey() (*SecretKey, error)

NewSecretKey generates a new secret key

func (*SecretKey) FromString

func (s *SecretKey) FromString(key string) error

FromString base64 decodes an existing SecretKey

func (*SecretKey) Sink

func (s *SecretKey) Sink(ds DataSink) DataSink

Sink wraps the given DataSink, encrypting any secret values

func (*SecretKey) Source

func (s *SecretKey) Source(ds DataSource) DataSource

Source wraps the given DataSource, decrypting any secret values

func (*SecretKey) String

func (s *SecretKey) String() string

String base64 encodes a SecretKey

type Store

type Store interface {
	Get(string) (string, error)
	Put(string, string) error
}

Store provides combined DataSource and DataSink.

Directories

Path Synopsis
Package vmomi is in a separate package to avoid the transitive inclusion of govmomi as a fundamental dependency of the main extraconfig
Package vmomi is in a separate package to avoid the transitive inclusion of govmomi as a fundamental dependency of the main extraconfig

Jump to

Keyboard shortcuts

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