exec, rollback: return error when no session found

Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
This commit is contained in:
Kohei Tokunaga 2023-10-13 10:14:04 +09:00
parent 508b2ef0c6
commit ded91da575
No known key found for this signature in database
GPG Key ID: 6CE0A04690DB3FB3
2 changed files with 7 additions and 0 deletions

View File

@ -35,6 +35,9 @@ COMMAND and ARG... will be executed in the container.
}
func (cm *ExecCmd) Exec(ctx context.Context, args []string) error {
if ref := cm.m.AttachedSessionID(); ref == "" {
return errors.Errorf("no attaching session")
}
if len(args) < 2 {
return errors.Errorf("command must be passed")
}

View File

@ -7,6 +7,7 @@ import (
controllerapi "github.com/docker/buildx/controller/pb"
"github.com/docker/buildx/monitor/types"
"github.com/pkg/errors"
)
type RollbackCmd struct {
@ -37,6 +38,9 @@ COMMAND and ARG... will be executed in the container.
}
func (cm *RollbackCmd) Exec(ctx context.Context, args []string) error {
if ref := cm.m.AttachedSessionID(); ref == "" {
return errors.Errorf("no attaching session")
}
cfg := cm.invokeConfig
if len(args) >= 2 {
cmds := args[1:]