summaryrefslogtreecommitdiff
path: root/pkg/domain/infra/tunnel/containers.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/domain/infra/tunnel/containers.go')
-rw-r--r--pkg/domain/infra/tunnel/containers.go25
1 files changed, 24 insertions, 1 deletions
diff --git a/pkg/domain/infra/tunnel/containers.go b/pkg/domain/infra/tunnel/containers.go
index aa26825e0..3830835cc 100644
--- a/pkg/domain/infra/tunnel/containers.go
+++ b/pkg/domain/infra/tunnel/containers.go
@@ -506,7 +506,30 @@ func startAndAttach(ic *ContainerEngine, name string, detachKeys *string, input,
func (ic *ContainerEngine) ContainerStart(ctx context.Context, namesOrIds []string, options entities.ContainerStartOptions) ([]*entities.ContainerStartReport, error) {
reports := []*entities.ContainerStartReport{}
var exitCode = define.ExecErrorCodeGeneric
- ctrs, err := getContainersByContext(ic.ClientCtx, options.All, false, namesOrIds)
+ containersNamesOrIds := namesOrIds
+ if len(options.Filters) > 0 {
+ containersNamesOrIds = []string{}
+ opts := new(containers.ListOptions).WithFilters(options.Filters).WithAll(true)
+ candidates, listErr := containers.List(ic.ClientCtx, opts)
+ if listErr != nil {
+ return nil, listErr
+ }
+ for _, candidate := range candidates {
+ for _, nameOrID := range namesOrIds {
+ if nameOrID == candidate.ID {
+ containersNamesOrIds = append(containersNamesOrIds, nameOrID)
+ continue
+ }
+ for _, containerName := range candidate.Names {
+ if containerName == nameOrID {
+ containersNamesOrIds = append(containersNamesOrIds, nameOrID)
+ continue
+ }
+ }
+ }
+ }
+ }
+ ctrs, err := getContainersByContext(ic.ClientCtx, options.All, false, containersNamesOrIds)
if err != nil {
return nil, err
}