snapdapi

package
v0.0.0-...-ad5a82a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 19, 2022 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionDevice

type ActionDevice struct {
	Brand        string `json:"brand"`
	Model        string `json:"model"`
	SerialNumber string `json:"serial"`
	StoreID      string `json:"store"`
	DeviceKey    string `json:"deviceKey"`
}

ActionDevice has basic information of a device

type ClientAdapter

type ClientAdapter struct {
	// contains filtered or unexported fields
}

ClientAdapter adapts our expectations to the snapd client API.

func NewClientAdapter

func NewClientAdapter() *ClientAdapter

NewClientAdapter creates a new ClientAdapter as a singleton

func (*ClientAdapter) Ack

func (a *ClientAdapter) Ack(b []byte) error

Ack adds a new assertion to the system

func (*ClientAdapter) Conf

func (a *ClientAdapter) Conf(name string) (map[string]interface{}, error)

Conf gets the snap's current configuration

func (*ClientAdapter) DeviceInfo

func (a *ClientAdapter) DeviceInfo() (ActionDevice, error)

DeviceInfo fetches the basic details of the device

func (*ClientAdapter) Disable

func (a *ClientAdapter) Disable(name string, options *client.SnapOptions) (string, error)

Disable deactivates the snap with the given name.

func (*ClientAdapter) Enable

func (a *ClientAdapter) Enable(name string, options *client.SnapOptions) (string, error)

Enable activates the snap with the given name.

func (*ClientAdapter) GetEncodedAssertions

func (a *ClientAdapter) GetEncodedAssertions() ([]byte, error)

GetEncodedAssertions fetches the encoded model and serial assertions

func (*ClientAdapter) Install

func (a *ClientAdapter) Install(name string, options *client.SnapOptions) (string, error)

Install adds the snap with the given name from the given channel (or the system default channel if not).

func (*ClientAdapter) Known

func (a *ClientAdapter) Known(assertTypeName string, headers map[string]string) ([]asserts.Assertion, error)

Known queries assertions with type assertTypeName and matching assertion headers.

func (*ClientAdapter) List

func (a *ClientAdapter) List(names []string, opts *client.ListOptions) ([]*client.Snap, error)

List returns the list of all snaps installed on the system with names in the given list; if the list is empty, all snaps.

func (*ClientAdapter) Refresh

func (a *ClientAdapter) Refresh(name string, options *client.SnapOptions) (string, error)

Refresh updates the snap with the given name from the given channel (or the system default channel if not).

func (*ClientAdapter) Remove

func (a *ClientAdapter) Remove(name string, options *client.SnapOptions) (string, error)

Remove removes the snap with the given name.

func (*ClientAdapter) Revert

func (a *ClientAdapter) Revert(name string, options *client.SnapOptions) (string, error)

Revert rolls the snap back to the previous on-disk state

func (*ClientAdapter) ServerVersion

func (a *ClientAdapter) ServerVersion() (*client.ServerVersion, error)

ServerVersion returns information about the snapd server.

func (*ClientAdapter) SetConf

func (a *ClientAdapter) SetConf(name string, patch map[string]interface{}) (string, error)

SetConf requests a snap to apply the provided patch to the configuration

func (*ClientAdapter) Snap

func (a *ClientAdapter) Snap(name string) (*client.Snap, *client.ResultInfo, error)

Snap returns the most recently published revision of the snap with the provided name.

type MockClient

type MockClient struct {
	WithError bool
}

MockClient is a mock snapd API client for testing

func (*MockClient) Ack

func (c *MockClient) Ack(b []byte) error

Ack mocks adding an assertion

func (*MockClient) Conf

func (c *MockClient) Conf(name string) (map[string]interface{}, error)

Conf mocks returning config

func (*MockClient) DeviceInfo

func (c *MockClient) DeviceInfo() (ActionDevice, error)

DeviceInfo returns a mock device details

func (*MockClient) Disable

func (c *MockClient) Disable(name string, options *client.SnapOptions) (string, error)

Disable mocks a snap disable

func (*MockClient) Enable

func (c *MockClient) Enable(name string, options *client.SnapOptions) (string, error)

Enable mocks a snap enable

func (*MockClient) GetEncodedAssertions

func (c *MockClient) GetEncodedAssertions() ([]byte, error)

GetEncodedAssertions returns the encoded model and serial assertions

func (*MockClient) Install

func (c *MockClient) Install(name string, options *client.SnapOptions) (string, error)

Install mocks the snap installation

func (*MockClient) Known

func (c *MockClient) Known(assertTypeName string, headers map[string]string) ([]asserts.Assertion, error)

Known returns the known assertions for a given type

func (*MockClient) List

func (c *MockClient) List(names []string, opts *client.ListOptions) ([]*client.Snap, error)

List lists installed snaps

func (*MockClient) Refresh

func (c *MockClient) Refresh(name string, options *client.SnapOptions) (string, error)

Refresh refreshes an existing snap

func (*MockClient) Remove

func (c *MockClient) Remove(name string, options *client.SnapOptions) (string, error)

Remove mocks a snap removal

func (*MockClient) Revert

func (c *MockClient) Revert(name string, options *client.SnapOptions) (string, error)

Revert reverts an existing snap

func (*MockClient) ServerVersion

func (c *MockClient) ServerVersion() (*client.ServerVersion, error)

ServerVersion mocks the server version call

func (*MockClient) SetConf

func (c *MockClient) SetConf(name string, patch map[string]interface{}) (string, error)

SetConf mocks setting the config

func (*MockClient) Snap

func (c *MockClient) Snap(name string) (*client.Snap, *client.ResultInfo, error)

Snap mocks the details of a snap

type SnapdClient

type SnapdClient interface {
	Snap(name string) (*client.Snap, *client.ResultInfo, error)
	List(names []string, opts *client.ListOptions) ([]*client.Snap, error)
	Install(name string, options *client.SnapOptions) (string, error)
	Refresh(name string, options *client.SnapOptions) (string, error)
	Revert(name string, options *client.SnapOptions) (string, error)
	Remove(name string, options *client.SnapOptions) (string, error)
	Enable(name string, options *client.SnapOptions) (string, error)
	Disable(name string, options *client.SnapOptions) (string, error)
	ServerVersion() (*client.ServerVersion, error)
	Ack(b []byte) error
	Known(assertTypeName string, headers map[string]string) ([]asserts.Assertion, error)
	Conf(name string) (map[string]interface{}, error)
	SetConf(name string, patch map[string]interface{}) (string, error)

	GetEncodedAssertions() ([]byte, error)
	DeviceInfo() (ActionDevice, error)
}

SnapdClient is a client of the snapd REST API

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL