api

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: BSD-3-Clause-Clear Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OrderByDeviceLastSeenDsc OrderBy = "last-seen-desc"
	OrderByDeviceLastSeenAsc OrderBy = "last-seen-asc"
	OrderByDeviceCreatedDsc  OrderBy = "created-at-desc"
	OrderByDeviceCreatedAsc  OrderBy = "created-at-asc"
	OrderByDeviceNameAsc     OrderBy = "name-asc"
	OrderByDeviceNameDesc    OrderBy = "name-desc"
	OrderByDeviceUuidAsc     OrderBy = "uuid-asc"
	OrderByDeviceUuidDesc    OrderBy = "uuid-desc"

	ConfigHistoryLimit int = 10
	ConfigSotaOverride     = storage.ConfigSotaOverride
)
View Source
const MissingState = "Missing"

A special status used to indicate that a device was expected to be part of the rollout but is not present in the rollout log.

Variables

View Source
var (
	NewDb = storage.NewDb
	NewFs = storage.NewFs

	DbFile = storage.DbFile

	ValidCorrelationId = storage.ValidCorrelationId
	TestIdRegex        = storage.TestIdRegex

	IsDbError             = storage.IsDbError
	ErrDbConstraintUnique = storage.ErrDbConstraintUnique
	ErrInvalidUpdate      = storage.ErrInvalidUpdate
	ErrUpdateInUse        = storage.ErrUpdateInUse
)

Functions

This section is empty.

Types

type AppliedConfigs

type AppliedConfigs = storage.AppliedConfigs

type AppsStates

type AppsStates = storage.AppsStates

type ConfigFile

type ConfigFile = storage.ConfigFile

type ConfigFileSet

type ConfigFileSet = storage.ConfigFileSet

type Device

type Device struct {
	DeviceListItem

	Apps       []string `json:"apps"`
	OstreeHash string   `json:"ostree-hash"`
	PubKey     string   `json:"pubkey"`
	UpdateName string   `json:"update-name"`

	Aktoml  string `json:"aktualizr-toml"`
	HwInfo  string `json:"hardware-info"`
	NetInfo string `json:"network-info"`

	Status *DeviceStatus `json:"status,omitempty"`
	// contains filtered or unexported fields
}

func (Device) AppsStates

func (d Device) AppsStates() ([]AppsStates, error)

func (Device) Delete

func (d Device) Delete() error

Delete is DESTRUCTIVE. It both adds the device to the denied list in the DB (deleted=1) and removes the device's filesystem data (configs, update events, apps-states). The filesystem data destroyed here is NOT recovered if the device is later allowed back via UndenyDevice.

func (Device) Events

func (d Device) Events(updateId string) ([]DeviceUpdateEvent, error)

func (*Device) GetTest

func (d *Device) GetTest(testId string) (*TargetTest, error)

func (*Device) GetTestArtifact

func (d *Device) GetTestArtifact(testId, name string) (io.ReadCloser, error)

func (*Device) GetTests

func (d *Device) GetTests() ([]TargetTest, error)

func (Device) Updates

func (d Device) Updates() ([]string, error)

type DeviceListItem

type DeviceListItem struct {
	Uuid      string `json:"uuid"`
	CreatedAt int64  `json:"created-at"`
	LastSeen  int64  `json:"last-seen"`
	Target    string `json:"target"`
	Tag       string `json:"tag"`
	Labels    Labels `json:"labels"`
}

type DeviceListOpts

type DeviceListOpts struct {
	OrderBy OrderBy `query:"order-by" default:"last-seen-desc"`
	Limit   int     `query:"limit"    default:"1000"`
	Offset  int     `query:"offset"   default:"0"`
}

DeviceListOpts lets you set the order devices will be returned by the `List` api

type DeviceStatus

type DeviceStatus = storage.DeviceStatus

type DeviceUpdateEvent

type DeviceUpdateEvent = storage.DeviceUpdateEvent

type ErrConfigUploadBroken

type ErrConfigUploadBroken = storage.ErrConfigUploadBroken

type FsHandle

type FsHandle = storage.FsHandle

type Labels

type Labels map[string]string

type OrderBy

type OrderBy string

type Rollout

type Rollout struct {
	Uuids  []string `json:"uuids,omitempty"`
	Groups []string `json:"groups,omitempty"`
	Effect []string `json:"effective-uuids,omitempty"`
	Commit bool     `json:"committed"`
}

type Storage

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

func NewStorage

func NewStorage(db *storage.DbHandle, fs *storage.FsHandle) (*Storage, error)

func (Storage) CommitRollout

func (s Storage) CommitRollout(tag, updateName, rolloutName string, rollout Rollout) (err error)

func (Storage) CreateRollout

func (s Storage) CreateRollout(tag, updateName, rolloutName string, rollout Rollout) error

func (Storage) CreateUpdate

func (s Storage) CreateUpdate(tag, updateName, uploadedBy string, opts TargetOptions, payload io.Reader) error

func (Storage) DeleteUpdate added in v0.9.3

func (s Storage) DeleteUpdate(tag, name string) error

DeleteUpdate removes an update's database row and on-disk directory. It refuses (returning ErrUpdateInUse) if any non-denied device is still assigned to the update. It returns ErrNotExist if the update does not exist.

func (Storage) DeniedDevicesList

func (s Storage) DeniedDevicesList() ([]string, error)

DeniedDevicesList returns the UUIDs of all devices on the denied list (deleted=1). These devices are prevented from accessing the backend via mTLS. The result is capped at 10000 entries to protect against unbounded responses on long-lived fleets.

