Documentation ¶
Index ¶
- Variables
- func AppNotFound(format string, v ...interface{}) *apiError
- func AuthCancelled(format string, v ...interface{}) *apiError
- func BadQuery() *apiError
- func InsufficientSpace(dserr *snapstate.InsufficientSpaceError) *apiError
- func InterfacesUnchanged(format string, v ...interface{}) *apiError
- func QuotaChangeConflict(qce *servicestate.QuotaChangeConflictError) *apiError
- func SnapChangeConflict(cce *snapstate.ChangeConflictError) *apiError
- func SnapNotFound(snapName string, err error) *apiError
- func SnapNotInstalled(snapName string, err error) *apiError
- func SnapRevisionNotAvailable(snapName string, rnaErr *store.RevisionNotAvailableError) *apiError
- type Command
- type Daemon
- func (d *Daemon) Dying() <-chan struct{}
- func (d *Daemon) HandleRestart(t restart.RestartType, rebootInfo *boot.RebootInfo)
- 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(ctx context.Context) (err error)
- func (d *Daemon) Stop(sigCh chan<- os.Signal) error
- type FileReference
- type Form
- type Response
- type ResponseFunc
- type ResponseType
- type StructuredResponse
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 ErrNoFailureRecoveryNeeded = fmt.Errorf("no failure recovery needed")
var ErrRestartSocket = fmt.Errorf("daemon stop requested to wait for socket activation")
Functions ¶
func AppNotFound ¶
func AppNotFound(format string, v ...interface{}) *apiError
AppNotFound is an error responder used when an operation is requested on a app that doesn't exist.
func AuthCancelled ¶
func AuthCancelled(format string, v ...interface{}) *apiError
AuthCancelled is an error responder used when a user cancelled the auth process.
func BadQuery ¶
func BadQuery() *apiError
BadQuery is an error responder used when a bad query was provided to the store.
func InsufficientSpace ¶
func InsufficientSpace(dserr *snapstate.InsufficientSpaceError) *apiError
InsufficientSpace is an error responder used when an operation cannot be performed due to low disk space.
func InterfacesUnchanged ¶
func InterfacesUnchanged(format string, v ...interface{}) *apiError
InterfacesUnchanged is an error responder used when an operation that would normally change interfaces finds it has nothing to do
func QuotaChangeConflict ¶
func QuotaChangeConflict(qce *servicestate.QuotaChangeConflictError) *apiError
QuotaChangeConflict is an error responder used when an operation would conflict with another ongoing change.
func SnapChangeConflict ¶
func SnapChangeConflict(cce *snapstate.ChangeConflictError) *apiError
SnapChangeConflict is an error responder used when an operation would conflict with another ongoing change.
func SnapNotFound ¶
SnapNotFound is an error responder used when an operation is requested on a snap that doesn't exist.
func SnapNotInstalled ¶
SnapNotInstalled is an error responder used when an operation is requested on a snap that is not in the system but expected to be.
func SnapRevisionNotAvailable ¶
func SnapRevisionNotAvailable(snapName string, rnaErr *store.RevisionNotAvailableError) *apiError
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).
Types ¶
type Command ¶
type Command struct { Path string PathPrefix string // GET ResponseFunc PUT ResponseFunc POST ResponseFunc // Access control. ReadAccess accessChecker WriteAccess accessChecker // contains filtered or unexported fields }
A Command routes a request to an individual per-verb ResponseFunc
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 restart.RestartType, rebootInfo *boot.RebootInfo)
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 a degraded mode. In this mode it will return the error given in the "err" argument for commands that are not pure HTTP GETs.
This is useful to report errors to the client when the daemon cannot work because e.g. a snapd squashfs precondition check failed or the system is out of diskspace.
When the system is fine again, calling "SetDegradedMode(nil)" is enough to put the daemon into full operation again.
type FileReference ¶
type Form ¶
type Form struct { // Values holds non-file parts keyed by their "name" parameter (from the // part's Content-Disposition header). Values map[string][]string // FileRefs holds file parts keyed by their "name" parameter (from the // part's Content-Disposition header). Each reference contains a filename // (the "filename" parameter) and the path to a file with the part's contents. FileRefs map[string][]*FileReference }
Form is a multipart form that holds file and non-file parts
func (*Form) GetSnapFiles ¶
func (f *Form) GetSnapFiles() ([]*uploadedSnap, *apiError)
GetSnapFiles returns the original name and temp path for each snap file in the form. Optionally, it might include a requested instance name, but only if the was only one file in the form.
func (*Form) RemoveAllExcept ¶
RemoveAllExcept removes all temporary files uploaded with form, except for the given paths. Should be called once the files uploaded with the form are no longer needed.
type Response ¶
type Response interface {
ServeHTTP(w http.ResponseWriter, r *http.Request)
}
Response knows how to serve itself.
func AssertResponse ¶
AssertResponse builds a response whose ServerHTTP method serves one or a bundle of assertions.
func AsyncResponse ¶
AsyncResponse builds an "async" response for a created change
func SyncResponse ¶
func SyncResponse(result interface{}) Response
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:
type StructuredResponse ¶
type StructuredResponse interface { Response JSON() *respJSON }
A StructuredResponse serializes itself to our standard JSON response format.
Source Files ¶
- access.go
- api.go
- api_accessories.go
- api_aliases.go
- api_apps.go
- api_asserts.go
- api_buy_unsupp.go
- api_categories.go
- api_cohort.go
- api_connections.go
- api_console_conf.go
- api_debug.go
- api_debug_migrate.go
- api_debug_pprof.go
- api_debug_seeding.go
- api_debug_stacktrace.go
- api_download.go
- api_find.go
- api_general.go
- api_icons.go
- api_interfaces.go
- api_json.go
- api_model.go
- api_notices.go
- api_prompting.go
- api_quotas.go
- api_registry.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
- errors.go
- request.go
- response.go
- snap.go
- ucrednet.go