Merge pull request #15940 from hashicorp/b-output-desc

config: parse description field for outputs
This commit is contained in:
Mitchell Hashimoto 2017-08-28 09:58:40 -07:00 committed by GitHub
commit b6047dcf9e
5 changed files with 35 additions and 3 deletions

View File

@ -143,6 +143,10 @@ func outputsStr(os []*Output) string {
result += fmt.Sprintf(" %s: %s\n", kind, str)
}
}
if o.Description != "" {
result += fmt.Sprintf(" description\n %s\n", o.Description)
}
}
return strings.TrimSpace(result)

View File

@ -499,6 +499,7 @@ func loadOutputsHcl(list *ast.ObjectList) ([]*Output, error) {
// Delete special keys
delete(config, "depends_on")
delete(config, "description")
rawConfig, err := NewRawConfig(config)
if err != nil {
@ -520,10 +521,23 @@ func loadOutputsHcl(list *ast.ObjectList) ([]*Output, error) {
}
}
// If we have a description field, then filter that
var description string
if o := listVal.Filter("description"); len(o.Items) > 0 {
err := hcl.DecodeObject(&description, o.Items[0].Val)
if err != nil {
return nil, fmt.Errorf(
"Error reading description for output %q: %s",
n,
err)
}
}
result = append(result, &Output{
Name: n,
RawConfig: rawConfig,
DependsOn: dependsOn,
Description: description,
})
}

View File

@ -1058,6 +1058,11 @@ aws_instance.test (x1)
`
const basicOutputsStr = `
web_id
vars
resource: aws_instance.web.id
description
The ID
web_ip
vars
resource: aws_instance.web.private_ip

View File

@ -85,6 +85,11 @@ output "web_ip" {
value = "${aws_instance.web.private_ip}"
}
output "web_id" {
description = "The ID"
value = "${aws_instance.web.id}"
}
atlas {
name = "mitchellh/foo"
}

View File

@ -88,6 +88,10 @@
},
"output": {
"web_id": {
"description": "The ID",
"value": "${aws_instance.web.id}"
},
"web_ip": {
"value": "${aws_instance.web.private_ip}"
}