Merge pull request #342 from thockin/valid2

Simplify supported manifest versions
This commit is contained in:
Tim Hockin 2014-07-02 15:32:02 -07:00
commit a1be413cb3

View File

@ -23,13 +23,9 @@ import (
"github.com/golang/glog"
)
func isSupportedManifestVersion(value string) bool {
switch value {
case "v1beta1", "v1beta2":
return true
}
return false
}
var (
supportedManifestVersions util.StringSet = util.NewStringSet("v1beta1", "v1beta2")
)
func errInvalid(field string, value interface{}) error {
return fmt.Errorf("%s is invalid: '%v'", field, value)
@ -109,7 +105,7 @@ func ValidateManifest(manifest *ContainerManifest) error {
if len(manifest.Version) == 0 {
return errInvalid("ContainerManifest.Version", manifest.Version)
}
if !isSupportedManifestVersion(manifest.Version) {
if !supportedManifestVersions.Has(manifest.Version) {
return errNotSupported("ContainerManifest.Version", manifest.Version)
}
if len(manifest.ID) > 255 || !util.IsDNSSubdomain(manifest.ID) {