utils

package
v0.0.0-...-ac9fa31 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2021 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateMOAttributesPayload

func CreateMOAttributesPayload(d *schema.ResourceData, mo_struct interface{}, config *meta.ManagedObjectMeta) ([]byte, error)

return the APIC MO object attributes as a []byte string from the schemadata and using the specified struct this []byte string is used as raw payload for the APIC POST.

func ExtractMOAttributes

func ExtractMOAttributes(byte_data *[]byte, class_name string) (map[string]interface{}, error)

* Implements: Extracts the direct MO attributes from the given returned payload from the APIC * from a GET/POST for an MO DN. * Generally called from GetMOAttributes * Expects the correct full response payload from APIC GET MO DN * Takes the raw APIC JSON response payload, converts to JSON object then checks the APIC response, * then converts the given Managed Object attributes to a map[string]interface{} * * Returns: * map[string]interface{} as k,v for each of the MO direct attributes: { ... } * Empty map[string]interface{} if no records returned with no error

func GetMOParentDn

func GetMOParentDn(dn string) (string, error)

GetMOParentDn Strips the MO name from the DN returning the MO parent DN

func GetMOSchemaKeys

func GetMOSchemaKeys(mo_struct interface{}) []string

GetMOSchemaKeys Returns a []string of the schema keys (MO struct field names) from the given MO struct

func MapApicKeyToSchemaKey

func MapApicKeyToSchemaKey(mo_struct interface{}) map[string]string

The MO Struct has the following attr keys field name: Struct Field Name, capitilised first letter but otherwise same case as APIC attr key tag=>json: Has the key name of the APIC attr key is same case etc as APIC tag=>schema: Has the name that is used in the TF schema

Input: MO Struct Output: map[string]string = APIC_MO_ATTR_KEY: SCHEMA_MO_ATTR_KEY

func SetMOStructValues

func SetMOStructValues(d *schema.ResourceData, mo_struct interface{}, config *meta.ManagedObjectMeta)

* Implements: Takes a pointer to a struct and maps the schema.ResourceData to the Struct elements * Expects mo_struct as input e.g : bds := new(aci.BridgeDomain) * This is basically a custom json.Marshal * * Returns: * Nothing: but sets the passed managed object struct fields with the matched attributes * from the schema.ResourceData

func SetResourceDataValues

func SetResourceDataValues(d *schema.ResourceData, src_key_val_map map[string]interface{}, src_schema_key_map map[string]string)

SetResourceDataValues

Takes the APIC MO attributes in map[string]string format and sets the schema.ResourceData attribute values from this map.

Input: d *schema.ResourceData - The TF ResourceData to be set with values from src_key_val_map

src_key_val_map    		- map[string]string - key:attribute name, value:attribite value to set in Schema
src_schema_key_map 		- map[string]string - key: key name used in the src_key_val_map key, value: the TF schema key to use to set with src_key_val_map value

Output: schema.ResourceData.attributes.value set as input key value

func SuppressDiffCheck

func SuppressDiffCheck(compare_a, compare_b string) schema.SchemaDiffSuppressFunc

Compares the TF and APIC read value against a known default value to determine if the TF or APIC values are actually defaults. - For some attributes the APIC has two defaults, you can configure the APIC with either default - usually a actual value or an empty string, but the APIC read will only return one of the defaults, so we have this function to compare the TF value & APIC Value and what we know the real default on and APIC read would be and supress if they match.

func SuppressDiffCheckDefault

func SuppressDiffCheckDefault(apic_default string) schema.SchemaDiffSuppressFunc

Checks the value from the APIC read with a given attribute to determine if they match and if so then supress the diff

func ValidateList

func ValidateList(options []string) schema.SchemaValidateFunc

Types

This section is empty.

Jump to

Keyboard shortcuts

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