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

mendersoftware / deployments / 920043239

pending completion
920043239

Pull #872

gitlab-ci

alfrunes
chore: Restrict tag character set

Changelog: None
Signed-off-by: Alf-Rune Siqveland <alf.rune@northern.tech>
Pull Request #872: MEN-6348: Add tags to releases

220 of 229 new or added lines in 7 files covered. (96.07%)

223 existing lines in 7 files now uncovered.

7560 of 9480 relevant lines covered (79.75%)

34.07 hits per line

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

83.67
/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

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

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

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

32
        URI *string // Optional
33
}
34

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

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

57
        BufferSize int64
58

59
        ContentType *string
60
}
61

62
func NewOptions(opts ...*Options) *Options {
6✔
63
        opt := &Options{
6✔
64
                BufferSize: BufferSizeDefault,
6✔
65
        }
6✔
66
        for _, o := range opts {
10✔
67
                if o == nil {
4✔
UNCOV
68
                        continue
×
69
                }
70
                if o.ConnectionString != nil {
4✔
71
                        opt.ConnectionString = o.ConnectionString
×
UNCOV
72
                }
×
73
                if o.SharedKey != nil {
6✔
74
                        opt.SharedKey = o.SharedKey
2✔
75
                }
2✔
76
                if o.ContentType != nil {
7✔
77
                        opt.ContentType = o.ContentType
3✔
78
                }
3✔
79
                if o.BufferSize >= BufferSizeMin {
8✔
80
                        opt.BufferSize = o.BufferSize
4✔
81
                }
4✔
82
        }
83
        return opt
6✔
84
}
85

UNCOV
86
func (opts *Options) SetConnectionString(connStr string) *Options {
×
UNCOV
87
        opts.ConnectionString = &connStr
×
UNCOV
88
        return opts
×
UNCOV
89
}
×
90

91
func (opts *Options) SetSharedKey(sk SharedKeyCredentials) *Options {
1✔
92
        opts.SharedKey = &sk
1✔
93
        return opts
1✔
94
}
1✔
95

96
func (opts *Options) SetContentType(typ string) *Options {
2✔
97
        opts.ContentType = &typ
2✔
98
        return opts
2✔
99
}
2✔
100

101
func (opts *Options) SetBufferSize(size int64) *Options {
1✔
102
        opts.BufferSize = size
1✔
103
        return opts
1✔
104
}
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