mirror of
https://github.com/opentffoundation/opentf.git
synced 2025-12-19 17:59:05 -05:00
Safer showDiagnostics in -json-into
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
This commit is contained in:
@@ -762,12 +762,12 @@ func (m *Meta) showDiagnostics(vals ...interface{}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if m.outputJSONInto != "" {
|
if m.outputJSONInto != "" {
|
||||||
out, err := os.OpenFile(m.outputJSONInto, os.O_RDWR|os.O_CREATE, 0600)
|
// This is a weird workaround for init and get using the legacy view wrappers mixed with the new view system
|
||||||
if err != nil {
|
wrapped, ok := m.Ui.(*WrappedUi)
|
||||||
panic(err)
|
if wrapped == nil || !ok {
|
||||||
|
panic("BUG: incorrect initialization of meta command structure")
|
||||||
}
|
}
|
||||||
jsonView := views.NewJSONView(m.View, out)
|
wrapped.jsonView.Diagnostics(diags)
|
||||||
jsonView.Diagnostics(diags)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if m.outputInJSON {
|
if m.outputInJSON {
|
||||||
|
|||||||
Reference in New Issue
Block a user