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

mendersoftware / deployments / 1197570064

01 Mar 2024 06:24PM UTC coverage: 52.222% (-28.4%) from 80.645%
1197570064

Pull #998

gitlab-ci

web-flow
chore: bump github.com/Azure/azure-sdk-for-go/sdk/azcore

Bumps [github.com/Azure/azure-sdk-for-go/sdk/azcore](https://github.com/Azure/azure-sdk-for-go) from 1.9.1 to 1.10.0.
- [Release notes](https://github.com/Azure/azure-sdk-for-go/releases)
- [Changelog](https://github.com/Azure/azure-sdk-for-go/blob/main/documentation/release.md)
- [Commits](https://github.com/Azure/azure-sdk-for-go/compare/sdk/azcore/v1.9.1...sdk/azcore/v1.10.0)

---
updated-dependencies:
- dependency-name: github.com/Azure/azure-sdk-for-go/sdk/azcore
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #998: chore: bump github.com/Azure/azure-sdk-for-go/sdk/azcore from 1.9.1 to 1.10.0

5218 of 9992 relevant lines covered (52.22%)

0.55 hits per line

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

26.67
/model/release.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 model
16

17
import (
18
        "encoding/json"
19
        "errors"
20
        "fmt"
21
        "strconv"
22
        "strings"
23
        "time"
24
        "unicode"
25
)
26

27
const (
28
        TagsMaxPerRelease = 20  // Maximum number of tags per release.
29
        TagsMaxUnique     = 100 // Maximum number of unique tags.
30
)
31

32
var (
33
        ErrTooManyTags = errors.New(
34
                "the total number of tags per exceeded maximum of " +
35
                        strconv.Itoa(TagsMaxPerRelease),
36
        )
37
        ErrTooManyUniqueTags = errors.New(
38
                "the total number of unique tags (" +
39
                        strconv.Itoa(TagsMaxUnique) +
40
                        ") has been exceeded",
41
        )
42
)
43

44
type Tags []Tag
45

46
func (tags Tags) Validate() (err error) {
×
47
        if len(tags) > TagsMaxPerRelease {
×
48
                return ErrTooManyTags
×
49
        }
×
50
        for _, tag := range tags {
×
51
                if err = tag.Validate(); err != nil {
×
52
                        return err
×
53
                }
×
54
        }
55
        return nil
×
56
}
57

58
func (tags Tags) MarshalJSON() ([]byte, error) {
1✔
59
        if len(tags) == 0 {
2✔
60
                return []byte{'[', ']'}, nil
1✔
61
        }
1✔
62
        return json.Marshal([]Tag(tags))
×
63
}
64

65
func (tags *Tags) Dedup() {
×
66
        // Deduplicate tags:
×
67
        set := make(map[Tag]struct{})
×
68
        result := make(Tags, 0, len(*tags))
×
69
        for _, item := range *tags {
×
70
                if _, exists := set[item]; !exists {
×
71
                        set[item] = struct{}{}
×
72
                        result = append(result, item)
×
73
                }
×
74
        }
75
        *tags = result
×
76
}
77

78
func (tags *Tags) UnmarshalJSON(b []byte) error {
×
79
        err := json.Unmarshal(b, (*[]Tag)(tags))
×
80
        if err != nil {
×
81
                return err
×
82
        }
×
83
        tags.Dedup()
×
84
        return nil
×
85
}
86

87
type Tag string
88

89
const (
90
        TagMaxLength = 1024
91
)
92

93
var (
94
        ErrTagEmpty   = errors.New("tag cannot be empty")
95
        ErrTagTooLong = errors.New("tag must be less than " +
96
                strconv.Itoa(TagMaxLength) +
97
                " characters")
98
)
99

100
type InvalidCharacterError struct {
101
        Source string
102
        Char   rune
103
}
104

105
func (err *InvalidCharacterError) Error() string {
×
106
        return fmt.Sprintf(`invalid character '%c' in string "%s"`, err.Char, err.Source)
×
107
}
×
108

109
func (tag Tag) Validate() error {
×
110
        if len(tag) < 1 {
×
111
                return ErrTagEmpty
×
112
        } else if len(tag) > TagMaxLength {
×
113
                return ErrTagTooLong
×
114
        }
×
115
        for _, c := range tag { // [A-Za-z0-9-_.]
×
116
                if c >= 'A' && c <= 'Z' {
×
117
                        continue
×
118
                } else if c >= 'a' && c <= 'z' {
×
119
                        continue
×
120
                } else if c >= '0' && c <= '9' {
×
121
                        continue
×
122
                } else if c == '-' || c == '_' || c == '.' {
×
123
                        continue
×
124
                } else {
×
125
                        return &InvalidCharacterError{
×
126
                                Source: string(tag),
×
127
                                Char:   c,
×
128
                        }
×
129
                }
×
130
        }
131
        return nil
×
132
}
133

134
func (tag *Tag) UnmarshalJSON(b []byte) error {
×
135
        // Convert tag to lower case
×
136
        var s string
×
137
        err := json.Unmarshal(b, &s)
×
138
        if err != nil {
×
139
                return err
×
140
        }
×
141
        *tag = Tag(strings.ToLower(s))
×
142
        return nil
×
143
}
144

145
type Notes string
146

147
var (
148
        NotesLengthMaximumCharacters = 1024
149

150
        ErrReleaseNotesTooLong  = errors.New("release notes too long")
151
        ErrCharactersNotAllowed = errors.New("release notes contain characters which are not allowed")
152
)
153

154
type InvalidCharError struct {
155
        Offset int
156
        Char   byte
157
}
158

159
func (err *InvalidCharError) Error() string {
×
160
        return fmt.Sprintf(`invalid character '%c' at offset %d`, err.Char, err.Offset)
×
161
}
×
162

163
func IsNotGraphic(r rune) bool {
1✔
164
        return !unicode.IsGraphic(r)
1✔
165
}
1✔
166

167
func (n Notes) Validate() error {
1✔
168
        length := len(n)
1✔
169
        if length > NotesLengthMaximumCharacters {
1✔
170
                return ErrReleaseNotesTooLong
×
171
        }
×
172
        if i := strings.IndexFunc(string(n), IsNotGraphic); i > 0 {
1✔
173
                return &InvalidCharError{
×
174
                        Char:   n[i],
×
175
                        Offset: i,
×
176
                }
×
177
        }
×
178

179
        return nil
1✔
180
}
181

182
type Release struct {
183
        Name           string     `json:"name" bson:"_id"`
184
        Modified       *time.Time `json:"modified,omitempty" bson:"modified,omitempty"`
185
        Artifacts      []Image    `json:"artifacts" bson:"artifacts"`
186
        ArtifactsCount int        `json:"artifacts_count" bson:"artifacts_count"`
187
        Tags           Tags       `json:"tags" bson:"tags,omitempty"`
188
        Notes          Notes      `json:"notes" bson:"notes,omitempty"`
189
}
190

191
type ReleaseV1 struct {
192
        Name           string     `json:"Name"`
193
        Modified       *time.Time `json:"Modified,omitempty"`
194
        Artifacts      []Image    `json:"Artifacts"`
195
        ArtifactsCount int        `json:"ArtifactsCount"`
196
        Tags           Tags       `json:"tags"`
197
        Notes          Notes      `json:"notes"`
198
}
199

200
func ConvertReleasesToV1(releases []Release) []ReleaseV1 {
1✔
201
        realesesV1 := make([]ReleaseV1, len(releases))
1✔
202
        for i, release := range releases {
2✔
203
                realesesV1[i] = ReleaseV1(release)
1✔
204
        }
1✔
205
        return realesesV1
1✔
206
}
207

208
type ReleasePatch struct {
209
        Notes Notes `json:"notes" bson:"notes,omitempty"`
210
}
211

212
func (r ReleasePatch) Validate() error {
1✔
213
        return r.Notes.Validate()
1✔
214
}
1✔
215

216
type ReleaseOrImageFilter struct {
217
        Name        string   `json:"name"`
218
        Description string   `json:"description"`
219
        DeviceType  string   `json:"device_type"`
220
        Tags        []string `json:"tags"`
221
        UpdateType  string   `json:"update_type"`
222
        Page        int      `json:"page"`
223
        PerPage     int      `json:"per_page"`
224
        Sort        string   `json:"sort"`
225
}
226

227
type DirectUploadMetadata struct {
228
        Size    int64    `json:"size,omitempty" valid:"-"`
229
        Updates []Update `json:"updates" valid:"-"`
230
}
231

232
const maxDirectUploadUpdatesMetadata = 1024
233

234
func (m DirectUploadMetadata) Validate() error {
1✔
235
        if len(m.Updates) < 1 {
1✔
236
                return errors.New("empty updates update")
×
237
        }
×
238
        if len(m.Updates) > maxDirectUploadUpdatesMetadata {
1✔
239
                return errors.New("updates array too large")
×
240
        }
×
241
        for _, f := range m.Updates {
2✔
242
                err := f.Validate()
1✔
243
                if err != nil {
1✔
244
                        return err
×
245
                }
×
246
        }
247
        return nil
1✔
248
}
249

250
type ReleasesDeleteError struct {
251
        Error             string   `json:"error"`
252
        RequestID         string   `json:"request_id"`
253
        ActiveDeployments []string `json:"active_deployments"`
254
}
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