func (Storage) DeviceCreate added in v0.9.3

func (s Storage) DeviceCreate(uuid, pubkey string, labels Labels) error

func (Storage) DeviceGet

func (s Storage) DeviceGet(uuid string) (*Device, error)

func (Storage) DevicesList

func (s Storage) DevicesList(opts DeviceListOpts) ([]DeviceListItem, int, error)

func (Storage) GenerateTufMeta

func (s Storage) GenerateTufMeta(tufDir string, opts TargetOptions) error

func (Storage) GetKnownDeviceGroupNames

func (s Storage) GetKnownDeviceGroupNames() ([]string, error)

func (Storage) GetKnownDeviceLabelNames

func (s Storage) GetKnownDeviceLabelNames() ([]string, error)

func (Storage) GetRollout

func (s Storage) GetRollout(tag, updateName, rolloutName string) (res Rollout, err error)

func (Storage) GetTufRoot

func (s Storage) GetTufRoot(version int) ([]byte, error)

GetTufRoot returns the raw JSON bytes of a TUF root metadata file. A version of 0 (or less) returns the latest root metadata. The returned error wraps os.ErrNotExist when the requested root does not exist.

func (Storage) GetUpdateTufMetadata

func (s Storage) GetUpdateTufMetadata(tag, updateName string) (map[string]map[string]any, error)

func (Storage) InsertUpdate

func (s Storage) InsertUpdate(tag, name, uploadedBy string) error

InsertUpdate is intended for unit tests that need to seed the updates table without going through the full upload path.

func (Storage) ListRollouts

func (s Storage) ListRollouts(tag, updateName string) ([]string, error)

func (Storage) ListUpdates

func (s Storage) ListUpdates(tag string) (map[string][]Update, error)

ListUpdates returns a map of tag to updates. If the tag is empty, it returns all tags.

func (Storage) PatchDeviceLabels

func (s Storage) PatchDeviceLabels(labels map[string]*string, uuids []string) error

func (Storage) ReadAppliedConfigs

func (s Storage) ReadAppliedConfigs(uuid string) (*storage.AppliedConfigs, error)

func (Storage) ReadDeviceConfigHistory

func (s Storage) ReadDeviceConfigHistory(uuid string, latest int, withFiles bool) ([]*ConfigFileSet, error)

func (Storage) ReadFactoryConfigHistory

func (s Storage) ReadFactoryConfigHistory(latest int, withFiles bool) ([]*ConfigFileSet, error)

func (Storage) ReadGroupConfigHistory

func (s Storage) ReadGroupConfigHistory(name string, latest int, withFiles bool) ([]*ConfigFileSet, error)

func (Storage) ReadRolloutJournal

func (s Storage) ReadRolloutJournal() iter.Seq2[*[3]string, error]

func (Storage) RefreshTufTimestamps

func (s Storage) RefreshTufTimestamps(c context.Context) error

func (Storage) RolloutStateFor added in v0.9.4

func (s Storage) RolloutStateFor(tag, updateName, rolloutName, status string) ([]string, error)

func (Storage) RolloutSummary added in v0.9.4

func (s Storage) RolloutSummary(tag, updateName, rolloutName string) (*UpdateSummary, error)

func (Storage) RolloverRolloutJournal

func (s Storage) RolloverRolloutJournal() error

func (Storage) SaveDeviceConfig

func (s Storage) SaveDeviceConfig(uuid, content, username, reason string) error

func (Storage) SaveFactoryConfig

func (s Storage) SaveFactoryConfig(content, username, reason string) error

func (Storage) SaveGroupConfig

func (s Storage) SaveGroupConfig(name, content, username, reason string) error

func (Storage) SaveRollout

func (s Storage) SaveRollout(tag, updateName, rolloutName string, rollout Rollout) error

func (Storage) SetUpdateName

func (s Storage) SetUpdateName(tag, updateName string, uuids, groups []string) (effectiveUuids []string, err error)

func (Storage) TailRolloutsLog

func (s Storage) TailRolloutsLog(tag, updateName string, stop storage.DoneChan) iter.Seq2[string, error]

func (Storage) UndenyDevice

func (s Storage) UndenyDevice(uuid string) (bool, error)

UndenyDevice removes a device from the denied list (sets deleted=0 WHERE deleted=1). It returns true when the device was found on the denied list and is now active, false when the device does not exist or was already active.

func (Storage) UpdateStateFor added in v0.9.4

func (s Storage) UpdateStateFor(tag, updateName, status string) ([]string, error)

func (Storage) UpdateSummary added in v0.9.4

func (s Storage) UpdateSummary(tag, name string) (*UpdateSummary, error)

func (Storage) UploadConfigs

func (s Storage) UploadConfigs(payload io.Reader) (err error)

type TargetOptions

type TargetOptions struct {
	AppVersion int               // Becomes custom.version
	HardwareId string            // Becomes custom.hardwareIds[0]
	Name       string            // Becomes custom.name (otherwise the ostree ref name)
	OstreeHash string            // Becomes hashes.sha256 (otherwise the ostree ref content)
	Tag        string            // Becomes custom.tags[0]
	Apps       map[string]string // Becomes docker_compose_apps (app name -> sha256)
	BaseUrl    string            // base URL used to build proxied app/target URIs
}

type TargetTest

type TargetTest = storage.TargetTest

type Update

type Update = storage.Update

type UpdateSummary added in v0.9.4

type UpdateSummary struct {
	// A map of device status to the number of devices in that status for the update.
	Status map[string]int `json:"summaries"`
}

Jump to

Keyboard shortcuts

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