github.com/graywolf-at-work-2/terraform-vendor@v1.4.5/internal/command/views/json/change_summary.go (about) 1 package json 2 3 import "fmt" 4 5 type Operation string 6 7 const ( 8 OperationApplied Operation = "apply" 9 OperationDestroyed Operation = "destroy" 10 OperationPlanned Operation = "plan" 11 ) 12 13 type ChangeSummary struct { 14 Add int `json:"add"` 15 Change int `json:"change"` 16 Remove int `json:"remove"` 17 Operation Operation `json:"operation"` 18 } 19 20 // The summary strings for apply and plan are accidentally a public interface 21 // used by Terraform Cloud and Terraform Enterprise, so the exact formats of 22 // these strings are important. 23 func (cs *ChangeSummary) String() string { 24 switch cs.Operation { 25 case OperationApplied: 26 return fmt.Sprintf("Apply complete! Resources: %d added, %d changed, %d destroyed.", cs.Add, cs.Change, cs.Remove) 27 case OperationDestroyed: 28 return fmt.Sprintf("Destroy complete! Resources: %d destroyed.", cs.Remove) 29 case OperationPlanned: 30 return fmt.Sprintf("Plan: %d to add, %d to change, %d to destroy.", cs.Add, cs.Change, cs.Remove) 31 default: 32 return fmt.Sprintf("%s: %d add, %d change, %d destroy", cs.Operation, cs.Add, cs.Change, cs.Remove) 33 } 34 }