mirror of https://github.com/hashicorp/terraform
parent
3d211eb42f
commit
14c53f74f2
@ -0,0 +1,56 @@
|
||||
// Copyright (c) HashiCorp, Inc.
|
||||
// SPDX-License-Identifier: BUSL-1.1
|
||||
|
||||
package views
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/hashicorp/terraform/internal/command/arguments"
|
||||
"github.com/hashicorp/terraform/internal/tfdiags"
|
||||
)
|
||||
|
||||
// The Init view is used for the init command.
|
||||
type Init interface {
|
||||
Diagnostics(diags tfdiags.Diagnostics)
|
||||
}
|
||||
|
||||
// NewInit returns Init implementation for the given ViewType.
|
||||
func NewInit(vt arguments.ViewType, view *View) Init {
|
||||
switch vt {
|
||||
case arguments.ViewJSON:
|
||||
return &InitJSON{
|
||||
view: NewJSONView(view),
|
||||
}
|
||||
case arguments.ViewHuman:
|
||||
return &InitHuman{
|
||||
view: view,
|
||||
}
|
||||
default:
|
||||
panic(fmt.Sprintf("unknown view type %v", vt))
|
||||
}
|
||||
}
|
||||
|
||||
// The InitHuman implementation renders human-readable text logs, suitable for
|
||||
// a scrolling terminal.
|
||||
type InitHuman struct {
|
||||
view *View
|
||||
}
|
||||
|
||||
var _ Init = (*InitHuman)(nil)
|
||||
|
||||
func (v *InitHuman) Diagnostics(diags tfdiags.Diagnostics) {
|
||||
v.view.Diagnostics(diags)
|
||||
}
|
||||
|
||||
// The InitJSON implementation renders streaming JSON logs, suitable for
|
||||
// integrating with other software.
|
||||
type InitJSON struct {
|
||||
view *JSONView
|
||||
}
|
||||
|
||||
var _ Init = (*InitJSON)(nil)
|
||||
|
||||
func (v *InitJSON) Diagnostics(diags tfdiags.Diagnostics) {
|
||||
v.view.Diagnostics(diags)
|
||||
}
|
||||
Loading…
Reference in new issue