All Projects → damnever → cc

damnever / cc

Licence: BSD-3-Clause License
💊 Golang Configuration Management for "Humans™?"

Programming Languages

go
31211 projects - #10 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to cc

play-rconf
Remote configuration for Play Framework
Stars: ✭ 17 (-46.87%)
Mutual labels:  configuration-management
node
💪 Simple & Secure Config Management for Node.js 💪
Stars: ✭ 32 (+0%)
Mutual labels:  configuration-management
ansible-rabbitmq-cluster
No description or website provided.
Stars: ✭ 21 (-34.37%)
Mutual labels:  configuration-management
Alpheus
Cross-platform configuration file parser
Stars: ✭ 21 (-34.37%)
Mutual labels:  configuration-management
doraemon
A management tool to help you organize your daily development
Stars: ✭ 21 (-34.37%)
Mutual labels:  configuration-management
ansible-role-for-splunk
Splunk@Splunk's Ansible role for installing Splunk, upgrading Splunk, and installing apps/addons on Splunk deployments (VM/bare metal)
Stars: ✭ 75 (+134.38%)
Mutual labels:  configuration-management
configmanager
Forget about configparser, YAML, or JSON parsers. Focus on configuration. NOT RECOMMENDED FOR USE (2019-01-26)
Stars: ✭ 15 (-53.12%)
Mutual labels:  configuration-management
envkeygo
EnvKey's official Go client library
Stars: ✭ 36 (+12.5%)
Mutual labels:  configuration-management
home-assistant-ansible
🎭 Ansible playbooks/role for the setup of Home Assistant.
Stars: ✭ 48 (+50%)
Mutual labels:  configuration-management
envkey-ruby
EnvKey's official Ruby client library
Stars: ✭ 24 (-25%)
Mutual labels:  configuration-management
sift-saltstack
Salt States for Configuring the SIFT Workstation
Stars: ✭ 82 (+156.25%)
Mutual labels:  configuration-management
puppet-augeasproviders
Alternative Augeas-based providers for Puppet
Stars: ✭ 64 (+100%)
Mutual labels:  configuration-management
easy-props
The simple, stupid properties library for Java
Stars: ✭ 76 (+137.5%)
Mutual labels:  configuration-management
humans
Awesome Humans
Stars: ✭ 49 (+53.13%)
Mutual labels:  humans
windows-lab
Windows Automated Lab with Vagrant
Stars: ✭ 78 (+143.75%)
Mutual labels:  configuration-management
rubric
Linter Config Initializer for Python
Stars: ✭ 21 (-34.37%)
Mutual labels:  configuration-management
granitic
Web/micro-services and IoC framework for Golang developers
Stars: ✭ 32 (+0%)
Mutual labels:  configuration-management
gops
配置管理,分布式定时任务
Stars: ✭ 45 (+40.63%)
Mutual labels:  configuration-management
nest-typed-config
Intuitive, type-safe configuration module for Nest framework ✨
Stars: ✭ 47 (+46.88%)
Mutual labels:  configuration-management
kas
Setup tool for bitbake based projects
Stars: ✭ 178 (+456.25%)
Mutual labels:  configuration-management

cc - Golang Configuration Management for Humans™

Build Status Go Report Card GoDoc

Only support JSON and YAML.

Installation

go get -u github.com/damnever/cc

Usage

c, _ := cc.NewConfigFromFile("./example/example.yaml")  // file must has extension
_ := c.MergeFromFile("./example/example.json") // do not ignore the errors

c.Must("name")  // panic if not found
c.String("name")

cc := c.Config("map")
cc.Bool("key_one")

list := c.Value("list").List()
list[1].Int()

// environment variables
os.Setenv("float_env", "11.11")
c.Float("float_env")

// flags (import "flag")
flag.Int("flag", 33, "usage")
c.Int("flag")

The priorities: flags > environment variables > normal configs NOTE: we take empty string, false boolean and zero number value as default value in flag, and those value has no priority.

Default configs

We may write the code like this:

name := "default"
if c.Has("name") {
    name = c.String("name")  // or panic
}

Now, we can write code like this:

name := c.StringOr("name", "cc")  // or c.Must("name")
b := c.BoolOr("bool", true)
f := c.FloatOr("float", 3.14)
i := c.IntOr("int", 33)

Pattern && Validation

If you want to check string value whether it is matched by regexp:

s, ok := c.StringAnd("name", "^c")

Or, the make the string value as a pattern:

p := c.Pattern("pattern_key_name")
ok := p.ValidateString("a string")

For int(time.Duration) and float, cc use if-like condition to do similar work. Assume we have threhold: "N>=30&&N<=80" in config file, we can use it like this:

p := c.Pattern("threhold")
ok := p.ValidateInt(40)  // or ValidateFloat

Or, using a pattern to validate the number:

ni, ok := c.IntAnd("int_key", "N>50")
nf, ok := c.FloatAnd("float_key", "N/100>=0.3")

// or, given a default value
ni = c.IntAndOr("int_key", "N>50", 51)
nf = c.FloatAndOr("int_key", "N/100>=0.3", 40)
d := c.DurationAndOr("duration", "N>20&&N<=100", 50)

NOTE: bit operation is not supported.

LICENSE

The BSD 3-Clause License

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].