store

package
v0.0.0-...-41dd8df Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 17, 2016 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Overview

Package store has support to use the Ubuntu Store for querying and downloading of snaps, and the related services.

Index

Constants

View Source
const (
	DebugRequest = debugflag(1 << iota)
	DebugResponse
	DebugBody
)

set these via the Key environ

View Source
const (
	// UbuntuCoreWireProtocol is the protocol level we support when
	// communicating with the store. History:
	//  - "1": client supports squashfs snaps
	UbuntuCoreWireProtocol = "1"
)

Variables

View Source
var (

	// MyAppsPackageAccessAPI points to MyApps endpoint to get a package access macaroon
	MyAppsPackageAccessAPI = myappsAPIBase + "api/2.0/acl/package_access/"

	// UbuntuoneDischargeAPI points to SSO endpoint to discharge a macaroon
	UbuntuoneDischargeAPI = ubuntuoneAPIBase + "/tokens/discharge"
)
View Source
var (
	// ErrSnapNotFound is returned when a snap can not be found
	ErrSnapNotFound = errors.New("snap not found")

	// ErrAssertionNotFound is returned when an assertion can not be found
	ErrAssertionNotFound = errors.New("assertion not found")

	// ErrAuthenticationNeeds2fa is returned if the authentication needs 2factor
	ErrAuthenticationNeeds2fa = errors.New("two factor authentication required")

	// Err2faFailed is returned when 2fa failed (e.g., a bad token was given)
	Err2faFailed = errors.New("two factor authentication failed")

	// ErrInvalidCredentials is returned on login error
	ErrInvalidCredentials = errors.New("invalid credentials")
)

Functions

func DischargeAuthCaveat

func DischargeAuthCaveat(username, password, macaroon, otp string) (string, error)

DischargeAuthCaveat returns a macaroon with the store auth caveat discharged.

func RequestPackageAccessMacaroon

func RequestPackageAccessMacaroon() (string, error)

RequestPackageAccessMacaroon requests a macaroon for accessing package data from the ubuntu store.

Types

type Authenticator

type Authenticator interface {
	Authenticate(r *http.Request)
}

Authenticator interface to set required authorization headers for requests to the store

type ErrDownload

type ErrDownload struct {
	Code int
	URL  *url.URL
}

ErrDownload represents a download error

func (*ErrDownload) Error

func (e *ErrDownload) Error() string

type LoggedTransport

type LoggedTransport struct {
	Transport http.RoundTripper
	Key       string
}

LoggedTransport is an http.RoundTripper that can be used by http.Client to log request/response roundtrips.

func (*LoggedTransport) RoundTrip

func (tr *LoggedTransport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip is from the http.RoundTripper interface.

type RefreshCandidate

type RefreshCandidate struct {
	SnapID   string
	Revision snap.Revision
	Epoch    string
	DevMode  bool

	// the desired channel
	Channel string
}

RefreshCandidate contains information for the store about the currently installed snap so that the store can decide what update we should see

type SnapUbuntuStoreConfig

type SnapUbuntuStoreConfig struct {
	SearchURI     *url.URL
	BulkURI       *url.URL
	AssertionsURI *url.URL
	PurchasesURI  *url.URL
}

SnapUbuntuStoreConfig represents the configuration to access the snap store

type SnapUbuntuStoreRepository

type SnapUbuntuStoreRepository struct {
	// contains filtered or unexported fields
}

SnapUbuntuStoreRepository represents the ubuntu snap store

func NewUbuntuStoreSnapRepository

func NewUbuntuStoreSnapRepository(cfg *SnapUbuntuStoreConfig, storeID string) *SnapUbuntuStoreRepository

NewUbuntuStoreSnapRepository creates a new SnapUbuntuStoreRepository with the given access configuration and for given the store id.

func (*SnapUbuntuStoreRepository) Assertion

func (s *SnapUbuntuStoreRepository) Assertion(assertType *asserts.AssertionType, primaryKey []string, auther Authenticator) (asserts.Assertion, error)

Assertion retrivies the assertion for the given type and primary key.

func (*SnapUbuntuStoreRepository) Download

func (s *SnapUbuntuStoreRepository) Download(remoteSnap *snap.Info, pbar progress.Meter, auther Authenticator) (path string, err error)

Download downloads the given snap and returns its filename. The file is saved in temporary storage, and should be removed after use to prevent the disk from running out of space.

func (*SnapUbuntuStoreRepository) Find

func (s *SnapUbuntuStoreRepository) Find(searchTerm string, channel string, auther Authenticator) ([]*snap.Info, error)

Find finds (installable) snaps from the store, matching the given search term.

func (*SnapUbuntuStoreRepository) ListRefresh

func (s *SnapUbuntuStoreRepository) ListRefresh(installed []*RefreshCandidate, auther Authenticator) (snaps []*snap.Info, err error)

ListRefresh returns the available updates for a list of snap identified by fullname with channel.

func (*SnapUbuntuStoreRepository) Snap

func (s *SnapUbuntuStoreRepository) Snap(name, channel string, auther Authenticator) (*snap.Info, error)

Snap returns the snap.Info for the store hosted snap with the given name or an error.

func (*SnapUbuntuStoreRepository) SuggestedCurrency

func (s *SnapUbuntuStoreRepository) SuggestedCurrency() string

SuggestedCurrency retrieves the cached value for the store's suggested currency

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL