From 9cb2cf4baeee2e136df62f7122b103e331574622 Mon Sep 17 00:00:00 2001 From: rcmadhankumar Date: Wed, 17 Jan 2024 17:34:47 +0530 Subject: [PATCH] Logger changed Signed-off-by: rcmadhankumar --- .../datapackaging/package_crd_rest_test.go | 53 ++++--------------- 1 file changed, 11 insertions(+), 42 deletions(-) diff --git a/pkg/apiserver/registry/datapackaging/package_crd_rest_test.go b/pkg/apiserver/registry/datapackaging/package_crd_rest_test.go index 4444a6bc83..86aae8875f 100644 --- a/pkg/apiserver/registry/datapackaging/package_crd_rest_test.go +++ b/pkg/apiserver/registry/datapackaging/package_crd_rest_test.go @@ -21,9 +21,7 @@ import ( "k8s.io/apimachinery/pkg/runtime" k8sfake "k8s.io/client-go/kubernetes/fake" cgtesting "k8s.io/client-go/testing" - "k8s.io/klog/v2" logf "sigs.k8s.io/controller-runtime/pkg/log" - "sigs.k8s.io/controller-runtime/pkg/log/zap" ) const globalNamespace = "global.packaging.kapp-controller.carvel.dev" @@ -35,10 +33,7 @@ func TestPackageVersionListIncludesGlobalAndNamespaced(t *testing.T) { internalClient := fake.NewSimpleClientset(globalIntPackageVersion(), namespacedIntPackageVersion(), excludedNonGlobalIntPackageVersion()) fakeCoreClient := k8sfake.NewSimpleClientset(namespace()) - log := zap.New(zap.UseDevMode(false)).WithName("package_crd_rest_test") - logf.SetLogger(log) - klog.SetLogger(log) - pkgvCRDREST := datapkgreg.NewPackageCRDREST(internalClient, fakeCoreClient, globalNamespace, log) + pkgvCRDREST := datapkgreg.NewPackageCRDREST(internalClient, fakeCoreClient, globalNamespace, logf.Log) pkgvList, err := pkgvCRDREST.List(namespacedCtx(nonGlobalNamespace), &internalversion.ListOptions{}) if err != nil { @@ -73,10 +68,7 @@ func TestPackageVersionListPrefersNamespacedOverGlobal(t *testing.T) { internalClient := fake.NewSimpleClientset(globalIntPackageVersion(), overrideIntPackageVersion()) fakeCoreClient := k8sfake.NewSimpleClientset(namespace()) - log := zap.New(zap.UseDevMode(false)).WithName("package_crd_rest_test") - logf.SetLogger(log) - klog.SetLogger(log) - pkgvCRDREST := datapkgreg.NewPackageCRDREST(internalClient, fakeCoreClient, globalNamespace, log) + pkgvCRDREST := datapkgreg.NewPackageCRDREST(internalClient, fakeCoreClient, globalNamespace, logf.Log) // list package versions and verify all of them are there pkgvList, err := pkgvCRDREST.List(namespacedCtx(nonGlobalNamespace), &internalversion.ListOptions{}) @@ -111,10 +103,7 @@ func TestPackageVersionGetNotPresentInNS(t *testing.T) { internalClient := fake.NewSimpleClientset(globalPackageVersion) fakeCoreClient := k8sfake.NewSimpleClientset(namespace()) - log := zap.New(zap.UseDevMode(false)).WithName("package_crd_rest_test") - logf.SetLogger(log) - klog.SetLogger(log) - pkgvCRDREST := datapkgreg.NewPackageCRDREST(internalClient, fakeCoreClient, globalNamespace, log) + pkgvCRDREST := datapkgreg.NewPackageCRDREST(internalClient, fakeCoreClient, globalNamespace, logf.Log) obj, err := pkgvCRDREST.Get(namespacedCtx(nonGlobalNamespace), name, &metav1.GetOptions{}) if err != nil { @@ -139,10 +128,7 @@ func TestPackageVersionGetPresentInOnlyNS(t *testing.T) { internalClient := fake.NewSimpleClientset(namespacedPackageVersion) fakeCoreClient := k8sfake.NewSimpleClientset(namespace()) - log := zap.New(zap.UseDevMode(false)).WithName("package_crd_rest_test") - logf.SetLogger(log) - klog.SetLogger(log) - pkgvCRDREST := datapkgreg.NewPackageCRDREST(internalClient, fakeCoreClient, globalNamespace, log) + pkgvCRDREST := datapkgreg.NewPackageCRDREST(internalClient, fakeCoreClient, globalNamespace, logf.Log) obj, err := pkgvCRDREST.Get(namespacedCtx(nonGlobalNamespace), name, &metav1.GetOptions{}) if err != nil { @@ -166,10 +152,8 @@ func TestPackageVersionGetNotFound(t *testing.T) { internalClient := fake.NewSimpleClientset(namespacedPackageVersion) fakeCoreClient := k8sfake.NewSimpleClientset(namespace()) - log := zap.New(zap.UseDevMode(false)).WithName("package_crd_rest_test") - logf.SetLogger(log) - klog.SetLogger(log) - pkgvCRDREST := datapkgreg.NewPackageCRDREST(internalClient, fakeCoreClient, globalNamespace, log) + + pkgvCRDREST := datapkgreg.NewPackageCRDREST(internalClient, fakeCoreClient, globalNamespace, logf.Log) _, err := pkgvCRDREST.Get(namespacedCtx(nonGlobalNamespace), name, &metav1.GetOptions{}) if err == nil { @@ -188,10 +172,7 @@ func TestPackageVersionGetPreferNS(t *testing.T) { internalClient := fake.NewSimpleClientset(overridePackageVersion, globalIntPackageVersion()) fakeCoreClient := k8sfake.NewSimpleClientset(namespace()) - log := zap.New(zap.UseDevMode(false)).WithName("package_crd_rest_test") - logf.SetLogger(log) - klog.SetLogger(log) - pkgvCRDREST := datapkgreg.NewPackageCRDREST(internalClient, fakeCoreClient, globalNamespace, log) + pkgvCRDREST := datapkgreg.NewPackageCRDREST(internalClient, fakeCoreClient, globalNamespace, logf.Log) obj, err := pkgvCRDREST.Get(namespacedCtx(nonGlobalNamespace), name, &metav1.GetOptions{}) if err != nil { @@ -221,10 +202,7 @@ func TestPackageVersionUpdateDoesntUpdateGlobal(t *testing.T) { internalClient := fake.NewSimpleClientset(globalPackageVersion, namespacedPackageVersion) fakeCoreClient := k8sfake.NewSimpleClientset(namespace()) - log := zap.New(zap.UseDevMode(false)).WithName("package_crd_rest_test") - logf.SetLogger(log) - klog.SetLogger(log) - pkgvCRDREST := datapkgreg.NewPackageCRDREST(internalClient, fakeCoreClient, globalNamespace, log) + pkgvCRDREST := datapkgreg.NewPackageCRDREST(internalClient, fakeCoreClient, globalNamespace, logf.Log) obj, created, err := pkgvCRDREST.Update(namespacedCtx(nonGlobalNamespace), name, UpdatePackageVersionTestImpl{updateReleaseNotesFn(newReleaseNotes, name, packageName, version)}, nil, nil, false, &metav1.UpdateOptions{}) if err != nil { @@ -265,10 +243,7 @@ func TestPackageVersionUpdateCreatesInNS(t *testing.T) { internalClient := fake.NewSimpleClientset(globalPackageVersion) fakeCoreClient := k8sfake.NewSimpleClientset(namespace()) - log := zap.New(zap.UseDevMode(false)).WithName("package_crd_rest_test") - logf.SetLogger(log) - klog.SetLogger(log) - pkgvCRDREST := datapkgreg.NewPackageCRDREST(internalClient, fakeCoreClient, globalNamespace, log) + pkgvCRDREST := datapkgreg.NewPackageCRDREST(internalClient, fakeCoreClient, globalNamespace, logf.Log) obj, created, err := pkgvCRDREST.Update(namespacedCtx(nonGlobalNamespace), name, UpdatePackageVersionTestImpl{updateReleaseNotesFn(newReleaseNotes, name, packageName, version)}, nil, nil, false, &metav1.UpdateOptions{}) if err != nil { @@ -302,10 +277,7 @@ func TestPackageVersionDeleteExistsInNS(t *testing.T) { internalClient := fake.NewSimpleClientset(namespacedPackageVersion) fakeCoreClient := k8sfake.NewSimpleClientset(namespace()) - log := zap.New(zap.UseDevMode(false)).WithName("package_crd_rest_test") - logf.SetLogger(log) - klog.SetLogger(log) - pkgvCRDREST := datapkgreg.NewPackageCRDREST(internalClient, fakeCoreClient, globalNamespace, log) + pkgvCRDREST := datapkgreg.NewPackageCRDREST(internalClient, fakeCoreClient, globalNamespace, logf.Log) _, _, err := pkgvCRDREST.Delete(namespacedCtx(nonGlobalNamespace), name, nil, &metav1.DeleteOptions{}) if err != nil { @@ -337,10 +309,7 @@ func TestPackageVersionDeleteExistsGlobalNotInNS(t *testing.T) { internalClient := fake.NewSimpleClientset(globalPackageVersion) fakeCoreClient := k8sfake.NewSimpleClientset(namespace()) - log := zap.New(zap.UseDevMode(false)).WithName("package_crd_rest_test") - logf.SetLogger(log) - klog.SetLogger(log) - pkgvCRDREST := datapkgreg.NewPackageCRDREST(internalClient, fakeCoreClient, globalNamespace, log) + pkgvCRDREST := datapkgreg.NewPackageCRDREST(internalClient, fakeCoreClient, globalNamespace, logf.Log) _, _, err := pkgvCRDREST.Delete(namespacedCtx(nonGlobalNamespace), name, nil, &metav1.DeleteOptions{}) if !errors.IsNotFound(err) {