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
149 stars 54 forks source link

feat(daemon): daemon access for API extensions #293

Closed flotter closed 1 year ago

flotter commented 1 year ago

The following PR provided Pebble derived projects to extend the supplied daemon HTTP API handlers.

https://github.com/canonical/pebble/pull/265

However, currently such a handler cannot access the daemon, even though we added a daemon method to also expose the Overlord.

func v1PostDevice(*daemon.Command, req *http.Request, _ *daemon.UserState) daemon.Response {
    :

    // Cannot access c.d (daemon is private)
        ovld := c.d.Overlord()

    :
}

This PR adds c.Daemon() to allow access inside externally defined HTTP API handlers.

flotter commented 1 year ago

I think this was most likely just an oversight at the time, but please let me know if I am missing something obvious where.