Convert plugins to accept bytes instead of unstruct.

This commit is contained in:
Jeffrey Regan
2019-05-07 17:54:02 -07:00
committed by jregan
parent 06acd3caa9
commit 2e71a3b862
14 changed files with 109 additions and 96 deletions

View File

@@ -22,27 +22,31 @@ import (
"sigs.k8s.io/kustomize/pkg/ifc"
"sigs.k8s.io/kustomize/pkg/resmap"
"sigs.k8s.io/kustomize/pkg/types"
"sigs.k8s.io/yaml"
)
type plugin struct {
ldr ifc.Loader
rf *resmap.Factory
options types.GeneratorOptions
args types.ConfigMapArgs
types.GeneratorOptions
types.ConfigMapArgs
}
var KustomizePlugin plugin
func (p *plugin) Config(
ldr ifc.Loader, rf *resmap.Factory, k ifc.Kunstructured) (err error) {
ldr ifc.Loader, rf *resmap.Factory, config []byte) (err error) {
p.GeneratorOptions = types.GeneratorOptions{}
p.ConfigMapArgs = types.ConfigMapArgs{}
err = yaml.Unmarshal(config, p)
p.ldr = ldr
p.rf = rf
p.args.GeneratorArgs, err = resmap.GeneratorArgsFromKunstruct(k)
return
}
func (p *plugin) Generate() (resmap.ResMap, error) {
argsList := make([]types.ConfigMapArgs, 1)
argsList[0] = p.args
return p.rf.NewResMapFromConfigMapArgs(p.ldr, &p.options, argsList)
argsList[0] = p.ConfigMapArgs
return p.rf.NewResMapFromConfigMapArgs(
p.ldr, &p.GeneratorOptions, argsList)
}