github.com/graywolf-at-work-2/terraform-vendor@v1.4.5/internal/command/jsonformat/computed/renderers/json.go (about)

     1  package renderers
     2  
     3  import (
     4  	"github.com/zclconf/go-cty/cty"
     5  
     6  	"github.com/hashicorp/terraform/internal/command/jsonformat/computed"
     7  	"github.com/hashicorp/terraform/internal/command/jsonformat/jsondiff"
     8  	"github.com/hashicorp/terraform/internal/plans"
     9  )
    10  
    11  // RendererJsonOpts creates a jsondiff.JsonOpts object that returns the correct
    12  // embedded renderers for each JSON type.
    13  //
    14  // We need to define this in our renderers package in order to avoid cycles, and
    15  // to help with reuse between the output processing in the differs package, and
    16  // our JSON string rendering here.
    17  func RendererJsonOpts() jsondiff.JsonOpts {
    18  	return jsondiff.JsonOpts{
    19  		Primitive: func(before, after interface{}, ctype cty.Type, action plans.Action) computed.Diff {
    20  			return computed.NewDiff(Primitive(before, after, ctype), action, false)
    21  		},
    22  		Object: func(elements map[string]computed.Diff, action plans.Action) computed.Diff {
    23  			return computed.NewDiff(Object(elements), action, false)
    24  		},
    25  		Array: func(elements []computed.Diff, action plans.Action) computed.Diff {
    26  			return computed.NewDiff(List(elements), action, false)
    27  		},
    28  		TypeChange: func(before, after computed.Diff, action plans.Action) computed.Diff {
    29  			return computed.NewDiff(TypeChange(before, after), action, false)
    30  		},
    31  	}
    32  }