chore(interfaces): move data-mysql schemas to the new format - #669
james-garner-canonical wants to merge 1 commit into
Conversation
…ormat Interface schemas no longer wrap their models in the `ProviderSchema` and `RequirerSchema` classes from `pytest-interface-tester`. Instead a schema names all four databags directly, as `ProviderAppData`, `ProviderUnitData`, `RequirerAppData` and `RequirerUnitData`, setting a databag that is always empty to `None`. Naming all four makes an empty databag a deliberate choice a reviewer can see, and makes a misspelled name an error rather than a silently empty databag. The models are unchanged; only the wrapper classes around them are gone. Dropping the `pytest-interface-tester` import leaves Pydantic as the only dependency needed to read a schema. The new format is designed to be consumed by `ops.Relation.load` and to round-trip with `ops.Relation.save`, so the schemas define custom encoders and decoders (since `ops` assumes JSON encoding) and add Pydantic aliases for the hyphenated databag keys. A follow-up PR documents the format and adds a CI check for it, once every interface has been migrated. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
sinclert-canonical
left a comment
There was a problem hiding this comment.
Thanks James!
I understand this is a cross-interface effort (see GitHub search), so I will approve to have you unblocked. Worth noting: if some systematic / structure related issue is raised in any of the sibling PRs, we would ask for this interface definition to be updated as well.
In short: wait for feedback on all other PRs. If no one has anything to say, go brrrr.
astrojuanlu
left a comment
There was a problem hiding this comment.
I'm confused about versioning here, pardon my ignorance. I see this is part of mysql_client/interface/v0, but we're removing the MySQLProviderData class altogether. Shouldn't this be in a new v1?
Thanks, I appreciate the prompt review @sinclert-canonical! The majority of reviews are in and haven't identified any unforeseen issues here, so it seems it's time for me to press the green button :)
Good question @astrojuanlu. The trick here is that these exact schema files aren't consumed from outside this repo -- legacy tooling points to |
350bf1d to
16b5ed5
Compare
This PR replaces the
pytest-interface-testerwrappers in the schema with a new convention: naming all four databags directly, asProviderAppData,ProviderUnitData,RequirerAppDataandRequirerUnitData, setting a databag that is always empty toNone.The new format is designed to be consumed by
ops.Relation.loadand round-trip withops.Relation.save, so the schemas are tweaked to facilitate this -- we define custom encoders and decoders (sinceopsassumes JSON encoding), and add Pydantic aliases for the actual databag keys (hyphenated). Note that the__juju_encoder/decoder__convention used here is not (yet?) supported in Ops, for now it's just designed to be consumed by the repository machinery.A follow up PR will document this and add tooling to enforce it, after similar PRs have landed for all the other
CODEOWNERSin this repository.