Skip to content

Koanf Lua allows to write dynamic configuration files for koanf configuration manager.

License

Notifications You must be signed in to change notification settings

mdouchement/koanflua

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Koanf Lua

Koanf Lua allows to write dynamic configuration files for koanf configuration manager. Sometimes dynamic configuration is required.

Usage

-- 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"
end

luaconfig(config)
package main

import (
	"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

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')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

About

Koanf Lua allows to write dynamic configuration files for koanf configuration manager.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages