• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mendersoftware / deployments / 1197570064

01 Mar 2024 06:24PM UTC coverage: 52.222% (-28.4%) from 80.645%
1197570064

Pull #998

gitlab-ci

web-flow
chore: bump github.com/Azure/azure-sdk-for-go/sdk/azcore

Bumps [github.com/Azure/azure-sdk-for-go/sdk/azcore](https://github.com/Azure/azure-sdk-for-go) from 1.9.1 to 1.10.0.
- [Release notes](https://github.com/Azure/azure-sdk-for-go/releases)
- [Changelog](https://github.com/Azure/azure-sdk-for-go/blob/main/documentation/release.md)
- [Commits](https://github.com/Azure/azure-sdk-for-go/compare/sdk/azcore/v1.9.1...sdk/azcore/v1.10.0)

---
updated-dependencies:
- dependency-name: github.com/Azure/azure-sdk-for-go/sdk/azcore
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #998: chore: bump github.com/Azure/azure-sdk-for-go/sdk/azcore from 1.9.1 to 1.10.0

5218 of 9992 relevant lines covered (52.22%)

0.55 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

87.5
/store/mongo/datastore_mongo_last_status.go
1
// Copyright 2023 Northern.tech AS
2
//
3
//        Licensed under the Apache License, Version 2.0 (the "License");
4
//        you may not use this file except in compliance with the License.
5
//        You may obtain a copy of the License at
6
//
7
//            http://www.apache.org/licenses/LICENSE-2.0
8
//
9
//        Unless required by applicable law or agreed to in writing, software
10
//        distributed under the License is distributed on an "AS IS" BASIS,
11
//        WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
//        See the License for the specific language governing permissions and
13
//        limitations under the License.
14
package mongo
15

16
import (
17
        "context"
18

19
        "github.com/pkg/errors"
20
        "go.mongodb.org/mongo-driver/bson"
21
        mopts "go.mongodb.org/mongo-driver/mongo/options"
22

23
        "github.com/mendersoftware/go-lib-micro/identity"
24
        mstore "github.com/mendersoftware/go-lib-micro/store"
25

26
        "github.com/mendersoftware/deployments/model"
27
)
28

29
var (
30
        ErrTenantRequired = errors.New("tenant id is required")
31
)
32

33
func (db *DataStoreMongo) SaveLastDeviceDeploymentStatus(
34
        ctx context.Context,
35
        deviceDeployment model.DeviceDeployment,
36
) error {
1✔
37
        tenantId := ""
1✔
38
        id := identity.FromContext(ctx)
1✔
39
        if id != nil {
2✔
40
                tenantId = id.Tenant
1✔
41
        }
1✔
42
        filter := bson.M{
1✔
43
                "_id": deviceDeployment.DeviceId,
1✔
44
        }
1✔
45

1✔
46
        lastStatus := model.DeviceDeploymentLastStatus{
1✔
47
                DeviceId:               deviceDeployment.DeviceId,
1✔
48
                DeploymentId:           deviceDeployment.DeploymentId,
1✔
49
                DeviceDeploymentId:     deviceDeployment.Id,
1✔
50
                DeviceDeploymentStatus: deviceDeployment.Status,
1✔
51
                TenantId:               tenantId,
1✔
52
        }
1✔
53

1✔
54
        database := db.client.Database(mstore.DbFromContext(ctx, DatabaseName))
1✔
55
        collDevs := database.Collection(CollectionDevicesLastStatus)
1✔
56
        var err error
1✔
57
        replaceOptions := mopts.Replace()
1✔
58
        replaceOptions.SetUpsert(true)
1✔
59
        _, err = collDevs.ReplaceOne(ctx, filter, lastStatus, replaceOptions)
1✔
60
        return err
1✔
61
}
62

63
func (db *DataStoreMongo) GetLastDeviceDeploymentStatus(
64
        ctx context.Context,
65
        devicesIds []string,
66
) ([]model.DeviceDeploymentLastStatus, error) {
1✔
67
        database := db.client.Database(mstore.DbFromContext(ctx, DatabaseName))
1✔
68
        collDevs := database.Collection(CollectionDevicesLastStatus)
1✔
69

1✔
70
        tenantId := ""
1✔
71
        id := identity.FromContext(ctx)
1✔
72
        if id != nil && id.Tenant != "" {
1✔
73
                tenantId = id.Tenant
×
74
        }
×
75
        filter := bson.M{
1✔
76
                "_id":              bson.M{"$in": devicesIds},
1✔
77
                StorageKeyTenantId: tenantId,
1✔
78
        }
1✔
79
        var statuses []model.DeviceDeploymentLastStatus
1✔
80
        cursor, err := collDevs.Find(ctx, filter)
1✔
81
        if err != nil {
1✔
82
                return statuses, err
×
83
        }
×
84

85
        err = cursor.All(ctx, &statuses)
1✔
86
        if err != nil {
1✔
87
                return statuses, err
×
88
        }
×
89

90
        return statuses, err
1✔
91
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc