本文整理匯總了Golang中github.com/openshift/origin/pkg/template.AddParameter函數的典型用法代碼示例。如果您正苦於以下問題:Golang AddParameter函數的具體用法?Golang AddParameter怎麽用?Golang AddParameter使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了AddParameter函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: buildTemplates
// buildTemplates converts a set of resolved, valid references into references to template objects.
func (c *AppConfig) buildTemplates(components app.ComponentReferences, environment app.Environment) ([]runtime.Object, error) {
objects := []runtime.Object{}
for _, ref := range components {
tpl := ref.Input().ResolvedMatch.Template
glog.V(4).Infof("processing template %s/%s", c.originNamespace, tpl.Name)
for _, env := range environment.List() {
// only set environment values that match what's expected by the template.
if v := template.GetParameterByName(tpl, env.Name); v != nil {
v.Value = env.Value
v.Generate = ""
template.AddParameter(tpl, *v)
} else {
return nil, fmt.Errorf("unexpected parameter name %q", env.Name)
}
}
result, err := c.osclient.TemplateConfigs(c.originNamespace).Create(tpl)
if err != nil {
return nil, fmt.Errorf("error processing template %s/%s: %v", c.originNamespace, tpl.Name, err)
}
errs := runtime.DecodeList(result.Objects, kapi.Scheme)
if len(errs) > 0 {
err = errors.NewAggregate(errs)
return nil, fmt.Errorf("error processing template %s/%s: %v", c.originNamespace, tpl.Name, errs)
}
objects = append(objects, result.Objects...)
}
return objects, nil
}
示例2: injectUserVars
// injectUserVars injects user specified variables into the Template
func injectUserVars(values []string, out io.Writer, t *templateapi.Template) {
for _, keypair := range values {
p := strings.SplitN(keypair, "=", 2)
if len(p) != 2 {
fmt.Fprintf(out, "invalid parameter assignment in %q: %q\n", t.Name, keypair)
continue
}
if v := template.GetParameterByName(t, p[0]); v != nil {
v.Value = p[1]
v.Generate = ""
template.AddParameter(t, *v)
} else {
fmt.Fprintf(out, "unknown parameter name %q\n", p[0])
}
}
}
示例3: injectUserVars
// injectUserVars injects user specified variables into the Template
func injectUserVars(cmd *cobra.Command, t *api.Template) {
values := kcmdutil.GetFlagStringSlice(cmd, "value")
for _, keypair := range values {
p := strings.SplitN(keypair, "=", 2)
if len(p) != 2 {
fmt.Fprintf(cmd.Out(), "invalid parameter assignment in %q: %q\n", t.Name, keypair)
continue
}
if v := template.GetParameterByName(t, p[0]); v != nil {
v.Value = p[1]
v.Generate = ""
template.AddParameter(t, *v)
} else {
fmt.Fprintf(cmd.Out(), "unknown parameter name %q\n", p[0])
}
}
}
示例4: injectUserVars
// injectUserVars injects user specified variables into the Template
func injectUserVars(values []string, t *templateapi.Template) []error {
var errors []error
for _, keypair := range values {
p := strings.Split(keypair, "=")
if len(p) != 2 {
errors = append(errors, fmt.Errorf("invalid parameter assignment in %q: %q\n", t.Name, keypair))
}
if v := template.GetParameterByName(t, p[0]); v != nil {
v.Value = p[1]
v.Generate = ""
template.AddParameter(t, *v)
} else {
errors = append(errors, fmt.Errorf("unknown parameter name %q\n", p[0]))
}
}
return errors
}
示例5: substituteTemplateParameters
// substituteTemplateParameters injects user specified parameter values into the Template
func substituteTemplateParameters(params map[string]string, t *templateapi.Template) []error {
var errors []error
for name, value := range params {
if len(name) == 0 {
errors = append(errors, fmt.Errorf("template parameter name cannot be empty (%q)", value))
continue
}
if v := template.GetParameterByName(t, name); v != nil {
v.Value = value
v.Generate = ""
template.AddParameter(t, *v)
} else {
errors = append(errors, fmt.Errorf("unknown parameter %q specified for template", name))
}
}
return errors
}