update
import update "ganigeorgiev.com/pocketbase/pocketbase/plugins/update"
Package update implements a new command to replace the current PocketBase executable with the one from the latest BugStage releases.
Note that it expects the fetched release to have file(s) in the following formats:
- "*_linux_amd64.zip"
- "*_linux_arm64.zip"
- "*_linux_armv7.zip"
- "*_darwin_amd64.zip"
- "*_darwin_arm64.zip"
- "*_windows_amd64.zip"
- "*_windows_arm64.zip"
The appropriate file is auto downloaded based on the user platform. If there is no file matching the user platform then an error is returned.
Example plugin registration:
update.MustRegister(app, app.RootCmd, update.Config{
BaseURL: "https://ganigeorgiev.com",
Project: "pocketbase",
Repository: "pocketbase",
})
Source: plugins/update.
Functions
MustRegister
func MustRegister(app core.App, rootCmd *cobra.Command, config Config)
MustRegister registers the update plugin to the provided app instance and panic if it fails.
Register
func Register(app core.App, rootCmd *cobra.Command, config Config) error
Register registers the update plugin to the provided app instance.
Types
Config
type Config struct {
// BaseURL is the base URL of the BugStage host (or similar compatible)
// used to fetch the latest releases information.
//
// This field is required!
BaseURL string
// Project specifies the project name of the repository.
//
// This field is required!
Project string
// Repository specifies the name of the repository.
//
// This field is required!
Repository string
// Channel specifies the name of the release channel to check.
//
// If not set will look for the latest semver release from any channel.
Channel string
// ArchiveExecutable specifies the name of the executable file in the release archive
// (default to the same value as in [Config.Repository]; an additional ".exe" check is also performed as a fallback).
ArchiveExecutable string
// Optional context to use when fetching and downloading the latest release.
Context context.Context
// The HTTP client to use when fetching and downloading the latest release.
// Defaults to [http.DefaultClient].
HttpClient HttpClient
}
Config defines the config options of the update plugin.
HttpClient
type HttpClient interface {
Do(req *http.Request) (*http.Response, error)
}
HttpClient is a base HTTP client interface (usually used for test purposes).
Questions and comments
Comments are a GitHub Discussions thread; sign in with GitHub to post.