Documentation
¶
Index ¶
- Constants
- Variables
- type AppliedConfigs
- type AppsStates
- type ConfigFile
- type ConfigFileSet
- type Device
- func (d Device) AppsStates() ([]AppsStates, error)
- func (d Device) Delete() error
- func (d Device) Events(updateId string) ([]DeviceUpdateEvent, error)
- func (d *Device) GetTest(testId string) (*TargetTest, error)
- func (d *Device) GetTestArtifact(testId, name string) (io.ReadCloser, error)
- func (d *Device) GetTests() ([]TargetTest, error)
- func (d Device) Updates() ([]string, error)
- type DeviceListItem
- type DeviceListOpts
- type DeviceStatus
- type DeviceUpdateEvent
- type ErrConfigUploadBroken
- type FsHandle
- type Labels
- type OrderBy
- type Rollout
- type Storage
- func (s Storage) CommitRollout(tag, updateName, rolloutName string, rollout Rollout) (err error)
- func (s Storage) CreateRollout(tag, updateName, rolloutName string, rollout Rollout) error
- func (s Storage) CreateUpdate(tag, updateName, uploadedBy string, opts TargetOptions, payload io.Reader) error
- func (s Storage) DeleteUpdate(tag, name string) error
- func (s Storage) DeniedDevicesList() ([]string, error)
- func (s Storage) DeviceCreate(uuid, pubkey string, labels Labels) error
- func (s Storage) DeviceGet(uuid string) (*Device, error)
- func (s Storage) DevicesList(opts DeviceListOpts) ([]DeviceListItem, int, error)
- func (s Storage) GenerateTufMeta(tufDir string, opts TargetOptions) error
- func (s Storage) GetKnownDeviceGroupNames() ([]string, error)
- func (s Storage) GetKnownDeviceLabelNames() ([]string, error)
- func (s Storage) GetRollout(tag, updateName, rolloutName string) (res Rollout, err error)
- func (s Storage) GetTufRoot(version int) ([]byte, error)
- func (s Storage) GetUpdateTufMetadata(tag, updateName string) (map[string]map[string]any, error)
- func (s Storage) InsertUpdate(tag, name, uploadedBy string) error
- func (s Storage) ListRollouts(tag, updateName string) ([]string, error)
- func (s Storage) ListUpdates(tag string) (map[string][]Update, error)
- func (s Storage) PatchDeviceLabels(labels map[string]*string, uuids []string) error
- func (s Storage) ReadAppliedConfigs(uuid string) (*storage.AppliedConfigs, error)
- func (s Storage) ReadDeviceConfigHistory(uuid string, latest int, withFiles bool) ([]*ConfigFileSet, error)
- func (s Storage) ReadFactoryConfigHistory(latest int, withFiles bool) ([]*ConfigFileSet, error)
- func (s Storage) ReadGroupConfigHistory(name string, latest int, withFiles bool) ([]*ConfigFileSet, error)
- func (s Storage) ReadRolloutJournal() iter.Seq2[*[3]string, error]
- func (s Storage) RefreshTufTimestamps(c context.Context) error
- func (s Storage) RolloutStateFor(tag, updateName, rolloutName, status string) ([]string, error)
- func (s Storage) RolloutSummary(tag, updateName, rolloutName string) (*UpdateSummary, error)
- func (s Storage) RolloverRolloutJournal() error
- func (s Storage) SaveDeviceConfig(uuid, content, username, reason string) error
- func (s Storage) SaveFactoryConfig(content, username, reason string) error
- func (s Storage) SaveGroupConfig(name, content, username, reason string) error
- func (s Storage) SaveRollout(tag, updateName, rolloutName string, rollout Rollout) error
- func (s Storage) SetUpdateName(tag, updateName string, uuids, groups []string) (effectiveUuids []string, err error)
- func (s Storage) TailRolloutsLog(tag, updateName string, stop storage.DoneChan) iter.Seq2[string, error]
- func (s Storage) UndenyDevice(uuid string) (bool, error)
- func (s Storage) UpdateStateFor(tag, updateName, status string) ([]string, error)
- func (s Storage) UpdateSummary(tag, name string) (*UpdateSummary, error)
- func (s Storage) UploadConfigs(payload io.Reader) (err error)
- type TargetOptions
- type TargetTest
- type Update
- type UpdateSummary
Constants ¶
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 )
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 ¶
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 ¶
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) GetTestArtifact ¶
func (d *Device) GetTestArtifact(testId, name string) (io.ReadCloser, error)
func (*Device) GetTests ¶
func (d *Device) GetTests() ([]TargetTest, error)
type DeviceListItem ¶
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 Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
func (Storage) CommitRollout ¶
func (Storage) CreateRollout ¶
func (Storage) CreateUpdate ¶
func (Storage) DeleteUpdate ¶ added in v0.9.3
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 ¶
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 (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 (Storage) GetKnownDeviceLabelNames ¶
func (Storage) GetRollout ¶
func (Storage) GetTufRoot ¶
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 (Storage) InsertUpdate ¶
InsertUpdate is intended for unit tests that need to seed the updates table without going through the full upload path.
func (Storage) ListRollouts ¶
func (Storage) ListUpdates ¶
ListUpdates returns a map of tag to updates. If the tag is empty, it returns all tags.
func (Storage) PatchDeviceLabels ¶
func (Storage) ReadAppliedConfigs ¶
func (s Storage) ReadAppliedConfigs(uuid string) (*storage.AppliedConfigs, error)
func (Storage) ReadDeviceConfigHistory ¶
func (Storage) ReadFactoryConfigHistory ¶
func (s Storage) ReadFactoryConfigHistory(latest int, withFiles bool) ([]*ConfigFileSet, error)
func (Storage) ReadGroupConfigHistory ¶
func (Storage) ReadRolloutJournal ¶
func (Storage) RefreshTufTimestamps ¶
func (Storage) RolloutStateFor ¶ added in v0.9.4
func (Storage) RolloutSummary ¶ added in v0.9.4
func (s Storage) RolloutSummary(tag, updateName, rolloutName string) (*UpdateSummary, error)
func (Storage) RolloverRolloutJournal ¶
func (Storage) SaveDeviceConfig ¶
func (Storage) SaveFactoryConfig ¶
func (Storage) SaveGroupConfig ¶
func (Storage) SaveRollout ¶
func (Storage) SetUpdateName ¶
func (Storage) TailRolloutsLog ¶
func (Storage) UndenyDevice ¶
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 (Storage) UpdateSummary ¶ added in v0.9.4
func (s Storage) UpdateSummary(tag, name string) (*UpdateSummary, 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