mirror of
https://github.com/clearlinux/docker.git
synced 2026-11-20 21:12:44 +00:00
Add test coverage to opts and refactor
- Refactor opts.ValidatePath and add an opts.ValidateDevice ValidePath will now accept : containerPath:mode, hostPath:containerPath:mode and hostPath:containerPath. ValidateDevice will have the same behavior as current. - Refactor opts.ValidateEnv, opts.ParseEnvFile Environment variables will now be validated with the following definition : > Environment variables set by the user must have a name consisting > solely of alphabetics, numerics, and underscores - the first of > which must not be numeric. Signed-off-by: Vincent Demeester <vincent@sbr.pm>
This commit is contained in:
@@ -24,3 +24,29 @@ type Volume interface {
|
||||
// Unmount unmounts the volume when it is no longer in use.
|
||||
Unmount() error
|
||||
}
|
||||
|
||||
// read-write modes
|
||||
var rwModes = map[string]bool{
|
||||
"rw": true,
|
||||
"rw,Z": true,
|
||||
"rw,z": true,
|
||||
"z,rw": true,
|
||||
"Z,rw": true,
|
||||
"Z": true,
|
||||
"z": true,
|
||||
}
|
||||
|
||||
// read-only modes
|
||||
var roModes = map[string]bool{
|
||||
"ro": true,
|
||||
"ro,Z": true,
|
||||
"ro,z": true,
|
||||
"z,ro": true,
|
||||
"Z,ro": true,
|
||||
}
|
||||
|
||||
// ValidateMountMode will make sure the mount mode is valid.
|
||||
// returns if it's a valid mount mode and if it's read-write or not.
|
||||
func ValidateMountMode(mode string) (bool, bool) {
|
||||
return roModes[mode] || rwModes[mode], rwModes[mode]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user