package changelist
import "github.com/theupdateframework/notary/client/changelist"
Index ¶
- Constants
- type Change
- type ChangeIterator
- type Changelist
- type FileChangeListIterator
- func (m *FileChangeListIterator) HasNext() bool
- func (m *FileChangeListIterator) Next() (item Change, err error)
- type FileChangelist
- func NewFileChangelist(dir string) (*FileChangelist, error)
- func (cl FileChangelist) Add(c Change) error
- func (cl FileChangelist) Clear(archive string) error
- func (cl FileChangelist) Close() error
- func (cl FileChangelist) List() []Change
- func (cl FileChangelist) Location() string
- func (cl FileChangelist) NewIterator() (ChangeIterator, error)
- func (cl FileChangelist) Remove(idxs []int) error
- type IteratorBoundsError
- type MemChangeListIterator
- func (m *MemChangeListIterator) HasNext() bool
- func (m *MemChangeListIterator) Next() (item Change, err error)
- type TUFChange
- func NewTUFChange(action string, role data.RoleName, changeType, changePath string, content []byte) *TUFChange
- func (c TUFChange) Action() string
- func (c TUFChange) Content() []byte
- func (c TUFChange) Path() string
- func (c TUFChange) Scope() data.RoleName
- func (c TUFChange) Type() string
- type TUFDelegation
- type TUFRootData
Constants ¶
const ( ScopeRoot = "root" ScopeTargets = "targets" )
Scopes for TUFChanges are simply the TUF roles. Unfortunately because of targets delegations, we can only cover the base roles.
const ( TypeBaseRole = "role" TypeTargetsTarget = "target" TypeTargetsDelegation = "delegation" TypeWitness = "witness" )
Types for TUFChanges are namespaced by the Role they are relevant for. The Root and Targets roles are the only ones for which user action can cause a change, as all changes in Snapshot and Timestamp are programmatically generated base on Root and Targets changes.
const ( // ActionCreate represents a Create action ActionCreate = "create" // ActionUpdate represents an Update action ActionUpdate = "update" // ActionDelete represents a Delete action ActionDelete = "delete" )
Types ¶
type Change ¶
type Change interface {
// "create","update", or "delete"
Action() string
// Where the change should be made.
// For TUF this will be the role
Scope() data.RoleName
// The content type being affected.
// For TUF this will be "target", or "delegation".
// If the type is "delegation", the Scope will be
// used to determine if a root role is being updated
// or a target delegation.
Type() string
// Path indicates the entry within a role to be affected by the
// change. For targets, this is simply the target's path,
// for delegations it's the delegated role name.
Path() string
// Serialized content that the interpreter of a changelist
// can use to apply the change.
// For TUF this will be the serialized JSON that needs
// to be inserted or merged. In the case of a "delete"
// action, it will be nil.
Content() []byte
}
Change is the interface for a TUF Change
type ChangeIterator ¶
ChangeIterator is the interface for iterating across collections of TUF Change items
type Changelist ¶
type Changelist interface {
// List returns the ordered list of changes
// currently stored
List() []Change
// Add change appends the provided change to
// the list of changes
Add(Change) error
// Clear empties the current change list.
// Archive may be provided as a directory path
// to save a copy of the changelist in that location
Clear(archive string) error
// Remove deletes the changes corresponding with the indices given
Remove(idxs []int) error
// Close synchronizes any pending writes to the underlying
// storage and closes the file/connection
Close() error
// NewIterator returns an iterator for walking through the list
// of changes currently stored
NewIterator() (ChangeIterator, error)
// Location returns the place the changelist is stores
Location() string
}
Changelist is the interface for all TUF change lists
func NewMemChangelist ¶
func NewMemChangelist() Changelist
NewMemChangelist instantiates a new in-memory changelist
type FileChangeListIterator ¶
type FileChangeListIterator struct {
// contains filtered or unexported fields
}
FileChangeListIterator is a concrete instance of ChangeIterator
func (*FileChangeListIterator) HasNext ¶
func (m *FileChangeListIterator) HasNext() bool
HasNext indicates whether iterator is exhausted
func (*FileChangeListIterator) Next ¶
func (m *FileChangeListIterator) Next() (item Change, err error)
Next returns the next Change in the FileChangeList
type FileChangelist ¶
type FileChangelist struct {
// contains filtered or unexported fields
}
FileChangelist stores all the changes as files
func NewFileChangelist ¶
func NewFileChangelist(dir string) (*FileChangelist, error)
NewFileChangelist is a convenience method for returning FileChangeLists
func (FileChangelist) Add ¶
func (cl FileChangelist) Add(c Change) error
Add adds a change to the file change list
func (FileChangelist) Clear ¶
func (cl FileChangelist) Clear(archive string) error
Clear clears the change list N.B. archiving not currently implemented
func (FileChangelist) Close ¶
func (cl FileChangelist) Close() error
Close is a no-op
func (FileChangelist) List ¶
func (cl FileChangelist) List() []Change
List returns a list of sorted changes
func (FileChangelist) Location ¶
func (cl FileChangelist) Location() string
Location returns the file path to the changelist
func (FileChangelist) NewIterator ¶
func (cl FileChangelist) NewIterator() (ChangeIterator, error)
NewIterator creates an iterator from FileChangelist
func (FileChangelist) Remove ¶
func (cl FileChangelist) Remove(idxs []int) error
Remove deletes the changes found at the given indices
type IteratorBoundsError ¶
type IteratorBoundsError int
IteratorBoundsError is an Error type used by Next()
func (IteratorBoundsError) Error ¶
func (e IteratorBoundsError) Error() string
Error implements the Error interface
type MemChangeListIterator ¶
type MemChangeListIterator struct {
// contains filtered or unexported fields
}
MemChangeListIterator is a concrete instance of ChangeIterator
func (*MemChangeListIterator) HasNext ¶
func (m *MemChangeListIterator) HasNext() bool
HasNext indicates whether the iterator is exhausted
func (*MemChangeListIterator) Next ¶
func (m *MemChangeListIterator) Next() (item Change, err error)
Next returns the next Change
type TUFChange ¶
type TUFChange struct {
// Abbreviated because Go doesn't permit a field and method of the same name
Actn string `json:"action"`
Role data.RoleName `json:"role"`
ChangeType string `json:"type"`
ChangePath string `json:"path"`
Data []byte `json:"data"`
}
TUFChange represents a change to a TUF repo
func NewTUFChange ¶
func NewTUFChange(action string, role data.RoleName, changeType, changePath string, content []byte) *TUFChange
NewTUFChange initializes a TUFChange object
func (TUFChange) Action ¶
Action return c.Actn
func (TUFChange) Content ¶
Content returns c.Data
func (TUFChange) Path ¶
Path return c.ChangePath
func (TUFChange) Scope ¶
Scope returns c.Role
func (TUFChange) Type ¶
Type returns c.ChangeType
type TUFDelegation ¶
type TUFDelegation struct {
NewName data.RoleName `json:"new_name,omitempty"`
NewThreshold int `json:"threshold,omitempty"`
AddKeys data.KeyList `json:"add_keys,omitempty"`
RemoveKeys []string `json:"remove_keys,omitempty"`
AddPaths []string `json:"add_paths,omitempty"`
RemovePaths []string `json:"remove_paths,omitempty"`
ClearAllPaths bool `json:"clear_paths,omitempty"`
}
TUFDelegation represents a modification to a target delegation this includes creating a delegations. This format is used to avoid unexpected race conditions between humans modifying the same delegation
func (TUFDelegation) ToNewRole ¶
ToNewRole creates a fresh role object from the TUFDelegation data
type TUFRootData ¶
TUFRootData represents a modification of the keys associated with a role that appears in the root.json
Source Files ¶
change.go changelist.go file_changelist.go interface.go
- Version
- v0.7.0 (latest)
- Published
- Jan 14, 2021
- Platform
- linux/amd64
- Imports
- 10 packages
- Last checked
- 8 months ago –
Tools for package owners.