mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-10 16:42:51 +00:00
Break a bad dep.
This commit is contained in:
@@ -1,40 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2018 The Kubernetes Authors.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package patch
|
|
||||||
|
|
||||||
import "sigs.k8s.io/kustomize/pkg/gvk"
|
|
||||||
|
|
||||||
// Json6902 represents a json patch for an object
|
|
||||||
// with format documented https://tools.ietf.org/html/rfc6902.
|
|
||||||
type Json6902 struct {
|
|
||||||
// Target refers to a Kubernetes object that the json patch will be
|
|
||||||
// applied to. It must refer to a Kubernetes resource under the
|
|
||||||
// purview of this kustomization. Target should use the
|
|
||||||
// raw name of the object (the name specified in its YAML,
|
|
||||||
// before addition of a namePrefix and a nameSuffix).
|
|
||||||
Target *Target `json:"target" yaml:"target"`
|
|
||||||
|
|
||||||
// relative file path for a json patch file inside a kustomization
|
|
||||||
Path string `json:"path,omitempty" yaml:"path,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Target represents the kubernetes object that the patch is applied to
|
|
||||||
type Target struct {
|
|
||||||
gvk.Gvk `json:",inline,omitempty" yaml:",inline,omitempty"`
|
|
||||||
Namespace string `json:"namespace,omitempty" yaml:"namespace,omitempty"`
|
|
||||||
Name string `json:"name" yaml:"name"`
|
|
||||||
}
|
|
||||||
@@ -16,23 +16,20 @@ limitations under the License.
|
|||||||
|
|
||||||
package patch
|
package patch
|
||||||
|
|
||||||
// StrategicMerge represents a relative path to a
|
import "sigs.k8s.io/kustomize/pkg/types"
|
||||||
// stategic merge patch with the format
|
|
||||||
// https://github.com/kubernetes/community/blob/master/contributors/devel/strategic-merge-patch.md
|
|
||||||
type StrategicMerge string
|
|
||||||
|
|
||||||
// Append appends a slice of patch paths to a StrategicMerge slice
|
// Append appends a slice of patch paths to a PatchStrategicMerge slice
|
||||||
func Append(patches []StrategicMerge, paths ...string) []StrategicMerge {
|
func Append(patches []types.PatchStrategicMerge, paths ...string) []types.PatchStrategicMerge {
|
||||||
for _, p := range paths {
|
for _, p := range paths {
|
||||||
patches = append(patches, StrategicMerge(p))
|
patches = append(patches, types.PatchStrategicMerge(p))
|
||||||
}
|
}
|
||||||
return patches
|
return patches
|
||||||
}
|
}
|
||||||
|
|
||||||
// Exist determines if a patch path exists in a slice of StrategicMerge
|
// Exist determines if a patch path exists in a slice of PatchStrategicMerge
|
||||||
func Exist(patches []StrategicMerge, path string) bool {
|
func Exist(patches []types.PatchStrategicMerge, path string) bool {
|
||||||
for _, p := range patches {
|
for _, p := range patches {
|
||||||
if p == StrategicMerge(path) {
|
if p == types.PatchStrategicMerge(path) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,15 +18,15 @@ package transformer
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"sigs.k8s.io/kustomize/pkg/ifc"
|
|
||||||
"sigs.k8s.io/kustomize/pkg/resid"
|
|
||||||
|
|
||||||
"sigs.k8s.io/kustomize/pkg/gvk"
|
"sigs.k8s.io/kustomize/pkg/gvk"
|
||||||
"sigs.k8s.io/kustomize/pkg/patch"
|
"sigs.k8s.io/kustomize/pkg/ifc"
|
||||||
|
"sigs.k8s.io/kustomize/pkg/resid"
|
||||||
"sigs.k8s.io/kustomize/pkg/transformers"
|
"sigs.k8s.io/kustomize/pkg/transformers"
|
||||||
|
"sigs.k8s.io/kustomize/pkg/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
// PatchJson6902Factory makes Json6902 transformers
|
// PatchJson6902Factory makes PatchJson6902 transformers
|
||||||
type PatchJson6902Factory struct {
|
type PatchJson6902Factory struct {
|
||||||
loader ifc.Loader
|
loader ifc.Loader
|
||||||
}
|
}
|
||||||
@@ -36,8 +36,8 @@ func NewPatchJson6902Factory(l ifc.Loader) PatchJson6902Factory {
|
|||||||
return PatchJson6902Factory{loader: l}
|
return PatchJson6902Factory{loader: l}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MakePatchJson6902Transformer returns a transformer for applying Json6902 patch
|
// MakePatchJson6902Transformer returns a transformer for applying PatchJson6902 patch
|
||||||
func (f PatchJson6902Factory) MakePatchJson6902Transformer(patches []patch.Json6902) (transformers.Transformer, error) {
|
func (f PatchJson6902Factory) MakePatchJson6902Transformer(patches []types.PatchJson6902) (transformers.Transformer, error) {
|
||||||
var ts []transformers.Transformer
|
var ts []transformers.Transformer
|
||||||
for _, p := range patches {
|
for _, p := range patches {
|
||||||
t, err := f.makeOnePatchJson6902Transformer(p)
|
t, err := f.makeOnePatchJson6902Transformer(p)
|
||||||
@@ -51,7 +51,7 @@ func (f PatchJson6902Factory) MakePatchJson6902Transformer(patches []patch.Json6
|
|||||||
return transformers.NewMultiTransformerWithConflictCheck(ts), nil
|
return transformers.NewMultiTransformerWithConflictCheck(ts), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f PatchJson6902Factory) makeOnePatchJson6902Transformer(p patch.Json6902) (transformers.Transformer, error) {
|
func (f PatchJson6902Factory) makeOnePatchJson6902Transformer(p types.PatchJson6902) (transformers.Transformer, error) {
|
||||||
if p.Target == nil {
|
if p.Target == nil {
|
||||||
return nil, fmt.Errorf("must specify the target field in patchesJson6902")
|
return nil, fmt.Errorf("must specify the target field in patchesJson6902")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,17 +25,17 @@ import (
|
|||||||
"sigs.k8s.io/kustomize/internal/loadertest"
|
"sigs.k8s.io/kustomize/internal/loadertest"
|
||||||
"sigs.k8s.io/kustomize/k8sdeps/kunstruct"
|
"sigs.k8s.io/kustomize/k8sdeps/kunstruct"
|
||||||
"sigs.k8s.io/kustomize/pkg/gvk"
|
"sigs.k8s.io/kustomize/pkg/gvk"
|
||||||
"sigs.k8s.io/kustomize/pkg/patch"
|
|
||||||
"sigs.k8s.io/kustomize/pkg/resid"
|
"sigs.k8s.io/kustomize/pkg/resid"
|
||||||
"sigs.k8s.io/kustomize/pkg/resmap"
|
"sigs.k8s.io/kustomize/pkg/resmap"
|
||||||
"sigs.k8s.io/kustomize/pkg/resource"
|
"sigs.k8s.io/kustomize/pkg/resource"
|
||||||
|
"sigs.k8s.io/kustomize/pkg/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
var rf = resource.NewFactory(
|
var rf = resource.NewFactory(
|
||||||
kunstruct.NewKunstructuredFactoryImpl())
|
kunstruct.NewKunstructuredFactoryImpl())
|
||||||
|
|
||||||
func TestNewPatchJson6902FactoryNoTarget(t *testing.T) {
|
func TestNewPatchJson6902FactoryNoTarget(t *testing.T) {
|
||||||
p := patch.Json6902{}
|
p := types.PatchJson6902{}
|
||||||
_, err := NewPatchJson6902Factory(nil).makeOnePatchJson6902Transformer(p)
|
_, err := NewPatchJson6902Factory(nil).makeOnePatchJson6902Transformer(p)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatal("expected error")
|
t.Fatal("expected error")
|
||||||
@@ -51,7 +51,7 @@ target:
|
|||||||
name: some-name
|
name: some-name
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
`)
|
`)
|
||||||
p := patch.Json6902{}
|
p := types.PatchJson6902{}
|
||||||
err := yaml.Unmarshal(jsonPatch, &p)
|
err := yaml.Unmarshal(jsonPatch, &p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("expected error %v", err)
|
t.Fatalf("expected error %v", err)
|
||||||
@@ -84,7 +84,7 @@ target:
|
|||||||
name: some-name
|
name: some-name
|
||||||
path: patch.json
|
path: patch.json
|
||||||
`)
|
`)
|
||||||
p := patch.Json6902{}
|
p := types.PatchJson6902{}
|
||||||
err = yaml.Unmarshal(jsonPatch, &p)
|
err = yaml.Unmarshal(jsonPatch, &p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("expected error")
|
t.Fatal("expected error")
|
||||||
@@ -122,7 +122,7 @@ target:
|
|||||||
kind: Deployment
|
kind: Deployment
|
||||||
path: patch.yaml
|
path: patch.yaml
|
||||||
`)
|
`)
|
||||||
p := patch.Json6902{}
|
p := types.PatchJson6902{}
|
||||||
err = yaml.Unmarshal(jsonPatch, &p)
|
err = yaml.Unmarshal(jsonPatch, &p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unexpected error : %v", err)
|
t.Fatalf("unexpected error : %v", err)
|
||||||
@@ -169,7 +169,7 @@ func TestNewPatchJson6902FactoryMulti(t *testing.T) {
|
|||||||
name: some-name
|
name: some-name
|
||||||
path: patch.yaml
|
path: patch.yaml
|
||||||
`)
|
`)
|
||||||
var p []patch.Json6902
|
var p []types.PatchJson6902
|
||||||
err = yaml.Unmarshal(jsonPatches, &p)
|
err = yaml.Unmarshal(jsonPatches, &p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unexpected error : %v", err)
|
t.Fatalf("unexpected error : %v", err)
|
||||||
@@ -283,7 +283,7 @@ func TestNewPatchJson6902FactoryMultiConflict(t *testing.T) {
|
|||||||
name: some-name
|
name: some-name
|
||||||
path: patch.yaml
|
path: patch.yaml
|
||||||
`)
|
`)
|
||||||
var p []patch.Json6902
|
var p []types.PatchJson6902
|
||||||
err = yaml.Unmarshal(jsonPatches, &p)
|
err = yaml.Unmarshal(jsonPatches, &p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unexpected error : %v", err)
|
t.Fatalf("unexpected error : %v", err)
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ import (
|
|||||||
|
|
||||||
"sigs.k8s.io/kustomize/internal/kusterr"
|
"sigs.k8s.io/kustomize/internal/kusterr"
|
||||||
"sigs.k8s.io/kustomize/pkg/ifc"
|
"sigs.k8s.io/kustomize/pkg/ifc"
|
||||||
"sigs.k8s.io/kustomize/pkg/patch"
|
|
||||||
"sigs.k8s.io/kustomize/pkg/types"
|
"sigs.k8s.io/kustomize/pkg/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -69,7 +68,7 @@ func (rf *Factory) FromKunstructured(
|
|||||||
// SliceFromPatches returns a slice of resources given a patch path
|
// SliceFromPatches returns a slice of resources given a patch path
|
||||||
// slice from a kustomization file.
|
// slice from a kustomization file.
|
||||||
func (rf *Factory) SliceFromPatches(
|
func (rf *Factory) SliceFromPatches(
|
||||||
ldr ifc.Loader, paths []patch.StrategicMerge) ([]*Resource, error) {
|
ldr ifc.Loader, paths []types.PatchStrategicMerge) ([]*Resource, error) {
|
||||||
var result []*Resource
|
var result []*Resource
|
||||||
for _, path := range paths {
|
for _, path := range paths {
|
||||||
content, err := ldr.Load(string(path))
|
content, err := ldr.Load(string(path))
|
||||||
|
|||||||
@@ -21,20 +21,20 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"sigs.k8s.io/kustomize/internal/loadertest"
|
"sigs.k8s.io/kustomize/internal/loadertest"
|
||||||
"sigs.k8s.io/kustomize/pkg/patch"
|
|
||||||
. "sigs.k8s.io/kustomize/pkg/resource"
|
. "sigs.k8s.io/kustomize/pkg/resource"
|
||||||
|
"sigs.k8s.io/kustomize/pkg/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestSliceFromPatches(t *testing.T) {
|
func TestSliceFromPatches(t *testing.T) {
|
||||||
|
|
||||||
patchGood1 := patch.StrategicMerge("patch1.yaml")
|
patchGood1 := types.PatchStrategicMerge("patch1.yaml")
|
||||||
patch1 := `
|
patch1 := `
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
metadata:
|
metadata:
|
||||||
name: pooh
|
name: pooh
|
||||||
`
|
`
|
||||||
patchGood2 := patch.StrategicMerge("patch2.yaml")
|
patchGood2 := types.PatchStrategicMerge("patch2.yaml")
|
||||||
patch2 := `
|
patch2 := `
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: ConfigMap
|
kind: ConfigMap
|
||||||
@@ -46,11 +46,11 @@ metadata:
|
|||||||
---
|
---
|
||||||
---
|
---
|
||||||
`
|
`
|
||||||
patchBad := patch.StrategicMerge("patch3.yaml")
|
patchBad := types.PatchStrategicMerge("patch3.yaml")
|
||||||
patch3 := `
|
patch3 := `
|
||||||
WOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOT: woot
|
WOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOT: woot
|
||||||
`
|
`
|
||||||
patchList := patch.StrategicMerge("patch4.yaml")
|
patchList := types.PatchStrategicMerge("patch4.yaml")
|
||||||
patch4 := `
|
patch4 := `
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: List
|
kind: List
|
||||||
@@ -65,7 +65,7 @@ items:
|
|||||||
name: winnie
|
name: winnie
|
||||||
namespace: hundred-acre-wood
|
namespace: hundred-acre-wood
|
||||||
`
|
`
|
||||||
patchList2 := patch.StrategicMerge("patch5.yaml")
|
patchList2 := types.PatchStrategicMerge("patch5.yaml")
|
||||||
patch5 := `
|
patch5 := `
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: DeploymentList
|
kind: DeploymentList
|
||||||
@@ -88,13 +88,13 @@ items:
|
|||||||
spec:
|
spec:
|
||||||
<<: *hostAliases
|
<<: *hostAliases
|
||||||
`
|
`
|
||||||
patchList3 := patch.StrategicMerge("patch6.yaml")
|
patchList3 := types.PatchStrategicMerge("patch6.yaml")
|
||||||
patch6 := `
|
patch6 := `
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: List
|
kind: List
|
||||||
items:
|
items:
|
||||||
`
|
`
|
||||||
patchList4 := patch.StrategicMerge("patch7.yaml")
|
patchList4 := types.PatchStrategicMerge("patch7.yaml")
|
||||||
patch7 := `
|
patch7 := `
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: List
|
kind: List
|
||||||
@@ -142,49 +142,49 @@ kind: List
|
|||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
input []patch.StrategicMerge
|
input []types.PatchStrategicMerge
|
||||||
expectedOut []*Resource
|
expectedOut []*Resource
|
||||||
expectedErr bool
|
expectedErr bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "happy",
|
name: "happy",
|
||||||
input: []patch.StrategicMerge{patchGood1, patchGood2},
|
input: []types.PatchStrategicMerge{patchGood1, patchGood2},
|
||||||
expectedOut: []*Resource{testDeployment, testConfigMap},
|
expectedOut: []*Resource{testDeployment, testConfigMap},
|
||||||
expectedErr: false,
|
expectedErr: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "badFileName",
|
name: "badFileName",
|
||||||
input: []patch.StrategicMerge{patchGood1, "doesNotExist"},
|
input: []types.PatchStrategicMerge{patchGood1, "doesNotExist"},
|
||||||
expectedOut: []*Resource{},
|
expectedOut: []*Resource{},
|
||||||
expectedErr: true,
|
expectedErr: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "badData",
|
name: "badData",
|
||||||
input: []patch.StrategicMerge{patchGood1, patchBad},
|
input: []types.PatchStrategicMerge{patchGood1, patchBad},
|
||||||
expectedOut: []*Resource{},
|
expectedOut: []*Resource{},
|
||||||
expectedErr: true,
|
expectedErr: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "listOfPatches",
|
name: "listOfPatches",
|
||||||
input: []patch.StrategicMerge{patchList},
|
input: []types.PatchStrategicMerge{patchList},
|
||||||
expectedOut: []*Resource{testDeployment, testConfigMap},
|
expectedOut: []*Resource{testDeployment, testConfigMap},
|
||||||
expectedErr: false,
|
expectedErr: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "listWithAnchorReference",
|
name: "listWithAnchorReference",
|
||||||
input: []patch.StrategicMerge{patchList2},
|
input: []types.PatchStrategicMerge{patchList2},
|
||||||
expectedOut: []*Resource{testDeploymentA, testDeploymentB},
|
expectedOut: []*Resource{testDeploymentA, testDeploymentB},
|
||||||
expectedErr: false,
|
expectedErr: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "listWithNoEntries",
|
name: "listWithNoEntries",
|
||||||
input: []patch.StrategicMerge{patchList3},
|
input: []types.PatchStrategicMerge{patchList3},
|
||||||
expectedOut: []*Resource{},
|
expectedOut: []*Resource{},
|
||||||
expectedErr: false,
|
expectedErr: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "listWithNo'items:'",
|
name: "listWithNo'items:'",
|
||||||
input: []patch.StrategicMerge{patchList4},
|
input: []types.PatchStrategicMerge{patchList4},
|
||||||
expectedOut: []*Resource{},
|
expectedOut: []*Resource{},
|
||||||
expectedErr: false,
|
expectedErr: false,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ package target
|
|||||||
import (
|
import (
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"sigs.k8s.io/kustomize/pkg/image"
|
"sigs.k8s.io/kustomize/pkg/image"
|
||||||
"sigs.k8s.io/kustomize/pkg/patch"
|
|
||||||
"sigs.k8s.io/kustomize/pkg/plugins"
|
"sigs.k8s.io/kustomize/pkg/plugins"
|
||||||
"sigs.k8s.io/kustomize/pkg/transformers"
|
"sigs.k8s.io/kustomize/pkg/transformers"
|
||||||
"sigs.k8s.io/kustomize/pkg/transformers/config"
|
"sigs.k8s.io/kustomize/pkg/transformers/config"
|
||||||
@@ -128,7 +127,7 @@ func (kt *KustTarget) configureBuiltinPatchJson6902Transformer(
|
|||||||
tConfig *config.TransformerConfig) (
|
tConfig *config.TransformerConfig) (
|
||||||
result []transformers.Transformer, err error) {
|
result []transformers.Transformer, err error) {
|
||||||
var c struct {
|
var c struct {
|
||||||
Patches []patch.Json6902
|
Patches []types.PatchJson6902
|
||||||
}
|
}
|
||||||
c.Patches = kt.kustomization.PatchesJson6902
|
c.Patches = kt.kustomization.PatchesJson6902
|
||||||
p := builtin.NewPatchJson6902TransformerPlugin()
|
p := builtin.NewPatchJson6902TransformerPlugin()
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ package types
|
|||||||
import (
|
import (
|
||||||
"regexp"
|
"regexp"
|
||||||
|
|
||||||
|
"sigs.k8s.io/kustomize/pkg/gvk"
|
||||||
"sigs.k8s.io/kustomize/pkg/image"
|
"sigs.k8s.io/kustomize/pkg/image"
|
||||||
"sigs.k8s.io/kustomize/pkg/patch"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -67,12 +67,12 @@ type Kustomization struct {
|
|||||||
// containing a strategic merge patch. Format documented at
|
// containing a strategic merge patch. Format documented at
|
||||||
// https://github.com/kubernetes/community/blob/master/contributors/devel/strategic-merge-patch.md
|
// https://github.com/kubernetes/community/blob/master/contributors/devel/strategic-merge-patch.md
|
||||||
// URLs and globs are not supported.
|
// URLs and globs are not supported.
|
||||||
PatchesStrategicMerge []patch.StrategicMerge `json:"patchesStrategicMerge,omitempty" yaml:"patchesStrategicMerge,omitempty"`
|
PatchesStrategicMerge []PatchStrategicMerge `json:"patchesStrategicMerge,omitempty" yaml:"patchesStrategicMerge,omitempty"`
|
||||||
|
|
||||||
// JSONPatches is a list of JSONPatch for applying JSON patch.
|
// JSONPatches is a list of JSONPatch for applying JSON patch.
|
||||||
// Format documented at https://tools.ietf.org/html/rfc6902
|
// Format documented at https://tools.ietf.org/html/rfc6902
|
||||||
// and http://jsonpatch.com
|
// and http://jsonpatch.com
|
||||||
PatchesJson6902 []patch.Json6902 `json:"patchesJson6902,omitempty" yaml:"patchesJson6902,omitempty"`
|
PatchesJson6902 []PatchJson6902 `json:"patchesJson6902,omitempty" yaml:"patchesJson6902,omitempty"`
|
||||||
|
|
||||||
// Images is a list of (image name, new name, new tag or digest)
|
// Images is a list of (image name, new name, new tag or digest)
|
||||||
// for changing image names, tags or digests. This can also be achieved with a
|
// for changing image names, tags or digests. This can also be achieved with a
|
||||||
@@ -333,3 +333,29 @@ type NameArgs struct {
|
|||||||
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
||||||
Namespace string `json:"namespace,omitempty" yaml:"namespace,omitempty"`
|
Namespace string `json:"namespace,omitempty" yaml:"namespace,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PatchJson6902 represents a json patch for an object
|
||||||
|
// with format documented https://tools.ietf.org/html/rfc6902.
|
||||||
|
type PatchJson6902 struct {
|
||||||
|
// PatchTarget refers to a Kubernetes object that the json patch will be
|
||||||
|
// applied to. It must refer to a Kubernetes resource under the
|
||||||
|
// purview of this kustomization. PatchTarget should use the
|
||||||
|
// raw name of the object (the name specified in its YAML,
|
||||||
|
// before addition of a namePrefix and a nameSuffix).
|
||||||
|
Target *PatchTarget `json:"target" yaml:"target"`
|
||||||
|
|
||||||
|
// relative file path for a json patch file inside a kustomization
|
||||||
|
Path string `json:"path,omitempty" yaml:"path,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// PatchTarget represents the kubernetes object that the patch is applied to
|
||||||
|
type PatchTarget struct {
|
||||||
|
gvk.Gvk `json:",inline,omitempty" yaml:",inline,omitempty"`
|
||||||
|
Namespace string `json:"namespace,omitempty" yaml:"namespace,omitempty"`
|
||||||
|
Name string `json:"name" yaml:"name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// PatchStrategicMerge represents a relative path to a
|
||||||
|
// stategic merge patch with the format
|
||||||
|
// https://github.com/kubernetes/community/blob/master/contributors/devel/strategic-merge-patch.md
|
||||||
|
type PatchStrategicMerge string
|
||||||
|
|||||||
@@ -3,15 +3,15 @@ package builtin
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"sigs.k8s.io/kustomize/pkg/ifc"
|
"sigs.k8s.io/kustomize/pkg/ifc"
|
||||||
"sigs.k8s.io/kustomize/pkg/patch"
|
|
||||||
"sigs.k8s.io/kustomize/pkg/patch/transformer"
|
"sigs.k8s.io/kustomize/pkg/patch/transformer"
|
||||||
"sigs.k8s.io/kustomize/pkg/resmap"
|
"sigs.k8s.io/kustomize/pkg/resmap"
|
||||||
|
"sigs.k8s.io/kustomize/pkg/types"
|
||||||
"sigs.k8s.io/yaml"
|
"sigs.k8s.io/yaml"
|
||||||
)
|
)
|
||||||
|
|
||||||
type PatchJson6902TransformerPlugin struct {
|
type PatchJson6902TransformerPlugin struct {
|
||||||
ldr ifc.Loader
|
ldr ifc.Loader
|
||||||
Patches []patch.Json6902 `json:"patches,omitempty" yaml:"patches,omitempty"`
|
Patches []types.PatchJson6902 `json:"patches,omitempty" yaml:"patches,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewPatchJson6902TransformerPlugin() *PatchJson6902TransformerPlugin {
|
func NewPatchJson6902TransformerPlugin() *PatchJson6902TransformerPlugin {
|
||||||
|
|||||||
@@ -6,15 +6,15 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"sigs.k8s.io/kustomize/pkg/ifc"
|
"sigs.k8s.io/kustomize/pkg/ifc"
|
||||||
"sigs.k8s.io/kustomize/pkg/patch"
|
|
||||||
"sigs.k8s.io/kustomize/pkg/patch/transformer"
|
"sigs.k8s.io/kustomize/pkg/patch/transformer"
|
||||||
"sigs.k8s.io/kustomize/pkg/resmap"
|
"sigs.k8s.io/kustomize/pkg/resmap"
|
||||||
|
"sigs.k8s.io/kustomize/pkg/types"
|
||||||
"sigs.k8s.io/yaml"
|
"sigs.k8s.io/yaml"
|
||||||
)
|
)
|
||||||
|
|
||||||
type plugin struct {
|
type plugin struct {
|
||||||
ldr ifc.Loader
|
ldr ifc.Loader
|
||||||
Patches []patch.Json6902 `json:"patches,omitempty" yaml:"patches,omitempty"`
|
Patches []types.PatchJson6902 `json:"patches,omitempty" yaml:"patches,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
var KustomizePlugin plugin
|
var KustomizePlugin plugin
|
||||||
|
|||||||
Reference in New Issue
Block a user