Start pluglib, a set of public, plugin specific functions.

This commit is contained in:
Jeffrey Regan
2019-10-14 17:52:40 -07:00
committed by jregan
parent 2fadb4dd59
commit 41a008e9a3
78 changed files with 280 additions and 329 deletions

View File

@@ -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(