dispatchers_unix.go 891 B

12345678910111213141516171819202122232425262728293031323334
  1. // +build !windows
  2. package dockerfile
  3. import (
  4. "errors"
  5. "fmt"
  6. "os"
  7. "path/filepath"
  8. )
  9. // normalizeWorkdir normalizes a user requested working directory in a
  10. // platform semantically consistent way.
  11. func normalizeWorkdir(_ string, current string, requested string) (string, error) {
  12. if requested == "" {
  13. return "", errors.New("cannot normalize nothing")
  14. }
  15. current = filepath.FromSlash(current)
  16. requested = filepath.FromSlash(requested)
  17. if !filepath.IsAbs(requested) {
  18. return filepath.Join(string(os.PathSeparator), current, requested), nil
  19. }
  20. return requested, nil
  21. }
  22. func errNotJSON(command, _ string) error {
  23. return fmt.Errorf("%s requires the arguments to be in JSON form", command)
  24. }
  25. // equalEnvKeys compare two strings and returns true if they are equal. On
  26. // Windows this comparison is case insensitive.
  27. func equalEnvKeys(from, to string) bool {
  28. return from == to
  29. }