Use admissionregistration/v1 client to fetch webhooks

* Do not fetch unused ComponentStatuses
sdas/webhooks-timeout-seconds
Varsha Varadarajan 2020-12-21 11:28:23 -08:00
parent a198e0364b
commit 95e7d57b51
6 changed files with 6 additions and 12 deletions

View File

@ -22,7 +22,7 @@ import (
"github.com/digitalocean/clusterlint/checks"
"github.com/digitalocean/clusterlint/kube"
"github.com/stretchr/testify/assert"
ar "k8s.io/api/admissionregistration/v1beta1"
ar "k8s.io/api/admissionregistration/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

View File

@ -19,7 +19,7 @@ package doks
import (
"github.com/digitalocean/clusterlint/checks"
"github.com/digitalocean/clusterlint/kube"
ar "k8s.io/api/admissionregistration/v1beta1"
ar "k8s.io/api/admissionregistration/v1"
corev1 "k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

View File

@ -22,7 +22,7 @@ import (
"github.com/digitalocean/clusterlint/checks"
"github.com/digitalocean/clusterlint/kube"
"github.com/stretchr/testify/assert"
ar "k8s.io/api/admissionregistration/v1beta1"
ar "k8s.io/api/admissionregistration/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

View File

@ -22,7 +22,7 @@ import (
"github.com/digitalocean/clusterlint/checks"
"github.com/digitalocean/clusterlint/kube"
"github.com/stretchr/testify/assert"
ar "k8s.io/api/admissionregistration/v1beta1"
ar "k8s.io/api/admissionregistration/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

View File

@ -20,7 +20,7 @@ import (
"context"
"golang.org/x/sync/errgroup"
ar "k8s.io/api/admissionregistration/v1beta1"
ar "k8s.io/api/admissionregistration/v1"
batchv1beta1 "k8s.io/api/batch/v1beta1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@ -42,7 +42,6 @@ type Identifier struct {
type Objects struct {
Nodes *corev1.NodeList
PersistentVolumes *corev1.PersistentVolumeList
ComponentStatuses *corev1.ComponentStatusList
SystemNamespace *corev1.Namespace
Pods *corev1.PodList
PodTemplates *corev1.PodTemplateList
@ -68,7 +67,7 @@ type Client struct {
// ctx is currently unused during API calls. More info: https://github.com/kubernetes/community/pull/1166
func (c *Client) FetchObjects(ctx context.Context, filter ObjectFilter) (*Objects, error) {
client := c.KubeClient.CoreV1()
admissionControllerClient := c.KubeClient.AdmissionregistrationV1beta1()
admissionControllerClient := c.KubeClient.AdmissionregistrationV1()
batchClient := c.KubeClient.BatchV1beta1()
opts := metav1.ListOptions{}
objects := &Objects{}
@ -82,10 +81,6 @@ func (c *Client) FetchObjects(ctx context.Context, filter ObjectFilter) (*Object
objects.PersistentVolumes, err = client.PersistentVolumes().List(gCtx, opts)
return
})
g.Go(func() (err error) {
objects.ComponentStatuses, err = client.ComponentStatuses().List(gCtx, opts)
return
})
g.Go(func() (err error) {
objects.Pods, err = client.Pods(corev1.NamespaceAll).List(gCtx, filter.NamespaceOptions(opts))
return

View File

@ -45,7 +45,6 @@ func TestFetchObjects(t *testing.T) {
assert.NotNil(t, actual.Nodes)
assert.NotNil(t, actual.PersistentVolumes)
assert.NotNil(t, actual.ComponentStatuses)
assert.NotNil(t, actual.Pods)
assert.NotNil(t, actual.PodTemplates)
assert.NotNil(t, actual.PersistentVolumeClaims)