fsorepos

package
v0.0.0-...-4450389 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2019 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package `fsorepos` implements an event-sourced aggregate that contains FSO repos. See package `fsomain` for an oveview.

Index

Constants

View Source
const ConfigMaxStatusMessageLength = 150

Variables

View Source
var ErrClearMessageEmpty = errors.New("empty clear message")
View Source
var ErrClearMessageMismatch = errors.New("clear message mismatch")
View Source
var ErrCommandConflict = errors.New("command conflict")
View Source
var ErrCommandUnknown = errors.New("unknown command")
View Source
var ErrConflictRepoError = errors.New("cannot proceed due to repo error")
View Source
var ErrConflictShadowPath = errors.New("shadow path conflict")
View Source
var ErrConflictStorageWorkflow = errors.New("storage workflow conflict")
View Source
var ErrConflictWorkflow = errors.New("workflow conflict")
View Source
var ErrDuplicateGPGKeys = errors.New("duplicate GPG keys")
View Source
var ErrEmptyTarPath = errors.New("empty tar path")
View Source
var ErrGitlabConfigInvalid = fmt.Errorf("invalid Gitlab config")
View Source
var ErrGitlabNamespaceInvalid = errors.New("invalid Gitlab namespace")
View Source
var ErrGitlabPathConflict = errors.New("conflicting GitLab path")
View Source
var ErrInitConflict = errors.New("init conflict")
View Source
var ErrInvalidErrorStatusCode = errors.New("invalid error status code")
View Source
var ErrInvalidErrorStatusMessage = errors.New("invalid error status message")
View Source
var ErrMalformedShadowBackupURL = errors.New("malformed shadow backup URL")
View Source
var ErrMalformedTarttURL = errors.New("malformed tartt URL")
View Source
var ErrMalformedWorkflowId = errors.New("malformed workflow ID")
View Source
var ErrMissingShadow = errors.New("missing shadow repo")
View Source
var ErrNoGPGKeys = errors.New("no GPG keys")
View Source
var ErrNoTarttRepo = errors.New("no tartt repo")
View Source
var ErrNotInitialized = errors.New("repo is not initialized")
View Source
var ErrNotInitializedShadowBackup = errors.New("shadow backup is not initialized")
View Source
var ErrShadowPathUnchanged = errors.New("unchanged shadow path")
View Source
var ErrStatusMessageTooLong = errors.New("status message too long")
View Source
var ErrSubdirTrackingInvalid = errors.New("invalid SubdirTracking")
View Source
var ErrUninitialized = errors.New("uninitialized repo")
View Source
var ErrWorkflowActive = errors.New("the workflow is already active")
View Source
var ErrWorkflowReuse = errors.New("workflow ID must not be reused")
View Source
var NoVC = events.NoVC

`NoVC` is a sentinel value that can be passed in place of `vid` to indicate that concurrency version checks are skipped.

Functions

This section is empty.

Types

type Advancer

type Advancer struct {
	// contains filtered or unexported fields
}

func (*Advancer) Advance

func (a *Advancer) Advance(s events.State, ev events.Event) events.State

type Behavior

type Behavior struct{}

func (Behavior) NewAdvancer

func (Behavior) NewAdvancer() events.Advancer

func (Behavior) NewEvent

func (Behavior) NewEvent() events.Event

func (Behavior) NewState

func (Behavior) NewState(id uuid.I) events.State

func (Behavior) Tell

func (Behavior) Tell(
	s events.State, c events.Command,
) ([]events.Event, error)

type CmdAbortArchive

type CmdAbortArchive struct {
	WorkflowId    uuid.I
	StatusCode    int32
	StatusMessage string
}

func (*CmdAbortArchive) AggregateCommand

func (*CmdAbortArchive) AggregateCommand()

type CmdAbortFreeze

type CmdAbortFreeze struct {
	WorkflowId    uuid.I
	StatusCode    int32
	StatusMessage string
}

func (*CmdAbortFreeze) AggregateCommand

func (*CmdAbortFreeze) AggregateCommand()

type CmdAbortUnarchive

type CmdAbortUnarchive struct {
	WorkflowId    uuid.I
	StatusCode    int32
	StatusMessage string
}

func (*CmdAbortUnarchive) AggregateCommand

func (*CmdAbortUnarchive) AggregateCommand()

type CmdAbortUnfreeze

