Skip to content
This repository was archived by the owner on Nov 26, 2025. It is now read-only.

Commit f221c82

Browse files
authored
[DPE-7302] Add prefix-databases field (#307)
Adds `prefix-databases` , reporting databases matching a requested prefix Implementation PR: canonical/data-platform-libs#245 Specification: DA190
1 parent c382a49 commit f221c82

3 files changed

Lines changed: 27 additions & 2 deletions

File tree

docs/json_schemas/postgresql_client/v0/provider.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,22 @@
200200
"alphanum-32byte-random"
201201
],
202202
"title": "Entity password"
203+
},
204+
"prefix-databases": {
205+
"anyOf": [
206+
{
207+
"type": "string"
208+
},
209+
{
210+
"type": "null"
211+
}
212+
],
213+
"default": null,
214+
"description": "Comma separated list of databases matching a requested prefix",
215+
"examples": [
216+
"database1,database2"
217+
],
218+
"title": "Prefix databases"
203219
}
204220
},
205221
"required": [

interfaces/postgresql_client/v0/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ If any side, Provider or Requirer doesn't support Juju Secrets, sensitive inform
3232
- Is expected to provide custom entity credentials (`entity-name` and `entity-password`) in a Juju Secret whenever the Requirer supplies both the `database` and `entity-type` fields.
3333
- Is expected to expose the Juju Secrets URI to the credentials through the `secret-user` field of the data bag.
3434
- Is expected to provide the `endpoints` field with the address of Primary, which can be used for Read/Write queries.
35-
- Is expected to provide the `database` field with the database that was actually created.
35+
- Is expected to provide the `database` field with the database that was actually created or the prefix requested by the requirer.
3636
- Is expected to provide the `uris` field with the connection string, in libpq's URI format, which can be used for direct connection to the db.
3737
- Is expected to provide the `read-only-uris` field with the connection string when requested as a secret field, in libpq's URI format, which can be used for direct connection to a read only edpoint of a cluster.
3838
- Is expected to provide optional `read-only-endpoints` field with a comma-separated list of hosts or one Kubernetes Service, which can be used for Read-only queries.
@@ -44,11 +44,12 @@ If any side, Provider or Requirer doesn't support Juju Secrets, sensitive inform
4444
- Is expected to express (via `external-node-connectivity`) whether external connectivity requests are to be respected or not, in case the charm is capable of such.
4545
- May require delays (via `subordinated`) to provide service on Requirer scale up. If so, it is expected to set unit level `state` data when it is `ready` to serve.
4646
- May respect the `entity-name` and `password` set in `requested-entity-secret`.
47+
- Is expected to populate `prefix-databases`, if a prefix was requested and any databases match the prefix.
4748

4849
### Requirer
4950

5051
- Is expected to provide `requested-secrets`, which is a list of field names that are not to be exposed on the relation databag, but handled within Juju Secrets. It should be JSON parsable array of strings, and correspond to valid Juju Secret keys (i.e. alphanumerical characters with a potential '-' (dash) character). Secret fields must contain `username` and `password` (and `tls-ca` in case TLS is enabled).
51-
- Is expected to provide a database name in the `database` field.
52+
- Is expected to provide either a database name field or a prefix (ending in `*` and containing at least three additional characters) in the `database` field.
5253
- Is expected to have unique credentials for each relation. Therefore, different instances of the same Charm (juju applications) will have different relations with different credentials.
5354
- Is expected to have different relations names on Requirer with the same interface name if Requirer needs access to multiple database charms.
5455
- Is expected to allow multiple different Juju applications to access the same database name.

interfaces/postgresql_client/v0/schema.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,14 @@ class PostgreSQLProviderData(BaseModel):
113113
title="Entity password",
114114
)
115115

116+
prefix_databases: Optional[str] = Field(
117+
None,
118+
alias="prefix-databases",
119+
description="Comma separated list of databases matching a requested prefix",
120+
examples=["database1,database2"],
121+
title="Prefix databases",
122+
)
123+
116124

117125
class PostgreSQLRequirerData(BaseModel):
118126
"""The databag for the requirer side of this interface."""

0 commit comments

Comments
 (0)