cli: output errors when monitoring deployment (#17348)

This commit is contained in:
Luiz Aoqui 2023-05-30 11:12:12 -04:00 committed by GitHub
parent e236d6dedd
commit 6236cb8f82
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 6 deletions

3
.changelog/17348.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:bug
cli: Output error messages during deployment monitoring
```

View File

@ -255,7 +255,7 @@ UPDATE:
deploy, meta, err = client.Deployments().Info(deployID, &q) deploy, meta, err = client.Deployments().Info(deployID, &q)
if err != nil { if err != nil {
d.Append(glint.Layout(glint.Style( d.Append(glint.Layout(glint.Style(
glint.Text(fmt.Sprintf("%s: Error fetching deployment", formatTime(time.Now()))), glint.Text(fmt.Sprintf("%s: Error fetching deployment: %v", formatTime(time.Now()), err)),
glint.Color("red"), glint.Color("red"),
)).MarginLeft(4), glint.Text("")) )).MarginLeft(4), glint.Text(""))
d.RenderFrame() d.RenderFrame()
@ -281,7 +281,7 @@ UPDATE:
allocComponent = glint.Layout( allocComponent = glint.Layout(
allocComponent, allocComponent,
glint.Style( glint.Style(
glint.Text("Error fetching allocations"), glint.Text(fmt.Sprintf("Error fetching allocations: %v", err)),
glint.Color("red"), glint.Color("red"),
), ),
) )
@ -324,7 +324,7 @@ UPDATE:
if err != nil { if err != nil {
d.Append(glint.Layout(glint.Style( d.Append(glint.Layout(glint.Style(
glint.Text(fmt.Sprintf("%s: Error fetching rollback deployment", formatTime(time.Now()))), glint.Text(fmt.Sprintf("%s: Error fetching rollback deployment: %v", formatTime(time.Now()), err)),
glint.Color("red"), glint.Color("red"),
)).MarginLeft(4), glint.Text("")) )).MarginLeft(4), glint.Text(""))
d.RenderFrame() d.RenderFrame()
@ -393,7 +393,7 @@ func (c *DeploymentStatusCommand) defaultMonitor(client *api.Client, deployID st
var meta *api.QueryMeta var meta *api.QueryMeta
deploy, meta, err = client.Deployments().Info(deployID, &q) deploy, meta, err = client.Deployments().Info(deployID, &q)
if err != nil { if err != nil {
c.Ui.Error(c.Colorize().Color(fmt.Sprintf("%s: Error fetching deployment", formatTime(time.Now())))) c.Ui.Error(c.Colorize().Color(fmt.Sprintf("%s: Error fetching deployment: %v", formatTime(time.Now()), err)))
return return
} }
@ -405,7 +405,7 @@ func (c *DeploymentStatusCommand) defaultMonitor(client *api.Client, deployID st
info += "\n\n[bold]Allocations[reset]\n" info += "\n\n[bold]Allocations[reset]\n"
allocs, _, err := client.Deployments().Allocations(deployID, nil) allocs, _, err := client.Deployments().Allocations(deployID, nil)
if err != nil { if err != nil {
info += "Error fetching allocations" info += fmt.Sprintf("Error fetching allocations: %v", err)
} else { } else {
info += formatAllocListStubs(allocs, verbose, length) info += formatAllocListStubs(allocs, verbose, length)
} }
@ -435,7 +435,7 @@ func (c *DeploymentStatusCommand) defaultMonitor(client *api.Client, deployID st
c.Ui.Output("") c.Ui.Output("")
if err != nil { if err != nil {
c.Ui.Error(c.Colorize().Color( c.Ui.Error(c.Colorize().Color(
fmt.Sprintf("%s: Error fetching deployment of previous job version", formatTime(time.Now())), fmt.Sprintf("%s: Error fetching deployment of previous job version: %v", formatTime(time.Now()), err),
)) ))
return return
} }