diff --git a/cmd/cli/kubectl-kyverno/commands/test/test.go b/cmd/cli/kubectl-kyverno/commands/test/test.go index 9262757950..d5e8e684b9 100644 --- a/cmd/cli/kubectl-kyverno/commands/test/test.go +++ b/cmd/cli/kubectl-kyverno/commands/test/test.go @@ -125,6 +125,10 @@ func runTest(out io.Writer, testCase test.TestCase, auditWarn bool) ([]engineapi } validPolicies = append(validPolicies, pol) } + rclient := store.GetRegistryClient() + if rclient == nil { + rclient = registryclient.NewOrDie() + } // execute engine var engineResponses []engineapi.EngineResponse var resultCounts processor.ResultCounts @@ -142,7 +146,7 @@ func runTest(out io.Writer, testCase test.TestCase, auditWarn bool) ([]engineapi Client: dClient, Subresources: vars.Subresources(), Out: out, - RegistryClient: registryclient.NewOrDie(), + RegistryClient: rclient, } ers, err := processor.ApplyPoliciesOnResource() if err != nil {