Documentation
¶
Index ¶
- Constants
- Variables
- func IsNoUpdatesAvailable(err error) bool
- type Action
- type Change
- type ChangeConflictError
- type ChangeSelector
- type ChangesOptions
- type Client
- func (client *Client) Abort(id string) (*Change, error)
- func (client *Client) Change(id string, verbose bool) (*Change, error)
- func (client *Client) Changes(opts *ChangesOptions) ([]*Change, error)
- func (client *Client) CloseIdleConnections()
- func (client *Client) Connect(plugProjectId, plugWorkshop, plugSdkName, plugName, slotProjectId, ... string, ...) (changeID string, err error)
- func (client *Client) Connections(opts *ConnectionOptions) (Connections, error)
- func (client *Client) DebugGet(action string, result any, params map[string]string) error
- func (client *Client) DebugPost(action string, params any, result any) error
- func (client *Client) Disconnect(plugProjectId, plugWorkshop, plugSdkName, plugName, slotProjectId, ... string, ...) (changeID string, err error)
- func (client *Client) Exec(opts *ExecOptions, workshop, projectId string) (*ExecProcess, error)
- func (client *Client) FindSdks(q string) ([]SdkSummary, error)
- func (client *Client) Hijack(f func(*http.Request) (*http.Response, error))
- func (client *Client) Launch(projectId string, names []string, mode string, verbose bool) (changeId string, err error)
- func (client *Client) List(opts *ListOptions) ([]*WorkshopInfo, []*WorkshopFile, error)
- func (client *Client) ListActions(projectId, name string) (map[string]Action, error)
- func (client *Client) Maintenance() error
- func (client *Client) Okay(t time.Time) error
- func (client *Client) Project(path string) (*Project, error)
- func (client *Client) Projects() ([]Project, error)
- func (client *Client) Refresh(projectId string, names []string, mode string, option string, verbose bool) (changeId string, err error)
- func (client *Client) Remount(plug *PlugRef, source string) (changeId string, err error)
- func (client *Client) Remove(projectId string, names []string) (changeId string, err error)
- func (client *Client) Restore(projectId string, names []string, verbose bool) (changeId string, err error)
- func (client *Client) RunWorkshopctl(options *WorkshopCtlOptions, stdin io.Reader) (stdout, stderr []byte, err error)
- func (client *Client) SdkInfo(name string) (*SdkFullInfo, error)
- func (client *Client) Sdks() ([]SdkVolume, error)
- func (client *Client) SingleWorkshop(project *Project) (*Workshop, error)
- func (client *Client) SingleWorkshopName(project *Project) (string, error)
- func (client *Client) Start(projectId string, names []string) (changeId string, err error)
- func (client *Client) Stop(projectId string, names []string) (changeId string, err error)
- func (client *Client) SysInfo() (*SysInfo, error)
- func (client *Client) WaitChange(id string, opts *WaitChangeOptions) (*Change, error)
- func (client *Client) Warnings(opts WarningsOptions) ([]*Warning, error)
- func (client *Client) WarningsSummary() (count int, timestamp time.Time)
- func (client *Client) Workshop(projectId, name string) (*Workshop, error)
- type Config
- type Connection
- type ConnectionError
- type ConnectionOptions
- type Connections
- type DisconnectOptions
- type Endpoint
- type Error
- type ExecOptions
- type ExecProcess
- type ExitError
- type HealthCheck
- type Interface
- type InterfaceAction
- type InterfaceOptions
- type ListOptions
- type Mount
- type Plug
- type PlugRef
- type Project
- type Remount
- type RequestError
- type ResultInfo
- type Sdk
- type SdkFullInfo
- type SdkInstalled
- type SdkRevision
- type SdkSummary
- type SdkVolume
- type SingleWorkshopError
- type Slot
- type SlotRef
- type SocketNotFoundError
- type StoreAccount
- type SysInfo
- type Task
- type TaskProgress
- type Tunnel
- type WaitChangeOptions
- type Warning
- type WarningsOptions
- type Workshop
- type WorkshopActionOptions
- type WorkshopActionSetup
- type WorkshopCtlOptions
- type WorkshopCtlPostData
- type WorkshopFile
- type WorkshopInfo
- type Workshops
Constants ¶
const ( // ErrorKindChangeConflict identifies an operation blocked by another change. ErrorKindChangeConflict = "change-conflict" ErrorKindLoginRequired = "login-required" ErrorKindSystemRestart = "system-restart" ErrorKindDaemonRestart = "daemon-restart" ErrorKindNoDefaultServices = "no-default-services" ErrorKindUnsuccessful = "unsuccessful" ErrorKindNoUpdatesAvailable = "no-updates-available" // ErrorKindNoWaitingChange identifies an abort or continue request made // when no paused change is waiting for the workshop. ErrorKindNoWaitingChange = "no-waiting-change-in-progress" )
Variables ¶
var ErrNoData = fmt.Errorf("data entry not found")
ErrNoData is returned when there is no data associated with a given key.
var ErrorNoWaitingChange = errors.New("no waiting change in progress")
ErrorNoWaitingChange signals that an abort or continue request could not be applied because no change is in progress to resume for the workshop. Match it with errors.Is.
Functions ¶
func IsNoUpdatesAvailable ¶
Types ¶
type Change ¶
type Change struct {
ID string `json:"id"`
Kind string `json:"kind"`
Summary string `json:"summary"`
Status string `json:"status"`
Tasks []*Task `json:"tasks,omitempty"`
Ready bool `json:"ready"`
Err string `json:"err,omitempty"`
SpawnTime time.Time `json:"spawn-time,omitempty"`
ReadyTime time.Time `json:"ready-time,omitempty"`
// contains filtered or unexported fields
}
Change is a modification to the system state.
type ChangeConflictError ¶ added in v0.9.2
type ChangeConflictError struct {
// ChangeID is the ID of the blocking change.
ChangeID string
// ChangeKind is the kind of the blocking change, such as "refresh".
ChangeKind string
// ProjectID is the ID of the project containing the blocked workshop.
ProjectID string
// Workshop is the name of the blocked workshop.
Workshop string
}
ChangeConflictError describes an operation blocked by another change.
func (ChangeConflictError) Error ¶ added in v0.9.2
func (e ChangeConflictError) Error() string
Error returns a human-readable description of the blocking change.
type ChangeSelector ¶
type ChangeSelector uint8
ChangeSelector represents a selection of changes to query for.
const ( ChangesInProgress ChangeSelector = 1 << iota ChangesReady ChangesAll = ChangesReady | ChangesInProgress )
func (ChangeSelector) String ¶
func (c ChangeSelector) String() string
type ChangesOptions ¶
type ChangesOptions struct {
Workshops []string // if empty, no filtering by service is done
ProjectPath string
Selector ChangeSelector
}
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
A Client knows how to talk to the Workshop daemon.
func (*Client) Changes ¶
func (client *Client) Changes(opts *ChangesOptions) ([]*Change, error)
Changes fetches information for the changes specified.
func (*Client) CloseIdleConnections ¶
func (client *Client) CloseIdleConnections()
CloseIdleConnections closes any API connections that are currently unused.
func (*Client) Connect ¶
func (client *Client) Connect(plugProjectId, plugWorkshop, plugSdkName, plugName, slotProjectId, slotWorkshop, slotSdkName, slotName string, opts *DisconnectOptions) (changeID string, err error)
Connects a plug and a slot.
func (*Client) Connections ¶
func (client *Client) Connections(opts *ConnectionOptions) (Connections, error)
Connections returns matching plugs, slots and their connections. Unless specified by matching options, returns established connections.
func (*Client) DebugGet ¶
DebugGet sends a GET debug action to the server with the provided parameters.
func (*Client) DebugPost ¶
DebugPost sends a POST debug action to the server with the provided parameters.
func (*Client) Disconnect ¶
func (client *Client) Disconnect(plugProjectId, plugWorkshop, plugSdkName, plugName, slotProjectId, slotWorkshop, slotSdkName, slotName string, opts *DisconnectOptions) (changeID string, err error)
Disconnect breaks the connection between a plug and a slot.
func (*Client) Exec ¶
func (client *Client) Exec(opts *ExecOptions, workshop, projectId string) (*ExecProcess, error)
Exec starts a command with the given options, returning a value representing the process.
func (*Client) FindSdks ¶
func (client *Client) FindSdks(q string) ([]SdkSummary, error)
FindSdks searches the SDK Store.
func (*Client) List ¶
func (client *Client) List(opts *ListOptions) ([]*WorkshopInfo, []*WorkshopFile, error)
func (*Client) ListActions ¶
func (*Client) Maintenance ¶
Maintenance returns an error reflecting the daemon maintenance status or nil.
func (*Client) Okay ¶
Okay asks workshopd to chill about the warnings that would have been returned by Warnings at the given time.
func (*Client) RunWorkshopctl ¶
func (client *Client) RunWorkshopctl(options *WorkshopCtlOptions, stdin io.Reader) (stdout, stderr []byte, err error)
RunWorkshopctl requests a workshopctl run for the given options.
func (*Client) SdkInfo ¶
func (client *Client) SdkInfo(name string) (*SdkFullInfo, error)
SdkInfo retrieves installation details of the given SDK across workshops.
func (*Client) SingleWorkshop ¶
func (*Client) SingleWorkshopName ¶
func (*Client) WaitChange ¶
func (client *Client) WaitChange(id string, opts *WaitChangeOptions) (*Change, error)
WaitChange waits for the change to be finished. If the wait operation succeeds, the returned Change.Err string will be non-empty if the change itself had an error.
func (*Client) Warnings ¶
func (client *Client) Warnings(opts WarningsOptions) ([]*Warning, error)
Warnings returns the list of un-okayed warnings.
func (*Client) WarningsSummary ¶
WarningsSummary returns the number of warnings that are ready to be shown to the user, and the timestamp of the most recently added warning (useful for silencing the warning alerts, and OKing the returned warnings).
type Config ¶
type Config struct {
// BaseURL contains the base URL where the Workshop daemon is expected to be.
// It can be empty for a default behavior of talking over a unix socket.
BaseURL string
// Socket is the path to the unix socket to use.
Socket string
// DisableKeepAlive indicates that the connections should not be kept
// alive for later reuse (the default is to keep them alive).
DisableKeepAlive bool
// UserAgent is the User-Agent header sent to the Workshop daemon.
UserAgent string
// RetryInterval is the time to wait between GET retries. Negative
// values disable retries.
RetryInterval time.Duration
// Timeout is the time to spend retrying the request.
Timeout time.Duration
}
Config allows the user to customize client behavior.
type Connection ¶
type Connection struct {
Slot SlotRef `json:"slot"`
Plug PlugRef `json:"plug"`
Interface string `json:"interface"`
// Manual is set for connections that were established manually.
Manual bool `json:"manual"`
// SlotAttrs is the list of attributes of the slot side of the connection.
SlotAttrs map[string]any `json:"slot-attrs,omitempty"`
// PlugAttrs is the list of attributes of the plug side of the connection.
PlugAttrs map[string]any `json:"plug-attrs,omitempty"`
}
Connection describes a connection between a plug and a slot.
type ConnectionError ¶
type ConnectionError struct {
// contains filtered or unexported fields
}
ConnectionError represents a connection or communication error.
func (ConnectionError) Error ¶
func (e ConnectionError) Error() string
func (ConnectionError) Unwrap ¶
func (e ConnectionError) Unwrap() error
type ConnectionOptions ¶
type ConnectionOptions struct {
ProjectId string
// Workshop selects connections with the workshop on one of the sides, as well
// as plugs and slots of a given workshop.
Workshop string
// Interface selects connections, plugs or slots using given interface.
Interface string
// All when true, selects established and undesired connections as well
// as all disconnected plugs and slots.
All bool
}
ConnectionOptions contains criteria for selecting matching connections, plugs and slots.
type Connections ¶
type Connections struct {
// Established is the list of connections that are currently present.
Established []Connection `json:"established"`
// Undersired is a list of connections that are manually denied.
Undesired []Connection `json:"undesired"`
Plugs []Plug `json:"plugs"`
Slots []Slot `json:"slots"`
}
Connections contains information about connections, as well as related plugs and slots.
type DisconnectOptions ¶
type DisconnectOptions struct {
Forget bool
}
DisconnectOptions represents extra options for disconnect op
type Error ¶
type Error struct {
Kind string `json:"kind"`
Value any `json:"value"`
Message string `json:"message"`
StatusCode int
}
Error is the real value of response.Result when an error occurs.
type ExecOptions ¶
type ExecOptions struct {
// Required: name of the workshop to run the command in
Workshop string
// Required: command and arguments (first element is the executable).
Command []string
// Optional command prefix prepended by Workshop before execution. If empty,
// the command is executed without a prefix.
CommandPrefix []string
// True to treat command as a workshop action with arguments.
Action bool
// Optional environment variables.
Environment map[string]string
// Optional working directory (default is /project).
WorkingDir string
// Optional user ID and group ID for the process to run as.
UserId *int
GroupId *int
// Optional timeout for the command execution, after which the process
// will be terminated. If zero, no timeout applies.
Timeout time.Duration
// NOT SUPPORTED: True to ask the server to set up a pseudo-terminal (PTY) for stdout
// (this also allows window resizing). The default is no PTY, and just
// to use pipes for stdout/stderr.
Terminal bool
// True to use the pseudo-terminal for stdin. The default is to use a pipe
// for stdin.
Interactive bool
// Initial terminal width and height (only apply if Interactive is true).
// If not specified, the Workshop server uses the target's default (usually
// 80x25). When using the "workshop exec" CLI, these are set to the host's
// terminal size automatically.
Width int
Height int
// Standard input stream. If nil, no input is sent.
Stdin io.Reader
// Standard output stream. If nil, output is discarded.
Stdout io.Writer
// Standard error stream. If nil, error output is combined with standard
// output and goes to the Stdout stream.
Stderr io.Writer
}
type ExecProcess ¶
type ExecProcess struct {
// contains filtered or unexported fields
}
ExecProcess represents a running process. Use Wait to wait for it to finish.
func (*ExecProcess) SendResize ¶
func (p *ExecProcess) SendResize(width, height int) error
SendResize sends a resize message to the running process.
func (*ExecProcess) SendSignal ¶
func (p *ExecProcess) SendSignal(sig unix.Signal) error
SendSignal sends a signal to the running process.
func (*ExecProcess) Wait ¶
func (p *ExecProcess) Wait() error
Wait waits for the command process to finish. The returned error is nil if the process runs successfully and returns a zero exit code. If the command fails with a nonzero exit code, the error is of type *ExitError.
func (*ExecProcess) WaitStdinDone ¶
func (p *ExecProcess) WaitStdinDone()
WaitStdinDone waits for WebsocketSendStream to be finished calling WriteMessage to avoid a race condition.
type ExitError ¶
type ExitError struct {
// contains filtered or unexported fields
}
ExitError reports an unsuccessful exit by a command (a nonzero exit code).
type HealthCheck ¶
type Interface ¶
type Interface struct {
Name string `json:"name,omitempty"`
Summary string `json:"summary,omitempty"`
DocURL string `json:"doc-url,omitempty"`
Plugs []Plug `json:"plugs,omitempty"`
Slots []Slot `json:"slots,omitempty"`
}
Interface holds information about a given interface and its instances.
type InterfaceAction ¶
type InterfaceAction struct {
Action string `json:"action"`
Forget bool `json:"forget,omitempty"`
Plugs []Plug `json:"plugs,omitempty"`
Slots []Slot `json:"slots,omitempty"`
}
InterfaceAction represents an action performed on the interface system.
type InterfaceOptions ¶
InterfaceOptions represents opt-in elements include in responses.
type ListOptions ¶
type ListOptions struct {
ProjectId string
}
type Plug ¶
type Plug struct {
ProjectId string `json:"project-id"`
Workshop string `json:"workshop"`
Sdk string `json:"sdk"`
Name string `json:"plug"`
Interface string `json:"interface,omitempty"`
Attrs map[string]any `json:"attrs,omitempty"`
Label string `json:"label,omitempty"`
Bind *PlugRef `json:"bind,omitempty"`
Connections []SlotRef `json:"connections,omitempty"`
}
Plug represents the potential of a given snap to connect to a slot.
type PlugRef ¶
type PlugRef struct {
ProjectId string `json:"project-id"`
Workshop string `json:"workshop"`
Sdk string `json:"sdk"`
Name string `json:"plug"`
}
PlugRef is a reference to a plug.
func ParseShortPlugRef ¶
type RequestError ¶
type RequestError struct {
// contains filtered or unexported fields
}
RequestError is returned when there's an error processing the request.
func (RequestError) Error ¶
func (e RequestError) Error() string
type ResultInfo ¶
type ResultInfo struct{}
ResultInfo is empty for now, but this is the mechanism that conveys general information that makes sense to requests at a more general level, and might be disconnected from the specific request at hand.
type Sdk ¶
type Sdk struct {
Name string `json:"name"`
Version string `json:"version,omitempty"`
Channel string `json:"channel"`
Source string `json:"source"`
Revision string `json:"revision"`
BuiltAt time.Time `json:"built-at"`
InstalledAt time.Time `json:"installed-at"`
Health *HealthCheck `json:"health-check,omitempty"`
Mounts []*Mount `json:"mounts,omitempty"`
Tunnels []*Tunnel `json:"tunnels,omitempty"`
}
type SdkFullInfo ¶
type SdkFullInfo struct {
Name string `json:"name"`
PackageID string `json:"package-id,omitempty"`
Title string `json:"title,omitempty"`
Summary string `json:"summary,omitempty"`
Description string `json:"description,omitempty"`
License string `json:"license,omitempty"`
Website string `json:"website,omitempty"`
Publisher *StoreAccount `json:"publisher,omitempty"`
Channels []*SdkRevision `json:"channels,omitempty"`
Installed []SdkInstalled `json:"installed,omitempty"`
}
type SdkInstalled ¶
type SdkRevision ¶
type SdkRevision struct {
Channel string `json:"channel"`
Track string `json:"track"`
Risk string `json:"risk"`
Revision string `json:"revision"`
BuiltAt *time.Time `json:"built-at,omitempty"`
UploadedAt *time.Time `json:"uploaded-at,omitempty"`
ReleasedAt *time.Time `json:"released-at,omitempty"`
Version string `json:"version,omitempty"`
Base string `json:"base,omitempty"`
Arch string `json:"arch,omitempty"`
DownloadSize uint64 `json:"download-size,omitzero"`
}
type SdkSummary ¶
type SdkSummary struct {
Name string `json:"name"`
PackageID string `json:"package-id,omitempty"`
Summary string `json:"summary,omitempty"`
Description string `json:"description,omitempty"`
License string `json:"license,omitempty"`
Publisher *StoreAccount `json:"publisher,omitempty"`
Channel string `json:"channel"`
Track string `json:"track"`
Risk string `json:"risk"`
Revision string `json:"revision"`
ReleasedAt *time.Time `json:"released-at,omitempty"`
Version string `json:"version,omitempty"`
Base string `json:"base,omitempty"`
Arch string `json:"arch,omitempty"`
}
type SdkVolume ¶
type SdkVolume struct {
Name string `json:"name"`
Version string `json:"version,omitempty"`
Revision string `json:"revision"`
BuiltAt *time.Time `json:"built-at,omitempty"`
Size uint64 `json:"size,omitempty"`
}
SdkVolume represents SDK volume summary returned by the daemon.
type SingleWorkshopError ¶
func (*SingleWorkshopError) Error ¶
func (e *SingleWorkshopError) Error() string
type Slot ¶
type Slot struct {
ProjectId string `json:"project-id"`
Workshop string `json:"workshop"`
Sdk string `json:"sdk"`
Name string `json:"slot"`
Interface string `json:"interface,omitempty"`
Attrs map[string]any `json:"attrs,omitempty"`
Label string `json:"label,omitempty"`
Connections []PlugRef `json:"connections,omitempty"`
}
Slot represents a capacity offered by a snap.
type SlotRef ¶
type SlotRef struct {
ProjectId string `json:"project-id"`
Workshop string `json:"workshop"`
Sdk string `json:"sdk"`
Name string `json:"slot"`
}
SlotRef is a reference to a slot.
func ParseShortSlotRef ¶
Uses the plug parsing function as the formats are identical. This should change when/if go will enable individual fields access for generic types which would allow to have one generic function returning plug or slot reference type on request.
func ParseSlotSdkRef ¶
type SocketNotFoundError ¶
type SocketNotFoundError struct {
// Err is the wrapped error.
Err error
// Path is the path of the non-existent socket.
Path string
}
SocketNotFoundError is the error type returned when the client fails to find a unix socket at the specified path.
func (SocketNotFoundError) Error ¶
func (s SocketNotFoundError) Error() string
func (SocketNotFoundError) Unwrap ¶
func (s SocketNotFoundError) Unwrap() error
type StoreAccount ¶
type Task ¶
type Task struct {
ID string `json:"id"`
Kind string `json:"kind"`
Summary string `json:"summary"`
Status string `json:"status"`
Log []string `json:"log,omitempty"`
Progress TaskProgress `json:"progress"`
SpawnTime time.Time `json:"spawn-time,omitempty"`
ReadyTime time.Time `json:"ready-time,omitempty"`
DoingTime time.Duration `json:"doing-time,omitempty"`
Data map[string]*json.RawMessage
}
Task represents a single operation done to change the system's state.
type TaskProgress ¶
type TaskProgress struct {
Label string `json:"label"`
Done int `json:"done"`
Total int `json:"total"`
}
TaskProgress represents the completion progress of a task.
type WaitChangeOptions ¶
type Warning ¶
type Warning struct {
Message string `json:"message"`
FirstAdded time.Time `json:"first-added"`
LastAdded time.Time `json:"last-added"`
LastShown time.Time `json:"last-shown,omitempty"`
ExpireAfter time.Duration `json:"expire-after,omitempty"`
RepeatAfter time.Duration `json:"repeat-after,omitempty"`
}
A Warning is a short messages that's meant to alert about system events. There'll only ever be one Warning with the same message, and it can be silenced for a while before repeating. After a (supposedly longer) while it'll go away on its own (unless it recurrs).
type WarningsOptions ¶
type WarningsOptions struct {
All bool
}
WarningsOptions contains options for querying workshopd for warnings supported options: - All: return all warnings, instead of only the un-okayed ones.
type Workshop ¶
type Workshop struct {
WorkshopInfo
Path string `json:"path"`
}
type WorkshopActionOptions ¶
type WorkshopActionSetup ¶
type WorkshopActionSetup struct {
Action string
Names []string
Options *WorkshopActionOptions
}
type WorkshopCtlOptions ¶
type WorkshopCtlOptions struct {
// ContextID is a string used to determine the context of this call (e.g.
// which context and handler should be used, etc.)
ContextID string `json:"context-id"`
// Args contains a list of parameters to use for this invocation.
Args []string `json:"args"`
}
WorkshopCtlOptions holds the various options with which workshopctl is invoked.
type WorkshopCtlPostData ¶
type WorkshopCtlPostData struct {
WorkshopCtlOptions
Stdin []byte `json:"stdin,omitempty"`
}
WorkshopCtlPostData is the data posted to the daemon /v2/workshopctl endpoint TODO: this can be removed again once we no longer need to pass stdin data but instead use a real stdin stream
type WorkshopFile ¶
type WorkshopInfo ¶
type Workshops ¶
type Workshops struct {
Workshops []*WorkshopInfo `json:"workshops"`
Files []*WorkshopFile `json:"files"`
}