mirror of
https://github.com/docker/compose.git
synced 2025-07-22 21:24:38 +02:00
pkg/compose: RunOneOffContainer: don't use NewStartOptions()
It's no longer used in docker/cli, and doesn't do anything other than creating an empty struct, so replacing it (as we're planning to deprecate that function) Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
150b88ab5d
commit
4eb43c53fa
@ -18,6 +18,7 @@ package compose
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
@ -36,11 +37,6 @@ func (s *composeService) RunOneOffContainer(ctx context.Context, project *types.
|
|||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
start := cmd.NewStartOptions()
|
|
||||||
start.OpenStdin = !opts.Detach && opts.Interactive
|
|
||||||
start.Attach = !opts.Detach
|
|
||||||
start.Containers = []string{containerID}
|
|
||||||
|
|
||||||
// remove cancellable context signal handler so we can forward signals to container without compose to exit
|
// remove cancellable context signal handler so we can forward signals to container without compose to exit
|
||||||
signal.Reset()
|
signal.Reset()
|
||||||
|
|
||||||
@ -49,9 +45,14 @@ func (s *composeService) RunOneOffContainer(ctx context.Context, project *types.
|
|||||||
go cmd.ForwardAllSignals(ctx, s.dockerCli, containerID, sigc)
|
go cmd.ForwardAllSignals(ctx, s.dockerCli, containerID, sigc)
|
||||||
defer signal.Stop(sigc)
|
defer signal.Stop(sigc)
|
||||||
|
|
||||||
err = cmd.RunStart(s.dockerCli, &start)
|
err = cmd.RunStart(s.dockerCli, &cmd.StartOptions{
|
||||||
if sterr, ok := err.(cli.StatusError); ok {
|
OpenStdin: !opts.Detach && opts.Interactive,
|
||||||
return sterr.StatusCode, nil
|
Attach: !opts.Detach,
|
||||||
|
Containers: []string{containerID},
|
||||||
|
})
|
||||||
|
var stErr cli.StatusError
|
||||||
|
if errors.As(err, &stErr) {
|
||||||
|
return stErr.StatusCode, nil
|
||||||
}
|
}
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user