MCPcopy
hub / github.com/nektos/act / attach

Method attach

pkg/container/docker_run.go:843–876  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

841}
842
843func (cr *containerReference) attach() common.Executor {
844 return func(ctx context.Context) error {
845 out, err := cr.cli.ContainerAttach(ctx, cr.id, client.ContainerAttachOptions{
846 Stream: true,
847 Stdout: true,
848 Stderr: true,
849 })
850 if err != nil {
851 return fmt.Errorf("failed to attach to container: %w", err)
852 }
853 isTerminal := term.IsTerminal(int(os.Stdout.Fd()))
854
855 var outWriter io.Writer
856 outWriter = cr.input.Stdout
857 if outWriter == nil {
858 outWriter = os.Stdout
859 }
860 errWriter := cr.input.Stderr
861 if errWriter == nil {
862 errWriter = os.Stderr
863 }
864 go func() {
865 if !isTerminal || os.Getenv("NORAW") != "" {
866 _, err = stdcopy.StdCopy(outWriter, errWriter, out.Reader)
867 } else {
868 _, err = io.Copy(outWriter, out.Reader)
869 }
870 if err != nil {
871 common.Logger(ctx).Error(err)
872 }
873 }()
874 return nil
875 }
876}
877
878func (cr *containerReference) start() common.Executor {
879 return func(ctx context.Context) error {

Callers 1

StartMethod · 0.95

Calls 4

LoggerFunction · 0.92
GetenvMethod · 0.65
CopyMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected