示例#1
0
文件: pod.go 项目: redspread/spread
func validatePod(pod *kube.Pod, ignoreContainers bool) error {
	errList := validation.ValidatePod(pod)

	// remove error for no containers if requested
	if ignoreContainers {
		errList = errList.Filter(func(e error) bool {
			return e.Error() == "spec.containers: Required value"
		})
	}

	meta := pod.GetObjectMeta()
	if len(meta.GetName()) == 0 && len(meta.GetGenerateName()) > 0 {
		errList = errList.Filter(func(e error) bool {
			return e.Error() == "metadata.name: Required value: name or generateName is required"
		})
	}

	return errList.ToAggregate()
}