Skip to content

Commit

Permalink
Add Metadata client (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
nabokihms authored May 5, 2023
1 parent 220474b commit 56b5524
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import (
fakedynamic "k8s.io/client-go/dynamic/fake"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/kubernetes/fake"
"k8s.io/client-go/metadata"
fakemetadata "k8s.io/client-go/metadata/fake"
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp" // load the gcp plugin (only required to authenticate against GKE clusters)
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
Expand Down Expand Up @@ -47,6 +49,7 @@ type Client interface {
DefaultNamespace() string
Dynamic() dynamic.Interface
ApiExt() apixv1client.ApiextensionsV1Interface
Metadata() metadata.Interface

APIResourceList(apiVersion string) ([]*metav1.APIResourceList, error)
APIResource(apiVersion, kind string) (*metav1.APIResource, error)
Expand All @@ -68,6 +71,7 @@ func NewFake(gvr map[schema.GroupVersionResource]string) Client {
Interface: fake.NewSimpleClientset(),
defaultNamespace: "default",
dynamicClient: fakedynamic.NewSimpleDynamicClientWithCustomListKinds(sc, gvr),
metadataClient: fakemetadata.NewSimpleMetadataClient(sc),
schema: sc,
}
}
Expand All @@ -82,6 +86,7 @@ type client struct {
defaultNamespace string
dynamicClient dynamic.Interface
apiExtClient apixv1client.ApiextensionsV1Interface
metadataClient metadata.Interface
qps float32
burst int
timeout time.Duration
Expand Down Expand Up @@ -137,6 +142,10 @@ func (c *client) ApiExt() apixv1client.ApiextensionsV1Interface {
return c.apiExtClient
}

func (c *client) Metadata() metadata.Interface {
return c.metadataClient
}

func (c *client) Init() error {
logEntry := log.WithField("operator.component", "KubernetesAPIClient")

Expand Down

0 comments on commit 56b5524

Please sign in to comment.