common

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package common contains general functions that are used by various packages and unit tests in ibmcloud-terratest-wrapper module

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConditionalAdd

func ConditionalAdd(amap map[string]interface{}, key string, value string, compareValue string)

Adds value to map[key] only if value != compareValue

func ConvertArrayToJsonString

func ConvertArrayToJsonString(arr interface{}) (string, error)

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

func GetBeforeAfterDiff(jsonString string) string

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

func GetRequiredEnvVars(t *testing.T, variableNames []string) map[string]string

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

func GitRootPath(fromPath string) (string, error)

GitRootPath gets the path to the current git repos root directory

func IntArrayContains added in v1.5.1

func IntArrayContains(arr []int, val int) bool

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

func LoadMapFromYaml(filePath string) (map[string]interface{}, error)

LoadMapFromYaml loads a YAML file into a map[string]interface{}. It returns the resulting map and any error encountered.

func MergeMaps

func MergeMaps(maps ...map[string]interface{}) map[string]interface{}

overwriting duplicate keys

func StrArrayContains

func StrArrayContains(arr []string, val string) bool

StrArrayContains is a helper function that will check an array and see if a value is already present

Types

This section is empty.

Jump to

Keyboard shortcuts

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