terraform: tests passing for Config change
This commit is contained in:
parent
e4bcd3c448
commit
a19e2983de
|
@ -48,6 +48,7 @@ func (t *libuclConfigurable) Config() (*Config, error) {
|
||||||
// TODO(mitchellh): Make function like loadVariablesLibucl so that
|
// TODO(mitchellh): Make function like loadVariablesLibucl so that
|
||||||
// duplicates aren't overriden
|
// duplicates aren't overriden
|
||||||
config := new(Config)
|
config := new(Config)
|
||||||
|
if len(rawConfig.Variable) > 0 {
|
||||||
config.Variables = make([]*Variable, 0, len(rawConfig.Variable))
|
config.Variables = make([]*Variable, 0, len(rawConfig.Variable))
|
||||||
for k, v := range rawConfig.Variable {
|
for k, v := range rawConfig.Variable {
|
||||||
defaultSet := false
|
defaultSet := false
|
||||||
|
@ -65,6 +66,7 @@ func (t *libuclConfigurable) Config() (*Config, error) {
|
||||||
defaultSet: defaultSet,
|
defaultSet: defaultSet,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Build the provider configs
|
// Build the provider configs
|
||||||
providers := t.Object.Get("provider")
|
providers := t.Object.Get("provider")
|
||||||
|
|
|
@ -26,6 +26,7 @@ func Merge(c1, c2 *Config) (*Config, error) {
|
||||||
|
|
||||||
// Merge variables: Variable merging is quite simple. Set fields in
|
// Merge variables: Variable merging is quite simple. Set fields in
|
||||||
// later set variables override those earlier.
|
// later set variables override those earlier.
|
||||||
|
if len(c1.Variables) > 0 || len(c2.Variables) > 0 {
|
||||||
c.Variables = make([]*Variable, 0, len(c1.Variables)+len(c2.Variables))
|
c.Variables = make([]*Variable, 0, len(c1.Variables)+len(c2.Variables))
|
||||||
varMap := make(map[string]*Variable)
|
varMap := make(map[string]*Variable)
|
||||||
for _, v := range c1.Variables {
|
for _, v := range c1.Variables {
|
||||||
|
@ -47,6 +48,7 @@ func Merge(c1, c2 *Config) (*Config, error) {
|
||||||
for _, v := range varMap {
|
for _, v := range varMap {
|
||||||
c.Variables = append(c.Variables, v)
|
c.Variables = append(c.Variables, v)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Merge outputs: If they collide, just take the latest one for now. In
|
// Merge outputs: If they collide, just take the latest one for now. In
|
||||||
// the future, we might provide smarter merge functionality.
|
// the future, we might provide smarter merge functionality.
|
||||||
|
|
|
@ -53,6 +53,8 @@ func TestReadWritePlan(t *testing.T) {
|
||||||
t.Fatalf("err: %s", err)
|
t.Fatalf("err: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
println(reflect.DeepEqual(actual.Config.Variables, plan.Config.Variables))
|
||||||
|
|
||||||
if !reflect.DeepEqual(actual, plan) {
|
if !reflect.DeepEqual(actual, plan) {
|
||||||
t.Fatalf("bad: %#v", actual)
|
t.Fatalf("bad: %#v", actual)
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,9 +13,9 @@ func smcUserVariables(c *config.Config, vs map[string]string) []error {
|
||||||
|
|
||||||
// Check that all required variables are present
|
// Check that all required variables are present
|
||||||
required := make(map[string]struct{})
|
required := make(map[string]struct{})
|
||||||
for k, v := range c.Variables {
|
for _, v := range c.Variables {
|
||||||
if v.Required() {
|
if v.Required() {
|
||||||
required[k] = struct{}{}
|
required[v.Name] = struct{}{}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for k, _ := range vs {
|
for k, _ := range vs {
|
||||||
|
|
Loading…
Reference in New Issue