github.com/graywolf-at-work-2/terraform-vendor@v1.4.5/internal/command/jsonformat/computed/renderers/sensitive_block.go (about) 1 package renderers 2 3 import ( 4 "fmt" 5 6 "github.com/hashicorp/terraform/internal/command/jsonformat/computed" 7 "github.com/hashicorp/terraform/internal/plans" 8 ) 9 10 func SensitiveBlock(diff computed.Diff, beforeSensitive, afterSensitive bool) computed.DiffRenderer { 11 return &sensitiveBlockRenderer{ 12 inner: diff, 13 beforeSensitive: beforeSensitive, 14 afterSensitive: afterSensitive, 15 } 16 } 17 18 type sensitiveBlockRenderer struct { 19 inner computed.Diff 20 21 afterSensitive bool 22 beforeSensitive bool 23 } 24 25 func (renderer sensitiveBlockRenderer) RenderHuman(diff computed.Diff, indent int, opts computed.RenderHumanOpts) string { 26 cachedLinePrefix := fmt.Sprintf("%s%s", formatIndent(indent), writeDiffActionSymbol(plans.NoOp, opts)) 27 return fmt.Sprintf("{%s\n%s # At least one attribute in this block is (or was) sensitive,\n%s # so its contents will not be displayed.\n%s}", 28 forcesReplacement(diff.Replace, opts), cachedLinePrefix, cachedLinePrefix, cachedLinePrefix) 29 } 30 31 func (renderer sensitiveBlockRenderer) WarningsHuman(diff computed.Diff, indent int, opts computed.RenderHumanOpts) []string { 32 if (renderer.beforeSensitive == renderer.afterSensitive) || renderer.inner.Action == plans.Create || renderer.inner.Action == plans.Delete { 33 // Only display warnings for sensitive values if they are changing from 34 // being sensitive or to being sensitive and if they are not being 35 // destroyed or created. 36 return []string{} 37 } 38 39 if renderer.beforeSensitive { 40 return []string{opts.Colorize.Color(fmt.Sprintf(" # [yellow]Warning[reset]: this block will no longer be marked as sensitive\n%s # after applying this change.", formatIndent(indent)))} 41 } else { 42 return []string{opts.Colorize.Color(fmt.Sprintf(" # [yellow]Warning[reset]: this block will be marked as sensitive and will not\n%s # display in UI output after applying this change.", formatIndent(indent)))} 43 } 44 }