model

package
v0.0.0-...-f6b2f6e Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 23 Imported by: 10

Documentation

Overview

Copyright 2023 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 (
	DeploymentStatusFinished   DeploymentStatus = "finished"
	DeploymentStatusInProgress DeploymentStatus = "inprogress"
	DeploymentStatusPending    DeploymentStatus = "pending"

	DeploymentTypeSoftware      DeploymentType = "software"
	DeploymentTypeConfiguration DeploymentType = "configuration"
)
View Source
const (
	// The following statuses are distributed evenly by incrementing the
	// enum counter's second byte.
	// NOTE: when adding new statuses into the list, use the mean value between the
	//       neighbouring values and append the value AFTER the following list and extend
	//       the DeviceDeploymentStatus<type>Str constant and allStatuses variable as well
	//       as the MarshalText and UnmarshalText interface functions.
	//       See example below.
	// WARN: DO NOT CHANGE ANY OF THE FOLLOWING VALUES.
	DeviceDeploymentStatusNull DeviceDeploymentStatus = iota << 8 // i=0... {i * 2^8}
	DeviceDeploymentStatusFailure
	DeviceDeploymentStatusAborted
	DeviceDeploymentStatusPauseBeforeInstall
	DeviceDeploymentStatusPauseBeforeCommit
	DeviceDeploymentStatusPauseBeforeReboot
	DeviceDeploymentStatusDownloading
	DeviceDeploymentStatusInstalling
	DeviceDeploymentStatusRebooting
	DeviceDeploymentStatusPending
	DeviceDeploymentStatusSuccess
	DeviceDeploymentStatusNoArtifact
	DeviceDeploymentStatusAlreadyInst
	DeviceDeploymentStatusDecommissioned

	DeviceDeploymentStatusActiveLow  = DeviceDeploymentStatusPauseBeforeInstall
	DeviceDeploymentStatusActiveHigh = DeviceDeploymentStatusPending

	DeviceDeploymentStatusFailureStr            = "failure"
	DeviceDeploymentStatusAbortedStr            = "aborted"
	DeviceDeploymentStatusPauseBeforeInstallStr = "pause_before_installing"
	DeviceDeploymentStatusPauseBeforeCommitStr  = "pause_before_committing"
	DeviceDeploymentStatusPauseBeforeRebootStr  = "pause_before_rebooting"
	DeviceDeploymentStatusDownloadingStr        = "downloading"
	DeviceDeploymentStatusInstallingStr         = "installing"
	DeviceDeploymentStatusRebootingStr          = "rebooting"
	DeviceDeploymentStatusPendingStr            = "pending"
	DeviceDeploymentStatusSuccessStr            = "success"
	DeviceDeploymentStatusNoArtifactStr         = "noartifact"
	DeviceDeploymentStatusAlreadyInstStr        = "already-installed"
	DeviceDeploymentStatusDecommissionedStr     = "decommissioned"
)

Deployment statuses

View Source
const (
	DeviceDeploymentStatusPauseStr    = "pause"
	DeviceDeploymentStatusActiveStr   = "active"
	DeviceDeploymentStatusFinishedStr = "finished"
)
View Source
const (
	TagsMaxPerRelease = 20  // Maximum number of tags per release.
	TagsMaxUnique     = 100 // Maximum number of unique tags.
)
View Source
const (
	ParamExpire    = "x-men-expire"
	ParamSignature = "x-men-signature"
	ParamTenantID  = "tenant_id"
)
View Source
const (
	ArtifactFileSuffix = ".mender"
)
View Source
const (
	LimitStorage = "storage"
)
View Source
const (
	TagMaxLength = 1024
)

Variables

View Source
var (
	ErrInvalidDeviceID                      = errors.New("Invalid device ID")
	ErrInvalidDeploymentDefinition          = errors.New("Invalid deployments definition")
	ErrInvalidDeploymentDefinitionNoDevices = errors.New(
		"Invalid deployments definition: provide list of devices or set all_devices flag",
	)
	ErrInvalidDeploymentDefinitionConflict = errors.New(
		"Invalid deployments definition: list of devices provided togheter with all_devices flag",
	)
	ErrInvalidDeploymentToGroupDefinitionConflict = errors.New(
		"The deployment for group constructor should have neither list of devices" +
			" nor all_devices flag set",
	)
)

Errors

