Merge lp:~chipaca/snappy/pkg-types into lp:~snappy-dev/snappy/snappy-moved-to-github

Proposed by John Lenton
Status: Merged
Approved by: Sergio Schvezov
Approved revision: 463
Merged at revision: 464
Proposed branch: lp:~chipaca/snappy/pkg-types
Merge into: lp:~snappy-dev/snappy/snappy-moved-to-github
Diff against target: 990 lines (+210/-128)
24 files modified
cmd/snappy/cmd_booted.go (+2/-1)
cmd/snappy/cmd_info.go (+4/-3)
cmd/snappy/cmd_list.go (+2/-1)
cmd/snappy/cmd_search.go (+2/-1)
pkg/types.go (+58/-0)
pkg/types_test.go (+64/-0)
snappy/click.go (+10/-9)
snappy/click_test.go (+2/-1)
snappy/common_test.go (+5/-4)
snappy/errors.go (+1/-1)
snappy/firstboot.go (+2/-1)
snappy/firstboot_test.go (+8/-6)
snappy/oem.go (+2/-1)
snappy/parts.go (+5/-39)
snappy/parts_test.go (+3/-2)
snappy/remove_test.go (+7/-5)
snappy/rollback_test.go (+5/-3)
snappy/security.go (+2/-1)
snappy/security_test.go (+3/-1)
snappy/set_test.go (+2/-1)
snappy/snapp.go (+12/-11)
snappy/snapp_test.go (+2/-32)
snappy/systemimage.go (+4/-3)
snappy/udev.go (+3/-1)
To merge this branch: bzr merge lp:~chipaca/snappy/pkg-types
Reviewer Review Type Date Requested Status
Sergio Schvezov Approve
Review via email: mp+259485@code.launchpad.net

Commit message

Move SnapType -> pkg.Type

To post a comment you must log in.
Revision history for this message
Sergio Schvezov (sergiusens) wrote :

This looks good, but I want to know what the next MP will look like.

Will the layout look a bit like:

pkg/oem
pkg/app
pkg/kernel
pkg/os
pkg/framework
?

An interface in pkg (superseeded from Part)?

Maybe a generic implementation of the interface in pkg and every component composing/embedding that?

review: Needs Information
Revision history for this message
John Lenton (chipaca) wrote :

I think saying that that will be in the _next_ MP would be ambitious. But soon.

Whether it's pkg/oem or pkg/snap/oem (with common snap-level things in snap) is unclear to me at this point, I'm keeping an open mind until I've finished worrying the code some more.

Interfaces would be in pkg, unless it got too hairy in which case I wouldn't mind pkg/interface or some such.

The fractal nature of the dependencies right now makes it hard for me to give concrete answers. You probably have more of all of this in your head, so we should discuss.

Revision history for this message
Sergio Schvezov (sergiusens) wrote :

The road map feels excellent so this gets to land!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'cmd/snappy/cmd_booted.go'
--- cmd/snappy/cmd_booted.go 2015-05-18 19:05:50 +0000
+++ cmd/snappy/cmd_booted.go 2015-05-19 11:17:28 +0000
@@ -19,6 +19,7 @@
1919
20import (20import (
21 "launchpad.net/snappy/logger"21 "launchpad.net/snappy/logger"
22 "launchpad.net/snappy/pkg"
22 "launchpad.net/snappy/priv"23 "launchpad.net/snappy/priv"
23 "launchpad.net/snappy/snappy"24 "launchpad.net/snappy/snappy"
24)25)
@@ -43,7 +44,7 @@
43 }44 }
44 defer privMutex.Unlock()45 defer privMutex.Unlock()
4546
46 parts, err := snappy.ActiveSnapsByType(snappy.SnapTypeCore)47 parts, err := snappy.ActiveSnapsByType(pkg.TypeCore)
47 if err != nil {48 if err != nil {
48 return err49 return err
49 }50 }
5051
=== modified file 'cmd/snappy/cmd_info.go'
--- cmd/snappy/cmd_info.go 2015-05-18 19:05:50 +0000
+++ cmd/snappy/cmd_info.go 2015-05-19 11:17:28 +0000
@@ -22,6 +22,7 @@
22 "strings"22 "strings"
2323
24 "launchpad.net/snappy/logger"24 "launchpad.net/snappy/logger"
25 "launchpad.net/snappy/pkg"
25 "launchpad.net/snappy/snappy"26 "launchpad.net/snappy/snappy"
26)27)
2728
@@ -80,7 +81,7 @@
80}81}
8182
82func ubuntuCoreChannel() string {83func ubuntuCoreChannel() string {
83 parts, err := snappy.ActiveSnapsByType(snappy.SnapTypeCore)84 parts, err := snappy.ActiveSnapsByType(pkg.TypeCore)
84 if len(parts) == 1 && err == nil {85 if len(parts) == 1 && err == nil {
85 return parts[0].Channel()86 return parts[0].Channel()
86 }87 }
@@ -90,8 +91,8 @@
9091
91func info() error {92func info() error {
92 release := ubuntuCoreChannel()93 release := ubuntuCoreChannel()
93 frameworks, _ := snappy.ActiveSnapNamesByType(snappy.SnapTypeFramework)94 frameworks, _ := snappy.ActiveSnapNamesByType(pkg.TypeFramework)
94 apps, _ := snappy.ActiveSnapNamesByType(snappy.SnapTypeApp)95 apps, _ := snappy.ActiveSnapNamesByType(pkg.TypeApp)
9596
96 fmt.Printf("release: %s\n", release)97 fmt.Printf("release: %s\n", release)
97 fmt.Printf("architecture: %s\n", snappy.Architecture())98 fmt.Printf("architecture: %s\n", snappy.Architecture())
9899
=== modified file 'cmd/snappy/cmd_list.go'
--- cmd/snappy/cmd_list.go 2015-05-18 19:05:50 +0000
+++ cmd/snappy/cmd_list.go 2015-05-19 11:17:28 +0000
@@ -25,6 +25,7 @@
25 "time"25 "time"
2626
27 "launchpad.net/snappy/logger"27 "launchpad.net/snappy/logger"
28 "launchpad.net/snappy/pkg"
28 "launchpad.net/snappy/snappy"29 "launchpad.net/snappy/snappy"
29)30)
3031
@@ -134,7 +135,7 @@
134 // there are only two version instaleld and135 // there are only two version instaleld and
135 // there is only a single part that may requires136 // there is only a single part that may requires
136 // a reboot137 // a reboot
137 if part.Type() != snappy.SnapTypeCore {138 if part.Type() != pkg.TypeCore {
138 continue139 continue
139 }140 }
140141
141142
=== modified file 'cmd/snappy/cmd_search.go'
--- cmd/snappy/cmd_search.go 2015-05-18 19:05:50 +0000
+++ cmd/snappy/cmd_search.go 2015-05-19 11:17:28 +0000
@@ -23,6 +23,7 @@
23 "text/tabwriter"23 "text/tabwriter"
2424
25 "launchpad.net/snappy/logger"25 "launchpad.net/snappy/logger"
26 "launchpad.net/snappy/pkg"
26 "launchpad.net/snappy/snappy"27 "launchpad.net/snappy/snappy"
27)28)
2829
@@ -68,7 +69,7 @@
68 }69 }
69 } else {70 } else {
70 for _, part := range sharedName.Parts {71 for _, part := range sharedName.Parts {
71 if sharedName.IsAlias(part.Namespace()) || part.Type() == snappy.SnapTypeFramework {72 if sharedName.IsAlias(part.Namespace()) || part.Type() == pkg.TypeFramework {
72 fmt.Fprintln(w, fmt.Sprintf("%s\t%s\t%s\t", part.Name(), part.Version(), part.Description()))73 fmt.Fprintln(w, fmt.Sprintf("%s\t%s\t%s\t", part.Name(), part.Version(), part.Description()))
73 } else {74 } else {
74 fmt.Fprintln(w, fmt.Sprintf("%s.%s\t%s\t%s\t", part.Name(), part.Namespace(), part.Version(), part.Description()))75 fmt.Fprintln(w, fmt.Sprintf("%s.%s\t%s\t%s\t", part.Name(), part.Namespace(), part.Version(), part.Description()))
7576
=== added directory 'pkg'
=== added file 'pkg/types.go'
--- pkg/types.go 1970-01-01 00:00:00 +0000
+++ pkg/types.go 2015-05-19 11:17:28 +0000
@@ -0,0 +1,58 @@
1/*
2 * Copyright (C) 2014-2015 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 */
17
18// Package pkg packages odds and ends that apply to packages in more than one
19// layer (to more than one of deb, click, snap, and part).
20package pkg
21
22import (
23 "encoding/json"
24)
25
26// Type represents the kind of snap (app, core, frameworks, oem)
27type Type string
28
29// The various types of snap parts we support
30const (
31 TypeApp Type = "app"
32 TypeCore Type = "core"
33 TypeFramework Type = "framework"
34 TypeOem Type = "oem"
35)
36
37// MarshalJSON returns *m as the JSON encoding of m.
38func (m Type) MarshalJSON() ([]byte, error) {
39 return json.Marshal(string(m))
40}
41
42// UnmarshalJSON sets *m to a copy of data.
43func (m *Type) UnmarshalJSON(data []byte) error {
44 var str string
45 if err := json.Unmarshal(data, &str); err != nil {
46 return err
47 }
48
49 // this is a workaround as the store sends "application" but snappy uses
50 // "app" for TypeApp
51 if str == "application" {
52 *m = TypeApp
53 } else {
54 *m = Type(str)
55 }
56
57 return nil
58}
059
=== added file 'pkg/types_test.go'
--- pkg/types_test.go 1970-01-01 00:00:00 +0000
+++ pkg/types_test.go 2015-05-19 11:17:28 +0000
@@ -0,0 +1,64 @@
1/*
2 * Copyright (C) 2014-2015 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 */
17
18package pkg
19
20import (
21 "encoding/json"
22 "testing"
23
24 . "launchpad.net/gocheck"
25)
26
27type typeSuite struct{}
28
29// Hook up gocheck into the "go test" runner
30func Test(t *testing.T) { TestingT(t) }
31
32var _ = Suite(&typeSuite{})
33
34func (s *typeSuite) TestJSONerr(c *C) {
35 var t Type
36 err := json.Unmarshal([]byte("false"), &t)
37 c.Assert(err, NotNil)
38}
39
40func (s *typeSuite) TestMarshalTypes(c *C) {
41 out, err := json.Marshal(TypeApp)
42 c.Assert(err, IsNil)
43 c.Check(string(out), Equals, "\"app\"")
44
45 out, err = json.Marshal(TypeOem)
46 c.Assert(err, IsNil)
47 c.Check(string(out), Equals, "\"oem\"")
48}
49
50func (s *typeSuite) TestUnmarshalTypes(c *C) {
51 var st Type
52
53 err := json.Unmarshal([]byte("\"application\""), &st)
54 c.Assert(err, IsNil)
55 c.Check(st, Equals, TypeApp)
56
57 err = json.Unmarshal([]byte("\"app\""), &st)
58 c.Assert(err, IsNil)
59 c.Check(st, Equals, TypeApp)
60
61 err = json.Unmarshal([]byte("\"oem\""), &st)
62 c.Assert(err, IsNil)
63 c.Check(st, Equals, TypeOem)
64}
065
=== modified file 'snappy/click.go'
--- snappy/click.go 2015-05-18 19:15:37 +0000
+++ snappy/click.go 2015-05-19 11:17:28 +0000
@@ -43,6 +43,7 @@
43 "launchpad.net/snappy/clickdeb"43 "launchpad.net/snappy/clickdeb"
44 "launchpad.net/snappy/helpers"44 "launchpad.net/snappy/helpers"
45 "launchpad.net/snappy/logger"45 "launchpad.net/snappy/logger"
46 "launchpad.net/snappy/pkg"
46 "launchpad.net/snappy/policy"47 "launchpad.net/snappy/policy"
47 "launchpad.net/snappy/systemd"48 "launchpad.net/snappy/systemd"
4849
@@ -55,7 +56,7 @@
55 Name string `json:"name"`56 Name string `json:"name"`
56 Version string `json:"version"`57 Version string `json:"version"`
57 Architecture []string `json:"architecture,omitempty"`58 Architecture []string `json:"architecture,omitempty"`
58 Type SnapType `json:"type,omitempty"`59 Type pkg.Type `json:"type,omitempty"`
59 Framework string `json:"framework,omitempty"`60 Framework string `json:"framework,omitempty"`
60 Description string `json:"description,omitempty"`61 Description string `json:"description,omitempty"`
61 Icon string `json:"icon,omitempty"`62 Icon string `json:"icon,omitempty"`
@@ -300,7 +301,7 @@
300// generate the name301// generate the name
301func generateBinaryName(m *packageYaml, binary Binary) string {302func generateBinaryName(m *packageYaml, binary Binary) string {
302 var binName string303 var binName string
303 if m.Type == SnapTypeFramework {304 if m.Type == pkg.TypeFramework {
304 binName = filepath.Base(binary.Name)305 binName = filepath.Base(binary.Name)
305 } else {306 } else {
306 binName = fmt.Sprintf("%s.%s", m.Name, filepath.Base(binary.Name))307 binName = fmt.Sprintf("%s.%s", m.Name, filepath.Base(binary.Name))
@@ -469,7 +470,7 @@
469 PostStop: service.PostStop,470 PostStop: service.PostStop,
470 StopTimeout: time.Duration(service.StopTimeout),471 StopTimeout: time.Duration(service.StopTimeout),
471 AaProfile: aaProfile,472 AaProfile: aaProfile,
472 IsFramework: m.Type == SnapTypeFramework,473 IsFramework: m.Type == pkg.TypeFramework,
473 BusName: service.BusName,474 BusName: service.BusName,
474 UdevAppName: udevPartName,475 UdevAppName: udevPartName,
475 }), nil476 }), nil
@@ -533,7 +534,7 @@
533534
534 // If necessary, generate the DBus policy file so the framework535 // If necessary, generate the DBus policy file so the framework
535 // service is allowed to start536 // service is allowed to start
536 if m.Type == SnapTypeFramework && service.BusName != "" {537 if m.Type == pkg.TypeFramework && service.BusName != "" {
537 content, err := genBusPolicyFile(service.BusName)538 content, err := genBusPolicyFile(service.BusName)
538 if err != nil {539 if err != nil {
539 return err540 return err
@@ -796,7 +797,7 @@
796 return err797 return err
797 }798 }
798799
799 if cm.Type != SnapTypeFramework && cm.Type != SnapTypeOem {800 if cm.Type != pkg.TypeFramework && cm.Type != pkg.TypeOem {
800 // add the namespace to the name801 // add the namespace to the name
801 cm.Name = fmt.Sprintf("%s.%s", cm.Name, namespace)802 cm.Name = fmt.Sprintf("%s.%s", cm.Name, namespace)
802 }803 }
@@ -861,7 +862,7 @@
861862
862 targetDir := snapAppsDir863 targetDir := snapAppsDir
863 // the "oem" parts are special864 // the "oem" parts are special
864 if manifest.Type == SnapTypeOem {865 if manifest.Type == pkg.TypeOem {
865 targetDir = snapOemDir866 targetDir = snapOemDir
866867
867 // TODO do the following at a higher level once the store publishes snap types868 // TODO do the following at a higher level once the store publishes snap types
@@ -885,7 +886,7 @@
885886
886 fullName := manifest.Name887 fullName := manifest.Name
887 // namespacing only applies to apps.888 // namespacing only applies to apps.
888 if manifest.Type != SnapTypeFramework && manifest.Type != SnapTypeOem {889 if manifest.Type != pkg.TypeFramework && manifest.Type != pkg.TypeOem {
889 fullName += "." + namespace890 fullName += "." + namespace
890 }891 }
891 instDir := filepath.Join(targetDir, fullName, manifest.Version)892 instDir := filepath.Join(targetDir, fullName, manifest.Version)
@@ -1158,7 +1159,7 @@
1158 return err1159 return err
1159 }1160 }
11601161
1161 if manifest.Type == SnapTypeFramework {1162 if manifest.Type == pkg.TypeFramework {
11621163
1163 if err := policy.Remove(m.Name, clickDir); err != nil {1164 if err := policy.Remove(m.Name, clickDir); err != nil {
1164 return err1165 return err
@@ -1204,7 +1205,7 @@
1204 return err1205 return err
1205 }1206 }
12061207
1207 if newActiveManifest.Type == SnapTypeFramework {1208 if newActiveManifest.Type == pkg.TypeFramework {
1208 if err := policy.Install(m.Name, baseDir); err != nil {1209 if err := policy.Install(m.Name, baseDir); err != nil {
1209 return err1210 return err
1210 }1211 }
12111212
=== modified file 'snappy/click_test.go'
--- snappy/click_test.go 2015-05-16 15:29:55 +0000
+++ snappy/click_test.go 2015-05-19 11:17:28 +0000
@@ -32,6 +32,7 @@
3232
33 "launchpad.net/snappy/clickdeb"33 "launchpad.net/snappy/clickdeb"
34 "launchpad.net/snappy/helpers"34 "launchpad.net/snappy/helpers"
35 "launchpad.net/snappy/pkg"
35 "launchpad.net/snappy/policy"36 "launchpad.net/snappy/policy"
36 "launchpad.net/snappy/progress"37 "launchpad.net/snappy/progress"
37 "launchpad.net/snappy/systemd"38 "launchpad.net/snappy/systemd"
@@ -1237,7 +1238,7 @@
1237 m := packageYaml{1238 m := packageYaml{
1238 Name: "xkcd-webserver",1239 Name: "xkcd-webserver",
1239 Version: "0.3.4",1240 Version: "0.3.4",
1240 Type: SnapTypeFramework,1241 Type: pkg.TypeFramework,
1241 }1242 }
12421243
1243 generatedWrapper, err := generateSnapServicesFile(service, pkgPath, aaProfile, &m)1244 generatedWrapper, err := generateSnapServicesFile(service, pkgPath, aaProfile, &m)
12441245
=== modified file 'snappy/common_test.go'
--- snappy/common_test.go 2015-05-06 12:26:38 +0000
+++ snappy/common_test.go 2015-05-19 11:17:28 +0000
@@ -23,12 +23,13 @@
23 "os"23 "os"
24 "path"24 "path"
25 "path/filepath"25 "path/filepath"
26 "strings"
2627
27 "launchpad.net/snappy/helpers"28 "launchpad.net/snappy/helpers"
29 "launchpad.net/snappy/pkg"
2830
29 "gopkg.in/yaml.v2"31 "gopkg.in/yaml.v2"
30 . "launchpad.net/gocheck"32 . "launchpad.net/gocheck"
31 "strings"
32)33)
3334
34const (35const (
@@ -147,10 +148,10 @@
147 return path.Join(tmpdir, snapFile)148 return path.Join(tmpdir, snapFile)
148}149}
149150
150// makeTwoTestSnaps creates two real snaps of SnapType of name151// makeTwoTestSnaps creates two real snaps of pkg.Type of name
151// "foo", with version "1.0" and "2.0", "2.0" being marked as the152// "foo", with version "1.0" and "2.0", "2.0" being marked as the
152// active snap.153// active snap.
153func makeTwoTestSnaps(c *C, snapType SnapType, extra ...string) {154func makeTwoTestSnaps(c *C, snapType pkg.Type, extra ...string) {
154 inter := &MockProgressMeter{}155 inter := &MockProgressMeter{}
155156
156 packageYaml := `name: foo157 packageYaml := `name: foo
@@ -161,7 +162,7 @@
161 packageYaml += strings.Join(extra, "\n") + "\n"162 packageYaml += strings.Join(extra, "\n") + "\n"
162 }163 }
163164
164 if snapType != SnapTypeApp {165 if snapType != pkg.TypeApp {
165 packageYaml += fmt.Sprintf("type: %s\n", snapType)166 packageYaml += fmt.Sprintf("type: %s\n", snapType)
166 }167 }
167168
168169
=== modified file 'snappy/errors.go'
--- snappy/errors.go 2015-05-18 19:15:37 +0000
+++ snappy/errors.go 2015-05-19 11:17:28 +0000
@@ -119,7 +119,7 @@
119 // an interface is partial.119 // an interface is partial.
120 ErrNotImplemented = errors.New("not implemented")120 ErrNotImplemented = errors.New("not implemented")
121121
122 // ErrNoOemConfiguration may be returned when there is a SnapTypeOem installed122 // ErrNoOemConfiguration may be returned when there is a pkg.TypeOem installed
123 // but does not provide a configuration.123 // but does not provide a configuration.
124 ErrNoOemConfiguration = errors.New("no configuration entry found in the oem snap")124 ErrNoOemConfiguration = errors.New("no configuration entry found in the oem snap")
125125
126126
=== modified file 'snappy/firstboot.go'
--- snappy/firstboot.go 2015-05-08 16:07:35 +0000
+++ snappy/firstboot.go 2015-05-19 11:17:28 +0000
@@ -24,6 +24,7 @@
24 "path/filepath"24 "path/filepath"
2525
26 "launchpad.net/snappy/helpers"26 "launchpad.net/snappy/helpers"
27 "launchpad.net/snappy/pkg"
2728
28 "gopkg.in/yaml.v2"29 "gopkg.in/yaml.v2"
29)30)
@@ -54,7 +55,7 @@
54 }55 }
55 defer stampFirstBoot()56 defer stampFirstBoot()
5657
57 oemSnap, err := activeSnapsByType(SnapTypeOem)58 oemSnap, err := activeSnapsByType(pkg.TypeOem)
58 if err != nil {59 if err != nil {
59 return err60 return err
60 }61 }
6162
=== modified file 'snappy/firstboot_test.go'
--- snappy/firstboot_test.go 2015-04-14 16:46:57 +0000
+++ snappy/firstboot_test.go 2015-05-19 11:17:28 +0000
@@ -23,13 +23,15 @@
23 "path/filepath"23 "path/filepath"
2424
25 . "launchpad.net/gocheck"25 . "launchpad.net/gocheck"
26
27 "launchpad.net/snappy/pkg"
26)28)
2729
28type fakePart struct {30type fakePart struct {
29 SnapPart31 SnapPart
30 config []byte32 config []byte
31 oemConfig SystemConfig33 oemConfig SystemConfig
32 snapType SnapType34 snapType pkg.Type
33}35}
3436
35func (p *fakePart) Config(b []byte) (string, error) {37func (p *fakePart) Config(b []byte) (string, error) {
@@ -41,7 +43,7 @@
41 return p.oemConfig43 return p.oemConfig
42}44}
4345
44func (p *fakePart) Type() SnapType {46func (p *fakePart) Type() pkg.Type {
45 return p.snapType47 return p.snapType
46}48}
4749
@@ -69,8 +71,8 @@
69}71}
7072
71func (s *FirstBootTestSuite) mockActiveSnapNamesByType() *fakePart {73func (s *FirstBootTestSuite) mockActiveSnapNamesByType() *fakePart {
72 fakeOem := fakePart{oemConfig: s.oemConfig, snapType: SnapTypeOem}74 fakeOem := fakePart{oemConfig: s.oemConfig, snapType: pkg.TypeOem}
73 activeSnapsByType = func(snapsTs ...SnapType) ([]Part, error) {75 activeSnapsByType = func(snapsTs ...pkg.Type) ([]Part, error) {
74 return []Part{&fakeOem}, nil76 return []Part{&fakeOem}, nil
75 }77 }
7678
@@ -78,7 +80,7 @@
78}80}
7981
80func (s *FirstBootTestSuite) mockActiveSnapByName() *fakePart {82func (s *FirstBootTestSuite) mockActiveSnapByName() *fakePart {
81 fakeMyApp := fakePart{snapType: SnapTypeApp}83 fakeMyApp := fakePart{snapType: pkg.TypeApp}
82 activeSnapByName = func(needle string) Part {84 activeSnapByName = func(needle string) Part {
83 return &fakeMyApp85 return &fakeMyApp
84 }86 }
@@ -108,7 +110,7 @@
108}110}
109111
110func (s *FirstBootTestSuite) TestNoErrorWhenNoOEM(c *C) {112func (s *FirstBootTestSuite) TestNoErrorWhenNoOEM(c *C) {
111 activeSnapsByType = func(snapsTs ...SnapType) ([]Part, error) {113 activeSnapsByType = func(snapsTs ...pkg.Type) ([]Part, error) {
112 return nil, nil114 return nil, nil
113 }115 }
114116
115117
=== modified file 'snappy/oem.go'
--- snappy/oem.go 2015-05-11 16:06:50 +0000
+++ snappy/oem.go 2015-05-19 11:17:28 +0000
@@ -31,6 +31,7 @@
3131
32 "launchpad.net/snappy/helpers"32 "launchpad.net/snappy/helpers"
33 "launchpad.net/snappy/logger"33 "launchpad.net/snappy/logger"
34 "launchpad.net/snappy/pkg"
34)35)
3536
36// OEM represents the structure inside the package.yaml for the oem component37// OEM represents the structure inside the package.yaml for the oem component
@@ -101,7 +102,7 @@
101var getOem = getOemImpl102var getOem = getOemImpl
102103
103var getOemImpl = func() (*packageYaml, error) {104var getOemImpl = func() (*packageYaml, error) {
104 oems, _ := ActiveSnapsByType(SnapTypeOem)105 oems, _ := ActiveSnapsByType(pkg.TypeOem)
105 if len(oems) == 1 {106 if len(oems) == 1 {
106 return oems[0].(*SnapPart).m, nil107 return oems[0].(*SnapPart).m, nil
107 }108 }
108109
=== modified file 'snappy/parts.go'
--- snappy/parts.go 2015-05-07 15:19:05 +0000
+++ snappy/parts.go 2015-05-19 11:17:28 +0000
@@ -18,53 +18,19 @@
18package snappy18package snappy
1919
20import (20import (
21 "encoding/json"
22 "fmt"21 "fmt"
23 "net"22 "net"
24 "net/url"23 "net/url"
25 "strings"24 "strings"
26 "time"25 "time"
2726
27 "launchpad.net/snappy/pkg"
28 "launchpad.net/snappy/progress"28 "launchpad.net/snappy/progress"
29)29)
3030
31// SnapType represents the kind of snap (app, core, frameworks, oem)
32type SnapType string
33
34// MarshalJSON returns *m as the JSON encoding of m.
35func (m SnapType) MarshalJSON() ([]byte, error) {
36 return json.Marshal(string(m))
37}
38
39// UnmarshalJSON sets *m to a copy of data.
40func (m *SnapType) UnmarshalJSON(data []byte) error {
41 var str string
42 if err := json.Unmarshal(data, &str); err != nil {
43 return err
44 }
45
46 // this is a workaround as the store sends "application" but snappy uses
47 // "app" for SnapTypeApp
48 if str == "application" {
49 *m = SnapTypeApp
50 } else {
51 *m = SnapType(str)
52 }
53
54 return nil
55}
56
57// SystemConfig is a config map holding configs for multiple packages31// SystemConfig is a config map holding configs for multiple packages
58type SystemConfig map[string]interface{}32type SystemConfig map[string]interface{}
5933
60// The various types of snap parts we support
61const (
62 SnapTypeApp SnapType = "app"
63 SnapTypeCore SnapType = "core"
64 SnapTypeFramework SnapType = "framework"
65 SnapTypeOem SnapType = "oem"
66)
67
68// Services implements snappy packages that offer services34// Services implements snappy packages that offer services
69type Services interface {35type Services interface {
70 Services() []Service36 Services() []Service
@@ -78,7 +44,7 @@
78// Dirname of a Part is the Name, in most cases qualified with the44// Dirname of a Part is the Name, in most cases qualified with the
79// Namespace45// Namespace
80func Dirname(p Part) string {46func Dirname(p Part) string {
81 if t := p.Type(); t == SnapTypeFramework || t == SnapTypeOem {47 if t := p.Type(); t == pkg.TypeFramework || t == pkg.TypeOem {
82 return p.Name()48 return p.Name()
83 }49 }
84 return p.Name() + "." + p.Namespace()50 return p.Name() + "." + p.Namespace()
@@ -110,7 +76,7 @@
110 Icon() string76 Icon() string
11177
112 // Returns app, framework, core78 // Returns app, framework, core
113 Type() SnapType79 Type() pkg.Type
11480
115 InstalledSize() int6481 InstalledSize() int64
116 DownloadSize() int6482 DownloadSize() int64
@@ -237,7 +203,7 @@
237}203}
238204
239// ActiveSnapsByType returns all installed snaps with the given type205// ActiveSnapsByType returns all installed snaps with the given type
240func ActiveSnapsByType(snapTs ...SnapType) (res []Part, err error) {206func ActiveSnapsByType(snapTs ...pkg.Type) (res []Part, err error) {
241 m := NewMetaRepository()207 m := NewMetaRepository()
242 installed, err := m.Installed()208 installed, err := m.Installed()
243 if err != nil {209 if err != nil {
@@ -261,7 +227,7 @@
261// ActiveSnapNamesByType returns all installed snap names with the given type227// ActiveSnapNamesByType returns all installed snap names with the given type
262var ActiveSnapNamesByType = activeSnapNamesByTypeImpl228var ActiveSnapNamesByType = activeSnapNamesByTypeImpl
263229
264func activeSnapNamesByTypeImpl(snapTs ...SnapType) (res []string, err error) {230func activeSnapNamesByTypeImpl(snapTs ...pkg.Type) (res []string, err error) {
265 installed, err := ActiveSnapsByType(snapTs...)231 installed, err := ActiveSnapsByType(snapTs...)
266 for _, part := range installed {232 for _, part := range installed {
267 res = append(res, part.Name())233 res = append(res, part.Name())
268234
=== modified file 'snappy/parts_test.go'
--- snappy/parts_test.go 2015-04-21 12:05:22 +0000
+++ snappy/parts_test.go 2015-05-19 11:17:28 +0000
@@ -24,6 +24,7 @@
2424
25 . "launchpad.net/gocheck"25 . "launchpad.net/gocheck"
2626
27 "launchpad.net/snappy/pkg"
27 "launchpad.net/snappy/progress"28 "launchpad.net/snappy/progress"
28)29)
2930
@@ -43,12 +44,12 @@
43 c.Assert(err, IsNil)44 c.Assert(err, IsNil)
44 makeSnapActive(yamlPath)45 makeSnapActive(yamlPath)
4546
46 parts, err := ActiveSnapsByType(SnapTypeApp)47 parts, err := ActiveSnapsByType(pkg.TypeApp)
47 c.Assert(err, IsNil)48 c.Assert(err, IsNil)
48 c.Assert(parts, HasLen, 1)49 c.Assert(parts, HasLen, 1)
49 c.Assert(parts[0].Name(), Equals, "app1")50 c.Assert(parts[0].Name(), Equals, "app1")
5051
51 parts, err = ActiveSnapsByType(SnapTypeFramework)52 parts, err = ActiveSnapsByType(pkg.TypeFramework)
52 c.Assert(err, IsNil)53 c.Assert(err, IsNil)
53 c.Assert(parts, HasLen, 1)54 c.Assert(parts, HasLen, 1)
54 c.Assert(parts[0].Name(), Equals, "framework1")55 c.Assert(parts[0].Name(), Equals, "framework1")
5556
=== modified file 'snappy/remove_test.go'
--- snappy/remove_test.go 2015-04-15 13:17:22 +0000
+++ snappy/remove_test.go 2015-05-19 11:17:28 +0000
@@ -19,6 +19,8 @@
1919
20import (20import (
21 . "launchpad.net/gocheck"21 . "launchpad.net/gocheck"
22
23 "launchpad.net/snappy/pkg"
22 "launchpad.net/snappy/progress"24 "launchpad.net/snappy/progress"
23)25)
2426
@@ -30,7 +32,7 @@
30}32}
3133
32func (s *SnapTestSuite) TestSnapRemoveByVersion(c *C) {34func (s *SnapTestSuite) TestSnapRemoveByVersion(c *C) {
33 makeTwoTestSnaps(c, SnapTypeApp)35 makeTwoTestSnaps(c, pkg.TypeApp)
3436
35 err := Remove("foo=1.0", 0, &progress.NullProgress{})37 err := Remove("foo=1.0", 0, &progress.NullProgress{})
3638
@@ -41,7 +43,7 @@
41}43}
4244
43func (s *SnapTestSuite) TestSnapRemoveActive(c *C) {45func (s *SnapTestSuite) TestSnapRemoveActive(c *C) {
44 makeTwoTestSnaps(c, SnapTypeApp)46 makeTwoTestSnaps(c, pkg.TypeApp)
4547
46 err := Remove("foo", 0, &progress.NullProgress{})48 err := Remove("foo", 0, &progress.NullProgress{})
4749
@@ -52,7 +54,7 @@
52}54}
5355
54func (s *SnapTestSuite) TestSnapRemoveActiveOemFails(c *C) {56func (s *SnapTestSuite) TestSnapRemoveActiveOemFails(c *C) {
55 makeTwoTestSnaps(c, SnapTypeOem)57 makeTwoTestSnaps(c, pkg.TypeOem)
5658
57 err := Remove("foo", 0, &progress.NullProgress{})59 err := Remove("foo", 0, &progress.NullProgress{})
58 c.Assert(err, DeepEquals, ErrPackageNotRemovable)60 c.Assert(err, DeepEquals, ErrPackageNotRemovable)
@@ -67,13 +69,13 @@
67 installed, err := m.Installed()69 installed, err := m.Installed()
68 c.Assert(err, IsNil)70 c.Assert(err, IsNil)
69 c.Assert(installed[0].Name(), Equals, "foo")71 c.Assert(installed[0].Name(), Equals, "foo")
70 c.Assert(installed[0].Type(), Equals, SnapTypeOem)72 c.Assert(installed[0].Type(), Equals, pkg.TypeOem)
71 c.Assert(installed[0].Version(), Equals, "2.0")73 c.Assert(installed[0].Version(), Equals, "2.0")
72 c.Assert(installed, HasLen, 1)74 c.Assert(installed, HasLen, 1)
73}75}
7476
75func (s *SnapTestSuite) TestSnapRemoveGC(c *C) {77func (s *SnapTestSuite) TestSnapRemoveGC(c *C) {
76 makeTwoTestSnaps(c, SnapTypeApp)78 makeTwoTestSnaps(c, pkg.TypeApp)
77 err := Remove("foo", DoRemoveGC, &progress.NullProgress{})79 err := Remove("foo", DoRemoveGC, &progress.NullProgress{})
78 c.Assert(err, IsNil)80 c.Assert(err, IsNil)
79 m := NewMetaRepository()81 m := NewMetaRepository()
8082
=== modified file 'snappy/rollback_test.go'
--- snappy/rollback_test.go 2015-04-30 16:56:15 +0000
+++ snappy/rollback_test.go 2015-05-19 11:17:28 +0000
@@ -19,10 +19,12 @@
1919
20import (20import (
21 . "launchpad.net/gocheck"21 . "launchpad.net/gocheck"
22
23 "launchpad.net/snappy/pkg"
22)24)
2325
24func (s *SnapTestSuite) TestRollbackWithVersion(c *C) {26func (s *SnapTestSuite) TestRollbackWithVersion(c *C) {
25 makeTwoTestSnaps(c, SnapTypeApp)27 makeTwoTestSnaps(c, pkg.TypeApp)
26 c.Assert(ActiveSnapByName("foo").Version(), Equals, "2.0")28 c.Assert(ActiveSnapByName("foo").Version(), Equals, "2.0")
2729
28 // rollback with version30 // rollback with version
@@ -34,7 +36,7 @@
34}36}
3537
36func (s *SnapTestSuite) TestRollbackFindVersion(c *C) {38func (s *SnapTestSuite) TestRollbackFindVersion(c *C) {
37 makeTwoTestSnaps(c, SnapTypeApp)39 makeTwoTestSnaps(c, pkg.TypeApp)
38 c.Assert(ActiveSnapByName("foo").Version(), Equals, "2.0")40 c.Assert(ActiveSnapByName("foo").Version(), Equals, "2.0")
3941
40 // rollback without version42 // rollback without version
@@ -46,7 +48,7 @@
46}48}
4749
48func (s *SnapTestSuite) TestRollbackService(c *C) {50func (s *SnapTestSuite) TestRollbackService(c *C) {
49 makeTwoTestSnaps(c, SnapTypeApp, `services:51 makeTwoTestSnaps(c, pkg.TypeApp, `services:
50 - name: svc152 - name: svc1
51`)53`)
52 pkg := ActiveSnapByName("foo")54 pkg := ActiveSnapByName("foo")
5355
=== modified file 'snappy/security.go'
--- snappy/security.go 2015-05-18 19:05:50 +0000
+++ snappy/security.go 2015-05-19 11:17:28 +0000
@@ -12,6 +12,7 @@
1212
13 "launchpad.net/snappy/helpers"13 "launchpad.net/snappy/helpers"
14 "launchpad.net/snappy/logger"14 "launchpad.net/snappy/logger"
15 "launchpad.net/snappy/pkg"
15)16)
1617
17type apparmorJSONTemplate struct {18type apparmorJSONTemplate struct {
@@ -112,7 +113,7 @@
112113
113func getSecurityProfile(m *packageYaml, appName, baseDir string) (string, error) {114func getSecurityProfile(m *packageYaml, appName, baseDir string) (string, error) {
114 cleanedName := strings.Replace(appName, "/", "-", -1)115 cleanedName := strings.Replace(appName, "/", "-", -1)
115 if m.Type == SnapTypeFramework || m.Type == SnapTypeOem {116 if m.Type == pkg.TypeFramework || m.Type == pkg.TypeOem {
116 return fmt.Sprintf("%s_%s_%s", m.Name, cleanedName, m.Version), nil117 return fmt.Sprintf("%s_%s_%s", m.Name, cleanedName, m.Version), nil
117 }118 }
118119
119120
=== modified file 'snappy/security_test.go'
--- snappy/security_test.go 2015-04-19 14:02:33 +0000
+++ snappy/security_test.go 2015-05-19 11:17:28 +0000
@@ -6,6 +6,8 @@
6 "path/filepath"6 "path/filepath"
77
8 . "launchpad.net/gocheck"8 . "launchpad.net/gocheck"
9
10 "launchpad.net/snappy/pkg"
9)11)
1012
11type SecurityTestSuite struct {13type SecurityTestSuite struct {
@@ -143,7 +145,7 @@
143 m := packageYaml{145 m := packageYaml{
144 Name: "foo",146 Name: "foo",
145 Version: "1.0",147 Version: "1.0",
146 Type: SnapTypeFramework,148 Type: pkg.TypeFramework,
147 }149 }
148 b := Binary{Name: "bin/app"}150 b := Binary{Name: "bin/app"}
149 ap, err := getSecurityProfile(&m, b.Name, "/apps/foo.mvo/1.0/")151 ap, err := getSecurityProfile(&m, b.Name, "/apps/foo.mvo/1.0/")
150152
=== modified file 'snappy/set_test.go'
--- snappy/set_test.go 2015-04-30 16:56:15 +0000
+++ snappy/set_test.go 2015-05-19 11:17:28 +0000
@@ -24,6 +24,7 @@
2424
25 . "launchpad.net/gocheck"25 . "launchpad.net/gocheck"
2626
27 "launchpad.net/snappy/pkg"
27 "launchpad.net/snappy/progress"28 "launchpad.net/snappy/progress"
28)29)
2930
@@ -73,7 +74,7 @@
73}74}
7475
75func (s *SnapTestSuite) TestSetActive(c *C) {76func (s *SnapTestSuite) TestSetActive(c *C) {
76 makeTwoTestSnaps(c, SnapTypeApp)77 makeTwoTestSnaps(c, pkg.TypeApp)
7778
78 path, err := filepath.EvalSymlinks(filepath.Join(snapAppsDir, fooComposedName, "current"))79 path, err := filepath.EvalSymlinks(filepath.Join(snapAppsDir, fooComposedName, "current"))
79 c.Assert(err, IsNil)80 c.Assert(err, IsNil)
8081
=== modified file 'snappy/snapp.go'
--- snappy/snapp.go 2015-05-18 16:05:45 +0000
+++ snappy/snapp.go 2015-05-19 11:17:28 +0000
@@ -40,6 +40,7 @@
40 "launchpad.net/snappy/clickdeb"40 "launchpad.net/snappy/clickdeb"
41 "launchpad.net/snappy/helpers"41 "launchpad.net/snappy/helpers"
42 "launchpad.net/snappy/logger"42 "launchpad.net/snappy/logger"
43 "launchpad.net/snappy/pkg"
43 "launchpad.net/snappy/policy"44 "launchpad.net/snappy/policy"
44 "launchpad.net/snappy/progress"45 "launchpad.net/snappy/progress"
45 "launchpad.net/snappy/release"46 "launchpad.net/snappy/release"
@@ -200,7 +201,7 @@
200 Version string201 Version string
201 Vendor string202 Vendor string
202 Icon string203 Icon string
203 Type SnapType204 Type pkg.Type
204205
205 // the spec allows a string or a list here *ick* so we need206 // the spec allows a string or a list here *ick* so we need
206 // to convert that into something sensible via reflect207 // to convert that into something sensible via reflect
@@ -240,7 +241,7 @@
240 RatingsAverage float64 `json:"ratings_average,omitempty"`241 RatingsAverage float64 `json:"ratings_average,omitempty"`
241 SupportURL string `json:"support_url"`242 SupportURL string `json:"support_url"`
242 Title string `json:"title"`243 Title string `json:"title"`
243 Type SnapType `json:"content,omitempty"`244 Type pkg.Type `json:"content,omitempty"`
244 Version string `json:"version"`245 Version string `json:"version"`
245}246}
246247
@@ -343,7 +344,7 @@
343 return nil344 return nil
344 }345 }
345346
346 if m.Type != SnapTypeFramework && m.Type != SnapTypeOem {347 if m.Type != pkg.TypeFramework && m.Type != pkg.TypeOem {
347 if part.Namespace() != namespace {348 if part.Namespace() != namespace {
348 return ErrPackageNameAlreadyInstalled349 return ErrPackageNameAlreadyInstalled
349 }350 }
@@ -375,7 +376,7 @@
375}376}
376377
377func (m *packageYaml) checkForFrameworks() error {378func (m *packageYaml) checkForFrameworks() error {
378 installed, err := ActiveSnapNamesByType(SnapTypeFramework)379 installed, err := ActiveSnapNamesByType(pkg.TypeFramework)
379 if err != nil {380 if err != nil {
380 return err381 return err
381 }382 }
@@ -497,7 +498,7 @@
497}498}
498499
499// Type returns the type of the SnapPart (app, oem, ...)500// Type returns the type of the SnapPart (app, oem, ...)
500func (s *SnapPart) Type() SnapType {501func (s *SnapPart) Type() pkg.Type {
501 if s.m.Type != "" {502 if s.m.Type != "" {
502 return s.m.Type503 return s.m.Type
503 }504 }
@@ -614,7 +615,7 @@
614 // OEM snaps should not be removed as they are a key615 // OEM snaps should not be removed as they are a key
615 // building block for OEMs. Prunning non active ones616 // building block for OEMs. Prunning non active ones
616 // is acceptible.617 // is acceptible.
617 if s.m.Type == SnapTypeOem && s.IsActive() {618 if s.m.Type == pkg.TypeOem && s.IsActive() {
618 return ErrPackageNotRemovable619 return ErrPackageNotRemovable
619 }620 }
620621
@@ -674,7 +675,7 @@
674//675//
675// /!\ not part of the Part interface.676// /!\ not part of the Part interface.
676func (s *SnapPart) Dependents() ([]*SnapPart, error) {677func (s *SnapPart) Dependents() ([]*SnapPart, error) {
677 if s.Type() != SnapTypeFramework {678 if s.Type() != pkg.TypeFramework {
678 // only frameworks are depended on679 // only frameworks are depended on
679 return nil, nil680 return nil, nil
680 }681 }
@@ -836,7 +837,7 @@
836 }837 }
837838
838 namespace := ""839 namespace := ""
839 if m.Type != SnapTypeFramework && m.Type != SnapTypeOem {840 if m.Type != pkg.TypeFramework && m.Type != pkg.TypeOem {
840 namespace, err = namespaceFromYamlPath(realpath)841 namespace, err = namespaceFromYamlPath(realpath)
841 if err != nil {842 if err != nil {
842 return nil, err843 return nil, err
@@ -870,7 +871,7 @@
870}871}
871872
872// Type returns the type of the SnapPart (app, oem, ...)873// Type returns the type of the SnapPart (app, oem, ...)
873func (s *RemoteSnapPart) Type() SnapType {874func (s *RemoteSnapPart) Type() pkg.Type {
874 return s.pkg.Type875 return s.pkg.Type
875}876}
876877
@@ -1123,7 +1124,7 @@
1123 req.Header.Set("Accept", "application/hal+json")1124 req.Header.Set("Accept", "application/hal+json")
11241125
1125 // frameworks1126 // frameworks
1126 frameworks, _ := ActiveSnapNamesByType(SnapTypeFramework)1127 frameworks, _ := ActiveSnapNamesByType(pkg.TypeFramework)
1127 req.Header.Set("X-Ubuntu-Frameworks", strings.Join(addCoreFmk(frameworks), ","))1128 req.Header.Set("X-Ubuntu-Frameworks", strings.Join(addCoreFmk(frameworks), ","))
1128 req.Header.Set("X-Ubuntu-Architecture", string(Architecture()))1129 req.Header.Set("X-Ubuntu-Architecture", string(Architecture()))
1129 req.Header.Set("X-Ubuntu-Release", release.String())1130 req.Header.Set("X-Ubuntu-Release", release.String())
@@ -1236,7 +1237,7 @@
1236func (s *SnapUbuntuStoreRepository) Updates() (parts []Part, err error) {1237func (s *SnapUbuntuStoreRepository) Updates() (parts []Part, err error) {
1237 // the store only supports apps, oem and frameworks currently, so no1238 // the store only supports apps, oem and frameworks currently, so no
1238 // sense in sending it our ubuntu-core snap1239 // sense in sending it our ubuntu-core snap
1239 installed, err := ActiveSnapNamesByType(SnapTypeApp, SnapTypeFramework, SnapTypeOem)1240 installed, err := ActiveSnapNamesByType(pkg.TypeApp, pkg.TypeFramework, pkg.TypeOem)
1240 if err != nil || len(installed) == 0 {1241 if err != nil || len(installed) == 0 {
1241 return nil, err1242 return nil, err
1242 }1243 }
12431244
=== modified file 'snappy/snapp_test.go'
--- snappy/snapp_test.go 2015-05-16 15:29:55 +0000
+++ snappy/snapp_test.go 2015-05-19 11:17:28 +0000
@@ -18,7 +18,6 @@
18package snappy18package snappy
1919
20import (20import (
21 "encoding/json"
22 "io"21 "io"
23 "io/ioutil"22 "io/ioutil"
24 "net/http"23 "net/http"
@@ -31,6 +30,7 @@
31 "launchpad.net/snappy/clickdeb"30 "launchpad.net/snappy/clickdeb"
32 "launchpad.net/snappy/helpers"31 "launchpad.net/snappy/helpers"
33 "launchpad.net/snappy/partition"32 "launchpad.net/snappy/partition"
33 "launchpad.net/snappy/pkg"
34 "launchpad.net/snappy/policy"34 "launchpad.net/snappy/policy"
35 "launchpad.net/snappy/release"35 "launchpad.net/snappy/release"
36 "launchpad.net/snappy/systemd"36 "launchpad.net/snappy/systemd"
@@ -510,7 +510,7 @@
510 c.Check(parts[0].Channel(), Equals, "edge")510 c.Check(parts[0].Channel(), Equals, "edge")
511}511}
512func mockActiveSnapNamesByType(mockSnaps []string) {512func mockActiveSnapNamesByType(mockSnaps []string) {
513 ActiveSnapNamesByType = func(snapTs ...SnapType) (res []string, err error) {513 ActiveSnapNamesByType = func(snapTs ...pkg.Type) (res []string, err error) {
514 return mockSnaps, nil514 return mockSnaps, nil
515 }515 }
516}516}
@@ -1384,33 +1384,3 @@
1384 c.Assert(cmds[1], DeepEquals, aCmd{"udevadm", "trigger"})1384 c.Assert(cmds[1], DeepEquals, aCmd{"udevadm", "trigger"})
1385 c.Assert(cmds, HasLen, 2)1385 c.Assert(cmds, HasLen, 2)
1386}1386}
1387
1388type SnapTypeSuite struct{}
1389
1390var _ = Suite(&SnapTypeSuite{})
1391
1392func (s *SnapTypeSuite) TestMarshalTypes(c *C) {
1393 out, err := json.Marshal(SnapTypeApp)
1394 c.Assert(err, IsNil)
1395 c.Check(string(out), Equals, "\"app\"")
1396
1397 out, err = json.Marshal(SnapTypeOem)
1398 c.Assert(err, IsNil)
1399 c.Check(string(out), Equals, "\"oem\"")
1400}
1401
1402func (s *SnapTypeSuite) TestUnmarshalTypes(c *C) {
1403 var st SnapType
1404
1405 err := json.Unmarshal([]byte("\"application\""), &st)
1406 c.Assert(err, IsNil)
1407 c.Check(st, Equals, SnapTypeApp)
1408
1409 err = json.Unmarshal([]byte("\"app\""), &st)
1410 c.Assert(err, IsNil)
1411 c.Check(st, Equals, SnapTypeApp)
1412
1413 err = json.Unmarshal([]byte("\"oem\""), &st)
1414 c.Assert(err, IsNil)
1415 c.Check(st, Equals, SnapTypeOem)
1416}
14171387
=== modified file 'snappy/systemimage.go'
--- snappy/systemimage.go 2015-05-11 16:06:50 +0000
+++ snappy/systemimage.go 2015-05-19 11:17:28 +0000
@@ -32,6 +32,7 @@
32 "launchpad.net/snappy/helpers"32 "launchpad.net/snappy/helpers"
33 "launchpad.net/snappy/logger"33 "launchpad.net/snappy/logger"
34 "launchpad.net/snappy/partition"34 "launchpad.net/snappy/partition"
35 "launchpad.net/snappy/pkg"
35 "launchpad.net/snappy/progress"36 "launchpad.net/snappy/progress"
36)37)
3738
@@ -94,9 +95,9 @@
94 partition partition.Interface95 partition partition.Interface
95}96}
9697
97// Type returns SnapTypeCore for this snap98// Type returns pkg.TypeCore for this snap
98func (s *SystemImagePart) Type() SnapType {99func (s *SystemImagePart) Type() pkg.Type {
99 return SnapTypeCore100 return pkg.TypeCore
100}101}
101102
102// Name returns the name103// Name returns the name
103104
=== modified file 'snappy/udev.go'
--- snappy/udev.go 2015-04-22 07:11:43 +0000
+++ snappy/udev.go 2015-05-19 11:17:28 +0000
@@ -20,10 +20,12 @@
20import (20import (
21 "fmt"21 "fmt"
22 "path/filepath"22 "path/filepath"
23
24 "launchpad.net/snappy/pkg"
23)25)
2426
25func getUdevPartName(m *packageYaml, baseDir string) (string, error) {27func getUdevPartName(m *packageYaml, baseDir string) (string, error) {
26 if m.Type == SnapTypeFramework || m.Type == SnapTypeOem {28 if m.Type == pkg.TypeFramework || m.Type == pkg.TypeOem {
27 return m.Name, nil29 return m.Name, nil
28 }30 }
2931

Subscribers

People subscribed via source and target branches