mongo

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: 3

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.

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.

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.

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.

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.

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.

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.

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 (
	DatabaseName                   = "deployment_service"
	CollectionLimits               = "limits"
	CollectionImages               = "images"
	CollectionDeployments          = "deployments"
	CollectionDeviceDeploymentLogs = "devices.logs"
	CollectionDevices              = "devices"
	CollectionDevicesLastStatus    = "devices_last_status"
	CollectionStorageSettings      = "settings"
	CollectionUploadIntents        = "uploads"
	CollectionReleases             = "releases"
	CollectionUpdateTypes          = "update_types"
)
View Source
const (
	// Need to be kept in sync with structure filed names
	StorageKeyId       = "_id"
	StorageKeyTenantId = "tenant_id"

	StorageKeyImageProvides    = "meta_artifact.provides"
	StorageKeyImageProvidesIdx = "meta_artifact.provides_idx"
	StorageKeyImageDepends     = "meta_artifact.depends"
	StorageKeyImageDependsIdx  = "meta_artifact.depends_idx"
	StorageKeyImageSize        = "size"
	StorageKeyImageDeviceTypes = "meta_artifact.device_types_compatible"
	StorageKeyImageName        = "meta_artifact.name"
	StorageKeyUpdateType       = "meta_artifact.updates.typeinfo.type"
	StorageKeyImageDescription = "meta.description"
	StorageKeyImageModified    = "modified"

	// releases
	StorageKeyReleaseName                      = "_id"
	StorageKeyReleaseModified                  = "modified"
	StorageKeyReleaseTags                      = "tags"
	StorageKeyReleaseNotes                     = "notes"
	StorageKeyReleaseArtifacts                 = "artifacts"
	StorageKeyReleaseArtifactsCount            = "artifacts_count"
	StorageKeyReleaseArtifactsIndexDescription = StorageKeyReleaseArtifacts + ".$." +
		StorageKeyImageDescription
	StorageKeyReleaseArtifactsDescription = StorageKeyReleaseArtifacts + "." +
		StorageKeyImageDescription
	StorageKeyReleaseArtifactsDeviceTypes = StorageKeyReleaseArtifacts + "." +
		StorageKeyImageDeviceTypes
	StorageKeyReleaseArtifactsUpdateTypes = StorageKeyReleaseArtifacts + "." +
		StorageKeyUpdateType
	StorageKeyReleaseArtifactsIndexModified = StorageKeyReleaseArtifacts + ".$." +
		StorageKeyImageModified
	StorageKeyReleaseArtifactsId = StorageKeyReleaseArtifacts + "." +
		StorageKeyId
	StorageKeyReleaseImageDependsIdx = StorageKeyReleaseArtifacts + "." +
		StorageKeyImageDependsIdx
	StorageKeyReleaseImageProvidesIdx = StorageKeyReleaseArtifacts + "." +
		StorageKeyImageProvidesIdx

	StorageKeyDeviceDeploymentLogMessages = "messages"

	StorageKeyDeviceDeploymentAssignedImage   = "image"
	StorageKeyDeviceDeploymentAssignedImageId = StorageKeyDeviceDeploymentAssignedImage +
		"." + StorageKeyId

	StorageKeyDeviceDeploymentActive         = "active"
	StorageKeyDeviceDeploymentCreated        = "created"
	StorageKeyDeviceDeploymentDeviceId       = "deviceid"
	StorageKeyDeviceDeploymentStatus         = "status"
	StorageKeyDeviceDeploymentStarted        = "started"
	StorageKeyDeviceDeploymentSubState       = "substate"
	StorageKeyDeviceDeploymentDeploymentID   = "deploymentid"
	StorageKeyDeviceDeploymentFinished       = "finished"
	StorageKeyDeviceDeploymentIsLogAvailable = "log"
	StorageKeyDeviceDeploymentArtifact       = "image"
	StorageKeyDeviceDeploymentRequest        = "request"
	StorageKeyDeviceDeploymentDeleted        = "deleted"

	StorageKeyDeploymentName         = "deploymentconstructor.name"
	StorageKeyDeploymentArtifactName = "deploymentconstructor.artifactname"
	StorageKeyDeploymentStats        = "stats"
	StorageKeyDeploymentActive       = "active"
	StorageKeyDeploymentStatus       = "status"
	StorageKeyDeploymentCreated      = "created"
	StorageKeyDeploymentStatsCreated = "created"
	StorageKeyDeploymentFinished     = "finished"
	StorageKeyDeploymentArtifacts    = "artifacts"
	StorageKeyDeploymentDeviceCount  = "device_count"
	StorageKeyDeploymentMaxDevices   = "max_devices"
	StorageKeyDeploymentType         = "type"
	StorageKeyDeploymentTotalSize    = "statistics.total_size"

	StorageKeyStorageSettingsDefaultID      = "settings"
	StorageKeyStorageSettingsBucket         = "bucket"
	StorageKeyStorageSettingsRegion         = "region"
	StorageKeyStorageSettingsKey            = "key"
	StorageKeyStorageSettingsSecret         = "secret"
	StorageKeyStorageSettingsURI            = "uri"
	StorageKeyStorageSettingsExternalURI    = "external_uri"
	StorageKeyStorageSettingsToken          = "token"
	StorageKeyStorageSettingsForcePathStyle = "force_path_style"
	StorageKeyStorageSettingsUseAccelerate  = "use_accelerate"

	StorageKeyStorageReleaseUpdateTypes = "update_types"

	ArtifactDependsDeviceType = "device_type"
)

