Merge lp:~stevenwilkin/snapweb/snappy-2-0 into lp:~snappy-dev/snapweb/trunk

Proposed by Steven Wilkin
Status: Merged
Approved by: Steven Wilkin
Approved revision: 191
Merged at revision: 180
Proposed branch: lp:~stevenwilkin/snapweb/snappy-2-0
Merge into: lp:~snappy-dev/snapweb/trunk
Diff against target: 1070 lines (+94/-394)
23 files modified
cmd/snappyd/handlers.go (+3/-3)
dependencies.tsv (+1/-1)
pkg/meta/snap.yaml (+1/-7)
pkg/meta/snappyd.profile (+0/-110)
pkg/meta/snappyd.seccomp (+0/-4)
pkg/snappyd (+1/-2)
snappy/common_test.go (+9/-71)
snappy/converge.go (+12/-48)
snappy/converge_test.go (+11/-53)
snappy/handlers.go (+12/-12)
snappy/handlers_test.go (+1/-1)
snappy/icon.go (+5/-5)
snappy/icon_test.go (+12/-12)
snappy/snapd_client.go (+5/-6)
statustracker/statustracker.go (+7/-11)
statustracker/statustracker_test.go (+4/-4)
www/src/css/snaplist.css (+4/-4)
www/src/js/config.js (+1/-1)
www/src/js/models/snap.js (+3/-18)
www/src/js/templates/snap-menu.hbs (+0/-5)
www/src/js/templates/snaplist-item.hbs (+1/-1)
www/src/js/templates/storelist-item.hbs (+1/-1)
www/tests/modelSpec.js (+0/-14)
To merge this branch: bzr merge lp:~stevenwilkin/snapweb/snappy-2-0
Reviewer Review Type Date Requested Status
Michael Vogt (community) Approve
Review via email: mp+292902@code.launchpad.net

Commit message

Get WebDM building against Snappy 2.0

Description of the change

Get WebDM building against Snappy 2.0.

NOTE: the resulting snap will still need to be sideloaded with `--devmode`

To post a comment you must log in.
Revision history for this message
Michael Vogt (mvo) wrote :

Looks good!

