@@ -16,7 +16,7 @@ import (
1616
1717// The Apply view is used for the apply command.
1818type Apply interface {
19- ResourceCount (stateOutPath string )
19+ ResourceCount (stateOutPath string , errored bool )
2020 Outputs (outputValues map [string ]* states.OutputValue )
2121
2222 Operation () Operation
@@ -60,25 +60,33 @@ type ApplyHuman struct {
6060
6161var _ Apply = (* ApplyHuman )(nil )
6262
63- func (v * ApplyHuman ) ResourceCount (stateOutPath string ) {
63+ func (v * ApplyHuman ) ResourceCount (stateOutPath string , errored bool ) {
6464 var summary string
65+ summaryColor := "[reset][bold][green]"
66+ completionString := "complete"
67+ if errored {
68+ summaryColor = "[reset][bold][red]"
69+ completionString = "incomplete with errors"
70+ }
6571 if v .destroy {
66- summary = fmt .Sprintf ("Destroy complete ! Resources: %d destroyed." , v .countHook .Removed )
72+ summary = fmt .Sprintf ("Destroy %s ! Resources: %d destroyed." , completionString , v .countHook .Removed )
6773 } else if v .countHook .Imported > 0 {
68- summary = fmt .Sprintf ("Apply complete! Resources: %d imported, %d added, %d changed, %d destroyed." ,
74+ summary = fmt .Sprintf ("Apply %s! Resources: %d imported, %d added, %d changed, %d destroyed." ,
75+ completionString ,
6976 v .countHook .Imported ,
7077 v .countHook .Added ,
7178 v .countHook .Changed ,
7279 v .countHook .Removed )
7380 } else {
74- summary = fmt .Sprintf ("Apply complete! Resources: %d added, %d changed, %d destroyed." ,
81+ summary = fmt .Sprintf ("Apply %s! Resources: %d added, %d changed, %d destroyed." ,
82+ completionString ,
7583 v .countHook .Added ,
7684 v .countHook .Changed ,
7785 v .countHook .Removed )
7886 }
79- v .view .streams .Print (v .view .colorize .Color ("[reset][bold][green] \n " + summary ))
87+ v .view .streams .Print (v .view .colorize .Color (summaryColor + " \n " + summary ))
8088 if v .countHook .ActionInvocation > 0 {
81- v .view .streams .Print (v .view .colorize .Color (fmt .Sprintf ("[reset][bold][green] Actions: %d invoked." , v .countHook .ActionInvocation )))
89+ v .view .streams .Print (v .view .colorize .Color (fmt .Sprintf ("%s Actions: %d invoked." , summaryColor , v .countHook .ActionInvocation )))
8290 }
8391 v .view .streams .Print ("\n " )
8492 if (v .countHook .Added > 0 || v .countHook .Changed > 0 ) && stateOutPath != "" {
@@ -131,7 +139,7 @@ type ApplyJSON struct {
131139
132140var _ Apply = (* ApplyJSON )(nil )
133141
134- func (v * ApplyJSON ) ResourceCount (stateOutPath string ) {
142+ func (v * ApplyJSON ) ResourceCount (stateOutPath string , errored bool ) {
135143 operation := json .OperationApplied
136144 if v .destroy {
137145 operation = json .OperationDestroyed
@@ -143,6 +151,7 @@ func (v *ApplyJSON) ResourceCount(stateOutPath string) {
143151 Import : v .countHook .Imported ,
144152 ActionInvocation : v .countHook .ActionInvocation ,
145153 Operation : operation ,
154+ Errored : errored ,
146155 })
147156}
148157
0 commit comments