Documentation ¶
Overview ¶
Package sequence contains types representing a sequence of snap revisions (with components) that describe current and past states of the snap in the system.
Index ¶
- Variables
- type ComponentState
- type RevisionSideState
- type SnapSequence
- func (snapSeq *SnapSequence) AddComponentForRevision(snapRev snap.Revision, cs *ComponentState) error
- func (snapSeq *SnapSequence) ComponentStateForRev(revIdx int, cref naming.ComponentRef) *ComponentState
- func (snapSeq *SnapSequence) ComponentsForRevision(rev snap.Revision) []*ComponentState
- func (snapSeq *SnapSequence) ComponentsWithTypeForRev(rev snap.Revision, compType snap.ComponentType) []*snap.ComponentSideInfo
- func (snapSeq *SnapSequence) HasComponents(revIdx int) bool
- func (snapSeq *SnapSequence) IsComponentRevInRefSeqPtInAnyOtherSeqPt(cref naming.ComponentRef, refIdx int) bool
- func (snapSeq *SnapSequence) IsComponentRevPresent(compSi *snap.ComponentSideInfo) bool
- func (snapSeq *SnapSequence) LastIndex(revision snap.Revision) int
- func (snapSeq SnapSequence) MarshalJSON() ([]byte, error)
- func (snapSeq *SnapSequence) MinimumLocalComponentRevision(compName string) snap.Revision
- func (snapSeq *SnapSequence) MinimumLocalRevision() snap.Revision
- func (snapSeq *SnapSequence) RemoveComponentForRevision(snapRev snap.Revision, cref naming.ComponentRef) (unlinkedComp *ComponentState)
- func (snapSeq SnapSequence) SideInfos() []*snap.SideInfo
- func (snapSeq *SnapSequence) UnmarshalJSON(in []byte) error
Constants ¶
This section is empty.
Variables ¶
var ErrSnapRevNotInSequence = errors.New("snap is not in the sequence")
Functions ¶
This section is empty.
Types ¶
type ComponentState ¶
type ComponentState struct { SideInfo *snap.ComponentSideInfo `json:"side-info"` CompType snap.ComponentType `json:"type"` }
ComponentState contains information about an installed component.
func NewComponentState ¶
func NewComponentState(si *snap.ComponentSideInfo, tp snap.ComponentType) *ComponentState
NewComponentState creates a ComponentState from components side information and type.
type RevisionSideState ¶
type RevisionSideState struct { Snap *snap.SideInfo Components []*ComponentState }
RevisionSideState contains the side information for a snap and related components installed in the system.
func NewRevisionSideState ¶
func NewRevisionSideState(snapSideInfo *snap.SideInfo, compSideInfo []*ComponentState) *RevisionSideState
NewRevisionSideState creates a RevisionSideInfo from snap and related components side information.
func (*RevisionSideState) FindComponent ¶
func (rss *RevisionSideState) FindComponent(cref naming.ComponentRef) *ComponentState
FindComponent returns the ComponentState if cref is found in the sequence point.
func (RevisionSideState) MarshalJSON ¶
func (bsi RevisionSideState) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface
func (*RevisionSideState) UnmarshalJSON ¶
func (bsi *RevisionSideState) UnmarshalJSON(in []byte) error
UnmarshalJSON implements the json.Unmarshaler interface
type SnapSequence ¶
type SnapSequence struct { // Revisions contains information for a snap revision and // components SideInfo. Revisions []*RevisionSideState }
SnapSequence is a container for a slice containing revisions of snaps plus related components. TODO add methods to access Revisions (length, copy, append) and use them in handlers.go and snapstate.go.
func (*SnapSequence) AddComponentForRevision ¶
func (snapSeq *SnapSequence) AddComponentForRevision(snapRev snap.Revision, cs *ComponentState) error
AddComponentForRevision adds a component to the last instance of snapRev in the sequence.
func (*SnapSequence) ComponentStateForRev ¶
func (snapSeq *SnapSequence) ComponentStateForRev(revIdx int, cref naming.ComponentRef) *ComponentState
ComponentStateForRev returns cref's component side info for the revision (sequence point) indicated by revIdx if there is one.
func (*SnapSequence) ComponentsForRevision ¶
func (snapSeq *SnapSequence) ComponentsForRevision(rev snap.Revision) []*ComponentState
func (*SnapSequence) ComponentsWithTypeForRev ¶
func (snapSeq *SnapSequence) ComponentsWithTypeForRev(rev snap.Revision, compType snap.ComponentType) []*snap.ComponentSideInfo
func (*SnapSequence) HasComponents ¶
func (snapSeq *SnapSequence) HasComponents(revIdx int) bool
HasComponents returns true if the revision at the given index has any components installed with it.
func (*SnapSequence) IsComponentRevInRefSeqPtInAnyOtherSeqPt ¶
func (snapSeq *SnapSequence) IsComponentRevInRefSeqPtInAnyOtherSeqPt(cref naming.ComponentRef, refIdx int) bool
IsComponentRevInRefSeqPtInAnyOtherSeqPt tells us if the component cref in the sequence point defined by refIdx is used in another sequence point too.
func (*SnapSequence) IsComponentRevPresent ¶
func (snapSeq *SnapSequence) IsComponentRevPresent(compSi *snap.ComponentSideInfo) bool
IsComponentRevPresent tells us if a given component revision is present in the system for this snap.
func (*SnapSequence) LastIndex ¶
func (snapSeq *SnapSequence) LastIndex(revision snap.Revision) int
LastIndex returns the last index of the given revision in snapSeq, or -1 if the revision was not found.
func (SnapSequence) MarshalJSON ¶
func (snapSeq SnapSequence) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface. We override the default so serialization of the SnapState.Sequence field is compatible to what was produced when it was defined as a []*snap.SideInfo. This is also the reason to have SnapSequence.UnmarshalJSON and MarshalJSON/UnmarshalJSON for RevisionSideState.
func (*SnapSequence) MinimumLocalComponentRevision ¶
func (snapSeq *SnapSequence) MinimumLocalComponentRevision(compName string) snap.Revision
MinimumLocalComponentRevision returns the smallest local revision for the compName component in the sequence. Local revisions start at -1 and are counted down. 0 will be returned if no local revision for the component is found.
func (*SnapSequence) MinimumLocalRevision ¶
func (snapSeq *SnapSequence) MinimumLocalRevision() snap.Revision
MinimumLocalRevision returns the the smallest local revision for the sequence. Local revisions start at -1 and are counted down. 0 will be returned if no local revision for the snap is found.
func (*SnapSequence) RemoveComponentForRevision ¶
func (snapSeq *SnapSequence) RemoveComponentForRevision(snapRev snap.Revision, cref naming.ComponentRef) (unlinkedComp *ComponentState)
RemoveComponentForRevision removes the cref component for the last instance of snapRev in the sequence and returns a pointer to it, which might be nil if not found.
func (SnapSequence) SideInfos ¶
func (snapSeq SnapSequence) SideInfos() []*snap.SideInfo
SideInfos returns a slice with all the SideInfos for the snap sequence.
func (*SnapSequence) UnmarshalJSON ¶
func (snapSeq *SnapSequence) UnmarshalJSON(in []byte) error
UnmarshalJSON implements the json.Unmarshaler interface