views

package
v1.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2021 License: MPL-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const JSON_UI_VERSION = "0.1.0"

This version describes the schema of JSON UI messages. This version must be updated after making any changes to this view, the jsonHook, or any of the command/views/json package.

Variables

This section is empty.

Functions

This section is empty.

Types

type Apply

type Apply interface {
	ResourceCount(stateOutPath string)
	Outputs(outputValues map[string]*states.OutputValue)

	Operation() Operation
	Hooks() []terraform.Hook

	Diagnostics(diags tfdiags.Diagnostics)
	HelpPrompt()
}

The Apply view is used for the apply command.

func NewApply

func NewApply(vt arguments.ViewType, destroy bool, view *View) Apply

NewApply returns an initialized Apply implementation for the given ViewType.

type ApplyHuman

type ApplyHuman struct {
	// contains filtered or unexported fields
}

The ApplyHuman implementation renders human-readable text logs, suitable for a scrolling terminal.

func (*ApplyHuman) Diagnostics

func (v *ApplyHuman) Diagnostics(diags tfdiags.Diagnostics)

func (*ApplyHuman) HelpPrompt

func (v *ApplyHuman) HelpPrompt()

func (*ApplyHuman) Hooks

func (v *ApplyHuman) Hooks() []terraform.Hook

func (*ApplyHuman) Operation

func (v *ApplyHuman) Operation() Operation

func (*ApplyHuman) Outputs

func (v *ApplyHuman) Outputs(outputValues map[string]*states.OutputValue)

func (*ApplyHuman) ResourceCount

func (v *ApplyHuman) ResourceCount(stateOutPath string)

type ApplyJSON

type ApplyJSON struct {
	// contains filtered or unexported fields
}

The ApplyJSON implementation renders streaming JSON logs, suitable for integrating with other software.

func (*ApplyJSON) Diagnostics

func (v *ApplyJSON) Diagnostics(diags tfdiags.Diagnostics)

func (*ApplyJSON) HelpPrompt

func (v *ApplyJSON) HelpPrompt()

func (*ApplyJSON) Hooks

func (v *ApplyJSON) Hooks() []terraform.Hook

func (*ApplyJSON) Operation

func (v *ApplyJSON) Operation() Operation

func (*ApplyJSON) Outputs

func (v *ApplyJSON) Outputs(outputValues map[string]*states.OutputValue)

func (*ApplyJSON) ResourceCount

func (v *ApplyJSON) ResourceCount(stateOutPath string)

type JSONView

type JSONView struct {
	// contains filtered or unexported fields
}

func NewJSONView

func NewJSONView(view *View) *JSONView

func (*JSONView) ChangeSummary

func (v *JSONView) ChangeSummary(cs *json.ChangeSummary)

func (*JSONView) Diagnostics

func (v *JSONView) Diagnostics(diags tfdiags.Diagnostics)

func (*JSONView) Hook

func (v *JSONView) Hook(h json.Hook)

func (*JSONView) Log

func (v *JSONView) Log(message string)

func (*JSONView) Outputs

func (v *JSONView) Outputs(outputs json.Outputs)

func (*JSONView) PlannedChange

func (v *JSONView) PlannedChange(c *json.ResourceInstanceChange)

func (*JSONView) ResourceDrift

func (v *JSONView) ResourceDrift(c *json.ResourceInstanceChange)

func (*JSONView) StateDump

func (v *JSONView) StateDump(state string)

func (*JSONView) Version

func (v *JSONView) Version()

type Operation

type Operation interface {
	Interrupted()
	FatalInterrupt()
	Stopping()
	Cancelled(planMode plans.Mode)

	EmergencyDumpState(stateFile *statefile.File) error

	PlannedChange(change *plans.ResourceInstanceChangeSrc)
	Plan(plan *plans.Plan, schemas *terraform.Schemas)
	PlanNextStep(planPath string)

	Diagnostics(diags tfdiags.Diagnostics)
}

func NewOperation

func NewOperation(vt arguments.ViewType, inAutomation bool, view *View) Operation

type OperationHuman

type OperationHuman struct {
	// contains filtered or unexported fields
}

func (*OperationHuman) Cancelled

func (v *OperationHuman) Cancelled(planMode plans.Mode)

func (*OperationHuman) Diagnostics

func (v *OperationHuman) Diagnostics(diags tfdiags.Diagnostics)

func (*OperationHuman) EmergencyDumpState

func (v *OperationHuman) EmergencyDumpState(stateFile *statefile.File) error

func (*OperationHuman) FatalInterrupt

func (v *OperationHuman) FatalInterrupt()

func (*OperationHuman) Interrupted

