From 94ba811fbaae9bc3d78f7e28b84b709aa736b4e4 Mon Sep 17 00:00:00 2001 From: Denis Bilenko Date: Mon, 24 Aug 2026 14:53:24 +0200 Subject: [PATCH] Pass PlanEntry to DoUpdateWithID DoUpdate receives the PlanEntry so it can tell what the plan is changing; DoUpdateWithID did not, so the rename paths had no way to consult it. Pure plumbing: carry the argument through the interface, the adapter and apply. No implementer reads it yet, so behaviour is unchanged. The UC rename paths use it in a follow-up, where an omitempty field the plan reports as cleared has to be force-sent or the rename drops the clear. Co-authored-by: Isaac --- bundle/direct/apply.go | 6 +++--- bundle/direct/dresources/adapter.go | 7 ++++--- bundle/direct/dresources/catalog.go | 2 +- bundle/direct/dresources/external_location.go | 2 +- bundle/direct/dresources/secret_scope_acls.go | 6 +++--- bundle/direct/dresources/volume.go | 2 +- 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/bundle/direct/apply.go b/bundle/direct/apply.go index 2f39e1072c6..6b2fffe9a16 100644 --- a/bundle/direct/apply.go +++ b/bundle/direct/apply.go @@ -50,7 +50,7 @@ func (d *DeploymentUnit) Deploy(ctx context.Context, db *dstate.DeploymentState, case deployplan.Update: return d.Update(ctx, db, oldID, newState, planEntry) case deployplan.UpdateWithID: - return d.UpdateWithID(ctx, db, oldID, newState) + return d.UpdateWithID(ctx, db, oldID, newState, planEntry) case deployplan.Resize: return d.Resize(ctx, db, oldID, newState, planEntry) default: @@ -195,12 +195,12 @@ func (d *DeploymentUnit) Update(ctx context.Context, db *dstate.DeploymentState, return nil } -func (d *DeploymentUnit) UpdateWithID(ctx context.Context, db *dstate.DeploymentState, oldID string, newState any) error { +func (d *DeploymentUnit) UpdateWithID(ctx context.Context, db *dstate.DeploymentState, oldID string, newState any, planEntry *deployplan.PlanEntry) error { var newID string var remoteState any err := retryOnTransientErr(ctx, func() error { var e error - newID, remoteState, e = d.Adapter.DoUpdateWithID(ctx, oldID, newState) + newID, remoteState, e = d.Adapter.DoUpdateWithID(ctx, oldID, newState, planEntry) return e }) if err != nil { diff --git a/bundle/direct/dresources/adapter.go b/bundle/direct/dresources/adapter.go index 6025f5dc0bd..ec9697dc3f9 100644 --- a/bundle/direct/dresources/adapter.go +++ b/bundle/direct/dresources/adapter.go @@ -84,7 +84,8 @@ type IResource interface { DoUpdate(ctx context.Context, id string, newState any, entry *PlanEntry) (remoteState any, e error) // [Optional] DoUpdateWithID performs an update that may result in resource having a new ID. Returns new id and optionally remote state. - DoUpdateWithID(ctx context.Context, id string, newState any) (newID string, remoteState any, e error) + // Example: func (r *ResourceCatalog) DoUpdateWithID(ctx context.Context, id string, newState *catalog.CreateCatalog, entry *PlanEntry) (string, *catalog.CatalogInfo, error) + DoUpdateWithID(ctx context.Context, id string, newState any, entry *PlanEntry) (newID string, remoteState any, e error) // [Optional] DoResize resizes the resource. Only supported by clusters DoResize(ctx context.Context, id string, newState any, entry *PlanEntry) error @@ -593,12 +594,12 @@ func (a *Adapter) HasDoUpdateWithID() bool { } // DoUpdateWithID updates the resource and may change its ID. Returns newID and remoteState if available. -func (a *Adapter) DoUpdateWithID(ctx context.Context, oldID string, newState any) (string, any, error) { +func (a *Adapter) DoUpdateWithID(ctx context.Context, oldID string, newState any, entry *PlanEntry) (string, any, error) { if a.doUpdateWithID == nil { return "", nil, errors.New("internal error: DoUpdateWithID not found") } - outs, err := a.doUpdateWithID.Call(ctx, oldID, newState) + outs, err := a.doUpdateWithID.Call(ctx, oldID, newState, entry) if err != nil { return "", nil, err } diff --git a/bundle/direct/dresources/catalog.go b/bundle/direct/dresources/catalog.go index 604100e92dd..645fb933cd1 100644 --- a/bundle/direct/dresources/catalog.go +++ b/bundle/direct/dresources/catalog.go @@ -74,7 +74,7 @@ func (r *ResourceCatalog) DoUpdate(ctx context.Context, id string, config *catal } // DoUpdateWithID updates the catalog and returns the new ID if the name changes. -func (r *ResourceCatalog) DoUpdateWithID(ctx context.Context, id string, config *catalog.CreateCatalog) (string, *catalog.CatalogInfo, error) { +func (r *ResourceCatalog) DoUpdateWithID(ctx context.Context, id string, config *catalog.CreateCatalog, _ *PlanEntry) (string, *catalog.CatalogInfo, error) { updateRequest := catalog.UpdateCatalog{ Comment: config.Comment, CustomMaxRetentionHours: config.CustomMaxRetentionHours, diff --git a/bundle/direct/dresources/external_location.go b/bundle/direct/dresources/external_location.go index 64eace48eb3..a1ea24e4109 100644 --- a/bundle/direct/dresources/external_location.go +++ b/bundle/direct/dresources/external_location.go @@ -78,7 +78,7 @@ func (r *ResourceExternalLocation) DoUpdate(ctx context.Context, id string, conf } // DoUpdateWithID updates the external location and returns the new ID if the name changes. -func (r *ResourceExternalLocation) DoUpdateWithID(ctx context.Context, id string, config *catalog.CreateExternalLocation) (string, *catalog.ExternalLocationInfo, error) { +func (r *ResourceExternalLocation) DoUpdateWithID(ctx context.Context, id string, config *catalog.CreateExternalLocation, _ *PlanEntry) (string, *catalog.ExternalLocationInfo, error) { updateRequest := catalog.UpdateExternalLocation{ Comment: config.Comment, CredentialName: config.CredentialName, diff --git a/bundle/direct/dresources/secret_scope_acls.go b/bundle/direct/dresources/secret_scope_acls.go index c35d53bd267..e9a2375eb06 100644 --- a/bundle/direct/dresources/secret_scope_acls.go +++ b/bundle/direct/dresources/secret_scope_acls.go @@ -101,7 +101,7 @@ func (r *ResourceSecretScopeAcls) DoCreate(ctx context.Context, state *SecretSco } // We implement DoUpdateWithId to ensure that the updated ID gets recorded in state. -func (r *ResourceSecretScopeAcls) DoUpdateWithID(ctx context.Context, id string, state *SecretScopeAclsState) (string, *SecretScopeAclsState, error) { +func (r *ResourceSecretScopeAcls) DoUpdateWithID(ctx context.Context, id string, state *SecretScopeAclsState, _ *PlanEntry) (string, *SecretScopeAclsState, error) { err := r.setACLs(ctx, state.ScopeName, state.Acls) if err != nil { return "", nil, err @@ -109,8 +109,8 @@ func (r *ResourceSecretScopeAcls) DoUpdateWithID(ctx context.Context, id string, return state.ScopeName, nil, nil } -func (r *ResourceSecretScopeAcls) DoUpdate(ctx context.Context, id string, state *SecretScopeAclsState, _ *PlanEntry) (*SecretScopeAclsState, error) { - _, _, err := r.DoUpdateWithID(ctx, id, state) +func (r *ResourceSecretScopeAcls) DoUpdate(ctx context.Context, id string, state *SecretScopeAclsState, entry *PlanEntry) (*SecretScopeAclsState, error) { + _, _, err := r.DoUpdateWithID(ctx, id, state, entry) return nil, err } diff --git a/bundle/direct/dresources/volume.go b/bundle/direct/dresources/volume.go index 6c96e66eccb..9d33f31ec71 100644 --- a/bundle/direct/dresources/volume.go +++ b/bundle/direct/dresources/volume.go @@ -79,7 +79,7 @@ func (r *ResourceVolume) DoUpdate(ctx context.Context, id string, config *catalo return response, err } -func (r *ResourceVolume) DoUpdateWithID(ctx context.Context, id string, config *catalog.CreateVolumeRequestContent) (string, *catalog.VolumeInfo, error) { +func (r *ResourceVolume) DoUpdateWithID(ctx context.Context, id string, config *catalog.CreateVolumeRequestContent, _ *PlanEntry) (string, *catalog.VolumeInfo, error) { updateRequest := catalog.UpdateVolumeRequestContent{ Comment: config.Comment, Name: id,