Skip to content

Commit

Permalink
log setup cf stack events
Browse files Browse the repository at this point in the history
  • Loading branch information
djelusic committed Nov 4, 2021
1 parent 76b0cef commit d774d65
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
5 changes: 1 addition & 4 deletions aws/cloudformation.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,7 @@ func (w *StackWaiter) event(e types.StackEvent) {
if w.isDone() {
return
}
if e.ResourceStatus == types.ResourceStatusCreateComplete ||
e.ResourceStatus == types.ResourceStatusDeleteComplete {
w.events <- e
}
w.events <- e
}

func (w *StackWaiter) pollEvents() {
Expand Down
12 changes: 11 additions & 1 deletion cli/controller/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ package controller

import (
_ "embed"
"encoding/json"
"fmt"
"strings"

"github.com/aws/aws-sdk-go-v2/service/cloudformation/types"
"github.com/mantil-io/mantil/aws"
"github.com/mantil-io/mantil/cli/backend"
"github.com/mantil-io/mantil/cli/log"
Expand Down Expand Up @@ -219,11 +221,13 @@ func runStackProgress(prefix string, stackWaiter *aws.StackWaiter) {
}

func (p *stackProgress) run() {
log.Printf(p.prefix)
fmt.Println()
p.dotsProgress.Run()
p.handleStackEvents()
p.dotsProgress.Stop()
fmt.Println()
log.Printf("%s: done", p.prefix)
}

func (p *stackProgress) line() string {
Expand All @@ -238,7 +242,13 @@ func (p *stackProgress) line() string {
}

func (p *stackProgress) handleStackEvents() {
for range p.stackWaiter.Events() {
for e := range p.stackWaiter.Events() {
ebuf, _ := json.Marshal(e)
log.Printf("%s event: %s", p.prefix, string(ebuf))
if e.ResourceStatus != types.ResourceStatusCreateComplete &&
e.ResourceStatus != types.ResourceStatusDeleteComplete {
continue
}
if p.currentCnt < stackResourceCount {
p.currentCnt++
p.lines <- p.line()
Expand Down

0 comments on commit d774d65

Please sign in to comment.