type CmdAbortUnfreeze struct {
	WorkflowId    uuid.I
	StatusCode    int32
	StatusMessage string
}

func (*CmdAbortUnfreeze) AggregateCommand

func (*CmdAbortUnfreeze) AggregateCommand()

type CmdBeginArchive

type CmdBeginArchive struct {
	WorkflowId uuid.I
}

func (*CmdBeginArchive) AggregateCommand

func (*CmdBeginArchive) AggregateCommand()

type CmdBeginFreeze

type CmdBeginFreeze struct {
	WorkflowId uuid.I
}

func (*CmdBeginFreeze) AggregateCommand

func (*CmdBeginFreeze) AggregateCommand()

type CmdBeginMoveRepo

type CmdBeginMoveRepo struct {
	RegistryEventId ulid.I
	WorkflowId      uuid.I
	NewGlobalPath   string
	NewFileHost     string
	NewHostPath     string
}

func (*CmdBeginMoveRepo) AggregateCommand

func (*CmdBeginMoveRepo) AggregateCommand()

type CmdBeginMoveShadow

type CmdBeginMoveShadow struct {
	WorkflowId    uuid.I
	NewShadowPath string
}

func (*CmdBeginMoveShadow) AggregateCommand

func (*CmdBeginMoveShadow) AggregateCommand()

type CmdBeginUnarchive

type CmdBeginUnarchive struct {
	WorkflowId uuid.I
}

func (*CmdBeginUnarchive) AggregateCommand

func (*CmdBeginUnarchive) AggregateCommand()

type CmdBeginUnfreeze

type CmdBeginUnfreeze struct {
	WorkflowId uuid.I
}

func (*CmdBeginUnfreeze) AggregateCommand

func (*CmdBeginUnfreeze) AggregateCommand()

type CmdClearRepoError

type CmdClearRepoError struct {
	ErrorMessage string
}

func (*CmdClearRepoError) AggregateCommand

func (*CmdClearRepoError) AggregateCommand()

type CmdCommitArchive

type CmdCommitArchive struct {
	WorkflowId uuid.I
	TarPath    string
}

func (*CmdCommitArchive) AggregateCommand

func (*CmdCommitArchive) AggregateCommand()

type CmdCommitFreeze

type CmdCommitFreeze struct {
	WorkflowId uuid.I
}

func (*CmdCommitFreeze) AggregateCommand

func (*CmdCommitFreeze) AggregateCommand()

type CmdCommitMoveRepo

type CmdCommitMoveRepo struct {
	WorkflowId      uuid.I
	WorkflowEventId ulid.I
	GlobalPath      string
	FileHost        string
	HostPath        string
	ShadowPath      string
}

func (*CmdCommitMoveRepo) AggregateCommand

func (*CmdCommitMoveRepo) AggregateCommand()

type CmdCommitMoveShadow

type CmdCommitMoveShadow struct {
	WorkflowId      uuid.I
	WorkflowEventId ulid.I
}

func (*CmdCommitMoveShadow) AggregateCommand

func (*CmdCommitMoveShadow) AggregateCommand()

type CmdCommitUnarchive

type CmdCommitUnarchive struct {
	WorkflowId uuid.I
}

func (*CmdCommitUnarchive) AggregateCommand

func (*CmdCommitUnarchive) AggregateCommand()

type CmdCommitUnfreeze

type CmdCommitUnfreeze struct {
	WorkflowId uuid.I
}

func (*CmdCommitUnfreeze) AggregateCommand

func (*CmdCommitUnfreeze) AggregateCommand()

type CmdConfirmGit

type CmdConfirmGit struct {
	GitlabProjectId int64
}

func (*CmdConfirmGit) AggregateCommand

func (*CmdConfirmGit) AggregateCommand()

type CmdConfirmShadow

type CmdConfirmShadow struct {
	ShadowPath string
}

func (*CmdConfirmShadow) AggregateCommand

func (*CmdConfirmShadow) AggregateCommand()

type CmdDeleteArchiveRecipients

type CmdDeleteArchiveRecipients struct{}

func (*CmdDeleteArchiveRecipients) AggregateCommand

func (*CmdDeleteArchiveRecipients) AggregateCommand()

type CmdDeleteShadowBackupRecipients

type CmdDeleteShadowBackupRecipients struct{}

func (*CmdDeleteShadowBackupRecipients) AggregateCommand

func (*CmdDeleteShadowBackupRecipients) AggregateCommand()

type CmdEnableGitlab

type CmdEnableGitlab struct {
	GitlabNamespace string
}

func (*CmdEnableGitlab) AggregateCommand

func (*CmdEnableGitlab) AggregateCommand()

type CmdInitRepo

type CmdInitRepo struct {
	Registry               string
	GlobalPath             string
	CreatorName            string
	CreatorEmail           string
	FileHost               string
	HostPath               string
	GitlabHost             string
	GitlabPath             string
	GitToNogAddr           string
	SubdirTracking         SubdirTracking
	ArchiveRecipients      gpg.Fingerprints
	ShadowBackupRecipients gpg.Fingerprints
}

func (*CmdInitRepo) AggregateCommand

func (*CmdInitRepo) AggregateCommand()

type CmdInitShadowBackup

type CmdInitShadowBackup struct {
	ShadowBackupURL string
}

func (*CmdInitShadowBackup) AggregateCommand

func (*CmdInitShadowBackup) AggregateCommand()

type CmdInitTartt

type CmdInitTartt struct {
	TarttURL string
}

func (*CmdInitTartt) AggregateCommand

func (*CmdInitTartt) AggregateCommand()

type CmdMoveShadowBackup

type CmdMoveShadowBackup struct {
	ShadowBackupURL string
}

func (*CmdMoveShadowBackup) AggregateCommand

func (*CmdMoveShadowBackup) AggregateCommand()

type CmdSetRepoError

type CmdSetRepoError struct {
	ErrorMessage string
}

func (*CmdSetRepoError) AggregateCommand

func (*CmdSetRepoError) AggregateCommand()

type CmdUpdateArchiveRecipients

type CmdUpdateArchiveRecipients struct {
	Keys gpg.Fingerprints
}

func (*CmdUpdateArchiveRecipients) AggregateCommand

func (*CmdUpdateArchiveRecipients) AggregateCommand()

type CmdUpdateShadowBackupRecipients

type CmdUpdateShadowBackupRecipients struct {
	Keys gpg.Fingerprints
}

func (*CmdUpdateShadowBackupRecipients) AggregateCommand

func (*CmdUpdateShadowBackupRecipients) AggregateCommand()

type Event

type Event struct {
	// contains filtered or unexported fields
}

func (*Event) Id

func (e *Event) Id() ulid.I

func (*Event) MarshalProto

func (e *Event) MarshalProto() ([]byte, error)

func (*Event) Parent

func (e *Event) Parent() ulid.I

func (*Event) PbRepoEvent

func (e *Event) PbRepoEvent() *pb.RepoEvent

func (*Event) UnmarshalProto

func (e *Event) UnmarshalProto(data []byte) error

func (Event) WithId

func (e Event) WithId(id ulid.I) events.Event

Receiver by value.

func (Event) WithParent

func (e Event) WithParent(parent ulid.I) events.Event

Receiver by value.

type EventDetailsError

type EventDetailsError struct {
	Err error
}

func (*EventDetailsError) Error

func (err *EventDetailsError) Error() string

type Repos

type Repos struct {
	// contains filtered or unexported fields
}

func New

func New(journal *events.Journal) *Repos

func (*Repos) AbortArchive

func (r *Repos) AbortArchive(
	id uuid.I, vid ulid.I, cmd *CmdAbortArchive,
) (ulid.I, error)

`AbortArchive()` completes a failed freeze.

func (*Repos) AbortFreeze

func (r *Repos) AbortFreeze(
	id uuid.I, vid ulid.I, cmd *CmdAbortFreeze,
) (ulid.I, error)

`AbortFreeze()` completes a failed freeze.

func (*Repos) AbortUnarchive

func (r *Repos) AbortUnarchive(
	id uuid.I, vid ulid.I, cmd *CmdAbortUnarchive,
) (ulid.I, error)

`AbortUnarchive()` completes a failed freeze.

func (*Repos) AbortUnfreeze

func (r *Repos) AbortUnfreeze(
	id uuid.I, vid ulid.I, cmd *CmdAbortUnfreeze,
) (ulid.I, error)

`AbortUnfreeze()` completes a failed freeze.

func (*Repos) BeginArchive

func (r *Repos) BeginArchive(
	id uuid.I, vid ulid.I, cmd *CmdBeginArchive,
) (ulid.I, error)

`BeginArchive()` starts a freeze.

func (*Repos) BeginFreeze

func (r *Repos) BeginFreeze(
	id uuid.I, vid ulid.I, cmd *CmdBeginFreeze,
) (ulid.I, error)

`BeginFreeze()` starts a freeze.

func (*Repos) BeginMoveRepo

func (r *Repos) BeginMoveRepo(
	id uuid.I, vid ulid.I, cmd *CmdBeginMoveRepo,
) (ulid.I, error)

`BeginMoveRepo()` is used by repoinit to start a move-repo workflow from on a corresponding `RegistryEvent`. See `moverepowf` for details.

func (*Repos) BeginMoveShadow

func (r *Repos) BeginMoveShadow(
	id uuid.I, vid ulid.I, workflowId uuid.I, newShadowPath string,
) (ulid.I, error)

`BeginMoveShadow()` starts a workflow to change the shadow location. `workflowId` is a client-generated nonce that is used to identify the workflow instance and to handle concurrent and repeated invocations.

func (*Repos) BeginUnarchive

func (r *Repos) BeginUnarchive(
	id uuid.I, vid ulid.I, cmd *CmdBeginUnarchive,
) (ulid.I, error)

`BeginUnarchive()` starts a freeze.

func (*Repos) BeginUnfreeze

func (r *Repos) BeginUnfreeze(
	id uuid.I, vid ulid.I, cmd *CmdBeginUnfreeze,
) (ulid.I, error)

`BeginUnfreeze()` starts a freeze.

func (*Repos) ClearRepoError

func (r *Repos) ClearRepoError(
	id uuid.I, vid ulid.I, cmd *CmdClearRepoError,
) (ulid.I, error)

func (*Repos) CommitArchive

func (r *Repos) CommitArchive(
	id uuid.I, vid ulid.I, cmd *CmdCommitArchive,
) (ulid.I, error)

`CommitArchive()` completes a successful freeze.

func (*Repos) CommitFreeze

func (r *Repos) CommitFreeze(
	id uuid.I, vid ulid.I, cmd *CmdCommitFreeze,
) (ulid.I, error)

`CommitFreeze()` completes a successful freeze.

func (*Repos) CommitMoveRepo

func (r *Repos) CommitMoveRepo(
	id uuid.I, vid ulid.I, cmd *CmdCommitMoveRepo,
) (ulid.I, error)

`CommitMoveRepo()` completes the workflow that started with `BeginMoveRepo()`.

func (*Repos) CommitMoveShadow

func (r *Repos) CommitMoveShadow(
	id uuid.I, vid ulid.I, workflowId uuid.I, workflowEventId ulid.I,
) (ulid.I, error)

`CommitMoveShadow()` completes the workflow that started with `BeginMoveShadow()`.

func (*Repos) CommitUnarchive

func (r *Repos) CommitUnarchive(
	id uuid.I, vid ulid.I, cmd *CmdCommitUnarchive,
) (ulid.I, error)

`CommitUnarchive()` completes a successful freeze.

func (*Repos) CommitUnfreeze

func (r *Repos) CommitUnfreeze(
	id uuid.I, vid ulid.I, cmd *CmdCommitUnfreeze,
) (ulid.I, error)

`CommitUnfreeze()` completes a successful freeze.

func (*Repos) ConfirmGit

func (r *Repos) ConfirmGit(
	id uuid.I, vid ulid.I, gitlabProjectId int64,
) (ulid.I, error)

func (*Repos) ConfirmShadow

func (r *Repos) ConfirmShadow(
	id uuid.I, vid ulid.I, shadowPath string,
) (ulid.I, error)

func (*Repos) DeleteArchiveRecipients

func (r *Repos) DeleteArchiveRecipients(
	id uuid.I, vid ulid.I,
) (ulid.I, error)

`DeleteArchiveRecipients()` disables archive encryption.

func (*Repos) DeleteShadowBackupRecipients

func (r *Repos) DeleteShadowBackupRecipients(
	id uuid.I, vid ulid.I,
) (ulid.I, error)

`DeleteShadowBackupRecipients()` disables shadow backup encryption.

func (*Repos) EnableGitlab

func (r *Repos) EnableGitlab(
	id uuid.I, vid ulid.I, gitlabNamespace string,
) (ulid.I, error)

Internal use only. External clients must enable GitLab via fsoregistry.

