Skip to content

Commit 647bd80

Browse files
committed
Drop redundant postgres_catalogs lifecycle rules
The hand-written `branch`, `postgres_database`, and `create_database_if_missing` entries under `ignore_remote_changes` are already produced by the OpenAPI autogen (`spec:input_only`); `postgres_database` is also autogen'd under `recreate_on_changes` (`spec:immutable`). Drop the duplicates from `resources.yml`. `catalog_id` was in `ignore_remote_changes` only to mask the cosmetic `catalogs/` prefix that the old `RemapState` propagated from `remote.Name`. Source it from `remote.Status.CatalogId` instead — semantic contract from the API rather than string manipulation on the hierarchical path — and drop the entry. `catalog_id` stays in `recreate_on_changes` (synthetic hierarchical key, not in the API spec) along with `branch` and `create_database_if_missing` (no UpdateCatalog endpoint). Co-authored-by: Isaac
1 parent bbbf49f commit 647bd80

2 files changed

Lines changed: 14 additions & 27 deletions

File tree

bundle/direct/dresources/postgres_catalog.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,20 @@ func (*ResourcePostgresCatalog) PrepareState(input *resources.PostgresCatalog) *
2626
}
2727

2828
func (*ResourcePostgresCatalog) RemapState(remote *postgres.Catalog) *PostgresCatalogState {
29-
// The server-side ID is the full hierarchical name `catalogs/<catalog_id>`.
30-
// Keep it as-is — the `catalogs/` prefix is an inherent part of the ID, not
31-
// noise to strip.
29+
// Status.CatalogId is the short identifier and matches the user-supplied
30+
// config. Prefer it over parsing remote.Name — semantic contract from the
31+
// API rather than string manipulation on the hierarchical path.
3232
//
3333
// GET does not return the spec today (only status). Return an empty spec
34-
// and rely on the ignore_remote_changes / input_only classifications in
35-
// resources.yml to suppress phantom drift until the backend starts
34+
// and rely on the spec:input_only classifications generated from the
35+
// OpenAPI schema to suppress phantom drift until the backend starts
3636
// echoing spec values on GET.
37+
var catalogId string
38+
if remote.Status != nil {
39+
catalogId = remote.Status.CatalogId
40+
}
3741
return &PostgresCatalogState{
38-
CatalogId: remote.Name,
42+
CatalogId: catalogId,
3943
CatalogCatalogSpec: postgres.CatalogCatalogSpec{
4044
Branch: "",
4145
CreateDatabaseIfMissing: false,

bundle/direct/dresources/resources.yml

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -513,31 +513,14 @@ resources:
513513
# catalog_id is part of the hierarchical name and immutable.
514514
- field: catalog_id
515515
reason: immutable
516-
# The Postgres SDK has no UpdateCatalog endpoint, so any local change to
517-
# a spec field requires delete+create. recreate_on_changes fires on the
518-
# intent diff (local config vs. persisted state); ignore_remote_changes
519-
# below silences the orthogonal drift diff (persisted state vs. RemapState).
516+
# The Postgres SDK has no UpdateCatalog endpoint, so any local change
517+
# requires delete+create. The OpenAPI spec only marks postgres_database
518+
# as IMMUTABLE (handled by autogen); branch and create_database_if_missing
519+
# need explicit entries here.
520520
- field: branch
521521
reason: immutable
522-
- field: postgres_database
523-
reason: immutable
524522
- field: create_database_if_missing
525523
reason: immutable
526-
ignore_remote_changes:
527-
# The remote .Name always carries the "catalogs/" prefix while the
528-
# user-supplied catalog_id does not. The framework's state ID still
529-
# holds the full prefixed name; this just suppresses the cosmetic diff.
530-
- field: catalog_id
531-
reason: input_only
532-
# The catalog API does not currently echo back spec values on GET; the
533-
# missing remote values would otherwise trigger phantom drift. Lift
534-
# these once the backend starts returning spec on GET.
535-
- field: branch
536-
reason: input_only
537-
- field: postgres_database
538-
reason: input_only
539-
- field: create_database_if_missing
540-
reason: input_only
541524

542525
vector_search_endpoints:
543526
recreate_on_changes:

0 commit comments

Comments
 (0)