Skip to content

Commit

Permalink
Fix ordering of create operations during uuid UpdateMany
Browse files Browse the repository at this point in the history
  • Loading branch information
kklimonda-cl committed Jan 22, 2025
1 parent b4e2b87 commit e9a6f46
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion assets/terraform/internal/manager/uuid.go
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,8 @@ func (o *UuidObjectManager[E, L, S]) UpdateMany(ctx context.Context, location L,
}
}

createOps := make([]*xmlapi.Config, len(planEntries))

for _, elt := range processedStateEntries {
path, err := location.XpathWithEntryName(o.client.Versioning(), elt.Entry.EntryName())
if err != nil {
Expand All @@ -547,7 +549,14 @@ func (o *UuidObjectManager[E, L, S]) UpdateMany(ctx context.Context, location L,
}

switch elt.State {
case entryMissing, entryOutdated:
case entryMissing:
createOps[elt.StateIdx] = &xmlapi.Config{
Action: "edit",
Xpath: util.AsXpath(path),
Element: xmlEntry,
Target: o.client.GetTarget(),
}
case entryOutdated:
updates.Add(&xmlapi.Config{
Action: "edit",
Xpath: util.AsXpath(path),
Expand Down Expand Up @@ -582,6 +591,12 @@ func (o *UuidObjectManager[E, L, S]) UpdateMany(ctx context.Context, location L,
}
}

for _, elt := range createOps {
if elt != nil {
updates.Add(elt)
}
}

if len(updates.Operations) > 0 {
if _, _, _, err := o.client.MultiConfig(ctx, updates, false, nil); err != nil {
return nil, &Error{err: err, message: "failed to execute MultiConfig command"}
Expand Down

0 comments on commit e9a6f46

Please sign in to comment.