Adds initial volumes package; Supports host-dirs

Adds the framework for external volume mounts.

Currently supports bare host directory mounts.

Modifies the API to support host directory mounts from Volumes
instead of VolumeMounts.
This commit is contained in:
Danny Jones
2014-07-14 18:39:30 -07:00
parent 831ab28759
commit f84ff740f0
8 changed files with 224 additions and 13 deletions

View File

@@ -76,6 +76,10 @@ func validateVolumes(volumes []Volume) (util.StringSet, errorList) {
allNames := util.StringSet{}
for i := range volumes {
vol := &volumes[i] // so we can set default values
if vol.HostDirectory != nil {
errs := validateHostDir(vol.HostDirectory)
allErrs.Append(errs...)
}
if !util.IsDNSLabel(vol.Name) {
allErrs.Append(makeInvalidError("Volume.Name", vol.Name))
} else if allNames.Has(vol.Name) {
@@ -87,6 +91,14 @@ func validateVolumes(volumes []Volume) (util.StringSet, errorList) {
return allNames, allErrs
}
func validateHostDir(hostDir *HostDirectory) errorList {
allErrs := errorList{}
if hostDir.Path == "" {
allErrs.Append(makeNotFoundError("Volume.HostDir.Path", hostDir.Path))
}
return allErrs
}
var supportedPortProtocols = util.NewStringSet("TCP", "UDP")
func validatePorts(ports []Port) errorList {
@@ -163,6 +175,11 @@ func validateVolumeMounts(mounts []VolumeMount, volumes util.StringSet) errorLis
mnt.Path = ""
}
}
if len(mnt.MountType) != 0 {
glog.Warning("DEPRECATED: VolumeMount.MountType will be removed. The Volume struct will handle types")
}
}
return allErrs
}