diff options
Diffstat (limited to 'src/Conftrack/Source/Aeson.hs')
-rw-r--r-- | src/Conftrack/Source/Aeson.hs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/Conftrack/Source/Aeson.hs b/src/Conftrack/Source/Aeson.hs index 97353d0..17ea4ee 100644 --- a/src/Conftrack/Source/Aeson.hs +++ b/src/Conftrack/Source/Aeson.hs @@ -7,7 +7,8 @@ {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE LambdaCase #-} -module Conftrack.Source.Aeson (JsonSource(..), mkJsonSource, mkJsonSourceWith, mkJsonFileSource) where +-- | Functions for producing sources reading from json strings or files, using the aeson library. +module Conftrack.Source.Aeson (mkJsonSource, mkJsonSourceWith, mkJsonFileSource, JsonSource(..)) where import Conftrack.Value (Key (..), ConfigError(..), Value (..), KeyPart) import Conftrack.Source (SomeSource(..), ConfigSource (..)) @@ -37,13 +38,17 @@ data JsonSource = JsonSource , jsonSourceDescription :: Text } deriving (Show) +-- | Make a source from an aeson value mkJsonSource :: A.Value -> SomeSource mkJsonSource value = mkJsonSourceWith ("JSON string " <> LT.toStrict (A.encodeToLazyText value)) value +-- | same as 'mkJsonSource', but with an additional description to be shown +-- in output of 'Conftrack.Pretty.printConfigOrigins'. mkJsonSourceWith :: Text -> A.Value -> SomeSource mkJsonSourceWith description value = SomeSource (source, []) where source = JsonSource value description +-- | Make a source from a json file. mkJsonFileSource :: OsPath -> IO (Maybe SomeSource) mkJsonFileSource path = do bytes <- readFile path |