Skip to content

Commit 5a565ba

Browse files
denikIsaac
andcommitted
direct: delete remaining dumb RemapState methods (copier handles them)
Removes RemapState for apps, jobs, job_runs, pipelines, the postgres_* resources and quality_monitors - all plain subset copies the auto-generated copier reproduces. Only model_serving_endpoints, vector_search_indexes and secrets keep a RemapState for now; they need their own prep before the copier can take them, after which this PR (rebased) will delete them and remove the RemapState hook. Co-authored-by: Isaac <no-reply@databricks.com>
1 parent 862cca2 commit 5a565ba

13 files changed

Lines changed: 9 additions & 141 deletions

‎bundle/direct/dresources/app.go‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,18 +73,8 @@ func (*ResourceApp) PrepareState(input *resources.App) *AppState {
7373
return s
7474
}
7575

76-
// RemapState maps the remote AppRemote to AppState for diff comparison.
7776
// DoRead populates config, git_source, and source_code_path from the active
7877
// deployment when one exists, enabling drift detection for out-of-band redeploys.
79-
// Started is derived from compute status so the planner can detect start/stop changes.
80-
func (*ResourceApp) RemapState(remote *AppRemote) *AppState {
81-
return &AppState{
82-
App: remote.App,
83-
Config: remote.Config,
84-
Lifecycle: remote.Lifecycle,
85-
}
86-
}
87-
8878
func (r *ResourceApp) DoRead(ctx context.Context, id string) (*AppRemote, error) {
8979
app, err := r.client.Apps.GetByName(ctx, id)
9080
if err != nil {

‎bundle/direct/dresources/job.go‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,6 @@ func (*ResourceJob) PrepareState(input *resources.Job) *jobs.JobSettings {
5252
return &input.JobSettings
5353
}
5454

55-
func (*ResourceJob) RemapState(remote *JobRemote) *jobs.JobSettings {
56-
return &remote.JobSettings
57-
}
58-
5955
func getTaskKey(x jobs.Task) (string, string) {
6056
return "task_key", x.TaskKey
6157
}

‎bundle/direct/dresources/job_run.go‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -176,16 +176,6 @@ func (r *ResourceJobRun) DoRead(ctx context.Context, id string) (*JobRunRemote,
176176
return makeJobRunRemote(run), nil
177177
}
178178

179-
// RemapState extracts the fields used for diffing: the RunNow request and the
180-
// outcome the run reached. Lifecycle has no remote counterpart.
181-
func (*ResourceJobRun) RemapState(remote *JobRunRemote) *JobRunState {
182-
return &JobRunState{
183-
RunNow: remote.RunNow,
184-
ResultState: remote.ResultState,
185-
Lifecycle: nil,
186-
}
187-
}
188-
189179
func (r *ResourceJobRun) DoCreate(ctx context.Context, config *JobRunState) (string, *JobRunRemote, error) {
190180
// Mint a token so an SDK retry of a lost response returns the same run. Set it
191181
// on a copy: recording it in state would drift from the empty config and recreate.

‎bundle/direct/dresources/job_run_test.go‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,14 @@ func TestJobRunPrepareStateCopiesResolvedTriggers(t *testing.T) {
290290
assert.Empty(t, triggers.OnBundleDeploy)
291291
}
292292

293-
// The planner diffs RemapState(remote) against PrepareState(config), so a run
293+
// The planner diffs the remapped remote against PrepareState(config), so a run
294294
// that did not end in SUCCESS has to surface as a difference on result_state.
295+
// job_runs has no RemapState method, so this exercises the auto-generated copier.
295296
func TestJobRunRemapStateCarriesTheOutcome(t *testing.T) {
297+
adapters, err := InitAll(nil)
298+
require.NoError(t, err)
299+
adapter := adapters["job_runs"]
300+
296301
for _, outcome := range []jobs.RunResultState{
297302
jobs.RunResultStateSuccess,
298303
jobs.RunResultStateFailed,
@@ -302,7 +307,9 @@ func TestJobRunRemapStateCarriesTheOutcome(t *testing.T) {
302307
t.Run(string(outcome), func(t *testing.T) {
303308
remote := &JobRunRemote{RunId: 123, ResultState: outcome}
304309

305-
state := (&ResourceJobRun{}).RemapState(remote)
310+
remapped, err := adapter.RemapState(remote)
311+
require.NoError(t, err)
312+
state := remapped.(*JobRunState)
306313

307314
assert.Equal(t, outcome, state.ResultState)
308315
assert.Nil(t, state.Lifecycle)

‎bundle/direct/dresources/pipeline.go‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,6 @@ func (*ResourcePipeline) PrepareState(input *resources.Pipeline) *PipelineState
8181
}
8282
}
8383

84-
func (*ResourcePipeline) RemapState(remote *PipelineRemote) *PipelineState {
85-
return &PipelineState{
86-
CreatePipeline: remote.CreatePipeline,
87-
// cascade_on_destroy is input-only and absent from PipelineRemote, so it stays nil here.
88-
CascadeOnDestroy: nil,
89-
}
90-
}
91-
9284
func (r *ResourcePipeline) DoRead(ctx context.Context, id string) (*PipelineRemote, error) {
9385
resp, err := r.client.Pipelines.GetByPipelineId(ctx, id)
9486
if err != nil {

‎bundle/direct/dresources/postgres_branch.go‎

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -59,24 +59,6 @@ func (*ResourcePostgresBranch) PrepareState(input *resources.PostgresBranch) *Po
5959
}
6060
}
6161

62-
func (*ResourcePostgresBranch) RemapState(remote *PostgresBranchRemote) *PostgresBranchState {
63-
return &PostgresBranchState{
64-
BranchId: remote.BranchId,
65-
Parent: remote.Parent,
66-
67-
// replace_existing is a create-time-only flag; the GET API never returns
68-
// it, so RemapState leaves it false.
69-
ReplaceExisting: false,
70-
71-
// purge_on_delete is a delete-time query parameter; the GET API never
72-
// returns it, so RemapState leaves it false.
73-
PurgeOnDelete: false,
74-
ForceSendFields: nil,
75-
76-
BranchSpec: remote.BranchSpec,
77-
}
78-
}
79-
8062
// makePostgresBranchRemote converts the SDK Branch into the embedded remote shape.
8163
// GET does not echo spec today (only status is returned); the embedded spec fields
8264
// stay at their zero values, and postgres_branches.yml suppresses phantom drift via

‎bundle/direct/dresources/postgres_catalog.go‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,6 @@ func (*ResourcePostgresCatalog) PrepareState(input *resources.PostgresCatalog) *
5353
}
5454
}
5555

56-
func (*ResourcePostgresCatalog) RemapState(remote *PostgresCatalogRemote) *PostgresCatalogState {
57-
return &PostgresCatalogState{
58-
CatalogId: remote.CatalogId,
59-
CatalogCatalogSpec: remote.CatalogCatalogSpec,
60-
}
61-
}
62-
6356
// makePostgresCatalogRemote converts the SDK Catalog into the embedded remote shape.
6457
// GET does not echo spec today (only status is returned); the embedded spec fields
6558
// stay at their zero values, and postgres_catalogs.yml suppresses phantom drift via

‎bundle/direct/dresources/postgres_database.go‎

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,6 @@ func (*ResourcePostgresDatabase) PrepareState(input *resources.PostgresDatabase)
5656
}
5757
}
5858

59-
func (*ResourcePostgresDatabase) RemapState(remote *PostgresDatabaseRemote) *PostgresDatabaseState {
60-
return &PostgresDatabaseState{
61-
DatabaseId: remote.DatabaseId,
62-
Parent: remote.Parent,
63-
64-
// replace_existing is a create-time-only flag; the GET API never returns
65-
// it, so RemapState leaves it false.
66-
ReplaceExisting: false,
67-
68-
DatabaseDatabaseSpec: remote.DatabaseDatabaseSpec,
69-
}
70-
}
71-
7259
// makePostgresDatabaseRemote converts the SDK Database into the embedded remote
7360
// shape. GET does not echo spec today (only status is returned); the embedded
7461
// spec fields stay at their zero values, and postgres_databases.yml suppresses phantom

‎bundle/direct/dresources/postgres_endpoint.go‎

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -65,19 +65,6 @@ func (*ResourcePostgresEndpoint) PrepareState(input *resources.PostgresEndpoint)
6565
}
6666
}
6767

