Rename HostDir to HostPath in v1beta3

This commit is contained in:
Tim Hockin
2015-01-20 15:56:44 -08:00
parent 494d003981
commit 60ec08db93
11 changed files with 105 additions and 38 deletions

View File

@@ -67,9 +67,9 @@ func validateVolumes(volumes []api.Volume) (util.StringSet, errs.ValidationError
func validateSource(source *api.VolumeSource) errs.ValidationErrorList {
numVolumes := 0
allErrs := errs.ValidationErrorList{}
if source.HostDir != nil {
if source.HostPath != nil {
numVolumes++
allErrs = append(allErrs, validateHostDir(source.HostDir).Prefix("hostDirectory")...)
allErrs = append(allErrs, validateHostPath(source.HostPath).Prefix("hostPath")...)
}
if source.EmptyDir != nil {
numVolumes++
@@ -77,11 +77,11 @@ func validateSource(source *api.VolumeSource) errs.ValidationErrorList {
}
if source.GitRepo != nil {
numVolumes++
allErrs = append(allErrs, validateGitRepo(source.GitRepo)...)
allErrs = append(allErrs, validateGitRepo(source.GitRepo).Prefix("gitRepo")...)
}
if source.GCEPersistentDisk != nil {
numVolumes++
allErrs = append(allErrs, validateGCEPersistentDisk(source.GCEPersistentDisk)...)
allErrs = append(allErrs, validateGCEPersistentDisk(source.GCEPersistentDisk).Prefix("persistentDisk")...)
}
if numVolumes != 1 {
allErrs = append(allErrs, errs.NewFieldInvalid("", source, "exactly 1 volume type is required"))
@@ -89,10 +89,10 @@ func validateSource(source *api.VolumeSource) errs.ValidationErrorList {
return allErrs
}
func validateHostDir(hostDir *api.HostDir) errs.ValidationErrorList {
func validateHostPath(hostDir *api.HostPath) errs.ValidationErrorList {
allErrs := errs.ValidationErrorList{}
if hostDir.Path == "" {
allErrs = append(allErrs, errs.NewNotFound("path", hostDir.Path))
allErrs = append(allErrs, errs.NewFieldRequired("path", hostDir.Path))
}
return allErrs
}
@@ -100,7 +100,7 @@ func validateHostDir(hostDir *api.HostDir) errs.ValidationErrorList {
func validateGitRepo(gitRepo *api.GitRepo) errs.ValidationErrorList {
allErrs := errs.ValidationErrorList{}
if gitRepo.Repository == "" {
allErrs = append(allErrs, errs.NewFieldRequired("gitRepo.Repository", gitRepo.Repository))
allErrs = append(allErrs, errs.NewFieldRequired("repository", gitRepo.Repository))
}
return allErrs
}
@@ -108,13 +108,13 @@ func validateGitRepo(gitRepo *api.GitRepo) errs.ValidationErrorList {
func validateGCEPersistentDisk(PD *api.GCEPersistentDisk) errs.ValidationErrorList {
allErrs := errs.ValidationErrorList{}
if PD.PDName == "" {
allErrs = append(allErrs, errs.NewFieldRequired("PD.PDName", PD.PDName))
allErrs = append(allErrs, errs.NewFieldRequired("pdName", PD.PDName))
}
if PD.FSType == "" {
allErrs = append(allErrs, errs.NewFieldRequired("PD.FSType", PD.FSType))
allErrs = append(allErrs, errs.NewFieldRequired("fsType", PD.FSType))
}
if PD.Partition < 0 || PD.Partition > 255 {
allErrs = append(allErrs, errs.NewFieldInvalid("PD.Partition", PD.Partition, ""))
allErrs = append(allErrs, errs.NewFieldInvalid("partition", PD.Partition, ""))
}
return allErrs
}

View File

@@ -77,8 +77,8 @@ func TestValidateLabels(t *testing.T) {
func TestValidateVolumes(t *testing.T) {
successCase := []api.Volume{
{Name: "abc"},
{Name: "123", Source: &api.VolumeSource{HostDir: &api.HostDir{"/mnt/path2"}}},
{Name: "abc-123", Source: &api.VolumeSource{HostDir: &api.HostDir{"/mnt/path3"}}},
{Name: "123", Source: &api.VolumeSource{HostPath: &api.HostPath{"/mnt/path2"}}},
{Name: "abc-123", Source: &api.VolumeSource{HostPath: &api.HostPath{"/mnt/path3"}}},
{Name: "empty", Source: &api.VolumeSource{EmptyDir: &api.EmptyDir{}}},
{Name: "gcepd", Source: &api.VolumeSource{GCEPersistentDisk: &api.GCEPersistentDisk{"my-PD", "ext4", 1, false}}},
{Name: "gitrepo", Source: &api.VolumeSource{GitRepo: &api.GitRepo{"my-repo", "hashstring"}}},
@@ -366,8 +366,8 @@ func TestValidateManifest(t *testing.T) {
{
Version: "v1beta1",
ID: "abc",
Volumes: []api.Volume{{Name: "vol1", Source: &api.VolumeSource{HostDir: &api.HostDir{"/mnt/vol1"}}},
{Name: "vol2", Source: &api.VolumeSource{HostDir: &api.HostDir{"/mnt/vol2"}}}},
Volumes: []api.Volume{{Name: "vol1", Source: &api.VolumeSource{HostPath: &api.HostPath{"/mnt/vol1"}}},
{Name: "vol2", Source: &api.VolumeSource{HostPath: &api.HostPath{"/mnt/vol2"}}}},
Containers: []api.Container{
{
Name: "abc",