View Source
var (
	ErrInvalidDeploymentLog = errors.New("invalid deployment log")
	ErrInvalidLogMessage    = errors.New("invalid log message")
)
View Source
var (
	StorageKeyImageProvidesIdxKey   = "meta_artifact.provides_idx.key"
	StorageKeyImageProvidesIdxValue = "meta_artifact.provides_idx.value"
)
View Source
var (
	ErrTooManyTags = errors.New(
		"the total number of tags per exceeded maximum of " +
			strconv.Itoa(TagsMaxPerRelease),
	)
	ErrTooManyUniqueTags = errors.New(
		"the total number of unique tags (" +
			strconv.Itoa(TagsMaxUnique) +
			") has been exceeded",
	)
)
View Source
var (
	ErrTagEmpty   = errors.New("tag cannot be empty")
	ErrTagTooLong = errors.New("tag must be less than " +
		strconv.Itoa(TagMaxLength) +
		" characters")
)
View Source
var (
	NotesLengthMaximumCharacters = 1024

	ErrReleaseNotesTooLong  = errors.New("release notes too long")
	ErrCharactersNotAllowed = errors.New("release notes contain characters which are not allowed")
)
View Source
var (
	ErrBadStatus = errors.New("unknown status value")
)
View Source
var (
	ErrDeviceDeploymentStatusMismatch = errors.New(
		"model active state does not match status",
	)
)
View Source
var ErrLinkExpired = errors.New("URL expired")
View Source
var (
	ValidLimits = []string{LimitStorage}
)

Functions

func ImagePathFromContext

func ImagePathFromContext(ctx context.Context, id string) string

func IsDeviceDeploymentStatusFinished

func IsDeviceDeploymentStatusFinished(status DeviceDeploymentStatus) bool

func IsNotGraphic

func IsNotGraphic(r rune) bool

func IsValidLimit

func IsValidLimit(name string) bool

Types

type ArtifactDeploymentInstructions

type ArtifactDeploymentInstructions struct {
	ID                    string   `json:"id"`
	ArtifactName          string   `json:"artifact_name"`
	Source                Link     `json:"source"`
	DeviceTypesCompatible []string `json:"device_types_compatible"`
}

type ArtifactInfo

type ArtifactInfo struct {
	// Mender artifact format - the only possible value is "mender"
	//Format string `json:"format" valid:"string,equal("mender"),required"`
	Format string `json:"format" valid:"required"`

	// Mender artifact format version
	//Version uint `json:"version" valid:"uint,equal(1),required"`
	Version uint `json:"version" valid:"required"`
}

Structure with artifact version information

func (ArtifactInfo) Validate

func (ai ArtifactInfo) Validate() error

type ArtifactMeta

type ArtifactMeta struct {
	// artifact_name from artifact file
	Name string `json:"name" bson:"name" valid:"length(1|4096),required"`

	// Compatible device types for the application
	//nolint:lll
	DeviceTypesCompatible []string `json:"device_types_compatible" bson:"device_types_compatible" valid:"length(1|4096),required"`

	// Artifact version info
	Info *ArtifactInfo `json:"info"`

	// Flag that indicates if artifact is signed or not
	Signed bool `json:"signed" bson:"signed"`

	// List of updates
	Updates []Update `json:"updates" valid:"-"`

	// Provides is a map of artifact_provides used
	// for checking artifact (version 3) dependencies.
	//nolint: lll
	Provides map[string]string `json:"artifact_provides,omitempty" bson:"provides,omitempty" valid:"-"`

	// ProvidesIdx is special representation of provides
	// which makes possible to index and query using provides.
	ProvidesIdx ProvidesIdx `json:"-" bson:"provides_idx,omitempty"`

	// Depends is a map[string]interface{} (JSON) of artifact_depends used
	// for checking/validate against artifact (version 3) provides.
	Depends map[string]interface{} `json:"artifact_depends,omitempty" bson:"depends" valid:"-"`

	// ClearsProvides is a list of strings (JSON) of clears_artifact_provides used
	// for clearing already-installed artifact (version 3) provides.
	//nolint:lll
	ClearsProvides []string `json:"clears_artifact_provides,omitempty" bson:"clears_provides,omitempty" valid:"-"`
}

Information provided by the Mender Artifact header

func NewArtifactMeta

func NewArtifactMeta() *ArtifactMeta

func (ArtifactMeta) MarshalBSON

func (am ArtifactMeta) MarshalBSON() ([]byte, error)

MarshalBSON transparently creates depends_idx field on bson.Marshal

func (ArtifactMeta) MarshalBSONValue

func (am ArtifactMeta) MarshalBSONValue() (bsontype.Type, []byte, error)

MarshalBSONValue transparently creates depends_idx field on bson.MarshalValue which is called if ArtifactMeta is marshaled as an embedded document.

func (*ArtifactMeta) Validate

func (am *ArtifactMeta) Validate() error

Validate checks structure according to valid tags.

type ArtifactUpdateTypeInfo

type ArtifactUpdateTypeInfo struct {
	Type *string `json:"type" valid:"required"`
}

Type info structure

type ConfigurationDeploymentConstructor

