datastore

package
v0.0.0-...-5331e25 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2019 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Copyright 2019 Northern.tech AS

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Copyright 2019 Northern.tech AS

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Copyright 2019 Northern.tech AS

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Index

Constants

View Source
const (
	// Name of artifact currently installed. Introduced in Mender 2.0.0.
	ArtifactNameKey = "artifact-name"

	// Key used to store the auth token.
	AuthTokenName = "authtoken"

	// The key used by the standalone installer to track artifacts that have
	// been started, but not committed. We don't want to use the
	// StateDataKey for this, because it contains a lot less information.
	StandaloneStateKey = "standalone-state"

	// Name of key that state data is stored under across reboots. Uses the
	// StateData structure, marshalled to JSON.
	StateDataKey = "state"

	// Added together with update modules in v2.0.0. This key is invoked if,
	// and only if, a client loads data using the StateDataKey, and
	// discovers that it is a different version than what it currently
	// supports. In that case it switches to using the
	// StateDataKeyUncommitted until the commit stage, where it switches
	// back to StateDataKey. This is intended to ensure that upgrading the
	// client to a new database schema doesn't overwrite the existing
	// schema, in case it is rolled back and the old client needs the
	// original schema again.
	StateDataKeyUncommitted = "state-uncommitted"
)
View Source
const (
	RollbackSupportUnknown = ""
	RollbackNotSupported   = "rollback-not-supported"
	RollbackSupported      = "rollback-supported"
)
View Source
const (
	RebootTypeNone      = ""
	RebootTypeCustom    = "reboot-type-custom"
	RebootTypeAutomatic = "reboot-type-automatic"
)
View Source
const StandaloneStateDataVersion = 1
View Source
const StateDataVersion = 2

current version of the format of StateData; increase the version number once the format of StateData is changed StateDataVersion = 2 was introduced in Mender 2.0.0.

Variables

This section is empty.

Functions

This section is empty.

Types

type Artifact

type Artifact struct {
	Source struct {
		URI    string
		Expire string
	}
	CompatibleDevices []string `json:"device_types_compatible"`
	ArtifactName      string   `json:"artifact_name"`
	PayloadTypes      []string
}

type MenderState

type MenderState int
const (
	// initial state
	MenderStateInit MenderState = iota
	// idle state; waiting for transition to the new state
	MenderStateIdle
	// client is bootstrapped, i.e. ready to go
	MenderStateAuthorize
	// wait before authorization attempt
	MenderStateAuthorizeWait
	// inventory update
	MenderStateInventoryUpdate
	// wait for new update or inventory sending
	MenderStateCheckWait
	// check update
	MenderStateUpdateCheck
	// update fetch
	MenderStateUpdateFetch
	// update store
	MenderStateUpdateStore
	// after update store (Download_Leave)
	MenderStateUpdateAfterStore
	// install update
	MenderStateUpdateInstall
	// wait before retrying fetch & install after first failing (timeout,
	// for example)
	MenderStateFetchStoreRetryWait
	// verify update
	MenderStateUpdateVerify
	// Retry sending status report before committing
	MenderStateUpdatePreCommitStatusReportRetry
	// commit needed
	MenderStateUpdateCommit
	// first commit is finished
	MenderStateUpdateAfterFirstCommit
	// all commits are finished
	MenderStateUpdateAfterCommit
	// status report
	MenderStateUpdateStatusReport
	// wait before retrying sending either report or deployment logs
	MenderStatusReportRetryState
	// error reporting status
	MenderStateReportStatusError
	// reboot
	MenderStateReboot
	// first state after booting device after rollback reboot
	MenderStateVerifyReboot
	// state which runs the ArtifactReboot_Leave scripts
	MenderStateAfterReboot
	// rollback
	MenderStateRollback
	// reboot after rollback
	MenderStateRollbackReboot
	// first state after booting device after rollback reboot
	MenderStateVerifyRollbackReboot
	// state which runs ArtifactRollbackReboot_Leave scripts
	MenderStateAfterRollbackReboot
	// error
	MenderStateError
	// update error
	MenderStateUpdateError
	// cleanup state
	MenderStateUpdateCleanup
	// exit state
	MenderStateDone
)

func (MenderState) MarshalJSON

func (m MenderState) MarshalJSON() ([]byte, error)

func (MenderState) String

func (m MenderState) String() string

func (*MenderState) UnmarshalJSON

func (m *MenderState) UnmarshalJSON(data []byte) error

type RebootRequestedType

type RebootRequestedType []RebootType

func (*RebootRequestedType) Get

func (r *RebootRequestedType) Get(n int) (RebootType, error)

func (*RebootRequestedType) Set

func (r *RebootRequestedType) Set(n int, t RebootType) error

type RebootType

type RebootType string

type StandaloneStateData

type StandaloneStateData struct {
	Version      int
	ArtifactName string
	PayloadTypes []string
}

type StateData

type StateData struct {
	// version is providing information about the format of the data
	Version int
	// number representing the id of the last state to execute
	Name MenderState
	// update info and response data for the update that was in progress
	UpdateInfo UpdateInfo
}

StateData is state information that can be used for restoring state from storage

type SupportsRollbackType

type SupportsRollbackType string

func (*SupportsRollbackType) Set

type UpdateInfo

type UpdateInfo struct {
	Artifact Artifact
	ID       string

	// Whether the currently running payloads asked for reboots. It is
	// indexed the same as PayloadTypes above.
	RebootRequested RebootRequestedType

	// Whether the currently running update supports rollback. All payloads
	// must either support rollback or not, so this is one global flag for
	// all of them.
	SupportsRollback SupportsRollbackType

	// How many times this update's state has been stored. This is roughly,
	// but not exactly, equivalent to the number of state transitions, and
	// is used to break out of loops.
	StateDataStoreCount int

	// Whether the current update includes a DB schema update (this
	// structure, and the StateData structure). This is set if we load state
	// data and discover that it is a different version. See also the
	// StateDataKeyUncommitted key.
	HasDBSchemaUpdate bool
}

Info about the update in progress.

func (*UpdateInfo) ArtifactName

func (ur *UpdateInfo) ArtifactName() string

func (*UpdateInfo) CompatibleDevices

func (ur *UpdateInfo) CompatibleDevices() []string

func (*UpdateInfo) URI

func (ur *UpdateInfo) URI() string

Jump to

Keyboard shortcuts

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