37
40
// xxx channel_target missing
39
42
VersionDetail map[string]string
42
46
// A SystemImage exposes the a subset of system-image service.
43
47
type SystemImage interface {
44
Info() (*InfoResult, error)
48
Information() (*InfoResult, error)
47
51
type systemImage struct {
57
61
var _ SystemImage = &systemImage{} // ensures it conforms
59
func (si *systemImage) Info() (*InfoResult, error) {
60
si.log.Debugf("invoking Info")
62
err := si.endp.Call("Info", bus.Args(), &res.BuildNumber, &res.Device, &res.Channel, &res.LastUpdate, &res.VersionDetail)
63
func (si *systemImage) Information() (*InfoResult, error) {
64
si.log.Debugf("invoking Information")
65
m := map[string]string{}
66
err := si.endp.Call("Information", bus.Args(), &m)
64
si.log.Errorf("Info failed: %v", err)
69
si.log.Errorf("Information failed: %v", err)
75
// Try parsing the build number if it exist.
76
if bn := m["current_build_number"]; len(bn) > 0 {
77
bn, err := strconv.ParseInt(bn, 10, 32)
79
res.BuildNumber = int32(bn)
85
res.Device = m["device_name"]
86
res.Channel = m["channel_name"]
87
res.LastUpdate = m["last_update_date"]
88
res.VersionDetail = map[string]string{}
90
// Split version detail key=value,key2=value2 into a string map
92
vals := strings.Split(m["version_detail"], ",")
93
for _, val := range vals {
94
pairs := strings.Split(val, "=")
98
res.VersionDetail[pairs[0]] = pairs[1]