Database keys

View Source
const (
	DbVersion        = "1.2.15"
	DbMinimumVersion = "1.2.14"
	DbName           = "deployment_service"
)
View Source
const DefaultDocumentLimit = 20
View Source
const IndexDeploymentsActiveCreatedV2 = "active_created:v2"

Variables

View Source
var (
	// Indexes (version: 1.2.2)
	IndexUniqueNameAndDeviceTypeName          = "uniqueNameAndDeviceTypeIndex"
	IndexDeploymentArtifactName               = "deploymentArtifactNameIndex"
	IndexDeploymentDeviceStatusesName         = "deviceIdWithStatusByCreated"
	IndexDeploymentDeviceIdStatusName         = "devicesIdWithStatus"
	IndexDeploymentDeviceCreatedStatusName    = "devicesIdWithCreatedStatus"
	IndexDeploymentDeviceDeploymentIdName     = "devicesDeploymentId"
	IndexDeploymentStatusFinishedName         = "deploymentStatusFinished"
	IndexDeploymentStatusPendingName          = "deploymentStatusPending"
	IndexDeploymentCreatedName                = "deploymentCreated"
	IndexDeploymentDeviceStatusRebootingName  = "deploymentsDeviceStatusRebooting"
	IndexDeploymentDeviceStatusPendingName    = "deploymentsDeviceStatusPending"
	IndexDeploymentDeviceStatusInstallingName = "deploymentsDeviceStatusInstalling"
	IndexDeploymentDeviceStatusFinishedName   = "deploymentsFinished"

	// Indexes (version: 1.2.3)
	IndexArtifactNameDependsName = "artifactNameDepends"
	IndexNameAndDeviceTypeName   = "artifactNameAndDeviceTypeIndex"

	// Indexes (version: 1.2.4)
	IndexDeploymentStatus = "deploymentStatus"

	// Indexes 1.2.6
	IndexDeviceDeploymentStatusName = "deploymentid_status_deviceid"

	// Indexes 1.2.13
	IndexArtifactProvidesName = "artifact_provides"

	// Indexes 1.2.15
	IndexNameReleaseTags           = "release_tags"
	IndexNameReleaseUpdateTypes    = "release_update_types"
	IndexNameAggregatedUpdateTypes = "aggregated_release_update_types"
	IndexNameReleaseArtifactsCount = "release_artifacts_count"

	StorageIndexes = mongo.IndexModel{

		Keys: bson.D{
			{Key: StorageKeyDeploymentName,
				Value: "text"},
			{Key: StorageKeyDeploymentArtifactName,
				Value: "text"},
		},
		Options: &mopts.IndexOptions{
			Background: &_false,
			Name:       &IndexDeploymentArtifactName,
		},
	}
	StatusIndexes = mongo.IndexModel{
		Keys: bson.D{
			{Key: StorageKeyDeviceDeploymentDeviceId,
				Value: 1},
			{Key: StorageKeyDeviceDeploymentStatus,
				Value: 1},
			{Key: StorageKeyDeploymentStatsCreated,
				Value: 1},
		},
		Options: &mopts.IndexOptions{
			Background: &_false,
			Name:       &IndexDeploymentDeviceStatusesName,
		},
	}
	DeploymentStatusIndex = mongo.IndexModel{
		Keys: bson.D{
			{Key: StorageKeyDeviceDeploymentStatus,
				Value: 1},
		},
		Options: &mopts.IndexOptions{
			Background: &_false,
			Name:       &IndexDeploymentStatus,
		},
	}
	DeviceIDStatusIndexes = mongo.IndexModel{
		Keys: bson.D{
			{Key: StorageKeyDeviceDeploymentDeviceId, Value: 1},
			{Key: StorageKeyDeviceDeploymentStatus, Value: 1},
		},
		Options: &mopts.IndexOptions{
			Background: &_false,
			Name:       &IndexDeploymentDeviceIdStatusName,
		},
	}
	DeviceIDCreatedStatusIndex = mongo.IndexModel{
		Keys: bson.D{
			{Key: StorageKeyDeviceDeploymentDeviceId, Value: 1},
			{Key: StorageKeyDeploymentStatsCreated, Value: 1},
			{Key: StorageKeyDeviceDeploymentStatus, Value: 1},
		},
		Options: &mopts.IndexOptions{
			Background: &_false,
			Name:       &IndexDeploymentDeviceCreatedStatusName,
		},
	}
	DeploymentIdIndexes = mongo.IndexModel{
		Keys: bson.D{
			{Key: StorageKeyDeviceDeploymentDeploymentID, Value: 1},
			{Key: StorageKeyDeviceDeploymentDeviceId, Value: 1},
		},
		Options: &mopts.IndexOptions{
			Background: &_false,
			Name:       &IndexDeploymentDeviceDeploymentIdName,
		},
	}
	DeviceDeploymentIdStatus = mongo.IndexModel{
		Keys: bson.D{
			{Key: StorageKeyDeviceDeploymentDeploymentID, Value: 1},
			{Key: StorageKeyDeviceDeploymentStatus, Value: 1},
			{Key: StorageKeyDeviceDeploymentDeviceId, Value: 1},
		},
		Options: mopts.Index().
			SetName(IndexDeviceDeploymentStatusName),
	}
	DeploymentStatusFinishedIndex = mongo.IndexModel{
		Keys: bson.D{
			{Key: "stats.downloading", Value: 1},
			{Key: "stats.installing", Value: 1},
			{Key: "stats.pending", Value: 1},
			{Key: "stats.rebooting", Value: 1},
			{Key: "created", Value: -1},
		},
		Options: &mopts.IndexOptions{
			Background: &_false,
			Name:       &IndexDeploymentStatusFinishedName,
		},
	}
	DeploymentStatusPendingIndex = mongo.IndexModel{
		Keys: bson.D{
			{Key: "stats.aborted", Value: 1},
			{Key: "stats.already-installed", Value: 1},
			{Key: "stats.decommissioned", Value: 1},
			{Key: "stats.downloading", Value: 1},
			{Key: "stats.failure", Value: 1},
			{Key: "stats.installing", Value: 1},
			{Key: "stats.noartifact", Value: 1},
			{Key: "stats.rebooting", Value: 1},
			{Key: "stats.success", Value: 1},
			{Key: "created", Value: -1},
		},
		Options: &mopts.IndexOptions{
			Background: &_false,
			Name:       &IndexDeploymentStatusPendingName,
		},
	}
	DeploymentCreatedIndex = mongo.IndexModel{
		Keys: bson.D{
			{Key: "created", Value: -1},
		},
		Options: &mopts.IndexOptions{
			Background: &_false,
			Name:       &IndexDeploymentCreatedName,
		},
	}
	DeploymentDeviceStatusRebootingIndex = mongo.IndexModel{
		Keys: bson.D{
			{Key: "stats.rebooting", Value: 1},
		},
		Options: &mopts.IndexOptions{
			Background: &_false,
			Name:       &IndexDeploymentDeviceStatusRebootingName,
		},
	}
	DeploymentDeviceStatusPendingIndex = mongo.IndexModel{
		Keys: bson.D{
			{Key: "stats.pending", Value: 1},
		},
		Options: &mopts.IndexOptions{
			Background: &_false,
			Name:       &IndexDeploymentDeviceStatusPendingName,
		},
	}
	DeploymentDeviceStatusInstallingIndex = mongo.IndexModel{
		Keys: bson.D{
			{Key: "stats.installing", Value: 1},
		},
		Options: &mopts.IndexOptions{
			Background: &_false,
			Name:       &IndexDeploymentDeviceStatusInstallingName,
		},
	}
	DeploymentDeviceStatusFinishedIndex = mongo.IndexModel{
		Keys: bson.D{
			{Key: "finished", Value: 1},
		},
		Options: &mopts.IndexOptions{
			Background: &_false,
			Name:       &IndexDeploymentDeviceStatusFinishedName,
		},
	}
	UniqueNameVersionIndex = mongo.IndexModel{
		Keys: bson.D{
			{Key: StorageKeyImageName,
				Value: 1},
			{Key: StorageKeyImageDeviceTypes,
				Value: 1},
		},
		Options: &mopts.IndexOptions{
			Background: &_false,
			Name:       &IndexUniqueNameAndDeviceTypeName,
			Unique:     &_true,
		},
	}

	// 1.2.3
	IndexArtifactNameDepends = mongo.IndexModel{
		Keys: bson.D{
			{Key: StorageKeyImageName,
				Value: 1},
			{Key: StorageKeyImageDependsIdx,
				Value: 1},
		},
		Options: &mopts.IndexOptions{
			Background: &_false,
			Name:       &IndexArtifactNameDependsName,
			Unique:     &_true,
		},
	}

	// Indexes 1.2.7
	IndexImageMetaDescription      = "image_meta_description"
	IndexImageMetaDescriptionModel = mongo.IndexModel{
		Keys: bson.D{
			{Key: StorageKeyImageDescription, Value: 1},
		},
		Options: &mopts.IndexOptions{
			Background: &_false,
			Name:       &IndexImageMetaDescription,
		},
	}

	IndexImageMetaArtifactDeviceTypeCompatible      = "image_meta_artifact_device_type_compatible"
	IndexImageMetaArtifactDeviceTypeCompatibleModel = mongo.IndexModel{
		Keys: bson.D{
			{Key: StorageKeyImageDeviceTypes, Value: 1},
		},
		Options: &mopts.IndexOptions{
			Background: &_false,
			Name:       &IndexImageMetaArtifactDeviceTypeCompatible,
		},
	}

	// Indexes 1.2.8
	IndexDeploymentsActiveCreated      = "active_created"
	IndexDeploymentsActiveCreatedModel = mongo.IndexModel{
		Keys: bson.D{
			{Key: StorageKeyDeploymentCreated, Value: 1},
		},
		Options: &mopts.IndexOptions{
			Background: &_false,
			Name:       &IndexDeploymentsActiveCreated,
			PartialFilterExpression: bson.M{
				StorageKeyDeploymentActive: true,
			},
		},
	}

	// Index 1.2.9
	IndexDeviceDeploymentsActiveCreated      = "active_deviceid_created"
	IndexDeviceDeploymentsActiveCreatedModel = mongo.IndexModel{
		Keys: bson.D{
			{Key: StorageKeyDeviceDeploymentActive, Value: 1},
			{Key: StorageKeyDeviceDeploymentDeviceId, Value: 1},
			{Key: StorageKeyDeviceDeploymentCreated, Value: 1},
		},
		Options: mopts.Index().
			SetName(IndexDeviceDeploymentsActiveCreated),
	}

	// Index 1.2.11
	IndexDeviceDeploymentsLogs      = "devices_logs"
	IndexDeviceDeploymentsLogsModel = mongo.IndexModel{
		Keys: bson.D{
			{Key: StorageKeyDeviceDeploymentDeploymentID, Value: 1},
			{Key: StorageKeyDeviceDeploymentDeviceId, Value: 1},
		},
		Options: mopts.Index().
			SetName(IndexDeviceDeploymentsLogs),
	}

	// 1.2.13
	IndexArtifactProvides = mongo.IndexModel{
		Keys: bson.D{
			{Key: model.StorageKeyImageProvidesIdxKey,
				Value: 1},
			{Key: model.StorageKeyImageProvidesIdxValue,
				Value: 1},
		},
		Options: &mopts.IndexOptions{
			Background: &_false,
			Sparse:     &_true,
			Name:       &IndexArtifactProvidesName,
		},
	}
)
View Source
var (
	ErrImagesStorageInvalidID           = errors.New("Invalid id")
	ErrImagesStorageInvalidArtifactName = errors.New("Invalid artifact name")
	ErrImagesStorageInvalidName         = errors.New("Invalid name")
	ErrImagesStorageInvalidDeviceType   = errors.New("Invalid device type")
	ErrImagesStorageInvalidImage        = errors.New("Invalid image")

	ErrStorageInvalidDeviceDeployment = errors.New("Invalid device deployment")

	ErrDeploymentStorageInvalidDeployment = errors.New("Invalid deployment")
	ErrStorageInvalidID                   = errors.New("Invalid id")
	ErrStorageNotFound                    = errors.New("Not found")
	ErrDeploymentStorageInvalidQuery      = errors.New("Invalid query")
	ErrDeploymentStorageCannotExecQuery   = errors.New("Cannot execute query")
	ErrStorageInvalidInput                = errors.New("invalid input")

	ErrLimitNotFound      = errors.New("limit not found")
	ErrDevicesCountFailed = errors.New("failed to count devices")
	ErrConflictingDepends = errors.New(
		"an artifact with the same name and depends already exists",
	)
)

