configschema: include description in schema

We will need access to this information in order to render interactive
input prompts, and it will also be useful in returning schema information
to external tools such as text editors that have autocomplete-like
functionality.
This commit is contained in:
Martin Atkins 2018-03-16 10:43:35 -07:00
parent 0a6938e90a
commit d6c6f8852c
3 changed files with 18 additions and 9 deletions

View File

@ -28,6 +28,12 @@ type Attribute struct {
// Type is a type specification that the attribute's value must conform to.
Type cty.Type
// Description is an English-language description of the purpose and
// usage of the attribute. A description should be concise and use only
// one or two sentences, leaving full definition to longer-form
// documentation defined elsewhere.
Description string
// Required, if set to true, specifies that an omitted or null value is
// not permitted.
Required bool

View File

@ -64,6 +64,7 @@ func (s *Schema) coreConfigSchemaAttribute() *configschema.Attribute {
Required: s.Required,
Computed: s.Computed,
Sensitive: s.Sensitive,
Description: s.Description,
}
}

View File

@ -25,6 +25,7 @@ func TestSchemaMapCoreConfigSchema(t *testing.T) {
"int": {
Type: TypeInt,
Required: true,
Description: "foo bar baz",
},
"float": {
Type: TypeFloat,
@ -45,6 +46,7 @@ func TestSchemaMapCoreConfigSchema(t *testing.T) {
"int": {
Type: cty.Number,
Required: true,
Description: "foo bar baz",
},
"float": {
Type: cty.Number,