packages feed

language-puppet 1.3.2.1 → 1.3.3

raw patch · 4 files changed

+40/−19 lines, 4 filesdep ~aeson

Dependency ranges changed: aeson

Files

CHANGELOG.markdown view
@@ -1,3 +1,10 @@+# v1.3.3 (2016/12/05)++* Rename some pdbquery subcommands+* Output pdbquery in `json` instead of `yaml`+* Fix `pdbquery resources NODENAME`+* Add `pdbquery fact NODENAME`+ # v1.3.2.1 (2016/10/04)  * Support for megaparsec 5.1
README.adoc view
@@ -129,9 +129,13 @@  == pdbQuery -The `pdbQuery` command is used to work with different implementations of PuppetDB (the official one with its HTTP API, the file-based backend and dummy ones). Its main use is to-export data from production PuppetDB to a file in order to debug some issue with `puppetresources`. Here is a list of command line arguments :+The `pdbquery` command will work with different implementations of PuppetDB (the official one with its HTTP API, the file-based backend and dummy ones). It can be used to: +* export data from production PuppetDB to a file (in order to debug some issue with `puppetresources`).+* query a Puppetdb++Here is a list of command line arguments :+ `-l` or `--location`::  The URL of the PuppetDB when working with a remote PuppetDB, a file path when working with the file-based test implementation.@@ -145,24 +149,26 @@ * test: a file-based backend emulating a PuppetDB.  .Commands-`dumpfacts`:: -Dump all facts, and store them in `/tmp/allfacts.yaml`.+`facts`::+Output facts for a specific node (json)  `nodes`::+Output all nodes (json) -Dump all nodes+`resources`::+Output all resources for a specific node (json) -`snapshot`::+`dumpfacts`::+Dump all facts to `/tmp/allfacts.yaml`. +`snapshot`:: Create a test DB from the current DB  `addfacts`::- Adds facts to the test DB for the given node name, if they are not already defined.  `--version`::- Output version information and exit.  == Unsupported Puppet idioms or features
language-puppet.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                language-puppet-version:             1.3.2.1+version:             1.3.3 synopsis:            Tools to parse and evaluate the Puppet DSL. description:         This is a set of tools that is supposed to fill all your Puppet needs : syntax checks, catalog compilation, PuppetDB queries, simulationg of complex interactions between nodes, Puppet master replacement, and more ! homepage:            http://lpuppet.banquise.net/@@ -219,6 +219,7 @@   ghc-options:         -Wall -rtsopts -threaded   -- ghc-prof-options:    -auto-all -caf-all -fprof-auto   build-depends:       base+                     , aeson                      , bytestring                      , http-client                      , language-puppet
progs/pdbQuery.hs view
@@ -6,7 +6,8 @@ import           Control.Lens import           Control.Monad              (forM_, unless, (>=>)) import           Control.Monad.Trans.Except-import qualified Data.ByteString.Char8      as BS+import qualified Data.Aeson                 as Aeson+import qualified Data.ByteString.Lazy.Char8 as BS import qualified Data.Either.Strict         as S import qualified Data.HashMap.Strict        as HM import           Data.List                  (foldl')@@ -14,7 +15,6 @@ import qualified Data.Text                  as T import qualified Data.Vector                as V import qualified Data.Version               (showVersion)-import           Data.Yaml                  hiding (Parser) import           Network.HTTP.Client import           Options.Applicative        as O import qualified Paths_language_puppet@@ -35,6 +35,7 @@                        }  data Command = DumpFacts+             | DumpFact T.Text              | DumpNodes              | EditFact T.Text T.Text              | DeactivateNode T.Text@@ -60,20 +61,24 @@         (  long "version"         <> help "Output version information and exit")     where-        cmd = subparser (  command "dumpfacts" (info (pure DumpFacts)(progDesc "Dump all facts, store in /tmp/allfacts.yaml" <> failureCode 4))-                        <> command "editfact"  (info factedit (progDesc "Edit a fact corresponding to a node" <> failureCode 7 ))-                        <> command "dumpres"   (info resourcesparser (progDesc "Dump resources" <> failureCode 5))-                        <> command "delnode"   (info delnodeparser   (progDesc "Deactivate node" <> failureCode 6))-                        <> command "nodes"     (info (pure DumpNodes)(progDesc "Dump all nodes" <> failureCode 8))+        cmd = subparser (  command "resources"   (info resourcesparser (progDesc "Output resources for one node" <> failureCode 5))+                        <> command "facts"  (info factparser (progDesc "Output facts for one node" <> failureCode 12 ))+                        <> command "nodes"     (info (pure DumpNodes)(progDesc "Output all nodes" <> failureCode 8))+                        <> command "dumpfacts" (info (pure DumpFacts)(progDesc "Dump all facts, store in /tmp/allfacts.yaml" <> failureCode 4))                         <> command "snapshot"  (info createtestdb    (progDesc "Create a test DB from the current DB" <> failureCode 10))+                        <> command "delnode"   (info delnodeparser   (progDesc "Deactivate node" <> failureCode 6))+                        <> command "editfact"  (info factedit (progDesc "Edit a fact corresponding to a node" <> failureCode 7 ))                         <> command "addfacts"  (info addfacts        (progDesc "Adds facts to the test DB for the given node name, if they are not already defined" <> failureCode 11))                         )  factedit :: Parser Command factedit = EditFact <$> O.argument auto mempty <*> O.argument auto mempty +factparser :: Parser Command+factparser = DumpFact <$> fmap T.pack (O.strArgument (metavar "NODE"))+ resourcesparser :: Parser Command-resourcesparser = DumpResources <$> O.argument auto mempty+resourcesparser = DumpResources <$> fmap T.pack (O.strArgument (metavar "NODE"))  delnodeparser :: Parser Command delnodeparser = DeactivateNode <$> O.argument auto mempty@@ -85,9 +90,9 @@ addfacts = AddFacts <$> O.argument auto mempty  -display :: (Show r, ToJSON a) => String -> Either r a -> IO ()+display :: (Show r, Aeson.ToJSON a) => String -> Either r a -> IO () display s (Left rr) = error (s <> " " <> show rr)-display _ (Right a) = BS.putStrLn (encode a)+display _ (Right a) = BS.putStrLn (Aeson.encode a)  checkErrorS :: (Show r) => String -> S.Either r a -> IO a checkErrorS s (S.Left rr) = error (s <> " " <> show rr)@@ -129,7 +134,9 @@                                      curmap & at ndname . non HM.empty %~ (at fctname ?~ fctval)                              runCheck "replace facts in dummy db" (replaceFacts tmpdb (HM.toList groupfacts))                              runCheck "commit db" (commitDB tmpdb)+        DumpFact n -> runExceptT (getFacts pdbapi (QEqual FCertname n ) ) >>= display "dump fact"         DumpNodes -> runExceptT (getNodes pdbapi QEmpty) >>= display "dump nodes"+        DumpResources n -> runExceptT (getResourcesOfNode pdbapi n QEmpty) >>= display "get resources"         AddFacts n -> do             unless (_pdbtype == PDBTest) (error "This option only works with the test puppetdb")             fcts <- puppetDBFacts n pdbapi