Documentation
¶
Overview ¶
Package plan handles the synchronization plan.
Each synchronization plan is a set of checks and actions to perform on specified paths that will result in the "plugin" repository being updated.
Index ¶
- func CopyDirectory(src, dst string) error
- func IsCheckFail(err error) bool
- type Action
- type ActionConditions
- type ActionSet
- type Check
- type CheckFail
- type FileUnalteredChecker
- type OverwriteDirectoryAction
- type OverwriteFileAction
- type PathExistsChecker
- type Plan
- type RepoID
- type RepoIsCleanChecker
- type RepoSetup
- type Setup
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopyDirectory ¶
CopyDirectory copies the directory src to dst so that after a successful operation the contents of src and dst are equal.
func IsCheckFail ¶
IsCheckFail determines if an error is a check fail error.
Types ¶
type Action ¶
type Action interface { // Run performs the action on the specified path. Run(string, Setup) error // Check runs checks associated with the action // before running it. Check(string, Setup) error }
Action runs the defined action.
type ActionConditions ¶
type ActionConditions struct { // Conditions are checkers run before executing the // action. If any one fails (returns an error), the action // itself is not executed. Conditions []Check }
ActionConditions adds condition support to actions.
type ActionSet ¶
ActionSet is a set of actions along with a set of paths to perform those actions on.
type CheckFail ¶
type CheckFail string
CheckFail is a custom error type used to indicate a check that did not pass (but did not fail due to external causes. Use `IsCheckFail` to check if an error is a check failure.
func CheckFailf ¶
CheckFailf creates an error with the specified message string. The error will pass the IsCheckFail filter.
type FileUnalteredChecker ¶
type FileUnalteredChecker struct { Params struct { SourceRepo RepoID `json:"compared-to"` TargetRepo RepoID `json:"in"` } }
FileUnalteredChecker checks whether the file in Repo is an unaltered version of that same file in ReferenceRepo.
Its purpose is to check that a file has not been changed after forking a repository. It could be an old unaltered version, so the git history of the file is traversed until a matching version is found.
If the repositories in the parameters are not specified, reference will default to the source repository and repo - to the target.
type OverwriteDirectoryAction ¶
type OverwriteDirectoryAction struct { ActionConditions Params struct { // Create determines whether the target directory // will be created if it does not exist. Create bool `json:"create"` } }
OverwriteDirectoryAction is used to completely overwrite directories. If the target directory exists, it will be removed first.
type OverwriteFileAction ¶
type OverwriteFileAction struct { ActionConditions Params struct { // Create determines whether the target directory // will be created if it does not exist. Create bool `json:"create"` } }
OverwriteFileAction is used to overwrite a file.
type PathExistsChecker ¶
type PathExistsChecker struct { Params struct { Repo RepoID } }
PathExistsChecker checks whether the fle or directory with the path exists. If it does not, an error is returned.
type Plan ¶
type Plan struct { Checks []Check `json:"checks"` // Each set of paths has multiple actions associated, each a fallback for the one // previous to it. Actions []ActionSet }
Plan defines the plan for synchronizing a target and a source directory.
func (*Plan) UnmarshalJSON ¶
UnmarshalJSON implements the `json.Unmarshaler` interface.
type RepoIsCleanChecker ¶
type RepoIsCleanChecker struct { Params struct { Repo RepoID } }
RepoIsCleanChecker checks whether the git repository is clean.
type RepoSetup ¶
type RepoSetup struct { Git *git.Repository Path string }
RepoSetup contains relevant information about a single repository (either source or target).
func GetRepoSetup ¶
GetRepoSetup returns the repository setup for the specified path.
type Setup ¶
Setup contains information about both parties in the sync: the plugin repository being updated and the source of the update - the template repo.
func (Setup) GetRepo ¶
GetRepo is a helper to get the required repo setup. If the target parameter is not one of "plugin" or "template", the function panics.