Skip to content

Commit

Permalink
added package_version() in Lua, removed version module
Browse files Browse the repository at this point in the history
The package_version() function returns current build information.
Removed the version module instead of fixing, as it's being obsoleted.
  • Loading branch information
vavrusa authored and tkrizek committed Jul 16, 2018
1 parent 97a43e2 commit fcdf8d6
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 111 deletions.
1 change: 0 additions & 1 deletion .gitignore
Expand Up @@ -65,7 +65,6 @@ kresd.amalg.c
libkres.amalg.c
/doc/kresd.8
/libkres.pc
/modules/version/version.lua
/tags
/coverage
/coverage.stats
1 change: 1 addition & 0 deletions .luacheckrc
Expand Up @@ -3,6 +3,7 @@ new_read_globals = {
'help',
'quit',
'hostname',
'package_version',
'moduledir',
'user',
'verbose',
Expand Down
2 changes: 1 addition & 1 deletion config.mk
Expand Up @@ -2,7 +2,7 @@
MAJOR := 2
MINOR := 4
PATCH := 0
EXTRA :=
EXTRA ?=
ABIVER := 7
BUILDMODE := dynamic
HARDENING := yes
Expand Down
12 changes: 12 additions & 0 deletions daemon/README.rst
Expand Up @@ -349,6 +349,18 @@ Environment
end
end)
.. function:: package_version()

:return: Current package version.

This returns current package version (the version of the binary) as a string.

.. code-block:: lua
> package_version()
2.1.1
Network configuration
^^^^^^^^^^^^^^^^^^^^^

Expand Down
10 changes: 10 additions & 0 deletions daemon/engine.c
Expand Up @@ -70,6 +70,7 @@ static int l_help(lua_State *L)
"help()\n show this help\n"
"quit()\n quit\n"
"hostname()\n hostname\n"
"package_version()\n return package version\n"
"user(name[, group])\n change process user (and group)\n"
"verbose(true|false)\n toggle verbose mode\n"
"option(opt[, new_val])\n get/set server option\n"
Expand Down Expand Up @@ -209,6 +210,13 @@ static int l_hostname(lua_State *L)
return 1;
}

/** Return server package version. */
static int l_package_version(lua_State *L)
{
lua_pushliteral(L, PACKAGE_VERSION);
return 1;
}

char *engine_get_moduledir(struct engine *engine) {
return engine->moduledir;
}
Expand Down Expand Up @@ -646,6 +654,8 @@ static int init_state(struct engine *engine)
lua_setglobal(engine->L, "quit");
lua_pushcfunction(engine->L, l_hostname);
lua_setglobal(engine->L, "hostname");
lua_pushcfunction(engine->L, l_package_version);
lua_setglobal(engine->L, "package_version");
lua_pushcfunction(engine->L, l_moduledir);
lua_setglobal(engine->L, "moduledir");
lua_pushcfunction(engine->L, l_verbose);
Expand Down
1 change: 0 additions & 1 deletion doc/modules.rst
Expand Up @@ -23,7 +23,6 @@ Knot DNS Resolver modules
.. include:: ../modules/dns64/README.rst
.. include:: ../modules/renumber/README.rst
.. include:: ../modules/cookies/README.rst
.. include:: ../modules/version/README.rst
.. include:: ../modules/bogus_log/README.rst
.. include:: ../modules/workarounds/README.rst
.. include:: ../modules/dnstap/README.rst
Expand Down
1 change: 0 additions & 1 deletion modules/modules.mk
Expand Up @@ -35,7 +35,6 @@ modules_TARGETS += bogus_log \
http \
daf \
workarounds \
version \
ta_signal_query \
priming \
serve_stale \
Expand Down
22 changes: 0 additions & 22 deletions modules/version/README.rst

This file was deleted.

74 changes: 0 additions & 74 deletions modules/version/version.lua.in

This file was deleted.

11 changes: 0 additions & 11 deletions modules/version/version.mk

This file was deleted.

0 comments on commit fcdf8d6

Please sign in to comment.