Documentation
¶
Overview ¶
Package catalog reads and repairs the plugin catalog stored in MongoDB by plugin-service.
Index ¶
- Variables
- type Conflict
- type Entry
- type Removal
- type Store
- func (s *Store) Close(ctx context.Context) error
- func (s *Store) Entries(ctx context.Context) ([]Entry, error)
- func (s *Store) RemoveVersions(ctx context.Context, module string, versions map[string]string, dryRun bool) (Removal, error)
- func (s *Store) SetHash(ctx context.Context, module, version, oldHash, newHash string) error
- type SyncResult
Constants ¶
This section is empty.
Variables ¶
var ErrHashChanged = errors.New("the recorded hash is not the expected one")
ErrHashChanged is returned when the catalog changed since it was read.
Functions ¶
This section is empty.
Types ¶
type Conflict ¶
type Conflict struct {
Key string `json:"key"`
Source string `json:"source"`
Target string `json:"target"`
}
Conflict is a hash entry recorded with different values in the source and the target.
type Entry ¶
type Entry struct {
Module string `json:"module"`
Version string `json:"version"`
Runtime string `json:"runtime,omitempty"`
Stars int `json:"stars"`
Listed bool `json:"listed"`
Disabled bool `json:"disabled,omitempty"`
Hidden bool `json:"hidden,omitempty"`
Hash string `json:"recordedHash"`
}
Entry is one archive hash recorded by plugin-service, with the plugin it belongs to.
type Removal ¶
type Removal struct {
Versions []string `json:"versions"`
LatestVersion string `json:"latestVersion"`
Hidden bool `json:"hidden"`
}
Removal is the outcome of RemoveVersions.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store gives access to one plugin catalog database.
func (*Store) RemoveVersions ¶
func (s *Store) RemoveVersions(ctx context.Context, module string, versions map[string]string, dryRun bool) (Removal, error)
RemoveVersions removes versions, given as version → recorded hash, from the versions and hashes of module. latestVersion moves to the newest version left, and the plugin is hidden when none is left. The removed versions are recorded in removedVersions for Sync. Nothing is written if a recorded hash or the version list changed in the meantime, or in dry-run.
type SyncResult ¶
type SyncResult struct {
// Inserted are the plugins created in the source after the dump.
Inserted []string `json:"inserted"`
// Updated are the plugins whose metadata, versions or hashes changed in the source.
Updated []string `json:"updated"`
// Hashes are the hash entries copied to the target.
Hashes []Entry `json:"hashes"`
// Conflicts are hash entries recorded on both sides with different values. The target value is kept.
Conflicts []Conflict `json:"conflicts"`
// Skipped are plugins missing in the target but created before the dump, so removed from it on purpose.
Skipped []string `json:"skipped"`
// Changed are plugins written in the target while Sync ran, left as is: run it again.
Changed []string `json:"changed"`
// MissingInSource are plugins of the target the source does not have, deleted after the dump or added to the target.
// They are left as is: review them by hand.
MissingInSource []string `json:"missingInSource"`
}
SyncResult describes what Sync copied, or would copy in dry-run.
func Sync ¶
Sync copies into dst what was added to src after the dump taken at since.
Plugins created after since are inserted as is. For the other plugins, metadata is copied, versions missing from dst are appended unless RemoveVersions removed them from dst, and hash entries missing from dst are added for the versions dst lists. Nothing is removed from dst and no dst hash is changed, so the fixes applied to dst survive. A plugin written in dst while Sync runs is left as is and reported in Changed. Plugins of dst that src lacks are only reported, in MissingInSource.