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

mendersoftware / mender-server / 1494677760

14 Oct 2024 08:56AM UTC coverage: 74.094% (-0.03%) from 74.12%
1494677760

push

gitlab-ci

web-flow
Merge pull request #99 from alfrunes/nats-uri

chore: Add nats_uri to inventory and iot-manager services

4399 of 6347 branches covered (69.31%)

Branch coverage included in aggregate %.

41981 of 56249 relevant lines covered (74.63%)

32.55 hits per line

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

82.14
/backend/services/deviceauth/store/mongo/migration_1_6_0.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
        "go.mongodb.org/mongo-driver/mongo"
22
        "go.mongodb.org/mongo-driver/mongo/options"
23

24
        "github.com/mendersoftware/mender-server/pkg/mongo/migrate"
25
        ctxstore "github.com/mendersoftware/mender-server/pkg/store"
26

27
        "github.com/mendersoftware/mender-server/services/deviceauth/model"
28
)
29

30
type migration_1_6_0 struct {
31
        ms  *DataStoreMongo
32
        ctx context.Context
33
}
34

35
func (m *migration_1_6_0) Up(from migrate.Version) error {
3✔
36
        _false := false
3✔
37
        _true := true
3✔
38
        authSetUniqueIndex := mongo.IndexModel{
3✔
39
                Keys: bson.D{
3✔
40
                        {Key: model.AuthSetKeyIdDataSha256, Value: 1},
3✔
41
                        {Key: model.AuthSetKeyPubKey, Value: 1},
3✔
42
                },
3✔
43
                Options: &options.IndexOptions{
3✔
44
                        Background: &_false,
3✔
45
                        Name:       &indexAuthSet_IdentityDataSha256_PubKey,
3✔
46
                        Unique:     &_true,
3✔
47
                },
3✔
48
        }
3✔
49
        cAuthSets := m.ms.client.Database(ctxstore.DbFromContext(m.ctx, DbName)).
3✔
50
                Collection(DbAuthSetColl)
3✔
51
        authSetIndexes := cAuthSets.Indexes()
3✔
52
        _, err := authSetIndexes.CreateOne(m.ctx, authSetUniqueIndex)
3✔
53
        if err != nil {
3✔
54
                return errors.Wrap(
×
55
                        err,
×
56
                        "failed to create index containing IdDataSha256 and PubKey on auth sets",
×
57
                )
×
58
        }
×
59

60
        return nil
3✔
61
}
62

63
func (m *migration_1_6_0) Version() migrate.Version {
3✔
64
        return migrate.MakeVersion(1, 6, 0)
3✔
65
}
3✔
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