2015-09-23 04:56:29 +00:00
|
|
|
package allocdir
|
|
|
|
|
2015-09-25 00:47:38 +00:00
|
|
|
import (
|
|
|
|
"os"
|
2016-06-19 20:56:09 +00:00
|
|
|
"path/filepath"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2016-09-02 19:44:05 +00:00
|
|
|
// SharedAllocContainerPath is the path inside container for mounted
|
|
|
|
// directory shared across tasks in a task group.
|
2016-06-19 20:56:09 +00:00
|
|
|
SharedAllocContainerPath = filepath.Join("c:\\", SharedAllocName)
|
|
|
|
|
2016-09-02 19:44:05 +00:00
|
|
|
// TaskLocalContainer is the path inside a container for mounted directory
|
|
|
|
// for local storage.
|
2016-06-19 20:56:09 +00:00
|
|
|
TaskLocalContainerPath = filepath.Join("c:\\", TaskLocal)
|
2016-09-02 19:44:05 +00:00
|
|
|
|
|
|
|
// TaskSecretsContainerPath is the path inside a container for mounted
|
|
|
|
// secrets directory
|
|
|
|
TaskSecretsContainerPath = filepath.Join("c:\\", TaskSecrets)
|
2015-09-25 00:47:38 +00:00
|
|
|
)
|
2015-09-23 04:56:29 +00:00
|
|
|
|
2016-12-03 01:04:07 +00:00
|
|
|
// linkOrCopy is always copies dst to src on Windows.
|
2017-04-12 19:31:00 +00:00
|
|
|
func linkOrCopy(src, dst string, uid, gid int, perm os.FileMode) error {
|
|
|
|
return fileCopy(src, dst, uid, gid, perm)
|
2015-09-23 04:56:29 +00:00
|
|
|
}
|
|
|
|
|
2016-12-03 01:04:07 +00:00
|
|
|
// The windows version does nothing currently.
|
|
|
|
func linkDir(src, dst string) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// The windows version does nothing currently.
|
|
|
|
func unlinkDir(dir string) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2016-09-02 19:44:05 +00:00
|
|
|
// createSecretDir creates the secrets dir folder at the given path
|
2016-12-03 01:04:07 +00:00
|
|
|
func createSecretDir(dir string) error {
|
2016-09-02 19:44:05 +00:00
|
|
|
return os.MkdirAll(dir, 0777)
|
|
|
|
}
|
|
|
|
|
|
|
|
// removeSecretDir removes the secrets dir folder
|
2016-12-03 01:04:07 +00:00
|
|
|
func removeSecretDir(dir string) error {
|
2016-09-02 19:44:05 +00:00
|
|
|
return os.RemoveAll(dir)
|
|
|
|
}
|
|
|
|
|
2016-09-02 00:23:15 +00:00
|
|
|
// The windows version does nothing currently.
|
2017-04-04 17:48:29 +00:00
|
|
|
func dropDirPermissions(path string, desired os.FileMode) error {
|
2016-09-02 00:23:15 +00:00
|
|
|
return nil
|
2015-09-25 23:49:14 +00:00
|
|
|
}
|
|
|
|
|
2016-02-08 22:11:53 +00:00
|
|
|
// MountSpecialDirs mounts the dev and proc file system on the chroot of the
|
|
|
|
// task. It's a no-op on windows.
|
2016-12-03 01:04:07 +00:00
|
|
|
func MountSpecialDirs(taskDir string) error {
|
2016-02-08 22:11:53 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2017-04-12 19:31:00 +00:00
|
|
|
// getOwner doesn't work on Windows as Windows doesn't use int user IDs
|
|
|
|
func getOwner(os.FileInfo) (int, int) {
|
2017-04-17 19:29:34 +00:00
|
|
|
return idUnsupported, idUnsupported
|
2017-04-12 19:31:00 +00:00
|
|
|
}
|