updatehub

package module
v0.0.0-...-9869abf Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2020 License: Apache-2.0 Imports: 9 Imported by: 4

README

updatehub agent SDK for Go

godoc

Documentation

Index

Constants

View Source
const (
	Updating = "updating"
	NoUpdate = "no_update"
	TryAgain = "try_again"
)
View Source
const (
	Park                = "park"
	EntryPoint          = "entry_point"
	Poll                = "poll"
	Validation          = "validation"
	Download            = "download"
	Install             = "install"
	Reboot              = "reboot"
	DirectDownload      = "direct_download"
	PrepareLocalInstall = "prepare_local_install"
	Error               = "error"
)
View Source
const (
	StateProbe    = "probe"
	StateDownload = "download"
	StateInstall  = "install"
	StateReboot   = "reboot"
	StateError    = "error"
)
View Source
const SDKTriggerFilename string = "/usr/share/updatehub/state-change-callbacks.d/10-updatehub-sdk-statechange-trigger"
View Source
const SocketPath string = "/run/updatehub-statechange.sock"

Variables

This section is empty.

Functions

This section is empty.

Types

type APIState

type APIState string

type AgentInfo

type AgentInfo struct {
	Config          Settings        `json:"config"`
	Firmware        Firmware        `json:"firmware"`
	RuntimeSettings RuntimeSettings `json:"runtime_settings"`
	State           APIState        `json:"state"`
	Version         string          `json:"version"`
}

type CallbackFunc

type CallbackFunc func(handler *Handler)

CallbackFunc the type of the callbacks.

type Client

type Client struct {
}

func NewClient

func NewClient() *Client

NewClient instantiates a new updatehub agent client

func (*Client) AbortDownload

func (c *Client) AbortDownload() (*APIState, error)

func (*Client) GetInfo

func (c *Client) GetInfo() (*AgentInfo, error)

GetInfo get updatehub agent general information

func (*Client) GetLogs

func (c *Client) GetLogs() (*Log, error)

GetLogs get updatehub agent log entries

func (*Client) LocalInstall

func (c *Client) LocalInstall(filePath string) (*APIState, error)

LocalInstall trigger the installation of a local package

func (*Client) Probe

func (c *Client) Probe(serverAddress string) (*ProbeResponse, error)

Probe server address for update

func (*Client) RemoteInstall

func (c *Client) RemoteInstall(serverAddress string) (*APIState, error)

RemoteInstall trigger the installation of a package from a direct URL

type DeviceAttributes

type DeviceAttributes struct {
	Attr1 string `json:"attr1"`
	Attr2 string `json:"attr2"`
}

type DeviceIdentity

type DeviceIdentity struct {
	ID1 string `json:"id1"`
	ID2 string `json:"id2"`
}

type Entry

type Entry struct {
	Data    interface{} `json:"data"`
	Level   string      `json:"level"`
	Message string      `json:"message"`
	Time    string      `json:"time"`
}

type Firmware

type Firmware struct {
	DeviceAttributes DeviceAttributes `json:"device_attributes"`
	DeviceIdentity   DeviceIdentity   `json:"device_identity"`
	Hardware         string           `json:"hardware"`
	PubKey           string           `json:"pub_key"`
	Version          string           `json:"version"`
}

type Handler

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

/ Handler used to communicate with UpdateHub / to call commands on the state callbacks.

func (Handler) Cancel

func (h Handler) Cancel()

Cancel cancels the current state.

func (Handler) Proceed

func (h Handler) Proceed()

Proceed proceeds to the next state.

type Log

type Log struct {
	Entries []Entry `json:"entries"`
}

type Metadata

type Metadata struct {
	Metadata string `json:"metadata"`
}

type Network

type Network struct {
	ServerAddress string `json:"server_address"`
	ListenSocket  string `json:"listen_socket"`
}

type Polling

type Polling struct {
	Interval string `json:"interval"`
	Enabled  bool   `json:"enabled"`
}

type PollingLog

type PollingLog struct {
	Last          string        `json:"last"`
	Now           bool          `json:"now"`
	Retries       int64         `json:"retries"`
	ServerAddress ServerAddress `json:"server_address"`
}

type ProbeResponse

type ProbeResponse interface{}

type RuntimeSettings

type RuntimeSettings struct {
	Path       string        `json:"path"`
	Persistent bool          `json:"persistent"`
	Polling    PollingLog    `json:"polling"`
	Update     UpdatePackage `json:"update"`
}

type ServerAddress

type ServerAddress struct {
	Custom string `json:"custom"`
}

type Settings

type Settings struct {
	Firmware Metadata `json:"firmware"`
	Network  Network  `json:"network"`
	Polling  Polling  `json:"polling"`
	Storage  Storage  `json:"storage"`
	Update   Update   `json:"update"`
}

type State

type State string

State Represent the states of UpdateHub Agent can handle.

type StateChange

type StateChange struct {
	Listeners map[string][]CallbackFunc
}

StateChange struct that store the callbacks for a state.

func NewStateChange

func NewStateChange() *StateChange

NewStateChange instantiates a new StateChange.

func (*StateChange) Listen

func (sc *StateChange) Listen() error

/ Listen start the agent to listen for messages on the socket.

func (*StateChange) OnState

func (sc *StateChange) OnState(state State, f CallbackFunc)

OnState register the callbacks for a state passed as argument.

type Storage

type Storage struct {
	ReadOnly        bool   `json:"read_only"`
	RuntimeSettings string `json:"runtime_settings"`
}

type Update

type Update struct {
	DownloadDir           string   `json:"download_dir"`
	SupportedInstallModes []string `json:"supported_install_modes"`
}

type UpdatePackage

type UpdatePackage struct {
	AppliedPackageUid      string `json:"applied_package_uid"`
	UpdgradeToInstallation string `json:"upgrade_to_installation"`
}

Directories

Path Synopsis
examples
api

Jump to

Keyboard shortcuts

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