[#7665] added BaseURL to the ghupdate plugin configuration

This commit is contained in:
Gani Georgiev
2026-04-26 20:42:40 +03:00
parent 494f47efb8
commit 1c86addc4c
2 changed files with 18 additions and 10 deletions

View File

@@ -15,6 +15,8 @@
- ⚠️ Fixed a pre-hijacking OAuth2 linking vulnerability ([#7662](https://github.com/pocketbase/pocketbase/discussions/7662); thanks @Alardiians for reporting it privately). - ⚠️ Fixed a pre-hijacking OAuth2 linking vulnerability ([#7662](https://github.com/pocketbase/pocketbase/discussions/7662); thanks @Alardiians for reporting it privately).
- Added `ghupdate.BaseURL` config option ([#7665](https://github.com/pocketbase/pocketbase/issues/7665)).
- Bumped Go and npm dependencies. - Bumped Go and npm dependencies.

View File

@@ -46,6 +46,12 @@ type Config struct {
// (default to "pocketbase"; an additional ".exe" check is also performed as a fallback). // (default to "pocketbase"; an additional ".exe" check is also performed as a fallback).
ArchiveExecutable string ArchiveExecutable string
// BaseURL is the base URL of the GitHub API (or similar compatible)
// used to fetch the latest releases information.
//
// Defaults to "https://api.github.com".
BaseURL string
// Optional context to use when fetching and downloading the latest release. // Optional context to use when fetching and downloading the latest release.
Context context.Context Context context.Context
@@ -82,6 +88,12 @@ func Register(app core.App, rootCmd *cobra.Command, config Config) error {
p.config.ArchiveExecutable = "pocketbase" p.config.ArchiveExecutable = "pocketbase"
} }
if p.config.BaseURL == "" {
p.config.BaseURL = "https://api.github.com"
} else {
p.config.BaseURL = strings.TrimRight(p.config.BaseURL, "/")
}
if p.config.HttpClient == nil { if p.config.HttpClient == nil {
p.config.HttpClient = http.DefaultClient p.config.HttpClient = http.DefaultClient
} }
@@ -145,12 +157,9 @@ func (p *plugin) updateCmd() *cobra.Command {
func (p *plugin) update(withBackup bool) error { func (p *plugin) update(withBackup bool) error {
color.Yellow("Fetching release information...") color.Yellow("Fetching release information...")
latest, err := fetchLatestRelease( url := fmt.Sprintf("%s/repos/%s/%s/releases/latest", p.config.BaseURL, p.config.Owner, p.config.Repo)
p.config.Context,
p.config.HttpClient, latest, err := fetchLatestRelease(p.config.Context, p.config.HttpClient, url)
p.config.Owner,
p.config.Repo,
)
if err != nil { if err != nil {
return err return err
} }
@@ -260,11 +269,8 @@ func (p *plugin) update(withBackup bool) error {
func fetchLatestRelease( func fetchLatestRelease(
ctx context.Context, ctx context.Context,
client HttpClient, client HttpClient,
owner string, url string,
repo string,
) (*release, error) { ) (*release, error) {
url := fmt.Sprintf("https://api.github.com/repos/%s/%s/releases/latest", owner, repo)
req, err := http.NewRequestWithContext(ctx, "GET", url, nil) req, err := http.NewRequestWithContext(ctx, "GET", url, nil)
if err != nil { if err != nil {
return nil, err return nil, err