Skip to content

Commit

Permalink
feat(daemon): daemon access for API extensions
Browse files Browse the repository at this point in the history
The following PR provided Pebble derived projects to extend the supplied
daemon HTTP API handlers.

canonical#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.
  • Loading branch information
flotter committed Aug 31, 2023
1 parent 3eec1af commit 4e1f8fb
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions internals/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,10 @@ func (d *Daemon) Overlord() *overlord.Overlord {
return d.overlord
}

func (c *Command) Daemon() *Daemon {
return c.d
}

func (c *Command) ServeHTTP(w http.ResponseWriter, r *http.Request) {
st := c.d.state
st.Lock()
Expand Down

0 comments on commit 4e1f8fb

Please sign in to comment.