Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pagination fix #2

Merged
merged 2 commits into from
Dec 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions cmd/aws/awsutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ func DescribeClusters() ([]*ecs.Cluster, error) {
include := "STATISTICS"

err := client.ListClustersPagesWithContext(context.Background(), &ecs.ListClustersInput{}, func(output *ecs.ListClustersOutput, b bool) bool {
if len(output.ClusterArns) == 0 {
return false
}
clusterDetails, err := client.DescribeClusters(&ecs.DescribeClustersInput{
Clusters: output.ClusterArns,
Include: []*string{&include},
Expand Down Expand Up @@ -58,6 +61,9 @@ func DescribeClusterServices(c *ecs.Cluster) ([]*ecs.Service, error) {
var services []*ecs.Service

err := client.ListServicesPagesWithContext(context.Background(), &ecs.ListServicesInput{Cluster: c.ClusterArn}, func(output *ecs.ListServicesOutput, b bool) bool {
if len(output.ServiceArns) == 0 {
return false
}
serviceDetails, err := client.DescribeServices(&ecs.DescribeServicesInput{
Cluster: c.ClusterArn,
Services: output.ServiceArns,
Expand Down Expand Up @@ -87,6 +93,9 @@ func DescribeClusterTasks(c *ecs.Cluster) ([]*ecs.Task, error) {
var tasks []*ecs.Task

err := client.ListTasksPagesWithContext(context.Background(), &ecs.ListTasksInput{Cluster: c.ClusterArn}, func(output *ecs.ListTasksOutput, b bool) bool {
if len(output.TaskArns) == 0 {
return false
}
taskDetails, err := client.DescribeTasks(&ecs.DescribeTasksInput{
Cluster: c.ClusterArn,
Tasks: output.TaskArns,
Expand Down Expand Up @@ -142,6 +151,9 @@ func DescribeContainerInstances(c *ecs.Cluster) ([]*ecs.ContainerInstance, error
var containerInstances []*ecs.ContainerInstance

err := client.ListContainerInstancesPagesWithContext(context.Background(), &ecs.ListContainerInstancesInput{Cluster: c.ClusterArn}, func(output *ecs.ListContainerInstancesOutput, b bool) bool {
if len(output.ContainerInstanceArns) == 0 {
return false
}
containerDetails, err := client.DescribeContainerInstances(&ecs.DescribeContainerInstancesInput{
Cluster: c.ClusterArn,
ContainerInstances: output.ContainerInstanceArns,
Expand Down
9 changes: 6 additions & 3 deletions cmd/utils/stringutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,12 @@ func BuildAsciiMeterCurrentTotal(portion int64, total int64, width int) string {
const fullChar = "█"
const emptyChar = "▒"

ratio := float64(portion) / float64(total)
ratio = math.Max(0, math.Min(1.0, ratio))
full := int(math.Round(ratio * float64(width)))
full := 0
if total > 0 {
ratio := float64(portion) / float64(total)
ratio = math.Max(0, math.Min(1.0, ratio))
full = int(math.Round(ratio * float64(width)))
}

return strings.Join([]string{
strings.Repeat(fullChar, full),
Expand Down