forked from lf-edge/eve
-
Notifications
You must be signed in to change notification settings - Fork 1
/
onboardingtypes.go
59 lines (49 loc) · 1.61 KB
/
onboardingtypes.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Copyright (c) 2017 Zededa, Inc.
// SPDX-License-Identifier: Apache-2.0
package types
import (
"github.com/google/go-cmp/cmp"
"github.com/lf-edge/eve/pkg/pillar/base"
uuid "github.com/satori/go.uuid"
)
// OnboardingStatus - UUID, etc. advertised by client process
type OnboardingStatus struct {
DeviceUUID uuid.UUID
HardwareModel string // From controller
}
// Key returns the key for pubsub
func (status OnboardingStatus) Key() string {
return "global"
}
// LogCreate :
func (status OnboardingStatus) LogCreate(logBase *base.LogObject) {
logObject := base.NewLogObject(logBase, base.OnboardingStatusLogType, "",
nilUUID, status.LogKey())
if logObject == nil {
return
}
logObject.Noticef("Onboarding status create")
}
// LogModify :
func (status OnboardingStatus) LogModify(logBase *base.LogObject, old interface{}) {
logObject := base.EnsureLogObject(logBase, base.OnboardingStatusLogType, "",
nilUUID, status.LogKey())
oldStatus, ok := old.(OnboardingStatus)
if !ok {
logObject.Clone().Fatalf("LogModify: Old object interface passed is not of OnboardingStatus type")
}
// XXX remove?
logObject.CloneAndAddField("diff", cmp.Diff(oldStatus, status)).
Noticef("Onboarding status modify")
}
// LogDelete :
func (status OnboardingStatus) LogDelete(logBase *base.LogObject) {
logObject := base.EnsureLogObject(logBase, base.OnboardingStatusLogType, "",
nilUUID, status.LogKey())
logObject.Noticef("Onboarding status delete")
base.DeleteLogObject(logBase, status.LogKey())
}
// LogKey :
func (status OnboardingStatus) LogKey() string {
return string(base.OnboardingStatusLogType) + "-" + status.Key()
}