2014-05-24 00:28:19 +02:00
|
|
|
package config
|
|
|
|
|
|
|
|
// Load loads the Terraform configuration from a given file.
|
2014-05-24 00:32:34 +02:00
|
|
|
//
|
|
|
|
// This file can be any format that Terraform recognizes, and import any
|
|
|
|
// other format that Terraform recognizes.
|
2014-05-24 00:28:19 +02:00
|
|
|
func Load(path string) (*Config, error) {
|
|
|
|
importTree, err := loadTree(path)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
configTree, err := importTree.ConfigTree()
|
2014-05-24 01:30:28 +02:00
|
|
|
|
|
|
|
// Close the importTree now so that we can clear resources as quickly
|
|
|
|
// as possible.
|
|
|
|
importTree.Close()
|
|
|
|
|
2014-05-24 00:28:19 +02:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return configTree.Flatten()
|
|
|
|
}
|