Errors

View Source
var (
	ErrTenantRequired = errors.New("tenant id is required")
)
View Source
var (
	IndexDeploymentArtifactName_0_0_0 = "deploymentconstructor." +
		"name_text_deploymentconstructor.artifactname_text"
)

Functions

func IteratorFromCursor

func IteratorFromCursor[T interface{}](cur *mongo.Cursor) store.Iterator[T]

func Migrate

func Migrate(ctx context.Context,
	version string,
	client *mongo.Client,
	automigrate bool) error

func MigrateSingle

func MigrateSingle(ctx context.Context,
	db string,
	version string,
	client *mongo.Client,
	automigrate bool) error

func NewMongoClient

func NewMongoClient(ctx context.Context, c config.Reader) (*mongo.Client, error)

Types

type DataStoreMongo

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

func NewDataStoreMongoWithClient

func NewDataStoreMongoWithClient(client *mongo.Client) *DataStoreMongo

func (*DataStoreMongo) AbortDeviceDeployments

func (db *DataStoreMongo) AbortDeviceDeployments(ctx context.Context,
	deploymentId string) error

func (*DataStoreMongo) AggregateDeviceDeploymentByStatus

func (db *DataStoreMongo) AggregateDeviceDeploymentByStatus(ctx context.Context,
	id string) (model.Stats, error)

