command: Re-enable showing outputs after successful "apply"
We temporarily disabled this because it needed some further work to update it for the new state models, which has now been done. We no longer need the configuration objects for the outputs because the state itself contains all of the information needed for displaying these.
This commit is contained in:
parent
98bbd560b5
commit
73abb6e8f4
|
@ -12,7 +12,6 @@ import (
|
||||||
"github.com/hashicorp/terraform/addrs"
|
"github.com/hashicorp/terraform/addrs"
|
||||||
"github.com/hashicorp/terraform/backend"
|
"github.com/hashicorp/terraform/backend"
|
||||||
"github.com/hashicorp/terraform/config/hcl2shim"
|
"github.com/hashicorp/terraform/config/hcl2shim"
|
||||||
"github.com/hashicorp/terraform/configs"
|
|
||||||
"github.com/hashicorp/terraform/repl"
|
"github.com/hashicorp/terraform/repl"
|
||||||
"github.com/hashicorp/terraform/states"
|
"github.com/hashicorp/terraform/states"
|
||||||
"github.com/hashicorp/terraform/tfdiags"
|
"github.com/hashicorp/terraform/tfdiags"
|
||||||
|
@ -201,18 +200,9 @@ func (c *ApplyCommand) Run(args []string) int {
|
||||||
}
|
}
|
||||||
|
|
||||||
if !c.Destroy {
|
if !c.Destroy {
|
||||||
// TODO: Print outputs, once this is updated to use new config types.
|
if outputs := outputsAsString(op.State, addrs.RootModuleInstance, true); outputs != "" {
|
||||||
/*
|
c.Ui.Output(c.Colorize().Color(outputs))
|
||||||
// Get the right module that we used. If we ran a plan, then use
|
}
|
||||||
// that module.
|
|
||||||
if plan != nil {
|
|
||||||
mod = plan.Module
|
|
||||||
}
|
|
||||||
|
|
||||||
if outputs := outputsAsString(op.State, terraform.RootModulePath, mod.Config().Outputs, true); outputs != "" {
|
|
||||||
c.Ui.Output(c.Colorize().Color(outputs))
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return op.Result.ExitStatus()
|
return op.Result.ExitStatus()
|
||||||
|
@ -342,7 +332,7 @@ Options:
|
||||||
return strings.TrimSpace(helpText)
|
return strings.TrimSpace(helpText)
|
||||||
}
|
}
|
||||||
|
|
||||||
func outputsAsString(state *states.State, modPath addrs.ModuleInstance, schema map[string]*configs.Output, includeHeader bool) string {
|
func outputsAsString(state *states.State, modPath addrs.ModuleInstance, includeHeader bool) string {
|
||||||
if state == nil {
|
if state == nil {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
@ -371,14 +361,12 @@ func outputsAsString(state *states.State, modPath addrs.ModuleInstance, schema m
|
||||||
sort.Strings(ks)
|
sort.Strings(ks)
|
||||||
|
|
||||||
for _, k := range ks {
|
for _, k := range ks {
|
||||||
schema, ok := schema[k]
|
v := outputs[k]
|
||||||
if ok && schema.Sensitive {
|
if v.Sensitive {
|
||||||
outputBuf.WriteString(fmt.Sprintf("%s = <sensitive>\n", k))
|
outputBuf.WriteString(fmt.Sprintf("%s = <sensitive>\n", k))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
v := outputs[k]
|
|
||||||
|
|
||||||
// Our formatter still wants an old-style raw interface{} value, so
|
// Our formatter still wants an old-style raw interface{} value, so
|
||||||
// for now we'll just shim it.
|
// for now we'll just shim it.
|
||||||
// FIXME: Port the formatter to work with cty.Value directly.
|
// FIXME: Port the formatter to work with cty.Value directly.
|
||||||
|
|
|
@ -158,7 +158,7 @@ func (c *OutputCommand) Run(args []string) int {
|
||||||
c.Ui.Output(string(jsonOutputs))
|
c.Ui.Output(string(jsonOutputs))
|
||||||
return 0
|
return 0
|
||||||
} else {
|
} else {
|
||||||
c.Ui.Output(outputsAsString(state, moduleAddr, nil, false))
|
c.Ui.Output(outputsAsString(state, moduleAddr, false))
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue