3.4.0: a low-level API for the Juju hook commands
The main feature in this release is the introduction of ops.hookcmds, which provides an API to the Juju hook commands. The API is low-level, complete (other than deprecated commands), and generally a 1-1 mapping to the hook commands, but providing a Pythonic interface.
Additionally, the length of the defer queue is now logged; more arguments can be passed as paths to ops.Container and ops.PebbleClient methods; and state transition testing Context has gained optional availability zone and principal unit arguments.
What's Changed
Breaking Changes
There are breaking changes in this release. Please review them carefully:
- Fix: Change
JujuContext.machine_idfrominttostrin #2108- Note that this fix was already included in Ops 3.3.1
- If you use this field, you may need to adjust type hints in your code
- Fix: Ensure that the testing context manager is exited when an exception occurs in #2117
- If you use
ops.testing.Contextas a context manager and expect the charm to raise an exception, you need to adjust the expected exception type.
- If you use
Features
- Add a low-level API for the Juju hook commands in #2019
- Make PebbleClient file methods also accept pathlib.PurePath in #2097
- Log the total number of deferred events in #2161
- Allow setting the Juju availability zone and principal unit in the testing Context in #2187
Fixes
- Allow actions without params or descriptions in ops[testing] in #2090
- Ensure
ops.Pebble.pullcleans up temporary files if it errors in #2087 - Make secret info description visible to the charm in ops[testing] in #2115
- Raise ActionFailed when using Context as a context manager in #2121
- Detect categories with an explanation mark indicating breaking changes in #2132
- Normalise Secret.owner to 'app' for ops[testing] output state in #2127
- Don't cache secret metadata in Ops in #2143
- Secret-info-get cannot be provided with both an ID and a label in #2170
- Minor hookcmds fixes in #2175
Documentation
- Update referenced examples for managing interfaces in #2068
- Tidy up spelling and formatting in several places in #2060
- Add missing assignment to state_out in unit tests how-to in #2075
- Update the holistic/delta explanation with the reconciler pattern in #2029
- Fix broken setup/teardown links in README in #2094
- Update info about release docs, mark testing changelog as not maintained in #2074
- Switch to makefile for building the docs in #2073
- Document how to extract the charm instance from the testing context in #2084
- Add a how-to guide for migrating away from Harness in #2062
- Rename hook tools to hook commands in #2114
- Remove legacy how-to guide for Harness in #2122
- Update the Juju release the metrics functionality is removed from 4.0 to 3.6.11 in #2126
- Clarify that Context is the testing context not only the Juju context in #2123
- Explain the Charmhub public listing process and add a reference list of best practices in #1989
- Expand next steps for K8s tutorial in #2034
- Remove mention of the
simpleCharmcraft profile in #2138 - Expand landing pages with summaries of pages in #2140
- Update environment setup for integration tests and K8s tutorial in #2124
- Replace machine charm tutorial by an improved tutorial in #2119
- Change HACKING.md instructions for maintaining Charmcraft profiles in #2151
- In integration tests, use consistent approach to logging and packing in #2150
- In integration testing how-to, clarify that Juju model is destroyed after module all tests in the module complete in #2154
- Remove Charmcraft channel specifier from machine charm tutorial in #2148
- Add AI contribution note and style guideline for type annotation of return values in #2168
- Add ops[testing] to the ops.testing docstring in #2171
- Add links to the Juju hook from each event class in #2176
- Add a short umask note in #2184
Tests
- Re-enable testing consistency checks after disabling them in #2141
- Expand secrets integration and state transition tests in #2130
Refactoring
- Use ops.hookcmds in _ModelBackend in #2116
- Don't get the storage details from --help in #2172
- Drop 3.8 and 3.9 compatibility code in #2173
- Use json.dumps to produce the YAML in relation-set and state-set in #2174
- Rely on type annotations instead of casts in hookcmds in #2179
CI
- Add integration and state transition tests for the secrets API in #2078
- Temporarily disable tracing integration tests in #2102
- Add secrets tests follow-up in #2105
- Support monorepos in ops charm compatibility testing in #2100
- Test both Charmcraft 3 and Charmcraft 4 profiles in #2103
- Add automated doc checks (and related starter pack updates) in #2099
- Clean up accidental workflow trigger in #2144
- Test if package versions match dependency versions before publishing in #2139
- Update spelling in #2167
- Test against 4.0/stable in #2186
- Store charmcraft logs if smoke tests fail in #2192
- Use Juju channel 4/stable in Ops smoke tests in #2190
Full Changelog: 3.3.0...3.4.0