Documentation ¶
Overview ¶
Package clientutil offers utilities to turn snap.Info and related structs into client structs and to work with the latter.
Index ¶
- func AvailableUserSessions() ([]int, error)
- func ClientAppInfoNotes(app *client.AppInfo) string
- func ClientAppInfosFromSnapAppInfos(apps []*snap.AppInfo, decorator StatusDecorator) ([]client.AppInfo, error)
- func ClientSnapFromSnapInfo(snapInfo *snap.Info, decorator StatusDecorator) (*client.Snap, error)
- func FmtServiceStatus(svc *client.AppInfo, isGlobal bool) string
- func ParseConfigValues(confValues []string, opts *ParseConfigOptions) (map[string]interface{}, []string, error)
- func PrintModelAssertion(w *tabwriter.Writer, modelAssertion asserts.Model, ...) error
- func PrintModelAssertionJSON(w *tabwriter.Writer, modelAssertion asserts.Model, ...) error
- func PrintSerialAssertionYAML(w *tabwriter.Writer, serialAssertion asserts.Serial, ...) error
- type ModelAssertJSON
- type ModelFormatter
- type ParseConfigOptions
- type PrintModelAssertionOptions
- type ServiceScopeOptions
- type StatusDecorator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AvailableUserSessions ¶
AvailableUserSessions returns a list of available user-session targets for snapd, by probing the available snapd-session-agent sockets in the XDG runtime directory.
func ClientAppInfoNotes ¶
func ClientAppInfosFromSnapAppInfos ¶
func ClientAppInfosFromSnapAppInfos(apps []*snap.AppInfo, decorator StatusDecorator) ([]client.AppInfo, error)
ClientAppInfosFromSnapAppInfos returns client.AppInfos derived from the given snap.AppInfos. If an optional StatusDecorator is provided it will be used to add service status information as well, this will be done only if the snap is active and when the app is a service.
func ClientSnapFromSnapInfo ¶
ClientSnapFromSnapInfo returns a client.Snap derived from snap.Info. If an optional StatusDecorator is provided it will be used to add service status information.
func FmtServiceStatus ¶
FmtServiceStatus formats a given service application into the following string <snap.app> <enabled> <active> <notes> To keep output persistent between snapctl and snap cmd.
func ParseConfigValues ¶
func ParseConfigValues(confValues []string, opts *ParseConfigOptions) (map[string]interface{}, []string, error)
ParseConfigValues parses config values in the format of "foo=bar" or "!foo", optionally a strict strings or JSON values depending on passed options. By default, values are parsed if valid JSON and stored as-is if not. Returns a map of config keys to values to set and a slice of keys in the order they were passed in.
func PrintModelAssertion ¶
func PrintModelAssertion(w *tabwriter.Writer, modelAssertion asserts.Model, serialAssertion *asserts.Serial, modelFormatter ModelFormatter, opts PrintModelAssertionOptions) error
PrintModelAssertion will format the provided serial or model assertion based on the parameters given in YAML format, or serialize it raw if Assertion is set. The output will be written to the provided io.Writer.
func PrintModelAssertionJSON ¶
func PrintModelAssertionJSON(w *tabwriter.Writer, modelAssertion asserts.Model, serialAssertion *asserts.Serial, opts PrintModelAssertionOptions) error
PrintModelAssertionJSON will format the provided serial or model assertion based on the parameters given in JSON format. The output will be written to the provided io.Writer.
func PrintSerialAssertionYAML ¶
func PrintSerialAssertionYAML(w *tabwriter.Writer, serialAssertion asserts.Serial, modelFormatter ModelFormatter, opts PrintModelAssertionOptions) error
PrintModelAssertionYAML will format the provided serial or model assertion based on the parameters given in YAML format. The output will be written to the provided io.Writer.
Types ¶
type ModelAssertJSON ¶
type ModelAssertJSON struct { Headers map[string]interface{} `json:"headers,omitempty"` Body string `json:"body,omitempty"` }
ModelAssertJSON is used to represent a model assertion as-is in JSON.
type ModelFormatter ¶
type ModelFormatter interface { // LongPublisher returns the publisher as a nicely formatted string. LongPublisher(storeAccountID string) string // GetEscapedDash returns either a double dash which is YAML safe, or the // special unicode dash character. GetEscapedDash() string }
ModelFormatter is a helper interface to format special model elements like the publisher, which needs additional formatting. The formatting varies based on where this code needs to be used, which is why this interface is defined.
type ParseConfigOptions ¶
type ParseConfigOptions struct { // String is enabled when values should be stored as-is w/o parsing being parsed. String bool // Typed is enabled when values should be stored parsed as JSON. If String is // enabled, this value is ignored. Typed bool }
ParseConfigOptions controls how config values should be parsed.
type PrintModelAssertionOptions ¶
type PrintModelAssertionOptions struct { // TermWidth is the width of the terminal for the output. This is used to format // the device keys in a more readable way. TermWidth int // AbsTime determines how the timestamps are formatted, if set the timestamp // will be formatted as RFC3339, otherwise as a human readable time. AbsTime bool // Verbose prints additional information about the provided assertion, // which includes most of the assertion headers. This is implicitly always // true when printing in JSON. Verbose bool // Assertion controls whether the provided assertion will be serialized // without any prior processing, which means if set, it will serialize // the entire assertion as-is. Assertion bool }
type ServiceScopeOptions ¶
type ServiceScopeOptions struct { System bool `long:"system"` User bool `long:"user"` Usernames string `long:"users"` }
ServiceScopeOptions represents shared options between service operations that change the scope of services affected.
func (*ServiceScopeOptions) Scope ¶
func (us *ServiceScopeOptions) Scope() client.ScopeSelector
func (*ServiceScopeOptions) Users ¶
func (us *ServiceScopeOptions) Users() client.UserSelector
func (*ServiceScopeOptions) Validate ¶
func (us *ServiceScopeOptions) Validate() error