func (v *OperationHuman) Interrupted()

func (*OperationHuman) Plan

func (v *OperationHuman) Plan(plan *plans.Plan, schemas *terraform.Schemas)

func (*OperationHuman) PlanNextStep

func (v *OperationHuman) PlanNextStep(planPath string)

PlanNextStep gives the user some next-steps, unless we're running in an automation tool which is presumed to provide its own UI for further actions.

func (*OperationHuman) PlannedChange

func (v *OperationHuman) PlannedChange(change *plans.ResourceInstanceChangeSrc)

func (*OperationHuman) Stopping

func (v *OperationHuman) Stopping()

type OperationJSON

type OperationJSON struct {
	// contains filtered or unexported fields
}

func (*OperationJSON) Cancelled

func (v *OperationJSON) Cancelled(planMode plans.Mode)

func (*OperationJSON) Diagnostics

func (v *OperationJSON) Diagnostics(diags tfdiags.Diagnostics)

func (*OperationJSON) EmergencyDumpState

func (v *OperationJSON) EmergencyDumpState(stateFile *statefile.File) error

func (*OperationJSON) FatalInterrupt

func (v *OperationJSON) FatalInterrupt()

func (*OperationJSON) Interrupted

func (v *OperationJSON) Interrupted()

func (*OperationJSON) Plan

func (v *OperationJSON) Plan(plan *plans.Plan, schemas *terraform.Schemas)

Log a change summary and a series of "planned" messages for the changes in the plan.

func (*OperationJSON) PlanNextStep

func (v *OperationJSON) PlanNextStep(planPath string)

PlanNextStep does nothing for the JSON view as it is a hook for user-facing output only applicable to human-readable UI.

func (*OperationJSON) PlannedChange

func (v *OperationJSON) PlannedChange(change *plans.ResourceInstanceChangeSrc)

func (*OperationJSON) Stopping

func (v *OperationJSON) Stopping()

type Output

type Output interface {
	Output(name string, outputs map[string]*states.OutputValue) tfdiags.Diagnostics
	Diagnostics(diags tfdiags.Diagnostics)
}

The Output view renders either one or all outputs, depending on whether or not the name argument is empty.

func NewOutput

func NewOutput(vt arguments.ViewType, view *View) Output

NewOutput returns an initialized Output implementation for the given ViewType.

type OutputHuman

type OutputHuman struct {
	// contains filtered or unexported fields
}

The OutputHuman implementation renders outputs in a format equivalent to HCL source. This uses the same formatting logic as in the console REPL.

func (*OutputHuman) Diagnostics

func (v *OutputHuman) Diagnostics(diags tfdiags.Diagnostics)

func (*OutputHuman) Output

func (v *OutputHuman) Output(name string, outputs map[string]*states.OutputValue) tfdiags.Diagnostics

type OutputJSON

type OutputJSON struct {
	// contains filtered or unexported fields
}

The OutputJSON implementation renders outputs as JSON values. When rendering a single output, only the value is displayed. When rendering all outputs, the result is a JSON object with keys matching the output names and object values including type and sensitivity metadata.

func (*OutputJSON) Diagnostics

func (v *OutputJSON) Diagnostics(diags tfdiags.Diagnostics)

func (*OutputJSON) Output

func (v *OutputJSON) Output(name string, outputs map[string]*states.OutputValue) tfdiags.Diagnostics

type OutputRaw

type OutputRaw struct {
	// contains filtered or unexported fields
}

The OutputRaw implementation renders single string, number, or boolean output values directly and without quotes or other formatting. This is intended for use in shell scripting or other environments where the exact type of an output value is not important.

func (*OutputRaw) Diagnostics

func (v *OutputRaw) Diagnostics(diags tfdiags.Diagnostics)

func (*OutputRaw) Output

func (v *OutputRaw) Output(name string, outputs map[string]*states.OutputValue) tfdiags.Diagnostics

type Plan

type Plan interface {
	Operation() Operation
	Hooks() []terraform.Hook

	Diagnostics(diags tfdiags.Diagnostics)
	HelpPrompt()
}

The Plan view is used for the plan command.

func NewPlan

func NewPlan(vt arguments.ViewType, view *View) Plan

NewPlan returns an initialized Plan implementation for the given ViewType.

type PlanHuman

type PlanHuman struct {
	// contains filtered or unexported fields
}

The PlanHuman implementation renders human-readable text logs, suitable for a scrolling terminal.

func (*PlanHuman) Diagnostics

func (v *PlanHuman) Diagnostics(diags tfdiags.Diagnostics)

func (*PlanHuman) HelpPrompt

func (v *PlanHuman) HelpPrompt()

func (*PlanHuman) Hooks