68-
func (*ResourcePostgresEndpoint) RemapState(remote *PostgresEndpointRemote) *PostgresEndpointState {
69-
return &PostgresEndpointState{
70-
EndpointId: remote.EndpointId,
71-
Parent: remote.Parent,
72-
73-
// replace_existing is a create-time-only flag; the GET API never returns
74-
// it, so RemapState leaves it false.
75-
ReplaceExisting: false,
76-
77-
EndpointSpec: remote.EndpointSpec,
78-
}
79-
}
80-
8168
// makePostgresEndpointRemote converts the SDK Endpoint into the embedded remote shape.
8269
// GET does not echo spec today (only status is returned); the embedded spec fields
8370
// stay at their zero values, and postgres_endpoints.yml suppresses phantom drift via

‎bundle/direct/dresources/postgres_project.go‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,6 @@ func (*ResourcePostgresProject) PrepareState(input *resources.PostgresProject) *
5959
}
6060
}
6161

62-
func (*ResourcePostgresProject) RemapState(remote *PostgresProjectRemote) *PostgresProjectState {
63-
return &PostgresProjectState{
64-
ProjectId: remote.ProjectId,
65-
ProjectSpec: remote.ProjectSpec,
66-
67-
// purge_on_delete is a delete-time query parameter; the GET API never
68-
// returns it, so RemapState leaves it false.
69-
PurgeOnDelete: false,
70-
ForceSendFields: nil,
71-
}
72-
}
73-
7462
// makePostgresProjectRemote converts the SDK Project into the embedded remote shape.
7563
// GET does not echo spec today (only status is returned); the embedded spec fields
7664
// stay at their zero values, and postgres_projects.yml suppresses phantom drift via

0 commit comments

Comments
 (0)