summaryrefslogtreecommitdiff
diff options
authorMichael Vogt <mvo@debian.org>2016-05-12 12:37:01 -0700
committerMichael Vogt <mvo@debian.org>2016-05-12 12:37:01 -0700
commit6f283c17f711850a482041a60db0bbfda9e9e692 (patch)
tree3b1d351aec5fc13d819aee7a83ba880f8c3f972f
parent8337c7ddf05daa678ecd04732dcd37417692c63f (diff)
make revision a typerefactor/sideloaded-revisions
-rw-r--r--daemon/api_test.go8
-rw-r--r--overlord/snapstate/backend_test.go6
-rw-r--r--overlord/snapstate/snapmgr.go16
-rw-r--r--overlord/snapstate/snapmgr_test.go20
-rw-r--r--overlord/snapstate/snapstate.go4
-rw-r--r--snap/info.go30
-rw-r--r--snap/info_test.go8
-rw-r--r--snappy/common_test.go4
-rw-r--r--snappy/info.go6
-rw-r--r--snappy/install_test.go3
-rw-r--r--snappy/kernel_os.go8
-rw-r--r--snappy/kernel_os_test.go9
-rw-r--r--snappy/overlord_test.go12
-rw-r--r--snappy/snap_local.go5
-rw-r--r--snappy/snapp_snapfs_test.go2
-rw-r--r--snappy/snapp_test.go26
-rw-r--r--snappy/utils.go15
-rw-r--r--store/details.go2
-rw-r--r--store/store_test.go4
-rw-r--r--wrappers/binaries.go2
-rw-r--r--wrappers/services.go2
21 files changed, 100 insertions, 92 deletions
diff --git a/daemon/api_test.go b/daemon/api_test.go
index 07918c5556..c154b8db16 100644
--- a/daemon/api_test.go
+++ b/daemon/api_test.go
@@ -159,11 +159,11 @@ func (s *apiSuite) mkManifest(c *check.C, pkgType snap.Type) {
}), check.IsNil)
}
-func (s *apiSuite) mkInstalled(c *check.C, name, developer, version string, revno int, active bool, extraYaml string) *snap.Info {
+func (s *apiSuite) mkInstalled(c *check.C, name, developer, version string, revno snap.Revision, active bool, extraYaml string) *snap.Info {
return s.mkInstalledInState(c, nil, name, developer, version, revno, active, extraYaml)
}
-func (s *apiSuite) mkInstalledInState(c *check.C, daemon *Daemon, name, developer, version string, revno int, active bool, extraYaml string) *snap.Info {
+func (s *apiSuite) mkInstalledInState(c *check.C, daemon *Daemon, name, developer, version string, revno snap.Revision, active bool, extraYaml string) *snap.Info {
// Collect arguments into a snap.SideInfo structure
sideInfo := &snap.SideInfo{
SnapID: "funky-snap-id",
@@ -254,7 +254,7 @@ func (s *apiSuite) TestSnapInfoOneIntegration(c *check.C) {
Result: map[string]interface{}{
"id": "funky-snap-id",
"name": "foo",
- "revision": 10,
+ "revision": snap.Revision(10),
"version": "v1",
"summary": "summary",
"description": "description",
@@ -695,7 +695,7 @@ func (s *apiSuite) TestSnapsInfoOnePerIntegration(c *check.C) {
name string
dev string
ver string
- rev int
+ rev snap.Revision
}
tsnaps := []tsnap{
diff --git a/overlord/snapstate/backend_test.go b/overlord/snapstate/backend_test.go
index 2a63fc9aae..c4188c6594 100644
--- a/overlord/snapstate/backend_test.go
+++ b/overlord/snapstate/backend_test.go
@@ -36,7 +36,7 @@ type fakeOp struct {
macaroon string
name string
- revno int
+ revno snap.Revision
channel string
flags int
active bool
@@ -69,7 +69,7 @@ func (f *fakeSnappyBackend) Download(name, channel string, checker func(*snap.In
p.SetTotal(float64(f.fakeTotalProgress))
p.Set(float64(f.fakeCurrentProgress))
- revno := 11
+ revno := snap.Revision(11)
if channel == "channel-for-7" {
revno = 7
}
@@ -107,7 +107,7 @@ func (f *fakeSnappyBackend) CheckSnap(snapFilePath string, curInfo *snap.Info, f
}
func (f *fakeSnappyBackend) SetupSnap(snapFilePath string, si *snap.SideInfo, flags int) error {
- revno := 0
+ revno := snap.Revision(0)
if si != nil {
revno = si.Revision
}
diff --git a/overlord/snapstate/snapmgr.go b/overlord/snapstate/snapmgr.go
index b33323de87..4567ce6b46 100644
--- a/overlord/snapstate/snapmgr.go
+++ b/overlord/snapstate/snapmgr.go
@@ -42,10 +42,10 @@ type SnapManager struct {
// SnapSetup holds the necessary snap details to perform most snap manager tasks.
type SnapSetup struct {
- Name string `json:"name"`
- Revision int `json:"revision,omitempty"`
- Channel string `json:"channel,omitempty"`
- UserID int `json:"user-id,omitempty"`
+ Name string `json:"name"`
+ Revision snap.Revision `json:"revision,omitempty"`
+ Channel string `json:"channel,omitempty"`
+ UserID int `json:"user-id,omitempty"`
Flags int `json:"flags,omitempty"`
@@ -80,7 +80,7 @@ type SnapState struct {
Channel string `json:"channel,omitempty"`
Flags SnapStateFlags `json:"flags,omitempty"`
// incremented revision used for local installs
- LocalRevision int `json:"local-revision,omitempty"`
+ LocalRevision snap.Revision `json:"local-revision,omitempty"`
}
// Current returns the side info for the current revision in the snap revision sequence if there is one.
@@ -138,7 +138,7 @@ func Manager(s *state.State) (*SnapManager, error) {
return m, nil
}
-func checkRevisionIsNew(name string, snapst *SnapState, revision int) error {
+func checkRevisionIsNew(name string, snapst *SnapState, revision snap.Revision) error {
for _, si := range snapst.Sequence {
if si.Revision == revision {
return fmt.Errorf("revision %d of snap %q already installed", revision, name)
@@ -147,7 +147,7 @@ func checkRevisionIsNew(name string, snapst *SnapState, revision int) error {
return nil
}
-const firstLocalRevision = 100001
+const firstLocalRevision = snap.Revision(100001)
func (m *SnapManager) doPrepareSnap(t *state.Task, _ *tomb.Tomb) error {
st := t.State()
@@ -158,7 +158,7 @@ func (m *SnapManager) doPrepareSnap(t *state.Task, _ *tomb.Tomb) error {
return err
}
- if ss.Revision == 0 { // sideloading
+ if ss.Revision == snap.Revision(0) { // sideloading
// to not clash with not sideload installs
// and to not have clashes between them
// use incremental revisions starting at 100001
diff --git a/overlord/snapstate/snapmgr_test.go b/overlord/snapstate/snapmgr_test.go
index 2fac9c426a..4f0c4483da 100644
--- a/overlord/snapstate/snapmgr_test.go
+++ b/overlord/snapstate/snapmgr_test.go
@@ -830,7 +830,7 @@ version: 1.0`)
Channel: "",
Revision: 100001,
})
- c.Assert(snapst.LocalRevision, Equals, 100001)
+ c.Assert(snapst.LocalRevision, Equals, snap.Revision(100001))
}
func (s *snapmgrTestSuite) TestInstallSubequentLocalIntegration(c *C) {
@@ -869,7 +869,7 @@ version: 1.0`)
c.Check(s.fakeBackend.ops[4].op, Equals, "setup-profiles:Doing")
c.Check(s.fakeBackend.ops[4].name, Equals, "mock")
- c.Check(s.fakeBackend.ops[4].revno, Equals, 100003)
+ c.Check(s.fakeBackend.ops[4].revno, Equals, snap.Revision(100003))
c.Check(s.fakeBackend.ops[5].op, Equals, "candidate")
c.Check(s.fakeBackend.ops[5].sinfo, DeepEquals, snap.SideInfo{Revision: 100003})
@@ -900,7 +900,7 @@ version: 1.0`)
Channel: "",
Revision: 100003,
})
- c.Assert(snapst.LocalRevision, Equals, 100003)
+ c.Assert(snapst.LocalRevision, Equals, snap.Revision(100003))
}
func (s *snapmgrTestSuite) TestRemoveIntegration(c *C) {
@@ -1075,7 +1075,7 @@ func (s *snapmgrTestSuite) TestRemoveWithManyRevisionsIntegration(c *C) {
// verify snapSetup info
tasks := ts.Tasks()
- revnos := []int{7, 3, 5}
+ revnos := []snap.Revision{7, 3, 5}
whichRevno := 0
for _, t := range tasks {
ss, err := snapstate.TaskSnapSetup(t)
@@ -1153,7 +1153,7 @@ func (s *snapmgrQuerySuite) TestInfo(c *C) {
c.Assert(err, IsNil)
c.Check(info.Name(), Equals, "name1")
- c.Check(info.Revision, Equals, 11)
+ c.Check(info.Revision, Equals, snap.Revision(11))
c.Check(info.Summary(), Equals, "s11")
c.Check(info.Version, Equals, "1.1")
c.Check(info.Description(), Equals, "Lots of text")
@@ -1168,7 +1168,7 @@ func (s *snapmgrQuerySuite) TestCurrent(c *C) {
c.Assert(err, IsNil)
c.Check(info.Name(), Equals, "name1")
- c.Check(info.Revision, Equals, 12)
+ c.Check(info.Revision, Equals, snap.Revision(12))
}
func (s *snapmgrQuerySuite) TestActiveInfos(c *C) {
@@ -1182,7 +1182,7 @@ func (s *snapmgrQuerySuite) TestActiveInfos(c *C) {
c.Check(infos, HasLen, 1)
c.Check(infos[0].Name(), Equals, "name1")
- c.Check(infos[0].Revision, Equals, 12)
+ c.Check(infos[0].Revision, Equals, snap.Revision(12))
c.Check(infos[0].Summary(), Equals, "s12")
c.Check(infos[0].Version, Equals, "1.2")
c.Check(infos[0].Description(), Equals, "Lots of text")
@@ -1211,7 +1211,7 @@ version: gadget
c.Assert(err, IsNil)
c.Check(info.Name(), Equals, "gadget")
- c.Check(info.Revision, Equals, 2)
+ c.Check(info.Revision, Equals, snap.Revision(2))
c.Check(info.Version, Equals, "gadget")
c.Check(info.Type, Equals, snap.TypeGadget)
}
@@ -1240,7 +1240,7 @@ func (s *snapmgrQuerySuite) TestAll(c *C) {
c.Assert(err, IsNil)
c.Check(info12.Name(), Equals, "name1")
- c.Check(info12.Revision, Equals, 12)
+ c.Check(info12.Revision, Equals, snap.Revision(12))
c.Check(info12.Summary(), Equals, "s12")
c.Check(info12.Version, Equals, "1.2")
c.Check(info12.Description(), Equals, "Lots of text")
@@ -1249,7 +1249,7 @@ func (s *snapmgrQuerySuite) TestAll(c *C) {
c.Assert(err, IsNil)
c.Check(info11.Name(), Equals, "name1")
- c.Check(info11.Revision, Equals, 11)
+ c.Check(info11.Revision, Equals, snap.Revision(11))
c.Check(info11.Version, Equals, "1.1")
}
diff --git a/overlord/snapstate/snapstate.go b/overlord/snapstate/snapstate.go
index d833d96596..39a01695b5 100644
--- a/overlord/snapstate/snapstate.go
+++ b/overlord/snapstate/snapstate.go
@@ -161,7 +161,7 @@ func Update(s *state.State, name, channel string, userID int, flags snappy.Insta
return doInstall(s, snapst.Active, name, "", channel, userID, flags)
}
-func removeInactiveRevision(s *state.State, name string, revision int, flags snappy.RemoveFlags) *state.TaskSet {
+func removeInactiveRevision(s *state.State, name string, revision snap.Revision, flags snappy.RemoveFlags) *state.TaskSet {
ss := SnapSetup{
Name: name,
Revision: revision,
@@ -267,7 +267,7 @@ var readInfo = snap.ReadInfo
// Info returns the information about the snap with given name and revision.
// Works also for a mounted candidate snap in the process of being installed.
-func Info(s *state.State, name string, revision int) (*snap.Info, error) {
+func Info(s *state.State, name string, revision snap.Revision) (*snap.Info, error) {
var snapst SnapState
err := Get(s, name, &snapst)
if err == state.ErrNoState {
diff --git a/snap/info.go b/snap/info.go
index 7d4daa6dc8..18eb3e7573 100644
--- a/snap/info.go
+++ b/snap/info.go
@@ -31,6 +31,10 @@ import (
"github.com/ubuntu-core/snappy/timeout"
)
+// FIXME: make this a struct and add a special unmarshal that will deal
+// with both int and string
+type Revision int
+
// PlaceInfo offers all the information about where a snap and its data are located and exposed in the filesystem.
type PlaceInfo interface {
// Name returns the name of the snap.
@@ -56,13 +60,13 @@ type PlaceInfo interface {
}
// MinimalPlaceInfo returns a PlaceInfo with just the location information for a snap of the given name and revision.
-func MinimalPlaceInfo(name string, revision int) PlaceInfo {
+func MinimalPlaceInfo(name string, revision Revision) PlaceInfo {
return &Info{SideInfo: SideInfo{OfficialName: name, Revision: revision}}
}
// MountDir returns the base directory where it gets mounted of the snap with the given name and revision.
-func MountDir(name string, revision int) string {
- return filepath.Join(dirs.SnapSnapsDir, name, strconv.Itoa(revision))
+func MountDir(name string, revision Revision) string {
+ return filepath.Join(dirs.SnapSnapsDir, name, strconv.Itoa(int(revision)))
}
// SideInfo holds snap metadata that is crucial for the tracking of
@@ -78,15 +82,15 @@ func MountDir(name string, revision int) string {
// from the store but is not required for working offline should not
// end up in SideInfo.
type SideInfo struct {
- OfficialName string `yaml:"name,omitempty" json:"name,omitempty"`
- SnapID string `yaml:"snap-id" json:"snap-id"`
- Revision int `yaml:"revision" json:"revision"`
- Channel string `yaml:"channel,omitempty" json:"channel,omitempty"`
- Developer string `yaml:"developer,omitempty" json:"developer,omitempty"`
- EditedSummary string `yaml:"summary,omitempty" json:"summary,omitempty"`
- EditedDescription string `yaml:"description,omitempty" json:"description,omitempty"`
- Size int64 `yaml:"size,omitempty" json:"size,omitempty"`
- Sha512 string `yaml:"sha512,omitempty" json:"sha512,omitempty"`
+ OfficialName string `yaml:"name,omitempty" json:"name,omitempty"`
+ SnapID string `yaml:"snap-id" json:"snap-id"`
+ Revision Revision `yaml:"revision" json:"revision"`
+ Channel string `yaml:"channel,omitempty" json:"channel,omitempty"`
+ Developer string `yaml:"developer,omitempty" json:"developer,omitempty"`
+ EditedSummary string `yaml:"summary,omitempty" json:"summary,omitempty"`
+ EditedDescription string `yaml:"description,omitempty" json:"description,omitempty"`
+ Size int64 `yaml:"size,omitempty" json:"size,omitempty"`
+ Sha512 string `yaml:"sha512,omitempty" json:"sha512,omitempty"`
}
// Info provides information about snaps.
@@ -146,7 +150,7 @@ func (s *Info) Description() string {
}
func (s *Info) strRevno() string {
- return strconv.Itoa(s.Revision)
+ return strconv.Itoa(int(s.Revision))
}
// MountDir returns the base directory of the snap where it gets mounted.
diff --git a/snap/info_test.go b/snap/info_test.go
index aa9e0c232f..b3784a121e 100644
--- a/snap/info_test.go
+++ b/snap/info_test.go
@@ -62,7 +62,7 @@ func (s *infoSuite) TestSideInfoOverrides(c *C) {
c.Check(info.Name(), Equals, "newname")
c.Check(info.Summary(), Equals, "fixed summary")
c.Check(info.Description(), Equals, "fixed desc")
- c.Check(info.Revision, Equals, 1)
+ c.Check(info.Revision, Equals, snap.Revision(1))
c.Check(info.SnapID, Equals, "snapidsnapidsnapidsnapidsnapidsn")
}
@@ -117,7 +117,7 @@ func (s *infoSuite) TestReadInfo(c *C) {
c.Assert(err, IsNil)
c.Check(snapInfo2.Name(), Equals, "sample")
- c.Check(snapInfo2.Revision, Equals, 42)
+ c.Check(snapInfo2.Revision, Equals, snap.Revision(42))
c.Check(snapInfo2.Summary(), Equals, "esummary")
c.Check(snapInfo2.Apps["app"].Command, Equals, "foo")
@@ -157,7 +157,7 @@ type: app`
c.Check(info.Name(), Equals, "foo")
c.Check(info.Version, Equals, "1.0")
c.Check(info.Type, Equals, snap.TypeApp)
- c.Check(info.Revision, Equals, 0)
+ c.Check(info.Revision, Equals, snap.Revision(0))
}
func (s *infoSuite) TestReadInfoFromSnapFileWithSideInfo(c *C) {
@@ -177,7 +177,7 @@ type: app`
c.Check(info.Name(), Equals, "baz")
c.Check(info.Version, Equals, "1.0")
c.Check(info.Type, Equals, snap.TypeApp)
- c.Check(info.Revision, Equals, 42)
+ c.Check(info.Revision, Equals, snap.Revision(42))
}
func (s *infoSuite) TestReadInfoFromSnapFileValidates(c *C) {
diff --git a/snappy/common_test.go b/snappy/common_test.go
index 791f65b727..46fc1f381a 100644
--- a/snappy/common_test.go
+++ b/snappy/common_test.go
@@ -71,7 +71,7 @@ apps:
if err != nil {
return "", err
}
- info.SideInfo = snap.SideInfo{Revision: revno}
+ info.SideInfo = snap.SideInfo{Revision: snap.Revision(revno)}
metaDir := filepath.Join(info.MountDir(), "meta")
if err := os.MkdirAll(metaDir, 0775); err != nil {
@@ -84,7 +84,7 @@ apps:
si := snap.SideInfo{
OfficialName: info.Name(),
- Revision: revno,
+ Revision: snap.Revision(revno),
Developer: testDeveloper,
Channel: "remote-channel",
EditedSummary: "hello in summary",
diff --git a/snappy/info.go b/snappy/info.go
index df29b0eb1e..754d9e79d9 100644
--- a/snappy/info.go
+++ b/snappy/info.go
@@ -159,7 +159,7 @@ func FindSnapsByNameAndVersion(needle, version string, haystack []*Snap) []*Snap
// FindSnapsByNameAndRevision returns the snaps with the name/version in the
// given slice of snaps
-func FindSnapsByNameAndRevision(needle string, revision int, haystack []*Snap) []*Snap {
+func FindSnapsByNameAndRevision(needle string, revision snap.Revision, haystack []*Snap) []*Snap {
name, developer := SplitDeveloper(needle)
ignorens := developer == ""
var found []*Snap
@@ -199,8 +199,8 @@ func PackageNameActive(name string) bool {
}
// manifestPath returns the would be path for the snap manifest.
-func manifestPath(name string, revno int) string {
- return filepath.Join(dirs.SnapMetaDir, fmt.Sprintf("%s_%d.manifest", name, revno))
+func manifestPath(name string, revno snap.Revision) string {
+ return filepath.Join(dirs.SnapMetaDir, fmt.Sprintf("%s_%d.manifest", name, int(revno)))
}
// SaveManifest saves the manifest at the designated location for the snap containing information not in the snap.yaml.
diff --git a/snappy/install_test.go b/snappy/install_test.go
index c4732ff8fa..e1c2fe09a9 100644
--- a/snappy/install_test.go
+++ b/snappy/install_test.go
@@ -33,6 +33,7 @@ import (
"github.com/ubuntu-core/snappy/dirs"
"github.com/ubuntu-core/snappy/progress"
+ "github.com/ubuntu-core/snappy/snap"
)
func (s *SnapTestSuite) TestInstallInstall(c *C) {
@@ -285,7 +286,7 @@ func (s *SnapTestSuite) TestUpdate(c *C) {
c.Assert(updates, HasLen, 1)
c.Check(updates[0].Name(), Equals, "foo")
c.Check(updates[0].Version(), Equals, "2")
- c.Check(updates[0].Revision(), Equals, 3)
+ c.Check(updates[0].Revision(), Equals, snap.Revision(3))
// ensure that we get a "local" snap back - not a remote one
c.Check(updates[0], FitsTypeOf, &Snap{})
}
diff --git a/snappy/kernel_os.go b/snappy/kernel_os.go
index 7de4c56eda..7577646539 100644
--- a/snappy/kernel_os.go
+++ b/snappy/kernel_os.go
@@ -185,14 +185,14 @@ func kernelOrOsRebootRequired(s *snap.Info) bool {
return false
}
-func nameAndRevnoFromSnap(snap string) (string, int) {
- name := strings.Split(snap, "_")[0]
- revnoNSuffix := strings.Split(snap, "_")[1]
+func nameAndRevnoFromSnap(sn string) (string, snap.Revision) {
+ name := strings.Split(sn, "_")[0]
+ revnoNSuffix := strings.Split(sn, "_")[1]
revno, err := strconv.Atoi(strings.Split(revnoNSuffix, ".snap")[0])
if err != nil {
return "", -1
}
- return name, revno
+ return name, snap.Revision(revno)
}
// SyncBoot synchronizes the active kernel and OS snap versions with
diff --git a/snappy/kernel_os_test.go b/snappy/kernel_os_test.go
index a445d0bb0c..a7e879297e 100644
--- a/snappy/kernel_os_test.go
+++ b/snappy/kernel_os_test.go
@@ -22,6 +22,7 @@ package snappy
import (
"github.com/ubuntu-core/snappy/dirs"
"github.com/ubuntu-core/snappy/partition"
+ "github.com/ubuntu-core/snappy/snap"
. "gopkg.in/check.v1"
)
@@ -43,11 +44,11 @@ func (s *kernelTestSuite) SetUpTest(c *C) {
func (s *kernelTestSuite) TestNameAndRevnoFromSnap(c *C) {
name, revno := nameAndRevnoFromSnap("canonical-pc-linux.canonical_101.snap")
c.Check(name, Equals, "canonical-pc-linux.canonical")
- c.Check(revno, Equals, 101)
+ c.Check(revno, Equals, snap.Revision(101))
name, revno = nameAndRevnoFromSnap("ubuntu-core.canonical_103.snap")
c.Check(name, Equals, "ubuntu-core.canonical")
- c.Check(revno, Equals, 103)
+ c.Check(revno, Equals, snap.Revision(103))
}
var kernelYaml = `name: linux
@@ -80,7 +81,7 @@ func (s *kernelTestSuite) TestSyncBoot(c *C) {
found := FindSnapsByNameAndRevision("linux", 21, installed)
c.Assert(found, HasLen, 1)
c.Assert(found[0].Name(), Equals, "linux")
- c.Assert(found[0].Revision(), Equals, 21)
+ c.Assert(found[0].Revision(), Equals, snap.Revision(21))
c.Assert(found[0].Version(), Equals, "v2")
c.Assert(found[0].IsActive(), Equals, true)
@@ -102,7 +103,7 @@ func (s *kernelTestSuite) TestSyncBoot(c *C) {
found = FindSnapsByNameAndVersion("linux", "v1", installed)
c.Assert(found, HasLen, 1)
c.Assert(found[0].Name(), Equals, "linux")
- c.Assert(found[0].Revision(), Equals, 20)
+ c.Assert(found[0].Revision(), Equals, snap.Revision(20))
c.Assert(found[0].Version(), Equals, "v1")
c.Assert(found[0].IsActive(), Equals, true)
}
diff --git a/snappy/overlord_test.go b/snappy/overlord_test.go
index 6d61499dda..050038a4fe 100644
--- a/snappy/overlord_test.go
+++ b/snappy/overlord_test.go
@@ -86,10 +86,10 @@ func (s *SnapTestSuite) TestLocalSnapInstallWithBlessedMetadata(c *C) {
Revision: 40,
}
- snap, err := (&Overlord{}).InstallWithSideInfo(snapPath, si, 0, nil)
+ sn, err := (&Overlord{}).InstallWithSideInfo(snapPath, si, 0, nil)
c.Assert(err, IsNil)
- c.Check(snap.Name(), Equals, "foo")
- c.Check(snap.Revision, Equals, 40)
+ c.Check(sn.Name(), Equals, "foo")
+ c.Check(sn.Revision, Equals, snap.Revision(40))
baseDir := filepath.Join(dirs.SnapSnapsDir, fooComposedName, "40")
c.Assert(osutil.FileExists(baseDir), Equals, true)
@@ -109,10 +109,10 @@ func (s *SnapTestSuite) TestLocalSnapInstallWithBlessedMetadataOverridingName(c
Revision: 55,
}
- snap, err := (&Overlord{}).InstallWithSideInfo(snapPath, si, 0, nil)
+ sn, err := (&Overlord{}).InstallWithSideInfo(snapPath, si, 0, nil)
c.Assert(err, IsNil)
- c.Check(snap.Name(), Equals, "bar")
- c.Check(snap.Revision, Equals, 55)
+ c.Check(sn.Name(), Equals, "bar")
+ c.Check(sn.Revision, Equals, snap.Revision(55))
baseDir := filepath.Join(dirs.SnapSnapsDir, "bar", "55")
c.Assert(osutil.FileExists(baseDir), Equals, true)
diff --git a/snappy/snap_local.go b/snappy/snap_local.go
index ebe2b9ce05..f719a85412 100644
--- a/snappy/snap_local.go
+++ b/snappy/snap_local.go
@@ -47,10 +47,11 @@ func NewInstalledSnap(yamlPath string) (*Snap, error) {
// snapstate primitives shouldn't need this
name := filepath.Base(filepath.Dir(mountDir))
revnoStr := filepath.Base(mountDir)
- revno, err := strconv.Atoi(revnoStr)
+ revnoInt, err := strconv.Atoi(revnoStr)
if err != nil {
return nil, fmt.Errorf("broken snap directory path: %q", mountDir)
}
+ revno := snap.Revision(revnoInt)
s := &Snap{}
@@ -120,7 +121,7 @@ func (s *Snap) Version() string {
}
// Revision returns the revision
-func (s *Snap) Revision() int {
+func (s *Snap) Revision() snap.Revision {
return s.info.Revision
}
diff --git a/snappy/snapp_snapfs_test.go b/snappy/snapp_snapfs_test.go
index 32dd287668..7c7d0fba9d 100644
--- a/snappy/snapp_snapfs_test.go
+++ b/snappy/snapp_snapfs_test.go
@@ -125,7 +125,7 @@ func (s *SquashfsTestSuite) TestOpenSnapFilebSideInfo(c *C) {
// check side info
c.Check(info.Name(), Equals, "blessed")
- c.Check(info.Revision, Equals, 42)
+ c.Check(info.Revision, Equals, snap.Revision(42))
}
func (s *SquashfsTestSuite) TestInstallViaSquashfsWorks(c *C) {
diff --git a/snappy/snapp_test.go b/snappy/snapp_test.go
index c4b92b0d51..3c3dd41581 100644
--- a/snappy/snapp_test.go
+++ b/snappy/snapp_test.go
@@ -100,17 +100,17 @@ func (s *SnapTestSuite) TestLocalSnapSimple(c *C) {
snapYaml, err := makeInstalledMockSnap("", 15)
c.Assert(err, IsNil)
- snap, err := NewInstalledSnap(snapYaml)
+ sn, err := NewInstalledSnap(snapYaml)
c.Assert(err, IsNil)
- c.Assert(snap, NotNil)
- c.Check(snap.Name(), Equals, "hello-snap")
- c.Check(snap.Version(), Equals, "1.10")
- c.Check(snap.IsActive(), Equals, false)
- c.Check(snap.Info().Summary(), Equals, "hello in summary")
- c.Check(snap.Info().Description(), Equals, "Hello...")
- c.Check(snap.Info().Revision, Equals, 15)
-
- mountDir := snap.Info().MountDir()
+ c.Assert(sn, NotNil)
+ c.Check(sn.Name(), Equals, "hello-snap")
+ c.Check(sn.Version(), Equals, "1.10")
+ c.Check(sn.IsActive(), Equals, false)
+ c.Check(sn.Info().Summary(), Equals, "hello in summary")
+ c.Check(sn.Info().Description(), Equals, "Hello...")
+ c.Check(sn.Info().Revision, Equals, snap.Revision(15))
+
+ mountDir := sn.Info().MountDir()
_, err = os.Stat(mountDir)
c.Assert(err, IsNil)
@@ -206,7 +206,7 @@ func (s *SnapTestSuite) TestUbuntuStoreRepositoryUpdates(c *C) {
c.Assert(err, IsNil)
c.Assert(results, HasLen, 1)
c.Assert(results[0].Name(), Equals, funkyAppName)
- c.Assert(results[0].Revision, Equals, 3)
+ c.Assert(results[0].Revision, Equals, snap.Revision(3))
c.Assert(results[0].Version, Equals, "42")
}
@@ -266,7 +266,7 @@ func (s *SnapTestSuite) TestUbuntuStoreRepositoryInstallRemoteSnap(c *C) {
r := &snap.Info{}
r.OfficialName = "foo"
- r.Revision = 42
+ r.Revision = snap.Revision(42)
r.Developer = "bar"
r.EditedDescription = "this is a description"
r.Version = "1.0"
@@ -287,7 +287,7 @@ func (s *SnapTestSuite) TestUbuntuStoreRepositoryInstallRemoteSnap(c *C) {
c.Assert(err, IsNil)
c.Assert(installed, HasLen, 1)
- c.Check(installed[0].Info().Revision, Equals, 42)
+ c.Check(installed[0].Info().Revision, Equals, snap.Revision(42))
c.Check(installed[0].Developer(), Equals, "bar")
c.Check(installed[0].Info().Description(), Equals, "this is a description")
diff --git a/snappy/utils.go b/snappy/utils.go
index 1a7c1120e0..e5981248b0 100644
--- a/snappy/utils.go
+++ b/snappy/utils.go
@@ -25,6 +25,7 @@ import (
"github.com/ubuntu-core/snappy/arch"
"github.com/ubuntu-core/snappy/dirs"
+ "github.com/ubuntu-core/snappy/snap"
"github.com/ubuntu-core/snappy/snap/snapenv"
)
@@ -47,21 +48,21 @@ func stripGlobalRootDirImpl(dir string) string {
// The returned environment contains additional SNAP_* variables that
// are required when calling a meta/hook/ script and that will override
// any already existing SNAP_* variables in os.Environment()
-func makeSnapHookEnv(snap *Snap) (env []string) {
+func makeSnapHookEnv(sn *Snap) (env []string) {
desc := struct {
SnapName string
SnapArch string
SnapPath string
Version string
- Revision int
+ Revision snap.Revision
UdevAppName string
}{
- snap.Name(),
+ sn.Name(),
arch.UbuntuArchitecture(),
- snap.Info().MountDir(),
- snap.Version(),
- snap.Revision(),
- snap.Name(),
+ sn.Info().MountDir(),
+ sn.Version(),
+ sn.Revision(),
+ sn.Name(),
}
vars := snapenv.GetBasicSnapEnvVars(desc)
diff --git a/store/details.go b/store/details.go
index 84b9bff300..46c2d8cf1a 100644
--- a/store/details.go
+++ b/store/details.go
@@ -42,7 +42,7 @@ type snapDetails struct {
Prices map[string]float64 `json:"prices,omitempty"`
Publisher string `json:"publisher,omitempty"`
RatingsAverage float64 `json:"ratings_average,omitempty"`
- Revision int `json:"revision"`
+ Revision snap.Revision `json:"revision"`
SnapID string `json:"snap_id"`
SupportURL string `json:"support_url"`
Title string `json:"title"`
diff --git a/store/store_test.go b/store/store_test.go
index 6d6ba4defb..1694b9a74a 100644
--- a/store/store_test.go
+++ b/store/store_test.go
@@ -318,7 +318,7 @@ func (t *remoteRepoTestSuite) TestUbuntuStoreRepositoryDetails(c *C) {
c.Assert(err, IsNil)
c.Check(result.Name(), Equals, "hello-world")
c.Check(result.Architectures, DeepEquals, []string{"all"})
- c.Check(result.Revision, Equals, 25)
+ c.Check(result.Revision, Equals, snap.Revision(25))
c.Check(result.SnapID, Equals, helloWorldSnapID)
c.Check(result.Developer, Equals, "canonical")
c.Check(result.Version, Equals, "6.0")
@@ -673,7 +673,7 @@ func (t *remoteRepoTestSuite) TestUbuntuStoreRepositoryUpdates(c *C) {
c.Assert(err, IsNil)
c.Assert(results, HasLen, 1)
c.Assert(results[0].Name(), Equals, funkyAppName)
- c.Assert(results[0].Revision, Equals, 3)
+ c.Assert(results[0].Revision, Equals, snap.Revision(3))
c.Assert(results[0].Version, Equals, "42")
}
diff --git a/wrappers/binaries.go b/wrappers/binaries.go
index 9937ab70a1..34a917232c 100644
--- a/wrappers/binaries.go
+++ b/wrappers/binaries.go
@@ -72,7 +72,7 @@ export HOME="$SNAP_USER_DATA"
SnapArch string
SnapPath string
Version string
- Revision int
+ Revision snap.Revision
Home string
}{
App: app,
diff --git a/wrappers/services.go b/wrappers/services.go
index a6acd0ccfe..53b2c01d40 100644
--- a/wrappers/services.go
+++ b/wrappers/services.go
@@ -231,7 +231,7 @@ WantedBy={{.ServiceTargetUnit}}
SnapArch string
SnapPath string
Version string
- Revision int
+ Revision snap.Revision
Home string
}{
App: appInfo,