mirror of
https://github.com/go-vikunja/vikunja.git
synced 2026-05-07 20:38:46 -05:00
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:
@@ -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)."
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user