cli: createContainer() remove intermediate variable

Having the intermediate variable made it difficult to see if it was
possibly mutated and/or something special done with it, so just use
the cli's accessors to get its Err().

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2022-08-31 18:40:37 +02:00
parent 6205b4eae6
commit 67ae2c0976
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
1 changed files with 5 additions and 6 deletions

View File

@ -203,10 +203,9 @@ func createContainer(ctx context.Context, dockerCli command.Cli, containerConfig
config := containerConfig.Config
hostConfig := containerConfig.HostConfig
networkingConfig := containerConfig.NetworkingConfig
stderr := dockerCli.Err()
warnOnOomKillDisable(*hostConfig, stderr)
warnOnLocalhostDNS(*hostConfig, stderr)
warnOnOomKillDisable(*hostConfig, dockerCli.Err())
warnOnLocalhostDNS(*hostConfig, dockerCli.Err())
var (
trustedRef reference.Canonical
@ -237,7 +236,7 @@ func createContainer(ctx context.Context, dockerCli command.Cli, containerConfig
}
pullAndTagImage := func() error {
pullOut := stderr
pullOut := dockerCli.Err()
if opts.quiet {
pullOut = io.Discard
}
@ -277,7 +276,7 @@ func createContainer(ctx context.Context, dockerCli command.Cli, containerConfig
if apiclient.IsErrNotFound(err) && namedRef != nil && opts.pull == PullImageMissing {
if !opts.quiet {
// we don't want to write to stdout anything apart from container.ID
fmt.Fprintf(stderr, "Unable to find image '%s' locally\n", reference.FamiliarString(namedRef))
fmt.Fprintf(dockerCli.Err(), "Unable to find image '%s' locally\n", reference.FamiliarString(namedRef))
}
if err := pullAndTagImage(); err != nil {
@ -295,7 +294,7 @@ func createContainer(ctx context.Context, dockerCli command.Cli, containerConfig
}
for _, warning := range response.Warnings {
fmt.Fprintf(stderr, "WARNING: %s\n", warning)
fmt.Fprintf(dockerCli.Err(), "WARNING: %s\n", warning)
}
err = containerIDFile.Write(response.ID)
return &response, err