Documentation
¶
Overview ¶
Package common contains general functions that are used by various packages and unit tests in ibmcloud-terratest-wrapper module
Index ¶
- func ConditionalAdd(amap map[string]interface{}, key string, value string, compareValue string)
- func ConvertArrayToJsonString(arr interface{}) (string, error)
- func GetBeforeAfterDiff(jsonString string) string
- func GetRequiredEnvVars(t *testing.T, variableNames []string) map[string]string
- func GetTagsFromTravis() []string
- func GitRootPath(fromPath string) (string, error)
- func IntArrayContains(arr []int, val int) bool
- func IsArray(v interface{}) bool
- func LoadMapFromYaml(filePath string) (map[string]interface{}, error)
- func MergeMaps(maps ...map[string]interface{}) map[string]interface{}
- func StrArrayContains(arr []string, val string) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConditionalAdd ¶
Adds value to map[key] only if value != compareValue
func ConvertArrayToJsonString ¶
ConvertArrayToJsonString is a helper function that will take an array of Golang data types, and return a string of the array formatted as a JSON array. Helpful to convert Golang arrays into a format that Terraform can consume.
func GetBeforeAfterDiff ¶
GetBeforeAfterDiff takes a JSON string as input and returns a string with the differences between the "before" and "after" objects in the JSON.
For example, given the JSON string:
{"before": {"a": 1, "b": 2}, "after": {"a": 2, "b": 3}}
the function would return the string:
"Before: {"b": 2}\nAfter: {"a": 2, "b": 3}"
func GetRequiredEnvVars ¶
GetRequiredEnvVars returns a map containing required environment variables and their values Fails the test if any are missing
func GetTagsFromTravis ¶
func GetTagsFromTravis() []string
GetTagsFromTravis Generates a list of tags to add to resources if running in Travis. Returns empty list if not in Travis
func GitRootPath ¶
GitRootPath gets the path to the current git repos root directory
func IntArrayContains ¶ added in v1.5.1
IntArrayContains is a helper function that will check an array and see if an int value is already present
func IsArray ¶
func IsArray(v interface{}) bool
IsArray is a simple helper function that will determine if a given Golang value is a slice or array.
func LoadMapFromYaml ¶ added in v1.8.0
LoadMapFromYaml loads a YAML file into a map[string]interface{}. It returns the resulting map and any error encountered.
func StrArrayContains ¶
StrArrayContains is a helper function that will check an array and see if a value is already present
Types ¶
This section is empty.