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

mendersoftware / mender-server / 1622978334

13 Jan 2025 03:51PM UTC coverage: 72.802% (-3.8%) from 76.608%
1622978334

Pull #300

gitlab-ci

alfrunes
fix: Deployment device count should not exceed max devices

Added a condition to skip deployments when the device count reaches max
devices.

Changelog: Title
Ticket: MEN-7847
Signed-off-by: Alf-Rune Siqveland <alf.rune@northern.tech>
Pull Request #300: fix: Deployment device count should not exceed max devices

4251 of 6164 branches covered (68.96%)

Branch coverage included in aggregate %.

0 of 18 new or added lines in 1 file covered. (0.0%)

2544 existing lines in 83 files now uncovered.

42741 of 58384 relevant lines covered (73.21%)

21.49 hits per line

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

46.43
/backend/services/deployments/storage/azblob/options.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 azblob
16

17
import (
18
        "fmt"
19
        "net/url"
20

21
        "github.com/Azure/azure-sdk-for-go/sdk/storage/azblob"
22
)
23

24
const (
25
        BufferSizeMin     = 4 * 1024          // 4KiB
26
        BufferSizeDefault = 8 * BufferSizeMin // 32KiB - same default as used in io.Copy
27
)
28

29
type SharedKeyCredentials struct {
30
        AccountName string
31
        AccountKey  string
32

33
        URI *string // Optional
34
}
35

36
func (creds SharedKeyCredentials) azParams(
37
        containerName string,
38
) (containerURL string, azCreds *azblob.SharedKeyCredential, err error) {
1✔
39
        azCreds, err = azblob.NewSharedKeyCredential(creds.AccountName, creds.AccountKey)
1✔
40
        if err == nil {
2✔
41
                if creds.URI != nil {
1✔
42
                        containerURL = *creds.URI
×
43
                } else {
1✔
44
                        containerURL = fmt.Sprintf(
1✔
45
                                "https://%s.blob.core.windows.net/%s",
1✔
46
                                azCreds.AccountName(),
1✔
47
                                containerName,
1✔
48
                        )
1✔
49
                }
1✔
50
        }
51
        return containerURL, azCreds, err
1✔
52
}
53

54
type Options struct {
55
        ConnectionString *string
56
        SharedKey        *SharedKeyCredentials
57

58
        ProxyURI *url.URL
59

60
        BufferSize int64
61

62
        ContentType *string
63
}
64

65
func NewOptions(opts ...*Options) *Options {
1✔
66
        opt := &Options{
1✔
67
                BufferSize: BufferSizeDefault,
1✔
68
        }
1✔
69
        for _, o := range opts {
1✔
UNCOV
70
                if o == nil {
×
71
                        continue
×
72
                }
UNCOV
73
                if o.ConnectionString != nil {
×
74
                        opt.ConnectionString = o.ConnectionString
×
75
                }
×
UNCOV
76
                if o.SharedKey != nil {
×
77
                        opt.SharedKey = o.SharedKey
×
78
                }
×
UNCOV
79
                if o.ProxyURI != nil {
×
80
                        opt.ProxyURI = o.ProxyURI
×
81
                }
×
UNCOV
82
                if o.ContentType != nil {
×
UNCOV
83
                        opt.ContentType = o.ContentType
×
UNCOV
84
                }
×
UNCOV
85
                if o.BufferSize >= BufferSizeMin {
×
UNCOV
86
                        opt.BufferSize = o.BufferSize
×
UNCOV
87
                }
×
88
        }
89
        return opt
1✔
90
}
91

92
func (opts *Options) SetConnectionString(connStr string) *Options {
×
93
        opts.ConnectionString = &connStr
×
94
        return opts
×
95
}
×
96

97
func (opts *Options) SetSharedKey(sk SharedKeyCredentials) *Options {
×
98
        opts.SharedKey = &sk
×
99
        return opts
×
100
}
×
101

102
func (opts *Options) SetProxyURI(proxyURI *url.URL) *Options {
×
103
        opts.ProxyURI = proxyURI
×
104
        return opts
×
105
}
×
106

107
func (opts *Options) SetContentType(typ string) *Options {
1✔
108
        opts.ContentType = &typ
1✔
109
        return opts
1✔
110
}
1✔
111

112
func (opts *Options) SetBufferSize(size int64) *Options {
1✔
113
        opts.BufferSize = size
1✔
114
        return opts
1✔
115
}
1✔
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