tooling

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2022 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CurrentSnap

type CurrentSnap struct {
	SnapName string
	SnapID   string
	Revision snap.Revision
	Channel  string
	Epoch    snap.Epoch
}

type DownloadManyOptions

type DownloadManyOptions struct {
	BeforeDownloadFunc func(*snap.Info) (targetPath string, err error)
	EnforceValidation  bool
}

type DownloadSnapOptions

type DownloadSnapOptions struct {
	TargetDir string

	Revision  snap.Revision
	Channel   string
	CohortKey string
	Basename  string

	LeavePartialOnError bool
}

DownloadSnapOptions carries options for downloading snaps plus assertions.

func (*DownloadSnapOptions) String

func (opts *DownloadSnapOptions) String() string

type DownloadedSnap

type DownloadedSnap struct {
	Path            string
	Info            *snap.Info
	RedirectChannel string
}

type SimpleCreds

type SimpleCreds struct {
	Scheme string
	Value  string
}

SimpleCreds can authorize requests using simply scheme/auth value.

func (*SimpleCreds) Authorize

func (*SimpleCreds) CanAuthorizeForUser

func (c *SimpleCreds) CanAuthorizeForUser(_ *auth.UserState) bool

type SnapToDownload

type SnapToDownload struct {
	Snap      naming.SnapRef
	Channel   string
	CohortKey string
}

type StoreImpl

type StoreImpl interface {
	// SnapAction queries the store for snap information for the given install/refresh actions. Orthogonally it can be used to fetch or update assertions.
	SnapAction(context.Context, []*store.CurrentSnap, []*store.SnapAction, store.AssertionQuery, *auth.UserState, *store.RefreshOptions) ([]store.SnapActionResult, []store.AssertionResult, error)

	// Download downloads the snap addressed by download info
	Download(ctx context.Context, name, targetFn string, downloadInfo *snap.DownloadInfo, pbar progress.Meter, user *auth.UserState, dlOpts *store.DownloadOptions) error

	// Assertion retrieves the assertion for the given type and primary key.
	Assertion(assertType *asserts.AssertionType, primaryKey []string, user *auth.UserState) (asserts.Assertion, error)
}

A StoreImpl can find metadata on snaps, download snaps and fetch assertions. This interface is a subset of store.Store methods.

type ToolingStore

type ToolingStore struct {
	// Stdout is for output, mainly progress bars
	// left unset stdout is used
	Stdout io.Writer
	// contains filtered or unexported fields
}

ToolingStore wraps access to the store for tools.

func MockToolingStore

func MockToolingStore(sto StoreImpl) *ToolingStore

MockToolingStore creates a ToolingStore that uses the provided StoreImpl implementation for Download, SnapAction and Assertion methods. For testing.

func NewToolingStore

func NewToolingStore() (*ToolingStore, error)

NewToolingStore creates ToolingStore, with optional arch and store id read from UBUNTU_STORE_ARCH and UBUNTU_STORE_ID environment variables.

func NewToolingStoreFromModel

func NewToolingStoreFromModel(model *asserts.Model, fallbackArchitecture string) (*ToolingStore, error)

NewToolingStoreFromModel creates ToolingStore for the snap store used by the given model.

func (*ToolingStore) AssertionFetcher

func (tsto *ToolingStore) AssertionFetcher(db *asserts.Database, save func(asserts.Assertion) error) asserts.Fetcher

AssertionFetcher creates an asserts.Fetcher for assertions using dlOpts for authorization, the fetcher will add assertions in the given database and after that also call save for each of them.

func (*ToolingStore) DownloadMany

func (tsto *ToolingStore) DownloadMany(toDownload []SnapToDownload, curSnaps []*CurrentSnap, opts DownloadManyOptions) (downloadedSnaps map[string]*DownloadedSnap, err error)

DownloadMany downloads the specified snaps. curSnaps are meant to represent already downloaded snaps that will be installed in conjunction with the snaps to download, this is needed if enforcing validations (ops.EnforceValidation set to true) to have cross-gating work.

func (*ToolingStore) DownloadSnap

func (tsto *ToolingStore) DownloadSnap(name string, opts DownloadSnapOptions) (downloadedSnap *DownloadedSnap, err error)

DownloadSnap downloads the snap with the given name and options. It returns the final full path of the snap and a snap.Info for it and optionally a channel the snap got redirected to wrapped in DownloadedSnap.

func (*ToolingStore) Find

func (tsto *ToolingStore) Find(at *asserts.AssertionType, headers map[string]string) (asserts.Assertion, error)

Find provides the snapsserts.Finder interface for snapasserts.DerviceSideInfo

type UbuntuOneCreds

type UbuntuOneCreds struct {
	User auth.UserState
}

UbuntuOneCreds can authorize requests using the implicitly carried SSO/U1 user credentials.

func (*UbuntuOneCreds) Authorize

func (*UbuntuOneCreds) CanAuthorizeForUser

func (c *UbuntuOneCreds) CanAuthorizeForUser(_ *auth.UserState) bool

func (*UbuntuOneCreds) RefreshAuth

func (*UbuntuOneCreds) UpdateUserAuth

func (c *UbuntuOneCreds) UpdateUserAuth(user *auth.UserState, discharges []string) (*auth.UserState, error)

Jump to

Keyboard shortcuts

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