func (*DataStoreMongo) AssignArtifact

func (db *DataStoreMongo) AssignArtifact(
	ctx context.Context,
	deviceID string,
	deploymentID string,
	artifact *model.Image,
) error

AssignArtifact assigns artifact to the device deployment

func (*DataStoreMongo) DecommissionDeviceDeployments

func (db *DataStoreMongo) DecommissionDeviceDeployments(ctx context.Context,
	deviceId string) error

func (*DataStoreMongo) DeleteDeployment

func (db *DataStoreMongo) DeleteDeployment(ctx context.Context, id string) error

Delete removed entry by ID Noop on ID not found

func (*DataStoreMongo) DeleteDeviceDeploymentsHistory

func (db *DataStoreMongo) DeleteDeviceDeploymentsHistory(ctx context.Context,
	deviceID string) error

func (*DataStoreMongo) DeleteImage

func (db *DataStoreMongo) DeleteImage(ctx context.Context, id string) error

Delete image specified by ID Noop on if not found.

func (*DataStoreMongo) DeleteImagesByNames

func (db *DataStoreMongo) DeleteImagesByNames(ctx context.Context, names []string) error

func (*DataStoreMongo) DeleteReleasesByNames

func (db *DataStoreMongo) DeleteReleasesByNames(ctx context.Context, names []string) error

