github.com/hugorut/terraform@v1.1.3/src/command/views/show.go (about) 1 package views 2 3 import ( 4 "fmt" 5 6 "github.com/hugorut/terraform/src/command/arguments" 7 "github.com/hugorut/terraform/src/plans" 8 "github.com/hugorut/terraform/src/terraform" 9 ) 10 11 // FIXME: this is a temporary partial definition of the view for the show 12 // command, in place to allow access to the plan renderer which is now in the 13 // views package. 14 type Show interface { 15 Plan(plan *plans.Plan, schemas *terraform.Schemas) 16 } 17 18 // FIXME: the show view should support both human and JSON types. This code is 19 // currently only used to render the plan in human-readable UI, so does not yet 20 // support JSON. 21 func NewShow(vt arguments.ViewType, view *View) Show { 22 switch vt { 23 case arguments.ViewHuman: 24 return &ShowHuman{View: *view} 25 default: 26 panic(fmt.Sprintf("unknown view type %v", vt)) 27 } 28 } 29 30 type ShowHuman struct { 31 View 32 } 33 34 var _ Show = (*ShowHuman)(nil) 35 36 func (v *ShowHuman) Plan(plan *plans.Plan, schemas *terraform.Schemas) { 37 renderPlan(plan, schemas, &v.View) 38 }