Documentation
¶
Index ¶
- Constants
- func Copy(srcFile, dstFile string) error
- func CopyDir(dst, src string) error
- func CopyDirectory(scrDir, dest string) error
- func CopySymLink(source, dest string) error
- func CreateIfNotExists(dir string, perm os.FileMode) error
- func Exists(filePath string) bool
- func FindGoBinary() (string, error)
- func FindNodeBinary() (string, error)
- func FindPnpmBinary() (string, error)
- func HydrateBuildOpts(opts *types.BuildOpts) error
- func PrepareCommandWithBinaries(command string, args []string, binaries ...string) (*exec.Cmd, error)
- type DevServerChecker
- type LoadPluginOptions
- type Manager
- type PluginBuilder
- type PluginPIDTracker
Constants ¶
const ( PluginInstallStart = "plugin/install_start" PluginDevInstallEventStart = "plugin/dev_install_start" PluginDevInstallEventError = "plugin/dev_install_error" PluginDevInstallEventComplete = "plugin/dev_install_complete" PluginReloadEventStart = "plugin/dev_reload_start" PluginReloadEventError = "plugin/dev_reload_error" PluginReloadEventComplete = "plugin/dev_reload_complete" )
const ( MaxPluginSize = 1024 * 1024 * 1024 // 1GB PluginUpdateStartedEvent = "plugin/update_started" PluginInstallStartedEvent = "plugin/install_started" PluginInstallFinishedEvent = "plugin/install_finished" PluginInstallErrorEvent = "plugin/install_error" PluginInitCompleteEvent = "plugin/init_complete" )
const (
DedupInterval = 500 * time.Millisecond
)
Variables ¶
This section is empty.
Functions ¶
func CopyDirectory ¶
func CopySymLink ¶
func FindGoBinary ¶
FindGoBinary looks for the Go binary in a number of well-known paths in case it's not available in the PATH.
func FindNodeBinary ¶
FindNodeBinary tries to locate the Node.js binary across common install paths.
func FindPnpmBinary ¶
FindPnpmBinary looks for the Pnpm binary in a number of well-known paths in case it's not available in the PATH.
func HydrateBuildOpts ¶
HydrateBuildOpts adds the additional build options if they are not specified
Types ¶
type DevServerChecker ¶
DevServerChecker allows the plugin manager to check if a plugin is managed by the dev server system, without importing the devserver package.
type LoadPluginOptions ¶
type LoadPluginOptions struct {
DevMode bool
DevModePath string
ExistingState *plugintypes.PluginState
}
type Manager ¶
type Manager interface {
// Initialize discovers and loads all plugins that are currently installed in the plugin directory,
// and initializes them with the appropriate controllers.
Initialize(ctx context.Context) error
// Run starts until the the passed in context is cancelled
Run(ctx context.Context)
// Shutdown stops the plugin manager and all plugins.
Shutdown()
// InstallInDevMode installs a plugin from the given path, and sets up a watcher to recompile and reload the plugin
// when changes are detected. Will prompt the user for a path.
InstallInDevMode() (*config.PluginMeta, error)
// InstallFromPathPrompt installs a plugin from the given path, prompting the user for the location
// with a window dialog.
InstallFromPathPrompt() (*config.PluginMeta, error)
// InstallPluginFromPath installs a plugin from the given path. It will validate the plugin
// and then load it into the manager.
InstallPluginFromPath(path string) (*config.PluginMeta, error)
// InstallPluginVersion installs a plugin with a specified version from the plugin registry.
// It returns an error if it does not exist.
InstallPluginVersion(pluginID string, version string) (*config.PluginMeta, error)
// LoadPlugin loads a plugin at the given path. It will validate the plugin
// and then load it into the manager.
LoadPlugin(id string, opts *LoadPluginOptions) (types.Plugin, error)
// ReloadPlugin reloads a plugin at the given path. It will validate the plugin
// and then load it into the manager.
ReloadPlugin(id string) (types.Plugin, error)
// UninstallPlugin uninstalls a plugin from the manager, and removes it from the filesystem.
UninstallPlugin(id string) (types.Plugin, error)
// GetPlugin returns the plugin with the given plugin ID.
GetPlugin(id string) (types.Plugin, error)
// ListPlugins returns a list of all plugins that are currently registered with the manager.
ListPlugins() []types.Plugin
// ListAvailablePlugins returns a list of all plugins that are available and supported for the
// user's IDE environment.
ListAvailablePlugins() ([]registry.AvailablePlugin, error)
// SearchPlugins searches the marketplace with filters.
SearchPlugins(query, category, sort string) ([]registry.AvailablePlugin, error)
// GetPluginReadme fetches the README for a marketplace plugin.
GetPluginReadme(pluginID string) (string, error)
// GetPluginVersions fetches version info for a marketplace plugin.
GetPluginVersions(pluginID string) ([]registry.VersionInfo, error)
// GetPluginReviews fetches reviews for a marketplace plugin.
GetPluginReviews(pluginID string, page int) ([]registry.Review, error)
// GetPluginDownloadStats fetches download statistics for a marketplace plugin.
GetPluginDownloadStats(pluginID string) (*registry.DownloadStats, error)
// GetPluginReleaseHistory fetches version history for a marketplace plugin.
GetPluginReleaseHistory(pluginID string) ([]registry.VersionInfo, error)
// GetPluginMeta returns the plugin metadata for the given plugin ID.
GetPluginMeta(id string) (config.PluginMeta, error)
// ListPlugins returns a list of all plugins that are currently registered with the manager.
ListPluginMetas() []config.PluginMeta
// SetDevServerChecker sets the dev server checker used to skip the old
// rebuild pipeline for plugins managed by the DevServerManager.
SetDevServerChecker(checker DevServerChecker)
// SetDevServerManager sets the dev server manager used to auto-start
// dev servers for plugins in dev mode.
SetDevServerManager(mgr *devserver.DevServerManager)
}
Manager manages the lifecycle and registration of plugins. It is responsible for registering and unregistering plugins, and communicating with the plugin controllers to handle the lifecycle of the plugins.
func NewManager ¶
func NewManager( logger *zap.SugaredLogger, resourceController resource.Controller, settingsController settings.Controller, execController pluginexec.Controller, networkerController networker.Controller, logsController pluginlogs.Controller, metricController pluginmetric.Controller, managers map[string]plugintypes.PluginManager, settingsProvider pkgsettings.Provider, registryClient *registry.Client, ) Manager
NewManager returns a new plugin manager for the IDE to use to manager installed plugins.
type PluginBuilder ¶
type PluginBuilder struct{}
type PluginPIDTracker ¶
type PluginPIDTracker struct {
// contains filtered or unexported fields
}
PluginPIDTracker tracks PIDs of running plugin binary processes so that orphaned processes from a previous unclean shutdown (force-quit, crash, SIGKILL) can be cleaned up on the next startup.
On clean shutdown, client.Kill() already terminates plugin processes, so the saved PID file will typically be empty. The file only matters when shutdown was interrupted.
func NewPluginPIDTracker ¶
func NewPluginPIDTracker() *PluginPIDTracker
NewPluginPIDTracker creates a new tracker with an empty PID map.
func (*PluginPIDTracker) CleanupStale ¶
func (t *PluginPIDTracker) CleanupStale(logger *zap.SugaredLogger)
CleanupStale reads the PID file from a previous session, kills any processes that are still alive, and removes the file. This should be called early in Initialize(), before any new plugins are started.
func (*PluginPIDTracker) Record ¶
func (t *PluginPIDTracker) Record(pluginID string, pid int)
Record adds or updates the PID for a plugin. Called after a plugin binary is successfully started and the gRPC connection is established.
func (*PluginPIDTracker) Remove ¶
func (t *PluginPIDTracker) Remove(pluginID string)
Remove deletes the PID entry for a plugin. Called when a plugin is cleanly stopped via client.Kill().
func (*PluginPIDTracker) Save ¶
func (t *PluginPIDTracker) Save() error
Save persists the current pluginID→PID map to disk. This is called during Shutdown as a safety net — if all plugins were stopped cleanly the map is empty, but if shutdownPlugin failed for any plugin its PID will be saved for cleanup on the next startup.