history

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2024 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
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.

func (*AferoStore) Get

func (s *AferoStore) Get(key string) ([]byte, error)

Get the value for key.

func (*AferoStore) Set

func (s *AferoStore) Set(key string, value []byte) error

Set the value for key.

type HashMismatchError

type HashMismatchError struct {
	Expected []byte
	Actual   []byte
}

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 New

func New() (*History, error)

New creates a new History backed by the default filesystem store.

func NewWithStore

func NewWithStore(store Store) *History

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

func (h *History) GetManifest(hash [HashSize]byte) ([]byte, error)

GetManifest returns the manifest for the given hash.

func (*History) GetPolicy

func (h *History) GetPolicy(hash [HashSize]byte) ([]byte, error)

GetPolicy returns the policy 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

func (h *History) HasLatest() (bool, error)

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

func (h *History) SetManifest(manifest []byte) ([HashSize]byte, error)

SetManifest sets the manifest and returns its hash.

func (*History) SetPolicy

func (h *History) SetPolicy(policy []byte) ([HashSize]byte, error)

SetPolicy sets the policy 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.

type Transition

type Transition struct {
	ManifestHash           [HashSize]byte
	PreviousTransitionHash [HashSize]byte
}

Transition is a transition between two manifests.

Jump to

Keyboard shortcuts

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