type ConfigurationDeploymentConstructor struct {
	// Deployment name, required
	Name string `json:"name"`

	// A string containing a configuration object.
	// The deployments service will use it to generate configuration
	// artifact for the device.
	// The artifact will be generated when the device will ask
	// for an update.
	Configuration configuration `json:"configuration,omitempty"`

	// Retries represents the number of retries in case of deployment failures
	Retries uint `json:"retries,omitempty"`
}

ConfigurationDeploymentConstructor represent input data needed for creating new Configuration Deployment

func (ConfigurationDeploymentConstructor) Validate

Validate validates the structure.

type ConflictError

type ConflictError struct {
	Err       error       `json:"error"`
	Metadata  interface{} `json:"metadata,omitempty"`
	RequestID string      `json:"request_id,omitempty"`
}

func NewConflictError

func NewConflictError(err error) *ConflictError

func (*ConflictError) Error

func (ce *ConflictError) Error() string

func (*ConflictError) WithMetadata

func (ce *ConflictError) WithMetadata(metadata interface{}) *ConflictError

func (*ConflictError) WithRequestID

func (ce *ConflictError) WithRequestID(requestID string) *ConflictError

type Deployment

type Deployment struct {
	// User provided field set
	*DeploymentConstructor

	// Auto set on create, required
	Created *time.Time `json:"created"`

	// Finished deployment time
	Finished *time.Time `json:"finished,omitempty"`

	// Deployment id, required
	Id string `json:"id" bson:"_id"`

	// List of artifact id's targeted for deployments, optional
	Artifacts []string `json:"artifacts,omitempty" bson:"artifacts"`

	// Aggregated device status counters.
	// Initialized with the "pending" counter set to total device count for deployment.
	// Individual counter incremented/decremented according to device status updates.
	Stats Stats `json:"-"`

	Statistics DeploymentStatistics `json:"statistics,omitempty" bson:"statistics,omitempty"`

	// Status is the overall deployment status
	Status DeploymentStatus `json:"status" bson:"status"`

	// Active is true for unfinished deployments
	Active bool `json:"-" bson:"active"`

	// Number of devices being part of the deployment
	DeviceCount *int `json:"device_count" bson:"device_count"`

	// Total number of devices targeted
	MaxDevices int `json:"max_devices,omitempty" bson:"max_devices"`

	// device groups
	Groups []string `json:"groups,omitempty" bson:"groups"`

	// list of devices
	DeviceList []string `json:"-" bson:"device_list"`

	// deployment type
	// currently we are supporting two types of deployments:
	// software and configuration
	Type DeploymentType `json:"type,omitempty" bson:"type"`

	// A field containing a configuration object.
	// The deployments service will use it to generate configuration
	// artifact for the device.
	// The artifact will be generated when the device will ask
	// for an update.
	Configuration deploymentConfiguration `json:"configuration,omitempty" bson:"configuration"`
}

func NewDeployment

func NewDeployment() (*Deployment, error)

NewDeployment creates new deployment object, sets create data by default.

func NewDeploymentFromConfigurationDeploymentConstructor

func NewDeploymentFromConfigurationDeploymentConstructor(
	constructor *ConfigurationDeploymentConstructor,
	deploymentID string,
) (*Deployment, error)

NewConfigurationDeploymentFromConstructor creates new Deployments object based onconfiguration deployment constructor data

func NewDeploymentFromConstructor

func NewDeploymentFromConstructor(constructor *DeploymentConstructor) (*Deployment, error)

NewDeploymentFromConstructor creates new Deployments object based on constructor data

func NewDeploymentWithID

func NewDeploymentWithID(ID string) (*Deployment, error)

NewDeploymentWithID creates new configuration deployment object, sets create data by default.

func (*Deployment) GetStatus

func (d *Deployment) GetStatus() DeploymentStatus

func (*Deployment) IsFinished

func (d *Deployment) IsFinished() bool

func (*Deployment) IsNotPending

func (d *Deployment) IsNotPending() bool

func (*Deployment) MarshalBSON

func (r *Deployment) MarshalBSON() ([]byte, error)

func (*Deployment) MarshalJSON

func (d *Deployment) MarshalJSON() ([]byte, error)

To be able to hide devices field, from API output provide custom marshaler

func (Deployment) Validate

func (d Deployment) Validate() error

Validate checks structure validation rules

type DeploymentArtifactsUpdate

type DeploymentArtifactsUpdate struct {
	// List of artifact id's targeted for deployments, optional
	Artifacts []string `bson:"artifacts"`
}

type DeploymentConstructor

