mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-05-25 16:18:37 +00:00
remove dependency on apimachinery from gvk package
This commit is contained in:
@@ -22,8 +22,10 @@ import (
|
||||
|
||||
"github.com/evanphx/json-patch"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/util/strategicpatch"
|
||||
"k8s.io/client-go/kubernetes/scheme"
|
||||
"sigs.k8s.io/kustomize/pkg/gvk"
|
||||
"sigs.k8s.io/kustomize/pkg/resmap"
|
||||
"sigs.k8s.io/kustomize/pkg/resource"
|
||||
"sigs.k8s.io/kustomize/pkg/transformers"
|
||||
@@ -81,7 +83,7 @@ func (pt *patchTransformer) Transform(baseResourceMap resmap.ResMap) error {
|
||||
id = matchedIds[0]
|
||||
base := baseResourceMap[id]
|
||||
merged := map[string]interface{}{}
|
||||
versionedObj, err := scheme.Scheme.New(id.Gvk().ToSchemaGvk())
|
||||
versionedObj, err := scheme.Scheme.New(toSchemaGvk(id.Gvk()))
|
||||
baseName := base.GetName()
|
||||
switch {
|
||||
case runtime.IsNotRegisteredError(err):
|
||||
@@ -139,7 +141,7 @@ func (pt *patchTransformer) mergePatches() (resmap.ResMap, error) {
|
||||
continue
|
||||
}
|
||||
|
||||
versionedObj, err := scheme.Scheme.New(id.Gvk().ToSchemaGvk())
|
||||
versionedObj, err := scheme.Scheme.New(toSchemaGvk(id.Gvk()))
|
||||
if err != nil && !runtime.IsNotRegisteredError(err) {
|
||||
return nil, err
|
||||
}
|
||||
@@ -174,3 +176,12 @@ func (pt *patchTransformer) mergePatches() (resmap.ResMap, error) {
|
||||
}
|
||||
return rc, nil
|
||||
}
|
||||
|
||||
// toSchemaGvk converts to a schema.GroupVersionKind.
|
||||
func toSchemaGvk(x gvk.Gvk) schema.GroupVersionKind {
|
||||
return schema.GroupVersionKind{
|
||||
Group: x.Group,
|
||||
Version: x.Version,
|
||||
Kind: x.Kind,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,12 @@ func NewKunstructuredFromObject(obj runtime.Object) (ifc.Kunstructured, error) {
|
||||
|
||||
// GetGvk returns the Gvk name of the object.
|
||||
func (fs *UnstructAdapter) GetGvk() gvk.Gvk {
|
||||
return gvk.FromSchemaGvk(fs.GroupVersionKind())
|
||||
x := fs.GroupVersionKind()
|
||||
return gvk.Gvk{
|
||||
Group: x.Group,
|
||||
Version: x.Version,
|
||||
Kind: x.Kind,
|
||||
}
|
||||
}
|
||||
|
||||
// Copy provides a copy behind an interface.
|
||||
|
||||
@@ -17,7 +17,6 @@ limitations under the License.
|
||||
package gvk
|
||||
|
||||
import (
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -36,24 +35,6 @@ func FromKind(k string) Gvk {
|
||||
}
|
||||
}
|
||||
|
||||
// FromSchemaGvk converts from a schema.GroupVersionKind.
|
||||
func FromSchemaGvk(x schema.GroupVersionKind) Gvk {
|
||||
return Gvk{
|
||||
Group: x.Group,
|
||||
Version: x.Version,
|
||||
Kind: x.Kind,
|
||||
}
|
||||
}
|
||||
|
||||
// ToSchemaGvk converts to a schema.GroupVersionKind.
|
||||
func (x Gvk) ToSchemaGvk() schema.GroupVersionKind {
|
||||
return schema.GroupVersionKind{
|
||||
Group: x.Group,
|
||||
Version: x.Version,
|
||||
Kind: x.Kind,
|
||||
}
|
||||
}
|
||||
|
||||
const (
|
||||
noGroup = "noGroup"
|
||||
noVersion = "noVersion"
|
||||
|
||||
Reference in New Issue
Block a user