func (v *PlanHuman) Hooks() []terraform.Hook

func (*PlanHuman) Operation

func (v *PlanHuman) Operation() Operation

type PlanJSON

type PlanJSON struct {
	// contains filtered or unexported fields
}

The PlanJSON implementation renders streaming JSON logs, suitable for integrating with other software.

func (*PlanJSON) Diagnostics

func (v *PlanJSON) Diagnostics(diags tfdiags.Diagnostics)

func (*PlanJSON) HelpPrompt

func (v *PlanJSON) HelpPrompt()

func (*PlanJSON) Hooks

func (v *PlanJSON) Hooks() []terraform.Hook

func (*PlanJSON) Operation

func (v *PlanJSON) Operation() Operation

type Refresh

type Refresh interface {
	Outputs(outputValues map[string]*states.OutputValue)

	Operation() Operation
	Hooks() []terraform.Hook

	Diagnostics(diags tfdiags.Diagnostics)
	HelpPrompt()
}

The Refresh view is used for the refresh command.

func NewRefresh

func NewRefresh(vt arguments.ViewType, view *View) Refresh

NewRefresh returns an initialized Refresh implementation for the given ViewType.

type RefreshHuman

type RefreshHuman struct {
	// contains filtered or unexported fields
}

The RefreshHuman implementation renders human-readable text logs, suitable for a scrolling terminal.

func (*RefreshHuman) Diagnostics

func (v *RefreshHuman) Diagnostics(diags tfdiags.Diagnostics)

func (*RefreshHuman) HelpPrompt

func (v *RefreshHuman) HelpPrompt()

func (*RefreshHuman) Hooks

func (v *RefreshHuman) Hooks() []terraform.Hook

func (*RefreshHuman) Operation

func (v *RefreshHuman) Operation() Operation

func (*RefreshHuman) Outputs

func (v *RefreshHuman) Outputs(outputValues map[string]*states.OutputValue)

type RefreshJSON

type RefreshJSON struct {
	// contains filtered or unexported fields
}

The RefreshJSON implementation renders streaming JSON logs, suitable for integrating with other software.

func (*RefreshJSON) Diagnostics

func (v *RefreshJSON) Diagnostics(diags tfdiags.Diagnostics)

func (*RefreshJSON) HelpPrompt

func (v *RefreshJSON) HelpPrompt()

func (*RefreshJSON) Hooks

func (v *RefreshJSON) Hooks() []terraform.Hook

func (*RefreshJSON) Operation

func (v *RefreshJSON) Operation() Operation

func (*RefreshJSON) Outputs

func (v *RefreshJSON) Outputs(outputValues map[string]*states.OutputValue)

type Show

type Show interface {
	Plan(plan *plans.Plan, schemas *terraform.Schemas)
}

FIXME: this is a temporary partial definition of the view for the show command, in place to allow access to the plan renderer which is now in the views package.

func NewShow

func NewShow(vt arguments.ViewType, view *View) Show

FIXME: the show view should support both human and JSON types. This code is currently only used to render the plan in human-readable UI, so does not yet support JSON.

type ShowHuman

type ShowHuman struct {
	View
}

func (*ShowHuman) Plan

func (v *ShowHuman) Plan(plan *plans.Plan, schemas *terraform.Schemas)

type StateLocker

type StateLocker interface {
	Locking()
	Unlocking()
}

The StateLocker view is used to display locking/unlocking status messages if the state lock process takes longer than expected.

func NewStateLocker

func NewStateLocker(vt arguments.ViewType, view *View) StateLocker

NewStateLocker returns an initialized StateLocker implementation for the given ViewType.

type StateLockerHuman

type StateLockerHuman struct {
	// contains filtered or unexported fields
}

StateLockerHuman is an implementation of StateLocker which prints status to a terminal.

func (*StateLockerHuman) Locking

func (v *StateLockerHuman) Locking()

func (*StateLockerHuman) Unlocking

func (v *StateLockerHuman) Unlocking()

type Test

type Test interface {
	// Results presents the given test results.
	Results(map[string]*moduletest.Suite) tfdiags.Diagnostics

	// Diagnostics is for reporting warnings or errors that occurred with the
	// mechanics of running tests. For this command in particular, some
	// errors are considered to be test failures rather than mechanism failures,
	// and so those will be reported via Results rather than via Diagnostics.
	Diagnostics(tfdiags.Diagnostics)
}

Test is the view interface for the "terraform test" command.

func NewTest

func NewTest(base *View, args arguments.TestOutput) Test

NewTest returns an implementation of Test configured to respect the settings described in the given arguments.

type UiHook

