func getBody()

in tf/utils.go [264:302]


func getBody(input map[string]interface{}) (map[string]interface{}, error) {
	output := map[string]interface{}{}
	bodyRaw, ok := input["body"]
	if !ok || bodyRaw == nil {
		return output, nil
	}
	if bodyStr, ok := bodyRaw.(string); ok && bodyStr != "" {
		if value, ok := input["tags"]; ok && value != nil && len(value.(map[string]interface{})) > 0 {
			output["tags"] = value.(map[string]interface{})
		}

		if value, ok := input["location"]; ok && value != nil && value.(string) != "" {
			output["location"] = value.(string)
		}

		if value, ok := input["identity"]; ok && value != nil && len(value.([]interface{})) > 0 {
			output["identity"] = expandIdentity(value.([]interface{}))
		}

		err := json.Unmarshal([]byte(bodyStr), &output)
		return output, err
	}
	if bodyMap, ok := bodyRaw.(map[string]interface{}); ok {
		if value, ok := input["tags"]; ok && value != nil && len(value.(map[string]interface{})) > 0 {
			bodyMap["tags"] = value.(map[string]interface{})
		}

		if value, ok := input["location"]; ok && value != nil && value.(string) != "" {
			bodyMap["location"] = value.(string)
		}

		if value, ok := input["identity"]; ok && value != nil && len(value.([]interface{})) > 0 {
			bodyMap["identity"] = expandIdentity(value.([]interface{}))
		}
		return bodyMap, nil
	}

	return output, nil
}