type DeploymentConstructor struct {
	// Deployment name, required
	Name string `json:"name,omitempty"`

	// Artifact name to be installed required, associated with image
	ArtifactName string `json:"artifact_name,omitempty"`

	// List of device id's targeted for deployments, required
	Devices []string `json:"devices,omitempty" bson:"-"`

	// When set to true deployment will be created for all currently accepted devices
	AllDevices bool `json:"all_devices,omitempty" bson:"-"`

	// ForceInstallation forces the installation of the artifact and disables the
	// `already-installed` check
	ForceInstallation bool `json:"force_installation,omitempty" bson:"force_installation"`

	// When set the deployment will be created for all accepted devices from a given group
	Group string `json:"-" bson:"-"`
}

DeploymentConstructor represent input data needed for creating new Deployment (they differ in fields)

func (DeploymentConstructor) Validate

func (c DeploymentConstructor) Validate() error

Validate checks structure according to valid tags TODO: Add custom validator to check devices array content (such us UUID formatting)

func (DeploymentConstructor) ValidateNew

func (c DeploymentConstructor) ValidateNew() error

type DeploymentIDs

type DeploymentIDs struct {
	IDs []string `json:"deployment_ids"`
}

func (DeploymentIDs) Validate

func (d DeploymentIDs) Validate() error

type DeploymentInstructions

type DeploymentInstructions struct {
	ID       string                         `json:"id"`
	Artifact ArtifactDeploymentInstructions `json:"artifact"`
	Type     DeploymentType                 `json:"-"`
}

type DeploymentLog

type DeploymentLog struct {
	// skip these 2 field when (un)marshaling to/from JSON
	DeviceID     string `json:"-" valid:"required"`
	DeploymentID string `json:"-" valid:"uuidv4,required"`

	Messages []LogMessage `json:"messages" valid:"required"`
}

func (*DeploymentLog) UnmarshalJSON

func (d *DeploymentLog) UnmarshalJSON(raw []byte) error

func (DeploymentLog) Validate

func (d DeploymentLog) Validate() error

type DeploymentNextRequest

type DeploymentNextRequest struct {
	DeviceProvides   *InstalledDeviceDeployment `json:"device_provides"`
	UpdateControlMap bool                       `json:"update_control_map"`
}

DeploymentNextRequest holds a deployments/next request

func (*DeploymentNextRequest) String

func (i *DeploymentNextRequest) String() string

func (*DeploymentNextRequest) Validate

func (i *DeploymentNextRequest) Validate() error

type DeploymentStatistics

type DeploymentStatistics struct {
	Status    Stats `json:"status" bson:"-"`
	TotalSize int   `json:"total_size" bson:"total_size"`
}

type DeploymentStats

type DeploymentStats struct {
	ID    string `json:"id" bson:"_id"`
	Stats Stats  `json:"stats" bson:"stats"`
}

type DeploymentStatus

type DeploymentStatus string

func (DeploymentStatus) Validate

func (stat DeploymentStatus) Validate() error

type DeploymentType

type DeploymentType string

func (DeploymentType) Validate

func (typ DeploymentType) Validate() error

type DeviceAttribute

type DeviceAttribute struct {
	Name        string      `json:"name" bson:",omitempty"`
	Description *string     `json:"description,omitempty" bson:",omitempty"`
	Value       interface{} `json:"value" bson:",omitempty"`
	Scope       string      `json:"scope" bson:",omitempty"`
}

type DeviceDeployment

type DeviceDeployment struct {
	// Active says whether the device's deployment status is in an active
	// state - in progress or pending.
	Active bool `json:"-" bson:"active"`

	// Internal field of initial creation of deployment
	Created *time.Time `json:"created" bson:"created"`

	// Internal field of start of the deployment (after /next call)
	Started *time.Time `json:"started,omitempty" bson:"started"`

	// Update finish time
	Finished *time.Time `json:"finished,omitempty" bson:"finished,omitempty"`

	// Logical deletion time
	Deleted *time.Time `json:"deleted,omitempty" bson:"deleted,omitempty"`

	// Status
	Status DeviceDeploymentStatus `json:"status" bson:"status"`

	// Device id
	DeviceId string `json:"id" bson:"deviceid"`

	// Deployment id
	DeploymentId string `json:"-" bson:"deploymentid"`

	// ID
	Id string `json:"-" bson:"_id"`

	// Assigned software image
	Image *Image `json:"image,omitempty"`

	// deployments/next request from the device
	Request *DeploymentNextRequest `json:"-"`

	// Presence of deployment log
	IsLogAvailable bool `json:"log" bson:"log"`

	// Device reported substate
	SubState string `json:"substate,omitempty" bson:"substate,omitempty"`
}

func NewDeviceDeployment

func NewDeviceDeployment(deviceId, deploymentId string) *DeviceDeployment

func (DeviceDeployment) Validate

func (d DeviceDeployment) Validate() error

type DeviceDeploymentLastStatus