type UiHook struct {
	terraform.NilHook
	// contains filtered or unexported fields
}

func NewUiHook

func NewUiHook(view *View) *UiHook

func (*UiHook) PostApply

func (h *UiHook) PostApply(addr addrs.AbsResourceInstance, gen states.Generation, newState cty.Value, applyerr error) (terraform.HookAction, error)

func (*UiHook) PostImportState

func (h *UiHook) PostImportState(addr addrs.AbsResourceInstance, imported []providers.ImportedResource) (terraform.HookAction, error)

func (*UiHook) PreApply

func (h *UiHook) PreApply(addr addrs.AbsResourceInstance, gen states.Generation, action plans.Action, priorState, plannedNewState cty.Value) (terraform.HookAction, error)

func (*UiHook) PreImportState

func (h *UiHook) PreImportState(addr addrs.AbsResourceInstance, importID string) (terraform.HookAction, error)

func (*UiHook) PreProvisionInstanceStep

func (h *UiHook) PreProvisionInstanceStep(addr addrs.AbsResourceInstance, typeName string) (terraform.HookAction, error)

func (*UiHook) PreRefresh

func (h *UiHook) PreRefresh(addr addrs.AbsResourceInstance, gen states.Generation, priorState cty.Value) (terraform.HookAction, error)

func (*UiHook) ProvisionOutput

func (h *UiHook) ProvisionOutput(addr addrs.AbsResourceInstance, typeName string, msg string)

type Validate

type Validate interface {
	// Results renders the diagnostics returned from a validation walk, and
	// returns a CLI exit code: 0 if there are no errors, 1 otherwise
	Results(diags tfdiags.Diagnostics) int

	// Diagnostics renders early diagnostics, resulting from argument parsing.
	Diagnostics(diags tfdiags.Diagnostics)
}

The Validate is used for the validate command.

func NewValidate

func NewValidate(vt arguments.ViewType, view *View) Validate

NewValidate returns an initialized Validate implementation for the given ViewType.

type ValidateHuman

type ValidateHuman struct {
	// contains filtered or unexported fields
}

The ValidateHuman implementation renders diagnostics in a human-readable form, along with a success/failure message if Terraform is able to execute the validation walk.

func (*ValidateHuman) Diagnostics

func (v *ValidateHuman) Diagnostics(diags tfdiags.Diagnostics)

func (*ValidateHuman) Results

func (v *ValidateHuman) Results(diags tfdiags.Diagnostics) int

type ValidateJSON

type ValidateJSON struct {
	// contains filtered or unexported fields
}

The ValidateJSON implementation renders validation results as a JSON object. This object includes top-level fields summarizing the result, and an array of JSON diagnostic objects.

func (*ValidateJSON) Diagnostics

func (v *ValidateJSON) Diagnostics(diags tfdiags.Diagnostics)

Diagnostics should only be called if the validation walk cannot be executed. In this case, we choose to render human-readable diagnostic output, primarily for backwards compatibility.

func (*ValidateJSON) Results

func (v *ValidateJSON) Results(diags tfdiags.Diagnostics) int

type View

type View struct {
	// contains filtered or unexported fields
}

View is the base layer for command views, encapsulating a set of I/O streams, a colorize implementation, and implementing a human friendly view for diagnostics.

func NewView

func NewView(streams *terminal.Streams) *View

Initialize a View with the given streams, a disabled colorize object, and a no-op configSources callback.

func (*View) Configure

func (v *View) Configure(view *arguments.View)

Configure applies the global view configuration flags.

func (*View) Diagnostics

func (v *View) Diagnostics(diags tfdiags.Diagnostics)

Diagnostics renders a set of warnings and errors in human-readable form. Warnings are printed to stdout, and errors to stderr.

func (*View) HelpPrompt

func (v *View) HelpPrompt(command string)

HelpPrompt is intended to be called from commands which fail to parse all of their CLI arguments successfully. It refers users to the full help output rather than rendering it directly, which can be overwhelming and confusing.

func (*View) RunningInAutomation

func (v *View) RunningInAutomation() bool

func (*View) SetConfigSources

func (v *View) SetConfigSources(cb func() map[string][]byte)

SetConfigSources overrides the default no-op callback with a new function pointer, and should be called when the config loader is initialized.

func (*View) SetRunningInAutomation

func (v *View) SetRunningInAutomation(new bool) *View

SetRunningInAutomation modifies the view's "running in automation" flag, which causes some slight adjustments to certain messages that would normally suggest specific Terraform commands to run, to make more conceptual gestures instead for situations where the user isn't running Terraform directly.

For convenient use during initialization (in conjunction with NewView), SetRunningInAutomation returns the reciever after modifying it.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL