Skip to content

feat!: inject Juju default databag keys at exec time#2637

Draft
tonyandrewmeyer wants to merge 1 commit into
canonical:mainfrom
tonyandrewmeyer:rainy/2185-juju-default-databag-at-exec
Draft

feat!: inject Juju default databag keys at exec time#2637
tonyandrewmeyer wants to merge 1 commit into
canonical:mainfrom
tonyandrewmeyer:rainy/2185-juju-default-databag-at-exec

Conversation

@tonyandrewmeyer

Copy link
Copy Markdown
Collaborator

Relation databags (local_unit_data, remote_units_data, remote_unit_data) now default to empty dicts. Just before the charm runs, Scenario injects the keys Juju itself auto-populates (egress-subnets, ingress-address, and on Juju 3 private-address) into every unit databag, and they flow through to the output state.

This is the backwards-incompatible alternative to #2618: instead of stripping private-address from the construction default when the mocked Juju version is 4+, Scenario now matches Juju's own behaviour and only inserts the keys the real Juju would insert. Tests that read a Relation's databag before running the charm will see empty dicts.

Fixes #2185.

Relation databags (`local_unit_data`, `remote_units_data`,
`remote_unit_data`) now default to empty dicts. Just before the charm
runs, Scenario injects the keys Juju itself auto-populates
(`egress-subnets`, `ingress-address`, and on Juju 3 `private-address`)
into every unit databag, and they flow through to the output state.

This is the backwards-incompatible alternative to canonical#2618: instead of
stripping `private-address` from the construction default when the
mocked Juju version is 4+, Scenario now matches Juju's own behaviour
and only inserts the keys the real Juju would insert. Tests that read
a `Relation`'s databag before running the charm will see empty dicts.

Fixes canonical#2185.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Don't include private-address in the default Scenario database when mocking Juju 4

1 participant