type DeviceDeploymentLastStatus struct {
	// Device id
	DeviceId string `json:"device_id" bson:"_id"`

	// Deployment id
	DeploymentId string `json:"deployment_id" bson:"deployment_id"`

	// Device Deployment id
	DeviceDeploymentId string `json:"device_deployment_id" bson:"device_deployment_id"`

	// Status
	// nolint:lll
	DeviceDeploymentStatus DeviceDeploymentStatus `json:"device_deployment_status" bson:"device_deployment_status"`

	// Tenant id
	TenantId string `json:"-" bson:"tenant_id"`
}

type DeviceDeploymentLastStatusReq

type DeviceDeploymentLastStatusReq struct {
	// Device ids
	DeviceIds []string `json:"device_ids"`
}

type DeviceDeploymentLastStatuses

type DeviceDeploymentLastStatuses struct {
	// DeviceDeploymentLastStatuses array of last device deployments statuses
	// nolint:lll
	DeviceDeploymentLastStatuses []DeviceDeploymentLastStatus `json:"device_deployment_last_statuses" bson:"device_deployment_last_statuses"`
}

type DeviceDeploymentListItem

type DeviceDeploymentListItem struct {
	Id         string            `json:"id"`
	Deployment *Deployment       `json:"deployment"`
	Device     *DeviceDeployment `json:"device"`
}

type DeviceDeploymentState

type DeviceDeploymentState struct {
	// status reported by device
	Status DeviceDeploymentStatus
	// substate reported by device
	SubState string `json:",omitempty" bson:",omitempty"`
	// finish time
	FinishTime *time.Time `json:",omitempty" bson:",omitempty"`
}

DeviceDeploymentStatus is a helper type for reporting status changes through the layers

func (DeviceDeploymentState) Validate

func (state DeviceDeploymentState) Validate() error

type DeviceDeploymentStatus

type DeviceDeploymentStatus int32

DeviceDeploymentStatus is an enumerated type showing the status of a device within a deployment

func ActiveDeploymentStatuses

func ActiveDeploymentStatuses() []DeviceDeploymentStatus

ActiveDeploymentStatuses lists statuses that represent deployment in active state (not finished).

func InactiveDeploymentStatuses

func InactiveDeploymentStatuses() []DeviceDeploymentStatus

func NewStatus

func NewStatus(status string) DeviceDeploymentStatus

func (DeviceDeploymentStatus) Active

func (stat DeviceDeploymentStatus) Active() bool

func (DeviceDeploymentStatus) MarshalText

func (stat DeviceDeploymentStatus) MarshalText() ([]byte, error)

func (DeviceDeploymentStatus) String

func (stat DeviceDeploymentStatus) String() string

func (*DeviceDeploymentStatus) UnmarshalText

func (stat *DeviceDeploymentStatus) UnmarshalText(b []byte) error

type DeviceGroups

type DeviceGroups struct {
	//device's groups names
	Groups []string `json:"groups" bson:"-"`
}

type DeviceIds

type DeviceIds struct {
	Devices []string `json:"devices,omitempty" valid:"required" bson:"-"`
}

type DirectUploadMetadata

type DirectUploadMetadata struct {
	Size    int64    `json:"size,omitempty" valid:"-"`
	Updates []Update `json:"updates" valid:"-"`
}

func (DirectUploadMetadata) Validate

func (m DirectUploadMetadata) Validate() error

type FilterPredicate

type FilterPredicate struct {
	Scope     string      `json:"scope" bson:"scope"`
	Attribute string      `json:"attribute" bson:"attribute"`
	Type      string      `json:"type" bson:"type"`
	Value     interface{} `json:"value" bson:"value"`
}

type Image

type Image struct {
	// Image ID
	Id string `json:"id" bson:"_id" valid:"uuidv4,required"`

	// User provided field set
	*ImageMeta `bson:"meta"`

	// Field set provided with yocto image
	*ArtifactMeta `bson:"meta_artifact"`

	// Artifact total size
	Size int64 `json:"size" bson:"size" valid:"-"`

	// Last modification time, including image upload time
	Modified *time.Time `json:"modified" valid:"-"`
}

Image YOCTO image with user application

func NewImage

func NewImage(
	id string,
	metaConstructor *ImageMeta,
	metaArtifactConstructor *ArtifactMeta,
	artifactSize int64) *Image

NewImage creates new software image object.

func (Image) MarshalBSON

func (img Image) MarshalBSON() (b []byte, err error)

func (Image) MarshalBSONValue

func (img Image) MarshalBSONValue() (bsontype.Type, []byte, error)

func (*Image) SetModified

func (s *Image) SetModified(time time.Time)

SetModified set last modification time for the image.

func (Image) Validate

func (s Image) Validate() error

Validate checks structure according to valid tags.

type ImageMeta

type ImageMeta struct {
	// Image description
	Description string `json:"description,omitempty" valid:"length(1|4096),optional"`
}

Information provided by the user

func NewImageMeta

func NewImageMeta() *ImageMeta

Creates new, empty ImageMeta

func (ImageMeta) Validate

func (s ImageMeta) Validate() error

Validate checks structure according to valid tags.

type InstalledDeviceDeployment

type InstalledDeviceDeployment struct {
	ArtifactName string            `json:"artifact_name"`
	DeviceType   string            `json:"device_type"`
	Provides     map[string]string `json:"artifact_provides,omitempty"`
}

InstalledDeviceDeployment describes a deployment currently installed on the device, usually reported by a device

func (*InstalledDeviceDeployment) Validate

func (i *InstalledDeviceDeployment) Validate() error

type InvDevice

type InvDevice struct {
	//system-generated device ID
	ID string `json:"id" bson:"_id,omitempty"`

	//a map of attributes names and their values.
	Attributes []DeviceAttribute `json:"attributes,omitempty" bson:"attributes,omitempty"`

	//device's group name
	Group string `json:"-" bson:"group,omitempty"`

	CreatedTs time.Time `json:"-" bson:"created_ts,omitempty"`
	//Timestamp of the last attribute update.
	UpdatedTs time.Time `json:"updated_ts" bson:"updated_ts,omitempty"`
}

Inventory device wrapper

type InvalidCharError

type InvalidCharError struct {
	Offset int
	Char   byte
}

func (*InvalidCharError) Error

func (err *InvalidCharError) Error() string

type InvalidCharacterError

type InvalidCharacterError struct {
	Source string
	Char   rune
}

func (*InvalidCharacterError) Error

func (err *InvalidCharacterError) Error() string

type Limit

type Limit struct {
	Name  string `bson:"_id"`
	Value uint64 `bson:"value" json:"value"`
}

func (Limit) IsLess

func (l Limit) IsLess(what uint64) bool
type Link struct {
	Uri      string            `json:"uri" bson:"-"`
	Expire   time.Time         `json:"expire,omitempty" bson:"expire"`
	Method   string            `json:"method,omitempty" bson:"-"`
	Header   map[string]string `json:"header,omitempty" bson:"-"`
	TenantID string            `json:"-" bson:"tenant_id"`
}
func NewLink(uri string, expire time.Time) *Link

type LinkStatus

type LinkStatus uint32
const (
	LinkStatusPending LinkStatus = (iota << 4)
	LinkStatusProcessing
	LinkStatusCompleted
	LinkStatusAborted

	LinkStatusProcessedBit  = LinkStatus(1 << 7)
	LinkStatusProcessedMask = ^LinkStatus(LinkStatusProcessedBit)
)

func (LinkStatus) MarshalText

func (status LinkStatus) MarshalText() (b []byte, err error)

func (*LinkStatus) UnmarshalText

func (status *LinkStatus) UnmarshalText(b []byte) error

type LogMessage

type LogMessage struct {
	Timestamp *time.Time `json:"timestamp" valid:"required"`
	Level     string     `json:"level" valid:"required"`
	Message   string     `json:"message" valid:"required"`
}

func (LogMessage) String

func (l LogMessage) String() string

func (*LogMessage) UnmarshalJSON

func (l *LogMessage) UnmarshalJSON(raw []byte) error

func (LogMessage) Validate

func (l LogMessage) Validate() error

type MultipartGenerateImageMsg

type MultipartGenerateImageMsg struct {
	Name                  string    `json:"name"`
	Description           string    `json:"description"`
	DeviceTypesCompatible []string  `json:"device_types_compatible"`
	Type                  string    `json:"type"`
	Args                  string    `json:"args"`
	ArtifactID            string    `json:"artifact_id"`
	GetArtifactURI        string    `json:"get_artifact_uri"`
	DeleteArtifactURI     string    `json:"delete_artifact_uri"`
	TenantID              string    `json:"tenant_id"`
	Token                 string    `json:"token"`
	FileReader            io.Reader `json:"-"`
}

MultipartGenerateImageMsg is a structure with fields extracted from the multipart/form-data form sent in the artifact generation request

func (MultipartGenerateImageMsg) Validate

func (msg MultipartGenerateImageMsg) Validate() error

type MultipartUploadMsg

type MultipartUploadMsg struct {
	// user metadata constructor
	MetaConstructor *ImageMeta
	// ArtifactID contains the artifact ID
	ArtifactID string
	// reader pointing to the beginning of the artifact data
	ArtifactReader io.Reader
}

MultipartUploadMsg is a structure with fields extracted from the multipart/form-data form send in the artifact upload request

type NewTenantReq

