Merge lp:~mariogrip/goget-ubuntu-touch/device-alias into lp:goget-ubuntu-touch

Proposed by Marius Gripsgard 
Status: Work in progress
Proposed branch: lp:~mariogrip/goget-ubuntu-touch/device-alias
Merge into: lp:goget-ubuntu-touch
Diff against target: 52 lines (+18/-0)
3 files modified
ubuntu-device-flash/touch.go (+6/-0)
ubuntuimage/channels.go (+7/-0)
ubuntuimage/types.go (+5/-0)
To merge this branch: bzr merge lp:~mariogrip/goget-ubuntu-touch/device-alias
Reviewer Review Type Date Requested Status
Ubuntu Phablet Team Pending
Review via email: mp+284162@code.launchpad.net

Description of the change

Support for device aliases

To post a comment you must log in.

Unmerged revisions

221. By Marius Gripsgard 

Add support for device alias

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ubuntu-device-flash/touch.go'
2--- ubuntu-device-flash/touch.go 2015-02-10 05:51:08 +0000
3+++ ubuntu-device-flash/touch.go 2016-01-27 17:18:34 +0000
4@@ -120,6 +120,12 @@
5 if err := touchCmd.setupDevice(); err != nil {
6 return err
7 }
8+
9+ if hasDeviceAlias, deviceAlias := channels.HasDeviceAlias(globalArgs.Server, touchCmd.Channel, touchCmd.Device); hasDeviceAlias {
10+ log.Printf("|%s| is an alias for |%s|", touchCmd.Device, deviceAlias);
11+ touchCmd.Device = deviceAlias
12+ }
13+
14 log.Printf("Device is |%s|", touchCmd.Device)
15
16 deviceChannel, err := channels.GetDeviceChannel(globalArgs.Server, touchCmd.Channel, touchCmd.Device)
17
18=== modified file 'ubuntuimage/channels.go'
19--- ubuntuimage/channels.go 2015-04-16 22:59:18 +0000
20+++ ubuntuimage/channels.go 2016-01-27 17:18:34 +0000
21@@ -59,6 +59,13 @@
22 return channels, nil
23 }
24
25+func (channels Channels) HasDeviceAlias(server, channel, device string) (bool, string) {
26+ if _, found := channels[channel].DevicesAlias[device]; found {
27+ return true, channels[channel].DevicesAlias[device].Device;
28+ }
29+ return false, "";
30+}
31+
32 func (channels Channels) GetDeviceChannel(server, channel, device string) (deviceChannel DeviceChannel, err error) {
33 if _, found := channels[channel]; !found {
34 return deviceChannel, fmt.Errorf("Channel %s not found on server %s", channel, server)
35
36=== modified file 'ubuntuimage/types.go'
37--- ubuntuimage/types.go 2014-11-19 15:54:36 +0000
38+++ ubuntuimage/types.go 2016-01-27 17:18:34 +0000
39@@ -23,8 +23,13 @@
40 Index string
41 }
42
43+type DeviceAlias struct {
44+ Device string
45+}
46+
47 type Channel struct {
48 Devices map[string]Device `json:"devices"`
49+ DevicesAlias map[string]DeviceAlias `json:"deviceAlias"`
50 Alias string `json:"alias"`
51 Hidden bool `json:"hidden,omitempty"`
52 }

Subscribers

People subscribed via source and target branches