Back to godoc.org
github.com/docker/notary / storage

package storage

v0.6.1
Latest Go to latest
Published: Apr 10, 2018 | License: Apache-2.0 | Module: github.com/docker/notary

Index

Constants

const (
	// MaxErrorResponseSize is the maximum size for an error message - 1KiB
	MaxErrorResponseSize int64 = 1 << 10
	// MaxKeySize is the maximum size for a stored TUF key - 256KiB
	MaxKeySize = 256 << 10
)
const NoSizeLimit int64 = -1

NoSizeLimit is represented as -1 for arguments to GetMeta

Variables

var (
	// ErrPathOutsideStore indicates that the returned path would be
	// outside the store
	ErrPathOutsideStore = errors.New("path outside file store")
)

func NewMultiPartMetaRequest

func NewMultiPartMetaRequest(url string, metas map[string][]byte) (*http.Request, error)

NewMultiPartMetaRequest builds a request with the provided metadata updates in multipart form

type Bootstrapper

type Bootstrapper interface {
	// Bootstrap instructs a configured Bootstrapper to perform
	// its setup operations.
	Bootstrap() error
}

Bootstrapper is a thing that can set itself up

type ErrInvalidOperation

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

ErrInvalidOperation indicates that the server returned a 400 response and propagate any body we received.

func (ErrInvalidOperation) Error

func (err ErrInvalidOperation) Error() string

type ErrMaliciousServer

type ErrMaliciousServer struct{}

ErrMaliciousServer indicates the server returned a response that is highly suspected of being malicious. i.e. it attempted to send us more data than the known size of a particular role metadata.

func (ErrMaliciousServer) Error

func (err ErrMaliciousServer) Error() string

type ErrMetaNotFound

type ErrMetaNotFound struct {
	Resource string
}

ErrMetaNotFound indicates we did not find a particular piece of metadata in the store

func (ErrMetaNotFound) Error

func (err ErrMetaNotFound) Error() string

type ErrOffline

type ErrOffline struct{}

ErrOffline is used to indicate we are operating offline

func (ErrOffline) Error

func (e ErrOffline) Error() string

type ErrServerUnavailable

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

ErrServerUnavailable indicates an error from the server. code allows us to populate the http error we received

func (ErrServerUnavailable) Error

func (err ErrServerUnavailable) Error() string

type FilesystemStore

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

FilesystemStore is a store in a locally accessible directory

func NewFileStore

func NewFileStore(baseDir, fileExt string) (*FilesystemStore, error)

NewFileStore creates a fully configurable file store

func NewPrivateKeyFileStorage

func NewPrivateKeyFileStorage(baseDir, fileExt string) (*FilesystemStore, error)

NewPrivateKeyFileStorage initializes a new filestore for private keys, appending the notary.PrivDir to the baseDir.

func NewPrivateSimpleFileStore

func NewPrivateSimpleFileStore(baseDir, fileExt string) (*FilesystemStore, error)

NewPrivateSimpleFileStore is a wrapper to create an owner readable/writeable _only_ filestore

func (*FilesystemStore) Get

func (f *FilesystemStore) Get(name string) ([]byte, error)

Get returns the meta for the given name.

func (*FilesystemStore) GetSized

func (f *FilesystemStore) GetSized(name string, size int64) ([]byte, error)

GetSized returns the meta for the given name (a role) up to size bytes If size is "NoSizeLimit", this corresponds to "infinite," but we cut off at a predefined threshold "notary.MaxDownloadSize". If the file is larger than size we return ErrMaliciousServer for consistency with the HTTPStore

func (FilesystemStore) ListFiles

func (f FilesystemStore) ListFiles() []string

ListFiles returns a list of all the filenames that can be used with Get* to retrieve content from this filestore

func (FilesystemStore) Location

func (f FilesystemStore) Location() string

Location returns a human readable name for the storage location

func (*FilesystemStore) Remove

func (f *FilesystemStore) Remove(name string) error

Remove removes the metadata for a single role - if the metadata doesn't exist, no error is returned

func (*FilesystemStore) RemoveAll

func (f *FilesystemStore) RemoveAll() error

RemoveAll clears the existing filestore by removing its base directory

func (*FilesystemStore) Set

func (f *FilesystemStore) Set(name string, meta []byte) error

Set sets the meta for a single role

func (*FilesystemStore) SetMulti

func (f *FilesystemStore) SetMulti(metas map[string][]byte) error

SetMulti sets the metadata for multiple roles in one operation

type HTTPStore

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

HTTPStore manages pulling and pushing metadata from and to a remote service over HTTP. It assumes the URL structure of the remote service maps identically to the structure of the TUF repo: <baseURL>/<metaPrefix>/(root|targets|snapshot|timestamp).json <baseURL>/<targetsPrefix>/foo.sh

