canonical / pebble

Pebble is a lightweight Linux service manager with layered configuration and an HTTP API.
https://canonical-pebble.readthedocs-hosted.com/
GNU General Public License v3.0
145 stars 54 forks source link

feat(state): core of reading/writing identities in state #428

Closed benhoyt closed 2 months ago

benhoyt commented 3 months ago

This adds code and tests for the state core of identities (spec OP043).

There's a new map[string]*Identity in state, which is marshalled via marshalledIdentity to disk. The marshalling for API requests is done by the apiIdentity type -- these are separate to ensure that the API (default) MarshalJSON for Identity does not include secrets (in future when we have identity types that include secrets; there's only user-id for now). So that's why there's a few more types and a bit more boilerplate than is necessary right now.

The new public State methods are:

Each of the FooIdentities modification functions validates that the identities are valid, and that the user-ids are unique, before applying to state.