From 44696d5fb91e1e19eb527e7961bcc68d517c6a04 Mon Sep 17 00:00:00 2001 From: Jeffrey Regan Date: Mon, 11 Jun 2018 14:43:22 -0700 Subject: [PATCH] Add TODO referencing bug --- pkg/app/application.go | 49 +++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/pkg/app/application.go b/pkg/app/application.go index 27bbf6ce5..ddbaac58f 100644 --- a/pkg/app/application.go +++ b/pkg/app/application.go @@ -60,6 +60,17 @@ func NewApplication(loader loader.Loader) (*Application, error) { return &Application{kustomization: &m, loader: loader}, nil } +func unmarshal(y []byte, o interface{}) error { + j, err := yaml.YAMLToJSON(y) + if err != nil { + return err + } + + dec := json.NewDecoder(bytes.NewReader(j)) + dec.DisallowUnknownFields() + return dec.Decode(o) +} + // MakeCustomizedResMap creates a ResMap per kustomization instructions. // The Resources in the returned ResMap are fully customized. func (a *Application) MakeCustomizedResMap() (resmap.ResMap, error) { @@ -70,6 +81,20 @@ func (a *Application) MakeCustomizedResMap() (resmap.ResMap, error) { return a.resolveRefsToGeneratedResources(m) } +// MakeUncustomizedResMap purports to create a ResMap without customization. +// The Resources in the returned ResMap include all resources mentioned +// in the kustomization file and transitively reachable via its Bases, +// and all generated secrets and configMaps. +// Meant for use in generating a diff against customized resources. +// TODO: See https://github.com/kubernetes-sigs/kustomize/issues/85 +func (a *Application) MakeUncustomizedResMap() (resmap.ResMap, error) { + m, err := a.loadResMapFromBasesAndResources() + if err != nil { + return nil, err + } + return a.resolveRefsToGeneratedResources(m) +} + // resolveRefsToGeneratedResources fixes all name references. func (a *Application) resolveRefsToGeneratedResources(m resmap.ResMap) (resmap.ResMap, error) { r := []transformers.Transformer{transformers.NewNameHashTransformer()} @@ -142,19 +167,6 @@ func (a *Application) loadCustomizedResMap() (resmap.ResMap, error) { return result, nil } -// MakeUncustomizedResMap purports to create a ResMap without customization. -// The Resources in the returned ResMap include all resources mentioned -// in the kustomization file and transitively reachable via its Bases, -// and all generated secrets and configMaps. -// Meant for use in generating a diff against customized resources. -func (a *Application) MakeUncustomizedResMap() (resmap.ResMap, error) { - m, err := a.loadResMapFromBasesAndResources() - if err != nil { - return nil, err - } - return a.resolveRefsToGeneratedResources(m) -} - // Gets Bases and Resources as advertised. func (a *Application) loadResMapFromBasesAndResources() (resmap.ResMap, error) { bases, errs := a.loadCustomizedBases() @@ -247,17 +259,6 @@ func (a *Application) newTransformer(patches []*resource.Resource) (transformers return transformers.NewMultiTransformer(r), nil } -func unmarshal(y []byte, o interface{}) error { - j, err := yaml.YAMLToJSON(y) - if err != nil { - return err - } - - dec := json.NewDecoder(bytes.NewReader(j)) - dec.DisallowUnknownFields() - return dec.Decode(o) -} - func (a *Application) resolveRefVars(m resmap.ResMap) (map[string]string, error) { result := map[string]string{} vars, err := a.getAllVars()