refactor: rename attach config var

This var for the incoming attach request.
Just within this one function we also have `cfg`, and `ctr` already, so
`c` just makes things more confusing.
Not to mention `c` is usually referencing a container object in other
parts of the code.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
This commit is contained in:
Brian Goff 2024-03-25 23:03:47 +00:00
parent 39fce09bd4
commit 59e015fd0e

View file

@ -18,13 +18,13 @@ import (
)
// ContainerAttach attaches to logs according to the config passed in. See ContainerAttachConfig.
func (daemon *Daemon) ContainerAttach(prefixOrName string, c *backend.ContainerAttachConfig) error {
func (daemon *Daemon) ContainerAttach(prefixOrName string, req *backend.ContainerAttachConfig) error {
keys := []byte{}
var err error
if c.DetachKeys != "" {
keys, err = term.ToBytes(c.DetachKeys)
if req.DetachKeys != "" {
keys, err = term.ToBytes(req.DetachKeys)
if err != nil {
return errdefs.InvalidParameter(errors.Errorf("Invalid detach keys (%s) provided", c.DetachKeys))
return errdefs.InvalidParameter(errors.Errorf("Invalid detach keys (%s) provided", req.DetachKeys))
}
}
@ -42,16 +42,16 @@ func (daemon *Daemon) ContainerAttach(prefixOrName string, c *backend.ContainerA
}
cfg := stream.AttachConfig{
UseStdin: c.UseStdin,
UseStdout: c.UseStdout,
UseStderr: c.UseStderr,
UseStdin: req.UseStdin,
UseStdout: req.UseStdout,
UseStderr: req.UseStderr,
TTY: ctr.Config.Tty,
CloseStdin: ctr.Config.StdinOnce,
DetachKeys: keys,
}
ctr.StreamConfig.AttachStreams(&cfg)
multiplexed := !ctr.Config.Tty && c.MuxStreams
multiplexed := !ctr.Config.Tty && req.MuxStreams
clientCtx, closeNotify := context.WithCancel(context.Background())
defer closeNotify()
@ -68,7 +68,7 @@ func (daemon *Daemon) ContainerAttach(prefixOrName string, c *backend.ContainerA
}
}()
inStream, outStream, errStream, err := c.GetStreams(multiplexed, closeNotify)
inStream, outStream, errStream, err := req.GetStreams(multiplexed, closeNotify)
if err != nil {
return err
}
@ -90,7 +90,7 @@ func (daemon *Daemon) ContainerAttach(prefixOrName string, c *backend.ContainerA
cfg.Stderr = errStream
}
if err := daemon.containerAttach(ctr, &cfg, c.Logs, c.Stream); err != nil {
if err := daemon.containerAttach(ctr, &cfg, req.Logs, req.Stream); err != nil {
fmt.Fprintf(outStream, "Error attaching: %s\n", err)
}
return nil