本文整理匯總了Golang中k8s/io/kubernetes/pkg/kubectl/cmd/util.MultipleErrors函數的典型用法代碼示例。如果您正苦於以下問題:Golang MultipleErrors函數的具體用法?Golang MultipleErrors怎麽用?Golang MultipleErrors使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了MultipleErrors函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Suggestion
// Suggestion is the usage error message returned when only a partial match is
// found.
func (e ErrPartialMatch) Suggestion(commandName string) string {
buf := &bytes.Buffer{}
fmt.Fprintf(buf, "* %s\n", e.Match.Description)
fmt.Fprintf(buf, " Use %[1]s to specify this image or template\n\n", e.Match.Argument)
return fmt.Sprintf(`%[3]s
The argument %[1]q only partially matched the following Docker image or OpenShift image stream:
%[2]s
`, e.Value, buf.String(), cmdutil.MultipleErrors("error: ", e.Errs))
}
示例2: Run
func (o *ExtractOptions) Run() error {
count := 0
contains := sets.NewString(o.OnlyKeys...)
err := o.VisitorFn(func(info *resource.Info, err error) error {
if err != nil {
return fmt.Errorf("%s: %v", name(info), err)
}
contents, ok, err := o.ExtractFileContentsFn(info.Object)
if err != nil {
return fmt.Errorf("%s: %v", name(info), err)
}
if !ok {
fmt.Fprintf(o.Err, "warning: %s does not support extraction\n", name(info))
return nil
}
count++
var errs []error
for k, v := range contents {
if contains.Len() == 0 || contains.Has(k) {
target := filepath.Join(o.TargetDirectory, k)
if err := writeToDisk(target, v, o.Overwrite, o.Out); err != nil {
if os.IsExist(err) {
err = fmt.Errorf("file exists, pass --confirm to overwrite")
}
errs = append(errs, fmt.Errorf("%s: %v", k, err))
}
}
}
if len(errs) > 0 {
return fmt.Errorf(kcmdutil.MultipleErrors("error: ", errs))
}
return nil
})
if err != nil {
return err
}
if count == 0 {
return fmt.Errorf("you must specify at least one resource to extract")
}
return nil
}
示例3: handleRunError
func handleRunError(err error, baseName, commandName, commandPath string) error {
if err == nil {
return nil
}
errs := []error{err}
if agg, ok := err.(errors.Aggregate); ok {
errs = agg.Errors()
}
groups := errorGroups{}
for _, err := range errs {
transformError(err, baseName, commandName, commandPath, groups)
}
buf := &bytes.Buffer{}
for _, group := range groups {
fmt.Fprint(buf, kcmdutil.MultipleErrors("error: ", group.errs))
if len(group.suggestion) > 0 {
fmt.Fprintln(buf)
}
fmt.Fprint(buf, group.suggestion)
}
return fmt.Errorf(buf.String())
}