Repository: kyverno/chainsaw
Pull request #250 (2023-10-29 22:03:31)

chore: reuse more from kyverno
Reuse more from kyverno.

codecov[bot]: We're currently processing your upload.  This comment will be updated when the results are available.

Patch:
diff --git a/go.mod b/go.mod
index 87d59026..60c164eb 100644
--- a/go.mod
+++ b/go.mod
@@ -5,7 +5,7 @@ go 1.21.1
 require (
 	github.com/dustinkirkland/golang-petname v0.0.0-20231002161417-6a283f1aaaf2
 	github.com/kudobuilder/kuttl v0.15.0
-	github.com/kyverno/kyverno v1.5.0-rc1.0.20231028153248-bd72e42bfe3d
+	github.com/kyverno/kyverno v1.5.0-rc1.0.20231029093939-32d16059beb4
 	github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2
 	github.com/spf13/cobra v1.7.0
 	github.com/spf13/pflag v1.0.5
diff --git a/go.sum b/go.sum
index 5197fd4c..35c3667b 100644
--- a/go.sum
+++ b/go.sum
@@ -134,8 +134,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
 github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
 github.com/kudobuilder/kuttl v0.15.0 h1:OmCbpY3ebn+myJaatD+IT1AL1OTz34+Cv6ettiXd/hI=
 github.com/kudobuilder/kuttl v0.15.0/go.mod h1:UtAOt+GE8HQZFveEN8p1fk3j+H1Cp5Fk1eMdQkXPqH0=
-github.com/kyverno/kyverno v1.5.0-rc1.0.20231028153248-bd72e42bfe3d h1:oIiEK6ZoiCeeAzraafkiNIeJXUD29PkwL10XIjXowRA=
-github.com/kyverno/kyverno v1.5.0-rc1.0.20231028153248-bd72e42bfe3d/go.mod h1:9Fdii26pII6fE5aQzJouIKL7vyzlAfSaCFaj+/UIoP8=
+github.com/kyverno/kyverno v1.5.0-rc1.0.20231029093939-32d16059beb4 h1:uOiXbeGbqCmLCQURoDUCEMGz7TzKPth/oq1B3RK+L0k=
+github.com/kyverno/kyverno v1.5.0-rc1.0.20231029093939-32d16059beb4/go.mod h1:9Fdii26pII6fE5aQzJouIKL7vyzlAfSaCFaj+/UIoP8=
 github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
 github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
 github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
diff --git a/pkg/commands/kuttl/migrate/command.go b/pkg/commands/kuttl/migrate/command.go
index 061f2435..7b3da115 100644
--- a/pkg/commands/kuttl/migrate/command.go
+++ b/pkg/commands/kuttl/migrate/command.go
@@ -12,9 +12,9 @@ import (
 	"github.com/kyverno/chainsaw/pkg/apis/v1alpha1"
 	"github.com/kyverno/chainsaw/pkg/discovery"
 	"github.com/kyverno/chainsaw/pkg/resource"
-	"github.com/kyverno/chainsaw/pkg/utils/convert"
 	fsutils "github.com/kyverno/chainsaw/pkg/utils/fs"
 	fileutils "github.com/kyverno/kyverno/ext/file"
+	"github.com/kyverno/kyverno/ext/resource/convert"
 	"github.com/spf13/cobra"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 	"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
diff --git a/pkg/config/load.go b/pkg/config/load.go
index ffef403e..e33f00c5 100644
--- a/pkg/config/load.go
+++ b/pkg/config/load.go
@@ -8,8 +8,8 @@ import (
 
 	"github.com/kyverno/chainsaw/pkg/apis/v1alpha1"
 	"github.com/kyverno/chainsaw/pkg/data"
-	"github.com/kyverno/chainsaw/pkg/utils/convert"
 	"github.com/kyverno/chainsaw/pkg/utils/loader"
+	"github.com/kyverno/kyverno/ext/resource/convert"
 	"github.com/kyverno/kyverno/ext/yaml"
 	"sigs.k8s.io/kubectl-validate/pkg/openapiclient"
 )
diff --git a/pkg/step/load.go b/pkg/step/load.go
index 02fa9d75..3a73e8d9 100644
--- a/pkg/step/load.go
+++ b/pkg/step/load.go
@@ -7,8 +7,8 @@ import (
 
 	"github.com/kyverno/chainsaw/pkg/apis/v1alpha1"
 	"github.com/kyverno/chainsaw/pkg/data"
-	"github.com/kyverno/chainsaw/pkg/utils/convert"
 	"github.com/kyverno/chainsaw/pkg/utils/loader"
+	"github.com/kyverno/kyverno/ext/resource/convert"
 	"github.com/kyverno/kyverno/ext/yaml"
 	"sigs.k8s.io/kubectl-validate/pkg/openapiclient"
 )
diff --git a/pkg/utils/convert/convert.go b/pkg/utils/convert/convert.go
deleted file mode 100644
index 876c2c76..00000000
--- a/pkg/utils/convert/convert.go
+++ /dev/null
@@ -1,18 +0,0 @@
-package convert
-
-import (
-	"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
-	"k8s.io/apimachinery/pkg/runtime"
-)
-
-func Into[T any](untyped unstructured.Unstructured, result *T) error {
-	return runtime.DefaultUnstructuredConverter.FromUnstructuredWithValidation(untyped.UnstructuredContent(), result, true)
-}
-
-func To[T any](untyped unstructured.Unstructured) (*T, error) {
-	var result T
-	if err := Into(untyped, &result); err != nil {
-		return nil, err
-	}
-	return &result, nil
-}


Test patch:
diff --git a/pkg/test/load.go b/pkg/test/load.go
index a37df6ad..81d9fcca 100644
--- a/pkg/test/load.go
+++ b/pkg/test/load.go
@@ -7,8 +7,8 @@ import (
 
 	"github.com/kyverno/chainsaw/pkg/apis/v1alpha1"
 	"github.com/kyverno/chainsaw/pkg/data"
-	"github.com/kyverno/chainsaw/pkg/utils/convert"
 	"github.com/kyverno/chainsaw/pkg/utils/loader"
+	"github.com/kyverno/kyverno/ext/resource/convert"
 	"github.com/kyverno/kyverno/ext/yaml"
 	"sigs.k8s.io/kubectl-validate/pkg/openapiclient"
 )