go-tuf: github.com/flynn/go-tuf/client Index | Files

package client

import "github.com/flynn/go-tuf/client"

Index

Package Files

client.go errors.go local_store.go remote_store.go

Variables

var (
    ErrNoRootKeys       = errors.New("tuf: no root keys found in local meta store")
    ErrInsufficientKeys = errors.New("tuf: insufficient keys to meet threshold")
)
var DefaultHTTPRetries = &HTTPRemoteRetries{
    Delay: time.Second,
    Total: 10 * time.Second,
}

func IsLatestSnapshot Uses

func IsLatestSnapshot(err error) bool

func IsNotFound Uses

func IsNotFound(err error) bool

type Client Uses

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

Client provides methods for fetching updates from a remote repository and downloading remote target files.

func NewClient Uses

func NewClient(local LocalStore, remote RemoteStore) *Client

func (*Client) Download Uses

func (c *Client) Download(name string, dest Destination) (err error)

Download downloads the given target file from remote storage into dest.

dest will be deleted and an error returned in the following situations:

* The target does not exist in the local targets.json
* The target does not exist in remote storage
* Metadata cannot be generated for the downloaded data
* Generated metadata does not match local metadata for the given file

func (*Client) Init Uses

func (c *Client) Init(rootKeys []*data.Key, threshold int) error

Init initializes a local repository.

The latest root.json is fetched from remote storage, verified using rootKeys and threshold, and then saved in local storage. It is expected that rootKeys were securely distributed with the software being updated.

func (*Client) Targets Uses

func (c *Client) Targets() (data.Files, error)

Targets returns the complete list of available targets.

func (*Client) Update Uses

func (c *Client) Update() (data.Files, error)

Update downloads and verifies remote metadata and returns updated targets.

It performs the update part of "The client application" workflow from section 5.1 of the TUF spec:

https://github.com/theupdateframework/tuf/blob/v0.9.9/docs/tuf-spec.txt#L714

type Destination Uses

type Destination interface {
    io.Writer
    Delete() error
}

type ErrDecodeFailed Uses

type ErrDecodeFailed struct {
    File string
    Err  error
}

func (ErrDecodeFailed) Error Uses

func (e ErrDecodeFailed) Error() string

type ErrDownloadFailed Uses

type ErrDownloadFailed struct {
    File string
    Err  error
}

func (ErrDownloadFailed) Error Uses

func (e ErrDownloadFailed) Error() string

type ErrInvalidURL Uses

type ErrInvalidURL struct {
    URL string
}

func (ErrInvalidURL) Error Uses

func (e ErrInvalidURL) Error() string

type ErrLatestSnapshot Uses

type ErrLatestSnapshot struct {
    Version int
}

func (ErrLatestSnapshot) Error Uses

func (e ErrLatestSnapshot) Error() string

type ErrMetaTooLarge Uses

type ErrMetaTooLarge struct {
    Name string
    Size int64
}

func (ErrMetaTooLarge) Error Uses

func (e ErrMetaTooLarge) Error() string

type ErrMissingRemoteMetadata Uses

type ErrMissingRemoteMetadata struct {
    Name string
}

func (ErrMissingRemoteMetadata) Error Uses

func (e ErrMissingRemoteMetadata) Error() string

type ErrNotFound Uses

type ErrNotFound struct {
    File string
}

func (ErrNotFound) Error Uses

func (e ErrNotFound) Error() string

type ErrUnknownTarget Uses

type ErrUnknownTarget struct {
    Name string
}

func (ErrUnknownTarget) Error Uses

func (e ErrUnknownTarget) Error() string

type ErrWrongSize Uses

type ErrWrongSize struct {
    File     string
    Actual   int64
    Expected int64
}

func (ErrWrongSize) Error Uses

func (e ErrWrongSize) Error() string

type HTTPRemoteOptions Uses

type HTTPRemoteOptions struct {
    MetadataPath string
    TargetsPath  string
    UserAgent    string
    Retries      *HTTPRemoteRetries
}

type HTTPRemoteRetries Uses

type HTTPRemoteRetries struct {
    Delay time.Duration
    Total time.Duration
}

type LocalStore Uses

type LocalStore interface {
    // GetMeta returns top-level metadata from local storage. The keys are
    // in the form `ROLE.json`, with ROLE being a valid top-level role.
    GetMeta() (map[string]json.RawMessage, error)

    // SetMeta persists the given top-level metadata in local storage, the
    // name taking the same format as the keys returned by GetMeta.
    SetMeta(name string, meta json.RawMessage) error
}

LocalStore is local storage for downloaded top-level metadata.

func FileLocalStore Uses

func FileLocalStore(path string) (LocalStore, error)

func MemoryLocalStore Uses

func MemoryLocalStore() LocalStore

type RemoteStore Uses

type RemoteStore interface {
    // GetMeta downloads the given metadata from remote storage.
    //
    // `name` is the filename of the metadata (e.g. "root.json")
    //
    // `err` is ErrNotFound if the given file does not exist.
    //
    // `size` is the size of the stream, -1 indicating an unknown length.
    GetMeta(name string) (stream io.ReadCloser, size int64, err error)

    // GetTarget downloads the given target file from remote storage.
    //
    // `path` is the path of the file relative to the root of the remote
    //        targets directory (e.g. "/path/to/file.txt").
    //
    // `err` is ErrNotFound if the given file does not exist.
    //
    // `size` is the size of the stream, -1 indicating an unknown length.
    GetTarget(path string) (stream io.ReadCloser, size int64, err error)
}

RemoteStore downloads top-level metadata and target files from a remote repository.

func HTTPRemoteStore Uses

func HTTPRemoteStore(baseURL string, opts *HTTPRemoteOptions) (RemoteStore, error)

Package client imports 16 packages (graph) and is imported by 67 packages. Updated 2020-07-16. Refresh now. Tools for package owners.