Merge pull request #818 from docker/ecs_event_status

Remove status truncate on wait
This commit is contained in:
Nicolas De loof 2020-10-20 16:57:53 +02:00 committed by GitHub
commit d5ed2bdecf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 12 deletions

View File

@ -74,8 +74,7 @@ func (b *ecsAPIService) WaitStackCompletion(ctx context.Context, name string, op
knownEvents[*event.EventId] = struct{}{}
resource := aws.StringValue(event.LogicalResourceId)
reason := shortenMessage(
aws.StringValue(event.ResourceStatusReason))
reason := aws.StringValue(event.ResourceStatusReason)
status := aws.StringValue(event.ResourceStatus)
progressStatus := progress.Working
@ -116,21 +115,13 @@ func (b *ecsAPIService) WaitStackCompletion(ctx context.Context, name string, op
}
stackErr = err
operation = stackDelete
reason := shortenMessage(err.Error())
w.Event(progress.Event{
ID: name,
Status: progress.Error,
StatusText: reason,
StatusText: err.Error(),
})
}
}
return stackErr
}
func shortenMessage(message string) string {
if len(message) < 30 {
return message
}
return message[:30] + "..."
}

View File

@ -146,12 +146,19 @@ func lineText(event Event, terminalWidth, statusPadding int, color bool) string
if padding < 0 {
padding = 0
}
// calculate the max length for the status text, on errors it
// is 2-3 lines long and breaks the line formating
maxStatusLen := terminalWidth - textLen - statusPadding - 15
status := event.StatusText
if len(status) > maxStatusLen {
status = status[:maxStatusLen] + "..."
}
text := fmt.Sprintf(" %s %s %s%s %s",
event.spinner.String(),
event.ID,
event.Text,
strings.Repeat(" ", padding),
event.StatusText,
status,
)
timer := fmt.Sprintf("%.1fs\n", elapsed)
o := align(text, timer, terminalWidth)