Merge pull request #15940 from hashicorp/b-output-desc
config: parse description field for outputs
This commit is contained in:
commit
b6047dcf9e
|
@ -143,6 +143,10 @@ func outputsStr(os []*Output) string {
|
||||||
result += fmt.Sprintf(" %s: %s\n", kind, str)
|
result += fmt.Sprintf(" %s: %s\n", kind, str)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if o.Description != "" {
|
||||||
|
result += fmt.Sprintf(" description\n %s\n", o.Description)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return strings.TrimSpace(result)
|
return strings.TrimSpace(result)
|
||||||
|
|
|
@ -499,6 +499,7 @@ func loadOutputsHcl(list *ast.ObjectList) ([]*Output, error) {
|
||||||
|
|
||||||
// Delete special keys
|
// Delete special keys
|
||||||
delete(config, "depends_on")
|
delete(config, "depends_on")
|
||||||
|
delete(config, "description")
|
||||||
|
|
||||||
rawConfig, err := NewRawConfig(config)
|
rawConfig, err := NewRawConfig(config)
|
||||||
if err != nil {
|
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{
|
result = append(result, &Output{
|
||||||
Name: n,
|
Name: n,
|
||||||
RawConfig: rawConfig,
|
RawConfig: rawConfig,
|
||||||
DependsOn: dependsOn,
|
DependsOn: dependsOn,
|
||||||
|
Description: description,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1058,6 +1058,11 @@ aws_instance.test (x1)
|
||||||
`
|
`
|
||||||
|
|
||||||
const basicOutputsStr = `
|
const basicOutputsStr = `
|
||||||
|
web_id
|
||||||
|
vars
|
||||||
|
resource: aws_instance.web.id
|
||||||
|
description
|
||||||
|
The ID
|
||||||
web_ip
|
web_ip
|
||||||
vars
|
vars
|
||||||
resource: aws_instance.web.private_ip
|
resource: aws_instance.web.private_ip
|
||||||
|
|
|
@ -85,6 +85,11 @@ output "web_ip" {
|
||||||
value = "${aws_instance.web.private_ip}"
|
value = "${aws_instance.web.private_ip}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
output "web_id" {
|
||||||
|
description = "The ID"
|
||||||
|
value = "${aws_instance.web.id}"
|
||||||
|
}
|
||||||
|
|
||||||
atlas {
|
atlas {
|
||||||
name = "mitchellh/foo"
|
name = "mitchellh/foo"
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,6 +88,10 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
"output": {
|
"output": {
|
||||||
|
"web_id": {
|
||||||
|
"description": "The ID",
|
||||||
|
"value": "${aws_instance.web.id}"
|
||||||
|
},
|
||||||
"web_ip": {
|
"web_ip": {
|
||||||
"value": "${aws_instance.web.private_ip}"
|
"value": "${aws_instance.web.private_ip}"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue