Merge lp:~chipaca/snappy/systemimage-exported-consts into lp:~snappy-dev/snappy/snappy-moved-to-github

Proposed by John Lenton on 2015-10-05
Status: Merged
Approved by: John Lenton on 2015-10-07
Approved revision: 741
Merged at revision: 742
Proposed branch: lp:~chipaca/snappy/systemimage-exported-consts
Merge into: lp:~snappy-dev/snappy/snappy-moved-to-github
Diff against target: 147 lines (+30/-20)
2 files modified
snappy/systemimage.go (+25/-15)
snappy/systemimage_test.go (+5/-5)
To merge this branch: bzr merge lp:~chipaca/snappy/systemimage-exported-consts
Reviewer Review Type Date Requested Status
Leo Arias 2015-10-05 Approve on 2015-10-07
Review via email: mp+273479@code.launchpad.net

Commit Message

Export systemimage's constants (name, origin, and vendor).

To post a comment you must log in.
Leo Arias (elopio) wrote :

seems ok to me. I just don't understand why now All returns also the updates. There is no mention about it in the commit message, the function comment is not updated and there is no test for that change.

review: Needs Fixing
John Lenton (chipaca) wrote :

Ah! good catch. Need to reverse that change.

741. By John Lenton on 2015-10-07

Reverted unneeded change to SysImgRepo's All() method

Leo Arias (elopio) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'snappy/systemimage.go'
2--- snappy/systemimage.go 2015-10-05 19:12:55 +0000
3+++ snappy/systemimage.go 2015-10-07 15:55:08 +0000
4@@ -39,11 +39,16 @@
5 "launchpad.net/snappy/provisioning"
6 )
7
8+// SystemImagePart have constant name, origin, and vendor.
9 const (
10- systemImagePartName = "ubuntu-core"
11- systemImagePartOrigin = "ubuntu"
12- systemImagePartVendor = "Canonical Ltd."
13+ SystemImagePartName = "ubuntu-core"
14+ // SystemImagePartOrigin is the origin of any system image part
15+ SystemImagePartOrigin = "ubuntu"
16+ // SystemImagePartVendor is the vendor of any system image part
17+ SystemImagePartVendor = "Canonical Ltd."
18+)
19
20+const (
21 // location of the channel config on the filesystem.
22 //
23 // This file specifies the s-i version installed on the rootfs
24@@ -97,17 +102,17 @@
25
26 // Name returns the name
27 func (s *SystemImagePart) Name() string {
28- return systemImagePartName
29+ return SystemImagePartName
30 }
31
32 // Origin returns the origin ("ubuntu")
33 func (s *SystemImagePart) Origin() string {
34- return systemImagePartOrigin
35+ return SystemImagePartOrigin
36 }
37
38 // Vendor returns the vendor ("Canonical Ltd.")
39 func (s *SystemImagePart) Vendor() string {
40- return systemImagePartVendor
41+ return SystemImagePartVendor
42 }
43
44 // Version returns the version
45@@ -248,7 +253,7 @@
46 if err = s.partition.ToggleNextBoot(); err != nil {
47 return "", err
48 }
49- return systemImagePartName, nil
50+ return SystemImagePartName, nil
51 }
52
53 // Ensure the expected version update was applied to the expected partition.
54@@ -440,7 +445,7 @@
55
56 // Search searches the SystemImageRepository for the given terms
57 func (s *SystemImageRepository) Search(terms string) (versions []Part, err error) {
58- if strings.Contains(terms, systemImagePartName) {
59+ if strings.Contains(terms, SystemImagePartName) {
60 part := makeCurrentPart(s.partition)
61 versions = append(versions, part)
62 }
63@@ -449,7 +454,7 @@
64
65 // Details returns details for the given snap
66 func (s *SystemImageRepository) Details(name string, origin string) ([]Part, error) {
67- if name == systemImagePartName && origin == systemImagePartOrigin {
68+ if name == SystemImagePartName && origin == SystemImagePartOrigin {
69 return []Part{makeCurrentPart(s.partition)}, nil
70 }
71
72@@ -457,28 +462,33 @@
73 }
74
75 // Updates returns the available updates
76-func (s *SystemImageRepository) Updates() (parts []Part, err error) {
77+func (s *SystemImageRepository) Updates() ([]Part, error) {
78 configFile := filepath.Join(systemImageRoot, systemImageChannelConfig)
79 updateStatus, err := systemImageClientCheckForUpdates(configFile)
80+ if err != nil {
81+ return nil, err
82+ }
83
84 current := makeCurrentPart(s.partition)
85 // no VersionCompare here because the channel provides a "order" and
86 // that may go backwards when switching channels(?)
87 if current.Version() != updateStatus.targetVersion {
88- parts = append(parts, &SystemImagePart{
89+ return []Part{&SystemImagePart{
90 version: updateStatus.targetVersion,
91 versionDetails: updateStatus.targetVersionDetails,
92 lastUpdate: updateStatus.lastUpdate,
93 updateSize: updateStatus.updateSize,
94 channelName: current.(*SystemImagePart).channelName,
95- partition: s.partition})
96+ partition: s.partition}}, nil
97 }
98
99- return parts, err
100+ return nil, nil
101 }
102
103 // Installed returns the installed snaps from this repository
104-func (s *SystemImageRepository) Installed() (parts []Part, err error) {
105+func (s *SystemImageRepository) Installed() ([]Part, error) {
106+ var parts []Part
107+
108 // current partition
109 curr := makeCurrentPart(s.partition)
110 if curr != nil {
111@@ -491,7 +501,7 @@
112 parts = append(parts, other)
113 }
114
115- return parts, err
116+ return parts, nil
117 }
118
119 // All installed parts. SystemImageParts are non-removable.
120
121=== modified file 'snappy/systemimage_test.go'
122--- snappy/systemimage_test.go 2015-09-29 09:45:15 +0000
123+++ snappy/systemimage_test.go 2015-10-07 15:55:08 +0000
124@@ -115,9 +115,9 @@
125 c.Assert(err, IsNil)
126 // we have one active and one inactive
127 c.Assert(parts, HasLen, 2)
128- c.Assert(parts[0].Name(), Equals, systemImagePartName)
129- c.Assert(parts[0].Origin(), Equals, systemImagePartOrigin)
130- c.Assert(parts[0].Vendor(), Equals, systemImagePartVendor)
131+ c.Assert(parts[0].Name(), Equals, SystemImagePartName)
132+ c.Assert(parts[0].Origin(), Equals, SystemImagePartOrigin)
133+ c.Assert(parts[0].Vendor(), Equals, SystemImagePartVendor)
134 c.Assert(parts[0].Version(), Equals, "1")
135 c.Assert(parts[0].Hash(), Equals, "e09c13f68fccef3b2fe0f5c8ff5c61acf2173b170b1f2a3646487147690b0970ef6f2c555d7bcb072035f29ee4ea66a6df7f6bb320d358d3a7d78a0c37a8a549")
136 c.Assert(parts[0].IsActive(), Equals, true)
137@@ -461,8 +461,8 @@
138 parts, err := s.systemImage.Installed()
139 c.Assert(err, IsNil)
140 c.Assert(parts, HasLen, 2)
141- c.Assert(parts[0].Origin(), Equals, systemImagePartOrigin)
142- c.Assert(parts[1].Origin(), Equals, systemImagePartOrigin)
143+ c.Assert(parts[0].Origin(), Equals, SystemImagePartOrigin)
144+ c.Assert(parts[1].Origin(), Equals, SystemImagePartOrigin)
145 }
146
147 func (s *SITestSuite) TestCannotUpdateIfSideLoaded(c *C) {

Subscribers

People subscribed via source and target branches