terraform: input properly sends on only set input
This commit is contained in:
parent
dc3178e06a
commit
686871310d
|
@ -346,7 +346,7 @@ func (m schemaMap) Input(
|
||||||
"%s: %s", k, err)
|
"%s: %s", k, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
c.Raw[k] = value
|
c.Config[k] = value
|
||||||
}
|
}
|
||||||
|
|
||||||
return c, nil
|
return c, nil
|
||||||
|
|
|
@ -1413,9 +1413,7 @@ func TestSchemaMap_Input(t *testing.T) {
|
||||||
"availability_zone": "foo",
|
"availability_zone": "foo",
|
||||||
},
|
},
|
||||||
|
|
||||||
Result: map[string]interface{}{
|
Result: map[string]interface{}{},
|
||||||
"availability_zone": "bar",
|
|
||||||
},
|
|
||||||
|
|
||||||
Err: false,
|
Err: false,
|
||||||
},
|
},
|
||||||
|
@ -1494,14 +1492,16 @@ func TestSchemaMap_Input(t *testing.T) {
|
||||||
input := new(terraform.MockUIInput)
|
input := new(terraform.MockUIInput)
|
||||||
input.InputReturnMap = tc.Input
|
input.InputReturnMap = tc.Input
|
||||||
|
|
||||||
actual, err := schemaMap(tc.Schema).Input(
|
rc := terraform.NewResourceConfig(c)
|
||||||
input, terraform.NewResourceConfig(c))
|
rc.Config = make(map[string]interface{})
|
||||||
|
|
||||||
|
actual, err := schemaMap(tc.Schema).Input(input, rc)
|
||||||
if (err != nil) != tc.Err {
|
if (err != nil) != tc.Err {
|
||||||
t.Fatalf("#%d err: %s", i, err)
|
t.Fatalf("#%d err: %s", i, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !reflect.DeepEqual(tc.Result, actual.Raw) {
|
if !reflect.DeepEqual(tc.Result, actual.Config) {
|
||||||
t.Fatalf("#%d: bad:\n\n%#v", i, actual.Raw)
|
t.Fatalf("#%d: bad:\n\n%#v", i, actual.Config)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -600,6 +600,7 @@ func (c *walkContext) inputWalkFn() depgraph.WalkFunc {
|
||||||
raw = sharedProvider.Config.RawConfig
|
raw = sharedProvider.Config.RawConfig
|
||||||
}
|
}
|
||||||
rc := NewResourceConfig(raw)
|
rc := NewResourceConfig(raw)
|
||||||
|
rc.Config = make(map[string]interface{})
|
||||||
|
|
||||||
// Wrap the input into a namespace
|
// Wrap the input into a namespace
|
||||||
input := &PrefixUIInput{
|
input := &PrefixUIInput{
|
||||||
|
@ -617,8 +618,8 @@ func (c *walkContext) inputWalkFn() depgraph.WalkFunc {
|
||||||
return fmt.Errorf(
|
return fmt.Errorf(
|
||||||
"Error configuring %s: %s", k, err)
|
"Error configuring %s: %s", k, err)
|
||||||
}
|
}
|
||||||
if newc != nil {
|
if newc != nil && len(newc.Config) > 0 {
|
||||||
configs[k] = newc.Raw
|
configs[k] = newc.Config
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -647,11 +647,11 @@ func TestContextInput_provider(t *testing.T) {
|
||||||
|
|
||||||
var actual interface{}
|
var actual interface{}
|
||||||
p.InputFn = func(i UIInput, c *ResourceConfig) (*ResourceConfig, error) {
|
p.InputFn = func(i UIInput, c *ResourceConfig) (*ResourceConfig, error) {
|
||||||
c.Raw["foo"] = "bar"
|
c.Config["foo"] = "bar"
|
||||||
return c, nil
|
return c, nil
|
||||||
}
|
}
|
||||||
p.ConfigureFn = func(c *ResourceConfig) error {
|
p.ConfigureFn = func(c *ResourceConfig) error {
|
||||||
actual = c.Raw["foo"]
|
actual = c.Config["foo"]
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -693,11 +693,11 @@ func TestContextInput_providerId(t *testing.T) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
c.Raw["foo"] = v
|
c.Config["foo"] = v
|
||||||
return c, nil
|
return c, nil
|
||||||
}
|
}
|
||||||
p.ConfigureFn = func(c *ResourceConfig) error {
|
p.ConfigureFn = func(c *ResourceConfig) error {
|
||||||
actual = c.Raw["foo"]
|
actual = c.Config["foo"]
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -745,11 +745,11 @@ func TestContextInput_providerOnly(t *testing.T) {
|
||||||
|
|
||||||
var actual interface{}
|
var actual interface{}
|
||||||
p.InputFn = func(i UIInput, c *ResourceConfig) (*ResourceConfig, error) {
|
p.InputFn = func(i UIInput, c *ResourceConfig) (*ResourceConfig, error) {
|
||||||
c.Raw["foo"] = "bar"
|
c.Config["foo"] = "bar"
|
||||||
return c, nil
|
return c, nil
|
||||||
}
|
}
|
||||||
p.ConfigureFn = func(c *ResourceConfig) error {
|
p.ConfigureFn = func(c *ResourceConfig) error {
|
||||||
actual = c.Raw["foo"]
|
actual = c.Config["foo"]
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -794,10 +794,13 @@ func TestContextInput_providerVars(t *testing.T) {
|
||||||
UIInput: input,
|
UIInput: input,
|
||||||
})
|
})
|
||||||
|
|
||||||
input.InputReturnMap = map[string]string{}
|
input.InputReturnMap = map[string]string{
|
||||||
|
"var.foo": "bar",
|
||||||
|
}
|
||||||
|
|
||||||
var actual interface{}
|
var actual interface{}
|
||||||
p.InputFn = func(i UIInput, c *ResourceConfig) (*ResourceConfig, error) {
|
p.InputFn = func(i UIInput, c *ResourceConfig) (*ResourceConfig, error) {
|
||||||
|
c.Config["bar"] = "baz"
|
||||||
return c, nil
|
return c, nil
|
||||||
}
|
}
|
||||||
p.ConfigureFn = func(c *ResourceConfig) error {
|
p.ConfigureFn = func(c *ResourceConfig) error {
|
||||||
|
|
|
@ -1594,14 +1594,15 @@ func graphRemoveInvalidDeps(g *depgraph.Graph) {
|
||||||
func (p *graphSharedProvider) MergeConfig(
|
func (p *graphSharedProvider) MergeConfig(
|
||||||
raw bool, override map[string]interface{}) *ResourceConfig {
|
raw bool, override map[string]interface{}) *ResourceConfig {
|
||||||
var rawMap map[string]interface{}
|
var rawMap map[string]interface{}
|
||||||
if override != nil {
|
if p.Config != nil {
|
||||||
rawMap = override
|
|
||||||
} else if p.Config != nil {
|
|
||||||
rawMap = p.Config.RawConfig.Config()
|
rawMap = p.Config.RawConfig.Config()
|
||||||
}
|
}
|
||||||
if rawMap == nil {
|
if rawMap == nil {
|
||||||
rawMap = make(map[string]interface{})
|
rawMap = make(map[string]interface{})
|
||||||
}
|
}
|
||||||
|
for k, v := range override {
|
||||||
|
rawMap[k] = v
|
||||||
|
}
|
||||||
|
|
||||||
// Merge in all the parent configurations
|
// Merge in all the parent configurations
|
||||||
if p.Parent != nil {
|
if p.Parent != nil {
|
||||||
|
|
Loading…
Reference in New Issue