From 992a0fb6b299b680c2285676447badf68adee772 Mon Sep 17 00:00:00 2001 From: Jason Swartz Date: Tue, 15 Dec 2020 14:13:04 -0800 Subject: [PATCH] apparently ContainerInstanceArn is an optional value for ECS tasks, handling nil's now. --- cmd/pages/instancespage.go | 2 +- cmd/pages/taskspage.go | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/cmd/pages/instancespage.go b/cmd/pages/instancespage.go index 1e455b6..b2f47f8 100644 --- a/cmd/pages/instancespage.go +++ b/cmd/pages/instancespage.go @@ -99,7 +99,7 @@ func renderInstancesTable(tableInfo *ui.TableInfo, ecsData *ecsview.ClusterData) if taskCount != "0" { tasks := make([]string, 0) for _, task := range ecsData.Tasks { - if *task.ContainerInstanceArn == *instance.ContainerInstanceArn { + if task.ContainerInstanceArn != nil && *task.ContainerInstanceArn == *instance.ContainerInstanceArn { tasks = append(tasks, aws.ShortenTaskDefArn(task.TaskDefinitionArn)) } } diff --git a/cmd/pages/taskspage.go b/cmd/pages/taskspage.go index 33b6ad7..c563407 100644 --- a/cmd/pages/taskspage.go +++ b/cmd/pages/taskspage.go @@ -81,14 +81,17 @@ func renderTasksPage(tableInfo *ui.TableInfo, ecsData *ecsview.ClusterData) { taskImages = strings.Join(images, ",") } - // utils.TakeRight + ec2InstanceId := "n/a" + if task.ContainerInstanceArn != nil { + ec2InstanceId = arnToEc2InstanceIdMap[*task.ContainerInstanceArn] + } return []string{ aws.ShortenTaskDefArn(task.TaskDefinitionArn), taskImages, status, utils.FormatLocalDateTimeAmPmZone(*task.CreatedAt), - arnToEc2InstanceIdMap[*task.ContainerInstanceArn], + ec2InstanceId, utils.TakeRight(utils.RemoveAllRegex(`.*/`, *task.TaskArn), 8), utils.I64ToString(*task.Version), }