Something went wrong. Try again.
sloproxy
Something went wrong. Try again.
7.0 kB · 201 lines
Go
at main
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202// Package pluginstore exposes plugin registry and artifact installation helpers// for embedders such as CLIProxyAPIHome.package pluginstore
import ( "context" "net/http" "strings" "time"
internalpluginstore "github.com/router-for-me/CLIProxyAPI/v7/internal/pluginstore")
const ( DefaultRegistryURL = internalpluginstore.DefaultRegistryURL DefaultSourceID = internalpluginstore.DefaultSourceID DefaultSourceName = internalpluginstore.DefaultSourceName SchemaVersion = internalpluginstore.SchemaVersion SchemaVersionV2 = internalpluginstore.SchemaVersionV2
InstallTypeGitHubRelease = internalpluginstore.InstallTypeGitHubRelease InstallTypeDirect = internalpluginstore.InstallTypeDirect
RequestKindRegistry = internalpluginstore.RequestKindRegistry RequestKindMetadata = internalpluginstore.RequestKindMetadata RequestKindArtifact = internalpluginstore.RequestKindArtifact
AuthTypeNone = internalpluginstore.AuthTypeNone AuthTypeBearer = internalpluginstore.AuthTypeBearer AuthTypeBasic = internalpluginstore.AuthTypeBasic AuthTypeHeader = internalpluginstore.AuthTypeHeader AuthTypeGitHubToken = internalpluginstore.AuthTypeGitHubToken
PluginSyncSchemaVersion = internalpluginstore.PluginSyncSchemaVersion)
type Source = internalpluginstore.Sourcetype Registry = internalpluginstore.Registrytype Plugin = internalpluginstore.Plugintype Version = internalpluginstore.Versiontype Release = internalpluginstore.Releasetype ReleaseAsset = internalpluginstore.ReleaseAssettype InstallOptions = internalpluginstore.InstallOptionstype InstallResult = internalpluginstore.InstallResulttype InstallPlan = internalpluginstore.InstallPlantype Artifact = internalpluginstore.Artifacttype Platform = internalpluginstore.Platformtype Manifest = internalpluginstore.Manifesttype AuthConfig = internalpluginstore.AuthConfigtype Secret = internalpluginstore.Secrettype ResolvedAuthConfig = internalpluginstore.ResolvedAuthConfigtype PluginSyncRequest = internalpluginstore.PluginSyncRequesttype PluginSyncItem = internalpluginstore.PluginSyncItemtype PluginSyncResponse = internalpluginstore.PluginSyncResponse
type HTTPDoer interface { Do(*http.Request) (*http.Response, error)}
var ErrLoadedPluginLocked = internalpluginstore.ErrLoadedPluginLocked
type Client struct { inner internalpluginstore.Client}
func NewClient(httpClient HTTPDoer, registryURL string) Client { return Client{inner: internalpluginstore.Client{ HTTPClient: httpClient, RegistryURL: strings.TrimSpace(registryURL), }}}
func NewClientWithAuth(httpClient HTTPDoer, registryURL string, auth []AuthConfig) Client { return Client{inner: internalpluginstore.Client{ HTTPClient: httpClient, RegistryURL: strings.TrimSpace(registryURL), Auth: internalpluginstore.NormalizeAuthConfigs(auth), }}}
func NewClientWithResolvedAuth(httpClient HTTPDoer, registryURL string, auth []ResolvedAuthConfig) Client { return NewClientWithResolvedAuthExpiry(httpClient, registryURL, auth, time.Time{})}
func NewClientWithResolvedAuthExpiry(httpClient HTTPDoer, registryURL string, auth []ResolvedAuthConfig, expiresAt time.Time) Client { return Client{inner: internalpluginstore.Client{ HTTPClient: httpClient, RegistryURL: strings.TrimSpace(registryURL), ResolvedAuth: auth, ResolvedAuthExpiresAt: expiresAt, }}}
func (c *Client) ClearAuth() { if c == nil { return } internalpluginstore.ClearResolvedAuthConfigs(c.inner.ResolvedAuth) c.inner.ResolvedAuth = nil c.inner.ResolvedAuthExpiresAt = time.Time{}}
func DefaultSource() Source { return internalpluginstore.DefaultSource()}
func NormalizeSources(registryURLs []string) ([]Source, error) { return internalpluginstore.NormalizeSources(registryURLs)}
func SourceID(registryURL string) string { return internalpluginstore.SourceID(registryURL)}
func ValidatePlugin(plugin Plugin) error { return internalpluginstore.ValidatePlugin(plugin)}
func PluginInstallType(plugin Plugin) string { return internalpluginstore.PluginInstallType(plugin)}
func PluginPlatforms(plugin Plugin) []Platform { return internalpluginstore.PluginPlatforms(plugin)}
func PluginArtifacts(plugin Plugin) []Artifact { return internalpluginstore.PluginArtifacts(plugin)}
func SelectArtifact(plan InstallPlan, goos string, goarch string) (Artifact, error) { return internalpluginstore.SelectArtifact(plan, goos, goarch)}
func GitHubRepositoryParts(repository string) (string, string, error) { return internalpluginstore.GitHubRepositoryParts(repository)}
func NormalizeAuthConfigs(auth []AuthConfig) []AuthConfig { return internalpluginstore.NormalizeAuthConfigs(auth)}
func ClearResolvedAuthConfigs(auth []ResolvedAuthConfig) { internalpluginstore.ClearResolvedAuthConfigs(auth)}
func ResolvedAuthForRequest(auth []ResolvedAuthConfig, requestURL string, kind string) (ResolvedAuthConfig, bool) { return internalpluginstore.ResolvedAuthForRequest(auth, requestURL, kind)}
func ValidateResolvedAuthConfig(auth ResolvedAuthConfig) error { return internalpluginstore.ValidateResolvedAuthConfig(auth)}
func AuthConfigured(auth []AuthConfig, requestURL string, kind string) bool { return internalpluginstore.AuthConfigured(auth, requestURL, kind)}
func PluginAuthConfigured(source Source, plugin Plugin, auth []AuthConfig) bool { return internalpluginstore.PluginAuthConfigured(source, plugin, auth)}
func UpdateAvailable(installed, latest string) bool { return internalpluginstore.UpdateAvailable(installed, latest)}
func ReleaseVersion(release Release) (string, error) { return internalpluginstore.ReleaseVersion(release)}
func ManifestFromRelease(source Source, plugin Plugin, release Release) (Manifest, error) { return internalpluginstore.ManifestFromRelease(source, plugin, release)}
func ManifestFromPlugin(source Source, plugin Plugin) (Manifest, error) { return internalpluginstore.ManifestFromPlugin(source, plugin)}
func (c Client) FetchRegistry(ctx context.Context) (Registry, error) { return c.inner.FetchRegistry(ctx)}
func (c Client) FetchLatestRelease(ctx context.Context, plugin Plugin) (Release, error) { return c.inner.FetchLatestRelease(ctx, plugin)}
func (c Client) FetchReleaseByTag(ctx context.Context, plugin Plugin, tag string) (Release, error) { return c.inner.FetchReleaseByTag(ctx, plugin, tag)}
func (c Client) Install(ctx context.Context, plugin Plugin, options InstallOptions) (InstallResult, error) { return c.inner.Install(ctx, plugin, options)}
func (c Client) InstallVersion(ctx context.Context, plugin Plugin, releaseTag string, version string, options InstallOptions) (InstallResult, error) { return c.inner.InstallVersion(ctx, plugin, releaseTag, version, options)}
func (c Client) InstallManifest(ctx context.Context, manifest Manifest, options InstallOptions) (InstallResult, error) { return c.inner.InstallManifest(ctx, manifest, options)}