2016-05-02 21:33:59 -04:00
|
|
|
// +build !windows
|
|
|
|
|
|
|
|
package dockerfile
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
)
|
|
|
|
|
|
|
|
// normaliseWorkdir normalises a user requested working directory in a
|
|
|
|
// platform sematically consistent way.
|
|
|
|
func normaliseWorkdir(current string, requested string) (string, error) {
|
|
|
|
if requested == "" {
|
|
|
|
return "", fmt.Errorf("cannot normalise nothing")
|
|
|
|
}
|
|
|
|
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 16:56:59 -04:00
|
|
|
|
|
|
|
func errNotJSON(command, _ string) error {
|
|
|
|
return fmt.Errorf("%s requires the arguments to be in JSON form", command)
|
|
|
|
}
|