Skip to content

Commit 63bada4

Browse files
committed
pkg/system: deprecate EscapeArgs and move internal
Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 1d272a4 commit 63bada4

3 files changed

Lines changed: 23 additions & 4 deletions

File tree

daemon/internal/libcontainerd/local/local_windows.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import (
2424
"github.com/docker/docker/daemon/internal/libcontainerd/queue"
2525
libcontainerdtypes "github.com/docker/docker/daemon/internal/libcontainerd/types"
2626
"github.com/docker/docker/errdefs"
27-
"github.com/docker/docker/pkg/system"
2827
"github.com/opencontainers/runtime-spec/specs-go"
2928
"github.com/pkg/errors"
3029
"golang.org/x/sys/windows"
@@ -532,10 +531,19 @@ func setCommandLineAndArgs(process *specs.Process, createProcessParms *hcsshim.P
532531
if process.CommandLine != "" {
533532
createProcessParms.CommandLine = process.CommandLine
534533
} else {
535-
createProcessParms.CommandLine = system.EscapeArgs(process.Args)
534+
createProcessParms.CommandLine = escapeArgs(process.Args)
536535
}
537536
}
538537

538+
// escapeArgs makes a Windows-style escaped command line from a set of arguments
539+
func escapeArgs(args []string) string {
540+
escapedArgs := make([]string, len(args))
541+
for i, a := range args {
542+
escapedArgs[i] = windows.EscapeArg(a)
543+
}
544+
return strings.Join(escapedArgs, " ")
545+
}
546+
539547
func newIOFromProcess(newProcess hcsshim.Process, terminal bool) (*cio.DirectIO, error) {
540548
stdin, stdout, stderr, err := newProcess.Stdio()
541549
if err != nil {

daemon/oci_windows.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ import (
1919
"github.com/docker/docker/errdefs"
2020
"github.com/docker/docker/image"
2121
"github.com/docker/docker/oci"
22-
"github.com/docker/docker/pkg/system"
2322
"github.com/opencontainers/runtime-spec/specs-go"
2423
"github.com/pkg/errors"
24+
"golang.org/x/sys/windows"
2525
"golang.org/x/sys/windows/registry"
2626
)
2727

@@ -240,7 +240,7 @@ func (daemon *Daemon) createSpecWindowsFields(c *container.Container, s *specs.S
240240
if c.Config.ArgsEscaped {
241241
s.Process.CommandLine = c.Path
242242
if len(c.Args) > 0 {
243-
s.Process.CommandLine += " " + system.EscapeArgs(c.Args)
243+
s.Process.CommandLine += " " + escapeArgs(c.Args)
244244
}
245245
} else {
246246
s.Process.Args = append([]string{c.Path}, c.Args...)
@@ -294,6 +294,15 @@ func (daemon *Daemon) createSpecWindowsFields(c *container.Container, s *specs.S
294294
return nil
295295
}
296296

297+
// escapeArgs makes a Windows-style escaped command line from a set of arguments
298+
func escapeArgs(args []string) string {
299+
escapedArgs := make([]string, len(args))
300+
for i, a := range args {
301+
escapedArgs[i] = windows.EscapeArg(a)
302+
}
303+
return strings.Join(escapedArgs, " ")
304+
}
305+
297306
// getBackingDeviceForContainerdMount extracts the backing device or directory mounted at mountPoint
298307
// by containerd's mount.Mount implementation for Windows.
299308
func getBackingDeviceForContainerdMount(mountPoint string) (string, error) {

pkg/system/args_windows.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import (
77
)
88

99
// EscapeArgs makes a Windows-style escaped command line from a set of arguments
10+
//
11+
// Deprecated: this function is no longer used and will be removed in the next release.
1012
func EscapeArgs(args []string) string {
1113
escapedArgs := make([]string, len(args))
1214
for i, a := range args {

0 commit comments

Comments
 (0)