feat(plugins): add plugin config options

Add configuration keys:
- plugins.enabled (default: false)
- plugins.dir (default: <rootpath>/plugins)
- plugins.loader (default: native, validated at startup)

Register yaegi loader via blank import in initialize package.
This commit is contained in:
kolaente
2026-03-30 22:21:35 +02:00
committed by kolaente
parent 1d354512e6
commit 3db410933e
3 changed files with 12 additions and 0 deletions

View File

@@ -1049,6 +1049,11 @@
"key": "dir",
"default_value": "<rootpath>plugins",
"comment": "The directory where plugins are stored."
},
{
"key": "loader",
"default_value": "native",
"comment": "The plugin loader to use. \"yaegi\" loads plugins from Go source files (directories of .go files). \"native\" (deprecated) loads compiled Go plugin shared libraries (.so files)."
}
]
}

View File

@@ -230,6 +230,7 @@ const (
PluginsEnabled Key = `plugins.enabled`
PluginsDir Key = `plugins.dir`
PluginsLoader Key = `plugins.loader`
)
var maxFileSizeInBytes uint64
@@ -484,6 +485,7 @@ func InitDefaultConfig() {
// Plugins
PluginsEnabled.setDefault(false)
PluginsDir.setDefault(ResolvePath("plugins"))
PluginsLoader.setDefault("native")
// Migrate deprecated webhook config keys to outgoingrequests.*
// This allows removing the old keys in a single place later.
@@ -657,6 +659,10 @@ func InitConfig() {
RateLimitStore.Set(KeyvalueType.GetString())
}
if loader := PluginsLoader.GetString(); loader != "yaegi" && loader != "native" {
log.Fatalf("Invalid value for plugins.loader: %q (must be \"yaegi\" or \"native\")", loader)
}
if CorsEnable.GetBool() && ServicePublicURL.GetString() == "" {
log.Fatalf("service.publicurl is required when cors.enable is true")
}

View File

@@ -34,6 +34,7 @@ import (
"code.vikunja.io/api/pkg/modules/keyvalue"
migrationHandler "code.vikunja.io/api/pkg/modules/migration/handler"
"code.vikunja.io/api/pkg/plugins"
_ "code.vikunja.io/api/pkg/plugins/yaegi" // register yaegi plugin loader
"code.vikunja.io/api/pkg/red"
"code.vikunja.io/api/pkg/user"
)