Skip to content

Commit f445b11

Browse files
committed
fix(postgres): use intOrString for postgresql.parameters, regenerate schema
Switch the postgresql.parameters field annotation from {map[string]string} to {map[string]intOrString}, which generates a JSON Schema with anyOf: [{type: integer}, {type: string}] plus the x-kubernetes-int-or-string extension. This lets users supply PostgreSQL parameters as bare integers (max_connections: 100) or quoted strings (max_connections: "100") without triggering schema validation errors. The Helm template already coerces any value to a string via {{ $value | toString | quote }}, so runtime behavior is unchanged. Bump CI to cozyvalues-gen v1.3.1, which adds intOrString alias support (see cozystack/cozyvalues-gen#25). The generated Go type changes from map[string]string to map[string]intstr.IntOrString; the Application spec is stored as raw JSON so there is no runtime unmarshaling impact. Signed-off-by: IvanHunters <[email protected]>
1 parent a5040e4 commit f445b11

5 files changed

Lines changed: 17 additions & 11 deletions

File tree

‎.github/workflows/pre-commit.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
4848
- name: Install generate
4949
run: |
50-
curl -sSL https://github.com/cozystack/cozyvalues-gen/releases/download/v1.3.0/cozyvalues-gen-linux-amd64.tar.gz | tar -xzvf- -C /usr/local/bin/ cozyvalues-gen
50+
curl -sSL https://github.com/cozystack/cozyvalues-gen/releases/download/v1.3.1/cozyvalues-gen-linux-amd64.tar.gz | tar -xzvf- -C /usr/local/bin/ cozyvalues-gen
5151
5252
- name: Run pre-commit hooks
5353
run: |

‎api/apps/v1alpha1/postgresql/types.go‎

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

‎packages/apps/postgres/README.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,10 @@ See:
177177

178178
### Application-specific parameters
179179

180-
| Name | Description | Type | Value |
181-
| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------- | ----- |
182-
| `postgresql` | PostgreSQL server configuration. | `object` | `{}` |
183-
| `postgresql.parameters` | PostgreSQL server parameters. All values must be strings (quote numbers: "100"). BLOCKED (enable arbitrary code execution): archive_command, restore_command, ssl_passphrase_command, dynamic_library_path, local_preload_libraries, session_preload_libraries, shared_preload_libraries. Do NOT override CloudNativePG-managed parameters: archive_mode, primary_conninfo, wal_level, max_replication_slots. | `map[string]string` | `{}` |
180+
| Name | Description | Type | Value |
181+
| ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------ | ----- |
182+
| `postgresql` | PostgreSQL server configuration. | `object` | `{}` |
183+
| `postgresql.parameters` | PostgreSQL server parameters. String values are preferred (quote numbers: "100"); integer values are also accepted and converted to strings automatically. BLOCKED (enable arbitrary code execution): archive_command, restore_command, ssl_passphrase_command, dynamic_library_path, local_preload_libraries, session_preload_libraries, shared_preload_libraries. Do NOT override CloudNativePG-managed parameters: archive_mode, primary_conninfo, wal_level, max_replication_slots. | `map[string]intOrString` | `{}` |
184184

185185

186186
### Quorum-based synchronous replication

‎packages/apps/postgres/values.schema.json‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,14 @@
144144
},
145145
"additionalProperties": {
146146
"anyOf": [
147-
{"type": "string"},
148-
{"type": "integer"}
149-
]
147+
{
148+
"type": "integer"
149+
},
150+
{
151+
"type": "string"
152+
}
153+
],
154+
"x-kubernetes-int-or-string": true
150155
}
151156
}
152157
}

‎packages/apps/postgres/values.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ version: v18
8989
##
9090

9191
## @typedef {struct} PostgreSQL - PostgreSQL server configuration.
92-
## @field {map[string]string} [parameters] - PostgreSQL server parameters. All values must be strings (quote numbers: "100"). BLOCKED (enable arbitrary code execution): archive_command, restore_command, ssl_passphrase_command, dynamic_library_path, local_preload_libraries, session_preload_libraries, shared_preload_libraries. Do NOT override CloudNativePG-managed parameters: archive_mode, primary_conninfo, wal_level, max_replication_slots.
92+
## @field {map[string]intOrString} [parameters] - PostgreSQL server parameters. String values are preferred (quote numbers: "100"); integer values are also accepted and converted to strings automatically. BLOCKED (enable arbitrary code execution): archive_command, restore_command, ssl_passphrase_command, dynamic_library_path, local_preload_libraries, session_preload_libraries, shared_preload_libraries. Do NOT override CloudNativePG-managed parameters: archive_mode, primary_conninfo, wal_level, max_replication_slots.
9393

9494
## @param {PostgreSQL} postgresql - PostgreSQL server configuration.
9595
postgresql:

0 commit comments

Comments
 (0)