本文整理汇总了Golang中github.com/GoogleCloudPlatform/kubernetes/pkg/util.IsCIdentifier函数的典型用法代码示例。如果您正苦于以下问题:Golang IsCIdentifier函数的具体用法?Golang IsCIdentifier怎么用?Golang IsCIdentifier使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IsCIdentifier函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestServiceRegistryMakeLinkVariables
func TestServiceRegistryMakeLinkVariables(t *testing.T) {
service := api.Service{
JSONBase: api.JSONBase{ID: "foo"},
Selector: map[string]string{"bar": "baz"},
ContainerPort: util.IntOrString{Kind: util.IntstrString, StrVal: "a-b-c"},
}
vars := makeLinkVariables(service, "mars")
for _, v := range vars {
if !util.IsCIdentifier(v.Name) {
t.Errorf("Environment variable name is not valid: %v", v.Name)
}
}
}
开发者ID:GoogleButtPlatform,项目名称:kubernetes,代码行数:13,代码来源:storage_test.go
示例2: validateEnv
func validateEnv(vars []EnvVar) errorList {
allErrs := errorList{}
for i := range vars {
ev := &vars[i] // so we can set default values
if len(ev.Name) == 0 {
allErrs.Append(makeInvalidError("EnvVar.Name", ev.Name))
}
if !util.IsCIdentifier(ev.Name) {
allErrs.Append(makeInvalidError("EnvVar.Name", ev.Name))
}
}
return allErrs
}
开发者ID:htomika,项目名称:kubernetes,代码行数:14,代码来源:validation.go
示例3: validateEnv
func validateEnv(vars []kapi.EnvVar) fielderrors.ValidationErrorList {
allErrs := fielderrors.ValidationErrorList{}
for i, ev := range vars {
vErrs := fielderrors.ValidationErrorList{}
if len(ev.Name) == 0 {
vErrs = append(vErrs, fielderrors.NewFieldRequired("name"))
}
if !util.IsCIdentifier(ev.Name) {
vErrs = append(vErrs, fielderrors.NewFieldInvalid("name", ev.Name, "must match regex "+util.CIdentifierFmt))
}
allErrs = append(allErrs, vErrs.PrefixIndex(i)...)
}
return allErrs
}
开发者ID:cjnygard,项目名称:origin,代码行数:15,代码来源:validation.go
示例4: validateEnv
func validateEnv(vars []api.EnvVar) errs.ValidationErrorList {
allErrs := errs.ValidationErrorList{}
for i, ev := range vars {
vErrs := errs.ValidationErrorList{}
if len(ev.Name) == 0 {
vErrs = append(vErrs, errs.NewFieldRequired("name", ev.Name))
}
if !util.IsCIdentifier(ev.Name) {
vErrs = append(vErrs, errs.NewFieldInvalid("name", ev.Name, cIdentifierErrorMsg))
}
allErrs = append(allErrs, vErrs.PrefixIndex(i)...)
}
return allErrs
}
开发者ID:brorhie,项目名称:panamax-kubernetes-adapter-go,代码行数:15,代码来源:validation.go
示例5: validateEnv
func validateEnv(vars []api.EnvVar) errs.ValidationErrorList {
allErrs := errs.ValidationErrorList{}
for i := range vars {
vErrs := errs.ValidationErrorList{}
ev := &vars[i] // so we can set default values
if len(ev.Name) == 0 {
vErrs = append(vErrs, errs.NewFieldRequired("name", ev.Name))
}
if !util.IsCIdentifier(ev.Name) {
vErrs = append(vErrs, errs.NewFieldInvalid("name", ev.Name, ""))
}
allErrs = append(allErrs, vErrs.PrefixIndex(i)...)
}
return allErrs
}
开发者ID:nhr,项目名称:kubernetes,代码行数:16,代码来源:validation.go
示例6: validateEnv
func validateEnv(vars []EnvVar) error {
for i := range vars {
ev := &vars[i] // so we can set default values
if len(ev.Name) == 0 {
// Backwards compat.
if len(ev.Key) == 0 {
return makeInvalidError("EnvVar.Name", ev.Name)
}
glog.Warning("DEPRECATED: EnvVar.Key has been replaced by EnvVar.Name")
ev.Name = ev.Key
ev.Key = ""
}
if !util.IsCIdentifier(ev.Name) {
return makeInvalidError("EnvVar.Name", ev.Name)
}
}
return nil
}
开发者ID:raphael,项目名称:kubernetes,代码行数:18,代码来源:validation.go
示例7: TestServiceRegistryMakeLinkVariables
func TestServiceRegistryMakeLinkVariables(t *testing.T) {
service := api.Service{
JSONBase: api.JSONBase{ID: "foo-bar"},
Selector: map[string]string{"bar": "baz"},
ContainerPort: util.IntOrString{Kind: util.IntstrString, StrVal: "a-b-c"},
}
registry := registrytest.NewServiceRegistry()
registry.List = api.ServiceList{
Items: []api.Service{service},
}
machine := "machine"
vars, err := GetServiceEnvironmentVariables(registry, machine)
if err != nil {
t.Errorf("Unexpected err: %v", err)
}
for _, v := range vars {
if !util.IsCIdentifier(v.Name) {
t.Errorf("Environment variable name is not valid: %v", v.Name)
}
}
}
开发者ID:asim,项目名称:kubernetes,代码行数:21,代码来源:rest_test.go
示例8: validateEnv
func validateEnv(vars []EnvVar) errorList {
allErrs := errorList{}
for i := range vars {
ev := &vars[i] // so we can set default values
if len(ev.Name) == 0 {
// Backwards compat.
if len(ev.Key) == 0 {
allErrs.Append(makeInvalidError("EnvVar.Name", ev.Name))
} else {
glog.Warning("DEPRECATED: EnvVar.Key has been replaced by EnvVar.Name")
ev.Name = ev.Key
ev.Key = ""
}
}
if !util.IsCIdentifier(ev.Name) {
allErrs.Append(makeInvalidError("EnvVar.Name", ev.Name))
}
}
return allErrs
}
开发者ID:hknochi,项目名称:kubernetes,代码行数:21,代码来源:validation.go
注:本文中的github.com/GoogleCloudPlatform/kubernetes/pkg/util.IsCIdentifier函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论