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.
pull/19086/head
Martin Atkins 8 years ago
parent 0a6938e90a
commit d6c6f8852c

@ -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

@ -59,11 +59,12 @@ func (m schemaMap) CoreConfigSchema() *configschema.Block {
// whose elem is a whole resource.
func (s *Schema) coreConfigSchemaAttribute() *configschema.Attribute {
return &configschema.Attribute{
Type: s.coreConfigSchemaType(),
Optional: s.Optional,
Required: s.Required,
Computed: s.Computed,
Sensitive: s.Sensitive,
Type: s.coreConfigSchemaType(),
Optional: s.Optional,
Required: s.Required,
Computed: s.Computed,
Sensitive: s.Sensitive,
Description: s.Description,
}
}

@ -23,8 +23,9 @@ func TestSchemaMapCoreConfigSchema(t *testing.T) {
"primitives": {
map[string]*Schema{
"int": {
Type: TypeInt,
Required: true,
Type: TypeInt,
Required: true,
Description: "foo bar baz",
},
"float": {
Type: TypeFloat,
@ -43,8 +44,9 @@ func TestSchemaMapCoreConfigSchema(t *testing.T) {
&configschema.Block{
Attributes: map[string]*configschema.Attribute{
"int": {
Type: cty.Number,
Required: true,
Type: cty.Number,
Required: true,
Description: "foo bar baz",
},
"float": {
Type: cty.Number,

Loading…
Cancel
Save