mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-10 08:20:59 +00:00
Introduce gvk package to isolate apimachinery schema.
This commit is contained in:
@@ -16,6 +16,8 @@ limitations under the License.
|
||||
|
||||
package patch
|
||||
|
||||
import "sigs.k8s.io/kustomize/pkg/gvk"
|
||||
|
||||
// PatchJson6902 represents a json patch for an object
|
||||
// with format documented https://tools.ietf.org/html/rfc6902.
|
||||
type PatchJson6902 struct {
|
||||
@@ -32,9 +34,7 @@ type PatchJson6902 struct {
|
||||
|
||||
// Target represents the kubernetes object that the patch is applied to
|
||||
type Target struct {
|
||||
Group string `json:"group,omitempty" yaml:"group,omitempty"`
|
||||
Version string `json:"version,omitempty" yaml:"version,omitempty"`
|
||||
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
|
||||
gvk.Gvk `json:",inline,omitempty" yaml:",inline,omitempty"`
|
||||
Namespace string `json:"namespace,omitempty" yaml:"namespace,omitempty"`
|
||||
Name string `json:"name" yaml:"name"`
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import (
|
||||
|
||||
"github.com/evanphx/json-patch"
|
||||
"github.com/krishicks/yaml-patch"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"sigs.k8s.io/kustomize/pkg/gvk"
|
||||
"sigs.k8s.io/kustomize/pkg/loader"
|
||||
"sigs.k8s.io/kustomize/pkg/patch"
|
||||
"sigs.k8s.io/kustomize/pkg/resource"
|
||||
@@ -62,7 +62,7 @@ func (f PatchJson6902Factory) makeOnePatchJson6902Transformer(p patch.PatchJson6
|
||||
}
|
||||
|
||||
targetId := resource.NewResIdWithPrefixNamespace(
|
||||
schema.GroupVersionKind{
|
||||
gvk.Gvk{
|
||||
Group: p.Target.Group,
|
||||
Version: p.Target.Version,
|
||||
Kind: p.Target.Kind,
|
||||
|
||||
@@ -22,7 +22,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"gopkg.in/yaml.v2"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"sigs.k8s.io/kustomize/pkg/gvk"
|
||||
"sigs.k8s.io/kustomize/pkg/internal/loadertest"
|
||||
"sigs.k8s.io/kustomize/pkg/patch"
|
||||
"sigs.k8s.io/kustomize/pkg/resmap"
|
||||
@@ -179,7 +179,7 @@ func TestNewPatchJson6902FactoryMulti(t *testing.T) {
|
||||
t.Fatal("the returned transformer should not be nil")
|
||||
}
|
||||
|
||||
id := resource.NewResId(schema.GroupVersionKind{Kind: "foo"}, "some-name")
|
||||
id := resource.NewResId(gvk.FromKind("foo"), "some-name")
|
||||
base := resmap.ResMap{
|
||||
id: resource.NewResourceFromMap(
|
||||
map[string]interface{}{
|
||||
@@ -293,7 +293,7 @@ func TestNewPatchJson6902FactoryMultiConflict(t *testing.T) {
|
||||
t.Fatal("the returned transformer should not be nil")
|
||||
}
|
||||
|
||||
id := resource.NewResId(schema.GroupVersionKind{Kind: "foo"}, "some-name")
|
||||
id := resource.NewResId(gvk.FromKind("foo"), "some-name")
|
||||
base := resmap.ResMap{
|
||||
id: resource.NewResourceFromMap(
|
||||
map[string]interface{}{
|
||||
|
||||
@@ -21,12 +21,12 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/krishicks/yaml-patch"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"sigs.k8s.io/kustomize/pkg/gvk"
|
||||
"sigs.k8s.io/kustomize/pkg/resmap"
|
||||
"sigs.k8s.io/kustomize/pkg/resource"
|
||||
)
|
||||
|
||||
var deploy = schema.GroupVersionKind{Group: "apps", Version: "v1", Kind: "Deployment"}
|
||||
var deploy = gvk.Gvk{Group: "apps", Version: "v1", Kind: "Deployment"}
|
||||
|
||||
func TestJsonPatchYAMLTransformer_Transform(t *testing.T) {
|
||||
id := resource.NewResId(deploy, "deploy1")
|
||||
|
||||
Reference in New Issue
Block a user