changelist

package
v0.0.0-...-f7d0ea7 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2015 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ScopeRoot      = "root"
	ScopeTargets   = "targets"
	ScopeSnapshot  = "snapshot"
	ScopeTimestamp = "timestamp"
)

Scopes for TufChanges are simply the TUF roles. Unfortunately because of targets delegations, we can only cover the base roles.

View Source
const (
	// ActionCreate represents a Create action
	ActionCreate = "create"
	// ActionUpdate represents an Update action
	ActionUpdate = "update"
	// ActionDelete represents a Delete action
	ActionDelete = "delete"
)

Variables

This section is empty.

Functions

This section is empty.

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() string

	// 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

type ChangeIterator interface {
	Next() (Change, error)
	HasNext() bool
}

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

	// Close syncronizes 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)
}

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

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) NewIterator

func (cl FileChangelist) NewIterator() (ChangeIterator, error)

NewIterator creates an iterator from FileChangelist

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       string `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, changeType, changePath string, content []byte) *TufChange

NewTufChange initializes a tufChange object

func (TufChange) Action

func (c TufChange) Action() string

Action return c.Actn

func (TufChange) Content

func (c TufChange) Content() []byte

Content returns c.Data

func (TufChange) Path

func (c TufChange) Path() string

Path return c.ChangePath

func (TufChange) Scope

func (c TufChange) Scope() string

Scope returns c.Role

func (TufChange) Type

func (c TufChange) Type() string

Type returns c.ChangeType

Jump to

Keyboard shortcuts

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