Skip to content

docs: document user-secret observer lifecycle and secret-changed semantics#2522

Merged
tonyandrewmeyer merged 14 commits into
canonical:mainfrom
tonyandrewmeyer:docs/user-secret-observer-lifecycle
Jun 5, 2026
Merged

docs: document user-secret observer lifecycle and secret-changed semantics#2522
tonyandrewmeyer merged 14 commits into
canonical:mainfrom
tonyandrewmeyer:docs/user-secret-observer-lifecycle

Conversation

@tonyandrewmeyer
Copy link
Copy Markdown
Collaborator

@tonyandrewmeyer tonyandrewmeyer commented Jun 1, 2026

This PR expands our secrets how-to so that it more clearly explains the differences between managing charm-owned secrets and user secrets.

A new section is added that explains the user secrets path. This is simpler than a charm-owned secret, since there's only one event to handle: config-changed.

Preview

See juju/juju#18892 for more context.

Comment thread docs/howto/manage-secrets.md Outdated
Comment thread docs/howto/manage-secrets.md Outdated
self.framework.observe(self.on.secret_changed, self._on_secret_changed)

def _on_config_changed(self, event: ops.ConfigChangedEvent):
secret_uri = self.config.get('my-secret-option')
Copy link
Copy Markdown
Collaborator Author

@tonyandrewmeyer tonyandrewmeyer Jun 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could use load_config but it seems like it would unnecessarily complicate the example.

Comment thread docs/howto/manage-secrets.md Outdated
tonyandrewmeyer and others added 3 commits June 1, 2026 21:19
Co-authored-by: Tony Meyer <tony.meyer@gmail.com>
The new section linked to manage-configuration via {external+ops:ref},
but the ops docs are this Sphinx project and there is no "ops" entry
in intersphinx_mapping, so the build failed under --fail-on-warning.
Use {ref} to match the convention in the sibling how-to files.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Comment thread docs/howto/manage-secrets.md
Copy link
Copy Markdown
Contributor

@dwilding dwilding left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice updates, thanks! All comments are minor

Comment thread docs/howto/manage-secrets.md
Comment thread docs/howto/manage-secrets.md Outdated
Comment thread docs/howto/manage-secrets.md Outdated
Comment thread docs/howto/manage-secrets.md Outdated

1. Create the secret: `juju add-secret my-secret key=value`
2. Grant it to the application: `juju grant-secret my-secret <app-name>`
3. Set the configuration option to the secret URI: `juju config <app-name> <secret-option>=<secret-uri>`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does the secret URI come from?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The add-secret output. Should the (1) say something like "Create the secret and record the secret URI in the output: juju...? Or (3) say something like:

Suggested change
3. Set the configuration option to the secret URI: `juju config <app-name> <secret-option>=<secret-uri>`
3. Set the configuration option to the secret URI that `secret-add` output: `juju config <app-name> <secret-option>=<secret-uri>`

Or a different approach?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer adjusting (3), but with "returned" instead of "output"

Comment thread docs/howto/manage-secrets.md Outdated
Comment thread docs/howto/manage-secrets.md Outdated
Comment thread docs/howto/manage-secrets.md Outdated
Comment thread docs/howto/manage-secrets.md
Comment thread docs/howto/manage-secrets.md
Comment thread docs/howto/manage-secrets.md Outdated
tonyandrewmeyer and others added 4 commits June 3, 2026 16:44
Co-authored-by: Dave Wilding <tech@dpw.me>
Apply suggestions from PR canonical#2522 review:

- Add a meta description for the page.
- Reorder the Prerequisites section so the charm-side configuration
  option declaration comes before the steps the Juju user must take.
- Link the See more pointer at the charmcraft config key reference
  instead of the Charmcraft Manage secrets page.
Use plain text for "See first / See more / See also" pointers, convert
the "See first" pointer into a bulleted list, and wrap the
non-pointer callouts ("Added in Juju 3.0.2", "By its nature ...") as
{note} admonitions. These lines aren't actually quotes, so the
leading > was misleading.
@tonyandrewmeyer
Copy link
Copy Markdown
Collaborator Author

I figured since I'm doing a "see also" link I should move this page away from the block quote style. @dwilding would you mind doing a brief re-review to validate those bits?

Copy link
Copy Markdown
Contributor

@dwilding dwilding left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I figured since I'm doing a "see also" link I should move this page away from the block quote style. @dwilding would you mind doing a brief re-review to validate those bits?

Looks good, thanks a lot! Just a couple of extra suggestions.

Comment thread docs/howto/manage-secrets.md Outdated
Comment thread docs/howto/manage-secrets.md Outdated
Copy link
Copy Markdown
Contributor

@tromai tromai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the docs update.

I read through the whole manage-secrets page and the added section looks good to me.

Comment thread docs/howto/manage-secrets.md
Comment thread docs/howto/manage-secrets.md Outdated
tonyandrewmeyer and others added 2 commits June 5, 2026 09:08
Co-authored-by: Dave Wilding <tech@dpw.me>
Co-authored-by: Dave Wilding <tech@dpw.me>
Comment thread docs/howto/manage-secrets.md Outdated
@tonyandrewmeyer tonyandrewmeyer merged commit be75eea into canonical:main Jun 5, 2026
60 checks passed
@tonyandrewmeyer tonyandrewmeyer deleted the docs/user-secret-observer-lifecycle branch June 5, 2026 09:31
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.

3 participants