Skip to content

Commit

Permalink
mod: add new property of context runtimeVersion for plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
aooohan committed Feb 5, 2024
1 parent 576ada7 commit 308c409
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions internal/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ const (
LuaPluginObjKey = "PLUGIN"
OsType = "OS_TYPE"
ArchType = "ARCH_TYPE"
PluginVersion = "0.0.1"
)

type LuaPlugin struct {
Expand Down Expand Up @@ -73,7 +72,7 @@ func (l *LuaPlugin) Close() {
func (l *LuaPlugin) Available() ([]*Package, error) {
L := l.state
ctxTable := L.NewTable()
L.SetField(ctxTable, "plugin_version", lua.LString(PluginVersion))
L.SetField(ctxTable, "runtimeVersion", lua.LString(RuntimeVersion))
if err := L.CallByParam(lua.P{
Fn: l.pluginObj.RawGetString("Available").(*lua.LFunction),
NRet: 1,
Expand Down Expand Up @@ -163,6 +162,7 @@ func (l *LuaPlugin) PreInstall(version Version) (*Package, error) {
L := l.state
ctxTable := L.NewTable()
L.SetField(ctxTable, "version", lua.LString(version))
L.SetField(ctxTable, "runtimeVersion", lua.LString(RuntimeVersion))

if err := L.CallByParam(lua.P{
Fn: l.pluginObj.RawGetString("PreInstall").(*lua.LFunction),
Expand Down Expand Up @@ -258,6 +258,7 @@ func (l *LuaPlugin) PostInstall(rootPath string, sdks []*Info) error {
}
ctxTable := L.NewTable()
L.SetField(ctxTable, "sdkInfo", sdkArr)
L.SetField(ctxTable, "runtimeVersion", lua.LString(RuntimeVersion))
L.SetField(ctxTable, "rootPath", lua.LString(rootPath))

function := l.pluginObj.RawGetString("PostInstall")
Expand Down Expand Up @@ -288,6 +289,7 @@ func (l *LuaPlugin) EnvKeys(sdkPackage *Package) (env.Envs, error) {
}
ctxTable := L.NewTable()
L.SetField(ctxTable, "sdkInfo", sdkArr)
L.SetField(ctxTable, "runtimeVersion", lua.LString(RuntimeVersion))
// TODO Will be deprecated in future versions
L.SetField(ctxTable, "path", lua.LString(mainInfo.Path))
if err := L.CallByParam(lua.P{
Expand Down

0 comments on commit 308c409

Please sign in to comment.