feat: translation support
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
See #483
This commit is contained in:
@ -17,7 +17,6 @@ package commandconn
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
"os"
|
||||
@ -27,6 +26,7 @@ import (
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"coopcloud.tech/abra/pkg/i18n"
|
||||
"coopcloud.tech/abra/pkg/log"
|
||||
"github.com/pkg/errors"
|
||||
exec "golang.org/x/sys/execabs"
|
||||
@ -46,7 +46,7 @@ func New(ctx context.Context, cmd string, args ...string) (net.Conn, error) {
|
||||
)
|
||||
c.cmd = exec.CommandContext(ctx, cmd, args...)
|
||||
// we assume that args never contains sensitive information
|
||||
log.Debugf("commandconn: starting %s with %v", cmd, args)
|
||||
log.Debug(i18n.G("commandconn: starting %s with %v", cmd, args))
|
||||
c.cmd.Env = os.Environ()
|
||||
c.cmd.SysProcAttr = &syscall.SysProcAttr{}
|
||||
setPdeathsig(c.cmd)
|
||||
@ -62,7 +62,7 @@ func New(ctx context.Context, cmd string, args ...string) (net.Conn, error) {
|
||||
c.cmd.Stderr = &stderrWriter{
|
||||
stderrMu: &c.stderrMu,
|
||||
stderr: &c.stderr,
|
||||
debugPrefix: fmt.Sprintf("commandconn (%s):", cmd),
|
||||
debugPrefix: i18n.G("commandconn (%s):", cmd),
|
||||
}
|
||||
c.localAddr = dummyAddr{network: "dummy", s: "dummy-0"}
|
||||
c.remoteAddr = dummyAddr{network: "dummy", s: "dummy-1"}
|
||||
@ -138,7 +138,7 @@ func (c *commandConn) kill() error {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
return errors.Wrapf(werr, "commandconn: failed to wait")
|
||||
return errors.Wrap(werr, i18n.G("commandconn: failed to wait"))
|
||||
}
|
||||
|
||||
func (c *commandConn) onEOF(eof error) error {
|
||||
@ -159,7 +159,7 @@ func (c *commandConn) onEOF(eof error) error {
|
||||
c.stderrMu.Lock()
|
||||
stderr := c.stderr.String()
|
||||
c.stderrMu.Unlock()
|
||||
return errors.Errorf("command %v did not exit after %v: stderr=%q", c.cmd.Args, eof, stderr)
|
||||
return errors.New(i18n.G("command %v did not exit after %v: stderr=%q", c.cmd.Args, eof, stderr))
|
||||
}
|
||||
}
|
||||
c.cmdMutex.Unlock()
|
||||
@ -169,7 +169,7 @@ func (c *commandConn) onEOF(eof error) error {
|
||||
c.stderrMu.Lock()
|
||||
stderr := c.stderr.String()
|
||||
c.stderrMu.Unlock()
|
||||
return errors.Errorf("command %v has exited with %v, please make sure the URL is valid, and Docker 18.09 or later is installed on the remote host: stderr=%s", c.cmd.Args, werr, stderr)
|
||||
return errors.New(i18n.G("command %v has exited with %v, please make sure the URL is valid, and Docker 18.09 or later is installed on the remote host: stderr=%s", c.cmd.Args, werr, stderr))
|
||||
}
|
||||
|
||||
func ignorableCloseError(err error) bool {
|
||||
@ -236,7 +236,7 @@ func (c *commandConn) Write(p []byte) (int, error) {
|
||||
func (c *commandConn) Close() error {
|
||||
var err error
|
||||
if err = c.CloseRead(); err != nil {
|
||||
log.Warnf("commandConn.Close: CloseRead: %v", err)
|
||||
log.Warnf(i18n.G("commandConn.Close: CloseRead: %v", err))
|
||||
}
|
||||
if err = c.CloseWrite(); err != nil {
|
||||
// muted because https://github.com/docker/compose/issues/8544
|
||||
@ -252,15 +252,15 @@ func (c *commandConn) RemoteAddr() net.Addr {
|
||||
return c.remoteAddr
|
||||
}
|
||||
func (c *commandConn) SetDeadline(t time.Time) error {
|
||||
log.Debugf("unimplemented call: SetDeadline(%v)", t)
|
||||
log.Debug(i18n.G("unimplemented call: SetDeadline(%v)", t))
|
||||
return nil
|
||||
}
|
||||
func (c *commandConn) SetReadDeadline(t time.Time) error {
|
||||
log.Debugf("unimplemented call: SetReadDeadline(%v)", t)
|
||||
log.Debug(i18n.G("unimplemented call: SetReadDeadline(%v)", t))
|
||||
return nil
|
||||
}
|
||||
func (c *commandConn) SetWriteDeadline(t time.Time) error {
|
||||
log.Debugf("unimplemented call: SetWriteDeadline(%v)", t)
|
||||
log.Debug(i18n.G("unimplemented call: SetWriteDeadline(%v)", t))
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user