k8s/io/kubernetes/pkg/api/errors.NewInvalid 示例代码

2022-03-03

以下示例是关于golang中包含errors.NewInvalid用法的示例代码,想了解errors.NewInvalid的具体用法?errors.NewInvalid怎么用?errors.NewInvalid使用的例子?那么可以参考以下10个相关示例代码来学习它的具体使用方法。

示例1:
rest.go开发语言: Go项目名称: ddysher代码行数: 649
123			el := field.ErrorList{field.Invalid(field.NewPath("spec", "clusterIP"), service.Spec.ClusterIP, err.Error())}
124			return nil, errors.NewInvalid(api.Kind("Service"), service.Name, el)
125		}
146					el := field.ErrorList{field.Invalid(field.NewPath("spec", "ports").Index(i).Child("nodePort"), np, err.Error())}
147					return nil, errors.NewInvalid(api.Kind("Service"), service.Name, el)
148				}
169					el := field.ErrorList{field.Invalid(field.NewPath("spec", "ports").Index(i).Child("nodePort"), servicePort.NodePort, err.Error())}
170					return nil, errors.NewInvalid(api.Kind("Service"), service.Name, el)
171				}
183		if errs := validation.ValidateServiceExternalTrafficFieldsCombination(service); len(errs) > 0 {
184			return nil, errors.NewInvalid(api.Kind("Service"), service.Name, errs)
185		}
341				"cannot change healthCheckNodePort on loadBalancer service with externalTraffic=Local during update")}
342			return false, errors.NewInvalid(api.Kind("Service"), service.Name, el)
343		}
示例2:
rest.go开发语言: Go项目名称: detiber代码行数: 572
113			el := field.ErrorList{field.Invalid(field.NewPath("spec", "clusterIP"), service.Spec.ClusterIP, err.Error())}
114			return nil, errors.NewInvalid(api.Kind("Service"), service.Name, el)
115		}
136					el := field.ErrorList{field.Invalid(field.NewPath("spec", "ports").Index(i).Child("nodePort"), np, err.Error())}
137					return nil, errors.NewInvalid(api.Kind("Service"), service.Name, el)
138				}
159					el := field.ErrorList{field.Invalid(field.NewPath("spec", "ports").Index(i).Child("nodePort"), servicePort.NodePort, err.Error())}
160					return nil, errors.NewInvalid(api.Kind("Service"), service.Name, el)
161				}
173		if errs := validation.ValidateServiceExternalTrafficFieldsCombination(service); len(errs) > 0 {
174			return nil, errors.NewInvalid(api.Kind("Service"), service.Name, errs)
175		}
331				"cannot change healthCheckNodePort on loadBalancer service with externalTraffic=Local during update")}
332			return false, errors.NewInvalid(api.Kind("Service"), service.Name, el)
333		}
示例3:
rest.go开发语言: Go项目名称: abhgupta代码行数: 646
141		if errs := validation.ValidateServiceExternalTrafficFieldsCombination(service); len(errs) > 0 {
142			return nil, errors.NewInvalid(api.Kind("Service"), service.Name, errs)
143		}
290				"cannot change healthCheckNodePort on loadBalancer service with externalTraffic=Local during update")}
291			return false, errors.NewInvalid(api.Kind("Service"), service.Name, el)
292		}
315	if errs := validation.ValidateServiceUpdate(service, oldService); len(errs) > 0 {
316		return nil, false, errors.NewInvalid(api.Kind("Service"), service.Name, errs)
317	}
368		if errs := validation.ValidateServiceExternalTrafficFieldsCombination(service); len(errs) > 0 {
369			return nil, false, errors.NewInvalid(api.Kind("Service"), service.Name, errs)
370		}
534			el := field.ErrorList{field.Invalid(field.NewPath("spec", "clusterIP"), service.Spec.ClusterIP, err.Error())}
535			return false, errors.NewInvalid(api.Kind("Service"), service.Name, el)
536		}
示例4:
rest.go开发语言: Go项目名称: cjcullen代码行数: 582
111			el := field.ErrorList{field.Invalid(field.NewPath("spec", "clusterIP"), service.Spec.ClusterIP, err.Error())}
112			return nil, errors.NewInvalid(api.Kind("Service"), service.Name, el)
113		}
131					el := field.ErrorList{field.Invalid(field.NewPath("spec", "ports").Index(i).Child("nodePort"), np, err.Error())}
132					return nil, errors.NewInvalid(api.Kind("Service"), service.Name, el)
133				}
154					el := field.ErrorList{field.Invalid(field.NewPath("spec", "ports").Index(i).Child("nodePort"), servicePort.NodePort, err.Error())}
155					return nil, errors.NewInvalid(api.Kind("Service"), service.Name, el)
156				}
316					apiservice.BetaAnnotationHealthCheckNodePort, errmsg)}
317				return false, errors.NewInvalid(api.Kind("Service"), service.Name, el)
318			}
350				apiservice.BetaAnnotationHealthCheckNodePort, "Cannot insert healthcheck nodePort annotation")}
351			return false, errors.NewInvalid(api.Kind("Service"), service.Name, el)
352		}
示例5:
rest.go开发语言: Go项目名称: amygdala代码行数: 395
108			el := field.ErrorList{field.Invalid(field.NewPath("spec", "clusterIP"), service.Spec.ClusterIP, err.Error())}
109			return nil, errors.NewInvalid(api.Kind("Service"), service.Name, el)
110		}
121				el := field.ErrorList{field.Invalid(field.NewPath("spec", "ports").Index(i).Child("nodePort"), servicePort.NodePort, err.Error())}
122				return nil, errors.NewInvalid(api.Kind("Service"), service.Name, el)
123			}
228	if errs := validation.ValidateServiceUpdate(service, oldService); len(errs) > 0 {
229		return nil, false, errors.NewInvalid(api.Kind("Service"), service.Name, errs)
230	}
248						el := field.ErrorList{field.Invalid(field.NewPath("spec", "ports").Index(i).Child("nodePort"), nodePort, err.Error())}
249						return nil, false, errors.NewInvalid(api.Kind("Service"), service.Name, el)
250					}
示例6:
rest.go开发语言: Go项目名称: ashumeow代码行数: 277
87	if errs := validation.ValidateService(service, rs.registry, ctx); len(errs) > 0 {
88		return nil, errors.NewInvalid("service", service.Name, errs)
89	}
103			el := errors.ValidationErrorList{errors.NewFieldInvalid("spec.portalIP", service.Spec.PortalIP, err.Error())}
104			return nil, errors.NewInvalid("service", service.Name, el)
105		}
216	if errs := validation.ValidateService(service, rs.registry, ctx); len(errs) > 0 {
217		return nil, errors.NewInvalid("service", service.Name, errs)
218	}
225			el := errors.ValidationErrorList{errors.NewFieldInvalid("spec.portalIP", service.Spec.PortalIP, "field is immutable")}
226			return nil, errors.NewInvalid("service", service.Name, el)
227		}
示例7:
rest.go开发语言: Go项目名称: bparees代码行数: 808
225	if errs := validation.ValidateServiceExternalTrafficFieldsCombination(service); len(errs) > 0 {
226		return nil, errors.NewInvalid(api.Kind("Service"), service.Name, errs)
227	}
361				"cannot change healthCheckNodePort on loadBalancer service with externalTraffic=Local during update")}
362			return false, errors.NewInvalid(api.Kind("Service"), service.Name, el)
363		}
458	if errs := validation.ValidateServiceExternalTrafficFieldsCombination(service); len(errs) > 0 {
459		return nil, false, errors.NewInvalid(api.Kind("Service"), service.Name, errs)
460	}
685			el := field.ErrorList{field.Invalid(field.NewPath("spec", "clusterIP"), service.Spec.ClusterIP, err.Error())}
686			return false, errors.NewInvalid(api.Kind("Service"), service.Name, el)
687		}
708					el := field.ErrorList{field.Invalid(field.NewPath("spec", "ports").Index(i).Child("nodePort"), np, err.Error())}
709					return errors.NewInvalid(api.Kind("Service"), service.Name, el)
710				}
示例8:
rest.go开发语言: Go项目名称: byxorna代码行数: 806
225	if errs := validation.ValidateServiceExternalTrafficFieldsCombination(service); len(errs) > 0 {
226		return nil, errors.NewInvalid(api.Kind("Service"), service.Name, errs)
227	}
361				"cannot change healthCheckNodePort on loadBalancer service with externalTraffic=Local during update")}
362			return false, errors.NewInvalid(api.Kind("Service"), service.Name, el)
363		}
458	if errs := validation.ValidateServiceExternalTrafficFieldsCombination(service); len(errs) > 0 {
459		return nil, false, errors.NewInvalid(api.Kind("Service"), service.Name, errs)
460	}
683			el := field.ErrorList{field.Invalid(field.NewPath("spec", "clusterIP"), service.Spec.ClusterIP, err.Error())}
684			return false, errors.NewInvalid(api.Kind("Service"), service.Name, el)
685		}
706					el := field.ErrorList{field.Invalid(field.NewPath("spec", "ports").Index(i).Child("nodePort"), np, err.Error())}
707					return errors.NewInvalid(api.Kind("Service"), service.Name, el)
708				}
示例9:
rest.go开发语言: Go项目名称: csrwng代码行数: 746
201	if errs := validation.ValidateServiceExternalTrafficFieldsCombination(service); len(errs) > 0 {
202		return nil, errors.NewInvalid(api.Kind("Service"), service.Name, errs)
203	}
336				"cannot change healthCheckNodePort on loadBalancer service with externalTraffic=Local during update")}
337			return false, errors.NewInvalid(api.Kind("Service"), service.Name, el)
338		}
427	if errs := validation.ValidateServiceExternalTrafficFieldsCombination(service); len(errs) > 0 {
428		return nil, false, errors.NewInvalid(api.Kind("Service"), service.Name, errs)
429	}
623			el := field.ErrorList{field.Invalid(field.NewPath("spec", "clusterIP"), service.Spec.ClusterIP, err.Error())}
624			return false, errors.NewInvalid(api.Kind("Service"), service.Name, el)
625		}
646					el := field.ErrorList{field.Invalid(field.NewPath("spec", "ports").Index(i).Child("nodePort"), np, err.Error())}
647					return errors.NewInvalid(api.Kind("Service"), service.Name, el)
648				}
示例10:
helpers_test.go开发语言: Go项目名称: ddysher代码行数: 321
218		{
219			errors.NewInvalid(api.Kind("Invalid1"), "invalidation", field.ErrorList{field.Invalid(field.NewPath("field"), "single", "details")}),
220			"The Invalid1 \"invalidation\" is invalid: field: Invalid value: \"single\": details\n",
223		{
224			errors.NewInvalid(api.Kind("Invalid2"), "invalidation", field.ErrorList{field.Invalid(field.NewPath("field1"), "multi1", "details"), field.Invalid(field.NewPath("field2"), "multi2", "details")}),
225			"The Invalid2 \"invalidation\" is invalid: \n* field1: Invalid value: \"multi1\": details\n* field2: Invalid value: \"multi2\": details\n",
228		{
229			errors.NewInvalid(api.Kind("Invalid3"), "invalidation", field.ErrorList{}),
230			"The Invalid3 \"invalidation\" is invalid",
233		{
234			errors.NewInvalid(api.Kind("Invalid4"), "invalidation", field.ErrorList{field.Invalid(field.NewPath("field4"), "multi4", "details"), field.Invalid(field.NewPath("field4"), "multi4", "details")}),
235			"The Invalid4 \"invalidation\" is invalid: field4: Invalid value: \"multi4\": details\n",

本文地址:https://www.itbaoku.cn/snippets/415706.html