Add initial validation of Service objects

This commit is contained in:
Brendan Burns
2014-07-10 12:45:01 -07:00
parent 56735fe2ec
commit e9edfc754e
3 changed files with 47 additions and 2 deletions

View File

@@ -246,3 +246,14 @@ func ValidateManifest(manifest *ContainerManifest) []error {
allErrs.Append(validateContainers(manifest.Containers, allVolumes)...)
return []error(allErrs)
}
func ValidateService(service *Service) []error {
allErrs := errorList{}
if service.ID == "" {
allErrs.Append(fmt.Errorf("ID should not be empty: %#v", *service))
}
if len(service.Selector) == 0 {
allErrs.Append(fmt.Errorf("Service %#v missing a selector", *service))
}
return []error(allErrs)
}