store

package
v0.0.0-...-926964d Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2016 License: Apache-2.0, BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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

Types

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 NewFilesystemStore

func NewFilesystemStore(baseDir, metaSubDir, metaExtension string) (*FilesystemStore, error)

NewFilesystemStore creates a new store in a directory tree

func (*FilesystemStore) GetMeta

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

GetMeta returns the meta for the given name (a role) up to size bytes If size is -1, this corresponds to "infinite," but we cut off at 100MB

func (*FilesystemStore) RemoveAll

func (f *FilesystemStore) RemoveAll() error

RemoveAll clears the existing filestore by removing its base directory

func (*FilesystemStore) RemoveMeta

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

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

func (*FilesystemStore) SetMeta

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

SetMeta sets the meta for a single role

func (*FilesystemStore) SetMultiMeta

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

SetMultiMeta 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 string) ([]byte, error)

GetKey retrieves a public key from the remote server

func (HTTPStore) GetMeta

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

GetMeta 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 -1, this corresponds to "infinite," but we cut off at 100MB

func (HTTPStore) RemoveAll

func (s HTTPStore) RemoveAll() error

RemoveAll in the interface is not supported, admins should use the DeleteHandler endpoint directly to delete remote data for a GUN

func (HTTPStore) RemoveMeta

func (s HTTPStore) RemoveMeta(name string) error

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

func (HTTPStore) SetMeta

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

SetMeta uploads a piece of TUF metadata to the server

func (HTTPStore) SetMultiMeta

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

SetMultiMeta 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 LocalStore

type LocalStore interface {
	MetadataStore
}

LocalStore represents a local TUF sture

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(meta map[string][]byte) *MemoryStore

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

func (*MemoryStore) GetKey

func (m *MemoryStore) GetKey(role string) ([]byte, error)

GetKey returns the public key for the given role

func (*MemoryStore) GetMeta

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

GetMeta returns up to size bytes of data references by name. If size is -1, this corresponds to "infinite," but we cut off at 100MB 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) RemoveAll

func (m *MemoryStore) RemoveAll() error

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

func (*MemoryStore) RemoveMeta

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

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

func (*MemoryStore) SetMeta

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

SetMeta sets the metadata value for the given name

func (*MemoryStore) SetMultiMeta

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

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

type MetadataStore

type MetadataStore interface {
	GetMeta(name string, size int64) ([]byte, error)
	SetMeta(name string, blob []byte) error
	SetMultiMeta(map[string][]byte) error
	RemoveAll() error
	RemoveMeta(name string) error
}

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

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 string) ([]byte, error)

GetKey returns ErrOffline

func (OfflineStore) GetMeta

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

GetMeta returns ErrOffline

func (OfflineStore) GetTarget

func (es OfflineStore) GetTarget(path string) (io.ReadCloser, error)

GetTarget returns ErrOffline

func (OfflineStore) RemoveAll

func (es OfflineStore) RemoveAll() error

RemoveAll return ErrOffline

func (OfflineStore) RemoveMeta

func (es OfflineStore) RemoveMeta(name string) error

RemoveMeta returns ErrOffline

func (OfflineStore) SetMeta

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

SetMeta returns ErrOffline

func (OfflineStore) SetMultiMeta

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

SetMultiMeta returns ErrOffline

type PublicKeyStore

type PublicKeyStore interface {
	GetKey(role string) ([]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

Jump to

Keyboard shortcuts

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