Skip to content

Commit 865d695

Browse files
authored
postgres: embed spec on Branch/Endpoint/Project remote types (#5273)
Define `Postgres{Branch,Endpoint,Project}Remote` types that embed the corresponding SDK `*Spec` and expose the identifier and output-only fields at the top level. `DoRead` returns the new shape so state-side and remote-side paths line up, which is a prerequisite for drift detection on spec fields once the backend starts echoing spec on GET. Today the embedded fields are auto-classified `spec:input_only` from the API field behaviors in `resources.generated.yml`, so drift is correctly suppressed. Follows the pattern set by `PipelineRemote` and `AppRemote`. Prompted by #5265 (comment). This pull request and its description were written by Isaac.
1 parent 75586fd commit 865d695

14 files changed

Lines changed: 260 additions & 187 deletions

File tree

acceptance/bundle/refschema/out.fields.txt

Lines changed: 40 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -2695,29 +2695,21 @@ resources.pipelines.*.permissions[*].group_name string ALL
26952695
resources.pipelines.*.permissions[*].level iam.PermissionLevel ALL
26962696
resources.pipelines.*.permissions[*].service_principal_name string ALL
26972697
resources.pipelines.*.permissions[*].user_name string ALL
2698-
resources.postgres_branches.*.branch_id string INPUT STATE
2698+
resources.postgres_branches.*.branch_id string ALL
26992699
resources.postgres_branches.*.create_time *time.Time REMOTE
2700-
resources.postgres_branches.*.expire_time *time.Time INPUT STATE
2700+
resources.postgres_branches.*.expire_time *time.Time ALL
27012701
resources.postgres_branches.*.id string INPUT
2702-
resources.postgres_branches.*.is_protected bool INPUT STATE
2702+
resources.postgres_branches.*.is_protected bool ALL
27032703
resources.postgres_branches.*.lifecycle resources.Lifecycle INPUT
27042704
resources.postgres_branches.*.lifecycle.prevent_destroy bool INPUT
27052705
resources.postgres_branches.*.modified_status string INPUT
27062706
resources.postgres_branches.*.name string REMOTE
2707-
resources.postgres_branches.*.no_expiry bool INPUT STATE
2707+
resources.postgres_branches.*.no_expiry bool ALL
27082708
resources.postgres_branches.*.parent string ALL
27092709
resources.postgres_branches.*.replace_existing bool INPUT STATE
2710-
resources.postgres_branches.*.source_branch string INPUT STATE
2711-
resources.postgres_branches.*.source_branch_lsn string INPUT STATE
2712-
resources.postgres_branches.*.source_branch_time *time.Time INPUT STATE
2713-
resources.postgres_branches.*.spec *postgres.BranchSpec REMOTE
2714-
resources.postgres_branches.*.spec.expire_time *time.Time REMOTE
2715-
resources.postgres_branches.*.spec.is_protected bool REMOTE
2716-
resources.postgres_branches.*.spec.no_expiry bool REMOTE
2717-
resources.postgres_branches.*.spec.source_branch string REMOTE
2718-
resources.postgres_branches.*.spec.source_branch_lsn string REMOTE
2719-
resources.postgres_branches.*.spec.source_branch_time *time.Time REMOTE
2720-
resources.postgres_branches.*.spec.ttl *duration.Duration REMOTE
2710+
resources.postgres_branches.*.source_branch string ALL
2711+
resources.postgres_branches.*.source_branch_lsn string ALL
2712+
resources.postgres_branches.*.source_branch_time *time.Time ALL
27212713
resources.postgres_branches.*.status *postgres.BranchStatus REMOTE
27222714
resources.postgres_branches.*.status.branch_id string REMOTE
27232715
resources.postgres_branches.*.status.current_state postgres.BranchStatusState REMOTE
@@ -2730,45 +2722,31 @@ resources.postgres_branches.*.status.source_branch string REMOTE
27302722
resources.postgres_branches.*.status.source_branch_lsn string REMOTE
27312723
resources.postgres_branches.*.status.source_branch_time *time.Time REMOTE
27322724
resources.postgres_branches.*.status.state_change_time *time.Time REMOTE
2733-
resources.postgres_branches.*.ttl *duration.Duration INPUT STATE
2725+
resources.postgres_branches.*.ttl *duration.Duration ALL
27342726
resources.postgres_branches.*.uid string REMOTE
27352727
resources.postgres_branches.*.update_time *time.Time REMOTE
27362728
resources.postgres_branches.*.url string INPUT
2737-
resources.postgres_endpoints.*.autoscaling_limit_max_cu float64 INPUT STATE
2738-
resources.postgres_endpoints.*.autoscaling_limit_min_cu float64 INPUT STATE
2729+
resources.postgres_endpoints.*.autoscaling_limit_max_cu float64 ALL
2730+
resources.postgres_endpoints.*.autoscaling_limit_min_cu float64 ALL
27392731
resources.postgres_endpoints.*.create_time *time.Time REMOTE
2740-
resources.postgres_endpoints.*.disabled bool INPUT STATE
2741-
resources.postgres_endpoints.*.endpoint_id string INPUT STATE
2742-
resources.postgres_endpoints.*.endpoint_type postgres.EndpointType INPUT STATE
2743-
resources.postgres_endpoints.*.group *postgres.EndpointGroupSpec INPUT STATE
2744-
resources.postgres_endpoints.*.group.enable_readable_secondaries bool INPUT STATE
2745-
resources.postgres_endpoints.*.group.max int INPUT STATE
2746-
resources.postgres_endpoints.*.group.min int INPUT STATE
2732+
resources.postgres_endpoints.*.disabled bool ALL
2733+
resources.postgres_endpoints.*.endpoint_id string ALL
2734+
resources.postgres_endpoints.*.endpoint_type postgres.EndpointType ALL
2735+
resources.postgres_endpoints.*.group *postgres.EndpointGroupSpec ALL
2736+
resources.postgres_endpoints.*.group.enable_readable_secondaries bool ALL
2737+
resources.postgres_endpoints.*.group.max int ALL
2738+
resources.postgres_endpoints.*.group.min int ALL
27472739
resources.postgres_endpoints.*.id string INPUT
27482740
resources.postgres_endpoints.*.lifecycle resources.Lifecycle INPUT
27492741
resources.postgres_endpoints.*.lifecycle.prevent_destroy bool INPUT
27502742
resources.postgres_endpoints.*.modified_status string INPUT
27512743
resources.postgres_endpoints.*.name string REMOTE
2752-
resources.postgres_endpoints.*.no_suspension bool INPUT STATE
2744+
resources.postgres_endpoints.*.no_suspension bool ALL
27532745
resources.postgres_endpoints.*.parent string ALL
27542746
resources.postgres_endpoints.*.replace_existing bool INPUT STATE
2755-
resources.postgres_endpoints.*.settings *postgres.EndpointSettings INPUT STATE
2756-
resources.postgres_endpoints.*.settings.pg_settings map[string]string INPUT STATE
2757-
resources.postgres_endpoints.*.settings.pg_settings.* string INPUT STATE
2758-
resources.postgres_endpoints.*.spec *postgres.EndpointSpec REMOTE
2759-
resources.postgres_endpoints.*.spec.autoscaling_limit_max_cu float64 REMOTE
2760-
resources.postgres_endpoints.*.spec.autoscaling_limit_min_cu float64 REMOTE
2761-
resources.postgres_endpoints.*.spec.disabled bool REMOTE
2762-
resources.postgres_endpoints.*.spec.endpoint_type postgres.EndpointType REMOTE
2763-
resources.postgres_endpoints.*.spec.group *postgres.EndpointGroupSpec REMOTE
2764-
resources.postgres_endpoints.*.spec.group.enable_readable_secondaries bool REMOTE
2765-
resources.postgres_endpoints.*.spec.group.max int REMOTE
2766-
resources.postgres_endpoints.*.spec.group.min int REMOTE
2767-
resources.postgres_endpoints.*.spec.no_suspension bool REMOTE
2768-
resources.postgres_endpoints.*.spec.settings *postgres.EndpointSettings REMOTE
2769-
resources.postgres_endpoints.*.spec.settings.pg_settings map[string]string REMOTE
2770-
resources.postgres_endpoints.*.spec.settings.pg_settings.* string REMOTE
2771-
resources.postgres_endpoints.*.spec.suspend_timeout_duration *duration.Duration REMOTE
2747+
resources.postgres_endpoints.*.settings *postgres.EndpointSettings ALL
2748+
resources.postgres_endpoints.*.settings.pg_settings map[string]string ALL
2749+
resources.postgres_endpoints.*.settings.pg_settings.* string ALL
27722750
resources.postgres_endpoints.*.status *postgres.EndpointStatus REMOTE
27732751
resources.postgres_endpoints.*.status.autoscaling_limit_max_cu float64 REMOTE
27742752
resources.postgres_endpoints.*.status.autoscaling_limit_min_cu float64 REMOTE
@@ -2788,28 +2766,28 @@ resources.postgres_endpoints.*.status.settings *postgres.EndpointSettings REMOTE
27882766
resources.postgres_endpoints.*.status.settings.pg_settings map[string]string REMOTE
27892767
resources.postgres_endpoints.*.status.settings.pg_settings.* string REMOTE
27902768
resources.postgres_endpoints.*.status.suspend_timeout_duration *duration.Duration REMOTE
2791-
resources.postgres_endpoints.*.suspend_timeout_duration *duration.Duration INPUT STATE
2769+
resources.postgres_endpoints.*.suspend_timeout_duration *duration.Duration ALL
27922770
resources.postgres_endpoints.*.uid string REMOTE
27932771
resources.postgres_endpoints.*.update_time *time.Time REMOTE
27942772
resources.postgres_endpoints.*.url string INPUT
2795-
resources.postgres_projects.*.budget_policy_id string INPUT STATE
2773+
resources.postgres_projects.*.budget_policy_id string ALL
27962774
resources.postgres_projects.*.create_time *time.Time REMOTE
2797-
resources.postgres_projects.*.custom_tags []postgres.ProjectCustomTag INPUT STATE
2798-
resources.postgres_projects.*.custom_tags[*] postgres.ProjectCustomTag INPUT STATE
2799-
resources.postgres_projects.*.custom_tags[*].key string INPUT STATE
2800-
resources.postgres_projects.*.custom_tags[*].value string INPUT STATE
2801-
resources.postgres_projects.*.default_branch string INPUT STATE
2802-
resources.postgres_projects.*.default_endpoint_settings *postgres.ProjectDefaultEndpointSettings INPUT STATE
2803-
resources.postgres_projects.*.default_endpoint_settings.autoscaling_limit_max_cu float64 INPUT STATE
2804-
resources.postgres_projects.*.default_endpoint_settings.autoscaling_limit_min_cu float64 INPUT STATE
2805-
resources.postgres_projects.*.default_endpoint_settings.no_suspension bool INPUT STATE
2806-
resources.postgres_projects.*.default_endpoint_settings.pg_settings map[string]string INPUT STATE
2807-
resources.postgres_projects.*.default_endpoint_settings.pg_settings.* string INPUT STATE
2808-
resources.postgres_projects.*.default_endpoint_settings.suspend_timeout_duration *duration.Duration INPUT STATE
2775+
resources.postgres_projects.*.custom_tags []postgres.ProjectCustomTag ALL
2776+
resources.postgres_projects.*.custom_tags[*] postgres.ProjectCustomTag ALL
2777+
resources.postgres_projects.*.custom_tags[*].key string ALL
2778+
resources.postgres_projects.*.custom_tags[*].value string ALL
2779+
resources.postgres_projects.*.default_branch string ALL
2780+
resources.postgres_projects.*.default_endpoint_settings *postgres.ProjectDefaultEndpointSettings ALL
2781+
resources.postgres_projects.*.default_endpoint_settings.autoscaling_limit_max_cu float64 ALL
2782+
resources.postgres_projects.*.default_endpoint_settings.autoscaling_limit_min_cu float64 ALL
2783+
resources.postgres_projects.*.default_endpoint_settings.no_suspension bool ALL
2784+
resources.postgres_projects.*.default_endpoint_settings.pg_settings map[string]string ALL
2785+
resources.postgres_projects.*.default_endpoint_settings.pg_settings.* string ALL
2786+
resources.postgres_projects.*.default_endpoint_settings.suspend_timeout_duration *duration.Duration ALL
28092787
resources.postgres_projects.*.delete_time *time.Time REMOTE
2810-
resources.postgres_projects.*.display_name string INPUT STATE
2811-
resources.postgres_projects.*.enable_pg_native_login bool INPUT STATE
2812-
resources.postgres_projects.*.history_retention_duration *duration.Duration INPUT STATE
2788+
resources.postgres_projects.*.display_name string ALL
2789+
resources.postgres_projects.*.enable_pg_native_login bool ALL
2790+
resources.postgres_projects.*.history_retention_duration *duration.Duration ALL
28132791
resources.postgres_projects.*.id string INPUT
28142792
resources.postgres_projects.*.initial_endpoint_spec *postgres.InitialEndpointSpec REMOTE
28152793
resources.postgres_projects.*.initial_endpoint_spec.group *postgres.EndpointGroupSpec REMOTE
@@ -2820,27 +2798,9 @@ resources.postgres_projects.*.lifecycle resources.Lifecycle INPUT
28202798
resources.postgres_projects.*.lifecycle.prevent_destroy bool INPUT
28212799
resources.postgres_projects.*.modified_status string INPUT
28222800
resources.postgres_projects.*.name string REMOTE
2823-
resources.postgres_projects.*.pg_version int INPUT STATE
2824-
resources.postgres_projects.*.project_id string INPUT STATE
2801+
resources.postgres_projects.*.pg_version int ALL
2802+
resources.postgres_projects.*.project_id string ALL
28252803
resources.postgres_projects.*.purge_time *time.Time REMOTE
2826-
resources.postgres_projects.*.spec *postgres.ProjectSpec REMOTE
2827-
resources.postgres_projects.*.spec.budget_policy_id string REMOTE
2828-
resources.postgres_projects.*.spec.custom_tags []postgres.ProjectCustomTag REMOTE
2829-
resources.postgres_projects.*.spec.custom_tags[*] postgres.ProjectCustomTag REMOTE
2830-
resources.postgres_projects.*.spec.custom_tags[*].key string REMOTE
2831-
resources.postgres_projects.*.spec.custom_tags[*].value string REMOTE
2832-
resources.postgres_projects.*.spec.default_branch string REMOTE
2833-
resources.postgres_projects.*.spec.default_endpoint_settings *postgres.ProjectDefaultEndpointSettings REMOTE
2834-
resources.postgres_projects.*.spec.default_endpoint_settings.autoscaling_limit_max_cu float64 REMOTE
2835-
resources.postgres_projects.*.spec.default_endpoint_settings.autoscaling_limit_min_cu float64 REMOTE
2836-
resources.postgres_projects.*.spec.default_endpoint_settings.no_suspension bool REMOTE
2837-
resources.postgres_projects.*.spec.default_endpoint_settings.pg_settings map[string]string REMOTE
2838-
resources.postgres_projects.*.spec.default_endpoint_settings.pg_settings.* string REMOTE
2839-
resources.postgres_projects.*.spec.default_endpoint_settings.suspend_timeout_duration *duration.Duration REMOTE
2840-
resources.postgres_projects.*.spec.display_name string REMOTE
2841-
resources.postgres_projects.*.spec.enable_pg_native_login bool REMOTE
2842-
resources.postgres_projects.*.spec.history_retention_duration *duration.Duration REMOTE
2843-
resources.postgres_projects.*.spec.pg_version int REMOTE
28442804
resources.postgres_projects.*.status *postgres.ProjectStatus REMOTE
28452805
resources.postgres_projects.*.status.branch_logical_size_limit_bytes int64 REMOTE
28462806
resources.postgres_projects.*.status.budget_policy_id string REMOTE

acceptance/bundle/resources/postgres_branches/update_protected/out.plan.no_change.direct.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
],
88
"action": "skip",
99
"remote_state": {
10+
"branch_id": "dev-branch",
1011
"create_time": "[TIMESTAMP]",
1112
"name": "[DEV_BRANCH_ID]",
1213
"parent": "projects/test-pg-proj-[UNIQUE_NAME]",

acceptance/bundle/resources/postgres_branches/update_protected/out.plan.restore.direct.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
}
1616
},
1717
"remote_state": {
18+
"branch_id": "dev-branch",
1819
"create_time": "[TIMESTAMP]",
1920
"name": "[DEV_BRANCH_ID]",
2021
"parent": "projects/test-pg-proj-[UNIQUE_NAME]",

acceptance/bundle/resources/postgres_branches/update_protected/out.plan.update.direct.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
}
1616
},
1717
"remote_state": {
18+
"branch_id": "dev-branch",
1819
"create_time": "[TIMESTAMP]",
1920
"name": "[DEV_BRANCH_ID]",
2021
"parent": "projects/test-pg-proj-[UNIQUE_NAME]",

acceptance/bundle/resources/postgres_endpoints/update_autoscaling/out.plan.no_change.direct.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
"action": "skip",
99
"remote_state": {
1010
"create_time": "[TIMESTAMP]",
11+
"endpoint_id": "my-endpoint",
12+
"endpoint_type": "",
1113
"name": "[MY_ENDPOINT_ID]",
1214
"parent": "projects/test-pg-proj-[UNIQUE_NAME]/branches/main",
1315
"status": {

acceptance/bundle/resources/postgres_endpoints/update_autoscaling/out.plan.restore.direct.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
},
1919
"remote_state": {
2020
"create_time": "[TIMESTAMP]",
21+
"endpoint_id": "my-endpoint",
22+
"endpoint_type": "",
2123
"name": "[MY_ENDPOINT_ID]",
2224
"parent": "projects/test-pg-proj-[UNIQUE_NAME]/branches/main",
2325
"status": {

acceptance/bundle/resources/postgres_endpoints/update_autoscaling/out.plan.update.direct.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
},
1919
"remote_state": {
2020
"create_time": "[TIMESTAMP]",
21+
"endpoint_id": "my-endpoint",
22+
"endpoint_type": "",
2123
"name": "[MY_ENDPOINT_ID]",
2224
"parent": "projects/test-pg-proj-[UNIQUE_NAME]/branches/main",
2325
"status": {

acceptance/bundle/resources/postgres_projects/update_display_name/out.plan.no_change.direct.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"remote_state": {
44
"create_time": "[TIMESTAMP]",
55
"name": "[MY_PROJECT_ID]",
6+
"project_id": "test-pg-proj-[UNIQUE_NAME]",
67
"status": {
78
"branch_logical_size_limit_bytes": [NUMID],
89
"default_branch": "[MY_PROJECT_ID]/branches/production",

acceptance/bundle/resources/postgres_projects/update_display_name/out.plan.restore.direct.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"remote_state": {
1717
"create_time": "[TIMESTAMP]",
1818
"name": "[MY_PROJECT_ID]",
19+
"project_id": "test-pg-proj-[UNIQUE_NAME]",
1920
"status": {
2021
"branch_logical_size_limit_bytes": [NUMID],
2122
"default_branch": "[MY_PROJECT_ID]/branches/production",

acceptance/bundle/resources/postgres_projects/update_display_name/out.plan.update.direct.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"remote_state": {
1717
"create_time": "[TIMESTAMP]",
1818
"name": "[MY_PROJECT_ID]",
19+
"project_id": "test-pg-proj-[UNIQUE_NAME]",
1920
"status": {
2021
"branch_logical_size_limit_bytes": [NUMID],
2122
"default_branch": "[MY_PROJECT_ID]/branches/production",

0 commit comments

Comments
 (0)