[DPE-8863] Custom username and prefixes for v1#258
Conversation
0bd5433 to
3f798ce
Compare
3f798ce to
f61dd66
Compare
72c3e5a to
371fba2
Compare
83c0c4c to
0b29a12
Compare
a94372a to
66af6bc
Compare
bddfdd4 to
4a7774a
Compare
2ee2a5e to
97a4f1a
Compare
97a4f1a to
557065c
Compare
| try: | ||
| secret = repository.get_secret( | ||
| secret_group, secret_uri=secret_uri, short_uuid=short_uuid | ||
| ) | ||
| except SecretNotFoundError: | ||
| # v0 deletes the requested entity secret | ||
| if secret_group == "requested-entity": | ||
| logger.debug("Missing requested entity secret") | ||
| continue | ||
| raise |
There was a problem hiding this comment.
v0 will delete the helper secret once the relation was established.
| mtls_cert: MtlsSecretStr = Field(default=None) | ||
| secret_requested_entity: SecretString | None = Field( | ||
| default=None, | ||
| validation_alias=AliasChoices("requested-entity-secret", "secret-requested-entity"), |
There was a problem hiding this comment.
Should match both the old and new secret field.
| entity_name: EntitySecretStr = Field(default=None) | ||
| entity_password: EntitySecretStr = Field(default=None) | ||
| version: str | None = Field(default=None) | ||
| prefix_resources: str | None = Field(default=None) |
There was a problem hiding this comment.
I wanted to use PlainSerializer to sort the CSV list, but it seems that the field_info.annotation in OptionalSecrets traps other annotations as well. Leaving it be for now.
There was a problem hiding this comment.
Interesting.
Maybe we can add just a field serializer for this one in this class ? Or that prevents it?
There was a problem hiding this comment.
What I tried to do was:
With the serialiser being:
data-platform-libs/lib/charms/data_platform_libs/v1/data_interfaces.py
Lines 1032 to 1036 in 4a7774a
But then the field got turned into a secret. I guess that the OptionalSecretStr alias traps this, since they are both str | None, but didn't dig further, since autosorting is nice to have, but not strictly necessary.
| "startup": "enabled", | ||
| "environment": { | ||
| "PGDATA": "/var/lib/postgresql/data/pgdata", | ||
| "PGDATA": "/var/lib/postgresql/data/pgdata/data", |
There was a problem hiding this comment.
For Canonical k8s compatibility (non-empty volume is provided).
| if response.prefix_resources: | ||
| self.interface.repository(relation_id).write_field( | ||
| "prefix-databases", response.prefix_resources | ||
| ) |
There was a problem hiding this comment.
Is there a better way to inject this field?
There was a problem hiding this comment.
Oh, this is because the field is renamed ?
Then probably we can do like we do for the other resources: here
There was a problem hiding this comment.
I think the original_field is still written in the provider response with write_field here:
data-platform-libs/lib/charms/data_platform_libs/v1/data_interfaces.py
Lines 2588 to 2596 in ba0faad
Gu1nness
left a comment
There was a problem hiding this comment.
All seems good.
Let's investigate on the CSV ordering.
For the prefix-database vs prefix-resource let's try like we do for the resource field.
Same pattern, a dedicated field that we don't serialize just to store the original field name.
| entity_name: EntitySecretStr = Field(default=None) | ||
| entity_password: EntitySecretStr = Field(default=None) | ||
| version: str | None = Field(default=None) | ||
| prefix_resources: str | None = Field(default=None) |
There was a problem hiding this comment.
Interesting.
Maybe we can add just a field serializer for this one in this class ? Or that prevents it?
| if response.prefix_resources: | ||
| self.interface.repository(relation_id).write_field( | ||
| "prefix-databases", response.prefix_resources | ||
| ) |
There was a problem hiding this comment.
Oh, this is because the field is renamed ?
Then probably we can do like we do for the other resources: here
Port of #239 and #245 for DPLv1