terraform/internal/command/format/format.go
kmoe a718f70f85
Add removed block (#34251)
* terraform: remove redundant code

NodeDestroyResourceInstance is never instantiated with a DeposedKey of anything other than states.NotDeposed, so the deleted code is never run. Deposed objects get a NodeDestroyDeposedResourceInstanceObject instead.

* tfdiags: add helper func

* configs: introduce removed block type

* terraform: add forget action

* renderer: render forget actions

* terraform: deposed objects can be forgotten

Deposed objects encountered during planning spawn
NodePlanDeposedResourceInstanceObject, which previously generated a
destroy change. Now it will generate a forget change if the deposed
object is a forget target, and a destroy change otherwise.

The apply graph gains a new node type,
NodeForgetDeposedResourceInstanceObject, whose execution simply removes
the object from the state.

* configs: add RemoveTarget address type

* terraform: modules can be forgotten

* terraform: error if removed obj still in config

* tests: better error on restore state fail

* Update CHANGELOG.md
2023-11-29 11:58:28 +00:00

42 lines
1.3 KiB
Go

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1
// Package format contains helpers for formatting various Terraform
// structures for human-readabout output.
//
// This package is used by the official Terraform CLI in formatting any
// output and is exported to encourage non-official frontends to mimic the
// output formatting as much as possible so that text formats of Terraform
// structures have a consistent look and feel.
package format
import "github.com/hashicorp/terraform/internal/plans"
// DiffActionSymbol returns a string that, once passed through a
// colorstring.Colorize, will produce a result that can be written
// to a terminal to produce a symbol made of three printable
// characters, possibly interspersed with VT100 color codes.
func DiffActionSymbol(action plans.Action) string {
switch action {
case plans.DeleteThenCreate:
return "[red]-[reset]/[green]+[reset]"
case plans.CreateThenDelete:
return "[green]+[reset]/[red]-[reset]"
case plans.Create:
return " [green]+[reset]"
case plans.Delete:
return " [red]-[reset]"
case plans.Forget:
return " [red].[reset]"
case plans.CreateThenForget:
return " [green]+[reset]/[red].[reset]"
case plans.Read:
return " [cyan]<=[reset]"
case plans.Update:
return " [yellow]~[reset]"
case plans.NoOp:
return " "
default:
return " ?"
}
}