dispatchers_unix.go 683 B

123456789101112131415161718192021222324252627
  1. // +build !windows
  2. package dockerfile
  3. import (
  4. "fmt"
  5. "os"
  6. "path/filepath"
  7. )
  8. // normaliseWorkdir normalises a user requested working directory in a
  9. // platform sematically consistent way.
  10. func normaliseWorkdir(current string, requested string) (string, error) {
  11. if requested == "" {
  12. return "", fmt.Errorf("cannot normalise nothing")
  13. }
  14. current = filepath.FromSlash(current)
  15. requested = filepath.FromSlash(requested)
  16. if !filepath.IsAbs(requested) {
  17. return filepath.Join(string(os.PathSeparator), current, requested), nil
  18. }
  19. return requested, nil
  20. }
  21. func errNotJSON(command, _ string) error {
  22. return fmt.Errorf("%s requires the arguments to be in JSON form", command)
  23. }