dispatchers_unix.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. //go:build !windows
  2. // +build !windows
  3. package dockerfile // import "github.com/docker/docker/builder/dockerfile"
  4. import (
  5. "errors"
  6. "os"
  7. "path/filepath"
  8. "github.com/docker/docker/api/types/container"
  9. "github.com/moby/buildkit/frontend/dockerfile/instructions"
  10. )
  11. // normalizeWorkdir normalizes a user requested working directory in a
  12. // platform semantically consistent way.
  13. func normalizeWorkdir(_ string, current string, requested string) (string, error) {
  14. if requested == "" {
  15. return "", errors.New("cannot normalize nothing")
  16. }
  17. current = filepath.FromSlash(current)
  18. requested = filepath.FromSlash(requested)
  19. if !filepath.IsAbs(requested) {
  20. return filepath.Join(string(os.PathSeparator), current, requested), nil
  21. }
  22. return requested, nil
  23. }
  24. // resolveCmdLine takes a command line arg set and optionally prepends a platform-specific
  25. // shell in front of it.
  26. func resolveCmdLine(cmd instructions.ShellDependantCmdLine, runConfig *container.Config, os, _, _ string) ([]string, bool) {
  27. result := cmd.CmdLine
  28. if cmd.PrependShell && result != nil {
  29. result = append(getShell(runConfig, os), result...)
  30. }
  31. return result, false
  32. }