mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-11 00:52:55 +00:00
Start pluglib, a set of public, plugin specific functions.
This commit is contained in:
@@ -6,7 +6,6 @@ import (
|
||||
|
||||
"github.com/evanphx/json-patch"
|
||||
"github.com/pkg/errors"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/ifc"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/resmap"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/resource"
|
||||
"sigs.k8s.io/kustomize/v3/pkg/types"
|
||||
@@ -14,8 +13,6 @@ import (
|
||||
)
|
||||
|
||||
type PatchTransformerPlugin struct {
|
||||
ldr ifc.Loader
|
||||
rf *resmap.Factory
|
||||
loadedPatch *resource.Resource
|
||||
decodedPatch jsonpatch.Patch
|
||||
Path string `json:"path,omitempty" yaml:"path,omitempty"`
|
||||
@@ -24,9 +21,7 @@ type PatchTransformerPlugin struct {
|
||||
}
|
||||
|
||||
func (p *PatchTransformerPlugin) Config(
|
||||
ldr ifc.Loader, rf *resmap.Factory, c []byte) (err error) {
|
||||
p.ldr = ldr
|
||||
p.rf = rf
|
||||
h *resmap.PluginHelpers, c []byte) (err error) {
|
||||
err = yaml.Unmarshal(c, p)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -43,7 +38,7 @@ func (p *PatchTransformerPlugin) Config(
|
||||
}
|
||||
var in []byte
|
||||
if p.Path != "" {
|
||||
in, err = ldr.Load(p.Path)
|
||||
in, err = h.Loader().Load(p.Path)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -52,7 +47,7 @@ func (p *PatchTransformerPlugin) Config(
|
||||
in = []byte(p.Patch)
|
||||
}
|
||||
|
||||
patchSM, errSM := p.rf.RF().FromBytes(in)
|
||||
patchSM, errSM := h.ResmapFactory().RF().FromBytes(in)
|
||||
patchJson, errJson := jsonPatchFromBytes(in)
|
||||
if errSM != nil && errJson != nil {
|
||||
err = fmt.Errorf(
|
||||
|
||||
Reference in New Issue
Block a user