Merge pull request #4193 from hashicorp/phinze/provider-dont-prompt-deprecated
helper/schema: skip provider input for deprecated fields
This commit is contained in:
commit
b09525d83d
|
@ -398,6 +398,11 @@ func (m schemaMap) Input(
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Deprecated fields should never prompt
|
||||||
|
if v.Deprecated != "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
// Skip things that have a value of some sort already
|
// Skip things that have a value of some sort already
|
||||||
if _, ok := c.Raw[k]; ok {
|
if _, ok := c.Raw[k]; ok {
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -2567,6 +2567,40 @@ func TestSchemaMap_InputDefault(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSchemaMap_InputDeprecated(t *testing.T) {
|
||||||
|
emptyConfig := make(map[string]interface{})
|
||||||
|
c, err := config.NewRawConfig(emptyConfig)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("err: %s", err)
|
||||||
|
}
|
||||||
|
rc := terraform.NewResourceConfig(c)
|
||||||
|
rc.Config = make(map[string]interface{})
|
||||||
|
|
||||||
|
input := new(terraform.MockUIInput)
|
||||||
|
input.InputFn = func(opts *terraform.InputOpts) (string, error) {
|
||||||
|
t.Fatalf("InputFn should not be called on: %#v", opts)
|
||||||
|
return "", nil
|
||||||
|
}
|
||||||
|
|
||||||
|
schema := map[string]*Schema{
|
||||||
|
"availability_zone": &Schema{
|
||||||
|
Type: TypeString,
|
||||||
|
Deprecated: "long gone",
|
||||||
|
Optional: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
actual, err := schemaMap(schema).Input(input, rc)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("err: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
expected := map[string]interface{}{}
|
||||||
|
|
||||||
|
if !reflect.DeepEqual(expected, actual.Config) {
|
||||||
|
t.Fatalf("got: %#v\nexpected: %#v", actual.Config, expected)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestSchemaMap_InternalValidate(t *testing.T) {
|
func TestSchemaMap_InternalValidate(t *testing.T) {
|
||||||
cases := map[string]struct {
|
cases := map[string]struct {
|
||||||
In map[string]*Schema
|
In map[string]*Schema
|
||||||
|
|
Loading…
Reference in New Issue