func (*DataStoreMongo) DeviceCountByDeployment

func (db *DataStoreMongo) DeviceCountByDeployment(ctx context.Context,
	id string) (int, error)

func (*DataStoreMongo) EnsureIndexes

func (db *DataStoreMongo) EnsureIndexes(dbName string, collName string,
	indexes ...mongo.IndexModel) error

func (*DataStoreMongo) ExistByArtifactId

func (db *DataStoreMongo) ExistByArtifactId(ctx context.Context,
	id string) (bool, error)

ExistByArtifactId check if there is any deployment that uses give artifact

func (*DataStoreMongo) ExistUnfinishedByArtifactId

func (db *DataStoreMongo) ExistUnfinishedByArtifactId(ctx context.Context,
	id string) (bool, error)

ExistUnfinishedByArtifactId checks if there is an active deployment that uses given artifact

func (*DataStoreMongo) ExistUnfinishedByArtifactName

func (db *DataStoreMongo) ExistUnfinishedByArtifactName(ctx context.Context,
	artifactName string) (bool, error)

ExistUnfinishedByArtifactName checks if there is an active deployment that uses given artifact

func (*DataStoreMongo) Exists

func (db *DataStoreMongo) Exists(ctx context.Context, id string) (bool, error)

Exists checks if object with ID exists

