예제 #1
0
파일: backend.go 프로젝트: dholbach/snappy
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
}
예제 #2
0
파일: api.go 프로젝트: dholbach/snappy
	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)