Documentation ¶
Index ¶
- func CreateKeyTable(db gorm.DB) error
- func CreateTUFTable(db gorm.DB) error
- type ErrKeyExists
- type ErrNoKey
- type ErrNotFound
- type ErrOldVersion
- type Key
- type KeyStore
- type MemStorage
- func (st *MemStorage) Delete(gun string) error
- func (st *MemStorage) GetChecksum(gun, role, checksum string) (*time.Time, []byte, error)
- func (st *MemStorage) GetCurrent(gun, role string) (*time.Time, []byte, error)
- func (st *MemStorage) GetKey(gun, role string) (algorithm string, public []byte, err error)
- func (st *MemStorage) SetKey(gun, role, algorithm string, public []byte) error
- func (st *MemStorage) UpdateCurrent(gun string, update MetaUpdate) error
- func (st *MemStorage) UpdateMany(gun string, updates []MetaUpdate) error
- type MetaStore
- type MetaUpdate
- type RDBKey
- type RDBTUFFile
- type RethinkDB
- func (rdb RethinkDB) Bootstrap() error
- func (rdb RethinkDB) CheckHealth() error
- func (rdb RethinkDB) Delete(gun string) error
- func (rdb RethinkDB) GetChecksum(gun, role, checksum string) (created *time.Time, data []byte, err error)
- func (rdb RethinkDB) GetCurrent(gun, role string) (created *time.Time, data []byte, err error)
- func (rdb RethinkDB) GetKey(gun, role string) (cipher string, public []byte, err error)
- func (rdb RethinkDB) SetKey(gun, role, cipher string, public []byte) error
- func (rdb RethinkDB) UpdateCurrent(gun string, update MetaUpdate) error
- func (rdb RethinkDB) UpdateCurrentWithTSChecksum(gun, tsChecksum string, update MetaUpdate) error
- func (rdb RethinkDB) UpdateMany(gun string, updates []MetaUpdate) error
- type SQLStorage
- func (db *SQLStorage) CheckHealth() error
- func (db *SQLStorage) Delete(gun string) error
- func (db *SQLStorage) GetChecksum(gun, tufRole, checksum string) (*time.Time, []byte, error)
- func (db *SQLStorage) GetCurrent(gun, tufRole string) (*time.Time, []byte, error)
- func (db *SQLStorage) GetKey(gun, role string) (algorithm string, public []byte, err error)
- func (db *SQLStorage) SetKey(gun, role, algorithm string, public []byte) error
- func (db *SQLStorage) UpdateCurrent(gun string, update MetaUpdate) error
- func (db *SQLStorage) UpdateMany(gun string, updates []MetaUpdate) error
- type TUFFile
- type TUFMetaStorage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateKeyTable ¶
CreateKeyTable creates the DB table for TUFFile
func CreateTUFTable ¶
CreateTUFTable creates the DB table for TUFFile
Types ¶
type ErrKeyExists ¶
type ErrKeyExists struct {
// contains filtered or unexported fields
}
ErrKeyExists is returned when a key already exists
func (ErrKeyExists) Error ¶
func (err ErrKeyExists) Error() string
ErrKeyExists is returned when a key already exists
type ErrNoKey ¶
type ErrNoKey struct {
// contains filtered or unexported fields
}
ErrNoKey is returned when no timestamp key is found
type ErrNotFound ¶
type ErrNotFound struct{}
ErrNotFound is returned when TUF metadata isn't found for a specific record
type ErrOldVersion ¶
type ErrOldVersion struct{}
ErrOldVersion is returned when a newer version of TUF metadada is already available
func (ErrOldVersion) Error ¶
func (err ErrOldVersion) Error() string
ErrOldVersion is returned when a newer version of TUF metadada is already available
type Key ¶
type Key struct { gorm.Model Gun string `sql:"type:varchar(255);not null;unique_index:gun_role"` Role string `sql:"type:varchar(255);not null;unique_index:gun_role"` Cipher string `sql:"type:varchar(30);not null"` Public []byte `sql:"type:blob;not null"` }
Key represents a single timestamp key in the database
type KeyStore ¶
type KeyStore interface { // GetKey returns the algorithm and public key for the given GUN and role. // If the GUN+role don't exist, returns an error. GetKey(gun, role string) (algorithm string, public []byte, err error) // SetKey sets the algorithm and public key for the given GUN and role if // it doesn't already exist. Otherwise an error is returned. SetKey(gun, role, algorithm string, public []byte) error }
KeyStore provides a minimal interface for managing key persistence
type MemStorage ¶
type MemStorage struct {
// contains filtered or unexported fields
}
MemStorage is really just designed for dev and testing. It is very inefficient in many scenarios
func NewMemStorage ¶
func NewMemStorage() *MemStorage
NewMemStorage instantiates a memStorage instance
func (*MemStorage) Delete ¶
func (st *MemStorage) Delete(gun string) error
Delete deletes all the metadata for a given GUN
func (*MemStorage) GetChecksum ¶
GetChecksum returns the createupdate date and metadata for a given role, under a GUN.
func (*MemStorage) GetCurrent ¶
GetCurrent returns the createupdate date metadata for a given role, under a GUN.
func (*MemStorage) GetKey ¶
func (st *MemStorage) GetKey(gun, role string) (algorithm string, public []byte, err error)
GetKey returns the public key material of the timestamp key of a given gun
func (*MemStorage) SetKey ¶
func (st *MemStorage) SetKey(gun, role, algorithm string, public []byte) error
SetKey sets a key under a gun and role
func (*MemStorage) UpdateCurrent ¶
func (st *MemStorage) UpdateCurrent(gun string, update MetaUpdate) error
UpdateCurrent updates the meta data for a specific role
func (*MemStorage) UpdateMany ¶
func (st *MemStorage) UpdateMany(gun string, updates []MetaUpdate) error
UpdateMany updates multiple TUF records
type MetaStore ¶
type MetaStore interface { // UpdateCurrent adds new metadata version for the given GUN if and only // if it's a new role, or the version is greater than the current version // for the role. Otherwise an error is returned. UpdateCurrent(gun string, update MetaUpdate) error // UpdateMany adds multiple new metadata for the given GUN. It can even // add multiple versions for the same role, so long as those versions are // all unique and greater than any current versions. Otherwise, // none of the metadata is added, and an error is be returned. UpdateMany(gun string, updates []MetaUpdate) error // GetCurrent returns the modification date and data part of the metadata for // the latest version of the given GUN and role. If there is no data for // the given GUN and role, an error is returned. GetCurrent(gun, tufRole string) (created *time.Time, data []byte, err error) // GetChecksum returns the given TUF role file and creation date for the // GUN with the provided checksum. If the given (gun, role, checksum) are // not found, it returns storage.ErrNotFound GetChecksum(gun, tufRole, checksum string) (created *time.Time, data []byte, err error) // Delete removes all metadata for a given GUN. It does not return an // error if no metadata exists for the given GUN. Delete(gun string) error KeyStore }
MetaStore holds the methods that are used for a Metadata Store
type MetaUpdate ¶
MetaUpdate packages up the fields required to update a TUF record
type RDBKey ¶ added in v0.3.0
type RDBKey struct { rethinkdb.Timing Gun string `gorethink:"gun"` Role string `gorethink:"role"` Cipher string `gorethink:"cipher"` Public []byte `gorethink:"public"` }
RDBKey is the public key record
type RDBTUFFile ¶ added in v0.3.0
type RDBTUFFile struct { rethinkdb.Timing GunRoleVersion []interface{} `gorethink:"gun_role_version"` Gun string `gorethink:"gun"` Role string `gorethink:"role"` Version int `gorethink:"version"` Sha256 string `gorethink:"sha256"` Data []byte `gorethink:"data"` TSchecksum string `gorethink:"timestamp_checksum"` }
RDBTUFFile is a tuf file record
func (RDBTUFFile) TableName ¶ added in v0.3.0
func (r RDBTUFFile) TableName() string
TableName returns the table name for the record type
type RethinkDB ¶ added in v0.3.0
type RethinkDB struct {
// contains filtered or unexported fields
}
RethinkDB implements a MetaStore against the Rethink Database
func NewRethinkDBStorage ¶ added in v0.3.0
NewRethinkDBStorage initializes a RethinkDB object
func (RethinkDB) CheckHealth ¶ added in v0.3.0
CheckHealth is currently a noop
func (RethinkDB) Delete ¶ added in v0.3.0
Delete removes all metadata for a given GUN. It does not return an error if no metadata exists for the given GUN.
func (RethinkDB) GetChecksum ¶ added in v0.3.0
func (rdb RethinkDB) GetChecksum(gun, role, checksum string) (created *time.Time, data []byte, err error)
GetChecksum returns the given TUF role file and creation date for the GUN with the provided checksum. If the given (gun, role, checksum) are not found, it returns storage.ErrNotFound
func (RethinkDB) GetCurrent ¶ added in v0.3.0
GetCurrent returns the modification date and data part of the metadata for the latest version of the given GUN and role. If there is no data for the given GUN and role, an error is returned.
func (RethinkDB) GetKey ¶ added in v0.3.0
GetKey returns the cipher and public key for the given GUN and role. If the GUN+role don't exist, returns an error.
func (RethinkDB) SetKey ¶ added in v0.3.0
SetKey sets the cipher and public key for the given GUN and role if it doesn't already exist. Otherwise an error is returned.
func (RethinkDB) UpdateCurrent ¶ added in v0.3.0
func (rdb RethinkDB) UpdateCurrent(gun string, update MetaUpdate) error
UpdateCurrent adds new metadata version for the given GUN if and only if it's a new role, or the version is greater than the current version for the role. Otherwise an error is returned.
func (RethinkDB) UpdateCurrentWithTSChecksum ¶ added in v0.3.0
func (rdb RethinkDB) UpdateCurrentWithTSChecksum(gun, tsChecksum string, update MetaUpdate) error
UpdateCurrentWithTSChecksum adds new metadata version for the given GUN with an associated checksum for the timestamp it belongs to, to afford us transaction-like functionality
func (RethinkDB) UpdateMany ¶ added in v0.3.0
func (rdb RethinkDB) UpdateMany(gun string, updates []MetaUpdate) error
UpdateMany adds multiple new metadata for the given GUN. RethinkDB does not support transactions, therefore we will attempt to insert the timestamp last as this represents a published version of the repo. However, we will insert all other role data in alphabetical order first, and also include the associated timestamp checksum so that we can easily roll back this pseudotransaction
type SQLStorage ¶
SQLStorage implements a versioned store using a relational database. See server/storage/models.go
func NewSQLStorage ¶
func NewSQLStorage(dialect string, args ...interface{}) (*SQLStorage, error)
NewSQLStorage is a convenience method to create a SQLStorage
func (*SQLStorage) CheckHealth ¶
func (db *SQLStorage) CheckHealth() error
CheckHealth asserts that both required tables are present
func (*SQLStorage) Delete ¶
func (db *SQLStorage) Delete(gun string) error
Delete deletes all the records for a specific GUN
func (*SQLStorage) GetChecksum ¶
GetChecksum gets a specific TUF record by its hex checksum
func (*SQLStorage) GetCurrent ¶
GetCurrent gets a specific TUF record
func (*SQLStorage) GetKey ¶
func (db *SQLStorage) GetKey(gun, role string) (algorithm string, public []byte, err error)
GetKey returns the Public Key data for a gun+role
func (*SQLStorage) SetKey ¶
func (db *SQLStorage) SetKey(gun, role, algorithm string, public []byte) error
SetKey attempts to write a key and returns an error if it already exists for the gun and role
func (*SQLStorage) UpdateCurrent ¶
func (db *SQLStorage) UpdateCurrent(gun string, update MetaUpdate) error
UpdateCurrent updates a single TUF.
func (*SQLStorage) UpdateMany ¶
func (db *SQLStorage) UpdateMany(gun string, updates []MetaUpdate) error
UpdateMany atomically updates many TUF records in a single transaction
type TUFFile ¶
type TUFFile struct { gorm.Model Gun string `sql:"type:varchar(255);not null"` Role string `sql:"type:varchar(255);not null"` Version int `sql:"not null"` Sha256 string `sql:"type:varchar(64);"` Data []byte `sql:"type:longblob;not null"` }
TUFFile represents a TUF file in the database
type TUFMetaStorage ¶ added in v0.3.0
type TUFMetaStorage struct { MetaStore // contains filtered or unexported fields }
TUFMetaStorage wraps a MetaStore in order to walk the TUF tree for GetCurrent in a consistent manner, by always starting from a current timestamp and then looking up other data by hash
func NewTUFMetaStorage ¶ added in v0.3.0
func NewTUFMetaStorage(m MetaStore) *TUFMetaStorage
NewTUFMetaStorage instantiates a TUFMetaStorage instance
func (TUFMetaStorage) Bootstrap ¶ added in v0.3.0
func (tms TUFMetaStorage) Bootstrap() error
Bootstrap the store with tables if possible
func (TUFMetaStorage) GetChecksum ¶ added in v0.3.0
GetChecksum gets a specific TUF record by checksum, also checking the internal cache
func (TUFMetaStorage) GetCurrent ¶ added in v0.3.0
GetCurrent gets a specific TUF record, by walking from the current Timestamp to other metadata by checksum