Documentation ¶
Index ¶
- Variables
- func UserFromRequest(st *state.State, req *http.Request) (*auth.UserState, error)
- type Command
- type ConnectivityStatus
- type ConsoleConfStartRoutineResult
- type Daemon
- func (d *Daemon) Dying() <-chan struct{}
- func (d *Daemon) HandleRestart(t state.RestartType)
- func (d *Daemon) Init() error
- func (d *Daemon) RebootAsExpected(st *state.State) error
- func (d *Daemon) RebootDidNotHappen(st *state.State) error
- func (d *Daemon) SetDegradedMode(err error)
- func (d *Daemon) Start() error
- func (d *Daemon) Stop(sigCh chan<- os.Signal) error
- type Meta
- type Response
- func AppNotFound(format string, v ...interface{}) Response
- func AssertResponse(asserts []asserts.Assertion, bundle bool) Response
- func AsyncResponse(result map[string]interface{}, meta *Meta) Response
- func AuthCancelled(format string, v ...interface{}) Response
- func InsufficientSpace(dserr *snapstate.InsufficientSpaceError) Response
- func InterfacesUnchanged(format string, v ...interface{}) Response
- func SnapChangeConflict(cce *snapstate.ChangeConflictError) Response
- func SnapNotFound(snapName string, err error) Response
- func SnapRevisionNotAvailable(snapName string, rnaErr *store.RevisionNotAvailableError) Response
- func SyncResponse(result interface{}, meta *Meta) Response
- type ResponseFunc
- type ResponseType
Constants ¶
This section is empty.
Variables ¶
var ( NotFound = makeErrorResponder(404) BadRequest = makeErrorResponder(400) MethodNotAllowed = makeErrorResponder(405) InternalError = makeErrorResponder(500) NotImplemented = makeErrorResponder(501) Forbidden = makeErrorResponder(403) Conflict = makeErrorResponder(409) )
standard error responses
var ErrRestartSocket = fmt.Errorf("daemon stop requested to wait for socket activation")
Functions ¶
Types ¶
type Command ¶
type Command struct { Path string PathPrefix string // GET ResponseFunc PUT ResponseFunc POST ResponseFunc // can guest GET? GuestOK bool // can non-admin GET? UserOK bool // is this path accessible on the snapd-snap socket? SnapOK bool // this path is only accessible to root RootOnly bool // can polkit grant access? set to polkit action ID if so PolkitOK string // contains filtered or unexported fields }
A Command routes a request to an individual per-verb ResponseFUnc
type ConnectivityStatus ¶
type ConsoleConfStartRoutineResult ¶
type ConsoleConfStartRoutineResult struct { ActiveAutoRefreshChanges []string `json:"active-auto-refreshes,omitempty"` ActiveAutoRefreshSnaps []string `json:"active-auto-refresh-snaps,omitempty"` }
ConsoleConfStartRoutineResult is the result of running the console-conf start routine..
type Daemon ¶
type Daemon struct { Version string // contains filtered or unexported fields }
A Daemon listens for requests and routes them to the right command
func (*Daemon) HandleRestart ¶
func (d *Daemon) HandleRestart(t state.RestartType)
HandleRestart implements overlord.RestartBehavior.
func (*Daemon) RebootAsExpected ¶
RebootAsExpected implements part of overlord.RestartBehavior.
func (*Daemon) RebootDidNotHappen ¶
RebootDidNotHappen implements part of overlord.RestartBehavior.
func (*Daemon) SetDegradedMode ¶
SetDegradedMode puts the daemon into an degraded mode which will the error given in the "err" argument for commands that are not marked as readonlyOK.
This is useful to report errors to the client when the daemon cannot work because e.g. a sanity check failed or the system is out of diskspace.
When the system is fine again calling "DegradedMode(nil)" is enough to put the daemon into full operation again.
type Meta ¶
type Meta struct { Sources []string `json:"sources,omitempty"` SuggestedCurrency string `json:"suggested-currency,omitempty"` Change string `json:"change,omitempty"` WarningTimestamp *time.Time `json:"warning-timestamp,omitempty"` WarningCount int `json:"warning-count,omitempty"` }
TODO This is being done in a rush to get the proper external
JSON representation in the API in time for the release. The right code style takes a bit more work and unifies these fields inside resp.
Increment the counter if you read this: 43
type Response ¶
type Response interface {
ServeHTTP(w http.ResponseWriter, r *http.Request)
}
Response knows how to serve itself, and how to find itself
func AppNotFound ¶
AppNotFound is an error responder used when an operation is requested on a app that doesn't exist.
func AssertResponse ¶
AssertResponse builds a response whose ServerHTTP method serves one or a bundle of assertions.
func AsyncResponse ¶
AsyncResponse builds an "async" response from the given *Task
func AuthCancelled ¶
AuthCancelled is an error responder used when a user cancelled the auth process.
func InsufficientSpace ¶
func InsufficientSpace(dserr *snapstate.InsufficientSpaceError) Response
InsufficientSpace is an error responder used when an operation cannot be performed due to low disk space.
func InterfacesUnchanged ¶
InterfacesUnchanged is an error responder used when an operation that would normally change interfaces finds it has nothing to do
func SnapChangeConflict ¶
func SnapChangeConflict(cce *snapstate.ChangeConflictError) Response
SnapChangeConflict is an error responder used when an operation is conflicts with another change.
func SnapNotFound ¶
SnapNotFound is an error responder used when an operation is requested on a snap that doesn't exist.
func SnapRevisionNotAvailable ¶
func SnapRevisionNotAvailable(snapName string, rnaErr *store.RevisionNotAvailableError) Response
SnapRevisionNotAvailable is an error responder used when an operation is requested for which no revivision can be found in the given context (e.g. request an install from a stable channel when this channel is empty).
func SyncResponse ¶
SyncResponse builds a "sync" response from the given result.
type ResponseFunc ¶
A ResponseFunc handles one of the individual verbs for a method
type ResponseType ¶
type ResponseType string
ResponseType is the response type
const ( ResponseTypeSync ResponseType = "sync" ResponseTypeAsync ResponseType = "async" ResponseTypeError ResponseType = "error" )
"there are three standard return types: Standard return value, Background operation, Error", each returning a JSON object with the following "type" field:
Source Files ¶
- api.go
- api_aliases.go
- api_apps.go
- api_asserts.go
- api_buy_unsupp.go
- api_cohort.go
- api_connections.go
- api_console_conf.go
- api_debug.go
- api_debug_pprof.go
- api_debug_seeding.go
- api_download.go
- api_find.go
- api_general.go
- api_icons.go
- api_interfaces.go
- api_json.go
- api_model.go
- api_sections.go
- api_sideload_n_try.go
- api_snap_conf.go
- api_snap_file.go
- api_snapctl.go
- api_snaps.go
- api_snapshots.go
- api_system_recovery_keys.go
- api_systems.go
- api_themes.go
- api_users.go
- api_validate.go
- daemon.go
- response.go
- snap.go
- ucrednet.go