Skip to content
This repository has been archived by the owner on Mar 16, 2024. It is now read-only.

Commit

Permalink
Fix broken exec --containers arg
Browse files Browse the repository at this point in the history
Signed-off-by: Darren Shepherd <darren@acorn.io>
  • Loading branch information
ibuildthecloud committed Oct 12, 2022
1 parent 561f273 commit c84cf94
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pkg/cli/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,18 @@ func (s *Exec) appAndArgs(ctx context.Context, c hclient.Client, args []string)
return appName, nil, err
}

func (s *Exec) filterContainers(containers []apiv1.ContainerReplica) (result []apiv1.ContainerReplica) {
for _, c := range containers {
if s.Container == "" {
result = append(result, c)
} else if c.Spec.ContainerName == s.Container {
result = append(result, c)
break
}
}
return result
}

func (s *Exec) execApp(ctx context.Context, c hclient.Client, app *apiv1.App, args []string) error {
containers, err := c.ContainerReplicaList(ctx, &hclient.ContainerReplicaListOptions{
App: app.Name,
Expand All @@ -83,6 +95,8 @@ func (s *Exec) execApp(ctx context.Context, c hclient.Client, app *apiv1.App, ar
names = map[string]string{}
)

containers = s.filterContainers(containers)

for _, container := range containers {
displayName := fmt.Sprintf("%s (%s %s)", container.Name, container.Status.Columns.State, table.FormatCreated(container.CreationTimestamp))
displayNames = append(displayNames, displayName)
Expand Down

0 comments on commit c84cf94

Please sign in to comment.