@@ -112,13 +112,6 @@ func ValidateReplicationControllerName(name string, prefix bool) (bool, string)
112112 return NameIsDNSSubdomain (name , prefix )
113113}
114114
115- // ValidateDaemonName can be used to check whether the given daemon name is valid.
116- // Prefix indicates this name will be used as part of generation, in which case
117- // trailing dashes are allowed.
118- func ValidateDaemonName (name string , prefix bool ) (bool , string ) {
119- return NameIsDNSSubdomain (name , prefix )
120- }
121-
122115// ValidateServiceName can be used to check whether the given service name is valid.
123116// Prefix indicates this name will be used as part of generation, in which case
124117// trailing dashes are allowed.
@@ -1244,65 +1237,6 @@ func ValidateReplicationControllerSpec(spec *api.ReplicationControllerSpec) errs
12441237 return allErrs
12451238}
12461239
1247- // ValidateDaemon tests if required fields in the daemon are set.
1248- func ValidateDaemon (controller * api.Daemon ) errs.ValidationErrorList {
1249- allErrs := errs.ValidationErrorList {}
1250- allErrs = append (allErrs , ValidateObjectMeta (& controller .ObjectMeta , true , ValidateReplicationControllerName ).Prefix ("metadata" )... )
1251- allErrs = append (allErrs , ValidateDaemonSpec (& controller .Spec ).Prefix ("spec" )... )
1252- return allErrs
1253- }
1254-
1255- // ValidateDaemonUpdate tests if required fields in the daemon are set.
1256- func ValidateDaemonUpdate (oldController , controller * api.Daemon ) errs.ValidationErrorList {
1257- allErrs := errs.ValidationErrorList {}
1258- allErrs = append (allErrs , ValidateObjectMetaUpdate (& controller .ObjectMeta , & oldController .ObjectMeta ).Prefix ("metadata" )... )
1259- allErrs = append (allErrs , ValidateDaemonSpec (& controller .Spec ).Prefix ("spec" )... )
1260- allErrs = append (allErrs , ValidateDaemonTemplateUpdate (oldController .Spec .Template , controller .Spec .Template ).Prefix ("spec.template" )... )
1261- return allErrs
1262- }
1263-
1264- // ValidateDaemonTemplateUpdate tests that certain fields in the daemon's pod template are not updated.
1265- func ValidateDaemonTemplateUpdate (oldPodTemplate , podTemplate * api.PodTemplateSpec ) errs.ValidationErrorList {
1266- allErrs := errs.ValidationErrorList {}
1267- podSpec := podTemplate .Spec
1268- // podTemplate.Spec is not a pointer, so we can modify NodeSelector and NodeName directly.
1269- podSpec .NodeSelector = oldPodTemplate .Spec .NodeSelector
1270- podSpec .NodeName = oldPodTemplate .Spec .NodeName
1271- // In particular, we do not allow updates to container images at this point.
1272- if ! api .Semantic .DeepEqual (oldPodTemplate .Spec , podSpec ) {
1273- // TODO: Pinpoint the specific field that causes the invalid error after we have strategic merge diff
1274- allErrs = append (allErrs , errs .NewFieldInvalid ("spec" , "content of spec is not printed out, please refer to the \" details\" " , "may not update fields other than spec.nodeSelector" ))
1275- }
1276- return allErrs
1277- }
1278-
1279- // ValidateDaemonSpec tests if required fields in the daemon spec are set.
1280- func ValidateDaemonSpec (spec * api.DaemonSpec ) errs.ValidationErrorList {
1281- allErrs := errs.ValidationErrorList {}
1282-
1283- selector := labels .Set (spec .Selector ).AsSelector ()
1284- if selector .Empty () {
1285- allErrs = append (allErrs , errs .NewFieldRequired ("selector" ))
1286- }
1287-
1288- if spec .Template == nil {
1289- allErrs = append (allErrs , errs .NewFieldRequired ("template" ))
1290- } else {
1291- labels := labels .Set (spec .Template .Labels )
1292- if ! selector .Matches (labels ) {
1293- allErrs = append (allErrs , errs .NewFieldInvalid ("template.metadata.labels" , spec .Template .Labels , "selector does not match template" ))
1294- }
1295- allErrs = append (allErrs , ValidatePodTemplateSpec (spec .Template ).Prefix ("template" )... )
1296- // Daemons typically run on more than one node, so mark Read-Write persistent disks as invalid.
1297- allErrs = append (allErrs , ValidateReadOnlyPersistentDisks (spec .Template .Spec .Volumes ).Prefix ("template.spec.volumes" )... )
1298- // RestartPolicy has already been first-order validated as per ValidatePodTemplateSpec().
1299- if spec .Template .Spec .RestartPolicy != api .RestartPolicyAlways {
1300- allErrs = append (allErrs , errs .NewFieldValueNotSupported ("template.spec.restartPolicy" , spec .Template .Spec .RestartPolicy , []string {string (api .RestartPolicyAlways )}))
1301- }
1302- }
1303- return allErrs
1304- }
1305-
13061240// ValidatePodTemplateSpec validates the spec of a pod template
13071241func ValidatePodTemplateSpec (spec * api.PodTemplateSpec ) errs.ValidationErrorList {
13081242 allErrs := errs.ValidationErrorList {}
0 commit comments