func (*DataStoreMongo) Find

func (db *DataStoreMongo) Find(ctx context.Context,
	match model.Query) ([]*model.Deployment, int64, error)

func (*DataStoreMongo) FindDeploymentByID

func (db *DataStoreMongo) FindDeploymentByID(
	ctx context.Context,
	id string,
) (*model.Deployment, error)

func (*DataStoreMongo) FindDeploymentStatsByIDs

func (db *DataStoreMongo) FindDeploymentStatsByIDs(
	ctx context.Context,
	ids ...string,
) (deploymentStats []*model.DeploymentStats, err error)

func (*DataStoreMongo) FindImageByID

func (db *DataStoreMongo) FindImageByID(ctx context.Context,
	id string) (*model.Image, error)

FindImageByID search storage for image with ID, returns nil if not found

func (*DataStoreMongo) FindLatestInactiveDeviceDeployment

func (db *DataStoreMongo) FindLatestInactiveDeviceDeployment(
	ctx context.Context,
	deviceID string,
) (*model.DeviceDeployment, error)

FindLatestInactiveDeviceDeployment finds the latest device deployment matching device id that has not finished yet.

func (*DataStoreMongo) FindNewerActiveDeployments

func (db *DataStoreMongo) FindNewerActiveDeployments(ctx context.Context,
	createdAfter *time.Time, skip, limit int) ([]*model.Deployment, error)

FindNewerActiveDeployments finds active deployments which were created after createdAfter

func (*DataStoreMongo) FindOldestActiveDeviceDeployment

func (db *DataStoreMongo) FindOldestActiveDeviceDeployment(
	ctx context.Context,
	deviceID string,
) (*model.DeviceDeployment, error)

FindOldestActiveDeviceDeployment finds the oldest deployment that has not finished yet.

func (*DataStoreMongo) FindUnfinishedByID

func (db *DataStoreMongo) FindUnfinishedByID(ctx context.Context,
	id string) (*model.Deployment, error)
func (db *DataStoreMongo) FindUploadLinks(
	ctx context.Context,
	expiredAt time.Time,
) (store.Iterator[model.UploadLink], error)

func (*DataStoreMongo) GetDeploymentIDsByArtifactNames

func (db *DataStoreMongo) GetDeploymentIDsByArtifactNames(
	ctx context.Context,
	artifactNames []string,
) ([]string, error)

func (*DataStoreMongo) GetDeviceDeployment

func (db *DataStoreMongo) GetDeviceDeployment(ctx context.Context, deploymentID string,
	deviceID string, includeDeleted bool) (*model.DeviceDeployment, error)

func (*DataStoreMongo) GetDeviceDeploymentLog

func (db *DataStoreMongo) GetDeviceDeploymentLog(ctx context.Context,
	deviceID, deploymentID string) (*model.DeploymentLog, error)

func (*DataStoreMongo) GetDeviceDeployments

func (db *DataStoreMongo) GetDeviceDeployments(
	ctx context.Context,
	skip int,
	limit int,
	deviceID string,
	active *bool,
	includeDeleted bool,
) ([]model.DeviceDeployment, error)

func (*DataStoreMongo) GetDeviceDeploymentsForDevice

func (db *DataStoreMongo) GetDeviceDeploymentsForDevice(ctx context.Context,
	q store.ListQueryDeviceDeployments) ([]model.DeviceDeployment, int, error)

func (*DataStoreMongo) GetDeviceStatusesForDeployment

func (db *DataStoreMongo) GetDeviceStatusesForDeployment(ctx context.Context,
	deploymentID string) ([]model.DeviceDeployment, error)

GetDeviceStatusesForDeployment retrieve device deployment statuses for a given deployment.

func (*DataStoreMongo) GetDevicesListForDeployment

func (db *DataStoreMongo) GetDevicesListForDeployment(ctx context.Context,
	q store.ListQuery) ([]model.DeviceDeployment, int, error)

func (*DataStoreMongo) GetLastDeviceDeploymentStatus

