Permalink
Browse files

obtain installed snaps developer/publisher username through snapd-dec…

…laration and publisher account assertion

drop this info from SideInfo and move the fields with the information for searches into snap.Info under
PublisherID/Publisher
  • Loading branch information...
1 parent 4b76c6c commit eb29d1797d921c243a1a38ad30c78bfc1f2becab @pedronis pedronis committed Dec 21, 2016
@@ -108,22 +108,10 @@ func DeriveSideInfo(snapPath string, db asserts.RODatabase) (*snap.SideInfo, err
name := snapDecl.SnapName()
- // TODO: once we are fully migrated to assertions this can
- // be done dynamically later instead of statically here
- a, err = db.Find(asserts.AccountType, map[string]string{
- "account-id": snapRev.DeveloperID(),
- })
- if err != nil {
- return nil, fmt.Errorf("internal error: cannot find developer account for snap %q (%q): %s", name, snapPath, snapRev.DeveloperID())
- }
- devAcct := a.(*asserts.Account)
-
return &snap.SideInfo{
- RealName: name,
- SnapID: snapID,
- Revision: snap.R(snapRev.SnapRevision()),
- DeveloperID: snapRev.DeveloperID(),
- Developer: devAcct.Username(),
+ RealName: name,
+ SnapID: snapID,
+ Revision: snap.R(snapRev.SnapRevision()),
}, nil
}
@@ -234,12 +234,10 @@ func (s *snapassertsSuite) TestDeriveSideInfoHappy(c *C) {
si, err := snapasserts.DeriveSideInfo(snapPath, s.localDB)
c.Assert(err, IsNil)
c.Check(si, DeepEquals, &snap.SideInfo{
- RealName: "foo",
- SnapID: "snap-id-1",
- Revision: snap.R(42),
- Channel: "",
- DeveloperID: s.dev1Acct.AccountID(),
- Developer: "developer1",
+ RealName: "foo",
+ SnapID: "snap-id-1",
+ Revision: snap.R(42),
+ Channel: "",
})
}
View
@@ -414,7 +414,7 @@ func getSnapInfo(c *Command, r *http.Request, user *auth.UserState) Response {
vars := muxVars(r)
name := vars["name"]
- localSnap, active, err := localSnapInfo(c.d.overlord.State(), name)
+ about, err := localSnapInfo(c.d.overlord.State(), name)
if err != nil {
if err == errNoSnap {
return NotFound("cannot find %q snap", name)
@@ -433,7 +433,7 @@ func getSnapInfo(c *Command, r *http.Request, user *auth.UserState) Response {
return InternalError("cannot build URL for %q snap: %v", name, err)
}
- result := webify(mapLocal(localSnap, active), url.String())
+ result := webify(mapLocal(about), url.String())
return SyncResponse(result, nil)
}
@@ -686,7 +686,7 @@ func getSnapsInfo(c *Command, r *http.Request, user *auth.UserState) Response {
continue
}
- data, err := json.Marshal(webify(mapLocal(x.info, x.snapst), url.String()))
+ data, err := json.Marshal(webify(mapLocal(x), url.String()))
if err != nil {
return InternalError("cannot serialize snap %q revision %s: %v", name, rev, err)
}
@@ -1386,15 +1386,15 @@ func unsafeReadSnapInfoImpl(snapPath string) (*snap.Info, error) {
var unsafeReadSnapInfo = unsafeReadSnapInfoImpl
func iconGet(st *state.State, name string) Response {
- info, _, err := localSnapInfo(st, name)
+ about, err := localSnapInfo(st, name)
if err != nil {
if err == errNoSnap {
return NotFound("cannot find snap %q", name)
}
return InternalError("%v", err)
}
- path := filepath.Clean(snapIcon(info))
+ path := filepath.Clean(snapIcon(about.info))
if !strings.HasPrefix(path, dirs.SnapMountDir) {
// XXX: how could this happen?
return BadRequest("requested icon is not in snap path")
Oops, something went wrong.

0 comments on commit eb29d17

Please sign in to comment.