Documentation ¶
Index ¶
- Constants
- Variables
- func NewMultiPartMetaRequest(url string, metas map[string][]byte) (*http.Request, error)
- type Bootstrapper
- type ErrInvalidOperation
- type ErrMaliciousServer
- type ErrMetaNotFound
- type ErrOffline
- type ErrServerUnavailable
- type FilesystemStore
- func (f *FilesystemStore) Get(name string) ([]byte, error)
- func (f *FilesystemStore) GetSized(name string, size int64) ([]byte, error)
- func (f FilesystemStore) ListFiles() []string
- func (f FilesystemStore) Location() string
- func (f *FilesystemStore) Remove(name string) error
- func (f *FilesystemStore) RemoveAll() error
- func (f *FilesystemStore) Set(name string, meta []byte) error
- func (f *FilesystemStore) SetMulti(metas map[string][]byte) error
- type HTTPStore
- func (s HTTPStore) GetKey(role string) ([]byte, error)
- func (s HTTPStore) GetSized(name string, size int64) ([]byte, error)
- func (s HTTPStore) Location() string
- func (s HTTPStore) Remove(name string) error
- func (s HTTPStore) RemoveAll() error
- func (s HTTPStore) RotateKey(role string) ([]byte, error)
- func (s HTTPStore) Set(name string, blob []byte) error
- func (s HTTPStore) SetMulti(metas map[string][]byte) error
- type MemoryStore
- func (m MemoryStore) Get(name string) ([]byte, error)
- func (m MemoryStore) GetSized(name string, size int64) ([]byte, error)
- func (m *MemoryStore) ListFiles() []string
- func (m MemoryStore) Location() string
- func (m *MemoryStore) Remove(name string) error
- func (m *MemoryStore) RemoveAll() error
- func (m *MemoryStore) Set(name string, meta []byte) error
- func (m *MemoryStore) SetMulti(metas map[string][]byte) error
- type MetadataStore
- type NetworkError
- type OfflineStore
- func (es OfflineStore) GetKey(role string) ([]byte, error)
- func (es OfflineStore) GetSized(name string, size int64) ([]byte, error)
- func (es OfflineStore) Location() string
- func (es OfflineStore) Remove(name string) error
- func (es OfflineStore) RemoveAll() error
- func (es OfflineStore) RotateKey(role string) ([]byte, error)
- func (es OfflineStore) Set(name string, blob []byte) error
- func (es OfflineStore) SetMulti(map[string][]byte) error
- type PublicKeyStore
- type RemoteStore
Constants ¶
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") )
Functions ¶
Types ¶
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 ¶ added in v0.4.0
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 ¶ added in v0.4.0
func (err ErrInvalidOperation) Error() string
type ErrMaliciousServer ¶ added in v0.4.0
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 ¶ added in v0.4.0
func (err ErrMaliciousServer) Error() string
type ErrMetaNotFound ¶ added in v0.4.0
type ErrMetaNotFound struct {
Resource string
}
ErrMetaNotFound indicates we did not find a particular piece of metadata in the store
func (ErrMetaNotFound) Error ¶ added in v0.4.0
func (err ErrMetaNotFound) Error() string
type ErrOffline ¶ added in v0.4.0
type ErrOffline struct{}
ErrOffline is used to indicate we are operating offline
func (ErrOffline) Error ¶ added in v0.4.0
func (e ErrOffline) Error() string
type ErrServerUnavailable ¶ added in v0.4.0
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 ¶ added in v0.4.0
func (err ErrServerUnavailable) Error() string
type FilesystemStore ¶ added in v0.4.0
type FilesystemStore struct {
// contains filtered or unexported fields
}
FilesystemStore is a store in a locally accessible directory
func NewFileStore ¶ added in v0.4.0
func NewFileStore(baseDir, fileExt string) (*FilesystemStore, error)
NewFileStore creates a fully configurable file store
func NewPrivateKeyFileStorage ¶ added in v0.4.0
func NewPrivateKeyFileStorage(baseDir, fileExt string) (*FilesystemStore, error)
NewPrivateKeyFileStorage initializes a new filestore for private keys, appending the notary.PrivDir to the baseDir.
func NewPrivateSimpleFileStore ¶ added in v0.4.0
func NewPrivateSimpleFileStore(baseDir, fileExt string) (*FilesystemStore, error)
NewPrivateSimpleFileStore is a wrapper to create an owner readable/writeable _only_ filestore
func (*FilesystemStore) Get ¶ added in v0.4.0
func (f *FilesystemStore) Get(name string) ([]byte, error)
Get returns the meta for the given name.
func (*FilesystemStore) GetSized ¶ added in v0.4.0
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 ¶ added in v0.4.0
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 ¶ added in v0.4.0
func (f FilesystemStore) Location() string
Location returns a human readable name for the storage location
func (*FilesystemStore) Remove ¶ added in v0.4.0
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 ¶ added in v0.4.0
func (f *FilesystemStore) RemoveAll() error
RemoveAll clears the existing filestore by removing its base directory
type HTTPStore ¶ added in v0.4.0
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) GetSized ¶ added in v0.4.0
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 ¶ added in v0.4.0
Location returns a human readable name for the storage location
func (HTTPStore) Remove ¶ added in v0.4.0
Remove always fails, because we should never be able to delete metadata remotely
func (HTTPStore) RemoveAll ¶ added in v0.4.0
RemoveAll will attempt to delete all TUF metadata for a GUN
func (HTTPStore) RotateKey ¶ added in v0.4.0
RotateKey rotates a private key and returns the public component from the remote server
type MemoryStore ¶ added in v0.4.0
type MemoryStore struct {
// contains filtered or unexported fields
}
MemoryStore implements a mock RemoteStore entirely in memory. For testing purposes only.
func NewMemoryStore ¶ added in v0.4.0
func NewMemoryStore(initial map[string][]byte) *MemoryStore
NewMemoryStore returns a MetadataStore that operates entirely in memory. Very useful for testing
func (MemoryStore) Get ¶ added in v0.4.0
func (m MemoryStore) Get(name string) ([]byte, error)
Get returns the data associated with name
func (MemoryStore) GetSized ¶ added in v0.4.0
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 ¶ added in v0.4.0
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 ¶ added in v0.4.0
func (m MemoryStore) Location() string
Location provides a human readable name for the storage location
func (*MemoryStore) Remove ¶ added in v0.4.0
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 ¶ added in v0.4.0
func (m *MemoryStore) RemoveAll() error
RemoveAll clears the existing memory store by setting this store as new empty one
type MetadataStore ¶ added in v0.4.0
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 ¶ added in v0.4.1
type NetworkError struct {
Wrapped error
}
NetworkError represents any kind of network error when attempting to make a request
func (NetworkError) Error ¶ added in v0.4.1
func (n NetworkError) Error() string
type OfflineStore ¶ added in v0.4.0
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 ¶ added in v0.4.0
func (es OfflineStore) GetKey(role string) ([]byte, error)
GetKey returns ErrOffline
func (OfflineStore) GetSized ¶ added in v0.4.0
func (es OfflineStore) GetSized(name string, size int64) ([]byte, error)
GetSized returns ErrOffline
func (OfflineStore) Location ¶ added in v0.4.0
func (es OfflineStore) Location() string
Location returns a human readable name for the storage location
func (OfflineStore) Remove ¶ added in v0.4.0
func (es OfflineStore) Remove(name string) error
Remove returns ErrOffline
func (OfflineStore) RemoveAll ¶ added in v0.4.0
func (es OfflineStore) RemoveAll() error
RemoveAll return ErrOffline
func (OfflineStore) RotateKey ¶ added in v0.4.0
func (es OfflineStore) RotateKey(role string) ([]byte, error)
RotateKey returns ErrOffline
type PublicKeyStore ¶ added in v0.4.0
type PublicKeyStore interface { GetKey(role string) ([]byte, error) RotateKey(role string) ([]byte, error) }
PublicKeyStore must be implemented by a key service
type RemoteStore ¶ added in v0.4.0
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 ¶ added in v0.4.0
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