From 3cd56e85d68384ddf15b002dd03fcbb4d490aed6 Mon Sep 17 00:00:00 2001 From: Tim Hockin Date: Wed, 2 Jul 2014 14:57:24 -0700 Subject: [PATCH] Simplify supported manifest versions --- pkg/api/validation.go | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/pkg/api/validation.go b/pkg/api/validation.go index 19cf33662d0..8182be3351c 100644 --- a/pkg/api/validation.go +++ b/pkg/api/validation.go @@ -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) {