當前位置: 首頁>>代碼示例>>Golang>>正文


Golang util.IsCIdentifier函數代碼示例

本文整理匯總了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;未經允許,請勿轉載。