func (db *DataStoreMongo) GetLastDeviceDeploymentStatus(
	ctx context.Context,
	devicesIds []string,
) ([]model.DeviceDeploymentLastStatus, error)

func (*DataStoreMongo) GetLimit

func (db *DataStoreMongo) GetLimit(ctx context.Context, name string) (*model.Limit, error)

limits

func (*DataStoreMongo) GetReleases

func (db *DataStoreMongo) GetReleases(
	ctx context.Context,
	filt *model.ReleaseOrImageFilter,
) ([]model.Release, int, error)

func (*DataStoreMongo) GetStorageSettings

func (db *DataStoreMongo) GetStorageSettings(ctx context.Context) (*model.StorageSettings, error)

Per-tenant storage settings

func (*DataStoreMongo) GetTenantDbs

func (db *DataStoreMongo) GetTenantDbs() ([]string, error)

func (*DataStoreMongo) GetUpdateTypes

func (db *DataStoreMongo) GetUpdateTypes(ctx context.Context) ([]string, error)

Get the update types

func (*DataStoreMongo) HasDeploymentForDevice

func (db *DataStoreMongo) HasDeploymentForDevice(ctx context.Context,
	deploymentID string, deviceID string) (bool, error)

Returns true if deployment of ID `deploymentID` is assigned to device with ID `deviceID`, false otherwise. In case of errors returns false and an error that occurred

func (*DataStoreMongo) ImageByIdsAndDeviceType

func (db *DataStoreMongo) ImageByIdsAndDeviceType(ctx context.Context,
	ids []string, deviceType string) (*model.Image, error)

ImageByIdsAndDeviceType finds image with id from ids and target device type

func (*DataStoreMongo) ImageByNameAndDeviceType

func (db *DataStoreMongo) ImageByNameAndDeviceType(ctx context.Context,
	name, deviceType string) (*model.Image, error)

ImageByNameAndDeviceType finds image with specified application name and target device type

func (*DataStoreMongo) ImagesByName

func (db *DataStoreMongo) ImagesByName(
	ctx context.Context, name string) ([]*model.Image, error)

ImagesByName finds images with specified artifact name

func (*DataStoreMongo) IncrementDeploymentDeviceCount

func (db *DataStoreMongo) IncrementDeploymentDeviceCount(
	ctx context.Context,
	deploymentID string,
	increment int,
) error

func (*DataStoreMongo) IncrementDeploymentTotalSize

func (db *DataStoreMongo) IncrementDeploymentTotalSize(
	ctx context.Context,
	deploymentID string,
	increment int64,
) error

func (*DataStoreMongo) InsertDeployment

func (db *DataStoreMongo) InsertDeployment(
	ctx context.Context,
	deployment *model.Deployment,
) error

Insert persists object

func (*DataStoreMongo) InsertDeviceDeployment

func (db *DataStoreMongo) InsertDeviceDeployment(
	ctx context.Context,
	deviceDeployment *model.DeviceDeployment,
	incrementDeviceCount bool,
) error

Insert persists device deployment object

func (*DataStoreMongo) InsertImage

func (db *DataStoreMongo) InsertImage(ctx context.Context, image *model.Image) error

Insert persists object

func (*DataStoreMongo) InsertMany

func (db *DataStoreMongo) InsertMany(ctx context.Context,
	deployments ...*model.DeviceDeployment) error

InsertMany stores multiple device deployment objects. TODO: Handle error cleanup, multi insert is not atomic, loop into two-phase commits

func (*DataStoreMongo) InsertUploadIntent

func (db *DataStoreMongo) InsertUploadIntent(ctx context.Context, link *model.UploadLink) error

func (*DataStoreMongo) IsArtifactUnique

func (db *DataStoreMongo) IsArtifactUnique(ctx context.Context,
	artifactName string, deviceTypesCompatible []string) (bool, error)

IsArtifactUnique checks if there is no artifact with the same artifactName supporting one of the device types from deviceTypesCompatible list. Returns true, nil if artifact is unique; false, nil if artifact is not unique; false, error in case of error.

func (*DataStoreMongo) ListImages

func (db *DataStoreMongo) ListImages(
	ctx context.Context,
	filt *model.ReleaseOrImageFilter,
) ([]*model.Image, int, error)

ListImages lists all images

func (*DataStoreMongo) ListReleaseTags

func (db *DataStoreMongo) ListReleaseTags(ctx context.Context) (model.Tags, error)

func (*DataStoreMongo) Ping

