Skip to content

Commit

Permalink
Merge pull request #31 from roman/config-value-type
Browse files Browse the repository at this point in the history
Multiple improvements:

* Better prettyprinter
* Support for types on etc/entries (not just cli)
* Remove .travis.yml
  • Loading branch information
roman authored May 13, 2018
2 parents f1c9e32 + 15af0e8 commit a01b8df
Show file tree
Hide file tree
Showing 24 changed files with 729 additions and 543 deletions.
171 changes: 0 additions & 171 deletions .travis.yml

This file was deleted.

13 changes: 13 additions & 0 deletions etc/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
0.4.0.0
----
**BREAKING CHANGES**

* Add new `type` field to `etc/spec` with support for `string`, `number`,
`bool`, `[string]`, `[number]` and `[bool]`, `[object]`
* Remove `type` field in `cli` spec in favor of `type` on `etc/spec`
* Allow ENV vars to accept supported types (only strings were allowed) (closes #30)
* Allow CLI options to accept supported types (only strings and numbers were allowed)
* Allow spec file to have array as default values
* Return a warning and an empty config whenever configuration files contain
entries not defined in the spec (closes #26)

0.3.2.0
----

Expand Down
2 changes: 1 addition & 1 deletion etc/etc.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
-- see: https://github.com/sol/hpack

name: etc
version: 0.3.2.0
version: 0.4.0.0
synopsis: Declarative configuration spec for Haskell projects
description: `etc` gathers configuration values from multiple sources (cli options, OS
environment variables, files) using a declarative spec file that defines where
Expand Down
6 changes: 0 additions & 6 deletions etc/src/System/Etc.hs
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE NoImplicitPrelude #-}


{-|
-}

module System.Etc (
-- * Config
-- $config
Expand Down
4 changes: 2 additions & 2 deletions etc/src/System/Etc/Internal/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ _getConfigValueWith parser keys0 (Config configValue0) =
Just (source, _) -> case JSON.iparse parser (fromValue $ value source) of

JSON.IError path err ->
let key = keys0 & reverse & Text.intercalate "."
let key = keys0 & Text.intercalate "."
in JSON.formatError path err
& Text.pack
& InvalidConfiguration (Just key)
Expand All @@ -57,7 +57,7 @@ _getConfigValueWith parser keys0 (Config configValue0) =
([], innerConfigValue) ->
case JSON.iparse parser (configValueToJsonObject innerConfigValue) of
JSON.IError path err ->
let key = keys0 & reverse & Text.intercalate "."
let key = keys0 & Text.intercalate "."
in JSON.formatError path err
& Text.pack
& InvalidConfiguration (Just key)
Expand Down
5 changes: 3 additions & 2 deletions etc/src/System/Etc/Internal/Extra/EnvMisspell.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
module System.Etc.Internal.Extra.EnvMisspell (
Expand Down Expand Up @@ -33,8 +34,8 @@ data EnvMisspell
lookupSpecEnvKeys :: ConfigSpec a -> Vector Text
lookupSpecEnvKeys spec =
let foldEnvSettings val acc = case val of
ConfigValue _defVal _sensitive sources ->
maybe acc (`Vector.cons` acc) (envVar sources)
ConfigValue { configSources } ->
maybe acc (`Vector.cons` acc) (envVar configSources)
SubConfig hsh -> HashMap.foldr foldEnvSettings acc hsh
in foldEnvSettings (SubConfig $ specConfigValues spec) Vector.empty

Expand Down
Loading

0 comments on commit a01b8df

Please sign in to comment.