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

@@ -23,6 +23,7 @@ import (
"sigs.k8s.io/kustomize/pkg/ifc"
"sigs.k8s.io/kustomize/pkg/resid"
"sigs.k8s.io/kustomize/pkg/types"
"sigs.k8s.io/yaml"
)
// Resource is map representation of a Kubernetes API resource object
@@ -56,6 +57,16 @@ func (r *Resource) DeepCopy() *Resource {
return rc
}
// AsYAML returns the resource in Yaml form.
// Easier to read than JSON.
func (r *Resource) AsYAML() ([]byte, error) {
json, err := r.MarshalJSON()
if err != nil {
return nil, err
}
return yaml.JSONToYAML(json)
}
// Behavior returns the behavior for the resource.
func (r *Resource) Behavior() types.GenerationBehavior {
return r.options.Behavior()