canonical / charm-relation-interfaces

Opinionated and standardized interface specifications for charmed operator relations.
https://canonical.github.io/charm-relation-interfaces/
Apache License 2.0
16 stars 47 forks source link

update prometheus_scrape for pydantic v2 #154

Closed ca-scribner closed 3 months ago

ca-scribner commented 3 months ago

The prometheus_scrape interface has an optional metrics_path data field. In pydantic v1, this can be defined by simply setting `metrics_path: Optional[str] = ...`` in the class definition, however pydantic v2 now requires the field default to be set for any optional parameters. This means that any application using this interface with pydantic v2 was required to specify metrics_path.

This commit fixes this issue, restoring metrics_path to being optional for pydantic v2. See this thread for more details.

This fix is demonstrated working in this pr, specifically this commit which bumps to the modified schema and now passes scenario tests the previously failed.