/
crd.go
31 lines (25 loc) · 816 Bytes
/
crd.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package dao
import (
"context"
"github.com/kswapd/k13s/internal"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
)
var (
_ Accessor = (*CustomResourceDefinition)(nil)
_ Nuker = (*CustomResourceDefinition)(nil)
)
// CustomResourceDefinition represents a CRD resource model.
type CustomResourceDefinition struct {
Resource
}
// List returns a collection of nodes.
func (c *CustomResourceDefinition) List(ctx context.Context, _ string) ([]runtime.Object, error) {
strLabel, ok := ctx.Value(internal.KeyLabels).(string)
labelSel := labels.Everything()
if sel, e := labels.ConvertSelectorToLabelsMap(strLabel); ok && e == nil {
labelSel = sel.AsSelector()
}
const gvr = "apiextensions.k8s.io/v1/customresourcedefinitions"
return c.GetFactory().List(gvr, "-", false, labelSel)
}