diff --git a/bundle/direct/apply.go b/bundle/direct/apply.go index 2f39e1072c..6b2fffe9a1 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 6025f5dc0b..ec9697dc3f 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 604100e92d..645fb933cd 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 64eace48eb..a1ea24e410 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 c35d53bd26..e9a2375eb0 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 6c96e66ecc..9d33f31ec7 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,