config: not directory that config was loaded from
This commit is contained in:
parent
6eee9fbcb3
commit
f8836290da
|
@ -15,6 +15,11 @@ import (
|
|||
// Config is the configuration that comes from loading a collection
|
||||
// of Terraform templates.
|
||||
type Config struct {
|
||||
// Dir is the path to the directory where this configuration was
|
||||
// loaded from. If it is blank, this configuration wasn't loaded from
|
||||
// any meaningful directory.
|
||||
Dir string
|
||||
|
||||
Modules []*Module
|
||||
ProviderConfigs []*ProviderConfig
|
||||
Resources []*Resource
|
||||
|
|
|
@ -140,6 +140,9 @@ func LoadDir(root string) (*Config, error) {
|
|||
}
|
||||
}
|
||||
|
||||
// Mark the directory
|
||||
result.Dir = root
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,10 @@ func TestLoadBasic(t *testing.T) {
|
|||
t.Fatal("config should not be nil")
|
||||
}
|
||||
|
||||
if c.Dir != "" {
|
||||
t.Fatalf("bad: %#v", c.Dir)
|
||||
}
|
||||
|
||||
actual := variablesStr(c.Variables)
|
||||
if actual != strings.TrimSpace(basicVariablesStr) {
|
||||
t.Fatalf("bad:\n%s", actual)
|
||||
|
@ -85,6 +89,10 @@ func TestLoadBasic_json(t *testing.T) {
|
|||
t.Fatal("config should not be nil")
|
||||
}
|
||||
|
||||
if c.Dir != "" {
|
||||
t.Fatalf("bad: %#v", c.Dir)
|
||||
}
|
||||
|
||||
actual := variablesStr(c.Variables)
|
||||
if actual != strings.TrimSpace(basicVariablesStr) {
|
||||
t.Fatalf("bad:\n%s", actual)
|
||||
|
@ -116,6 +124,10 @@ func TestLoadBasic_modules(t *testing.T) {
|
|||
t.Fatal("config should not be nil")
|
||||
}
|
||||
|
||||
if c.Dir != "" {
|
||||
t.Fatalf("bad: %#v", c.Dir)
|
||||
}
|
||||
|
||||
actual := modulesStr(c.Modules)
|
||||
if actual != strings.TrimSpace(modulesModulesStr) {
|
||||
t.Fatalf("bad:\n%s", actual)
|
||||
|
@ -131,6 +143,10 @@ func TestLoad_variables(t *testing.T) {
|
|||
t.Fatal("config should not be nil")
|
||||
}
|
||||
|
||||
if c.Dir != "" {
|
||||
t.Fatalf("bad: %#v", c.Dir)
|
||||
}
|
||||
|
||||
actual := variablesStr(c.Variables)
|
||||
if actual != strings.TrimSpace(variablesVariablesStr) {
|
||||
t.Fatalf("bad:\n%s", actual)
|
||||
|
@ -138,7 +154,8 @@ func TestLoad_variables(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestLoadDir_basic(t *testing.T) {
|
||||
c, err := LoadDir(filepath.Join(fixtureDir, "dir-basic"))
|
||||
dir := filepath.Join(fixtureDir, "dir-basic")
|
||||
c, err := LoadDir(dir)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
@ -147,6 +164,10 @@ func TestLoadDir_basic(t *testing.T) {
|
|||
t.Fatal("config should not be nil")
|
||||
}
|
||||
|
||||
if c.Dir != dir {
|
||||
t.Fatalf("bad: %#v", c.Dir)
|
||||
}
|
||||
|
||||
actual := variablesStr(c.Variables)
|
||||
if actual != strings.TrimSpace(dirBasicVariablesStr) {
|
||||
t.Fatalf("bad:\n%s", actual)
|
||||
|
|
Loading…
Reference in New Issue