func (*Repos) FindId

func (r *Repos) FindId(id uuid.I) (*State, error)

func (*Repos) Init

func (r *Repos) Init(id uuid.I, info *CmdInitRepo) (ulid.I, error)

func (*Repos) InitShadowBackup

func (r *Repos) InitShadowBackup(
	id uuid.I, vid ulid.I, shadowBackupURL string,
) (ulid.I, error)

`InitShadowBackup()` sets the archive URL.

func (*Repos) InitTartt

func (r *Repos) InitTartt(
	id uuid.I, vid ulid.I, tarttURL string,
) (ulid.I, error)

`InitTartt()` sets the archive URL.

func (*Repos) MoveShadowBackup

func (r *Repos) MoveShadowBackup(
	id uuid.I, vid ulid.I, shadowBackupURL string,
) (ulid.I, error)

`MoveShadowBackup()` changes the archive URL.

func (*Repos) SetRepoError

func (r *Repos) SetRepoError(
	id uuid.I, vid ulid.I, cmd *CmdSetRepoError,
) (ulid.I, error)

func (*Repos) UpdateArchiveRecipients

func (r *Repos) UpdateArchiveRecipients(
	id uuid.I, vid ulid.I, keys gpg.Fingerprints,
) (*State, error)

`UpdateArchiveRecipients()` sets the archive GPG keys, enabling encryption.

func (*Repos) UpdateShadowBackupRecipients

func (r *Repos) UpdateShadowBackupRecipients(
	id uuid.I, vid ulid.I, keys gpg.Fingerprints,
) (*State, error)

`UpdateShadowBackupRecipients()` sets the shadow backup GPG keys, enabling encryption.

type State

type State struct {
	// contains filtered or unexported fields
}

func (*State) AggregateState

func (*State) AggregateState()

func (*State) ArchiveRecipients

func (s *State) ArchiveRecipients() gpg.Fingerprints

func (*State) ArchiveURL

func (s *State) ArchiveURL() string

func (*State) ErrorMessage

func (s *State) ErrorMessage() string

func (*State) FileLocation

func (s *State) FileLocation() string

func (*State) GitlabLocation

func (s *State) GitlabLocation() string

func (*State) GitlabProjectId

func (s *State) GitlabProjectId() int64

func (*State) GlobalPath

func (s *State) GlobalPath() string

func (*State) HasActiveMoveRepo

func (s *State) HasActiveMoveRepo() bool

func (*State) HasActiveMoveShadow

func (s *State) HasActiveMoveShadow() bool

func (*State) Id

func (s *State) Id() uuid.I

func (*State) MayArchive

func (st *State) MayArchive() (ok bool, reason string)

`MayArchiveRepo()` is used in `BeginArchiveRepo()` to check preconditions before initializing an archive-repo workflow.

func (*State) MoveRepoId

func (s *State) MoveRepoId() uuid.I

func (*State) MoveShadowId

func (s *State) MoveShadowId() uuid.I

func (*State) Registry

func (s *State) Registry() string

func (*State) SetVid

func (s *State) SetVid(vid ulid.I)

func (*State) ShadowBackupRecipients

func (s *State) ShadowBackupRecipients() gpg.Fingerprints

func (*State) ShadowBackupURL

func (s *State) ShadowBackupURL() string

func (*State) ShadowLocation

func (s *State) ShadowLocation() string

func (*State) StorageTier

func (st *State) StorageTier() StorageTierCode

func (*State) TarttTarPath

func (s *State) TarttTarPath() string

func (*State) Vid

func (s *State) Vid() ulid.I

type StorageTierCode

type StorageTierCode int

XXX Maybe factor out into a common package, e.g. `storagetier`, that is used by packages `fsoregistry` and `fsorepos`.

const (
	StorageTierUnspecified StorageTierCode = iota
	StorageOnline
	StorageFrozen
	StorageArchived
	StorageFreezing
	StorageFreezeFailed
	StorageUnfreezing
	StorageUnfreezeFailed
	StorageArchiving
	StorageArchiveFailed
	StorageUnarchiving
	StorageUnarchiveFailed
)

type SubdirTracking

type SubdirTracking int
const (
	SubdirTrackingUnspecified SubdirTracking = iota
	EnterSubdirs
	BundleSubdirs
	IgnoreSubdirs
	IgnoreMost
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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