If consistent snapshots are disabled, it is advised that caching is not enabled. Simple set a cachePath (and ensure it's writeable) to enable caching.

func (HTTPStore) GetKey

func (s HTTPStore) GetKey(role data.RoleName) ([]byte, error)

GetKey retrieves a public key from the remote server

func (HTTPStore) GetSized

func (s HTTPStore) GetSized(name string, size int64) ([]byte, error)

GetSized downloads the named meta file with the given size. A short body is acceptable because in the case of timestamp.json, the size is a cap, not an exact length. If size is "NoSizeLimit", this corresponds to "infinite," but we cut off at a predefined threshold "notary.MaxDownloadSize".

func (HTTPStore) Location

func (s HTTPStore) Location() string

Location returns a human readable name for the storage location

func (HTTPStore) Remove

func (s HTTPStore) Remove(name string) error

Remove always fails, because we should never be able to delete metadata remotely

func (HTTPStore) RemoveAll

func (s HTTPStore) RemoveAll() error

RemoveAll will attempt to delete all TUF metadata for a GUN

func (HTTPStore) RotateKey

func (s HTTPStore) RotateKey(role data.RoleName) ([]byte, error)

RotateKey rotates a private key and returns the public component from the remote server

func (HTTPStore) Set

func (s HTTPStore) Set(name string, blob []byte) error

Set sends a single piece of metadata to the TUF server

func (HTTPStore) SetMulti

func (s HTTPStore) SetMulti(metas map[string][]byte) error

SetMulti does a single batch upload of multiple pieces of TUF metadata. This should be preferred for updating a remote server as it enable the server to remain consistent, either accepting or rejecting the complete update.

type MemoryStore

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

MemoryStore implements a mock RemoteStore entirely in memory. For testing purposes only.

func NewMemoryStore

func NewMemoryStore(seed map[data.RoleName][]byte) *MemoryStore

NewMemoryStore returns a MetadataStore that operates entirely in memory. Very useful for testing

func (MemoryStore) Get

func (m MemoryStore) Get(name string) ([]byte, error)

Get returns the data associated with name

func (MemoryStore) GetSized

func (m MemoryStore) GetSized(name string, size int64) ([]byte, error)

GetSized returns up to size bytes of data references by name. If size is "NoSizeLimit", this corresponds to "infinite," but we cut off at a predefined threshold "notary.MaxDownloadSize", as we will always know the size for everything but a timestamp and sometimes a root, neither of which should be exceptionally large

func (*MemoryStore) ListFiles

func (m *MemoryStore) ListFiles() []string

ListFiles returns a list of all files. The names returned should be usable with Get directly, with no modification.

func (MemoryStore) Location

func (m MemoryStore) Location() string

Location provides a human readable name for the storage location

func (*MemoryStore) Remove

func (m *MemoryStore) Remove(name string) error

Remove removes the metadata for a single role - if the metadata doesn't exist, no error is returned

func (*MemoryStore) RemoveAll

func (m *MemoryStore) RemoveAll() error

RemoveAll clears the existing memory store by setting this store as new empty one

func (*MemoryStore) Set

func (m *MemoryStore) Set(name string, meta []byte) error

Set sets the metadata value for the given name

func (*MemoryStore) SetMulti

func (m *MemoryStore) SetMulti(metas map[string][]byte) error

SetMulti sets multiple pieces of metadata for multiple names in a single operation.

type MetadataStore

type MetadataStore interface {
	GetSized(name string, size int64) ([]byte, error)
	Set(name string, blob []byte) error
	SetMulti(map[string][]byte) error
	RemoveAll() error
	Remove(name string) error
}

MetadataStore must be implemented by anything that intends to interact with a store of TUF files

type NetworkError

type NetworkError struct {
	Wrapped error
}

NetworkError represents any kind of network error when attempting to make a request

func (NetworkError) Error

func (n NetworkError) Error() string

type OfflineStore

type OfflineStore struct{}

OfflineStore is to be used as a placeholder for a nil store. It simply returns ErrOffline for every operation

func (OfflineStore) GetKey

func (es OfflineStore) GetKey(role data.RoleName) ([]byte, error)

GetKey returns ErrOffline

func (OfflineStore) GetSized

func (es OfflineStore) GetSized(name string, size int64) ([]byte, error)

GetSized returns ErrOffline

func (OfflineStore) Location

func (es OfflineStore) Location() string

Location returns a human readable name for the storage location

func (OfflineStore) Remove

func (es OfflineStore) Remove(name string) error

Remove returns ErrOffline

func (OfflineStore) RemoveAll

func (es OfflineStore) RemoveAll() error

RemoveAll return ErrOffline

func (OfflineStore) RotateKey

func (es OfflineStore) RotateKey(role data.RoleName) ([]byte, error)

RotateKey returns ErrOffline

func (OfflineStore) Set

func (es OfflineStore) Set(name string, blob []byte) error

Set returns ErrOffline

func (OfflineStore) SetMulti

func (es OfflineStore) SetMulti(map[string][]byte) error

SetMulti returns ErrOffline

type PublicKeyStore

type PublicKeyStore interface {
	GetKey(role data.RoleName) ([]byte, error)
	RotateKey(role data.RoleName) ([]byte, error)
}

PublicKeyStore must be implemented by a key service

type RemoteStore

type RemoteStore interface {
	MetadataStore
	PublicKeyStore
}

RemoteStore is similar to LocalStore with the added expectation that it should provide a way to download targets once located

func NewHTTPStore

func NewHTTPStore(baseURL, metaPrefix, metaExtension, keyExtension string, roundTrip http.RoundTripper) (RemoteStore, error)

NewHTTPStore initializes a new store against a URL and a number of configuration options.

In case of a nil `roundTrip`, a default offline store is used instead.

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier