name="blah"
foo="bar"
profile "site1" {
api_url = "https://api.site1.com/client"
api_key = "key"
secret_key = "secret"
}
profile "site2" {
api_url = "https://api.site2.com/client"
api_key = "key"
secret_key = "secret"
}
"list" = ["item1", "item2", "item3"]
"map" = {
"key" = "value"
}
"nested_map" "map" {
"key" = "value"
"list" = ["item1", "item2", "item3"]
}
The following is probably a hacky way of doing it..I do think there is a cleaner way to get these values by using structs and the viper.unmarshal() function(TBD).
hclKeyValue := viper.Get("foo")
fmt.Println("\n\nhclKeyValue is: ", hclKeyValue)
hclList := viper.Get("list")
fmt.Printf("hclList is: %T\n\n", hclList.([]interface{})[2])
hclMap := viper.Get("map")
fmt.Println("\n\nhclMap is: ", hclMap.([]map[string]interface{})[0]["key"])
hclNestedMap := viper.Get("nested_map")
fmt.Println("\n\nhclNestedMap is Key: ", hclNestedMap.([]map[string]interface{})[0]["key"])
fmt.Println("\n\nhclNestedMap is List: ", hclNestedMap.([]map[string]interface{})[0]["list"])
hclProfiles := viper.Get("profile")
fmt.Println("\n\nhclProfiles are: ", hclProfiles.([]map[string]interface{}))
fmt.Println("\n\nhclProfiles first slice: ", hclProfiles.([]map[string]interface{})[0])
fmt.Println("\n\nhclProfiles first slice/value: ", hclProfiles.([]map[string]interface{})[0]["site1"].([]map[string]interface{})[0]["api_url"])