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

mendersoftware / deployments / 1022633108

02 Oct 2023 08:56AM UTC coverage: 80.458% (-0.03%) from 80.483%
1022633108

Pull #931

gitlab-ci

merlin-northern
feat: direct upload with skip verify: set metadata on complete

Changelog: Title
Ticket: MEN-6696
Signed-off-by: Peter Grzybowski <peter@northern.tech>
Pull Request #931: feat: direct upload with skip verify: set metadata on complete

21 of 76 new or added lines in 4 files covered. (27.63%)

84 existing lines in 1 file now uncovered.

7835 of 9738 relevant lines covered (80.46%)

34.99 hits per line

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

0.0
/model/update.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
        "errors"
19
        "time"
20
)
21

22
// Type info structure
23
type ArtifactUpdateTypeInfo struct {
24
        Type *string `json:"type" valid:"required"`
25
}
26

27
// Update file structure
28
type UpdateFile struct {
29
        // Image name
30
        Name string `json:"name" valid:"required"`
31

32
        // Image file checksum
33
        Checksum string `json:"checksum" valid:"optional"`
34

35
        // Image size
36
        Size int64 `json:"size" valid:"optional"`
37

38
        // Date build
39
        Date *time.Time `json:"date" valid:"optional"`
40
}
41

42
// Update structure
43
type Update struct {
44
        TypeInfo ArtifactUpdateTypeInfo `json:"type_info" valid:"required"`
45
        Files    []UpdateFile           `json:"files"`
46
        MetaData interface{}            `json:"meta_data,omitempty" valid:"optional"`
47
}
48

NEW
49
func (u Update) Match(update Update) bool {
×
NEW
50
        if len(u.Files) != len(update.Files) {
×
NEW
51
                return false
×
NEW
52
        }
×
53

NEW
54
        lFiles := make(map[string]UpdateFile, len(u.Files))
×
NEW
55
        for i, f := range u.Files {
×
NEW
56
                lFiles[f.Name] = u.Files[i]
×
NEW
57
        }
×
NEW
58
        for _, f := range update.Files {
×
NEW
59
                if _, ok := lFiles[f.Name]; !ok {
×
NEW
60
                        return false
×
NEW
61
                }
×
62
        }
NEW
63
        return true
×
64
}
65

66
const maxUpdateFiles = 1024
67

NEW
68
func (u Update) Validate() error {
×
NEW
69
        if len(u.Files) > maxUpdateFiles {
×
NEW
70
                return errors.New("too large update files array")
×
NEW
71
        }
×
72

NEW
73
        return nil
×
74
}
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