Documentation
¶
Index ¶
- Constants
- type AferoStore
- type HashMismatchError
- type History
- func (h *History) ConfigureSigningKey(signingKey *ecdsa.PrivateKey)
- func (h *History) GetLatest() (*LatestTransition, error)
- func (h *History) GetManifest(hash [HashSize]byte) ([]byte, error)
- func (h *History) GetPolicy(hash [HashSize]byte) ([]byte, error)
- func (h *History) GetTransition(hash [HashSize]byte) (*Transition, error)
- func (h *History) HasLatest() (bool, error)
- func (h *History) SetLatest(oldT, newT *LatestTransition) error
- func (h *History) SetManifest(manifest []byte) ([HashSize]byte, error)
- func (h *History) SetPolicy(policy []byte) ([HashSize]byte, error)
- func (h *History) SetTransition(transition *Transition) ([HashSize]byte, error)
- type LatestTransition
- type Store
- type Transition
Constants ¶
const ( // HashSize is the number of octets in hashes used by this package. HashSize = sha256.Size )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AferoStore ¶
type AferoStore struct {
// contains filtered or unexported fields
}
AferoStore is a Store implementation backed by an Afero filesystem.
func NewAferoStore ¶
func NewAferoStore(fs *afero.Afero) *AferoStore
NewAferoStore creates a new instance backed by the given fs.
func (*AferoStore) CompareAndSwap ¶
func (s *AferoStore) CompareAndSwap(key string, oldVal, newVal []byte) error
CompareAndSwap updates the key to newVal if its current value is oldVal.
type HashMismatchError ¶
HashMismatchError is returned when a hash does not match the expected value. This can occur when content addressed storage has been corrupted.
func (HashMismatchError) Error ¶
func (e HashMismatchError) Error() string
type History ¶
type History struct {
// contains filtered or unexported fields
}
History is the history of the Coordinator.
func NewWithStore ¶
NewWithStore creates a new History with the given storage backend.
func (*History) ConfigureSigningKey ¶
func (h *History) ConfigureSigningKey(signingKey *ecdsa.PrivateKey)
ConfigureSigningKey sets the signing key for validation and signing of the protected history parts.
func (*History) GetLatest ¶
func (h *History) GetLatest() (*LatestTransition, error)
GetLatest returns the verified transition for the given hash.
func (*History) GetManifest ¶
GetManifest returns the manifest for the given hash.
func (*History) GetTransition ¶
func (h *History) GetTransition(hash [HashSize]byte) (*Transition, error)
GetTransition returns the transition for the given hash.
func (*History) HasLatest ¶
HasLatest returns true if there exist a latest transaction. It does not verify the transaction signature or return the transaction.
func (*History) SetLatest ¶
func (h *History) SetLatest(oldT, newT *LatestTransition) error
SetLatest signs and sets the latest transition if the current latest is equal to oldT.
func (*History) SetManifest ¶
SetManifest sets the manifest and returns its hash.
func (*History) SetTransition ¶
func (h *History) SetTransition(transition *Transition) ([HashSize]byte, error)
SetTransition sets the transition and returns its hash.
type LatestTransition ¶
type LatestTransition struct { TransitionHash [HashSize]byte // contains filtered or unexported fields }
LatestTransition is the latest transition signed by the Coordinator.
type Store ¶
type Store interface { // Get the value for key. // // If the key is not found, an error wrapping os.ErrNotExist must be returned. Get(key string) ([]byte, error) // Set the value for key. Set(key string, value []byte) error // CompareAndSwap sets key to newVal if, and only if, key is currently oldVal. // // If the current value is not equal to oldVal, an error must be returned. The comparison must // treat a nil slice the same as an empty slice. CompareAndSwap(key string, oldVal, newVal []byte) error }
Store defines the Key-Value store interface used by History.
In addition to the documented behavior below, History expects all functions to be thread-safe and the Store to be globally consistent.