helper/schema: don't ask for input on fields that have a value

This commit is contained in:
Mitchell Hashimoto 2014-09-29 11:16:19 -07:00
parent 5b0859b3f5
commit d9596fa4d0
2 changed files with 32 additions and 4 deletions

View File

@ -282,6 +282,11 @@ func (m schemaMap) Input(
continue
}
// Skip things that have a value of some sort already
if _, ok := c.Raw[k]; ok {
continue
}
var value interface{}
var err error
switch v.Type {

View File

@ -1055,10 +1055,6 @@ func TestSchemaMap_Input(t *testing.T) {
},
},
Config: map[string]interface{}{
"availability_zone": "bar",
},
Input: map[string]string{
"availability_zone": "foo",
},
@ -1069,9 +1065,36 @@ func TestSchemaMap_Input(t *testing.T) {
Err: false,
},
{
Schema: map[string]*Schema{
"availability_zone": &Schema{
Type: TypeString,
Optional: true,
},
},
Config: map[string]interface{}{
"availability_zone": "bar",
},
Input: map[string]string{
"availability_zone": "foo",
},
Result: map[string]interface{}{
"availability_zone": "bar",
},
Err: false,
},
}
for i, tc := range cases {
if tc.Config == nil {
tc.Config = make(map[string]interface{})
}
c, err := config.NewRawConfig(tc.Config)
if err != nil {
t.Fatalf("err: %s", err)