2020-04-20 19:36:34 +03:00
package plugins
2023-11-30 23:42:06 +03:00
const (
runtimeYaegi = "yaegi"
runtimeWasm = "wasm"
)
const (
typeMiddleware = "middleware"
typeProvider = "provider"
)
2024-06-25 10:58:04 +03:00
type Settings struct {
Envs [ ] string ` description:"Environment variables to forward to the wasm guest." json:"envs,omitempty" toml:"envs,omitempty" yaml:"envs,omitempty" `
Mounts [ ] string ` description:"Directory to mount to the wasm guest." json:"mounts,omitempty" toml:"mounts,omitempty" yaml:"mounts,omitempty" `
}
2021-06-25 16:50:09 +03:00
// Descriptor The static part of a plugin configuration.
2020-04-20 19:36:34 +03:00
type Descriptor struct {
// ModuleName (required)
2020-10-30 14:44:05 +03:00
ModuleName string ` description:"plugin's module name." json:"moduleName,omitempty" toml:"moduleName,omitempty" yaml:"moduleName,omitempty" export:"true" `
2020-04-20 19:36:34 +03:00
// Version (required)
2020-10-30 14:44:05 +03:00
Version string ` description:"plugin's version." json:"version,omitempty" toml:"version,omitempty" yaml:"version,omitempty" export:"true" `
2024-06-25 10:58:04 +03:00
// Settings (optional)
Settings Settings ` description:"Plugin's settings (works only for wasm plugins)." json:"settings,omitempty" toml:"settings,omitempty" yaml:"settings,omitempty" export:"true" `
2020-04-20 19:36:34 +03:00
}
2021-06-25 16:50:09 +03:00
// LocalDescriptor The static part of a local plugin configuration.
type LocalDescriptor struct {
2020-04-20 19:36:34 +03:00
// ModuleName (required)
2024-06-25 10:58:04 +03:00
ModuleName string ` description:"Plugin's module name." json:"moduleName,omitempty" toml:"moduleName,omitempty" yaml:"moduleName,omitempty" export:"true" `
// Settings (optional)
Settings Settings ` description:"Plugin's settings (works only for wasm plugins)." json:"settings,omitempty" toml:"settings,omitempty" yaml:"settings,omitempty" export:"true" `
2020-04-20 19:36:34 +03:00
}
// Manifest The plugin manifest.
type Manifest struct {
DisplayName string ` yaml:"displayName" `
Type string ` yaml:"type" `
2023-11-30 23:42:06 +03:00
Runtime string ` yaml:"runtime" `
WasmPath string ` yaml:"wasmPath" `
2020-04-20 19:36:34 +03:00
Import string ` yaml:"import" `
BasePkg string ` yaml:"basePkg" `
Compatibility string ` yaml:"compatibility" `
Summary string ` yaml:"summary" `
TestData map [ string ] interface { } ` yaml:"testData" `
}
2023-11-30 23:42:06 +03:00
// IsYaegiPlugin returns true if the plugin is a Yaegi plugin.
func ( m * Manifest ) IsYaegiPlugin ( ) bool {
// defaults always Yaegi to have backwards compatibility to plugins without runtime
return m . Runtime == runtimeYaegi || m . Runtime == ""
}