Safe Haskell | None |
---|
This module is used for user plugins. It exports three functions that should
be easy to use: initLua
, puppetFunc
and closeLua
. Right now it is used by
the Puppet.Daemon by initializing and destroying the Lua context for each
catalog computation. Obviously such plugins will be implemented in Lua.
Users plugins are right now limited to custom functions. The user must put them at the exact same place as their Ruby counterparts, except the extension must be lua instead of rb. In the file, a function called by the same name that takes a single argument must be defined. This argument will be an array made of all the functions arguments. If the file doesn't parse, it will be silently ignored.
Here are the things that must be kept in mind:
- Lua doesn't have integers. All numbers are double.
- All Lua associative arrays that are returned must have a simple type for all the keys, as it will be converted to a string. Numbers will be directly converted and other types will produce strange results.
- This currently only works for functions that must return a value. They will have no access to the manifests data.
- initLua :: Text -> IO (LuaState, [Text])
- puppetFunc :: LuaState -> Text -> [ResolvedValue] -> CatalogMonad ResolvedValue
- closeLua :: LuaState -> IO ()
- getFiles :: Text -> Text -> Text -> IO [Text]
Documentation
initLua :: Text -> IO (LuaState, [Text])Source
Initializes the Lua state. The argument is the modules directory. Each
subdirectory will be traversed for functions.
The default location is /lib/puppet/parser/functions
.
puppetFunc :: LuaState -> Text -> [ResolvedValue] -> CatalogMonad ResolvedValueSource
Runs a puppet function in the CatalogMonad
monad. It takes a state,
function name and list of arguments. It returns a valid Puppet value.