1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2024-12-14 11:57:48 +00:00

chore: make kube informers and listers import aliases consistent (#3957)

* chore: make kyverno api import aliases consistent

Signed-off-by: Charles-Edouard Brétéché <charled.breteche@gmail.com>

* chore: make apimachinery api import aliases consistent

Signed-off-by: Charles-Edouard Brétéché <charled.breteche@gmail.com>

* chore: make dclient api import aliases consistent

Signed-off-by: Charles-Edouard Brétéché <charled.breteche@gmail.com>

* chore: make clients import aliases consistent

Signed-off-by: Charles-Edouard Brétéché <charled.breteche@gmail.com>

* chore: make kube informers and listers import aliases consistent

Signed-off-by: Charles-Edouard Brétéché <charled.breteche@gmail.com>
This commit is contained in:
Charles-Edouard Brétéché 2022-05-17 17:51:03 +02:00 committed by GitHub
parent a6d4cd186d
commit 572a76ce33
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 67 additions and 63 deletions

View file

@ -59,3 +59,7 @@ linters-settings:
alias: kyvernoclient
- pkg: k8s.io/client-go/kubernetes
alias: kubernetes
- pkg: k8s.io/client-go/informers/(\w+)/(v[\w\d]+)
alias: ${1}${2}informers
- pkg: k8s.io/client-go/listers/(\w+)/(v[\w\d]+)
alias: ${1}${2}listers

View file

@ -18,9 +18,9 @@ import (
"k8s.io/apimachinery/pkg/labels"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/apimachinery/pkg/util/wait"
coreinformers "k8s.io/client-go/informers/core/v1"
corev1informers "k8s.io/client-go/informers/core/v1"
"k8s.io/client-go/kubernetes"
corelister "k8s.io/client-go/listers/core/v1"
corev1listers "k8s.io/client-go/listers/core/v1"
"k8s.io/client-go/tools/cache"
"k8s.io/client-go/util/workqueue"
)
@ -56,7 +56,7 @@ type Controller struct {
urLister urkyvernolister.UpdateRequestNamespaceLister
// nsLister can list/get namespaces from the shared informer's store
nsLister corelister.NamespaceLister
nsLister corev1listers.NamespaceLister
// logger
log logr.Logger
@ -70,7 +70,7 @@ func NewController(
pInformer kyvernoinformer.ClusterPolicyInformer,
npInformer kyvernoinformer.PolicyInformer,
urInformer urkyvernoinformer.UpdateRequestInformer,
namespaceInformer coreinformers.NamespaceInformer,
namespaceInformer corev1informers.NamespaceInformer,
log logr.Logger,
) (*Controller, error) {
c := Controller{

View file

@ -32,7 +32,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/labels"
corelister "k8s.io/client-go/listers/core/v1"
corev1listers "k8s.io/client-go/listers/core/v1"
"k8s.io/client-go/tools/cache"
)
@ -55,7 +55,7 @@ type GenerateController struct {
urLister urlister.UpdateRequestNamespaceLister
// nsLister can list/get namespaces from the shared informer's store
nsLister corelister.NamespaceLister
nsLister corev1listers.NamespaceLister
// policyLister can list/get cluster policy from the shared informer's store
policyLister kyvernolister.ClusterPolicyLister
@ -74,7 +74,7 @@ func NewGenerateController(
npolicyLister kyvernolister.PolicyLister,
urLister urlister.UpdateRequestNamespaceLister,
eventGen event.Interface,
nsLister corelister.NamespaceLister,
nsLister corev1listers.NamespaceLister,
log logr.Logger,
dynamicConfig config.Configuration,
) (*GenerateController, error) {

View file

@ -22,9 +22,9 @@ import (
apierrors "k8s.io/apimachinery/pkg/api/errors"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/apimachinery/pkg/util/wait"
coreinformers "k8s.io/client-go/informers/core/v1"
corev1informers "k8s.io/client-go/informers/core/v1"
"k8s.io/client-go/kubernetes"
corelister "k8s.io/client-go/listers/core/v1"
corev1listers "k8s.io/client-go/listers/core/v1"
"k8s.io/client-go/tools/cache"
"k8s.io/client-go/util/workqueue"
)
@ -62,7 +62,7 @@ type Controller struct {
urLister urlister.UpdateRequestNamespaceLister
// nsLister can list/get namespaces from the shared informer's store
nsLister corelister.NamespaceLister
nsLister corev1listers.NamespaceLister
log logr.Logger
@ -78,7 +78,7 @@ func NewController(
npolicyInformer kyvernoinformer.PolicyInformer,
urInformer urkyvernoinformer.UpdateRequestInformer,
eventGen event.Interface,
namespaceInformer coreinformers.NamespaceInformer,
namespaceInformer corev1informers.NamespaceInformer,
log logr.Logger,
dynamicConfig config.Configuration,
) (*Controller, error) {

View file

@ -14,7 +14,7 @@ import (
"github.com/pkg/errors"
corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
listerv1 "k8s.io/client-go/listers/core/v1"
corev1listers "k8s.io/client-go/listers/core/v1"
"sigs.k8s.io/controller-runtime/pkg/log"
)
@ -25,7 +25,7 @@ const (
)
// GetNamespaceSelectorsFromNamespaceLister - extract the namespacelabels when namespace lister is passed
func GetNamespaceSelectorsFromNamespaceLister(kind, namespaceOfResource string, nsLister listerv1.NamespaceLister, logger logr.Logger) map[string]string {
func GetNamespaceSelectorsFromNamespaceLister(kind, namespaceOfResource string, nsLister corev1listers.NamespaceLister, logger logr.Logger) map[string]string {
namespaceLabels := make(map[string]string)
if kind != "Namespace" && namespaceOfResource != "" {
namespaceObj, err := nsLister.Get(namespaceOfResource)

View file

@ -9,8 +9,8 @@ import (
"github.com/kyverno/kyverno/pkg/config"
"github.com/kyverno/kyverno/pkg/tls"
corev1 "k8s.io/api/core/v1"
informerv1 "k8s.io/client-go/informers/core/v1"
listersv1 "k8s.io/client-go/listers/core/v1"
corev1informers "k8s.io/client-go/informers/core/v1"
corev1listers "k8s.io/client-go/listers/core/v1"
"k8s.io/client-go/tools/cache"
)
@ -24,12 +24,12 @@ type Controller interface {
type controller struct {
renewer *tls.CertRenewer
secretLister listersv1.SecretLister
secretLister corev1listers.SecretLister
secretQueue chan bool
onSecretChanged func() error
}
func NewController(secretInformer informerv1.SecretInformer, certRenewer *tls.CertRenewer, onSecretChanged func() error) (Controller, error) {
func NewController(secretInformer corev1informers.SecretInformer, certRenewer *tls.CertRenewer, onSecretChanged func() error) (Controller, error) {
manager := &controller{
renewer: certRenewer,
secretLister: secretInformer.Lister(),

View file

@ -32,10 +32,10 @@ import (
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/apimachinery/pkg/util/wait"
informers "k8s.io/client-go/informers/core/v1"
corev1informers "k8s.io/client-go/informers/core/v1"
"k8s.io/client-go/kubernetes"
typedcorev1 "k8s.io/client-go/kubernetes/typed/core/v1"
listerv1 "k8s.io/client-go/listers/core/v1"
corev1listers "k8s.io/client-go/listers/core/v1"
"k8s.io/client-go/tools/cache"
"k8s.io/client-go/tools/record"
"k8s.io/client-go/util/workqueue"
@ -74,7 +74,7 @@ type PolicyController struct {
urLister urkyvernolister.UpdateRequestLister
// nsLister can list/get namespaces from the shared informer's store
nsLister listerv1.NamespaceLister
nsLister corev1listers.NamespaceLister
// Resource manager, manages the mapping for already processed resource
rm resourceManager
@ -106,7 +106,7 @@ func NewPolicyController(
eventGen event.Interface,
prGenerator policyreport.GeneratorInterface,
policyReportEraser policyreport.PolicyReportEraser,
namespaces informers.NamespaceInformer,
namespaces corev1informers.NamespaceInformer,
log logr.Logger,
reconcilePeriod time.Duration,
promConfig *metrics.PromConfig,

View file

@ -28,8 +28,8 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/apimachinery/pkg/util/wait"
informers "k8s.io/client-go/informers/core/v1"
listerv1 "k8s.io/client-go/listers/core/v1"
corev1informers "k8s.io/client-go/informers/core/v1"
corev1listers "k8s.io/client-go/listers/core/v1"
"k8s.io/client-go/tools/cache"
"k8s.io/client-go/util/workqueue"
)
@ -62,7 +62,7 @@ type ReportGenerator struct {
clusterReportLister policyreport.ClusterPolicyReportLister
reportChangeRequestLister requestlister.ReportChangeRequestLister
clusterReportChangeRequestLister requestlister.ClusterReportChangeRequestLister
nsLister listerv1.NamespaceLister
nsLister corev1listers.NamespaceLister
queue workqueue.RateLimitingInterface
@ -81,7 +81,7 @@ func NewReportGenerator(
reportInformer policyreportinformer.PolicyReportInformer,
reportReqInformer requestinformer.ReportChangeRequestInformer,
clusterReportReqInformer requestinformer.ClusterReportChangeRequestInformer,
namespace informers.NamespaceInformer,
namespace corev1informers.NamespaceInformer,
log logr.Logger,
) (*ReportGenerator, error) {
gen := &ReportGenerator{

View file

@ -10,7 +10,7 @@ import (
authenticationv1 "k8s.io/api/authentication/v1"
rbacv1 "k8s.io/api/rbac/v1"
labels "k8s.io/apimachinery/pkg/labels"
rbaclister "k8s.io/client-go/listers/rbac/v1"
rbacv1listers "k8s.io/client-go/listers/rbac/v1"
"sigs.k8s.io/controller-runtime/pkg/log"
)
@ -22,7 +22,7 @@ const (
)
// GetRoleRef gets the list of roles and cluster roles for the incoming api-request
func GetRoleRef(rbLister rbaclister.RoleBindingLister, crbLister rbaclister.ClusterRoleBindingLister, request *admissionv1.AdmissionRequest, dynamicConfig config.Configuration) ([]string, []string, error) {
func GetRoleRef(rbLister rbacv1listers.RoleBindingLister, crbLister rbacv1listers.ClusterRoleBindingLister, request *admissionv1.AdmissionRequest, dynamicConfig config.Configuration) ([]string, []string, error) {
keys := append(request.UserInfo.Groups, request.UserInfo.Username)
if utils.SliceContains(keys, dynamicConfig.GetExcludeGroupRole()...) {
return nil, nil, nil

View file

@ -26,9 +26,9 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/apimachinery/pkg/util/sets"
adminformers "k8s.io/client-go/informers/admissionregistration/v1"
admissionregistrationv1informers "k8s.io/client-go/informers/admissionregistration/v1"
"k8s.io/client-go/kubernetes"
admlisters "k8s.io/client-go/listers/admissionregistration/v1"
admissionregistrationv1listers "k8s.io/client-go/listers/admissionregistration/v1"
"k8s.io/client-go/tools/cache"
"k8s.io/client-go/util/workqueue"
)
@ -46,14 +46,14 @@ type webhookConfigManager struct {
// informers
pInformer kyvernoinformer.ClusterPolicyInformer
npInformer kyvernoinformer.PolicyInformer
mutateInformer adminformers.MutatingWebhookConfigurationInformer
validateInformer adminformers.ValidatingWebhookConfigurationInformer
mutateInformer admissionregistrationv1informers.MutatingWebhookConfigurationInformer
validateInformer admissionregistrationv1informers.ValidatingWebhookConfigurationInformer
// listers
pLister kyvernolister.ClusterPolicyLister
npLister kyvernolister.PolicyLister
mutateLister admlisters.MutatingWebhookConfigurationLister
validateLister admlisters.ValidatingWebhookConfigurationLister
mutateLister admissionregistrationv1listers.MutatingWebhookConfigurationLister
validateLister admissionregistrationv1listers.ValidatingWebhookConfigurationLister
// queue
queue workqueue.RateLimitingInterface
@ -82,8 +82,8 @@ func newWebhookConfigManager(
kyvernoClient kyvernoclient.Interface,
pInformer kyvernoinformer.ClusterPolicyInformer,
npInformer kyvernoinformer.PolicyInformer,
mwcInformer adminformers.MutatingWebhookConfigurationInformer,
vwcInformer adminformers.ValidatingWebhookConfigurationInformer,
mwcInformer admissionregistrationv1informers.MutatingWebhookConfigurationInformer,
vwcInformer admissionregistrationv1informers.ValidatingWebhookConfigurationInformer,
serverIP string,
autoUpdateWebhooks bool,
createDefaultWebhook chan<- string,

View file

@ -19,11 +19,11 @@ import (
admissionregistrationv1 "k8s.io/api/admissionregistration/v1"
errorsapi "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
adminformers "k8s.io/client-go/informers/admissionregistration/v1"
informers "k8s.io/client-go/informers/apps/v1"
admissionregistrationv1informers "k8s.io/client-go/informers/admissionregistration/v1"
appsv1informers "k8s.io/client-go/informers/apps/v1"
"k8s.io/client-go/kubernetes"
admlisters "k8s.io/client-go/listers/admissionregistration/v1"
listers "k8s.io/client-go/listers/apps/v1"
admissionregistrationv1listers "k8s.io/client-go/listers/admissionregistration/v1"
appsv1listers "k8s.io/client-go/listers/apps/v1"
rest "k8s.io/client-go/rest"
)
@ -44,9 +44,9 @@ type Register struct {
clientConfig *rest.Config
// listers
mwcLister admlisters.MutatingWebhookConfigurationLister
vwcLister admlisters.ValidatingWebhookConfigurationLister
kDeplLister listers.DeploymentLister
mwcLister admissionregistrationv1listers.MutatingWebhookConfigurationLister
vwcLister admissionregistrationv1listers.ValidatingWebhookConfigurationLister
kDeplLister appsv1listers.DeploymentLister
// channels
stopCh <-chan struct{}
@ -69,9 +69,9 @@ func NewRegister(
client dclient.Interface,
kubeClient kubernetes.Interface,
kyvernoClient kyvernoclient.Interface,
mwcInformer adminformers.MutatingWebhookConfigurationInformer,
vwcInformer adminformers.ValidatingWebhookConfigurationInformer,
kDeplInformer informers.DeploymentInformer,
mwcInformer admissionregistrationv1informers.MutatingWebhookConfigurationInformer,
vwcInformer admissionregistrationv1informers.ValidatingWebhookConfigurationInformer,
kDeplInformer appsv1informers.DeploymentInformer,
pInformer kyvernoinformer.ClusterPolicyInformer,
npInformer kyvernoinformer.PolicyInformer,
serverIP string,

View file

@ -34,8 +34,8 @@ import (
admissionv1 "k8s.io/api/admission/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
corelister "k8s.io/client-go/listers/core/v1"
rbaclister "k8s.io/client-go/listers/rbac/v1"
corev1listers "k8s.io/client-go/listers/core/v1"
rbacv1listers "k8s.io/client-go/listers/rbac/v1"
)
type handlers struct {
@ -51,9 +51,9 @@ type handlers struct {
pCache policycache.Cache
// listers
nsLister corelister.NamespaceLister
rbLister rbaclister.RoleBindingLister
crbLister rbaclister.ClusterRoleBindingLister
nsLister corev1listers.NamespaceLister
rbLister rbacv1listers.RoleBindingLister
crbLister rbacv1listers.ClusterRoleBindingLister
urLister urlister.UpdateRequestNamespaceLister
prGenerator policyreport.GeneratorInterface
@ -70,9 +70,9 @@ func NewHandlers(
configuration config.Configuration,
promConfig *metrics.PromConfig,
pCache policycache.Cache,
nsLister corelister.NamespaceLister,
rbLister rbaclister.RoleBindingLister,
crbLister rbaclister.ClusterRoleBindingLister,
nsLister corev1listers.NamespaceLister,
rbLister rbacv1listers.RoleBindingLister,
crbLister rbacv1listers.ClusterRoleBindingLister,
urLister urlister.UpdateRequestNamespaceLister,
prGenerator policyreport.GeneratorInterface,
urGenerator webhookgenerate.Interface,

View file

@ -20,10 +20,10 @@ import (
admissionv1 "k8s.io/api/admission/v1"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/apimachinery/pkg/util/wait"
informers "k8s.io/client-go/informers/core/v1"
rbacinformer "k8s.io/client-go/informers/rbac/v1"
listerv1 "k8s.io/client-go/listers/core/v1"
rbaclister "k8s.io/client-go/listers/rbac/v1"
corev1informers "k8s.io/client-go/informers/core/v1"
rbacv1informers "k8s.io/client-go/informers/rbac/v1"
corev1listers "k8s.io/client-go/listers/core/v1"
rbacv1listers "k8s.io/client-go/listers/rbac/v1"
"k8s.io/client-go/util/workqueue"
)
@ -48,9 +48,9 @@ type auditHandler struct {
eventGen event.Interface
prGenerator policyreport.GeneratorInterface
rbLister rbaclister.RoleBindingLister
crbLister rbaclister.ClusterRoleBindingLister
nsLister listerv1.NamespaceLister
rbLister rbacv1listers.RoleBindingLister
crbLister rbacv1listers.ClusterRoleBindingLister
nsLister corev1listers.NamespaceLister
log logr.Logger
configHandler config.Configuration
@ -61,9 +61,9 @@ type auditHandler struct {
func NewValidateAuditHandler(pCache policycache.Cache,
eventGen event.Interface,
prGenerator policyreport.GeneratorInterface,
rbInformer rbacinformer.RoleBindingInformer,
crbInformer rbacinformer.ClusterRoleBindingInformer,
namespaces informers.NamespaceInformer,
rbInformer rbacv1informers.RoleBindingInformer,
crbInformer rbacv1informers.ClusterRoleBindingInformer,
namespaces corev1informers.NamespaceInformer,
log logr.Logger,
dynamicConfig config.Configuration,
client dclient.Interface,