Documentation ¶
Index ¶
- Constants
- Variables
- type App
- type Deployments
- func (d *Deployments) AbortDeployment(ctx context.Context, deploymentID string) error
- func (d *Deployments) AbortDeviceDeployments(ctx context.Context, deviceId string) error
- func (d *Deployments) CleanupExpiredUploads(ctx context.Context, interval, jitter time.Duration) error
- func (d *Deployments) CompleteUpload(ctx context.Context, intentID string, skipVerify bool, ...) error
- func (d *Deployments) CreateDeployment(ctx context.Context, constructor *model.DeploymentConstructor) (string, error)
- func (d *Deployments) CreateDeviceConfigurationDeployment(ctx context.Context, constructor *model.ConfigurationDeploymentConstructor, ...) (string, error)
- func (d *Deployments) CreateImage(ctx context.Context, multipartUploadMsg *model.MultipartUploadMsg) (string, error)
- func (d *Deployments) DecommissionDevice(ctx context.Context, deviceId string) error
- func (d *Deployments) DeleteDeviceDeploymentsHistory(ctx context.Context, deviceId string) error
- func (d *Deployments) DeleteImage(ctx context.Context, imageID string) error
- func (d *Deployments) DeleteReleases(ctx context.Context, releaseNames []string) ([]string, error)
- func (d *Deployments) DownloadLink(ctx context.Context, imageID string, expire time.Duration) (*model.Link, error)
- func (d *Deployments) EditImage(ctx context.Context, imageID string, constructor *model.ImageMeta) (bool, error)
- func (d *Deployments) GenerateConfigurationImage(ctx context.Context, deviceType string, deploymentID string) (io.Reader, error)
- func (d *Deployments) GenerateImage(ctx context.Context, ...) (string, error)
- func (d *Deployments) GetDeployment(ctx context.Context, deploymentID string) (*model.Deployment, error)
- func (d *Deployments) GetDeploymentForDeviceWithCurrent(ctx context.Context, deviceID string, request *model.DeploymentNextRequest) (*model.DeploymentInstructions, error)
- func (d *Deployments) GetDeploymentStats(ctx context.Context, deploymentID string) (model.Stats, error)
- func (d *Deployments) GetDeploymentsStats(ctx context.Context, deploymentIDs ...string) (deploymentStats []*model.DeploymentStats, err error)
- func (d *Deployments) GetDeviceDeploymentLastStatus(ctx context.Context, devicesIds []string) (model.DeviceDeploymentLastStatuses, error)
- func (d *Deployments) GetDeviceDeploymentListForDevice(ctx context.Context, query store.ListQueryDeviceDeployments) ([]model.DeviceDeploymentListItem, int, error)
- func (d *Deployments) GetDeviceDeploymentLog(ctx context.Context, deviceID, deploymentID string) (*model.DeploymentLog, error)
- func (d *Deployments) GetDeviceStatusesForDeployment(ctx context.Context, deploymentID string) ([]model.DeviceDeployment, error)
- func (d *Deployments) GetDevicesListForDeployment(ctx context.Context, query store.ListQuery) ([]model.DeviceDeployment, int, error)
- func (d *Deployments) GetImage(ctx context.Context, id string) (*model.Image, error)
- func (d *Deployments) GetLimit(ctx context.Context, name string) (*model.Limit, error)
- func (d *Deployments) GetReleasesUpdateTypes(ctx context.Context) ([]string, error)
- func (d *Deployments) GetStorageSettings(ctx context.Context) (*model.StorageSettings, error)
- func (d *Deployments) HasDeploymentForDevice(ctx context.Context, deploymentID string, deviceID string) (bool, error)
- func (d *Deployments) HealthCheck(ctx context.Context) error
- func (d *Deployments) ImageUsedInActiveDeployment(ctx context.Context, imageID string) (bool, error)
- func (d *Deployments) ImageUsedInDeployment(ctx context.Context, imageID string) (bool, error)
- func (d *Deployments) IsDeploymentFinished(ctx context.Context, deploymentID string) (bool, error)
- func (d *Deployments) ListImages(ctx context.Context, filters *model.ReleaseOrImageFilter) ([]*model.Image, int, error)
- func (d *Deployments) ListReleaseTags(ctx context.Context) (model.Tags, error)
- func (d *Deployments) LookupDeployment(ctx context.Context, query model.Query) ([]*model.Deployment, int64, error)
- func (d *Deployments) ProvisionTenant(ctx context.Context, tenant_id string) error
- func (d *Deployments) ReplaceReleaseTags(ctx context.Context, releaseName string, tags model.Tags) error
- func (d *Deployments) SaveDeviceDeploymentLog(ctx context.Context, deviceID string, deploymentID string, ...) error
- func (d *Deployments) SetInventoryClient(inventoryClient inventory.Client)
- func (d *Deployments) SetStorageSettings(ctx context.Context, storageSettings *model.StorageSettings) error
- func (d *Deployments) SetWorkflowsClient(workflowsClient workflows.Client)
- func (d *Deployments) UpdateDeploymentsWithArtifactName(ctx context.Context, artifactName string) error
- func (d *Deployments) UpdateDeviceDeploymentStatus(ctx context.Context, deploymentID string, deviceID string, ...) error
- func (d *Deployments) UpdateRelease(ctx context.Context, releaseName string, release model.ReleasePatch) error
- func (d *Deployments) UploadLink(ctx context.Context, expire time.Duration, skipVerify bool) (*model.UploadLink, error)
- func (d *Deployments) WithReporting(c reporting.Client) *Deployments
Constants ¶
const ( ArtifactContentType = "application/vnd.mender-artifact" ArtifactConfigureProvides = "data-partition.mender-configure.version" ArtifactConfigureProvidesCleared = "data-partition.mender-configure.*" DefaultUpdateDownloadLinkExpire = 24 * time.Hour DefaultImageGenerationLinkExpire = 7 * 24 * time.Hour PerPageInventoryDevices = 512 InventoryGroupScope = "system" InventoryIdentityScope = "identity" InventoryGroupAttributeName = "group" InventoryStatusAttributeName = "status" InventoryStatusAccepted = "accepted" )
const (
MaxDeviceArrayLength = 1024
)
Variables ¶
var ( // images ErrImageMetaNotFound = errors.New("Image metadata is not found") ErrModelMultipartUploadMsgMalformed = errors.New("Multipart upload message malformed") ErrModelMissingInputMetadata = errors.New("Missing input metadata") ErrModelMissingInputArtifact = errors.New("Missing input artifact") ErrModelInvalidMetadata = errors.New("Metadata invalid") ErrModelArtifactNotUnique = errors.New("Artifact not unique") ErrModelImageInActiveDeployment = errors.New( "Image is used in active deployment and cannot be removed", ) ErrModelImageUsedInAnyDeployment = errors.New("Image has already been used in deployment") ErrModelParsingArtifactFailed = errors.New("Cannot parse artifact file") ErrUploadNotFound = errors.New("artifact object not found") ErrEmptyArtifact = errors.New("artifact cannot be nil") ErrMsgArtifactConflict = "An artifact with the same name has conflicting dependencies" // deployments ErrModelMissingInput = errors.New("Missing input deployment data") ErrModelInvalidDeviceID = errors.New("Invalid device ID") ErrModelDeploymentNotFound = errors.New("Deployment not found") ErrModelInternal = errors.New("Internal error") ErrStorageInvalidLog = errors.New("Invalid deployment log") ErrStorageNotFound = errors.New("Not found") ErrDeploymentAborted = errors.New("Deployment aborted") ErrDeviceDecommissioned = errors.New("Device decommissioned") ErrNoArtifact = errors.New("No artifact for the deployment") ErrNoDevices = errors.New("No devices for the deployment") ErrDuplicateDeployment = errors.New("Deployment with given ID already exists") ErrInvalidDeploymentID = errors.New("Deployment ID must be a valid UUID") ErrConflictingRequestData = errors.New("Device provided conflicting request data") ErrConflictingDeployment = errors.New( "Invalid deployment definition: there is already an active deployment with " + "the same parameters", ) )
Errors expected from App interface
var ( ErrNoIdsGiven = errors.New("need at least one device id") ErrArrayTooBig = errors.New("too many device ids given") )
var (
ArtifactConfigureType = "mender-configure"
)
var (
ErrReleaseNotFound = errors.New("release not found")
)
Errors expected from App interface
Functions ¶
This section is empty.
Types ¶
type App ¶
type App interface { HealthCheck(ctx context.Context) error // limits GetLimit(ctx context.Context, name string) (*model.Limit, error) ProvisionTenant(ctx context.Context, tenant_id string) error // Storage Settings GetStorageSettings(ctx context.Context) (*model.StorageSettings, error) SetStorageSettings(ctx context.Context, storageSettings *model.StorageSettings) error // images ListImages( ctx context.Context, filters *model.ReleaseOrImageFilter, ) ([]*model.Image, int, error) DownloadLink(ctx context.Context, imageID string, expire time.Duration) (*model.Link, error) UploadLink( ctx context.Context, expire time.Duration, skipVerify bool, ) (*model.UploadLink, error) CompleteUpload( ctx context.Context, intentID string, skipVerify bool, metadata *model.DirectUploadMetadata, ) error GetImage(ctx context.Context, id string) (*model.Image, error) DeleteImage(ctx context.Context, imageID string) error CreateImage(ctx context.Context, multipartUploadMsg *model.MultipartUploadMsg) (string, error) GenerateImage(ctx context.Context, multipartUploadMsg *model.MultipartGenerateImageMsg) (string, error) GenerateConfigurationImage( ctx context.Context, deviceType string, deploymentID string, ) (io.Reader, error) EditImage(ctx context.Context, id string, constructorData *model.ImageMeta) (bool, error) // deployments CreateDeployment(ctx context.Context, constructor *model.DeploymentConstructor) (string, error) GetDeployment(ctx context.Context, deploymentID string) (*model.Deployment, error) IsDeploymentFinished(ctx context.Context, deploymentID string) (bool, error) AbortDeployment(ctx context.Context, deploymentID string) error GetDeploymentStats(ctx context.Context, deploymentID string) (model.Stats, error) GetDeploymentsStats(ctx context.Context, deploymentIDs ...string) ([]*model.DeploymentStats, error) GetDeploymentForDeviceWithCurrent(ctx context.Context, deviceID string, request *model.DeploymentNextRequest) (*model.DeploymentInstructions, error) HasDeploymentForDevice(ctx context.Context, deploymentID string, deviceID string) (bool, error) UpdateDeviceDeploymentStatus(ctx context.Context, deploymentID string, deviceID string, state model.DeviceDeploymentState) error GetDeviceStatusesForDeployment(ctx context.Context, deploymentID string) ([]model.DeviceDeployment, error) GetDevicesListForDeployment(ctx context.Context, query store.ListQuery) ([]model.DeviceDeployment, int, error) GetDeviceDeploymentListForDevice(ctx context.Context, query store.ListQueryDeviceDeployments) ([]model.DeviceDeploymentListItem, int, error) LookupDeployment(ctx context.Context, query model.Query) ([]*model.Deployment, int64, error) SaveDeviceDeploymentLog(ctx context.Context, deviceID string, deploymentID string, logs []model.LogMessage) error GetDeviceDeploymentLog(ctx context.Context, deviceID, deploymentID string) (*model.DeploymentLog, error) AbortDeviceDeployments(ctx context.Context, deviceID string) error DeleteDeviceDeploymentsHistory(ctx context.Context, deviceId string) error DecommissionDevice(ctx context.Context, deviceID string) error CreateDeviceConfigurationDeployment( ctx context.Context, constructor *model.ConfigurationDeploymentConstructor, deviceID, deploymentID string) (string, error) UpdateDeploymentsWithArtifactName( ctx context.Context, artifactName string, ) error GetDeviceDeploymentLastStatus( ctx context.Context, devicesIds []string, ) ( model.DeviceDeploymentLastStatuses, error, ) // releases ReplaceReleaseTags(ctx context.Context, releaseName string, tags model.Tags) error UpdateRelease(ctx context.Context, releaseName string, release model.ReleasePatch) error ListReleaseTags(ctx context.Context) (model.Tags, error) GetReleasesUpdateTypes(ctx context.Context) ([]string, error) DeleteReleases(ctx context.Context, releaseNames []string) ([]string, error) }
type Deployments ¶
type Deployments struct {
// contains filtered or unexported fields
}
func NewDeployments ¶
func NewDeployments( storage store.DataStore, objectStorage storage.ObjectStorage, maxActiveDeployments int64, withAuditLogs bool, ) *Deployments
func (*Deployments) AbortDeployment ¶
func (d *Deployments) AbortDeployment(ctx context.Context, deploymentID string) error
AbortDeployment aborts deployment for devices and updates deployment stats
func (*Deployments) AbortDeviceDeployments ¶
func (d *Deployments) AbortDeviceDeployments(ctx context.Context, deviceId string) error
AbortDeviceDeployments aborts all the pending and active deployments for a device
func (*Deployments) CleanupExpiredUploads ¶
func (*Deployments) CompleteUpload ¶
func (d *Deployments) CompleteUpload( ctx context.Context, intentID string, skipVerify bool, metadata *model.DirectUploadMetadata, ) error
func (*Deployments) CreateDeployment ¶
func (d *Deployments) CreateDeployment(ctx context.Context, constructor *model.DeploymentConstructor) (string, error)
CreateDeployment precomputes new deployment and schedules it for devices.
func (*Deployments) CreateDeviceConfigurationDeployment ¶
func (d *Deployments) CreateDeviceConfigurationDeployment( ctx context.Context, constructor *model.ConfigurationDeploymentConstructor, deviceID, deploymentID string) (string, error)
CreateDeviceConfigurationDeployment creates new configuration deployment for the device.
func (*Deployments) CreateImage ¶
func (d *Deployments) CreateImage(ctx context.Context, multipartUploadMsg *model.MultipartUploadMsg) (string, error)
CreateImage parses artifact and uploads artifact file to the file storage - in parallel, and creates image structure in the system. Returns image ID and nil on success.
func (*Deployments) DecommissionDevice ¶
func (d *Deployments) DecommissionDevice(ctx context.Context, deviceId string) error
DecommissionDevice updates the status of all the pending and active deployments for a device to decommissioned
func (*Deployments) DeleteDeviceDeploymentsHistory ¶
func (d *Deployments) DeleteDeviceDeploymentsHistory(ctx context.Context, deviceId string) error
DeleteDeviceDeploymentsHistory deletes the device deployments history
func (*Deployments) DeleteImage ¶
func (d *Deployments) DeleteImage(ctx context.Context, imageID string) error
DeleteImage removes metadata and image file Noop for not existing images Allowed to remove image only if image is not scheduled or in progress for an updates - then image file is needed In case of already finished updates only image file is not needed, metadata is attached directly to device deployment therefore we still have some information about image that have been used (but not the file)
func (*Deployments) DeleteReleases ¶
func (*Deployments) DownloadLink ¶
func (d *Deployments) DownloadLink(ctx context.Context, imageID string, expire time.Duration) (*model.Link, error)
DownloadLink presigned GET link to download image file. Returns error if image have not been uploaded.
func (*Deployments) EditImage ¶
func (d *Deployments) EditImage(ctx context.Context, imageID string, constructor *model.ImageMeta) (bool, error)
EditObject allows editing only if image have not been used yet in any deployment.
func (*Deployments) GenerateConfigurationImage ¶
func (*Deployments) GenerateImage ¶
func (d *Deployments) GenerateImage(ctx context.Context, multipartGenerateImageMsg *model.MultipartGenerateImageMsg) (string, error)
GenerateImage parses raw data and uploads it to the file storage - in parallel, creates image structure in the system, and starts the workflow to generate the artifact from them. Returns image ID and nil on success.
func (*Deployments) GetDeployment ¶
func (d *Deployments) GetDeployment(ctx context.Context, deploymentID string) (*model.Deployment, error)
GetDeployment fetches deployment by ID
func (*Deployments) GetDeploymentForDeviceWithCurrent ¶
func (d *Deployments) GetDeploymentForDeviceWithCurrent(ctx context.Context, deviceID string, request *model.DeploymentNextRequest) (*model.DeploymentInstructions, error)
GetDeploymentForDeviceWithCurrent returns deployment for the device
func (*Deployments) GetDeploymentStats ¶
func (*Deployments) GetDeploymentsStats ¶
func (d *Deployments) GetDeploymentsStats(ctx context.Context, deploymentIDs ...string) (deploymentStats []*model.DeploymentStats, err error)
func (*Deployments) GetDeviceDeploymentLastStatus ¶
func (d *Deployments) GetDeviceDeploymentLastStatus( ctx context.Context, devicesIds []string, ) (model.DeviceDeploymentLastStatuses, error)
GetDeviceDeploymentLastStatus returns the array of last device deployment statuses.
func (*Deployments) GetDeviceDeploymentListForDevice ¶
func (d *Deployments) GetDeviceDeploymentListForDevice(ctx context.Context, query store.ListQueryDeviceDeployments) ([]model.DeviceDeploymentListItem, int, error)
func (*Deployments) GetDeviceDeploymentLog ¶
func (d *Deployments) GetDeviceDeploymentLog(ctx context.Context, deviceID, deploymentID string) (*model.DeploymentLog, error)
func (*Deployments) GetDeviceStatusesForDeployment ¶
func (d *Deployments) GetDeviceStatusesForDeployment(ctx context.Context, deploymentID string) ([]model.DeviceDeployment, error)
GetDeviceStatusesForDeployment retrieve device deployment statuses for a given deployment.
func (*Deployments) GetDevicesListForDeployment ¶
func (d *Deployments) GetDevicesListForDeployment(ctx context.Context, query store.ListQuery) ([]model.DeviceDeployment, int, error)
func (*Deployments) GetImage ¶
GetImage allows to fetch image object with specified id Nil if not found
func (*Deployments) GetReleasesUpdateTypes ¶
func (d *Deployments) GetReleasesUpdateTypes(ctx context.Context) ([]string, error)
func (*Deployments) GetStorageSettings ¶
func (d *Deployments) GetStorageSettings(ctx context.Context) (*model.StorageSettings, error)
Storage settings
func (*Deployments) HasDeploymentForDevice ¶
func (*Deployments) HealthCheck ¶
func (d *Deployments) HealthCheck(ctx context.Context) error
func (*Deployments) ImageUsedInActiveDeployment ¶
func (d *Deployments) ImageUsedInActiveDeployment(ctx context.Context, imageID string) (bool, error)
ImageUsedInActiveDeployment checks if specified image is in use by deployments. Image is considered to be in use if it's participating in at lest one non success/error deployment.
func (*Deployments) ImageUsedInDeployment ¶
ImageUsedInDeployment checks if specified image is in use by deployments. Image is considered to be in use if it's participating in any deployment.
func (*Deployments) IsDeploymentFinished ¶
func (d *Deployments) IsDeploymentFinished( ctx context.Context, deploymentID string, ) (bool, error)
IsDeploymentFinished checks if there is unfinished deployment with given ID
func (*Deployments) ListImages ¶
func (d *Deployments) ListImages( ctx context.Context, filters *model.ReleaseOrImageFilter, ) ([]*model.Image, int, error)
ListImages according to specified filers.
func (*Deployments) ListReleaseTags ¶
func (*Deployments) LookupDeployment ¶
func (d *Deployments) LookupDeployment(ctx context.Context, query model.Query) ([]*model.Deployment, int64, error)
func (*Deployments) ProvisionTenant ¶
func (d *Deployments) ProvisionTenant(ctx context.Context, tenant_id string) error
func (*Deployments) ReplaceReleaseTags ¶
func (*Deployments) SaveDeviceDeploymentLog ¶
func (d *Deployments) SaveDeviceDeploymentLog(ctx context.Context, deviceID string, deploymentID string, logs []model.LogMessage) error
SaveDeviceDeploymentLog will save the deployment log for device of ID `deviceID`. Returns nil if log was saved successfully.
func (*Deployments) SetInventoryClient ¶
func (d *Deployments) SetInventoryClient(inventoryClient inventory.Client)
func (*Deployments) SetStorageSettings ¶
func (d *Deployments) SetStorageSettings( ctx context.Context, storageSettings *model.StorageSettings, ) error
func (*Deployments) SetWorkflowsClient ¶
func (d *Deployments) SetWorkflowsClient(workflowsClient workflows.Client)
func (*Deployments) UpdateDeploymentsWithArtifactName ¶
func (d *Deployments) UpdateDeploymentsWithArtifactName( ctx context.Context, artifactName string, ) error
func (*Deployments) UpdateDeviceDeploymentStatus ¶
func (d *Deployments) UpdateDeviceDeploymentStatus(ctx context.Context, deploymentID string, deviceID string, ddState model.DeviceDeploymentState) error
UpdateDeviceDeploymentStatus will update the deployment status for device of ID `deviceID`. Returns nil if update was successful.
func (*Deployments) UpdateRelease ¶
func (d *Deployments) UpdateRelease( ctx context.Context, releaseName string, release model.ReleasePatch, ) error
func (*Deployments) UploadLink ¶
func (d *Deployments) UploadLink( ctx context.Context, expire time.Duration, skipVerify bool, ) (*model.UploadLink, error)
func (*Deployments) WithReporting ¶
func (d *Deployments) WithReporting(c reporting.Client) *Deployments