Documentation
¶
Index ¶
- Constants
- Variables
- func ArchiveName(id, version, goos, goarch string) string
- func GitHubRepositoryParts(repository string) (string, string, error)
- func ParseChecksums(data []byte) (map[string]string, error)
- func ReleaseVersion(release Release) (string, error)
- func SelectReleaseAssets(release Release, id, version, goos, goarch string) (ReleaseAsset, ReleaseAsset, error)
- func SourceID(registryURL string) string
- func SourceName(registryURL string) string
- func UpdateAvailable(installed, latest string) bool
- func ValidatePlugin(plugin Plugin) error
- func ValidateRegistry(registry Registry) error
- func VerifyChecksum(name string, data []byte, checksums map[string]string) error
- type Client
- func (c Client) DownloadAsset(ctx context.Context, asset ReleaseAsset) ([]byte, error)
- func (c Client) FetchLatestRelease(ctx context.Context, plugin Plugin) (Release, error)
- func (c Client) FetchRegistry(ctx context.Context) (Registry, error)
- func (c Client) Install(ctx context.Context, plugin Plugin, options InstallOptions) (InstallResult, error)
- type HTTPDoer
- type InstallOptions
- type InstallResult
- type Plugin
- type Registry
- type Release
- type ReleaseAsset
- type Source
Constants ¶
const ( DefaultRegistryURL = "https://raw.githubusercontent.com/router-for-me/CLIProxyAPI-Plugins-Store/main/registry.json" DefaultSourceID = "official" DefaultSourceName = "Official" SchemaVersion = 1 )
Variables ¶
var ErrLoadedPluginLocked = errors.New("loaded plugin library cannot be overwritten while the server is running")
ErrLoadedPluginLocked is returned when an install would overwrite a plugin library that is loaded by the running process on Windows.
Functions ¶
func ArchiveName ¶
func ReleaseVersion ¶
ReleaseVersion derives the plugin version from the release tag, stripping a leading "v"/"V" and validating the result.
func SelectReleaseAssets ¶
func SelectReleaseAssets(release Release, id, version, goos, goarch string) (ReleaseAsset, ReleaseAsset, error)
func SourceName ¶
func UpdateAvailable ¶
UpdateAvailable reports whether latest should be offered as an upgrade over installed. A leading "v"/"V" is ignored on both sides. Versions are compared numerically when both are dotted release numbers, so an installed version newer than the registry one is not reported as an update; otherwise any difference counts as an update.
func ValidatePlugin ¶
func ValidateRegistry ¶
Types ¶
type Client ¶
func (Client) DownloadAsset ¶
func (Client) FetchLatestRelease ¶
FetchLatestRelease returns the latest published release of the plugin's GitHub repository, mirroring the WebUI panel update check.
func (Client) Install ¶
func (c Client) Install(ctx context.Context, plugin Plugin, options InstallOptions) (InstallResult, error)
type InstallOptions ¶
type InstallOptions struct {
PluginsDir string
GOOS string
GOARCH string
// PluginLoaded reports whether the plugin's dynamic library is currently
// loaded by the running host. Windows installs are rejected while it returns
// true unless BeforeWrite can unload the plugin before replacement.
PluginLoaded func() bool
// BeforeWrite runs after the archive has been downloaded and verified, but
// before the target plugin file is replaced.
BeforeWrite func() error
}
type InstallResult ¶
type InstallResult struct {
ID string `json:"id"`
Version string `json:"version"`
Path string `json:"path"`
Overwritten bool `json:"overwritten"`
}
func InstallArchive ¶
func InstallArchive(archiveData []byte, plugin Plugin, options InstallOptions) (InstallResult, error)
type Plugin ¶
type Plugin struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Author string `json:"author"`
Version string `json:"version"`
Repository string `json:"repository"`
Logo string `json:"logo,omitempty"`
Homepage string `json:"homepage,omitempty"`
License string `json:"license,omitempty"`
Tags []string `json:"tags,omitempty"`
}
type Registry ¶
type Registry struct {
SchemaVersion int `json:"schema_version"`
Plugins []Plugin `json:"plugins"`
}
func ParseRegistry ¶
type Release ¶
type Release struct {
TagName string `json:"tag_name"`
Assets []ReleaseAsset `json:"assets"`
}