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

mendersoftware / iot-manager / 1401702106

05 Aug 2024 08:32PM UTC coverage: 87.577%. Remained the same
1401702106

push

gitlab-ci

web-flow
Merge pull request #295 from mendersoftware/dependabot/docker/docker-dependencies-03b04ac819

chore: bump golang from 1.22.4-alpine3.19 to 1.22.5-alpine3.19 in the docker-dependencies group

3264 of 3727 relevant lines covered (87.58%)

11.44 hits per line

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

69.23
/client/iotcore/model.go
1
// Copyright 2022 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 iotcore
16

17
import (
18
        "bytes"
19

20
        validation "github.com/go-ozzo/ozzo-validation/v4"
21

22
        "github.com/mendersoftware/iot-manager/model"
23
)
24

25
type Device struct {
26
        ID            string  `json:"id"`
27
        Name          string  `json:"name"`
28
        Version       int64   `json:"version,omitempty"`
29
        Status        Status  `json:"status,omitempty"`
30
        CertificateID string  `json:"certificate_id,omitempty"`
31
        Certificate   string  `json:"certificate,omitempty"`
32
        PrivateKey    string  `json:"private_key,omitempty"`
33
        Endpoint      *string `json:"endpoint,omitempty"`
34
}
35

36
type Status string
37

38
const (
39
        StatusEnabled  Status = "enabled"
40
        StatusDisabled Status = "disabled"
41
)
42

43
func NewStatusFromMenderStatus(status model.Status) Status {
33✔
44
        switch status {
33✔
45
        case model.StatusAccepted, model.StatusPreauthorized:
18✔
46
                return StatusEnabled
18✔
47
        default:
15✔
48
                return StatusDisabled
15✔
49
        }
50
}
51

52
func (s *Status) UnmarshalText(b []byte) error {
×
53
        *s = Status(bytes.ToLower(b))
×
54
        return s.Validate()
×
55
}
×
56

57
var validateStatus = validation.In(
58
        StatusEnabled,
59
        StatusDisabled,
60
)
61

62
func (s Status) Validate() error {
4✔
63
        return validateStatus.Validate(s)
4✔
64
}
4✔
65

66
type DeviceShadow struct {
67
        Payload model.DeviceState `json:"state"`
68
}
69

70
type DesiredState struct {
71
        Desired map[string]interface{} `json:"desired"`
72
}
73

74
type DeviceShadowUpdate struct {
75
        State DesiredState `json:"state"`
76
}
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