2016-05-03 01:33:59 +00:00
|
|
|
// +build !windows
|
|
|
|
|
|
|
|
package dockerfile
|
|
|
|
|
|
|
|
import (
|
2017-02-21 08:53:29 +00:00
|
|
|
"errors"
|
2016-05-03 01:33:59 +00:00
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
)
|
|
|
|
|
|
|
|
// normaliseWorkdir normalises a user requested working directory in a
|
2017-02-21 08:53:29 +00:00
|
|
|
// platform semantically consistent way.
|
2017-08-04 18:39:23 +00:00
|
|
|
func normaliseWorkdir(_ string, current string, requested string) (string, error) {
|
2016-05-03 01:33:59 +00:00
|
|
|
if requested == "" {
|
2017-02-21 08:53:29 +00:00
|
|
|
return "", errors.New("cannot normalise nothing")
|
2016-05-03 01:33:59 +00:00
|
|
|
}
|
|
|
|
current = filepath.FromSlash(current)
|
|
|
|
requested = filepath.FromSlash(requested)
|
|
|
|
if !filepath.IsAbs(requested) {
|
|
|
|
return filepath.Join(string(os.PathSeparator), current, requested), nil
|
|
|
|
}
|
|
|
|
return requested, nil
|
|
|
|
}
|
2016-05-03 20:56:59 +00:00
|
|
|
|
|
|
|
func errNotJSON(command, _ string) error {
|
|
|
|
return fmt.Errorf("%s requires the arguments to be in JSON form", command)
|
|
|
|
}
|
2017-04-04 16:28:59 +00:00
|
|
|
|
|
|
|
// equalEnvKeys compare two strings and returns true if they are equal. On
|
|
|
|
// Windows this comparison is case insensitive.
|
|
|
|
func equalEnvKeys(from, to string) bool {
|
|
|
|
return from == to
|
|
|
|
}
|