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

mendersoftware / iot-manager / 1445709825

09 Sep 2024 11:23AM UTC coverage: 86.917% (-0.3%) from 87.172%
1445709825

Pull #303

gitlab-ci

alfrunes
ci: update gitlab runner

Moving to deprecated docker gitlab public runner, to a self-hosted runner

Ticket: SEC-1133
Changelog: none

Signed-off-by: Roberto Giovanardi <roberto.giovanardi@northern.tech>
(cherry picked from commit bb026f77c)
Pull Request #303: Cherry-pick MEN-7478 to 1.3.x (3.7.x)

42 of 54 new or added lines in 2 files covered. (77.78%)

128 existing lines in 10 files now uncovered.

3169 of 3646 relevant lines covered (86.92%)

9.75 hits per line

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

87.1
/store/mongo/migrations.go
1
// Copyright 2022 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

15
package mongo
16

17
import (
18
        "context"
19

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

23
        "github.com/mendersoftware/go-lib-micro/log"
24
        "github.com/mendersoftware/go-lib-micro/mongo/migrate"
25
)
26

27
const (
28
        // DbVersion is the current schema version
29
        DbVersion = "1.1.0"
30

31
        // DbName is the database name
32
        DbName = "iot_manager"
33
)
34

35
// Migrate applies migrations to the database
36
func Migrate(ctx context.Context,
37
        db string,
38
        version string,
39
        client *mongo.Client,
40
        automigrate bool) error {
2✔
41
        l := log.FromContext(ctx)
2✔
42

2✔
43
        l.Infof("migrating %s", db)
2✔
44

2✔
45
        ver, err := migrate.NewVersion(version)
2✔
46
        if err != nil {
2✔
47
                return errors.Wrap(err, "failed to parse service version")
×
48
        }
×
49

50
        m := migrate.SimpleMigrator{
2✔
51
                Client:      client,
2✔
52
                Db:          db,
2✔
53
                Automigrate: automigrate,
2✔
54
        }
2✔
55

2✔
56
        migrations := []migrate.Migration{
2✔
57
                &migration_1_0_0{
2✔
58
                        client: client,
2✔
59
                        db:     db,
2✔
60
                },
2✔
61
                &migration_1_1_0{
2✔
62
                        client: client,
2✔
63
                        db:     db,
2✔
64
                },
2✔
65
        }
2✔
66

2✔
67
        err = m.Apply(ctx, *ver, migrations)
2✔
68
        if err != nil {
2✔
UNCOV
69
                return errors.Wrap(err, "failed to apply migrations")
×
UNCOV
70
        }
×
71

72
        return nil
2✔
73
}
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