本文整理汇总了Golang中k8s/io/kubernetes/pkg/client/unversioned.Interface.ResourceQuotas方法的典型用法代码示例。如果您正苦于以下问题:Golang Interface.ResourceQuotas方法的具体用法?Golang Interface.ResourceQuotas怎么用?Golang Interface.ResourceQuotas使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类k8s/io/kubernetes/pkg/client/unversioned.Interface
的用法示例。
在下文中一共展示了Interface.ResourceQuotas方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: formatImageStreamQuota
func formatImageStreamQuota(out *tabwriter.Writer, c client.Interface, kc kclient.Interface, stream *imageapi.ImageStream) {
quotas, err := kc.ResourceQuotas(stream.Namespace).List(api.ListOptions{})
if err != nil {
return
}
var limit *resource.Quantity
for _, item := range quotas.Items {
// search for smallest ImageStream quota
if value, ok := item.Spec.Hard[imageapi.ResourceImageStreamSize]; ok {
if limit == nil || limit.Cmp(value) > 0 {
limit = &value
}
}
}
if limit != nil {
quantity := imagequota.GetImageStreamSize(c, stream, make(map[string]*imageapi.Image))
scale := mega
if quantity.Value() >= (1<<giga.scale) || limit.Value() >= (1<<giga.scale) {
scale = giga
}
formatString(out, "Quota Usage", fmt.Sprintf("%s / %s",
formatQuantity(quantity, scale), formatQuantity(limit, scale)))
}
}
示例2: deleteResourceQuotas
func deleteResourceQuotas(kubeClient client.Interface, ns string) error {
resourceQuotas, err := kubeClient.ResourceQuotas(ns).List(unversioned.ListOptions{})
if err != nil {
return err
}
for i := range resourceQuotas.Items {
err := kubeClient.ResourceQuotas(ns).Delete(resourceQuotas.Items[i].Name)
if err != nil && !errors.IsNotFound(err) {
return err
}
}
return nil
}
示例3: deleteResourceQuotas
func deleteResourceQuotas(kubeClient client.Interface, ns string) error {
resourceQuotas, err := kubeClient.ResourceQuotas(ns).List(labels.Everything(), fields.Everything())
if err != nil {
return err
}
for i := range resourceQuotas.Items {
err := kubeClient.ResourceQuotas(ns).Delete(resourceQuotas.Items[i].Name)
if err != nil && !errors.IsNotFound(err) {
return err
}
}
return nil
}
示例4: NewResourceQuota
// NewResourceQuota creates a new resource quota admission control handler
func NewResourceQuota(client client.Interface) admission.Interface {
lw := &cache.ListWatch{
ListFunc: func() (runtime.Object, error) {
return client.ResourceQuotas(api.NamespaceAll).List(labels.Everything(), fields.Everything())
},
WatchFunc: func(resourceVersion string) (watch.Interface, error) {
return client.ResourceQuotas(api.NamespaceAll).Watch(labels.Everything(), fields.Everything(), resourceVersion)
},
}
indexer, reflector := cache.NewNamespaceKeyedIndexerAndReflector(lw, &api.ResourceQuota{}, 0)
reflector.Run()
return createResourceQuota(client, indexer)
}
示例5: NewResourceQuota
// NewResourceQuota creates a new resource quota admission control handler
func NewResourceQuota(client client.Interface) admission.Interface {
lw := &cache.ListWatch{
ListFunc: func() (runtime.Object, error) {
return client.ResourceQuotas(api.NamespaceAll).List(unversioned.ListOptions{})
},
WatchFunc: func(options unversioned.ListOptions) (watch.Interface, error) {
return client.ResourceQuotas(api.NamespaceAll).Watch(options)
},
}
indexer, reflector := cache.NewNamespaceKeyedIndexerAndReflector(lw, &api.ResourceQuota{}, 0)
reflector.Run()
return createResourceQuota(client, indexer)
}