Documentation ¶
Index ¶
- Constants
- Variables
- func CalculateKey(obj interface{}, field string, prefix string) string
- func CalculateKeys(obj interface{}, field string, prefix string) []string
- func Decode(src DataSource, dest interface{}) interface{}
- func DecodeWithPrefix(src DataSource, dest interface{}, prefix string) interface{}
- func Encode(sink DataSink, src interface{})
- func EncodeWithPrefix(sink DataSink, src interface{}, prefix string)
- func SetLogLevel(level logrus.Level)
- type DataSink
- type DataSource
- type MapStore
- type SecretKey
- type Store
Constants ¶
const ( // GuestInfoPrefix is dictated by vSphere GuestInfoPrefix = "guestinfo." // ScopeTag is the tag name used for declaring scopes for a field ScopeTag = "scope" // KeyTag is the tag name by which to override default key naming based on field name KeyTag = "key" // RecurseTag is the tag name with which different recursion properties are declared RecurseTag = "recurse" // HiddenScope means the key is hidden from the guest and will not have a GuestInfoPrefix HiddenScope = "hidden" // ReadOnlyScope means the key is read-only from the guest ReadOnlyScope = "read-only" // ReadWriteScope means the key may be read and modified by the guest ReadWriteScope = "read-write" // VolatileScope means that the value is expected to change and should be refreshed on use VolatileScope = "volatile" // SecretSuffix means the value should be encrypted in the vmx. SecretSuffix = "secret" // NonPersistentSuffix means the key should only be written if the key will be deleted on guest power off. NonPersistentSuffix = "non-persistent" // RecurseDepthProperty controls how deep to recuse into a structure field from this level. A value of zero // prevents both encode and decode of that field. This is provided to control recursion into unannotated structures. // This is unbounded if not specified. RecurseDepthProperty = "depth" // RecurseFollowProperty instructs encode and decode to follow pointers. RecurseFollowProperty = "follow" // RecurseNoFollowProperty instructs encode and decode not to follow pointers. RecurseNoFollowProperty = "nofollow" // RecurseSkipEncodeProperty causes the marked field and subfields to be skipped when encoding. RecurseSkipEncodeProperty = "skip-encode" // RecurseSkipDecodeProperty causes the marked field and subfields to be skipped when decoding. RecurseSkipDecodeProperty = "skip-decode" )
const ( // Invalid value Invalid = 1 << iota // Hidden value Hidden // ReadOnly value ReadOnly // WriteOnly value WriteOnly // ReadWrite value ReadWrite // NonPersistent value NonPersistent // Volatile value Volatile // Secret value Secret )
const GuestInfoSecretKey = GuestInfoPrefix + "ovfEnv"
The value of this key is hidden from API requests, but visible within the guest #nosec: Potential hardcoded credentials
Variables ¶
var ( // DefaultTagName is the annotation tag name we use for basic semantic version. Not currently used. DefaultTagName = "vic" // DefaultPrefix is prepended to generated key paths for basic namespacing DefaultPrefix = "vice." //Separator for slice values and map keys Separator = "|" )
TODO: this entire section of variables should be turned into a config struct that can be passed to Encode and Decode, or that Encode and Decode are method on
var (
ErrKeyNotFound = errors.New("key not found")
)
var Unbounded = recursion{/* contains filtered or unexported fields */}
Unbounded is the value used for unbounded recursion
Functions ¶
func CalculateKey ¶ added in v1.4.1
CalculateKey is a specific case of CalculateKeys that will panic if more than one key matches the field pattern passed in.
func CalculateKeys ¶
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 ¶
EncodeWithPrefix serializes the given type to the supplied data sink, using the supplied prefix - this allows for serialization of subsections of a struct
Types ¶
type DataSink ¶
DataSink provides a function that, given a key/value will persist that in some manner suited for later retrieval
func GuestInfoSink ¶
GuestInfoSink uses the rpcvmx mechanism to update the guestinfo key/value map as the datasink for encoding target structures
func GuestInfoSinkWithPrefix ¶
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 ScopeFilterSink ¶
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 ¶
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 SecretKey ¶
type SecretKey struct {
// contains filtered or unexported fields
}
SecretKey provides helpers to encrypt/decrypt extraconfig values
func (*SecretKey) FromString ¶
FromString base64 decodes an existing SecretKey
func (*SecretKey) Source ¶
func (s *SecretKey) Source(ds DataSource) DataSource
Source wraps the given DataSource, decrypting any secret values
Source Files ¶
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 |