tooling

package
v0.0.0-...-f890545 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: GPL-3.0 Imports: 27 Imported by: 4

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, map[string]*snap.ComponentInfo) (targetPath string, compPaths map[string]string, err error)
	EnforceValidation  bool
}

type DownloadSnapOptions

type DownloadSnapOptions struct {
	TargetDir string

	Revision  snap.Revision
	Channel   string
	CohortKey string
	Basename  string

	LeavePartialOnError bool
	// OnlyComponents is set if we only want to download the
	// specified components and not the snap
	OnlyComponents bool
}

DownloadSnapOptions carries options for downloading snaps plus assertions.

func (*DownloadSnapOptions) String

func (opts *DownloadSnapOptions) String() string

type DownloadedComponent

type DownloadedComponent struct {
	Path string
	Info *snap.ComponentInfo
}

type DownloadedSnap

type DownloadedSnap struct {
	Path            string
	Info            *snap.Info
	RedirectChannel string
	Components      []*DownloadedComponent
}

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
	Revision  snap.Revision
	CohortKey string
	// ValidationSets is an optional array of validation set primary keys.
	ValidationSets []snapasserts.ValidationSetKey
	// CompsToDownload has the names of components we wish to dowload.
	CompsToDownload []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)

	// SeqFormingAssertion retrieves the sequence-forming assertion for the given
	// type (currently validation-set only). For sequence <= 0 we query for the
	// latest sequence, otherwise the latest revision of the given sequence is
	// requested.
	SeqFormingAssertion(assertType *asserts.AssertionType, sequenceKey []string, sequence int, user *auth.UserState) (asserts.Assertion, error)

	// SetAssertionMaxFormats sets the assertion max formats to send.
	SetAssertionMaxFormats(maxFormats map[string]int)
}

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, the fetcher will add assertions in the given database and after that also call save for each of them.

func (*ToolingStore) AssertionMaxFormats

func (tsto *ToolingStore) AssertionMaxFormats() map[string]int

AssertionMaxFormats returns the max formats set with SetAssertionMaxFormats or nil.

func (*ToolingStore) AssertionSequenceFormingFetcher

func (tsto *ToolingStore) AssertionSequenceFormingFetcher(db *asserts.Database, save func(asserts.Assertion) error) asserts.SequenceFormingFetcher

AssertionSequenceFormingFetcher creates an asserts.SequenceFormingFetcher for fetching assertions. The fetcher will then store the fetched assertions in the given db and 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, comps []string, opts DownloadSnapOptions) (downloadedSnap *DownloadedSnap, err error)

DownloadSnap downloads the snap/components with the given names and options. It returns the final full paths of the snap/components and infos for them 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

func (*ToolingStore) SetAssertionMaxFormats

func (tsto *ToolingStore) SetAssertionMaxFormats(maxFormats map[string]int)

SetAssertionMaxFormats sets the assertion max formats to use with Assertion and SnapAction.

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