func (b *defaultBackend) Download(name, channel string, checker func(*snap.Info) error, meter progress.Meter, auther store.Authenticator) (*snap.Info, string, error) { mStore := snappy.NewConfiguredUbuntuStoreSnapRepository() snap, err := mStore.Snap(name, channel, auther) if err != nil { return nil, "", err } err = checker(snap) if err != nil { return nil, "", err } downloadedSnapFile, err := mStore.Download(snap, meter, auther) if err != nil { return nil, "", err } return snap, downloadedSnapFile, nil }
if macaroon == "" || len(discharges) == 0 { return nil, fmt.Errorf("invalid authorization header") } user, err := auth.CheckMacaroon(st, macaroon, discharges) return user, err } type metarepo interface { Snap(string, string, store.Authenticator) (*snap.Info, error) FindSnaps(string, string, store.Authenticator) ([]*snap.Info, error) SuggestedCurrency() string } var newRemoteRepo = func() metarepo { return snappy.NewConfiguredUbuntuStoreSnapRepository() } var muxVars = mux.Vars func getSnapInfo(c *Command, r *http.Request) Response { vars := muxVars(r) name := vars["name"] channel := "" remoteRepo := newRemoteRepo() suggestedCurrency := remoteRepo.SuggestedCurrency() localSnap, active, err := localSnapInfo(c.d.overlord.State(), name) if err != nil { return InternalError("%v", err)