dispatchers_unix.go 1.1 KB

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