本文整理汇总了Golang中github.com/ttysteale/kubernetes-api/kubectl/cmd/util.Factory.HistoryViewer方法的典型用法代码示例。如果您正苦于以下问题:Golang Factory.HistoryViewer方法的具体用法?Golang Factory.HistoryViewer怎么用?Golang Factory.HistoryViewer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/ttysteale/kubernetes-api/kubectl/cmd/util.Factory
的用法示例。
在下文中一共展示了Factory.HistoryViewer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: RunHistory
func RunHistory(f *cmdutil.Factory, cmd *cobra.Command, out io.Writer, args []string, options *HistoryOptions) error {
if len(args) == 0 && len(options.Filenames) == 0 {
return cmdutil.UsageError(cmd, "Required resource not specified.")
}
revisionDetail := cmdutil.GetFlagInt64(cmd, "revision")
mapper, typer := f.Object(false)
cmdNamespace, enforceNamespace, err := f.DefaultNamespace()
if err != nil {
return err
}
r := resource.NewBuilder(mapper, typer, resource.ClientMapperFunc(f.ClientForMapping), f.Decoder(true)).
NamespaceParam(cmdNamespace).DefaultNamespace().
FilenameParam(enforceNamespace, options.Recursive, options.Filenames...).
ResourceTypeOrNameArgs(true, args...).
ContinueOnError().
Latest().
Flatten().
Do()
err = r.Err()
if err != nil {
return err
}
err = r.Visit(func(info *resource.Info, err error) error {
if err != nil {
return err
}
mapping := info.ResourceMapping()
historyViewer, err := f.HistoryViewer(mapping)
if err != nil {
return err
}
historyInfo, err := historyViewer.History(info.Namespace, info.Name)
if err != nil {
return err
}
if revisionDetail > 0 {
// Print details of a specific revision
template, ok := historyInfo.RevisionToTemplate[revisionDetail]
if !ok {
return fmt.Errorf("unable to find revision %d of %s %q", revisionDetail, mapping.Resource, info.Name)
}
fmt.Fprintf(out, "%s %q revision %d\n", mapping.Resource, info.Name, revisionDetail)
kubectl.DescribePodTemplate(template, out)
} else {
// Print all revisions
formattedOutput, printErr := kubectl.PrintRolloutHistory(historyInfo, mapping.Resource, info.Name)
if printErr != nil {
return printErr
}
fmt.Fprintf(out, "%s\n", formattedOutput)
}
return nil
})
return err
}