Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions api/apiv1/design/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const (
cpuPattern = `^[0-9]+(\.[0-9]{1,3}|m)?$`
postgresVersionPattern = `^\d{2}\.\d{1,2}$`
spockVersionPattern = `^\d{1}$`
serviceVersionPattern = `^(\d+\.\d+\.\d+|latest)$`
serviceVersionPattern = `^(\d+\.\d+(\.\d+)?|latest)$`
)

var HostIDs = g.ArrayOf(Identifier, func() {
Expand Down Expand Up @@ -166,10 +166,10 @@ var ServiceSpec = g.Type("ServiceSpec", func() {
g.Meta("struct:tag:json", "service_type")
})
g.Attribute("version", g.String, func() {
g.Description("The version of the service in semver format (e.g., '1.0.0') or the literal 'latest'.")
g.Description("The version of the service (e.g., '1.0.0', '14.5') or the literal 'latest'.")
g.Pattern(serviceVersionPattern)
g.Example("1.0.0")
g.Example("1.2.3")
g.Example("14.5")
g.Example("latest")
g.Meta("struct:tag:json", "version")
})
Expand Down
3 changes: 1 addition & 2 deletions api/apiv1/gen/control_plane/service.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 5 additions & 8 deletions api/apiv1/gen/http/control_plane/client/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 5 additions & 8 deletions api/apiv1/gen/http/control_plane/server/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions api/apiv1/gen/http/openapi.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions api/apiv1/gen/http/openapi.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 14 additions & 14 deletions api/apiv1/gen/http/openapi3.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 14 additions & 14 deletions api/apiv1/gen/http/openapi3.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion server/internal/api/apiv1/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ func validateS3RepoProperties(props repoProperties, path []string) []error {
}

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

// reservedLabelPrefix is the label key prefix reserved for system use.
const reservedLabelPrefix = "pgedge."
Expand Down
10 changes: 10 additions & 0 deletions server/internal/api/apiv1/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,16 @@ func TestValidateServiceSpec(t *testing.T) {
},
},
},
{
name: "valid PostgREST service with two-part version",
svc: &api.ServiceSpec{
ServiceID: "postgrest",
ServiceType: "postgrest",
Version: "14.5",
HostIds: []api.Identifier{"host-1"},
Config: map[string]any{},
},
},
{
name: "valid MCP service with 'latest' version",
svc: &api.ServiceSpec{
Expand Down
47 changes: 47 additions & 0 deletions server/internal/orchestrator/swarm/postgrest_config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package swarm

import (
"bytes"
"fmt"

"github.com/pgEdge/control-plane/server/internal/database"
)

// PostgRESTConfigParams holds all inputs needed to generate a postgrest.conf file.
type PostgRESTConfigParams struct {
Config *database.PostgRESTServiceConfig
}

// GeneratePostgRESTConfig generates the postgrest.conf file content.
// Credentials are not written here; they are injected as libpq env vars at the container level.
func GeneratePostgRESTConfig(params *PostgRESTConfigParams) ([]byte, error) {
if params == nil {
return nil, fmt.Errorf("GeneratePostgRESTConfig: params must not be nil")
}
if params.Config == nil {
return nil, fmt.Errorf("GeneratePostgRESTConfig: params.Config must not be nil")
}
cfg := params.Config

var buf bytes.Buffer

fmt.Fprintf(&buf, "db-schemas = %q\n", cfg.DBSchemas)
fmt.Fprintf(&buf, "db-anon-role = %q\n", cfg.DBAnonRole)
fmt.Fprintf(&buf, "db-pool = %d\n", cfg.DBPool)
fmt.Fprintf(&buf, "db-max-rows = %d\n", cfg.MaxRows)

if cfg.JWTSecret != nil {
fmt.Fprintf(&buf, "jwt-secret = %q\n", *cfg.JWTSecret)
}
if cfg.JWTAud != nil {
fmt.Fprintf(&buf, "jwt-aud = %q\n", *cfg.JWTAud)
}
if cfg.JWTRoleClaimKey != nil {
fmt.Fprintf(&buf, "jwt-role-claim-key = %q\n", *cfg.JWTRoleClaimKey)
}
if cfg.ServerCORSAllowedOrigins != nil {
fmt.Fprintf(&buf, "server-cors-allowed-origins = %q\n", *cfg.ServerCORSAllowedOrigins)
}

return buf.Bytes(), nil
}
Loading