From 310757829b6d97508aae3f3a12e5d54535d4dd02 Mon Sep 17 00:00:00 2001 From: ajanikow <12255597+ajanikow@users.noreply.github.com> Date: Thu, 14 Jul 2022 16:19:11 +0000 Subject: [PATCH] [Linter] [Imports] Standardize k8s.io/api/apps/v1 --- .golangci.yaml | 2 ++ cmd/cmd.go | 4 ++-- pkg/util/k8sutil/owner.go | 6 +++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index 48f1b35ad..13d2b2a34 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -36,6 +36,8 @@ linters-settings: alias: meta - pkg: k8s.io/client-go/kubernetes/typed/core/v1 alias: typedCore + - pkg: k8s.io/api/apps/v1 + alias: apps gci: sections: - standard diff --git a/cmd/cmd.go b/cmd/cmd.go index 986bff05a..e312ee8ed 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -36,7 +36,7 @@ import ( "github.com/rs/zerolog" "github.com/spf13/cobra" flag "github.com/spf13/pflag" - appsv1 "k8s.io/api/apps/v1" + apps "k8s.io/api/apps/v1" core "k8s.io/api/core/v1" meta "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" @@ -476,6 +476,6 @@ func createRecorder(kubecli kubernetes.Interface, name, namespace string) record combinedScheme := runtime.NewScheme() scheme.AddToScheme(combinedScheme) core.AddToScheme(combinedScheme) - appsv1.AddToScheme(combinedScheme) + apps.AddToScheme(combinedScheme) return eventBroadcaster.NewRecorder(combinedScheme, core.EventSource{Component: name}) } diff --git a/pkg/util/k8sutil/owner.go b/pkg/util/k8sutil/owner.go index 1a76bf713..97c21eb2a 100644 --- a/pkg/util/k8sutil/owner.go +++ b/pkg/util/k8sutil/owner.go @@ -23,7 +23,7 @@ package k8sutil import ( "context" - appsv1 "k8s.io/api/apps/v1" + apps "k8s.io/api/apps/v1" core "k8s.io/api/core/v1" meta "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes" @@ -33,7 +33,7 @@ import ( // GetPodOwner returns the ReplicaSet that owns the given Pod. // If the Pod has no owner of the owner is not a ReplicaSet, nil is returned. -func GetPodOwner(kubecli kubernetes.Interface, pod *core.Pod, ns string) (*appsv1.ReplicaSet, error) { +func GetPodOwner(kubecli kubernetes.Interface, pod *core.Pod, ns string) (*apps.ReplicaSet, error) { for _, ref := range pod.GetOwnerReferences() { if ref.Kind == "ReplicaSet" { rSets := kubecli.AppsV1().ReplicaSets(pod.GetNamespace()) @@ -49,7 +49,7 @@ func GetPodOwner(kubecli kubernetes.Interface, pod *core.Pod, ns string) (*appsv // GetReplicaSetOwner returns the Deployment that owns the given ReplicaSet. // If the ReplicaSet has no owner of the owner is not a Deployment, nil is returned. -func GetReplicaSetOwner(kubecli kubernetes.Interface, rSet *appsv1.ReplicaSet, ns string) (*appsv1.Deployment, error) { +func GetReplicaSetOwner(kubecli kubernetes.Interface, rSet *apps.ReplicaSet, ns string) (*apps.Deployment, error) { for _, ref := range rSet.GetOwnerReferences() { if ref.Kind == "Deployment" { depls := kubecli.AppsV1().Deployments(rSet.GetNamespace())