Documentation ¶
Index ¶
- func CreateTUFTable(db gorm.DB) error
- func CreateTimestampTable(db gorm.DB) error
- type ErrNoKey
- type ErrNotFound
- type ErrOldVersion
- type ErrTimestampKeyExists
- type MemStorage
- func (st *MemStorage) Delete(gun string) error
- func (st *MemStorage) GetCurrent(gun, role string) (data []byte, err error)
- func (st *MemStorage) GetTimestampKey(gun string) (algorithm string, public []byte, err error)
- func (st *MemStorage) SetTimestampKey(gun string, 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 SQLStorage
- func (db *SQLStorage) CheckHealth() error
- func (db *SQLStorage) Delete(gun string) error
- func (db *SQLStorage) GetCurrent(gun, tufRole string) ([]byte, error)
- func (db *SQLStorage) GetTimestampKey(gun string) (algorithm string, public []byte, err error)
- func (db *SQLStorage) SetTimestampKey(gun string, 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 TimestampKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateTUFTable ¶
CreateTUFTable creates the DB table for TUFFile
func CreateTimestampTable ¶
CreateTimestampTable creates the DB table for TUFFile
Types ¶
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 ErrTimestampKeyExists ¶
type ErrTimestampKeyExists struct {
// contains filtered or unexported fields
}
ErrTimestampKeyExists is returned when a timestamp key already exists
func (ErrTimestampKeyExists) Error ¶
func (err ErrTimestampKeyExists) Error() string
ErrTimestampKeyExists is returned when a timestamp key already exists
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 delets all the metadata for a given GUN
func (*MemStorage) GetCurrent ¶
func (st *MemStorage) GetCurrent(gun, role string) (data []byte, err error)
GetCurrent returns the metadada for a given role, under a GUN
func (*MemStorage) GetTimestampKey ¶
func (st *MemStorage) GetTimestampKey(gun string) (algorithm string, public []byte, err error)
GetTimestampKey returns the public key material of the timestamp key of a given gun
func (*MemStorage) SetTimestampKey ¶
func (st *MemStorage) SetTimestampKey(gun string, algorithm string, public []byte) error
SetTimestampKey sets a Timestamp key under a gun
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 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) (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 // GetTimestampKey returns the algorithm and public key for the given GUN. // If the GUN doesn't exist, returns an error. GetTimestampKey(gun string) (algorithm string, public []byte, err error) // SetTimeStampKey sets the algorithm and public key for the given GUN if // it doesn't already exist. Otherwise an error is returned. SetTimestampKey(gun string, algorithm string, public []byte) error }
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 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) GetCurrent ¶
func (db *SQLStorage) GetCurrent(gun, tufRole string) ([]byte, error)
GetCurrent gets a specific TUF record
func (*SQLStorage) GetTimestampKey ¶
func (db *SQLStorage) GetTimestampKey(gun string) (algorithm string, public []byte, err error)
GetTimestampKey returns the timestamps Public Key data
func (*SQLStorage) SetTimestampKey ¶
func (db *SQLStorage) SetTimestampKey(gun string, algorithm string, public []byte) error
SetTimestampKey attempts to write a TimeStamp key and returns an error if it already exists
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"` Data []byte `sql:"type:longblob;not null"` }
TUFFile represents a TUF file in the database
type TimestampKey ¶
type TimestampKey struct { gorm.Model Gun string `sql:"type:varchar(255);unique;not null"` Cipher string `sql:"type:varchar(30);not null"` Public []byte `sql:"type:blob;not null"` }
TimestampKey represents a single timestamp key in the database
func (TimestampKey) TableName ¶
func (g TimestampKey) TableName() string
TableName sets a specific table name for our TimestampKey