Skip to content

Commit

Permalink
Merge pull request #3 from swartzrock/nil-checks
Browse files Browse the repository at this point in the history
apparently ContainerInstanceArn is an optional value for ECS tasks
  • Loading branch information
swartzrock authored Dec 15, 2020
2 parents 067d744 + 992a0fb commit 1091670
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cmd/pages/instancespage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}
Expand Down
7 changes: 5 additions & 2 deletions cmd/pages/taskspage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
Expand Down

0 comments on commit 1091670

Please sign in to comment.