Documentation ¶
Overview ¶
Package store has support to use the Ubuntu Store for querying and downloading of snaps, and the related services.
Index ¶
- Constants
- Variables
- func DischargeAuthCaveat(username, password, macaroon, otp string) (string, error)
- func RequestPackageAccessMacaroon() (string, error)
- type Authenticator
- type ErrDownload
- type LoggedTransport
- type RefreshCandidate
- type SnapUbuntuStoreConfig
- type SnapUbuntuStoreRepository
- func (s *SnapUbuntuStoreRepository) Assertion(assertType *asserts.AssertionType, primaryKey []string, auther Authenticator) (asserts.Assertion, error)
- func (s *SnapUbuntuStoreRepository) Download(remoteSnap *snap.Info, pbar progress.Meter, auther Authenticator) (path string, err error)
- func (s *SnapUbuntuStoreRepository) Find(searchTerm string, channel string, auther Authenticator) ([]*snap.Info, error)
- func (s *SnapUbuntuStoreRepository) ListRefresh(installed []*RefreshCandidate, auther Authenticator) (snaps []*snap.Info, err error)
- func (s *SnapUbuntuStoreRepository) Snap(name, channel string, auther Authenticator) (*snap.Info, error)
- func (s *SnapUbuntuStoreRepository) SuggestedCurrency() string
Constants ¶
const ( DebugRequest = debugflag(1 << iota) DebugResponse DebugBody )
set these via the Key environ
const ( // UbuntuCoreWireProtocol is the protocol level we support when // communicating with the store. History: // - "1": client supports squashfs snaps UbuntuCoreWireProtocol = "1" )
Variables ¶
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" )
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 ¶
DischargeAuthCaveat returns a macaroon with the store auth caveat discharged.
func RequestPackageAccessMacaroon ¶
RequestPackageAccessMacaroon requests a macaroon for accessing package data from the ubuntu store.
Types ¶
type Authenticator ¶
Authenticator interface to set required authorization headers for requests to the store
type ErrDownload ¶
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.
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