Maintain resources in order loaded.

This commit is contained in:
Jeffrey Regan
2019-06-03 11:22:53 -07:00
parent af57fc3ece
commit 4162dbc2d8
39 changed files with 1074 additions and 617 deletions

View File

@@ -191,8 +191,8 @@ func (p *ExecPlugin) getEnv() []string {
// Returns a new copy of the given ResMap with the ResIds annotated in each Resource
func (p *ExecPlugin) getResMapWithIdAnnotation(rm resmap.ResMap) (resmap.ResMap, error) {
inputRM := rm.DeepCopy(p.rf.RF())
for id, r := range inputRM {
inputRM := rm.DeepCopy()
for id, r := range inputRM.AsMap() {
idString, err := yaml.Marshal(id)
if err != nil {
return nil, err
@@ -216,7 +216,7 @@ func (p *ExecPlugin) updateResMapValues(output []byte, rm resmap.ResMap) error {
if err != nil {
return err
}
for _, r := range outputRM {
for _, r := range outputRM.Resources() {
// for each emitted Resource, find the matching Resource in the original ResMap
// using its id
annotations := r.GetAnnotations()
@@ -230,8 +230,8 @@ func (p *ExecPlugin) updateResMapValues(output []byte, rm resmap.ResMap) error {
if err != nil {
return err
}
res, ok := rm[id]
if !ok {
res := rm.GetById(id)
if res == nil {
return fmt.Errorf("unable to find id %s in resource map", id.String())
}
// remove the annotation set by Kustomize to track the resource

View File

@@ -35,7 +35,7 @@ func NewLoader(
func (l *Loader) LoadGenerators(
ldr ifc.Loader, rm resmap.ResMap) ([]transformers.Generator, error) {
var result []transformers.Generator
for _, res := range rm {
for _, res := range rm.Resources() {
g, err := l.LoadGenerator(ldr, res)
if err != nil {
return nil, err
@@ -61,7 +61,7 @@ func (l *Loader) LoadGenerator(
func (l *Loader) LoadTransformers(
ldr ifc.Loader, rm resmap.ResMap) ([]transformers.Transformer, error) {
var result []transformers.Transformer
for _, res := range rm {
for _, res := range rm.Resources() {
t, err := l.LoadTransformer(ldr, res)
if err != nil {
return nil, err