本文整理汇总了Golang中github.com/openshift/origin/pkg/util.AddObjectLabels函数的典型用法代码示例。如果您正苦于以下问题:Golang AddObjectLabels函数的具体用法?Golang AddObjectLabels怎么用?Golang AddObjectLabels使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了AddObjectLabels函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Process
// Process transforms Template object into List object. It generates
// Parameter values using the defined set of generators first, and then it
// substitutes all Parameter expression occurrences with their corresponding
// values (currently in the containers' Environment variables only).
func (p *Processor) Process(template *api.Template) fielderrors.ValidationErrorList {
templateErrors := fielderrors.ValidationErrorList{}
if err := p.GenerateParameterValues(template); err != nil {
return append(templateErrors.Prefix("Template"), fielderrors.NewFieldInvalid("parameters", err, "failure to generate parameter value"))
}
for i, item := range template.Objects {
if obj, ok := item.(*runtime.Unknown); ok {
// TODO: use runtime.DecodeList when it returns ValidationErrorList
obj, err := runtime.UnstructuredJSONScheme.Decode(obj.RawJSON)
if err != nil {
util.ReportError(&templateErrors, i, *fielderrors.NewFieldInvalid("objects", err, "unable to handle object"))
continue
}
item = obj
}
newItem, err := p.SubstituteParameters(template.Parameters, item)
if err != nil {
util.ReportError(&templateErrors, i, *fielderrors.NewFieldInvalid("parameters", template.Parameters, err.Error()))
}
stripNamespace(newItem)
if err := util.AddObjectLabels(newItem, template.ObjectLabels); err != nil {
util.ReportError(&templateErrors, i, *fielderrors.NewFieldInvalid("labels", err, "label could not be applied"))
}
template.Objects[i] = newItem
}
return templateErrors
}
开发者ID:patrykattc,项目名称:origin,代码行数:35,代码来源:template.go
示例2: Process
// Process transforms Template object into List object. It generates
// Parameter values using the defined set of generators first, and then it
// substitutes all Parameter expression occurrences with their corresponding
// values (currently in the containers' Environment variables only).
func (p *Processor) Process(template *api.Template) fielderrors.ValidationErrorList {
templateErrors := fielderrors.ValidationErrorList{}
if err, badParam := p.GenerateParameterValues(template); err != nil {
return append(templateErrors.Prefix("Template"), fielderrors.NewFieldInvalid("parameters", *badParam, err.Error()))
}
for i, item := range template.Objects {
if obj, ok := item.(*runtime.Unknown); ok {
// TODO: use runtime.DecodeList when it returns ValidationErrorList
decodedObj, err := runtime.UnstructuredJSONScheme.Decode(obj.RawJSON)
if err != nil {
util.ReportError(&templateErrors, i, *fielderrors.NewFieldInvalid("objects", obj, "unable to handle object"))
continue
}
item = decodedObj
}
newItem, err := p.SubstituteParameters(template.Parameters, item)
if err != nil {
util.ReportError(&templateErrors, i, *fielderrors.NewFieldInvalid("parameters", template.Parameters, err.Error()))
}
// If an object definition's metadata includes a namespace field, the field will be stripped out of
// the definition during template instantiation. This is necessary because all objects created during
// instantiation are placed into the target namespace, so it would be invalid for the object to declare
//a different namespace.
stripNamespace(newItem)
if err := util.AddObjectLabels(newItem, template.ObjectLabels); err != nil {
util.ReportError(&templateErrors, i, *fielderrors.NewFieldInvalid("labels", err, "label could not be applied"))
}
template.Objects[i] = newItem
}
return templateErrors
}
开发者ID:johnmccawley,项目名称:origin,代码行数:39,代码来源:template.go
示例3: setLabels
func setLabels(labels map[string]string, result *newcmd.AppResult) error {
for _, object := range result.List.Items {
err := util.AddObjectLabels(object, labels)
if err != nil {
return err
}
}
return nil
}
开发者ID:nak3,项目名称:origin,代码行数:9,代码来源:newapp.go
示例4: setLabels
func setLabels(labels map[string]string, result *newcmd.AppResult) error {
if len(labels) == 0 {
if len(result.Name) > 0 {
labels = map[string]string{"app": result.Name}
}
}
for _, object := range result.List.Items {
err := util.AddObjectLabels(object, labels)
if err != nil {
return err
}
}
return nil
}
开发者ID:sztsian,项目名称:origin,代码行数:14,代码来源:newapp.go
示例5: Process
// Process transforms Template object into List object. It generates
// Parameter values using the defined set of generators first, and then it
// substitutes all Parameter expression occurrences with their corresponding
// values (currently in the containers' Environment variables only).
func (p *Processor) Process(template *api.Template) field.ErrorList {
templateErrors := field.ErrorList{}
if fieldError := p.GenerateParameterValues(template); fieldError != nil {
return append(templateErrors, fieldError)
}
// Place parameters into a map for efficient lookup
paramMap := make(map[string]api.Parameter)
for _, param := range template.Parameters {
paramMap[param.Name] = param
}
// Perform parameter substitution on the template's user message. This can be used to
// instruct a user on next steps for the template.
template.Message = p.EvaluateParameterSubstitution(paramMap, template.Message)
itemPath := field.NewPath("item")
for i, item := range template.Objects {
idxPath := itemPath.Index(i)
if obj, ok := item.(*runtime.Unknown); ok {
// TODO: use runtime.DecodeList when it returns ValidationErrorList
decodedObj, err := runtime.Decode(runtime.UnstructuredJSONScheme, obj.Raw)
if err != nil {
templateErrors = append(templateErrors, field.Invalid(idxPath.Child("objects"), obj, fmt.Sprintf("unable to handle object: %v", err)))
continue
}
item = decodedObj
}
newItem, err := p.SubstituteParameters(paramMap, item)
if err != nil {
templateErrors = append(templateErrors, field.Invalid(idxPath.Child("parameters"), template.Parameters, err.Error()))
}
// If an object definition's metadata includes a namespace field, the field will be stripped out of
// the definition during template instantiation. This is necessary because all objects created during
// instantiation are placed into the target namespace, so it would be invalid for the object to declare
//a different namespace.
stripNamespace(newItem)
if err := util.AddObjectLabels(newItem, template.ObjectLabels); err != nil {
templateErrors = append(templateErrors, field.Invalid(idxPath.Child("labels"),
template.ObjectLabels, fmt.Sprintf("label could not be applied: %v", err)))
}
template.Objects[i] = newItem
}
return templateErrors
}
开发者ID:Xmagicer,项目名称:origin,代码行数:52,代码来源:template.go
示例6: setLabels
func setLabels(c *cobra.Command, result *newcmd.AppResult) error {
label := cmdutil.GetFlagString(c, "labels")
if len(label) != 0 {
lbl, err := ctl.ParseLabels(label)
if err != nil {
return err
}
for _, object := range result.List.Items {
err = util.AddObjectLabels(object, lbl)
if err != nil {
return err
}
}
}
return nil
}
开发者ID:nstrug,项目名称:origin,代码行数:17,代码来源:newapp.go
注:本文中的github.com/openshift/origin/pkg/util.AddObjectLabels函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论