@@ -28,9 +28,11 @@ const (
28
28
containerStateKey = "State"
29
29
containerPortsKey = "Ports"
30
30
taskDefinitionKey = "TaskDefinition"
31
+ healthKey = "Health"
31
32
)
32
33
33
- var ContainerInfoColumns = []string {containerNameKey , containerStateKey , containerPortsKey , taskDefinitionKey }
34
+ // ContainerInfoColumns is the ordered list of info columns for the ps commands
35
+ var ContainerInfoColumns = []string {containerNameKey , containerStateKey , containerPortsKey , taskDefinitionKey , healthKey }
34
36
35
37
// Container is a wrapper around ecsContainer
36
38
type Container struct {
@@ -59,8 +61,8 @@ func (c *Container) Id() string {
59
61
// ECS doesn't have a describe container API so providing the task's UUID in the name enables users
60
62
// to easily look up this container in the ecs world by invoking DescribeTask
61
63
func (c * Container ) Name () string {
62
- taskId := utils .GetIdFromArn (aws .StringValue (c .task .TaskArn ))
63
- return utils .GetFormattedContainerName (taskId , aws .StringValue (c .ecsContainer .Name ))
64
+ taskID := utils .GetIdFromArn (aws .StringValue (c .task .TaskArn ))
65
+ return utils .GetFormattedContainerName (taskID , aws .StringValue (c .ecsContainer .Name ))
64
66
}
65
67
66
68
// TaskDefinition returns the ECS task definition id which encompasses the container definition, with
@@ -112,6 +114,11 @@ func (c *Container) PortString() string {
112
114
return strings .Join (result , ", " )
113
115
}
114
116
117
+ // HealthStatus returns the container healthcheck status for the given container
118
+ func (c * Container ) HealthStatus () string {
119
+ return aws .StringValue (c .ecsContainer .HealthStatus )
120
+ }
121
+
115
122
// ConvertContainersToInfoSet transforms the list of containers into a formatted set of fields
116
123
func ConvertContainersToInfoSet (containers []Container ) project.InfoSet {
117
124
result := project.InfoSet {}
@@ -122,6 +129,7 @@ func ConvertContainersToInfoSet(containers []Container) project.InfoSet {
122
129
containerStateKey : cont .State (),
123
130
containerPortsKey : cont .PortString (),
124
131
taskDefinitionKey : cont .TaskDefinition (),
132
+ healthKey : cont .HealthStatus (),
125
133
}
126
134
result = append (result , info )
127
135
}
0 commit comments