2014-11-14 04:20:42 +00:00
|
|
|
/*
|
2015-05-01 16:19:44 +00:00
|
|
|
Copyright 2014 The Kubernetes Authors All rights reserved.
|
2014-11-14 04:20:42 +00:00
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package validation
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
|
|
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
2015-03-22 21:40:47 +00:00
|
|
|
errs "github.com/GoogleCloudPlatform/kubernetes/pkg/util/fielderrors"
|
2014-11-14 04:20:42 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// ValidateEvent makes sure that the event makes sense.
|
|
|
|
func ValidateEvent(event *api.Event) errs.ValidationErrorList {
|
|
|
|
allErrs := errs.ValidationErrorList{}
|
2015-03-26 23:30:23 +00:00
|
|
|
// TODO: There is no namespace required for minion
|
|
|
|
if event.InvolvedObject.Kind != "Node" &&
|
|
|
|
event.Namespace != event.InvolvedObject.Namespace {
|
2014-11-20 22:24:10 +00:00
|
|
|
allErrs = append(allErrs, errs.NewFieldInvalid("involvedObject.namespace", event.InvolvedObject.Namespace, "namespace does not match involvedObject"))
|
2014-11-14 04:20:42 +00:00
|
|
|
}
|
2015-03-11 14:57:19 +00:00
|
|
|
if !util.IsDNS1123Subdomain(event.Namespace) {
|
2014-11-20 22:24:10 +00:00
|
|
|
allErrs = append(allErrs, errs.NewFieldInvalid("namespace", event.Namespace, ""))
|
2014-11-14 04:20:42 +00:00
|
|
|
}
|
|
|
|
return allErrs
|
|
|
|
}
|