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 is a type specification that the attribute's value must conform to.
Type cty.Type 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 // Required, if set to true, specifies that an omitted or null value is
// not permitted. // not permitted.
Required bool Required bool

View File

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

View File

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