func (db *DataStoreMongo) Ping(ctx context.Context) error

func (*DataStoreMongo) ProvisionTenant

func (db *DataStoreMongo) ProvisionTenant(ctx context.Context, tenantId string) error

func (*DataStoreMongo) ReplaceReleaseTags

func (db *DataStoreMongo) ReplaceReleaseTags(
	ctx context.Context,
	releaseName string,
	tags model.Tags,
) error

func (*DataStoreMongo) SaveDeviceDeploymentLog

func (db *DataStoreMongo) SaveDeviceDeploymentLog(ctx context.Context,
	log model.DeploymentLog) error

device deployment log

func (*DataStoreMongo) SaveDeviceDeploymentRequest

func (db *DataStoreMongo) SaveDeviceDeploymentRequest(
	ctx context.Context,
	ID string,
	request *model.DeploymentNextRequest,
) error

SaveDeviceDeploymentRequest saves device deployment request with the device deployment object

func (*DataStoreMongo) SaveLastDeviceDeploymentStatus

func (db *DataStoreMongo) SaveLastDeviceDeploymentStatus(
	ctx context.Context,
	deviceDeployment model.DeviceDeployment,
) error

func (*DataStoreMongo) SaveUpdateTypes

func (db *DataStoreMongo) SaveUpdateTypes(ctx context.Context, updateTypes []string) error

Save the possibly new update types

func (*DataStoreMongo) SetDeploymentDeviceCount

func (db *DataStoreMongo) SetDeploymentDeviceCount(
	ctx context.Context,
	deploymentID string,
	count int,
) error

func (*DataStoreMongo) SetDeploymentStatus

func (db *DataStoreMongo) SetDeploymentStatus(
	ctx context.Context,
	id string,
	status model.DeploymentStatus,
	now time.Time,
) error

SetDeploymentStatus simply sets the status field optionally sets 'finished time' if deployment is indeed finished

func (*DataStoreMongo) SetStorageSettings

func (db *DataStoreMongo) SetStorageSettings(
	ctx context.Context,
	storageSettings *model.StorageSettings,
) error

func (*DataStoreMongo) Update

func (db *DataStoreMongo) Update(ctx context.Context,
	image *model.Image) (bool, error)

Update provided Image Return false if not found

func (*DataStoreMongo) UpdateDeploymentsWithArtifactName

func (db *DataStoreMongo) UpdateDeploymentsWithArtifactName(
	ctx context.Context,
	artifactName string,
	artifactIDs []string,
) error

func (*DataStoreMongo) UpdateDeviceDeploymentLogAvailability

func (db *DataStoreMongo) UpdateDeviceDeploymentLogAvailability(ctx context.Context,
	deviceID string, deploymentID string, log bool) error

func (*DataStoreMongo) UpdateDeviceDeploymentStatus

func (db *DataStoreMongo) UpdateDeviceDeploymentStatus(
	ctx context.Context,
	deviceID string,
	deploymentID string,
	ddState model.DeviceDeploymentState,
	currentStatus model.DeviceDeploymentStatus,
) (model.DeviceDeploymentStatus, error)

func (*DataStoreMongo) UpdateRelease

func (db *DataStoreMongo) UpdateRelease(
	ctx context.Context,
	releaseName string,
	release model.ReleasePatch,
) error

func (*DataStoreMongo) UpdateReleaseArtifactDescription

func (db *DataStoreMongo) UpdateReleaseArtifactDescription(
	ctx context.Context,
	artifactToEdit *model.Image,
	releaseName string,
) error

func (*DataStoreMongo) UpdateReleaseArtifacts

func (db *DataStoreMongo) UpdateReleaseArtifacts(
	ctx context.Context,
	artifactToAdd *model.Image,
	artifactToRemove *model.Image,
	releaseName string,
) error

func (*DataStoreMongo) UpdateStats

func (db *DataStoreMongo) UpdateStats(ctx context.Context,
	id string, stats model.Stats) error

func (*DataStoreMongo) UpdateStatsInc

func (db *DataStoreMongo) UpdateStatsInc(ctx context.Context, id string,
	stateFrom, stateTo model.DeviceDeploymentStatus) error

func (*DataStoreMongo) UpdateUploadIntentStatus

func (db *DataStoreMongo) UpdateUploadIntentStatus(
	ctx context.Context,
	id string,
	from, to model.LinkStatus,
) error

Jump to

Keyboard shortcuts

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