type NewTenantReq struct {
	TenantId string `json:"tenant_id"`
}

func ParseNewTenantReq

func ParseNewTenantReq(source io.Reader) (*NewTenantReq, error)

type Notes

type Notes string

func (Notes) Validate

func (n Notes) Validate() error

type ProvidesIdx

type ProvidesIdx map[string]string

func (ProvidesIdx) MarshalBSONValue

func (p ProvidesIdx) MarshalBSONValue() (bsontype.Type, []byte, error)

func (*ProvidesIdx) UnmarshalBSONValue

func (p *ProvidesIdx) UnmarshalBSONValue(t bsontype.Type, b []byte) error

type Query

type Query struct {
	// list of IDs
	IDs []string

	// match deployments by text by looking at deployment name and artifact name
	SearchText string

	// deployment type
	Type DeploymentType

	// deployment status
	Status StatusQuery
	Limit  int
	Skip   int
	// only return deployments between timestamp range
	CreatedAfter  *time.Time
	CreatedBefore *time.Time

	// sort values by creation date
	Sort string

	// disable the counting
	DisableCount bool
}

Deployment lookup query

type ReadCounter

type ReadCounter interface {
	io.Reader
	// Count returns the number of bytes read.
	Count() int64
}

type Release

type Release struct {
	Name           string     `json:"name" bson:"_id"`
	Modified       *time.Time `json:"modified,omitempty" bson:"modified,omitempty"`
	Artifacts      []Image    `json:"artifacts" bson:"artifacts"`
	ArtifactsCount int        `json:"artifacts_count" bson:"artifacts_count"`
	Tags           Tags       `json:"tags" bson:"tags,omitempty"`
	Notes          Notes      `json:"notes" bson:"notes,omitempty"`
}

type ReleaseOrImageFilter

type ReleaseOrImageFilter struct {
	Name        string   `json:"name"`
	Description string   `json:"description"`
	DeviceType  string   `json:"device_type"`
	Tags        []string `json:"tags"`
	UpdateType  string   `json:"update_type"`
	Page        int      `json:"page"`
	PerPage     int      `json:"per_page"`
	Sort        string   `json:"sort"`
}

type ReleasePatch

type ReleasePatch struct {
	Notes Notes `json:"notes" bson:"notes,omitempty"`
}

func (ReleasePatch) Validate

func (r ReleasePatch) Validate() error

type ReleaseV1

type ReleaseV1 struct {
	Name           string     `json:"Name"`
	Modified       *time.Time `json:"Modified,omitempty"`
	Artifacts      []Image    `json:"Artifacts"`
	ArtifactsCount int        `json:"ArtifactsCount"`
	Tags           Tags       `json:"tags"`
	Notes          Notes      `json:"notes"`
}

func ConvertReleasesToV1

func ConvertReleasesToV1(releases []Release) []ReleaseV1

type ReleasesDeleteError

type ReleasesDeleteError struct {
	Error             string   `json:"error"`
	RequestID         string   `json:"request_id"`
	ActiveDeployments []string `json:"active_deployments"`
}

type RequestSignature

type RequestSignature struct {
	*http.Request
	Secret []byte
}

func NewRequestSignature

func NewRequestSignature(req *http.Request, secret []byte) *RequestSignature

func (*RequestSignature) Bytes

func (sig *RequestSignature) Bytes() []byte

func (*RequestSignature) HMAC256

func (sig *RequestSignature) HMAC256() []byte

func (*RequestSignature) PresignURL

func (sig *RequestSignature) PresignURL() string

PresignURL generates and assign the request signature parameter and returning the resulting URL.

func (*RequestSignature) SetExpire

func (sig *RequestSignature) SetExpire(expire time.Time)

func (*RequestSignature) Validate

func (sig *RequestSignature) Validate() error

Validate validates the request parameters - assumes that the signature is already signed.

func (*RequestSignature) VerifyHMAC256

func (sig *RequestSignature) VerifyHMAC256() bool

VerifyHMAC256 verifies the request signature with the parameter.

type SearchParams

type SearchParams struct {
	Page      int               `json:"page"`
	PerPage   int               `json:"per_page"`
	Filters   []FilterPredicate `json:"filters"`
	DeviceIDs []string          `json:"device_ids"`
}

type Stats

type Stats map[string]int

Deployment statistics wrapper, each value carries a count of deployments aggregated by state.

func NewDeviceDeploymentStats

func NewDeviceDeploymentStats() Stats

func (Stats) Get

func (s Stats) Get(status DeviceDeploymentStatus) int

func (Stats) Inc

func (s Stats) Inc(status DeviceDeploymentStatus)

func (Stats) Set

func (s Stats) Set(status DeviceDeploymentStatus, count int)

type StatusQuery

