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

mendersoftware / mender-server / 1978354074

11 Aug 2025 05:31PM UTC coverage: 65.755% (+0.3%) from 65.495%
1978354074

Pull #862

gitlab-ci

web-flow
chore: bump the development-dependencies group across 1 directory with 11 updates

Bumps the development-dependencies group with 11 updates in the /frontend directory:

| Package | From | To |
| --- | --- | --- |
| [@rspack/cli](https://github.com/web-infra-dev/rspack/tree/HEAD/packages/rspack-cli) | `1.4.8` | `1.4.11` |
| [@rspack/core](https://github.com/web-infra-dev/rspack/tree/HEAD/packages/rspack) | `1.4.8` | `1.4.11` |
| [@sentry/webpack-plugin](https://github.com/getsentry/sentry-javascript-bundler-plugins) | `4.0.0` | `4.0.2` |
| [@testing-library/jest-dom](https://github.com/testing-library/jest-dom) | `6.6.3` | `6.6.4` |
| [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) | `24.1.0` | `24.2.1` |
| [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) | `8.38.0` | `8.39.0` |
| [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/tree/HEAD/packages/plugin-react) | `4.7.0` | `5.0.0` |
| [core-js](https://github.com/zloirock/core-js/tree/HEAD/packages/core-js) | `3.44.0` | `3.45.0` |
| [lint-staged](https://github.com/lint-staged/lint-staged) | `16.1.2` | `16.1.5` |
| [typescript](https://github.com/microsoft/TypeScript) | `5.7.3` | `5.9.2` |
| [undici](https://github.com/nodejs/undici) | `7.12.0` | `7.13.0` |



Updates `@rspack/cli` from 1.4.8 to 1.4.11
- [Release notes](https://github.com/web-infra-dev/rspack/releases)
- [Commits](https://github.com/web-infra-dev/rspack/commits/v1.4.11/packages/rspack-cli)

Updates `@rspack/core` from 1.4.8 to 1.4.11
- [Release notes](https://github.com/web-infra-dev/rspack/releases)
- [Commits](https://github.com/web-infra-dev/rspack/commits/v1.4.11/packages/rspack)

Updates `@sentry/webpack-plugin` from 4.0.0 to 4.0.2
- [Release notes](https://github.com/getsentry/sentry-javascript-bundler-plugins/releases)
- [Changelog](https://github.com/getsentry/sentry-javascript-bundler-plugins/blob... (continued)
Pull Request #862: chore: bump the development-dependencies group across 1 directory with 11 updates

29261 of 44500 relevant lines covered (65.76%)

1.44 hits per line

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

71.43
/backend/pkg/store/v2/utils.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 store
16

17
import (
18
        "context"
19
        "strings"
20

21
        "go.mongodb.org/mongo-driver/bson"
22

23
        "github.com/mendersoftware/mender-server/pkg/identity"
24
        mdoc "github.com/mendersoftware/mender-server/pkg/mongo/doc"
25
        v1 "github.com/mendersoftware/mender-server/pkg/store"
26
)
27

28
const FieldTenantID = "tenant_id"
29

30
// WithTenantID adds the tenant_id field to a bson document using the value extracted
31
// from the identity of the context
32
func WithTenantID(ctx context.Context, doc interface{}) bson.D {
6✔
33
        var (
6✔
34
                tenantID string
6✔
35
                res      bson.D
6✔
36
        )
6✔
37

6✔
38
        identity := identity.FromContext(ctx)
6✔
39
        if identity != nil {
12✔
40
                tenantID = identity.Tenant
6✔
41
        }
6✔
42
        tenantElem := bson.E{Key: FieldTenantID, Value: tenantID}
6✔
43

6✔
44
        switch v := doc.(type) {
6✔
45
        case map[string]interface{}:
×
46
                res = make(bson.D, 0, len(v)+1)
×
47
                for k, v := range v {
×
48
                        res = append(res, bson.E{Key: k, Value: v})
×
49
                }
×
50
        case bson.M:
3✔
51
                res = make(bson.D, 0, len(v)+1)
3✔
52
                for k, v := range v {
6✔
53
                        res = append(res, bson.E{Key: k, Value: v})
3✔
54
                }
3✔
55
        case bson.D:
6✔
56
                res = make(bson.D, len(v), len(v)+1)
6✔
57
                copy(res, v)
6✔
58

59
        case bson.Marshaler:
3✔
60
                b, err := v.MarshalBSON()
3✔
61
                if err != nil {
3✔
62
                        return nil
×
63
                }
×
64
                err = bson.Unmarshal(b, &res)
3✔
65
                if err != nil {
3✔
66
                        return nil
×
67
                }
×
68
        default:
5✔
69
                return mdoc.DocumentFromStruct(v, tenantElem)
5✔
70
        }
71
        res = append(res, tenantElem)
6✔
72

6✔
73
        return res
6✔
74
}
75

76
// ArrayWithTenantID adds the tenant_id field to an array of bson documents
77
// using the value extracted from the identity of the context
78
func ArrayWithTenantID(ctx context.Context, doc bson.A) bson.A {
×
79
        res := bson.A{}
×
80
        for _, item := range doc {
×
81
                res = append(res, WithTenantID(ctx, item))
×
82
        }
×
83
        return res
×
84
}
85

86
// DbFromContext generates database name using tenant field from identity extracted
87
// from context and original database name
88
func DbFromContext(ctx context.Context, origDbName string) string {
3✔
89
        return origDbName
3✔
90
}
3✔
91

92
// IsTenantDb returns a function of `TenantDbMatchFunc` that can be used for
93
// checking if database has a tenant DB name format
94
func IsTenantDb(baseDb string) v1.TenantDbMatchFunc {
2✔
95
        prefix := baseDb + "-"
2✔
96
        return func(name string) bool {
4✔
97
                return strings.HasPrefix(name, prefix)
2✔
98
        }
2✔
99
}
100

101
// TenantFromDbName attempts to extract tenant ID from provided tenant DB name.
102
// Returns extracted tenant ID or an empty string.
103
func TenantFromDbName(dbName string, baseDb string) string {
3✔
104
        noBase := strings.TrimPrefix(dbName, baseDb+"-")
3✔
105
        if noBase == dbName {
6✔
106
                return ""
3✔
107
        }
3✔
108
        return noBase
1✔
109
}
110

111
// DbNameForTenant composes tenant's db name.
112
func DbNameForTenant(tenantId string, baseDb string) string {
×
113
        return baseDb
×
114
}
×
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