Documentation
¶
Overview ¶
campaign_update_repository.go — SQL for campaign_package_updates.
One repository per aggregate root: this table is keyed by (campaign, package) and owned by the packages plugin, so it lives beside the package repository rather than inside it, which keeps PackageRepository's many fakes untouched.
campaign_update_service.go — per-campaign update modes for packages.
The packages plugin stays type-agnostic: it decides what a mode MEANS (hold, freeze, approve) and asks a per-type CampaignBinding where a campaign's mode and version are stored. Game systems have no per-campaign state anywhere else, so their binding keeps it in campaign_package_updates. The Foundry module already keeps a pin and pin mode in the campaign's settings (and its manifest endpoint serves from them), so its binding, in the foundry_vtt plugin, maps that onto these modes instead of creating a second copy. The held version of a newly installed release lives in campaign_package_updates for every type.
Package packages provides the package manager plugin for Chronicle. This file embeds the plugin's SQL migration files so they are available in the compiled binary regardless of the runtime working directory.
Package packages manages external package repositories for Chronicle. It provides version management, auto-updates, and admin UI for game system packs and the Foundry VTT module pulled from GitHub repos.
prune.go — stale-version cleanup for installed SYSTEM packages.
Every InstallVersion leaves the previous version's dir on disk, so media/packages/systems/<slug>/ accumulates one folder per release ever installed. This file implements the safe reclaim: a dry-run scan (the admin wizard's preview) and an execute path that deletes only folders provably not in use.
Scope: SYSTEM packages ONLY. Foundry-module version dirs are served to campaigns via historical pins (resolveCampaignManifest hard-errors with ErrPinnedVersionNotInstalled if a pinned dir is missing), so they are never touched here.
retention.go — the automatic old-version rule: its settings, validation, the pure "which folders go" selection, and the service entry points.
The default is manual: nothing is removed unless an admin clicks Clean up, so an install that never opens the new settings behaves exactly as before. Automatic runs and the manual card share one deletion path (prune.go) so there is a single protected set; this file only decides WHICH folders a rule nominates, never whether a protected one may go.
system_binding.go — the game-system CampaignBinding.
A game system has no per-campaign state anywhere else, so its mode and version live in campaign_package_updates. A campaign with no row is automatic, which is how every campaign followed a system before modes.
update_mode.go — the per-campaign update choice for a package.
A campaign follows each package it uses in one of three ways. The choice is the same for every package type; where it is stored differs by type (see CampaignBinding), and everything here stays type-agnostic.
Index ¶
- Constants
- Variables
- func ConfigureSettings(svc PackageService, settings SettingsReader)
- func RegisterOwnerRoutes(authenticated *echo.Group, oh *OwnerHandler)
- func RegisterPostInstallHook(svc PackageService, h PostInstallHook)
- func RegisterRoutes(admin *echo.Group, h *Handler, reauth echo.MiddlewareFunc)
- func ReleaseNoteLines(notes string, n int) []string
- func RetentionSummary(site RetentionSettings, pkg *Package) string
- func SetCampaignVersionsProvider(svc PackageService, ...)
- func SetLoadedDirsProvider(svc PackageService, fn func() map[string]bool)
- func SetManifestValidator(svc PackageService, fn func(manifestPath string) error)
- func SetOnSystemInstall(svc PackageService, fn func(installPath string))
- func SetOnSystemUnload(svc PackageService, fn func(packageRoot string))
- func SetPostInstallVerifier(svc PackageService, fn func(installPath, version string) error)
- func SetSystemDirProvider(svc PackageService, fn func(systemID string) string)
- func ValidVersionString(v string) bool
- func ValidatePackageContents(extractDir string, validateManifest, scanContent bool, maxFileSize int64) error
- func ValidateRepoURL(repoURL, policy string) error
- func ValidateRetentionCount(n int, what string) error
- type ActivityRecorder
- type ActorInfo
- type AddPackageInput
- type AsksByDefaultBinding
- type AuditLogger
- type CampaignBinding
- type CampaignPackageState
- type CampaignUpdateRepository
- type CampaignUpdateRow
- type CampaignUpdateService
- type DeprecateInput
- type GitHubAPIError
- type GitHubAsset
- type GitHubClient
- type GitHubRelease
- type Handler
- func (h *Handler) AddPackage(c *echo.Context) error
- func (h *Handler) ArchivePackage(c *echo.Context) error
- func (h *Handler) CheckForUpdates(c *echo.Context) error
- func (h *Handler) ClearPinnedVersion(c *echo.Context) error
- func (h *Handler) DeprecatePackage(c *echo.Context) error
- func (h *Handler) GetSecuritySettings(c *echo.Context) error
- func (h *Handler) GetUsage(c *echo.Context) error
- func (h *Handler) HoldCampaign(c *echo.Context) error
- func (h *Handler) InstallVersion(c *echo.Context) error
- func (h *Handler) ListPackages(c *echo.Context) error
- func (h *Handler) ListPendingSubmissions(c *echo.Context) error
- func (h *Handler) ListVersions(c *echo.Context) error
- func (h *Handler) MoveCampaign(c *echo.Context) error
- func (h *Handler) PruneExecute(c *echo.Context) error
- func (h *Handler) PrunePreview(c *echo.Context) error
- func (h *Handler) ReleaseCampaign(c *echo.Context) error
- func (h *Handler) RemindCampaignOwner(c *echo.Context) error
- func (h *Handler) RemovePackage(c *echo.Context) error
- func (h *Handler) ReviewPackage(c *echo.Context) error
- func (h *Handler) SaveSecuritySettings(c *echo.Context) error
- func (h *Handler) SetActivityRecorder(r ActivityRecorder)
- func (h *Handler) SetAutoUpdate(c *echo.Context) error
- func (h *Handler) SetCampaignUpdates(svc CampaignUpdateService)
- func (h *Handler) SetOwnerReminder(r OwnerReminder)
- func (h *Handler) SetPinnedVersion(c *echo.Context) error
- func (h *Handler) SetRetention(c *echo.Context) error
- func (h *Handler) SetTypeUI(t PackageType, ui TypeUI)
- func (h *Handler) UnarchivePackage(c *echo.Context) error
- func (h *Handler) UndeprecatePackage(c *echo.Context) error
- func (h *Handler) UpdateRepoURL(c *echo.Context) error
- type InstallVersionInput
- type OwnerHandler
- type OwnerReminder
- type Package
- type PackageRepository
- type PackageRow
- type PackageSecuritySettings
- type PackageService
- type PackageStatus
- type PackageType
- type PackageUsage
- type PackageVersion
- type PackagesPageData
- type PinVersionInput
- type PostCommitHook
- type PostInstallHook
- type PruneResult
- type ReconcileResult
- type RetentionMode
- type RetentionOverrideInput
- type RetentionSettings
- type ReviewPackageInput
- type ServedVersion
- type SetUpdateModeInput
- type SettingsReader
- type SettingsWriter
- type StaleVersion
- type SubmitPackageInput
- type TypeUI
- type UpdateMode
- type UpdatePolicy
- type UpdatePolicyInput
- type UpdateRepoURLInput
Constants ¶
const ( EventCampaignUpdateModeSet = "packages.campaign_update_mode_set" EventCampaignUpdateHeld = "packages.campaign_update_held" EventCampaignUpdateApproved = "packages.campaign_update_approved" // EventCampaignUpdateSwitched is a move to a version the owner or an admin // picked rather than the one that was waiting. EventCampaignUpdateSwitched = "packages.campaign_update_switched" EventCampaignUpdateDismissed = "packages.campaign_update_dismissed" EventCampaignUpdateAdminHold = "packages.campaign_update_admin_hold" )
Audit event types written when a campaign's update choice changes. Same shape and sink as the Foundry force-pin events.
const ( PackagesTabInstalled = "installed" PackagesTabUpdates = "updates" PackagesTabReview = "review" PackagesTabSettings = "settings" )
Top-level tabs of the Packages page.
const ( PanelTabOverview = "overview" PanelTabVersions = "versions" PanelTabCampaigns = "campaigns" PanelTabSettings = "settings" )
Tabs of the open package's side panel.
const ( FilterActive = "" FilterSystems = "systems" FilterFoundry = "foundry" FilterProblems = "problems" FilterRetired = "retired" )
Filters of the Installed list. The empty filter is "Active": everything that is not retired.
const ( // DefaultRetentionKeepNewest and DefaultRetentionUnusedDays pre-fill the // number boxes; they take effect only once the admin picks that mode. DefaultRetentionKeepNewest = 2 DefaultRetentionUnusedDays = 30 )
const OwnerUploadAutoApprove = "auto_approve"
OwnerUploadAutoApprove allows campaign owners to upload custom systems without admin review. Suitable for trusted private instances.
const OwnerUploadDisabled = "disabled"
OwnerUploadDisabled prevents campaign owners from uploading custom systems.
const OwnerUploadRequireApproval = "require_approval"
OwnerUploadRequireApproval requires admin approval before owner-uploaded custom systems are installed. Suitable for public hosted instances.
const RepoPolicyAllowAll = "allow_all"
RepoPolicyAllowAll allows any HTTPS URL.
const RepoPolicyAnyGit = "any_git"
RepoPolicyAnyGit allows any public git host.
const RepoPolicyGitHubOnly = "github_only"
RepoPolicyGitHubOnly restricts submissions to GitHub repos only.
Variables ¶
var MigrationsFS embed.FS
MigrationsFS contains the embedded SQL migration files for the packages plugin.
Functions ¶
func ConfigureSettings ¶
func ConfigureSettings(svc PackageService, settings SettingsReader)
ConfigureSettings wires settings reader/writer into the package service. Called from routes.go after both services are initialized.
func RegisterOwnerRoutes ¶
func RegisterOwnerRoutes(authenticated *echo.Group, oh *OwnerHandler)
RegisterOwnerRoutes mounts the owner-facing system submission routes. These routes require authentication but NOT admin privileges.
func RegisterPostInstallHook ¶
func RegisterPostInstallHook(svc PackageService, h PostInstallHook)
RegisterPostInstallHook attaches a PostInstallHook to the install pipeline. Sub-plugins call this at boot; the hook fires after every install whose package type matches. Multiple hooks per type are allowed; they fire in registration order.
func RegisterRoutes ¶
func RegisterRoutes(admin *echo.Group, h *Handler, reauth echo.MiddlewareFunc)
RegisterRoutes mounts all package manager routes under the given admin group. All routes require site admin authentication (enforced by the parent group). reauth guards the writes that change which code the site runs or delete package files: adding, removing or re-pointing a package, pruning, reviewing a submission (approving one fetches and installs its code), the settings that decide what may be deleted or accepted (the site settings form, which carries the old-version rule, and a package's own rule), and the actions that hold or move a campaign against its owner's choice.
func ReleaseNoteLines ¶
ReleaseNoteLines is releaseNoteLines for another plugin's page, so a campaign owner reads release notes the same way the admin does.
func RetentionSummary ¶
func RetentionSummary(site RetentionSettings, pkg *Package) string
RetentionSummary is the plain-words sentence the Versions tab shows.
func SetCampaignVersionsProvider ¶
func SetCampaignVersionsProvider(svc PackageService, fn func(ctx context.Context) (map[string]map[string]bool, error))
SetCampaignVersionsProvider wires the set of versions campaigns are on into clean-up (see prune.go). Clean-up refuses to run until it is wired.
func SetLoadedDirsProvider ¶
func SetLoadedDirsProvider(svc PackageService, fn func() map[string]bool)
SetLoadedDirsProvider wires the systems loader's live served-dir set into the prune safety check (dependency inversion — packages must not import systems). Pruning FAILS CLOSED when unset: with no signal about what the loader is serving, nothing is deleted.
func SetManifestValidator ¶
func SetManifestValidator(svc PackageService, fn func(manifestPath string) error)
SetManifestValidator wires full system-manifest validation into the install pipeline (dependency inversion — packages must not import systems). The app layer passes systems.LoadManifest so a manifest the loader would reject at boot is rejected at INSTALL time instead, with the real validation message surfaced to the admin, and no DB/disk state change.
func SetOnSystemInstall ¶
func SetOnSystemInstall(svc PackageService, fn func(installPath string))
SetOnSystemInstall wires a callback invoked after a system package is installed, receiving the installed dir. Used to rescan the system registry AND force-load the exact installed dir so explicit installs (including rollbacks to an older version) always take effect.
func SetOnSystemUnload ¶
func SetOnSystemUnload(svc PackageService, fn func(packageRoot string))
SetOnSystemUnload wires the callback that stops serving a removed or archived system package.
func SetPostInstallVerifier ¶
func SetPostInstallVerifier(svc PackageService, fn func(installPath, version string) error)
SetPostInstallVerifier wires the loaded-state check that runs after a system install's registry rescan (dependency inversion — packages must not import systems). The app layer passes a closure over systems.LoadedHealth + DiagnosticEvents.
func SetSystemDirProvider ¶
func SetSystemDirProvider(svc PackageService, fn func(systemID string) string)
SetSystemDirProvider wires the lookup of which folder serves a system id, so one package can't replace a system another package provides.
func ValidVersionString ¶
ValidVersionString reports whether v is safe to use as a package version in a filesystem path or URL. Every path built from a stored or requested version must pass this check, so callers do not each re-implement it.
func ValidatePackageContents ¶
func ValidatePackageContents(extractDir string, validateManifest, scanContent bool, maxFileSize int64) error
ValidatePackageContents checks extracted package files for safety. validateManifest requires a manifest.json at root. scanContent rejects executables, symlinks, and oversized files.
func ValidateRepoURL ¶
ValidateRepoURL checks the submitted URL against the site's repo policy. Returns nil if the URL is valid for the given policy.
func ValidateRetentionCount ¶
ValidateRetentionCount rejects N outside 1..maxRetentionN. N < 1 would mean "keep nothing", which the safety rules forbid anyway.
Types ¶
type ActivityRecorder ¶
type ActivityRecorder interface {
RecordAdminChange(c *echo.Context, action, targetType, targetID, label string)
}
ActivityRecorder is the slice of the admin change log this plugin writes to. It is declared here, not imported from the admin plugin, so the plugins stay independent; app wiring supplies an adapter that stamps the signed-in admin. Recording is best-effort: implementations must not fail the request.
type ActorInfo ¶
ActorInfo says who is asking, for the audit trail and the admin "approve for them" path. Admin is true when a site admin acts on a campaign's behalf.
type AddPackageInput ¶
type AddPackageInput struct {
RepoURL string `json:"repo_url" form:"repo_url"`
Name string `json:"name" form:"name"`
Type string `json:"type" form:"type"`
}
AddPackageInput is the request to add a new package repository.
type AsksByDefaultBinding ¶
type AsksByDefaultBinding interface {
AsksByDefault() bool
}
AsksByDefaultBinding is implemented by a binding whose package type never moves a campaign to a new version on its own. For such a type a campaign with no choice of its own is frozen where it is the first time a version would move it, and a pinned campaign is offered the waiting version too, so every campaign ends up either on its version or asked. Game systems do not implement it and keep following the installed version.
type AuditLogger ¶
type AuditLogger interface {
LogEvent(ctx context.Context, eventType, userID, actorID, ip, userAgent string, details map[string]any) error
}
AuditLogger writes one audit row per action. Same shape as the security event logger so the app can pass it straight through; nil disables it.
type CampaignBinding ¶
type CampaignBinding interface {
// PackageType is the type this binding serves.
PackageType() PackageType
// UsedBy reports whether the campaign uses the package at all.
UsedBy(ctx context.Context, campaignID string, pkg *Package) (bool, error)
// State reports the campaign's stored mode and explicit version. Mode and
// Version are the only fields it must fill.
State(ctx context.Context, campaignID string, pkg *Package) (CampaignPackageState, error)
// Campaigns lists every campaign that uses the package with its mode,
// version and campaign identity (id, name, owner).
Campaigns(ctx context.Context, pkg *Package) ([]CampaignPackageState, error)
// Apply stores mode and version. The service has already validated them
// (mode known, version installed on disk); version is "" for automatic.
Apply(ctx context.Context, campaignID string, pkg *Package, mode UpdateMode, version string, actor ActorInfo) error
// Freeze records the version a campaign was running at install time and
// nothing else: it must not rewrite any stored mode, so a campaign whose
// mode is derived from older data keeps that data as it was.
Freeze(ctx context.Context, campaignID string, pkg *Package, mode UpdateMode, version string) error
}
CampaignBinding is how one package type stores a campaign's mode and version. Implemented by the packages plugin for game systems and by the foundry_vtt plugin for the Foundry module.
type CampaignPackageState ¶
type CampaignPackageState struct {
CampaignID string
CampaignName string
OwnerName string
PackageID string
PackageSlug string
PackageType PackageType
Mode UpdateMode
// Version is the explicit version the campaign is on. Empty means it has
// none of its own and follows the installed version (always the case for
// automatic; transiently possible for the other two until the first
// install freezes it).
Version string
// EffectiveVersion is the version the campaign actually runs: Version, or
// the package's installed version when Version is empty.
EffectiveVersion string
// HeldVersion is a newly installed version waiting for approval. Set only
// for a mode that holds (see holds): approve_first, and pinned for a
// package type that asks by default.
HeldVersion string
// HeldAt is when HeldVersion was first offered; nil when nothing waits.
HeldAt *time.Time
// DismissedVersion is the waiting version the owner answered "Later" to.
// The owner's prompt is hidden while it equals HeldVersion.
DismissedVersion string
// AdminHold is true while a site admin is keeping the campaign on
// EffectiveVersion. The owner cannot approve or switch while it is set.
AdminHold bool
AdminHoldAt *time.Time
// Explicit is true when the campaign's mode was chosen through the update
// modes themselves rather than derived from older stored data. Install
// refuses to move an explicit campaign it cannot hold; a derived one keeps
// the older best-effort behaviour.
Explicit bool
}
CampaignPackageState is one campaign's standing on one package.
type CampaignUpdateRepository ¶
type CampaignUpdateRepository interface {
// Get returns the row, or (nil, nil) when the campaign has no choice
// stored (meaning automatic).
Get(ctx context.Context, campaignID, packageID string) (*CampaignUpdateRow, error)
// ListByPackage returns every stored row for a package.
ListByPackage(ctx context.Context, packageID string) ([]CampaignUpdateRow, error)
// ListHeld returns every row that has a held version, across packages.
ListHeld(ctx context.Context) ([]CampaignUpdateRow, error)
// ListKeptVersions returns every non-empty version or held version stored
// for a SYSTEM package, keyed by package slug then version. Clean-up uses
// it to protect every version some campaign is on.
ListKeptVersions(ctx context.Context) (map[string]map[string]bool, error)
// UpsertModeVersion writes mode and version and leaves held_version alone.
UpsertModeVersion(ctx context.Context, campaignID, packageID string, mode UpdateMode, version string) error
// SetHeld records (or with "" clears) the held version. Clearing never
// creates a row. Offering a different version restarts HeldAt; offering the
// same one again keeps it.
SetHeld(ctx context.Context, campaignID, packageID, held string) error
// SetDismissed records the waiting version the owner chose "Later" for.
SetDismissed(ctx context.Context, campaignID, packageID, version string) error
// SetAdminHold turns the site admin's hold on or off. Turning it off never
// creates a row.
SetAdminHold(ctx context.Context, campaignID, packageID string, hold bool) error
// DeleteDefaultRows removes rows that say nothing (automatic, no version,
// no held version, no dismissal, no admin hold) and reports how many went.
DeleteDefaultRows(ctx context.Context) (int64, error)
}
CampaignUpdateRepository is the data layer for per-campaign update choices.
func NewCampaignUpdateRepository ¶
func NewCampaignUpdateRepository(db *sql.DB) CampaignUpdateRepository
NewCampaignUpdateRepository builds the MariaDB implementation.
type CampaignUpdateRow ¶
type CampaignUpdateRow struct {
CampaignID string
CampaignName string // Filled by the list queries only; "" from Get.
PackageID string
Mode UpdateMode
Version string
HeldVersion string
// HeldAt is when HeldVersion was first offered, so the admin can see how
// long an owner has been asked.
HeldAt *time.Time
// DismissedVersion is the waiting version the owner answered "Later" to.
// It hides the owner's prompt for that version only: a newer one asks
// again.
DismissedVersion string
// AdminHold is set while a site admin is keeping the campaign on its
// version; the owner cannot move it until the admin lets go.
AdminHold bool
AdminHoldAt *time.Time
}
CampaignUpdateRow is one stored row. Version, HeldVersion and DismissedVersion are "" when NULL, and the times are nil.
type CampaignUpdateService ¶
type CampaignUpdateService interface {
// CampaignState returns one campaign's mode, version and held update for
// one package.
CampaignState(ctx context.Context, campaignID, packageID string) (*CampaignPackageState, error)
// CampaignStates returns the campaign's standing on every installed
// package it uses (its game-system package and the Foundry module).
CampaignStates(ctx context.Context, campaignID string) ([]CampaignPackageState, error)
// SetMode changes a campaign's mode for one package (owner action).
SetMode(ctx context.Context, in SetUpdateModeInput, actor ActorInfo) (*CampaignPackageState, error)
// ApproveHeld moves an approve_first campaign onto its held version. The
// owner calls it with actor.Admin false; a site admin approving on the
// owner's behalf passes true.
ApproveHeld(ctx context.Context, campaignID, packageID string, actor ActorInfo) (*CampaignPackageState, error)
// ApproveVersion is ApproveHeld for a caller that names the version it was
// shown: it fails if a different one is waiting by now.
ApproveVersion(ctx context.Context, campaignID, packageID, version string, actor ActorInfo) (*CampaignPackageState, error)
// SwitchVersion keeps a campaign on a version the caller picked (an owner
// going back from a new version, or an admin moving it). The version must
// be a known release whose folder is on disk. An owner is refused while a
// site admin holds the campaign; an admin (actor.Admin) is not.
SwitchVersion(ctx context.Context, campaignID, packageID, version string, actor ActorInfo) (*CampaignPackageState, error)
// DismissHeld records that the owner answered "Later" to the waiting
// version, which must still be the one waiting.
DismissHeld(ctx context.Context, campaignID, packageID, version string) (*CampaignPackageState, error)
// SetAdminHold keeps a campaign on its current version against its
// owner's Update, or lets go. A campaign that has no version of its own
// yet is frozen on the one it runs first.
SetAdminHold(ctx context.Context, campaignID, packageID string, hold bool, actor ActorInfo) (*CampaignPackageState, error)
// InstalledVersions lists the package's known releases whose folder is on
// disk, newest first: the versions a campaign can be moved to.
InstalledVersions(ctx context.Context, packageID string) ([]string, error)
// CampaignsOnPackage lists every campaign on a package with its mode,
// version and any held update (the admin panel's Campaigns tab).
CampaignsOnPackage(ctx context.Context, packageID string) ([]CampaignPackageState, error)
// HeldUpdates lists every campaign currently holding an update.
HeldUpdates(ctx context.Context) ([]CampaignPackageState, error)
// ServedVersion resolves the version a campaign's files come from. It
// never errors: anything it cannot honour falls back to the installed
// version, which is what every campaign was served before modes existed.
ServedVersion(ctx context.Context, campaignID string, pkg *Package) ServedVersion
// OnInstall runs before an install is committed: pinned and approve_first
// campaigns are frozen on the version they were running. It writes no
// holds and no audit rows, so a refused install leaves none behind. A
// campaign whose mode was set explicitly and cannot be frozen fails the
// call so the install is refused rather than silently moving it; a
// campaign whose mode is derived from older data is logged and skipped,
// as before.
OnInstall(ctx context.Context, pkg *Package, previousVersion, newVersion string) error
// OnInstalled runs after the install is committed and hands approve_first
// campaigns the new version to approve (writing the hold and its audit
// event). pkg.InstalledVersion is the new version.
OnInstalled(ctx context.Context, pkg *Package, previousVersion, newVersion string) error
// KeptVersions is every system version some campaign is on or holds,
// keyed by package slug, for the clean-up protected set.
KeptVersions(ctx context.Context) (map[string]map[string]bool, error)
// Reconcile is the idempotent boot pass that makes held versions agree
// with the installed version and drops rows that say nothing.
Reconcile(ctx context.Context) (ReconcileResult, error)
// RegisterBinding attaches a package type's binding (boot-time wiring).
RegisterBinding(b CampaignBinding)
}
CampaignUpdateService owns the per-campaign update modes.
It never checks that the caller may act: the owner/admin gate belongs to the handler that will sit on top, which passes ActorInfo.Admin to say which.
func NewCampaignUpdateService ¶
func NewCampaignUpdateService(repo CampaignUpdateRepository, pkgs PackageService, audit AuditLogger) CampaignUpdateService
NewCampaignUpdateService wires the service with the game-system binding already registered. audit may be nil.
type DeprecateInput ¶
type DeprecateInput struct {
Message string `json:"message" form:"message"`
}
DeprecateInput is the request to mark a package as nearing end-of-life.
type GitHubAPIError ¶
type GitHubAPIError struct {
Status int
RateLimited bool
Cause error // transport error, for the logs only
}
GitHubAPIError is a failed release lookup, worded for the admin page. GitHub's response body is never part of the message: on an outage it is an HTML error page, and on other failures it says nothing an admin can act on. Status is 0 when GitHub could not be reached at all.
func (*GitHubAPIError) Error ¶
func (e *GitHubAPIError) Error() string
func (*GitHubAPIError) Unwrap ¶
func (e *GitHubAPIError) Unwrap() error
type GitHubAsset ¶
type GitHubAsset struct {
Name string `json:"name"`
BrowserDownloadURL string `json:"browser_download_url"`
Size int64 `json:"size"`
ContentType string `json:"content_type"`
}
GitHubAsset represents a downloadable file in a GitHub release.
type GitHubClient ¶
type GitHubClient struct {
// contains filtered or unexported fields
}
GitHubClient fetches release information from GitHub repositories.
func NewGitHubClient ¶
func NewGitHubClient() *GitHubClient
NewGitHubClient creates a GitHub API client. It reads GITHUB_TOKEN from the environment for authenticated requests (5000 req/hour vs 60).
func (*GitHubClient) DownloadAsset ¶
func (c *GitHubClient) DownloadAsset(ctx context.Context, downloadURL, destPath string) (int64, error)
DownloadAsset downloads a release asset (ZIP file) to disk, refusing one larger than maxPackageDownloadBytes. Returns the number of bytes written.
func (*GitHubClient) ListReleases ¶
func (c *GitHubClient) ListReleases(ctx context.Context, repoURL string) ([]GitHubRelease, error)
ListReleases fetches all releases for a GitHub repository. Returns them sorted by published_at descending (newest first).
type GitHubRelease ¶
type GitHubRelease struct {
TagName string `json:"tag_name"`
Name string `json:"name"`
Body string `json:"body"`
Prerelease bool `json:"prerelease"`
PublishedAt time.Time `json:"published_at"`
Assets []GitHubAsset `json:"assets"`
}
GitHubRelease represents a release from the GitHub Releases API.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler handles admin HTTP requests for the package manager plugin.
func NewHandler ¶
func NewHandler(service PackageService) *Handler
NewHandler creates a new package manager handler.
func (*Handler) AddPackage ¶
AddPackage registers a new GitHub repository (POST /admin/packages).
func (*Handler) ArchivePackage ¶
ArchivePackage hides a package (POST /admin/packages/:id/archive).
func (*Handler) CheckForUpdates ¶
CheckForUpdates triggers an update check (POST /admin/packages/:id/check).
func (*Handler) ClearPinnedVersion ¶
ClearPinnedVersion unpins a package (DELETE /admin/packages/:id/pin).
func (*Handler) DeprecatePackage ¶
DeprecatePackage marks a package as EOL (POST /admin/packages/:id/deprecate).
func (*Handler) GetSecuritySettings ¶
GetSecuritySettings renders the settings page (GET /admin/packages/settings).
func (*Handler) GetUsage ¶
GetUsage shows which campaigns use a package (GET /admin/packages/:id/usage).
func (*Handler) HoldCampaign ¶
HoldCampaign keeps a campaign on its current version against its owner's Update (POST /admin/packages/:id/campaigns/:cid/hold).
func (*Handler) InstallVersion ¶
InstallVersion installs a specific version (PUT /admin/packages/:id/version).
func (*Handler) ListPackages ¶
ListPackages renders the package management page (GET /admin/packages). The tab, filter, search and open package are query parameters, so every view is a link and survives a reload.
func (*Handler) ListPendingSubmissions ¶
ListPendingSubmissions shows packages awaiting approval (GET /admin/packages/pending).
func (*Handler) ListVersions ¶
ListVersions returns available versions for a package (GET /admin/packages/:id/versions). Returns an HTMX fragment for the version picker.
func (*Handler) MoveCampaign ¶
MoveCampaign moves a campaign to a version the admin picked (PUT /admin/packages/:id/campaigns/:cid/version, form: version).
func (*Handler) PruneExecute ¶
PruneExecute deletes stale version folders (DELETE /admin/packages/prune). The service re-derives the deletion set server-side — the confirm click authorizes the OPERATION, never a client-supplied list.
func (*Handler) PrunePreview ¶
PrunePreview renders the stale-version cleanup card as a lazy HTMX fragment (GET /admin/packages/prune). Dry-run only — nothing deleted. Errors (incl. the fail-closed unwired-provider case) degrade to an empty fragment rather than breaking the packages page.
func (*Handler) ReleaseCampaign ¶
ReleaseCampaign lets go of a hold (DELETE /admin/packages/:id/campaigns/:cid/hold).
func (*Handler) RemindCampaignOwner ¶
RemindCampaignOwner nudges the owner of a campaign that has a version waiting (POST /admin/packages/:id/campaigns/:cid/remind).
func (*Handler) RemovePackage ¶
RemovePackage deletes a package (DELETE /admin/packages/:id).
func (*Handler) ReviewPackage ¶
ReviewPackage approves or rejects a submission (POST /admin/packages/:id/review).
func (*Handler) SaveSecuritySettings ¶
SaveSecuritySettings persists settings (POST /admin/packages/settings).
func (*Handler) SetActivityRecorder ¶
func (h *Handler) SetActivityRecorder(r ActivityRecorder)
SetActivityRecorder wires the admin change log. Optional: nil disables it.
func (*Handler) SetAutoUpdate ¶
SetAutoUpdate changes the auto-update policy (PUT /admin/packages/:id/auto-update).
func (*Handler) SetCampaignUpdates ¶
func (h *Handler) SetCampaignUpdates(svc CampaignUpdateService)
SetCampaignUpdates injects the per-campaign update service. Without it the Campaigns tab shows the plain usage list and the actions answer 404.
func (*Handler) SetOwnerReminder ¶
func (h *Handler) SetOwnerReminder(r OwnerReminder)
SetOwnerReminder injects the way to remind an owner.
func (*Handler) SetPinnedVersion ¶
SetPinnedVersion pins a package to a version (PUT /admin/packages/:id/pin).
func (*Handler) SetRetention ¶
SetRetention sets or clears a package's own old-version rule (PUT /admin/packages/:id/retention). mode=site clears it; mode=own stores keep_newest. No re-auth, matching auto-update: it only decides how many already-installed old folders may be cleaned up later.
func (*Handler) SetTypeUI ¶
func (h *Handler) SetTypeUI(t PackageType, ui TypeUI)
SetTypeUI registers a package type's UI hook. Optional: a type with none renders only the generic row actions.
func (*Handler) UnarchivePackage ¶
UnarchivePackage restores an archived package (DELETE /admin/packages/:id/archive).
func (*Handler) UndeprecatePackage ¶
UndeprecatePackage clears deprecation (DELETE /admin/packages/:id/deprecate).
type InstallVersionInput ¶
type InstallVersionInput struct {
Version string `json:"version" form:"version"`
}
InstallVersionInput is the request to install a specific version.
type OwnerHandler ¶
type OwnerHandler struct {
// contains filtered or unexported fields
}
OwnerHandler handles HTTP requests for the owner-facing package submission UI. These routes are accessible to any authenticated campaign owner, not just admins.
func NewOwnerHandler ¶
func NewOwnerHandler(service PackageService) *OwnerHandler
NewOwnerHandler creates a new owner-facing handler.
func (*OwnerHandler) BrowseSystems ¶
func (h *OwnerHandler) BrowseSystems(c *echo.Context) error
BrowseSystems renders the systems browse page (GET /systems/browse).
func (*OwnerHandler) HandleSubmitSystem ¶
func (h *OwnerHandler) HandleSubmitSystem(c *echo.Context) error
HandleSubmitSystem processes a system submission (POST /systems/submit).
func (*OwnerHandler) MySubmissions ¶
func (h *OwnerHandler) MySubmissions(c *echo.Context) error
MySubmissions renders the user's submitted packages (GET /systems/my-submissions).
func (*OwnerHandler) SubmitSystemForm ¶
func (h *OwnerHandler) SubmitSystemForm(c *echo.Context) error
SubmitSystemForm renders the submission form (GET /systems/submit).
type OwnerReminder ¶
type OwnerReminder interface {
RemindOwner(ctx context.Context, pkg *Package, campaignID, version string, actor ActorInfo) error
}
OwnerReminder tells a campaign's owner that a version is waiting for them. It is implemented outside this plugin by the package types that have a way to reach owners; without one, Remind owner is not offered.
type Package ¶
type Package struct {
ID string
Type PackageType
Slug string
Name string
RepoURL string
Description string
InstalledVersion string
PinnedVersion string
AutoUpdate UpdatePolicy
LastCheckedAt *time.Time
LastInstalledAt *time.Time
InstallPath string
SubmittedBy string // UserID of submitter (empty = admin-created).
Status PackageStatus // Lifecycle state: pending/approved/rejected/archived/deprecated.
ReviewedBy string // Admin who approved/rejected.
ReviewedAt *time.Time
ReviewNote string // Reason for rejection or review comment.
DeprecatedAt *time.Time
DeprecationMsg string // Message shown to users about EOL.
// LastError is the most recent install/check/load failure for this
// package ("" = healthy). Written by the install pipeline and the
// post-install verifier, cleared on verified success. Durable (DB
// column) so background failures survive restarts — the /admin/packages
// badge + banner render straight from this field.
LastError string
LastErrorAt *time.Time
// RetentionKeepNewest is this package's own old-version rule: keep the
// newest N versions. nil = follow the site rule. Never consulted for
// foundry-module packages, whose versions are never removed.
RetentionKeepNewest *int
CreatedAt time.Time
UpdatedAt time.Time
}
Package represents an external repository tracked by the package manager.
type PackageRepository ¶
type PackageRepository interface {
ListPackages(ctx context.Context) ([]Package, error)
GetPackage(ctx context.Context, id string) (*Package, error)
FindBySlug(ctx context.Context, slug string) (*Package, error)
FindByRepoURL(ctx context.Context, repoURL string) (*Package, error)
CreatePackage(ctx context.Context, pkg *Package) error
// Each setter writes only its own columns. Callers hold a package row
// across slow network calls, and a whole-row write from that copy would
// undo an admin's pin, policy or install made meanwhile.
SetInstalled(ctx context.Context, id, version, installPath string, at time.Time) error
SetPinnedVersion(ctx context.Context, id, version string) error
SetAutoUpdate(ctx context.Context, id string, policy UpdatePolicy) error
SetLastChecked(ctx context.Context, id string, at time.Time) error
DeletePackage(ctx context.Context, id string) error
ListVersions(ctx context.Context, packageID string) ([]PackageVersion, error)
GetVersion(ctx context.Context, packageID, version string) (*PackageVersion, error)
UpsertVersion(ctx context.Context, v *PackageVersion) error
MarkVersionDownloaded(ctx context.Context, id string) error
// RecordVersionDigest stores digest as the version's content digest if it
// has none yet, and returns the digest it holds afterwards.
RecordVersionDigest(ctx context.Context, id, digest string) (string, error)
// Usage tracking.
GetUsageByCampaign(ctx context.Context, systemSlug string) ([]PackageUsage, error)
// Submission/approval workflow.
ListByStatus(ctx context.Context, status PackageStatus) ([]Package, error)
ListBySubmitter(ctx context.Context, userID string) ([]Package, error)
CountPendingSubmissions(ctx context.Context) (int, error)
UpdateStatus(ctx context.Context, id string, status PackageStatus, reviewedBy, note string) error
SetDeprecated(ctx context.Context, id string, msg string) error
ClearDeprecated(ctx context.Context, id string) error
UpdateRepoURL(ctx context.Context, id, newURL string) error
// SetLastError records the most recent install/check/load failure for
// a package; msg=="" clears it. Kept out of UpdatePackage so failure
// bookkeeping can't clobber unrelated fields and works even on paths
// where the full row wasn't loaded.
SetLastError(ctx context.Context, id, msg string) error
// SetRetention stores the per-package old-version override: nil clears
// it (use the site rule), a value means keep the newest N. Separate from
// UpdatePackage so the many read-modify-write callers can never echo a
// stale override back over a fresh one.
SetRetention(ctx context.Context, id string, keepNewest *int) error
}
PackageRepository handles database access for the packages plugin.
func NewPackageRepository ¶
func NewPackageRepository(db *sql.DB) PackageRepository
NewPackageRepository creates a repository backed by the given database.
type PackageRow ¶
type PackageRow struct {
Package
Status rowStatus
Newer *PackageVersion // non-nil only for statusUpdateReady or statusProblem
Versions []PackageVersion
Usage []PackageUsage
// UsageKnown is false when the usage lookup failed: the page then says
// nothing about campaign counts rather than showing a wrong zero.
UsageKnown bool
// ActionsFragmentURL is the type-registered lazy-load slot URL, "" for none.
ActionsFragmentURL string
// Campaigns is each campaign's standing on the package, loaded for a type
// whose owners are asked before a campaign moves (the Foundry module).
// CampaignsKnown is false when that is not wired or the lookup failed, and
// the page then shows the plain usage list instead.
Campaigns []CampaignPackageState
CampaignsKnown bool
// Versions the admin may move a campaign to: installed, not cleaned up.
MovableVersions []string
}
PackageRow is one package with everything the page shows about it, loaded once so the list, the strip and the panel never disagree.
func (PackageRow) IsFoundryModule ¶
func (r PackageRow) IsFoundryModule() bool
IsFoundryModule reports whether the row is the Foundry module type.
func (PackageRow) IsRetired ¶
func (r PackageRow) IsRetired() bool
IsRetired reports whether the row belongs under the Retired filter.
type PackageSecuritySettings ¶
type PackageSecuritySettings struct {
RepoPolicy string // "github_only", "any_git", or "allow_all".
RequireApproval bool
MaxFileSize int64 // Bytes.
ValidateManifest bool
ScanContent bool
OwnerUploadPolicy string // "auto_approve", "require_approval", or "disabled".
}
PackageSecuritySettings holds the parsed security settings for packages.
type PackageService ¶
type PackageService interface {
// Package CRUD (admin).
ListPackages(ctx context.Context) ([]Package, error)
GetPackage(ctx context.Context, id string) (*Package, error)
AddPackage(ctx context.Context, input AddPackageInput) (*Package, error)
RemovePackage(ctx context.Context, id string) error
// Version management.
CheckForUpdates(ctx context.Context, packageID string) ([]PackageVersion, error)
CheckAllForUpdates(ctx context.Context) error
ListVersions(ctx context.Context, packageID string) ([]PackageVersion, error)
InstallVersion(ctx context.Context, packageID, version string) error
SetPinnedVersion(ctx context.Context, packageID, version string) error
ClearPinnedVersion(ctx context.Context, packageID string) error
SetAutoUpdate(ctx context.Context, packageID string, policy UpdatePolicy) error
// Usage tracking.
GetUsage(ctx context.Context, packageID string) ([]PackageUsage, error)
// Auto-update worker.
RunAutoUpdates(ctx context.Context) error
StartAutoUpdateWorker(ctx context.Context)
// SubmitPackage lets a campaign owner submit a repo URL for review.
SubmitPackage(ctx context.Context, userID string, input SubmitPackageInput) (*Package, error)
// ListMySubmissions returns packages submitted by the given user.
ListMySubmissions(ctx context.Context, userID string) ([]Package, error)
// ListPendingSubmissions returns all packages awaiting admin approval.
ListPendingSubmissions(ctx context.Context) ([]Package, error)
// CountPendingSubmissions returns the number of packages awaiting approval.
CountPendingSubmissions(ctx context.Context) (int, error)
// CountUpdatesReady returns how many packages the Updates tab offers an
// update for: installed, not pinned, not failing, with a newer release.
CountUpdatesReady(ctx context.Context) (int, error)
// ReviewPackage approves or rejects a pending package submission.
ReviewPackage(ctx context.Context, packageID, adminUserID string, input ReviewPackageInput) error
// DeprecatePackage marks a package as nearing end-of-life.
DeprecatePackage(ctx context.Context, packageID, msg string) error
// ArchivePackage hides a package from active listings.
ArchivePackage(ctx context.Context, packageID string) error
// UnarchivePackage restores an archived package to approved status.
UnarchivePackage(ctx context.Context, packageID string) error
// UpdateRepoURL changes a package's repository URL (admin only).
UpdateRepoURL(ctx context.Context, packageID, newURL string) error
// GetSecuritySettings returns the current package security configuration.
GetSecuritySettings(ctx context.Context) (*PackageSecuritySettings, error)
// SaveSecuritySettings persists updated security settings.
SaveSecuritySettings(ctx context.Context, s *PackageSecuritySettings) error
// PruneStaleVersions reclaims old on-disk version dirs of installed
// SYSTEM packages (never foundry-module — those are pin-served).
// Always keeps the top keepNewest versions, the DB-installed version,
// and any currently-loaded dir. dryRun previews without deleting.
PruneStaleVersions(ctx context.Context, keepNewest int, dryRun bool) (*PruneResult, error)
// GetRetentionSettings / SaveRetentionSettings are the site-wide
// automatic old-version rule (default: manual, nothing automatic).
GetRetentionSettings(ctx context.Context) (*RetentionSettings, error)
SaveRetentionSettings(ctx context.Context, r RetentionSettings) error
// SetPackageRetention sets (non-nil) or clears (nil) one package's own
// "keep the newest N" rule, which overrides the site rule.
SetPackageRetention(ctx context.Context, packageID string, keepNewest *int) error
// RunRetention applies the effective rule to every package through the
// same protected-set code path as PruneStaleVersions.
RunRetention(ctx context.Context) (*PruneResult, error)
// InstallDirForVersion returns the on-disk path for a SPECIFIC
// historical version of a package — regardless of which version
// is marked "installed" in the DB. Used by sub-plugins (foundry_vtt)
// to serve a campaign-pinned version that may not be the package's
// currently-active install.
//
// The path is computed deterministically from (type, slug, version);
// no filesystem check is performed. Callers needing existence
// confirmation should stat the returned path themselves. Empty string
// return if pkgType is unknown.
InstallDirForVersion(pkgType PackageType, slug, version string) string
}
PackageService handles business logic for package management. It coordinates between the repository (database), GitHub API client, and the local filesystem to manage installed package versions.
func NewPackageService ¶
func NewPackageService(repo PackageRepository, github *GitHubClient, mediaDir, baseURL string) PackageService
NewPackageService creates a new package service with the given dependencies. baseURL is the chronicle host's external URL (BASE_URL config); it is used only to rewrite the manifest/download URLs inside the cached Foundry-module zip so Foundry's installed copy points at chronicle rather than upstream.
type PackageStatus ¶
type PackageStatus string
PackageStatus tracks the lifecycle state of a submitted package.
const ( // StatusPending means the package is awaiting admin approval. StatusPending PackageStatus = "pending" // StatusApproved means the package has been approved and is active. StatusApproved PackageStatus = "approved" // StatusRejected means an admin declined the package submission. StatusRejected PackageStatus = "rejected" // StatusArchived means the package has been archived (hidden but preserved). StatusArchived PackageStatus = "archived" // StatusDeprecated means the package is nearing end-of-life. StatusDeprecated PackageStatus = "deprecated" )
type PackageType ¶
type PackageType string
PackageType distinguishes system packs from Foundry modules.
const ( // PackageTypeSystem is a game system content pack (manifest.json + data/*.json). PackageTypeSystem PackageType = "system" // PackageTypeFoundryModule is the Foundry VTT sync module. PackageTypeFoundryModule PackageType = "foundry-module" )
type PackageUsage ¶
type PackageUsage struct {
CampaignID string
CampaignName string
SystemID string
EnabledAt time.Time
}
PackageUsage shows which campaigns use a package's systems.
type PackageVersion ¶
type PackageVersion struct {
ID string
PackageID string
Version string
TagName string
ReleaseURL string
DownloadURL string
ReleaseNotes string
Prerelease bool // True for pre-release/beta versions from GitHub.
PublishedAt time.Time
DownloadedAt *time.Time
FileSize int64
CreatedAt time.Time
}
PackageVersion represents a single release from GitHub.
type PackagesPageData ¶
type PackagesPageData struct {
Query packagesQuery
CSRFToken string
Now time.Time
// Rows is every manageable package (pending submissions are in Pending);
// Visible is Rows after the chip and the search box.
Rows []PackageRow
Visible []PackageRow
Counts filterCounts
// Selected is the open package, nil when none is open or the id is unknown.
Selected *PackageRow
Updates []PackageRow
Pending []Package
PendingCount int
// Settings is loaded for the Settings tab only.
Settings *PackageSecuritySettings
// Retention is the site-wide old-version rule, loaded for every tab.
Retention RetentionSettings
// CanRemind is true when an owner-notification path is wired, so the
// Remind owner action is offered.
CanRemind bool
}
PackagesPageData is everything PackagesPage renders.
type PinVersionInput ¶
type PinVersionInput struct {
Version string `json:"version" form:"version"`
}
PinVersionInput is the request to pin to a specific version.
type PostCommitHook ¶
type PostCommitHook interface {
AfterCommit(ctx context.Context, pkg *Package, version, previousVersion string) error
}
PostCommitHook is an optional extension of PostInstallHook: AfterCommit runs once the install is committed (DB row updated). Failures are logged, never fatal, because the install is already done. Use it for state that must not exist for an install that was refused.
type PostInstallHook ¶
type PostInstallHook interface {
// PackageType returns the type this hook fires for. The packages
// service iterates registered hooks and calls only those matching
// the installed package's type. No matching type → no-op.
PackageType() PackageType
// AfterInstall runs after extraction + validation but BEFORE the
// package row is committed to the DB: a hook failure must leave the
// catalog pointing at the old version, never at a directory the
// failure path just deleted. pkg.InstalledVersion still holds the
// PREVIOUS version at hook time; previousVersion is "" on a
// first-ever install (foundry_vtt's auto-pin hook uses that to know
// what to preserve). Returning an error fails the install:
// InstallVersion removes destDir and never writes the DB row.
AfterInstall(ctx context.Context, pkg *Package, version, previousVersion, destDir string) error
}
PostInstallHook is the extension point sub-plugins use to attach package-type-specific logic to the generic install pipeline. The foundry_vtt sub-plugin registers a hook for PackageTypeFoundryModule that rewrites the version field in the on-disk module.json so served manifests reflect the installed version, not the upstream GitHub tag.
The hook list is iterated after the zip is extracted and validated but BEFORE the DB row is updated, so a hook failure aborts the install with the catalog untouched. Hook errors fail the install loudly — no silent warn-and-continue.
func NewUpdateModeHook ¶
func NewUpdateModeHook(svc CampaignUpdateService, typ PackageType) PostInstallHook
NewUpdateModeHook returns the PostInstallHook that applies update modes when a package of the given type installs. Register it AFTER any type-specific hook that also freezes campaigns (the Foundry auto-pin), since it reads the state that hook leaves behind.
type PruneResult ¶
type PruneResult struct {
Reclaimable []StaleVersion // what would be / was deleted
Removed []StaleVersion // actually deleted (empty on dry-run)
BytesFreed int64
DryRun bool
}
PruneResult summarizes a prune run (dry-run or executed).
type ReconcileResult ¶
ReconcileResult counts what the boot reconciler changed.
type RetentionMode ¶
type RetentionMode string
RetentionMode is the site-wide old-version rule.
const ( // RetentionManual removes nothing automatically (the default). RetentionManual RetentionMode = "manual" // RetentionKeepNewest keeps the newest N versions of each package. RetentionKeepNewest RetentionMode = "keep_newest" // RetentionUnusedDays removes versions untouched for N days. RetentionUnusedDays RetentionMode = "unused_days" )
type RetentionOverrideInput ¶
type RetentionOverrideInput struct {
Mode string `json:"mode" form:"mode"`
KeepNewest int `json:"keepNewest" form:"keep_newest"`
}
RetentionOverrideInput is the per-package old-version rule form. Mode is "site" (follow the site rule) or "own" (keep the newest KeepNewest).
type RetentionSettings ¶
type RetentionSettings struct {
Mode RetentionMode
KeepNewest int
UnusedDays int
}
RetentionSettings is the site-wide rule. Both numbers are always kept so switching mode back and forth does not lose what the admin typed.
func DefaultRetentionSettings ¶
func DefaultRetentionSettings() RetentionSettings
DefaultRetentionSettings is the rule for installs that never set one.
func ParseRetentionSettings ¶
func ParseRetentionSettings(mode, keepNewest, unusedDays string, current RetentionSettings) (RetentionSettings, error)
ParseRetentionSettings builds the rule from submitted form text, starting from current so a blank or garbled number in a mode that is NOT selected keeps its stored value instead of rejecting the whole save.
func (RetentionSettings) Validate ¶
func (r RetentionSettings) Validate() error
Validate checks the mode and the number the mode actually uses; the other number is not required to be sensible while its mode is not selected.
type ReviewPackageInput ¶
type ReviewPackageInput struct {
Action string `json:"action" form:"action"` // "approve" or "reject".
Note string `json:"note" form:"note"`
}
ReviewPackageInput is the admin's approval or rejection decision.
type ServedVersion ¶
type ServedVersion struct {
Version string
Dir string
// FellBack is true when the campaign's own version could not be used (its
// folder is gone, or the lookup failed) and the installed version is
// served instead. Reason says why.
FellBack bool
Reason string
}
ServedVersion is the version (and folder) a campaign's files should be served from, and whether that is the campaign's own choice or the fallback.
type SetUpdateModeInput ¶
type SetUpdateModeInput struct {
CampaignID string
PackageID string
Mode string
// Version is the version to stay on. Only read for "pinned"; empty there
// means "the version the campaign is on now".
Version string
}
SetUpdateModeInput is the owner's request to change one package's mode.
type SettingsReader ¶
SettingsReader provides read access to site settings without importing the full settings package. Matches settings.SettingsRepository.Get.
type SettingsWriter ¶
SettingsWriter provides write access to site settings.
type StaleVersion ¶
StaleVersion is one on-disk version folder the cleanup may reclaim.
type SubmitPackageInput ¶
type SubmitPackageInput struct {
RepoURL string `json:"repo_url" form:"repo_url"`
Name string `json:"name" form:"name"`
Type string `json:"type" form:"type"`
}
SubmitPackageInput is the request from a campaign owner to submit a repo.
type TypeUI ¶
type TypeUI struct {
// ActionsFragmentURL returns the URL of the type's per-row actions
// fragment, or "" for no fragment. Nil means no fragment.
ActionsFragmentURL func(pkg Package) string
}
TypeUI is one package type's contribution to the packages page.
type UpdateMode ¶
type UpdateMode string
UpdateMode is how one campaign follows one package.
const ( // UpdateModeAutomatic moves the campaign up whenever the site installs a // new version. It is what every campaign did before modes existed, so it // is the default for anything with no stored choice. UpdateModeAutomatic UpdateMode = "automatic" // UpdateModePinned keeps the campaign on a chosen version until its owner // changes it ("Stay on a version"). UpdateModePinned UpdateMode = "pinned" // UpdateModeApproveFirst keeps the campaign on its current version when a // new one is installed, holds the new version, and moves only when the // owner (or an admin on their behalf) approves it ("Ask me first"). UpdateModeApproveFirst UpdateMode = "approve_first" )
func ParseUpdateMode ¶
func ParseUpdateMode(s string) (UpdateMode, error)
ParseUpdateMode validates a user-supplied mode. Empty is rejected: callers that want "no choice yet" mean UpdateModeAutomatic and must say so.
func ReportedPackageMode ¶
func ReportedPackageMode(pkg *Package) UpdateMode
ReportedPackageMode is how the admin panel reports a package's own mode: pinned when it has a pin, or when auto-update is off (so nothing moves it either way); automatic otherwise. It is reporting only. It writes nothing and changes what no campaign is served, because today an off package still serves whatever an admin installs by hand.
func (UpdateMode) KeepsVersion ¶
func (m UpdateMode) KeepsVersion() bool
KeepsVersion reports whether the mode holds a campaign on an explicit version (so that version must be protected from clean-up and survive an install). Automatic follows the installed version instead.
func (UpdateMode) Valid ¶
func (m UpdateMode) Valid() bool
Valid reports whether m is one of the three modes.
type UpdatePolicy ¶
type UpdatePolicy string
UpdatePolicy controls automatic update behavior.
const ( // UpdateOff disables automatic updates. UpdateOff UpdatePolicy = "off" // UpdateNightly checks for updates once per day. UpdateNightly UpdatePolicy = "nightly" // UpdateWeekly checks for updates once per week. UpdateWeekly UpdatePolicy = "weekly" // UpdateOnRelease checks every hour for new releases. UpdateOnRelease UpdatePolicy = "on_release" )
type UpdatePolicyInput ¶
type UpdatePolicyInput struct {
Policy string `json:"policy" form:"policy"`
}
UpdatePolicyInput is the request to change auto-update policy.
type UpdateRepoURLInput ¶
type UpdateRepoURLInput struct {
RepoURL string `json:"repo_url" form:"repo_url"`
}
UpdateRepoURLInput is the request to change a package's repository URL.
Source Files
¶
- activity_recorder.go
- campaign_update_handler.go
- campaign_update_repository.go
- campaign_update_service.go
- embed.go
- github_client.go
- handler.go
- helpers.go
- model.go
- owner_handler.go
- page_builder.go
- page_model.go
- prune.go
- repository.go
- retention.go
- routes.go
- service.go
- system_binding.go
- templ_helpers.go
- update_mode.go
- validation.go
- version_string.go