type StatusQuery int
const (
	StatusQueryAny StatusQuery = iota
	StatusQueryPending
	StatusQueryInProgress
	StatusQueryFinished
	StatusQueryAborted

	SortDirectionAscending  = "asc"
	SortDirectionDescending = "desc"
)

type StatusReport

type StatusReport struct {
	Status   DeviceDeploymentStatus `json:"status"`
	SubState string                 `json:"substate"`
}

func (*StatusReport) UnmarshalJSON

func (s *StatusReport) UnmarshalJSON(raw []byte) error

func (StatusReport) Validate

func (s StatusReport) Validate() error

type StorageSettings

type StorageSettings struct {
	// Type is the provider type (azblob/s3) for the given settings
	Type StorageType `json:"type" bson:"type"`
	// Region sets the s3 bucket region (required when StorageType == StorageTypeAWS)
	Region string `json:"region" bson:"region"`
	// Bucket is the name of the bucket (s3) or container (azblob) storing artifacts.
	Bucket string `json:"bucket" bson:"bucket"`

	// Uri contains the (private) URI used to call the storage APIs.
	Uri string `json:"uri" bson:"uri"`
	// ExternalUri contains the public bucket / container URI.
	ExternalUri string `json:"external_uri" bson:"external_uri"`
	// ProxyURI is used for rewriting presigned requests, pointing the
	// requests to the proxy URL instead of the direct URL to s3.
	ProxyURI *string `json:"proxy_uri,omitempty" bson:"proxy_uri,omitempty"`

	// Key contains the key identifier (azblob: account name) used to
	// authenticate with the storage APIs.
	Key string `json:"key,omitempty" bson:"key,omitempty"`
	// Secret holds the secret part of the authentication credentials.
	Secret string `json:"secret,omitempty" bson:"secret,omitempty"`
	// Token (s3) stores the optional session token.
	Token string `json:"token,omitempty" bson:"token,omitempty"`
	// ConnectionString (azblob) contains the Azure connection string as an
	// alternative set of credentials from (Uri, Key, Secret).
	ConnectionString *string `json:"connection_string,omitempty" bson:"connection_string,omitempty"`
	// ForcePathStyle (s3) enables path-style URL scheme for the s3 API.
	ForcePathStyle bool `json:"force_path_style" bson:"force_path_style"`
	// UseAccelerate (s3) enables AWS transfer acceleration.
	UseAccelerate bool `json:"use_accelerate" bson:"use_accelerate"`
}

func ParseStorageSettingsRequest

func ParseStorageSettingsRequest(source io.Reader) (settings *StorageSettings, err error)

func (StorageSettings) Validate

func (s StorageSettings) Validate() error

Validate checks structure according to valid tags

type StorageType

type StorageType uint32
const (
	StorageTypeS3 StorageType = iota
	StorageTypeAzure
)

func (StorageType) MarshalText

func (typ StorageType) MarshalText() ([]byte, error)

func (*StorageType) UnmarshalText

func (typ *StorageType) UnmarshalText(b []byte) error

type Tag

type Tag string

func (*Tag) UnmarshalJSON

func (tag *Tag) UnmarshalJSON(b []byte) error

func (Tag) Validate

func (tag Tag) Validate() error

type Tags

type Tags []Tag

func (*Tags) Dedup

func (tags *Tags) Dedup()

func (Tags) MarshalJSON

func (tags Tags) MarshalJSON() ([]byte, error)

func (*Tags) UnmarshalJSON

func (tags *Tags) UnmarshalJSON(b []byte) error

func (Tags) Validate

func (tags Tags) Validate() (err error)

type Update

type Update struct {
	TypeInfo ArtifactUpdateTypeInfo `json:"type_info" valid:"required"`
	Files    []UpdateFile           `json:"files"`
	MetaData interface{}            `json:"meta_data,omitempty" valid:"optional"`
}

Update structure

func (Update) Match

func (u Update) Match(update Update) bool

func (Update) Validate

func (u Update) Validate() error

type UpdateFile

type UpdateFile struct {
	// Image name
	Name string `json:"name" valid:"required"`

	// Image file checksum
	Checksum string `json:"checksum" valid:"optional"`

	// Image size
	Size int64 `json:"size" valid:"optional"`

	// Date build
	Date *time.Time `json:"date" valid:"optional"`
}

Update file structure

type UploadLink struct {
	ArtifactID string `json:"id" bson:"_id"`
	Link       `bson:"inline"`

	// Internal metadata
	IssuedAt  time.Time  `json:"-" bson:"issued_ts"`
	UpdatedTS time.Time  `json:"-" bson:"updated_ts"`
	Status    LinkStatus `json:"-" bson:"status"`
}

Jump to

Keyboard shortcuts

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