command/format: concise diff is now the default (#27079)

* command/format: concise diff is no longer an experiment

Since state formatting goes through the "diff" printer, I have
repurposed the concise flag as a verbose flag, used only when printing
state. It's silly but it works!

* remove helper/experiment
With this experiment concluded, we no longer need helper/experiment. The
shadow experiment had not been touched in many years, so I removed all
references, and removed the package entirely. Any new experiments are
expected to be configuration experiments handled by our (other)
experiments package.

* check for the verbose flag consistently, in case we end up using it in plans in the future
This commit is contained in:
Kristin Laemmert
2020-12-02 15:42:41 -05:00
committed by GitHub
parent b2d0e20759
commit 3fa063b8dc
8 changed files with 15 additions and 791 deletions

View File

@@ -14,7 +14,6 @@ import (
"github.com/hashicorp/terraform/addrs"
"github.com/hashicorp/terraform/configs/configschema"
"github.com/hashicorp/terraform/helper/experiment"
"github.com/hashicorp/terraform/plans"
"github.com/hashicorp/terraform/plans/objchange"
"github.com/hashicorp/terraform/states"
@@ -99,7 +98,6 @@ func ResourceChange(
color: color,
action: change.Action,
requiredReplace: change.RequiredReplace,
concise: experiment.Enabled(experiment.X_concise_diff),
}
// Most commonly-used resources have nested blocks that result in us
@@ -154,10 +152,9 @@ func OutputChanges(
) string {
var buf bytes.Buffer
p := blockBodyDiffPrinter{
buf: &buf,
color: color,
action: plans.Update, // not actually used in this case, because we're not printing a containing block
concise: experiment.Enabled(experiment.X_concise_diff),
buf: &buf,
color: color,
action: plans.Update, // not actually used in this case, because we're not printing a containing block
}
// We're going to reuse the codepath we used for printing resource block
@@ -200,7 +197,8 @@ type blockBodyDiffPrinter struct {
color *colorstring.Colorize
action plans.Action
requiredReplace cty.PathSet
concise bool
// verbose is set to true when using the "diff" printer to format state
verbose bool
}
type blockBodyDiffResult struct {
@@ -326,7 +324,7 @@ func (p *blockBodyDiffPrinter) writeAttrDiff(name string, attrS *configschema.At
path = append(path, cty.GetAttrStep{Name: name})
action, showJustNew := getPlanActionAndShow(old, new)
if action == plans.NoOp && p.concise && !identifyingAttribute(name, attrS) {
if action == plans.NoOp && !p.verbose && !identifyingAttribute(name, attrS) {
return true
}
@@ -624,7 +622,7 @@ func (p *blockBodyDiffPrinter) writeSensitiveNestedBlockDiff(name string, old, n
}
func (p *blockBodyDiffPrinter) writeNestedBlockDiff(name string, label *string, blockS *configschema.Block, action plans.Action, old, new cty.Value, indent int, path cty.Path) bool {
if action == plans.NoOp && p.concise {
if action == plans.NoOp && !p.verbose {
return true
}
@@ -984,7 +982,7 @@ func (p *blockBodyDiffPrinter) writeValueDiff(old, new cty.Value, indent int, pa
action = plans.NoOp
}
if action == plans.NoOp && p.concise {
if action == plans.NoOp && !p.verbose {
suppressedElements++
continue
}
@@ -1024,8 +1022,7 @@ func (p *blockBodyDiffPrinter) writeValueDiff(old, new cty.Value, indent int, pa
var changeShown bool
for i := 0; i < len(elemDiffs); i++ {
// In concise mode, push any no-op diff elements onto the stack
if p.concise {
if !p.verbose {
for i < len(elemDiffs) && elemDiffs[i].Action == plans.NoOp {
suppressedElements = append(suppressedElements, elemDiffs[i])
i++
@@ -1161,7 +1158,7 @@ func (p *blockBodyDiffPrinter) writeValueDiff(old, new cty.Value, indent int, pa
}
}
if action == plans.NoOp && p.concise {
if action == plans.NoOp && !p.verbose {
suppressedElements++
continue
}
@@ -1262,7 +1259,7 @@ func (p *blockBodyDiffPrinter) writeValueDiff(old, new cty.Value, indent int, pa
action = plans.Update
}
if action == plans.NoOp && p.concise {
if action == plans.NoOp && !p.verbose {
suppressedElements++
continue
}