Skip to content

Commit f8de470

Browse files
committed
feat: add PostgREST image registry and schema/role preflight
- Pin postgrest image to ghcr.io/pgedge/postgrest:14.5 - Extend version pattern to accept two-part versions (e.g. 14.5) - Add PostgRESTPreflightResource with PrimaryExecutor to validate that configured schemas and anon role exist before provisioning - Refresh() returns ErrNotFound so the check re-runs on every apply - Extract connectToPrimaryDB as a package-level helper shared between ServiceUserRole and PostgRESTPreflightResource - All config fields optional: db_schemas defaults to "public", db_anon_role to "pgedge_application_read_only" PLAT-499, PLAT-500
1 parent a356068 commit f8de470

15 files changed

Lines changed: 323 additions & 65 deletions

File tree

api/apiv1/design/database.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const (
99
cpuPattern = `^[0-9]+(\.[0-9]{1,3}|m)?$`
1010
postgresVersionPattern = `^\d{2}\.\d{1,2}$`
1111
spockVersionPattern = `^\d{1}$`
12-
serviceVersionPattern = `^(\d+\.\d+\.\d+|latest)$`
12+
serviceVersionPattern = `^(\d+\.\d+(\.\d+)?|latest)$`
1313
)
1414

1515
var HostIDs = g.ArrayOf(Identifier, func() {
@@ -164,10 +164,10 @@ var ServiceSpec = g.Type("ServiceSpec", func() {
164164
g.Meta("struct:tag:json", "service_type")
165165
})
166166
g.Attribute("version", g.String, func() {
167-
g.Description("The version of the service in semver format (e.g., '1.0.0') or the literal 'latest'.")
167+
g.Description("The version of the service (e.g., '1.0.0', '14.5') or the literal 'latest'.")
168168
g.Pattern(serviceVersionPattern)
169169
g.Example("1.0.0")
170-
g.Example("1.2.3")
170+
g.Example("14.5")
171171
g.Example("latest")
172172
g.Meta("struct:tag:json", "version")
173173
})

api/apiv1/gen/control_plane/service.go

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/apiv1/gen/http/control_plane/client/types.go

Lines changed: 5 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/apiv1/gen/http/control_plane/server/types.go

Lines changed: 5 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/apiv1/gen/http/openapi.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/apiv1/gen/http/openapi.yaml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/apiv1/gen/http/openapi3.json

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/apiv1/gen/http/openapi3.yaml

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/internal/api/apiv1/validate.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ func validateS3RepoProperties(props repoProperties, path []string) []error {
602602
}
603603

604604
var pgBackRestOptionPattern = regexp.MustCompile(`^[a-z0-9-]+$`)
605-
var semverPattern = regexp.MustCompile(`^\d+\.\d+\.\d+$`)
605+
var semverPattern = regexp.MustCompile(`^\d+\.\d+(\.\d+)?$`)
606606

607607
// reservedLabelPrefix is the label key prefix reserved for system use.
608608
const reservedLabelPrefix = "pgedge."

server/internal/api/apiv1/validate_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -805,6 +805,16 @@ func TestValidateServiceSpec(t *testing.T) {
805805
},
806806
},
807807
},
808+
{
809+
name: "valid PostgREST service with two-part version",
810+
svc: &api.ServiceSpec{
811+
ServiceID: "postgrest",
812+
ServiceType: "postgrest",
813+
Version: "14.5",
814+
HostIds: []api.Identifier{"host-1"},
815+
Config: map[string]any{},
816+
},
817+
},
808818
{
809819
name: "valid MCP service with 'latest' version",
810820
svc: &api.ServiceSpec{

0 commit comments

Comments
 (0)