本文整理汇总了Golang中k8s/io/kubernetes/pkg/kubectl.IsNoSuchReaperError函数的典型用法代码示例。如果您正苦于以下问题:Golang IsNoSuchReaperError函数的具体用法?Golang IsNoSuchReaperError怎么用?Golang IsNoSuchReaperError使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IsNoSuchReaperError函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: ReapResult
func ReapResult(r *resource.Result, f *cmdutil.Factory, out io.Writer, isDefaultDelete, ignoreNotFound bool, timeout time.Duration, gracePeriod int, shortOutput bool, mapper meta.RESTMapper) error {
found := 0
if ignoreNotFound {
r = r.IgnoreErrors(errors.IsNotFound)
}
err := r.Visit(func(info *resource.Info) error {
found++
reaper, err := f.Reaper(info.Mapping)
if err != nil {
// If there is no reaper for this resources and the user didn't explicitly ask for stop.
if kubectl.IsNoSuchReaperError(err) && isDefaultDelete {
return deleteResource(info, out, shortOutput, mapper)
}
return cmdutil.AddSourceToErr("reaping", info.Source, err)
}
var options *api.DeleteOptions
if gracePeriod >= 0 {
options = api.NewDeleteOptions(int64(gracePeriod))
}
if _, err := reaper.Stop(info.Namespace, info.Name, timeout, options); err != nil {
return cmdutil.AddSourceToErr("stopping", info.Source, err)
}
cmdutil.PrintSuccess(mapper, shortOutput, out, info.Mapping.Resource, info.Name, "deleted")
return nil
})
if err != nil {
return err
}
if found == 0 {
fmt.Fprintf(out, "No resources found\n")
}
return nil
}
示例2: Reaper
func (f *ring1Factory) Reaper(mapping *meta.RESTMapping) (kubectl.Reaper, error) {
mappingVersion := mapping.GroupVersionKind.GroupVersion()
clientset, clientsetErr := f.clientAccessFactory.ClientSetForVersion(&mappingVersion)
reaper, reaperErr := kubectl.ReaperFor(mapping.GroupVersionKind.GroupKind(), clientset)
if kubectl.IsNoSuchReaperError(reaperErr) {
return nil, reaperErr
}
if clientsetErr != nil {
return nil, clientsetErr
}
return reaper, reaperErr
}
示例3: deleteResourcesBySelect
func (c *Context) deleteResourcesBySelect(fn selectFunc) error {
factory, err := c.Factory()
if err != nil {
return err
}
namespace, err := c.Namespace()
if err != nil {
return err
}
mapper, typer := factory.Object()
clientMapper := factory.ClientMapperForCommand()
r := fn(
resource.
NewBuilder(mapper, typer, clientMapper).
ContinueOnError().
NamespaceParam(namespace).DefaultNamespace().
FilenameParam(true).
ResourceTypeOrNameArgs(false, "template,buildconfig,build,imagestream,deploymentconfig,replicationcontroller,pod,service,route,pvc").
RequireObject(false)).
Flatten().
Do()
if err = r.Err(); err != nil {
return err
}
return r.Visit(func(info *resource.Info, err error) error {
if err != nil {
return err
}
reaper, err := factory.Reaper(info.Mapping)
if err != nil {
if kubectl.IsNoSuchReaperError(err) {
return resource.NewHelper(info.Client, info.Mapping).Delete(info.Namespace, info.Name)
}
return err
}
_, err = reaper.Stop(info.Namespace, info.Name, 5*time.Second, api.NewDeleteOptions(int64(0)))
return err
})
}
示例4: Delete
// Delete deletes kubernetes resources from an io.reader
//
// Namespace will set the namespace
func (c *Client) Delete(namespace string, reader io.Reader) error {
return perform(c, namespace, reader, func(info *resource.Info) error {
log.Printf("Starting delete for %s %s", info.Name, info.Mapping.GroupVersionKind.Kind)
reaper, err := c.Reaper(info.Mapping)
if err != nil {
// If there is no reaper for this resources, delete it.
if kubectl.IsNoSuchReaperError(err) {
err := resource.NewHelper(info.Client, info.Mapping).Delete(info.Namespace, info.Name)
return skipIfNotFound(err)
}
return err
}
log.Printf("Using reaper for deleting %s", info.Name)
err = reaper.Stop(info.Namespace, info.Name, 0, nil)
return skipIfNotFound(err)
})
}