Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mdouchement/koanflua
Koanf Lua allows to write dynamic configuration files for koanf configuration manager.
https://github.com/mdouchement/koanflua
configuration configuration-management configuration-parser koanf lua
Last synced: about 1 month ago
JSON representation
Koanf Lua allows to write dynamic configuration files for koanf configuration manager.
- Host: GitHub
- URL: https://github.com/mdouchement/koanflua
- Owner: mdouchement
- License: mit
- Created: 2020-03-27T23:09:25.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-03-17T16:06:21.000Z (almost 2 years ago)
- Last Synced: 2024-10-16T10:05:56.225Z (3 months ago)
- Topics: configuration, configuration-management, configuration-parser, koanf, lua
- Language: Go
- Size: 6.84 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Koanf Lua
Koanf Lua allows to write dynamic configuration files for [koanf](https://github.com/knadh/koanf) configuration manager. Sometimes dynamic configuration is required.
## Usage
```lua
-- config.lua
local os = require "os"local config = {
brokers = array({"localhost:42", "localhost:4242"}), -- Hack for Golang to detect the table as an array
listen = "localhost",
redis = {
addr = "localhost:6379",
password = "trololo",
db = 1
}
}if os.getenv("MAGIC_FEATURE") == "enabled" then
config["feature"] = "testouille"
endluaconfig(config)
``````go
package mainimport (
"fmt"
"log""github.com/knadh/koanf"
"github.com/knadh/koanf/providers/file"
"github.com/mdouchement/koanflua"
)func main() {
konf := koanf.New(".")
err := konf.Load(file.Provider("config.lua"), koanflua.Parser())
if err != nil {
log.Fatal(err)
}//
redisAddr := konf.String("redis.addr")
fmt.Println(redisAddr)
}
```## Resources
- Default Lua library (same as Lua's VM): https://github.com/Shopify/go-lua
- Extra Lua library: https://github.com/Shopify/goluago## License
**MIT**
## Contributing
All PRs are welcome.
1. Fork it
2. Create your feature branch (git checkout -b my-new-feature)
3. Commit your changes (git commit -am 'Add some feature')
5. Push to the branch (git push origin my-new-feature)
6. Create new Pull Request