structure

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2018 License: MPL-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllFieldsEmpty

func AllFieldsEmpty(v interface{}) bool

AllFieldsEmpty checks to see if all fields in a given struct are zero values. It does not recurse, so finer-grained checking should be done for deep accuracy when necessary. It also does not dereference pointers, except if the value itself is a pointer and is not nil.

func BoolPolicy

func BoolPolicy(b bool) *types.BoolPolicy

BoolPolicy converts a bool into a VMware BoolPolicy value.

func BoolPtr

func BoolPtr(v bool) *bool

BoolPtr makes a *bool out of the value passed in through v.

vSphere uses nil values in bools to omit values in the SOAP XML request, and helps denote inheritance in certain cases.

func ByteToGB

func ByteToGB(n interface{}) interface{}

ByteToGB returns n/1000000000. The input must be an integer that can be divisible by 1000000000.

Remember that int32 overflows at 2GB, so any values higher than that will produce an inaccurate result.

func ByteToGiB

func ByteToGiB(n interface{}) interface{}

ByteToGiB returns n/1024^3. The input must be an integer that can be appropriately divisible.

Remember that int32 overflows at approximately 2GiB, so any values higher than that will produce an inaccurate result.

func ByteToMB

func ByteToMB(n interface{}) interface{}

ByteToMB returns n/1000000. The input must be an integer that can be divisible by 1000000.

func DeRef

func DeRef(v interface{}) interface{}

DeRef returns the value pointed to by the interface if the interface is a pointer and is not nil, otherwise returns nil, or the direct value if it's not a pointer.

func GBToByte

func GBToByte(n interface{}) int64

GBToByte returns n*1000000000.

The output is returned as int64 - if another type is needed, it needs to be cast. Remember that int32 overflows at 2GB and uint32 will overflow at 4GB.

func GetBool

func GetBool(d *schema.ResourceData, key string) *bool

GetBool reads a ResourceData and returns a *bool. This differs from GetBoolPtr in that a nil value is never returned.

func GetBoolPolicy

func GetBoolPolicy(d *schema.ResourceData, key string) *types.BoolPolicy

GetBoolPolicy reads a ResourceData and returns an appropriate BoolPolicy for the state of the definition. nil is returned if it does not exist.

func GetBoolPolicyReverse

func GetBoolPolicyReverse(d *schema.ResourceData, key string) *types.BoolPolicy

GetBoolPolicyReverse acts like GetBoolPolicy, but the value is inverted.

func GetBoolPtr

func GetBoolPtr(d *schema.ResourceData, key string) *bool

GetBoolPtr reads a ResourceData and returns an appropriate *bool for the state of the definition. nil is returned if it does not exist.

func GetInt64Ptr

func GetInt64Ptr(d *schema.ResourceData, key string) *int64

GetInt64Ptr reads a ResourceData and returns an appropriate *int64 for the state of the definition. nil is returned if it does not exist.

func GetLongPolicy

func GetLongPolicy(d *schema.ResourceData, key string) *types.LongPolicy

GetLongPolicy reads a ResourceData and returns an appropriate LongPolicy for the state of the definition. nil is returned if it does not exist.

func GetStringPolicy

func GetStringPolicy(d *schema.ResourceData, key string) *types.StringPolicy

GetStringPolicy reads a ResourceData and returns an appropriate StringPolicy for the state of the definition. nil is returned if it does not exist.

func GiBToByte

func GiBToByte(n interface{}) int64

GiBToByte returns n*1024^3.

The output is returned as int64 - if another type is needed, it needs to be cast. Remember that int32 overflows at around 2GiB and uint32 will overflow at 4GiB.

func Int32Ptr

func Int32Ptr(v int32) *int32

Int32Ptr makes an *int32 out of the value passed in through v.

func Int64Ptr

func Int64Ptr(v int64) *int64

Int64Ptr makes an *int64 out of the value passed in through v.

func LogCond added in v1.1.1

func LogCond(c bool, t, f interface{}) interface{}

LogCond takes a boolean (which can be passed in as a bool or as a conditional), and returns either the first value if true, and the second if false. It's designed to be a "ternary" operator of sorts for logging.

func LongPolicy

func LongPolicy(n interface{}) *types.LongPolicy

LongPolicy converts a supported number into a VMware LongPolicy value. This will panic if there is no implicit conversion of the value into an int64.

func MergeSchema

func MergeSchema(dst, src map[string]*schema.Schema)

MergeSchema merges the map[string]*schema.Schema from src into dst. Safety against conflicts is enforced by panicing.

func NormalizeValue

func NormalizeValue(v interface{}) interface{}

NormalizeValue converts a value to something that is suitable to be set in a ResourceData and can be useful in situations where there is not access to normal helper/schema functionality, but you still need saved fields to behave in the same way.

Specifically, this will run the value through DeRef to dereference any pointers first, and then convert numeric primitives, if necessary.

func SetBoolPolicy

func SetBoolPolicy(d *schema.ResourceData, key string, val *types.BoolPolicy) error

SetBoolPolicy sets a ResourceData field depending on if a BoolPolicy exists or not. The field is not set if it's nil.

func SetBoolPolicyReverse

func SetBoolPolicyReverse(d *schema.ResourceData, key string, val *types.BoolPolicy) error

SetBoolPolicyReverse acts like SetBoolPolicy, but the value is inverted.

func SetBoolPtr

func SetBoolPtr(d *schema.ResourceData, key string, val *bool) error

SetBoolPtr sets a ResourceData field depending on if a *bool exists or not. The field is not set if it's nil.

func SetInt64Ptr

func SetInt64Ptr(d *schema.ResourceData, key string, val *int64) error

SetInt64Ptr sets a ResourceData field depending on if an *int64 exists or not. The field is not set if it's nil.

func SetLongPolicy

func SetLongPolicy(d *schema.ResourceData, key string, val *types.LongPolicy) error

SetLongPolicy sets a ResourceData field depending on if a LongPolicy exists or not. The field is not set if it's nil.

func SetStringPolicy

func SetStringPolicy(d *schema.ResourceData, key string, val *types.StringPolicy) error

SetStringPolicy sets a ResourceData field depending on if a StringPolicy exists or not. The field is not set if it's nil.

func SliceInterfacesToStrings

func SliceInterfacesToStrings(s []interface{}) []string

SliceInterfacesToStrings converts an interface slice to a string slice. The function does not attempt to do any sanity checking and will panic if one of the items in the slice is not a string.

func SliceStringsToInterfaces

func SliceStringsToInterfaces(s []string) []interface{}

SliceStringsToInterfaces converts a string slice to an interface slice.

func StringPolicy

func StringPolicy(s string) *types.StringPolicy

StringPolicy converts a string into a VMware StringPolicy value.

Types

This section is empty.

Jump to

Keyboard shortcuts

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