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

mendersoftware / useradm / 1396224475

01 Aug 2024 02:01AM UTC coverage: 85.226%. Remained the same
1396224475

Pull #428

gitlab-ci

web-flow
chore: bump golang in the docker-dependencies group

Bumps the docker-dependencies group with 1 update: golang.


Updates `golang` from 1.22.4-alpine3.19 to 1.22.5-alpine3.19

---
updated-dependencies:
- dependency-name: golang
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: docker-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #428: chore: bump golang from 1.22.4-alpine3.19 to 1.22.5-alpine3.19 in the docker-dependencies group

2792 of 3276 relevant lines covered (85.23%)

49.04 hits per line

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

94.59
/store/mongo/migration_2_0_3.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

15
package mongo
16

17
import (
18
        "context"
19
        "errors"
20
        "fmt"
21

22
        "github.com/mendersoftware/go-lib-micro/log"
23
        "github.com/mendersoftware/go-lib-micro/mongo/migrate"
24
        "go.mongodb.org/mongo-driver/bson"
25
        "go.mongodb.org/mongo-driver/mongo"
26
        mopts "go.mongodb.org/mongo-driver/mongo/options"
27
)
28

29
const IndexNameTokenExpire = "exp_time"
30

31
type migration_2_0_3 struct {
32
        ds     *DataStoreMongo
33
        dbName string
34
        ctx    context.Context
35
}
36

37
func (m *migration_2_0_3) Up(from migrate.Version) error {
114✔
38

114✔
39
        const errCodeIndexNotFound = 27
114✔
40
        var err error
114✔
41

114✔
42
        ctx := context.Background()
114✔
43

114✔
44
        indexModel := mongo.IndexModel{
114✔
45
                Keys: bson.D{
114✔
46
                        {Key: DbTokenExpireTime, Value: 1},
114✔
47
                },
114✔
48
                Options: mopts.Index().
114✔
49
                        SetExpireAfterSeconds(0).
114✔
50
                        SetName(IndexNameTokenExpire),
114✔
51
        }
114✔
52
        if m.dbName == DbName {
170✔
53
                logger := log.FromContext(ctx)
56✔
54
                iw := m.ds.client.Database(DbName).
56✔
55
                        Collection(DbTokensColl).
56✔
56
                        Indexes()
56✔
57
                // drop existing bad TTL index (if it exists)
56✔
58
                _, err = iw.DropOne(ctx, brokenDbTokenExpirationIndexName)
56✔
59
                if err != nil {
112✔
60
                        var srvErr mongo.ServerError
56✔
61
                        if !errors.As(err, &srvErr) || !srvErr.HasErrorCode(errCodeIndexNotFound) {
57✔
62
                                logger.Warnf("failed to drop index '%s': %s",
1✔
63
                                        brokenDbTokenExpirationIndexName,
1✔
64
                                        err.Error())
1✔
65
                        }
1✔
66
                }
67

68
                _, err = iw.CreateOne(ctx, indexModel)
56✔
69
                if err != nil {
56✔
70
                        err = fmt.Errorf("failed to create index '%s': %w", IndexNameTokenExpire, err)
×
71
                }
×
72
        }
73

74
        return err
114✔
75
}
76

77
func (m *migration_2_0_3) Version() migrate.Version {
242✔
78
        return migrate.MakeVersion(2, 0, 3)
242✔
79
}
242✔
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