review: Approve
Revision history for this message
Steven Wilkin (stevenwilkin) :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'cmd/snappyd/handlers.go'
--- cmd/snappyd/handlers.go 2016-03-08 18:55:57 +0000
+++ cmd/snappyd/handlers.go 2016-04-26 10:36:16 +0000
@@ -53,7 +53,7 @@
53 snappyHandler := snappy.NewHandler()53 snappyHandler := snappy.NewHandler()
54 http.Handle("/api/v2/packages/", snappyHandler.MakeMuxer("/api/v2/packages"))54 http.Handle("/api/v2/packages/", snappyHandler.MakeMuxer("/api/v2/packages"))
5555
56 http.Handle("/public/", loggingHandler(http.FileServer(http.Dir("./www"))))56 http.Handle("/public/", loggingHandler(http.FileServer(http.Dir(filepath.Join(os.Getenv("SNAP"), "www")))))
5757
58 if iconDir, relativePath, err := snappy.IconDir(); err == nil {58 if iconDir, relativePath, err := snappy.IconDir(); err == nil {
59 http.Handle(fmt.Sprintf("/%s/", relativePath), loggingHandler(http.FileServer(http.Dir(filepath.Join(iconDir, "..")))))59 http.Handle(fmt.Sprintf("/%s/", relativePath), loggingHandler(http.FileServer(http.Dir(filepath.Join(iconDir, "..")))))
@@ -95,13 +95,13 @@
95}95}
9696
97func renderLayout(html string, data *page, w http.ResponseWriter) error {97func renderLayout(html string, data *page, w http.ResponseWriter) error {
98 htmlPath := filepath.Join("www", "templates", html)98 htmlPath := filepath.Join(os.Getenv("SNAP"), "www", "templates", html)
99 if _, err := os.Stat(htmlPath); err != nil {99 if _, err := os.Stat(htmlPath); err != nil {
100 http.Error(w, err.Error(), http.StatusInternalServerError)100 http.Error(w, err.Error(), http.StatusInternalServerError)
101 return err101 return err
102 }102 }
103103
104 layoutPath := filepath.Join("www", "templates", "base.html")104 layoutPath := filepath.Join(os.Getenv("SNAP"), "www", "templates", "base.html")
105 t, err := template.ParseFiles(layoutPath, htmlPath)105 t, err := template.ParseFiles(layoutPath, htmlPath)
106 if err != nil {106 if err != nil {
107 http.Error(w, err.Error(), http.StatusInternalServerError)107 http.Error(w, err.Error(), http.StatusInternalServerError)
108108
=== modified file 'dependencies.tsv'
--- dependencies.tsv 2016-02-23 16:00:47 +0000
+++ dependencies.tsv 2016-04-26 10:36:16 +0000
@@ -7,7 +7,7 @@
7github.com/miekg/dns git 5a357a6fc5e85268b929350aa6423e2d56dcc4ff 2015-04-18T05:52:30Z7github.com/miekg/dns git 5a357a6fc5e85268b929350aa6423e2d56dcc4ff 2015-04-18T05:52:30Z
8github.com/mvo5/goconfigparser git 26426272dda20cc76aa1fa44286dc743d2972fe8 2015-02-12T09:37:50Z8github.com/mvo5/goconfigparser git 26426272dda20cc76aa1fa44286dc743d2972fe8 2015-02-12T09:37:50Z
9github.com/mvo5/uboot-go git 69978a3e4b05cca9d7cfee489b3453dfed45e72c 2015-07-23T08:17:10Z9github.com/mvo5/uboot-go git 69978a3e4b05cca9d7cfee489b3453dfed45e72c 2015-07-23T08:17:10Z
10github.com/ubuntu-core/snappy git 5bcb20229bb884b85144eab0fe5db7aa05a27ebf 2016-02-23T14:04:06Z10github.com/ubuntu-core/snappy git 462812cfc390aff5bc2861320edba4cf34b740cf 2016-04-19T15:04:48Z
11golang.org/x/crypto git 60052bd85f2d91293457e8811b0cf26b773de469 2015-06-22T23:34:07Z11golang.org/x/crypto git 60052bd85f2d91293457e8811b0cf26b773de469 2015-06-22T23:34:07Z
12gopkg.in/check.v1 git 64131543e7896d5bcc6bd5a76287eb75ea96c673 2014-10-24T13:38:53Z12gopkg.in/check.v1 git 64131543e7896d5bcc6bd5a76287eb75ea96c673 2014-10-24T13:38:53Z
13gopkg.in/yaml.v2 git 49c95bdc21843256fb6c4e0d370a05f24a0bf213 2015-02-24T22:57:58Z13gopkg.in/yaml.v2 git 49c95bdc21843256fb6c4e0d370a05f24a0bf213 2015-02-24T22:57:58Z
1414
=== modified file 'pkg/meta/snap.yaml'
--- pkg/meta/snap.yaml 2016-03-06 16:59:32 +0000
+++ pkg/meta/snap.yaml 2016-04-26 10:36:16 +0000
@@ -24,10 +24,4 @@
24 daemon: simple24 daemon: simple
25 description: Snappy WebDM25 description: Snappy WebDM
26 command: snappyd26 command: snappyd
27 plugs: [snappyd]27 plugs: [network, network-bind, snapd-control]
28plugs:
29 snappyd:
30 interface: old-security
31 security-policy:
32 apparmor: meta/snappyd.profile
33 seccomp: meta/snappyd.seccomp
3428
=== removed file 'pkg/meta/snappyd.profile'
--- pkg/meta/snappyd.profile 2016-01-27 14:16:35 +0000
+++ pkg/meta/snappyd.profile 1970-01-01 00:00:00 +0000
@@ -1,110 +0,0 @@
1#include <tunables/global>
2
3###VAR###
4
5###PROFILEATTACH### (attach_disconnected) {
6 #include <abstractions/base>
7 #include <abstractions/nameservice>
8
9 # Read-only for the install directory
10 @{CLICK_DIR}/@{APP_PKGNAME}/ r,
11 @{CLICK_DIR}/@{APP_PKGNAME}/@{APP_VERSION}/ r,
12 @{CLICK_DIR}/@{APP_PKGNAME}/@{APP_VERSION}/** mrklix,
13
14 # Writable home area
15 owner @{HOMEDIRS}/snaps/@{APP_PKGNAME}/@{APP_VERSION}/ rw,
16 owner @{HOMEDIRS}/snaps/@{APP_PKGNAME}/@{APP_VERSION}/** mrwklix,
17
18 # Read-only system area for other versions
19 /var/lib/snaps/@{APP_PKGNAME}/ rw,
20 /var/lib/snaps/@{APP_PKGNAME}/** mrkix,
21
22 # Writable system area only for this version.
23 /var/lib/snaps/@{APP_PKGNAME}/@{APP_VERSION}/ w,
24 /var/lib/snaps/@{APP_PKGNAME}/@{APP_VERSION}/** wl,
25
26 # temp dirs
27 /tmp/snaps/@{APP_PKGNAME}/ r,
28 /tmp/snaps/@{APP_PKGNAME}/** rk,
29 /tmp/snaps/@{APP_PKGNAME}/@{APP_VERSION}/ rw,
30 /tmp/snaps/@{APP_PKGNAME}/@{APP_VERSION}/** mrwlkix,
31
32 # magic script
33 /bin/uname ixr,
34 /usr/bin/basename ixr,
35 /usr/bin/realpath ixr,
36 /usr/bin/dirname ixr,
37 /bin/dash ixr,
38 /bin/sed ixr,
39 /bin/mkdir ixr,
40
41 @{PROC}/sys/kernel/hostname r,
42 @{PROC}/sys/kernel/somaxconn r,
43 @{PROC}/sys/net/core/somaxconn r,
44
45 # system image
46 /etc/system-image/channel.ini r,
47 /writable/cache/system/etc/system-image/channel.ini r,
48
49 # snaps
50 /snaps/ r,
51 /snaps/** rwl,
52 /gadget/ r,
53 /gadget/** rwl,
54 /tmp/ r,
55 /tmp/** rwl,
56 /var/lib/snaps/ r,
57 /var/lib/snaps/** rwl,
58 /var/lib/snappy/ r,
59 /var/lib/snappy/** rwl,
60 /var/lib/click/hooks/ r,
61 /var/lib/click/hooks/** rwl,
62 /home/ r,
63 /home/** r,
64
65
66 # snappy unpack
67 /usr/bin/snappy uxr,
68
69 # snappy tty change
70 /dev/tty r,
71
72 # snappy requirements
73 /bin/lsblk Uxr,
74 /bin/mountpoint Uxr,
75 /bin/cp Uxr,
76 /usr/bin/debsig-verify Uxr,
77 /usr/bin/sc-filtergen Uxr,
78 /usr/bin/aa-clickhook Uxr,
79 /usr/bin/aa-profile-hook Uxr,
80
81 # snapd REST API
82 /run/snapd.socket rw,
83
84 # TODO: attention needed here
85 /etc/lsb-release r,
86 /sbin/apparmor_parser Uxr,
87 /usr/bin/unsquashfs Uxr,
88 /usr/share/apparmor/easyprof/policygroups/** r,
89 /usr/share/apparmor/easyprof/templates/** r,
90 /usr/share/seccomp/policygroups/** r,
91 /usr/share/seccomp/templates/** r,
92 /var/cache/apparmor/** w,
93
94 # snappy requirements for services
95 /etc/dbus-1/system.d/ r,
96 /etc/dbus-1/system.d/** rwl,
97 /etc/mime.types r,
98 /usr/share/click/hooks/ r,
99 /usr/share/click/hooks/** r,
100 /etc/systemd/system/ r,
101 /etc/systemd/system/** rwl,
102 /var/lib/apparmor/clicks/ r,
103 /var/lib/apparmor/clicks/** rwl,
104 /var/lib/apparmor/snappy/ r,
105 /var/lib/apparmor/snappy/** rwl,
106 /bin/systemctl Uxr,
107
108 capability net_admin,
109 capability dac_override,
110}
1110
=== removed file 'pkg/meta/snappyd.seccomp'
--- pkg/meta/snappyd.seccomp 2015-06-11 22:03:29 +0000
+++ pkg/meta/snappyd.seccomp 1970-01-01 00:00:00 +0000
@@ -1,4 +0,0 @@
1# This has to be unrestricted since snappyd will fork/exec /usr/bin/snappy for
2# various things and seccomp would apply this policy to snappy and it then
3# doesn't run well. Once there is a proper IPC service, this can be revisited.
4@unrestricted
50
=== modified file 'pkg/snappyd'
--- pkg/snappyd 2016-02-23 12:15:07 +0000
+++ pkg/snappyd 2016-04-26 10:36:16 +0000
@@ -18,8 +18,7 @@
18 ;;18 ;;
19esac19esac
2020
21mkdir -m1777 -p $SNAP_APP_TMPDIR21exec $SNAP/bin/$plat_abi/snappyd
22exec $SNAP_APP_PATH/bin/$plat_abi/snappyd
2322
24# never reach this23# never reach this
25exit 124exit 1
2625
=== modified file 'snappy/common_test.go'
--- snappy/common_test.go 2016-04-21 04:33:37 +0000
+++ snappy/common_test.go 2016-04-26 10:36:16 +0000
@@ -18,7 +18,6 @@
18package snappy18package snappy
1919
20import (20import (
21 "errors"
22 "testing"21 "testing"
2322
24 "github.com/ubuntu-core/snappy/client"23 "github.com/ubuntu-core/snappy/client"
@@ -41,7 +40,7 @@
41 Icon: "/1.0/icons/chatroom.ogra/icon",40 Icon: "/1.0/icons/chatroom.ogra/icon",
42 InstalledSize: 18976651,41 InstalledSize: 18976651,
43 Name: "chatroom",42 Name: "chatroom",
44 Origin: "ogra",43 Developer: "ogra",
45 Status: client.StatusActive,44 Status: client.StatusActive,
46 Type: client.TypeApp,45 Type: client.TypeApp,
47 Version: "0.1-8",46 Version: "0.1-8",
@@ -55,7 +54,7 @@
55 return snap54 return snap
56}55}
5756
58func (f *fakeSnapdClient) Icon(pkgID string) (*client.Icon, error) {57func (f *fakeSnapdClient) Icon(name string) (*client.Icon, error) {
59 icon := &client.Icon{58 icon := &client.Icon{
60 Filename: "icon.png",59 Filename: "icon.png",
61 Content: []byte("png"),60 Content: []byte("png"),
@@ -63,86 +62,25 @@
63 return icon, nil62 return icon, nil
64}63}
6564
66func (f *fakeSnapdClient) Services(pkg string) (map[string]*client.Service, error) {65func (f *fakeSnapdClient) Snap(name string) (*client.Snap, *client.ResultInfo, error) {
67 return nil, errors.New("the package has no services")
68}
69
70func (f *fakeSnapdClient) Snap(name string) (*client.Snap, error) {
71 if len(f.snaps) > 0 {66 if len(f.snaps) > 0 {
72 return f.snaps[0], f.err67 return f.snaps[0], nil, f.err
73 }68 }
74 return nil, f.err69 return nil, nil, f.err
75}70}
7671
77func (f *fakeSnapdClient) FilterSnaps(filter client.SnapFilter) (map[string]*client.Snap, error) {72func (f *fakeSnapdClient) FilterSnaps(filter client.SnapFilter) ([]*client.Snap, *client.ResultInfo, error) {
78 f.filter = filter // record the filter used73 f.filter = filter // record the filter used
7974
80 snaps := make(map[string]*client.Snap)75 return f.snaps, nil, f.err
81 for _, s := range f.snaps {
82 snaps[s.Name] = s
83 }
84
85 return snaps, f.err
86}76}
8777
88func (f *fakeSnapdClient) AddSnap(name string) (string, error) {78func (f *fakeSnapdClient) Install(name string, options *client.SnapOptions) (string, error) {
89 return "", nil79 return "", nil
90}80}
9181
92func (f *fakeSnapdClient) RemoveSnap(name string) (string, error) {82func (f *fakeSnapdClient) Remove(name string, options *client.SnapOptions) (string, error) {
93 return "", nil83 return "", nil
94}84}
9585
96var _ snapdClient = (*fakeSnapdClient)(nil)86var _ snapdClient = (*fakeSnapdClient)(nil)
97
98type fakeSnapdClientServicesNoExternalUI struct {
99 fakeSnapdClient
100}
101
102func (f *fakeSnapdClientServicesNoExternalUI) Services(pkg string) (map[string]*client.Service, error) {
103 internal := map[string]client.ServicePort{"ui": client.ServicePort{Port: "200/tcp"}}
104 external := map[string]client.ServicePort{"web": client.ServicePort{Port: "1024/tcp"}}
105 s1 := &client.Service{
106 Spec: client.ServiceSpec{
107 Ports: client.ServicePorts{
108 Internal: internal,
109 External: external,
110 },
111 },
112 }
113
114 s2 := &client.Service{}
115
116 services := map[string]*client.Service{
117 "s1": s1,
118 "s2": s2,
119 }
120
121 return services, nil
122}
123
124type fakeSnapdClientServicesExternalUI struct {
125 fakeSnapdClient
126}
127
128func (f *fakeSnapdClientServicesExternalUI) Services(pkg string) (map[string]*client.Service, error) {
129 s1 := &client.Service{}
130
131 internal := map[string]client.ServicePort{"ui": client.ServicePort{Port: "200/tcp"}}
132 external := map[string]client.ServicePort{"ui": client.ServicePort{Port: "1024/tcp"}}
133 s2 := &client.Service{
134 Spec: client.ServiceSpec{
135 Ports: client.ServicePorts{
136 Internal: internal,
137 External: external,
138 },
139 },
140 }
141
142 services := map[string]*client.Service{
143 "s1": s1,
144 "s2": s2,
145 }
146
147 return services, nil
148}
14987
=== modified file 'snappy/converge.go'
--- snappy/converge.go 2016-04-21 04:33:37 +0000
+++ snappy/converge.go 2016-04-26 10:36:16 +0000
@@ -19,8 +19,6 @@
1919
20import (20import (
21 "sort"21 "sort"
22 "strconv"
23 "strings"
2422
25 "log"23 "log"
2624
@@ -31,7 +29,7 @@
31type snapPkg struct {29type snapPkg struct {
32 ID string `json:"id"`30 ID string `json:"id"`
33 Name string `json:"name"`31 Name string `json:"name"`
34 Origin string `json:"origin"`32 Developer string `json:"developer"`
35 Version string `json:"version"`33 Version string `json:"version"`
36 Description string `json:"description"`34 Description string `json:"description"`
37 Icon string `json:"icon"`35 Icon string `json:"icon"`
@@ -41,7 +39,6 @@
41 InstalledSize int64 `json:"installed_size,omitempty"`39 InstalledSize int64 `json:"installed_size,omitempty"`
42 DownloadSize int64 `json:"download_size,omitempty"`40 DownloadSize int64 `json:"download_size,omitempty"`
43 Type snap.Type `json:"type,omitempty"`41 Type snap.Type `json:"type,omitempty"`
44 UIPort uint64 `json:"ui_port,omitempty"`
45}42}
4643
47type response struct {44type response struct {
@@ -50,7 +47,7 @@
50}47}
5148
52func (h *Handler) packagePayload(resource string) (snapPkg, error) {49func (h *Handler) packagePayload(resource string) (snapPkg, error) {
53 snap, err := h.snapdClient.Snap(resource)50 snap, _, err := h.snapdClient.Snap(resource)
54 if err != nil {51 if err != nil {
55 return snapPkg{}, err52 return snapPkg{}, err
56 }53 }
@@ -59,7 +56,7 @@
59}56}
6057
61func (h *Handler) allPackages(filter client.SnapFilter) ([]snapPkg, error) {58func (h *Handler) allPackages(filter client.SnapFilter) ([]snapPkg, error) {
62 snaps, err := h.snapdClient.FilterSnaps(filter)59 snaps, _, err := h.snapdClient.FilterSnaps(filter)
63 if err != nil {60 if err != nil {
64 return nil, err61 return nil, err
65 }62 }
@@ -74,56 +71,45 @@
74 return snapPkgs, nil71 return snapPkgs, nil
75}72}
7673
77func (h *Handler) removePackage(ID string) error {74func (h *Handler) removePackage(name string) error {
78 snap, err := h.snapdClient.Snap(ID)75 snap, _, err := h.snapdClient.Snap(name)
79 if err != nil {76 if err != nil {
80 return err77 return err
81 }78 }
8279
83 h.statusTracker.TrackUninstall(snap)80 h.statusTracker.TrackUninstall(snap)
8481
85 _, err = h.snapdClient.RemoveSnap(ID)82 _, err = h.snapdClient.Remove(name, nil)
86 return err83 return err
87}84}
8885
89func (h *Handler) installPackage(ID string) error {86func (h *Handler) installPackage(name string) error {
90 snap, err := h.snapdClient.Snap(ID)87 snap, _, err := h.snapdClient.Snap(name)
91 if err != nil {88 if err != nil {
92 return err89 return err
93 }90 }
9491
95 h.statusTracker.TrackInstall(snap)92 h.statusTracker.TrackInstall(snap)
9693
97 _, err = h.snapdClient.AddSnap(ID)94 _, err = h.snapdClient.Install(name, nil)
98 return err95 return err
99}96}
10097
101func hasPortInformation(snapQ *client.Snap) bool {
102 snapType := snap.Type(snapQ.Type)
103 return snapType == snap.TypeApp || snapType == snap.TypeFramework
104}
105
106func (h *Handler) snapToPayload(snapQ *client.Snap) snapPkg {98func (h *Handler) snapToPayload(snapQ *client.Snap) snapPkg {
107 snap := snapPkg{99 snap := snapPkg{
108 ID: snapQ.Name + "." + snapQ.Origin,100 ID: snapQ.Name,
109 Name: snapQ.Name,101 Name: snapQ.Name,
110 Origin: snapQ.Origin,102 Developer: snapQ.Developer,
111 Version: snapQ.Version,103 Version: snapQ.Version,
112 Description: snapQ.Description,104 Description: snapQ.Description,
113 Type: snap.Type(snapQ.Type),105 Type: snap.Type(snapQ.Type),
114 Status: h.statusTracker.Status(snapQ),106 Status: h.statusTracker.Status(snapQ),
115 }107 }
116108
117 if hasPortInformation(snapQ) {
118 if services, err := h.snapdClient.Services(snap.ID); err == nil {
119 snap.UIPort = uiAccess(services)
120 }
121 }
122
123 isInstalled := snapQ.Status == client.StatusInstalled || snapQ.Status == client.StatusActive109 isInstalled := snapQ.Status == client.StatusInstalled || snapQ.Status == client.StatusActive
124110
125 if isInstalled {111 if isInstalled {
126 iconPath, err := localIconPath(h.snapdClient, snap.ID)112 iconPath, err := localIconPath(h.snapdClient, snap.Name)
127 if err != nil {113 if err != nil {
128 log.Println("Icon path for installed package cannot be set", err)114 log.Println("Icon path for installed package cannot be set", err)
129 iconPath = ""115 iconPath = ""
@@ -138,25 +124,3 @@
138124
139 return snap125 return snap
140}126}
141
142func uiAccess(services map[string]*client.Service) uint64 {
143 for i := range services {
144 if services[i].Spec.Ports.External == nil {
145 continue
146 }
147
148 if ui, ok := services[i].Spec.Ports.External["ui"]; ok {
149 ui := strings.Split(ui.Port, "/")
150 if len(ui) == 2 {
151 port, err := strconv.ParseUint(ui[0], 0, 64)
152 if err != nil {
153 return 0
154 }
155
156 return port
157 }
158 }
159 }
160
161 return 0
162}
163127
=== modified file 'snappy/converge_test.go'
--- snappy/converge_test.go 2016-03-08 18:30:48 +0000
+++ snappy/converge_test.go 2016-04-26 10:36:16 +0000
@@ -35,7 +35,7 @@
35var _ = Suite(&PackagePayloadSuite{})35var _ = Suite(&PackagePayloadSuite{})
3636
37func (s *PackagePayloadSuite) SetUpTest(c *C) {37func (s *PackagePayloadSuite) SetUpTest(c *C) {
38 os.Setenv("SNAP_APP_DATA_PATH", c.MkDir())38 os.Setenv("SNAP_DATA", c.MkDir())
39 s.h.statusTracker = statustracker.New()39 s.h.statusTracker = statustracker.New()
40 s.c = &fakeSnapdClient{}40 s.c = &fakeSnapdClient{}
41 s.h.setClient(s.c)41 s.h.setClient(s.c)
@@ -44,23 +44,23 @@
44func (s *PackagePayloadSuite) TestPackageNotFound(c *C) {44func (s *PackagePayloadSuite) TestPackageNotFound(c *C) {
45 s.c.err = errors.New("the snap could not be retrieved")45 s.c.err = errors.New("the snap could not be retrieved")
4646
47 _, err := s.h.packagePayload("chatroom.ogra")47 _, err := s.h.packagePayload("chatroom")
48 c.Assert(err, NotNil)48 c.Assert(err, NotNil)
49}49}
5050
51func (s *PackagePayloadSuite) TestPackage(c *C) {51func (s *PackagePayloadSuite) TestPackage(c *C) {
52 s.c.snaps = []*client.Snap{newDefaultSnap()}52 s.c.snaps = []*client.Snap{newDefaultSnap()}
5353
54 pkg, err := s.h.packagePayload("chatroom.ogra")54 pkg, err := s.h.packagePayload("chatroom")
55 c.Assert(err, IsNil)55 c.Assert(err, IsNil)
56 c.Assert(pkg, DeepEquals, snapPkg{56 c.Assert(pkg, DeepEquals, snapPkg{
57 ID: "chatroom.ogra",57 ID: "chatroom",
58 Description: "WebRTC Video chat server for Snappy",58 Description: "WebRTC Video chat server for Snappy",
59 DownloadSize: 0,59 DownloadSize: 0,
60 Icon: "/icons/chatroom.ogra_icon.png",60 Icon: "/icons/chatroom_icon.png",
61 InstalledSize: 18976651,61 InstalledSize: 18976651,
62 Name: "chatroom",62 Name: "chatroom",
63 Origin: "ogra",63 Developer: "ogra",
64 Status: "installed",64 Status: "installed",
65 Type: "app",65 Type: "app",
66 Version: "0.1-8",66 Version: "0.1-8",
@@ -74,12 +74,12 @@
74var _ = Suite(&PayloadSuite{})74var _ = Suite(&PayloadSuite{})
7575
76func (s *PayloadSuite) SetUpTest(c *C) {76func (s *PayloadSuite) SetUpTest(c *C) {
77 os.Setenv("SNAP_APP_DATA_PATH", c.MkDir())77 os.Setenv("SNAP_DATA", c.MkDir())
78 s.h.statusTracker = statustracker.New()78 s.h.statusTracker = statustracker.New()
79 s.h.setClient(&fakeSnapdClient{})79 s.h.setClient(&fakeSnapdClient{})
80}80}
8181
82func (s *PayloadSuite) TestPayloadWithNoServices(c *C) {82func (s *PayloadSuite) TestPayload(c *C) {
83 fakeSnap := newDefaultSnap()83 fakeSnap := newDefaultSnap()
8484
85 q := s.h.snapToPayload(fakeSnap)85 q := s.h.snapToPayload(fakeSnap)
@@ -88,55 +88,13 @@
88 c.Check(q.Version, Equals, fakeSnap.Version)88 c.Check(q.Version, Equals, fakeSnap.Version)
89 c.Check(q.Status, Equals, statustracker.StatusInstalled)89 c.Check(q.Status, Equals, statustracker.StatusInstalled)
90 c.Check(q.Type, Equals, snap.Type(fakeSnap.Type))90 c.Check(q.Type, Equals, snap.Type(fakeSnap.Type))
91 c.Check(q.UIPort, Equals, uint64(0))91 c.Check(q.Icon, Equals, "/icons/chatroom_icon.png")
92 c.Check(q.Icon, Equals, "/icons/chatroom.ogra_icon.png")
93 c.Check(q.Description, Equals, fakeSnap.Description)92 c.Check(q.Description, Equals, fakeSnap.Description)
94}93}
9594
96func (s *PayloadSuite) TestPayloadWithServicesButNoUI(c *C) {
97 s.h.setClient(&fakeSnapdClientServicesNoExternalUI{})
98
99 fakeSnap := newDefaultSnap()
100 q := s.h.snapToPayload(fakeSnap)
101
102 c.Assert(q.Name, Equals, fakeSnap.Name)
103 c.Assert(q.Version, Equals, fakeSnap.Version)
104 c.Assert(q.Status, Equals, statustracker.StatusInstalled)
105 c.Assert(q.Type, Equals, snap.Type(fakeSnap.Type))
106 c.Assert(q.UIPort, Equals, uint64(0))
107}
108
109func (s *PayloadSuite) TestPayloadWithServicesUI(c *C) {
110 s.h.setClient(&fakeSnapdClientServicesExternalUI{})
111
112 fakeSnap := newDefaultSnap()
113 q := s.h.snapToPayload(fakeSnap)
114
115 c.Assert(q.Name, Equals, fakeSnap.Name)
116 c.Assert(q.Version, Equals, fakeSnap.Version)
117 c.Assert(q.Status, Equals, statustracker.StatusInstalled)
118 c.Assert(q.Type, Equals, snap.Type(fakeSnap.Type))
119 c.Assert(q.UIPort, Equals, uint64(1024))
120}
121
122func (s *PayloadSuite) TestPayloadTypeGadget(c *C) {
123 s.h.setClient(&fakeSnapdClientServicesExternalUI{})
124
125 fakeSnap := newDefaultSnap()
126 fakeSnap.Type = string(snap.TypeGadget)
127
128 q := s.h.snapToPayload(fakeSnap)
129
130 c.Assert(q.Name, Equals, fakeSnap.Name)
131 c.Assert(q.Version, Equals, fakeSnap.Version)
132 c.Assert(q.Status, Equals, statustracker.StatusInstalled)
133 c.Assert(q.Type, Equals, snap.Type(fakeSnap.Type))
134 c.Assert(q.UIPort, Equals, uint64(0))
135}
136
137func (s *PayloadSuite) TestPayloadSnapInstalling(c *C) {95func (s *PayloadSuite) TestPayloadSnapInstalling(c *C) {
138 fakeSnap := newDefaultSnap()96 fakeSnap := newDefaultSnap()
139 fakeSnap.Status = client.StatusNotInstalled97 fakeSnap.Status = client.StatusAvailable
140 s.h.statusTracker.TrackInstall(fakeSnap)98 s.h.statusTracker.TrackInstall(fakeSnap)
14199
142 payload := s.h.snapToPayload(fakeSnap)100 payload := s.h.snapToPayload(fakeSnap)
@@ -151,7 +109,7 @@
151var _ = Suite(&AllPackagesSuite{})109var _ = Suite(&AllPackagesSuite{})
152110
153func (s *AllPackagesSuite) SetUpTest(c *C) {111func (s *AllPackagesSuite) SetUpTest(c *C) {
154 os.Setenv("SNAP_APP_DATA_PATH", c.MkDir())112 os.Setenv("SNAP_DATA", c.MkDir())
155 s.h.statusTracker = statustracker.New()113 s.h.statusTracker = statustracker.New()
156 s.c = &fakeSnapdClient{}114 s.c = &fakeSnapdClient{}
157 s.h.setClient(s.c)115 s.h.setClient(s.c)
158116
=== modified file 'snappy/handlers.go'
--- snappy/handlers.go 2016-03-08 18:30:48 +0000
+++ snappy/handlers.go 2016-04-26 10:36:16 +0000
@@ -82,13 +82,13 @@
82 w.Header().Set("Content-Type", "application/json")82 w.Header().Set("Content-Type", "application/json")
83 // Get the Key.83 // Get the Key.
84 vars := mux.Vars(r)84 vars := mux.Vars(r)
85 resource := vars["id"]85 name := vars["name"]
86 enc := json.NewEncoder(w)86 enc := json.NewEncoder(w)
8787
88 payload, err := h.packagePayload(resource)88 payload, err := h.packagePayload(name)
89 if err != nil {89 if err != nil {
90 w.WriteHeader(http.StatusNotFound)90 w.WriteHeader(http.StatusNotFound)
91 enc.Encode(fmt.Sprintln(err, resource))91 enc.Encode(fmt.Sprintln(err, name))
92 return92 return
93 }93 }
9494
@@ -104,12 +104,12 @@
104 w.Header().Set("Content-Type", "application/json")104 w.Header().Set("Content-Type", "application/json")
105 // Get the Key.105 // Get the Key.
106 vars := mux.Vars(r)106 vars := mux.Vars(r)
107 ID := vars["id"]107 name := vars["name"]
108108
109 err := h.installPackage(ID)109 err := h.installPackage(name)
110 msg, status := respond(err)110 msg, status := respond(err)
111111
112 response := response{Message: msg, Package: ID}112 response := response{Message: msg, Package: name}
113 bs, err := json.Marshal(response)113 bs, err := json.Marshal(response)
114 if err != nil {114 if err != nil {
115 // giving up on json115 // giving up on json
@@ -127,12 +127,12 @@
127 w.Header().Set("Content-Type", "application/json")127 w.Header().Set("Content-Type", "application/json")
128 // Get the Key.128 // Get the Key.
129 vars := mux.Vars(r)129 vars := mux.Vars(r)
130 ID := vars["id"]130 name := vars["name"]
131131
132 err := h.removePackage(ID)132 err := h.removePackage(name)
133 msg, status := respond(err)133 msg, status := respond(err)
134134
135 response := response{Message: msg, Package: ID}135 response := response{Message: msg, Package: name}
136 bs, err := json.Marshal(response)136 bs, err := json.Marshal(response)
137 if err != nil {137 if err != nil {
138 // giving up on json138 // giving up on json
@@ -180,13 +180,13 @@
180 m.HandleFunc("/", h.getAll).Methods("GET")180 m.HandleFunc("/", h.getAll).Methods("GET")
181181
182 // get specific package182 // get specific package
183 m.HandleFunc("/{id}", h.get).Methods("GET")183 m.HandleFunc("/{name}", h.get).Methods("GET")
184184
185 // Add a package185 // Add a package
186 m.HandleFunc("/{id}", h.add).Methods("PUT")186 m.HandleFunc("/{name}", h.add).Methods("PUT")
187187
188 // Remove a package188 // Remove a package
189 m.HandleFunc("/{id}", h.remove).Methods("DELETE")189 m.HandleFunc("/{name}", h.remove).Methods("DELETE")
190190
191 return m191 return m
192}192}
193193
=== modified file 'snappy/handlers_test.go'
--- snappy/handlers_test.go 2016-03-08 18:30:48 +0000
+++ snappy/handlers_test.go 2016-04-26 10:36:16 +0000
@@ -35,7 +35,7 @@
35var _ = Suite(&HandlersSuite{})35var _ = Suite(&HandlersSuite{})
3636
37func (s *HandlersSuite) SetUpTest(c *C) {37func (s *HandlersSuite) SetUpTest(c *C) {
38 os.Setenv("SNAP_APP_DATA_PATH", c.MkDir())38 os.Setenv("SNAP_DATA", c.MkDir())
39 s.c = &fakeSnapdClient{}39 s.c = &fakeSnapdClient{}
40 s.h.setClient(s.c)40 s.h.setClient(s.c)
41}41}
4242
=== modified file 'snappy/icon.go'
--- snappy/icon.go 2016-01-27 14:16:35 +0000
+++ snappy/icon.go 2016-04-26 10:36:16 +0000
@@ -26,7 +26,7 @@
26)26)
2727
28var (28var (
29 // ErrDataPathNotSet indicates that SNAP_APP_DATA_PATH has not been set by the29 // ErrDataPathNotSet indicates that SNAP_DATA has not been set by the
30 // launching system.30 // launching system.
31 ErrDataPathNotSet = errors.New("package data path not set")31 ErrDataPathNotSet = errors.New("package data path not set")
32 // ErrOnIconDataPathSet indicates that there has been an error when setting up32 // ErrOnIconDataPathSet indicates that there has been an error when setting up
@@ -36,18 +36,18 @@
36 ErrIconNotExist = errors.New("the icon does not exist")36 ErrIconNotExist = errors.New("the icon does not exist")
37)37)
3838
39func localIconPath(c snapdClient, ID string) (relativePath string, err error) {39func localIconPath(c snapdClient, name string) (relativePath string, err error) {
40 dataPath, relativePath, err := IconDir()40 dataPath, relativePath, err := IconDir()
41 if err != nil {41 if err != nil {
42 return "", err42 return "", err
43 }43 }
4444
45 icon, err := c.Icon(ID)45 icon, err := c.Icon(name)
46 if err != nil {46 if err != nil {
47 return "", ErrIconNotExist47 return "", ErrIconNotExist
48 }48 }
4949
50 baseIcon := fmt.Sprintf("%s_%s", ID, icon.Filename)50 baseIcon := fmt.Sprintf("%s_%s", name, icon.Filename)
5151
52 relativePath = filepath.Join(relativePath, baseIcon)52 relativePath = filepath.Join(relativePath, baseIcon)
53 iconDstPath := filepath.Join(dataPath, baseIcon)53 iconDstPath := filepath.Join(dataPath, baseIcon)
@@ -67,7 +67,7 @@
6767
68// IconDir returns information to properly serve package icons with an http.FileServer68// IconDir returns information to properly serve package icons with an http.FileServer
69func IconDir() (dataPath, relativeBasePath string, err error) {69func IconDir() (dataPath, relativeBasePath string, err error) {
70 dataPath = os.Getenv("SNAP_APP_DATA_PATH")70 dataPath = os.Getenv("SNAP_DATA")
71 if dataPath == "" {71 if dataPath == "" {
72 return "", "", ErrDataPathNotSet72 return "", "", ErrDataPathNotSet
73 }73 }
7474
=== modified file 'snappy/icon_test.go'
--- snappy/icon_test.go 2016-01-27 14:16:35 +0000
+++ snappy/icon_test.go 2016-04-26 10:36:16 +0000
@@ -36,7 +36,7 @@
3636
37func (s *IconSuite) SetUpTest(c *C) {37func (s *IconSuite) SetUpTest(c *C) {
38 s.dataPath = c.MkDir()38 s.dataPath = c.MkDir()
39 os.Setenv("SNAP_APP_DATA_PATH", s.dataPath)39 os.Setenv("SNAP_DATA", s.dataPath)
40}40}
4141
42func (s *IconSuite) TestIconDir(c *C) {42func (s *IconSuite) TestIconDir(c *C) {
@@ -47,7 +47,7 @@
47}47}
4848
49func (s *IconSuite) TestNoSnapAppDataPathCausesError(c *C) {49func (s *IconSuite) TestNoSnapAppDataPathCausesError(c *C) {
50 os.Setenv("SNAP_APP_DATA_PATH", "")50 os.Setenv("SNAP_DATA", "")
51 _, _, err := IconDir()51 _, _, err := IconDir()
52 c.Assert(err, Equals, ErrDataPathNotSet)52 c.Assert(err, Equals, ErrDataPathNotSet)
53}53}
@@ -55,7 +55,7 @@
55func (s *IconSuite) TestIconDirCreateFails(c *C) {55func (s *IconSuite) TestIconDirCreateFails(c *C) {
56 fileAsDir := filepath.Join(s.dataPath, "badDataPath")56 fileAsDir := filepath.Join(s.dataPath, "badDataPath")
57 c.Assert(ioutil.WriteFile(fileAsDir, []byte{}, 0644), IsNil)57 c.Assert(ioutil.WriteFile(fileAsDir, []byte{}, 0644), IsNil)
58 os.Setenv("SNAP_APP_DATA_PATH", fileAsDir)58 os.Setenv("SNAP_DATA", fileAsDir)
59 _, _, err := IconDir()59 _, _, err := IconDir()
60 c.Assert(err, Equals, ErrOnIconDataPathSet)60 c.Assert(err, Equals, ErrOnIconDataPathSet)
61}61}
@@ -66,7 +66,7 @@
66 err error66 err error
67}67}
6868
69func (s *IconPathSuite) Icon(pkgID string) (*client.Icon, error) {69func (s *IconPathSuite) Icon(name string) (*client.Icon, error) {
70 icon := &client.Icon{70 icon := &client.Icon{
71 Filename: "pkgIcon.png",71 Filename: "pkgIcon.png",
72 Content: []byte("png"),72 Content: []byte("png"),
@@ -78,14 +78,14 @@
7878
79func (s *IconPathSuite) SetUpTest(c *C) {79func (s *IconPathSuite) SetUpTest(c *C) {
80 s.dataPath = c.MkDir()80 s.dataPath = c.MkDir()
81 os.Setenv("SNAP_APP_DATA_PATH", s.dataPath)81 os.Setenv("SNAP_DATA", s.dataPath)
82 s.err = nil82 s.err = nil
83}83}
8484
85func (s *IconPathSuite) TestIconCopy(c *C) {85func (s *IconPathSuite) TestIconCopy(c *C) {
86 relativePath, err := localIconPath(s, "mypackage.sergiusens")86 relativePath, err := localIconPath(s, "mypackage")
87 c.Assert(err, IsNil)87 c.Assert(err, IsNil)
88 iconBaseName := "icons/mypackage.sergiusens_pkgIcon.png"88 iconBaseName := "icons/mypackage_pkgIcon.png"
89 c.Check(relativePath, Equals, filepath.Join("/", iconBaseName))89 c.Check(relativePath, Equals, filepath.Join("/", iconBaseName))
9090
91 contents, err := ioutil.ReadFile(filepath.Join(s.dataPath, iconBaseName))91 contents, err := ioutil.ReadFile(filepath.Join(s.dataPath, iconBaseName))
@@ -95,23 +95,23 @@
95}95}
9696
97func (s *IconPathSuite) TestIconCopyNoDataPath(c *C) {97func (s *IconPathSuite) TestIconCopyNoDataPath(c *C) {
98 os.Setenv("SNAP_APP_DATA_PATH", "")98 os.Setenv("SNAP_DATA", "")
99 _, err := localIconPath(s, "mypackage.sergiusens")99 _, err := localIconPath(s, "mypackage")
100 c.Assert(err, Equals, ErrDataPathNotSet)100 c.Assert(err, Equals, ErrDataPathNotSet)
101}101}
102102
103func (s *IconPathSuite) TestIconCopyNoIcon(c *C) {103func (s *IconPathSuite) TestIconCopyNoIcon(c *C) {
104 s.err = errors.New("Not Found")104 s.err = errors.New("Not Found")
105 _, err := localIconPath(s, "mypackage.sergiusens")105 _, err := localIconPath(s, "mypackage")
106 c.Assert(err, Equals, ErrIconNotExist)106 c.Assert(err, Equals, ErrIconNotExist)
107}107}
108108
109func (s *IconPathSuite) TestIconCopyTargetIconExists(c *C) {109func (s *IconPathSuite) TestIconCopyTargetIconExists(c *C) {
110 iconBaseName := "icons/mypackage.sergiusens_pkgIcon.png"110 iconBaseName := "icons/mypackage_pkgIcon.png"
111 c.Assert(os.MkdirAll(filepath.Join(s.dataPath, "icons"), 0755), IsNil)111 c.Assert(os.MkdirAll(filepath.Join(s.dataPath, "icons"), 0755), IsNil)
112 c.Assert(ioutil.WriteFile(filepath.Join(s.dataPath, iconBaseName), []byte{}, 0644), IsNil)112 c.Assert(ioutil.WriteFile(filepath.Join(s.dataPath, iconBaseName), []byte{}, 0644), IsNil)
113113
114 relativePath, err := localIconPath(s, "mypackage.sergiusens")114 relativePath, err := localIconPath(s, "mypackage")
115 c.Assert(err, IsNil)115 c.Assert(err, IsNil)
116 c.Check(relativePath, Equals, filepath.Join("/", iconBaseName))116 c.Check(relativePath, Equals, filepath.Join("/", iconBaseName))
117}117}
118118
=== modified file 'snappy/snapd_client.go'
--- snappy/snapd_client.go 2016-04-21 04:33:37 +0000
+++ snappy/snapd_client.go 2016-04-26 10:36:16 +0000
@@ -22,10 +22,9 @@
22)22)
2323
24type snapdClient interface {24type snapdClient interface {
25 Icon(pkgID string) (*client.Icon, error)25 Icon(name string) (*client.Icon, error)
26 Services(pkg string) (map[string]*client.Service, error)26 Snap(name string) (*client.Snap, *client.ResultInfo, error)
27 Snap(name string) (*client.Snap, error)27 FilterSnaps(filter client.SnapFilter) ([]*client.Snap, *client.ResultInfo, error)
28 FilterSnaps(filter client.SnapFilter) (map[string]*client.Snap, error)28 Install(name string, options *client.SnapOptions) (string, error)
29 AddSnap(name string) (string, error)29 Remove(name string, options *client.SnapOptions) (string, error)
30 RemoveSnap(name string) (string, error)
31}30}
3231
=== modified file 'statustracker/statustracker.go'
--- statustracker/statustracker.go 2016-03-08 18:30:49 +0000
+++ statustracker/statustracker.go 2016-04-26 10:36:16 +0000
@@ -62,13 +62,13 @@
62 s.Lock()62 s.Lock()
63 defer s.Unlock()63 defer s.Unlock()
6464
65 status, ok := s.statuses[snapID(snap)]65 status, ok := s.statuses[snap.Name]
66 if !ok {66 if !ok {
67 return translateStatus(snap)67 return translateStatus(snap)
68 }68 }
6969
70 if hasCompleted(status, snap) {70 if hasCompleted(status, snap) {
71 delete(s.statuses, snapID(snap))71 delete(s.statuses, snap.Name)
72 return translateStatus(snap)72 return translateStatus(snap)
73 }73 }
7474
@@ -81,19 +81,19 @@
81 return81 return
82 }82 }
8383
84 s.trackOperation(snapID(snap), StatusInstalling)84 s.trackOperation(snap.Name, StatusInstalling)
85}85}
8686
87func (s *StatusTracker) trackOperation(id, operation string) {87func (s *StatusTracker) trackOperation(name, operation string) {
88 s.Lock()88 s.Lock()
89 defer s.Unlock()89 defer s.Unlock()
9090
91 s.statuses[id] = operation91 s.statuses[name] = operation
9292
93 go func() {93 go func() {
94 <-time.After(trackerDuration)94 <-time.After(trackerDuration)
95 s.Lock()95 s.Lock()
96 delete(s.statuses, id)96 delete(s.statuses, name)
97 s.Unlock()97 s.Unlock()
98 }()98 }()
99}99}
@@ -104,11 +104,7 @@
104 return104 return
105 }105 }
106106
107 s.trackOperation(snapID(snap), StatusUninstalling)107 s.trackOperation(snap.Name, StatusUninstalling)
108}
109
110func snapID(s *client.Snap) string {
111 return s.Name + "." + s.Origin
112}108}
113109
114func isInstalled(s *client.Snap) bool {110func isInstalled(s *client.Snap) bool {
115111
=== modified file 'statustracker/statustracker_test.go'
--- statustracker/statustracker_test.go 2016-04-21 06:03:28 +0000
+++ statustracker/statustracker_test.go 2016-04-26 10:36:16 +0000
@@ -45,7 +45,7 @@
45 }{45 }{
46 {client.StatusInstalled, StatusInstalled},46 {client.StatusInstalled, StatusInstalled},
47 {client.StatusActive, StatusInstalled},47 {client.StatusActive, StatusInstalled},
48 {client.StatusNotInstalled, StatusUninstalled},48 {client.StatusAvailable, StatusUninstalled},
49 {client.StatusRemoved, StatusUninstalled},49 {client.StatusRemoved, StatusUninstalled},
50 }50 }
5151
@@ -85,7 +85,7 @@
85}85}
8686
87func (s *StatusTrackerSuite) TestTrackInstall(c *C) {87func (s *StatusTrackerSuite) TestTrackInstall(c *C) {
88 snap := &client.Snap{Status: client.StatusNotInstalled}88 snap := &client.Snap{Status: client.StatusAvailable}
89 s.t.TrackInstall(snap)89 s.t.TrackInstall(snap)
90 c.Assert(s.t.Status(snap), Equals, StatusInstalling)90 c.Assert(s.t.Status(snap), Equals, StatusInstalling)
91 // installation completes91 // installation completes
@@ -96,7 +96,7 @@
96func (s *StatusTrackerSuite) TestTrackInstallExpiry(c *C) {96func (s *StatusTrackerSuite) TestTrackInstallExpiry(c *C) {
97 trackerDuration = 200 * time.Millisecond97 trackerDuration = 200 * time.Millisecond
9898
99 snap := &client.Snap{Status: client.StatusNotInstalled}99 snap := &client.Snap{Status: client.StatusAvailable}
100 s.t.TrackInstall(snap)100 s.t.TrackInstall(snap)
101 c.Assert(s.t.Status(snap), Equals, StatusInstalling)101 c.Assert(s.t.Status(snap), Equals, StatusInstalling)
102102
@@ -106,7 +106,7 @@
106}106}
107107
108func (s *StatusTrackerSuite) TestTrackUninstallNotInstalled(c *C) {108func (s *StatusTrackerSuite) TestTrackUninstallNotInstalled(c *C) {
109 snap := &client.Snap{Status: client.StatusNotInstalled}109 snap := &client.Snap{Status: client.StatusAvailable}
110 s.t.TrackUninstall(snap)110 s.t.TrackUninstall(snap)
111 c.Assert(s.t.Status(snap), Equals, StatusUninstalled)111 c.Assert(s.t.Status(snap), Equals, StatusUninstalled)
112}112}
113113
=== modified file 'www/src/css/snaplist.css'
--- www/src/css/snaplist.css 2015-12-11 15:07:16 +0000
+++ www/src/css/snaplist.css 2016-04-26 10:36:16 +0000
@@ -62,7 +62,7 @@
6262
63.b-snaplist_grid .b-snaplist__version,63.b-snaplist_grid .b-snaplist__version,
64.b-snaplist_grid .b-snaplist__type,64.b-snaplist_grid .b-snaplist__type,
65.b-snaplist_grid .b-snaplist__origin,65.b-snaplist_grid .b-snaplist__developer,
66.b-snaplist_grid .b-snaplist__actions {66.b-snaplist_grid .b-snaplist__actions {
67 display:none;67 display:none;
68}68}
@@ -114,7 +114,7 @@
114114
115.b-snaplist_row .b-snaplist__name,115.b-snaplist_row .b-snaplist__name,
116.b-snaplist_row .b-snaplist__version,116.b-snaplist_row .b-snaplist__version,
117.b-snaplist_row .b-snaplist__origin,117.b-snaplist_row .b-snaplist__developer,
118.b-snaplist_row .b-snaplist__size {118.b-snaplist_row .b-snaplist__size {
119 white-space: nowrap;119 white-space: nowrap;
120 width: 100%;120 width: 100%;
@@ -142,8 +142,8 @@
142 display:none;142 display:none;
143}143}
144144
145.b-snaplist_row .b-snaplist__origin145.b-snaplist_row .b-snaplist__developer
146.b-snaplist_row .b-snaplist__origin {146.b-snaplist_row .b-snaplist__developer {
147 text-transform: capitalize;147 text-transform: capitalize;
148}148}
149149
150150
=== modified file 'www/src/js/config.js'
--- www/src/js/config.js 2016-01-27 14:16:35 +0000
+++ www/src/js/config.js 2016-04-26 10:36:16 +0000
@@ -7,7 +7,7 @@
7 ],7 ],
8 NON_INSTALLABLE_IDS: [8 NON_INSTALLABLE_IDS: [
9 'webdm',9 'webdm',
10 'ubuntu-core.ubuntu'10 'ubuntu-core'
11 ],11 ],
12 NON_INSTALLABLE_TYPES: [12 NON_INSTALLABLE_TYPES: [
13 'gadget'13 'gadget'
1414
=== modified file 'www/src/js/models/snap.js'
--- www/src/js/models/snap.js 2015-06-03 11:45:59 +0000
+++ www/src/js/models/snap.js 2016-04-26 10:36:16 +0000
@@ -166,8 +166,8 @@
166 response.icon = this.defaults.icon;166 response.icon = this.defaults.icon;
167 }167 }
168168
169 if (response.hasOwnProperty('origin') && !response.origin.length) {169 if (response.hasOwnProperty('developer') && !response.developer.length) {
170 response.origin = this.defaults.origin;170 response.developer = this.defaults.developer;
171 }171 }
172172
173 if (type) {173 if (type) {
@@ -200,28 +200,13 @@
200 );200 );
201 }201 }
202202
203 if (response.hasOwnProperty('ui_port')) {
204 //jscs:disable requireCamelCaseOrUpperCaseIdentifiers
205 var port = response.ui_port;
206 //jscs:enable requireCamelCaseOrUpperCaseIdentifiers
207
208 if (_.isFinite(port) && port > 0) {
209
210 this.set('vendorGuiHref', window.location.protocol + '//' +
211 window.location.hostname + ':' + port + '/'
212 );
213 } else {
214 this.unset('vendorGuiHref');
215 }
216 }
217
218 return response;203 return response;
219 },204 },
220205
221 defaults: {206 defaults: {
222 icon: '/public/images/default-package-icon.svg',207 icon: '/public/images/default-package-icon.svg',
223 installActionString: false,208 installActionString: false,
224 origin: '-',209 developer: '-',
225 isInstallable: true210 isInstallable: true
226 }211 }
227212
228213
=== modified file 'www/src/js/templates/snap-menu.hbs'
--- www/src/js/templates/snap-menu.hbs 2015-06-03 11:33:11 +0000
+++ www/src/js/templates/snap-menu.hbs 2016-04-26 10:36:16 +0000
@@ -8,9 +8,4 @@
8 <a class="b-snap__nav-item" href="settings">8 <a class="b-snap__nav-item" href="settings">
9 Settings9 Settings
10 </a>10 </a>
11 {{#if vendorGuiHref}}
12 <a class="b-snap__nav-item" href="{{vendorGuiHref}}" target="_blank">
13 Open / Manage
14 </a>
15 {{/if}}
16</div>11</div>
1712
=== modified file 'www/src/js/templates/snaplist-item.hbs'
--- www/src/js/templates/snaplist-item.hbs 2015-12-11 15:07:16 +0000
+++ www/src/js/templates/snaplist-item.hbs 2016-04-26 10:36:16 +0000
@@ -6,7 +6,7 @@
6 <div class="b-snaplist__version">{{ version }}</div>6 <div class="b-snaplist__version">{{ version }}</div>
7</div>7</div>
8<div class="b-snaplist__src">8<div class="b-snaplist__src">
9 <div class="b-snaplist__origin">{{ origin }}</div>9 <div class="b-snaplist__developer">{{ developer }}</div>
10</div>10</div>
11<div class="b-snaplist__size" title="Installed file size">{{ prettyInstalledSize }}</div>11<div class="b-snaplist__size" title="Installed file size">{{ prettyInstalledSize }}</div>
12<div class="b-snaplist__actions">12<div class="b-snaplist__actions">
1313
=== modified file 'www/src/js/templates/storelist-item.hbs'
--- www/src/js/templates/storelist-item.hbs 2015-12-11 15:07:16 +0000
+++ www/src/js/templates/storelist-item.hbs 2016-04-26 10:36:16 +0000
@@ -6,7 +6,7 @@
6 <div class="b-snaplist__version">{{ version }}</div>6 <div class="b-snaplist__version">{{ version }}</div>
7</div>7</div>
8<div class="b-snaplist__src">8<div class="b-snaplist__src">
9 <div class="b-snaplist__origin">{{ origin }}</div>9 <div class="b-snaplist__developer">{{ developer }}</div>
10</div>10</div>
11<div class="b-snaplist__actions">11<div class="b-snaplist__actions">
12 {{> installer}}12 {{> installer}}
1313
=== modified file 'www/tests/modelSpec.js'
--- www/tests/modelSpec.js 2015-06-03 11:45:59 +0000
+++ www/tests/modelSpec.js 2016-04-26 10:36:16 +0000
@@ -88,20 +88,6 @@
88 expect(this.model.get('prettyDownloadSize')).toBe('0 B');88 expect(this.model.get('prettyDownloadSize')).toBe('0 B');
89 });89 });
9090
91 it('should parse response to create vendorGuiHref', function() {
92 this.model.parse({'ui_port': 8080});
93 expect(this.model.get('vendorGuiHref')).toBe('http://localhost:8080/');
94 });
95
96 it('should not set vendorGuiHref if not a finite number', function() {
97 this.model.parse({'ui_port': NaN});
98 expect(this.model.get('vendorGuiHref')).not.toBeDefined();
99 this.model.parse({'ui_port': ''});
100 expect(this.model.get('vendorGuiHref')).not.toBeDefined();
101 this.model.parse({'ui_port': -9});
102 expect(this.model.get('vendorGuiHref')).not.toBeDefined();
103 });
104
105 });91 });
10692
107 describe('sync methods', function() {93 describe('sync methods', function() {

Subscribers

People subscribed via source and target branches