-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[config] YAML with template #2
Comments
- NOTE: didn't test it, since we don't have getter functions like viper yet. - Add `util` package for things that is handy but can not be grouped into a specific package, like get environment variables as map[string]string
- previously, the second render is done regardless of current document has vars or not. - add test for environment variables - use 4 space for tab in golang file, this would avoid the yaml can't parse tab problem when writting test - pongo render false to False, which is ok for Yaml, since it is very tolerant on the format of boolean values
Found viper complains about go-yaml as well
I think it would be a good idea to write a new yaml parser for golang now
|
- similar to https://github.com/spf13/cast - need to use cast when working on config #2 - [ ] I am still not sure if go-yaml is still using map[interface{}]interface{} for nested levels although based on previous comments, using map[string]interface{} won't work
- add util function to merge two map[string]interface{} - add ParseSingleDocumentBytes and call it in ParseMultipleDocumentBytes
- keys inside `vars` are merged while other top level keys are merged inside directly, i.e. `vars: a:1 db:jack --- vars: b:1 db: marry` would result in `var: a:1 b:1 db: marry`
- Get and GetOrDefault don't return error when the key does not exists, and default is helpful in some cases, though I think it's better to set default values globally instead of put it when you read the config
now I am considering using https://golang.org/pkg/text/template instead of pong2 because we don't need that much feature, though the golang syntax is a little bit strange .... |
- for #2, we may not need that much feature on pongo2 - the main drawback of golang's built in template is its syntax is quite strange - golang's template does support remove new line, though it would also trim tab
so current version is using go's template, and has function to get environment variables, it is rendered twice to make use of variables declared in current file, it supports multiple yaml in same document (by split before unmarshal), also we no longer have so many getter and setter, we chose to unmarshal it into a go struct, which provides usage and type safety. We may change to a DSL, like https://github.com/dhall-lang/dhall-lang, but that would be another story, sorry didn't have a release for config (patpat config) .... there is no semver in all projects where I am the only active developer and user .... |
Transferred from: dyweb/Ayi#65
Related issues: embed script language dyweb/Ayi#51, xephon-b config xephonhq/xephon-b#6, runner command config dyweb/Ayi#63
TODO
test broke, mixed use ofenv
andenvs
Get
https://github.com/spf13/viper/blob/master/viper.go#L591find
https://github.com/spf13/viper/blob/master/viper.go#L851var
andenv
interface{}
, like what I did in xephon-k https://github.com/xephonhq/xephon-k/blob/master/pkg/config/bench.goUnmarshal
https://godoc.org/github.com/spf13/viper#Unmarshalc.data["vars"]
should be removed, thought about it in [config] Use built in template package instead of pongo2 #15Get methods
now
,now+1d
, might be something from Reika?a.b.c
can be override byA_B_C
https://github.com/influxdata/influxdb/blob/master/cmd/influxd/run/config.go#L192applyEnvOverrides
Set method
Load file
/
? likenpm?? (I saw some program traverse parent folders to find the nearest match, just could find one for now, maybe git?)Legacy
TODO
Won't fix
we no longer use pongo2, so they are all fixed ....
false
toFalse
, but Yaml spec support a lot of values http://yaml.org/type/bool.htmlThe text was updated successfully, but these errors were encountered: