-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Tools to parse and evaluate the Puppet DSL. -- -- This is a set of tools that is supposed to fill all your Puppet needs -- : syntax checks, catalog compilation, PuppetDB queries, simulation of -- complex interactions between nodes, Puppet master replacement, and -- more ! @package language-puppet @version 1.4.3 -- | General specific prelude for language-puppet. Customization of the -- Protolude with extra specific utilities. module XPrelude type Container = HashMap Text text2Scientific :: Text -> Maybe Scientific scientific2text :: Scientific -> Text strictifyEither :: Either a b -> Either a b -- | Helper for hashmap, in case we want another kind of map. ifromList :: (Monoid m, At m, Foldable f) => f (Index m, IxValue m) -> m -- | Return all the keys of a map in a set. ikeys :: (Eq k, Hashable k) => HashMap k v -> HashSet k ifromListWith :: (Monoid m, At m, Foldable f) => (IxValue m -> IxValue m -> IxValue m) -> f (Index m, IxValue m) -> m iinsertWith :: At m => (IxValue m -> IxValue m -> IxValue m) -> Index m -> IxValue m -> m -> m iunionWith :: (Hashable k, Eq k) => (v -> v -> v) -> HashMap k v -> HashMap k v -> HashMap k v -- | Remove the '::' token from a text if any. dropInitialColons :: Text -> Text loggerName :: String logDebug :: Text -> IO () logInfo :: Text -> IO () logInfoStr :: String -> IO () logWarning :: Text -> IO () logWarningStr :: String -> IO () logError :: Text -> IO () logCritical :: Text -> IO () logCriticalStr :: String -> IO () logDebugStr :: String -> IO () -- | In case of a Left error, print and exit immediately. unwrapError :: Doc -> Either PrettyError a -> IO a -- | An associative operation. (<>) :: Semigroup a => a -> a -> a infixr 6 <> -- | (hPutDoc handle doc) pretty prints document doc to -- the file handle handle with a page width of 80 characters and -- a ribbon width of 32 characters. -- --
--   main = do{ handle <- openFile "MyFile" WriteMode
--            ; hPutDoc handle (vcat (map text
--                              ["vertical","text"]))
--            ; hClose handle
--            }
--   
-- -- Any ANSI colorisation in doc will be output. hPutDoc :: Handle -> Doc -> IO () -- | The action (putDoc doc) pretty prints document doc -- to the standard output, with a page width of 80 characters and a -- ribbon width of 32 characters. -- --
--   main :: IO ()
--   main = do{ putDoc (text "hello" <+> text "world") }
--   
-- -- Which would output -- --
--   hello world
--   
-- -- Any ANSI colorisation in doc will be output. putDoc :: Doc -> IO () -- | (displayIO handle simpleDoc) writes simpleDoc to the -- file handle handle. This function is used for example by -- hPutDoc: -- --
--   hPutDoc handle doc  = displayIO handle (renderPretty 0.4 80 doc)
--   
-- -- Any ANSI colorisation in simpleDoc will be output. displayIO :: Handle -> SimpleDoc -> IO () -- | (displayS simpleDoc) takes the output simpleDoc from -- a rendering function and transforms it to a ShowS type (for use -- in the Show class). -- --
--   showWidth :: Int -> Doc -> String
--   showWidth w x   = displayS (renderPretty 0.4 w x) ""
--   
-- -- ANSI color information will be discarded by this function unless you -- are running on a Unix-like operating system. This is due to a -- technical limitation in Windows ANSI support. displayS :: SimpleDoc -> ShowS -- | (renderCompact x) renders document x without adding -- any indentation. Since no 'pretty' printing is involved, this renderer -- is very fast. The resulting output contains fewer characters than a -- pretty printed version and can be used for output that is read by -- other programs. -- -- This rendering function does not add any colorisation information. renderCompact :: Doc -> SimpleDoc -- | A slightly smarter rendering algorithm with more lookahead. It -- provides provide earlier breaking on deeply nested structures For -- example, consider this python-ish pseudocode: -- fun(fun(fun(fun(fun([abcdefg, abcdefg]))))) If we put a -- softbreak (+ nesting 2) after each open parenthesis, and align the -- elements of the list to match the opening brackets, this will render -- with renderPretty and a page width of 20 as: -- fun(fun(fun(fun(fun([ | abcdef, | abcdef, ] ))))) | Where the -- 20c. boundary has been marked with |. Because renderPretty -- only uses one-line lookahead, it sees that the first line fits, and is -- stuck putting the second and third lines after the 20-c mark. In -- contrast, renderSmart will continue to check that the -- potential document up to the end of the indentation level. Thus, it -- will format the document as: -- --
--   fun(                |
--     fun(              |
--       fun(            |
--         fun(          |
--           fun([       |
--                 abcdef,
--                 abcdef,
--               ]       |
--     )))))             |
--   
-- -- Which fits within the 20c. boundary. renderSmart :: Float -> Int -> Doc -> SimpleDoc -- | This is the default pretty printer which is used by show, -- putDoc and hPutDoc. (renderPretty ribbonfrac width -- x) renders document x with a page width of -- width and a ribbon width of (ribbonfrac * width) -- characters. The ribbon width is the maximal amount of non-indentation -- characters on a line. The parameter ribbonfrac should be -- between 0.0 and 1.0. If it is lower or higher, the -- ribbon width will be 0 or width respectively. renderPretty :: Float -> Int -> Doc -> SimpleDoc -- | Removes all colorisation, emboldening and underlining from a document plain :: Doc -> Doc -- | Displays a document with no underlining deunderline :: Doc -> Doc -- | Displays a document with underlining underline :: Doc -> Doc -- | Displays a document in the normal font weight debold :: Doc -> Doc -- | Displays a document in a heavier font weight bold :: Doc -> Doc -- | Displays a document with the dull white backcolor ondullwhite :: Doc -> Doc -- | Displays a document with the white backcolor onwhite :: Doc -> Doc -- | Displays a document with the dull cyan backcolor ondullcyan :: Doc -> Doc -- | Displays a document with the cyan backcolor oncyan :: Doc -> Doc -- | Displays a document with the dull magenta backcolor ondullmagenta :: Doc -> Doc -- | Displays a document with the magenta backcolor onmagenta :: Doc -> Doc -- | Displays a document with the dull blue backcolor ondullblue :: Doc -> Doc -- | Displays a document with the blue backcolor onblue :: Doc -> Doc -- | Displays a document with the dull yellow backcolor ondullyellow :: Doc -> Doc -- | Displays a document with the yellow backcolor onyellow :: Doc -> Doc -- | Displays a document with the dull green backcolor ondullgreen :: Doc -> Doc -- | Displays a document with the green backcolor ongreen :: Doc -> Doc -- | Displays a document with the dull red backcolor ondullred :: Doc -> Doc -- | Displays a document with the red backcolor onred :: Doc -> Doc -- | Displays a document with the dull black backcolor ondullblack :: Doc -> Doc -- | Displays a document with the black backcolor onblack :: Doc -> Doc -- | Displays a document with the dull white forecolor dullwhite :: Doc -> Doc -- | Displays a document with the white forecolor white :: Doc -> Doc -- | Displays a document with the dull cyan forecolor dullcyan :: Doc -> Doc -- | Displays a document with the cyan forecolor cyan :: Doc -> Doc -- | Displays a document with the dull magenta forecolor dullmagenta :: Doc -> Doc -- | Displays a document with the magenta forecolor magenta :: Doc -> Doc -- | Displays a document with the dull blue forecolor dullblue :: Doc -> Doc -- | Displays a document with the blue forecolor blue :: Doc -> Doc -- | Displays a document with the dull yellow forecolor dullyellow :: Doc -> Doc -- | Displays a document with the yellow forecolor yellow :: Doc -> Doc -- | Displays a document with the dull green forecolor dullgreen :: Doc -> Doc -- | Displays a document with the green forecolor green :: Doc -> Doc -- | Displays a document with the dull red forecolor dullred :: Doc -> Doc -- | Displays a document with the red forecolor red :: Doc -> Doc -- | Displays a document with the dull black forecolor dullblack :: Doc -> Doc -- | Displays a document with the black forecolor black :: Doc -> Doc -- | A document that is normally rendered as the first argument, but when -- flattened, is rendered as the second document. flatAlt :: Doc -> Doc -> Doc columns :: Maybe Int -> Doc -> Doc nesting :: Int -> Doc -> Doc column :: Int -> Doc -> Doc -- | The document (nest i x) renders document x with the -- current indentation level increased by i (See also hang, -- align and indent). -- --
--   nest 2 (text "hello" <$> text "world") <$> text "!"
--   
-- -- outputs as: -- --
--   hello
--     world
--   !
--   
nest :: Int -> Doc -> Doc -- | A linebreak that will never be flattened; it is guaranteed to render -- as a newline. hardline :: Doc -- | The linebreak document advances to the next line and indents -- to the current nesting level. Document linebreak behaves like -- empty if the line break is undone by group. linebreak :: Doc -- | The line document advances to the next line and indents to -- the current nesting level. Document line behaves like -- (text " ") if the line break is undone by group. line :: Doc -- | The document (align x) renders document x with the -- nesting level set to the current column. It is used for example to -- implement hang. -- -- As an example, we will put a document right above another one, -- regardless of the current nesting level: -- --
--   x $$ y  = align (x <$> y)
--   
-- --
--   test    = text "hi" <+> (text "nice" $$ text "world")
--   
-- -- which will be layed out as: -- --
--   hi nice
--      world
--   
align :: Doc -> Doc -- | The hang combinator implements hanging indentation. The document -- (hang i x) renders document x with a nesting level -- set to the current column plus i. The following example uses -- hanging indentation for some text: -- --
--   test  = hang 4 (fillSep (map text
--           (words "the hang combinator indents these words !")))
--   
-- -- Which lays out on a page with a width of 20 characters as: -- --
--   the hang combinator
--       indents these
--       words !
--   
-- -- The hang combinator is implemented as: -- --
--   hang i x  = align (nest i x)
--   
hang :: Int -> Doc -> Doc -- | The document (indent i x) indents document x with -- i spaces. -- --
--   test  = indent 4 (fillSep (map text
--           (words "the indent combinator indents these words !")))
--   
-- -- Which lays out with a page width of 20 as: -- --
--   the indent
--   combinator
--   indents these
--   words !
--   
indent :: Int -> Doc -> Doc -- | The document (fill i x) renders document x. It than -- appends spaces until the width is equal to i. If the -- width of x is already larger, nothing is appended. This -- combinator is quite useful in practice to output a list of bindings. -- The following example demonstrates this. -- --
--   types  = [("empty","Doc")
--            ,("nest","Int -> Doc -> Doc")
--            ,("linebreak","Doc")]
--   
--   ptype (name,tp)
--          = fill 6 (text name) <+> text "::" <+> text tp
--   
--   test   = text "let" <+> align (vcat (map ptype types))
--   
-- -- Which is layed out as: -- --
--   let empty  :: Doc
--       nest   :: Int -> Doc -> Doc
--       linebreak :: Doc
--   
fill :: Int -> Doc -> Doc -- | The document (fillBreak i x) first renders document -- x. It than appends spaces until the width is equal -- to i. If the width of x is already larger than -- i, the nesting level is increased by i and a -- line is appended. When we redefine ptype in the -- previous example to use fillBreak, we get a useful variation -- of the previous output: -- --
--   ptype (name,tp)
--          = fillBreak 6 (text name) <+> text "::" <+> text tp
--   
-- -- The output will now be: -- --
--   let empty  :: Doc
--       nest   :: Int -> Doc -> Doc
--       linebreak
--              :: Doc
--   
fillBreak :: Int -> Doc -> Doc -- | The document equals contains an equal sign, "=". equals :: Doc -- | The document backslash contains a back slash, "\". backslash :: Doc -- | The document dot contains a single dot, ".". dot :: Doc -- | The document space contains a single space, " ". -- --
--   x <+> y   = x <> space <> y
--   
space :: Doc -- | The document comma contains a comma, ",". comma :: Doc -- | The document colon contains a colon, ":". colon :: Doc -- | The document semi contains a semicolon, ";". semi :: Doc -- | The document dquote contains a double quote, '"'. dquote :: Doc -- | The document squote contains a single quote, "'". squote :: Doc -- | The document rbracket contains a right square bracket, "]". rbracket :: Doc -- | The document lbracket contains a left square bracket, "[". lbracket :: Doc -- | The document rbrace contains a right brace, "}". rbrace :: Doc -- | The document lbrace contains a left brace, "{". lbrace :: Doc -- | The document rangle contains a right angle, ">". rangle :: Doc -- | The document langle contains a left angle, "<". langle :: Doc -- | The document rparen contains a right parenthesis, ")". rparen :: Doc -- | The document lparen contains a left parenthesis, "(". lparen :: Doc -- | The document (enclose l r x) encloses document x -- between documents l and r using (<>). -- --
--   enclose l r x   = l <> x <> r
--   
enclose :: Doc -> Doc -> Doc -> Doc -- | Document (brackets x) encloses document x in square -- brackets, "[" and "]". brackets :: Doc -> Doc -- | Document (angles x) encloses document x in angles, -- "<" and ">". angles :: Doc -> Doc -- | Document (parens x) encloses document x in -- parenthesis, "(" and ")". parens :: Doc -> Doc -- | Document (braces x) encloses document x in braces, -- "{" and "}". braces :: Doc -> Doc -- | Document (dquotes x) encloses document x with double -- quotes '"'. dquotes :: Doc -> Doc -- | Document (squotes x) encloses document x with single -- quotes "'". squotes :: Doc -> Doc -- | The document softbreak behaves like empty if the -- resulting output fits the page, otherwise it behaves like line. -- --
--   softbreak  = group linebreak
--   
softbreak :: Doc -- | The document softline behaves like space if the -- resulting output fits the page, otherwise it behaves like line. -- --
--   softline = group line
--   
softline :: Doc -- | The document (x <$$> y) concatenates document -- x and y with a linebreak in between. -- (infixr 5) (<$$>) :: Doc -> Doc -> Doc infixr 5 <$$> -- | The document (x <//> y) concatenates document -- x and y with a softbreak in between. This -- effectively puts x and y either right next to each -- other or underneath each other. (infixr 5) () :: Doc -> Doc -> Doc infixr 5 -- | The document (x <+> y) concatenates document x -- and y with a space in between. (infixr 6) (<+>) :: Doc -> Doc -> Doc infixr 6 <+> -- | The document (vcat xs) concatenates all documents xs -- vertically with (<$$>). If a group undoes the -- line breaks inserted by vcat, all documents are directly -- concatenated. vcat :: [Doc] -> Doc -- | The document (hcat xs) concatenates all documents xs -- horizontally with (<>). hcat :: [Doc] -> Doc -- | The document (fillCat xs) concatenates documents xs -- horizontally with (<>) as long as its fits the page, -- than inserts a linebreak and continues doing that for all -- documents in xs. -- --
--   fillCat xs  = foldr (<//>) empty xs
--   
fillCat :: [Doc] -> Doc -- | The document (vsep xs) concatenates all documents xs -- vertically with (<$>). If a group undoes the -- line breaks inserted by vsep, all documents are separated -- with a space. -- --
--   someText = map text (words ("text to lay out"))
--   
--   test     = text "some" <+> vsep someText
--   
-- -- This is layed out as: -- --
--   some text
--   to
--   lay
--   out
--   
-- -- The align combinator can be used to align the documents under -- their first element -- --
--   test     = text "some" <+> align (vsep someText)
--   
-- -- Which is printed as: -- --
--   some text
--        to
--        lay
--        out
--   
vsep :: [Doc] -> Doc -- | The document (hsep xs) concatenates all documents xs -- horizontally with (<+>). hsep :: [Doc] -> Doc -- | The document (fillSep xs) concatenates documents xs -- horizontally with (<+>) as long as its fits the page, -- than inserts a line and continues doing that for all -- documents in xs. -- --
--   fillSep xs  = foldr (</>) empty xs
--   
fillSep :: [Doc] -> Doc -- | The document (sep xs) concatenates all documents xs -- either horizontally with (<+>), if it fits the page, or -- vertically with (<$>). -- --
--   sep xs  = group (vsep xs)
--   
sep :: [Doc] -> Doc -- | (punctuate p xs) concatenates all documents in xs -- with document p except for the last document. -- --
--   someText = map text ["words","in","a","tuple"]
--   test     = parens (align (cat (punctuate comma someText)))
--   
-- -- This is layed out on a page width of 20 as: -- --
--   (words,in,a,tuple)
--   
-- -- But when the page width is 15, it is layed out as: -- --
--   (words,
--    in,
--    a,
--    tuple)
--   
-- -- (If you want put the commas in front of their elements instead of at -- the end, you should use tupled or, in general, -- encloseSep.) punctuate :: Doc -> [Doc] -> [Doc] -- | The document (encloseSep l r sep xs) concatenates the -- documents xs separated by sep and encloses the -- resulting document by l and r. The documents are -- rendered horizontally if that fits the page. Otherwise they are -- aligned vertically. All separators are put in front of the elements. -- For example, the combinator list can be defined with -- encloseSep: -- --
--   list xs = encloseSep lbracket rbracket comma xs
--   test    = text "list" <+> (list (map int [10,200,3000]))
--   
-- -- Which is layed out with a page width of 20 as: -- --
--   list [10,200,3000]
--   
-- -- But when the page width is 15, it is layed out as: -- --
--   list [10
--        ,200
--        ,3000]
--   
encloseSep :: Doc -> Doc -> Doc -> [Doc] -> Doc -- | The document (semiBraces xs) separates the documents -- xs with semicolons and encloses them in braces. The documents -- are rendered horizontally if that fits the page. Otherwise they are -- aligned vertically. All semicolons are put in front of the elements. semiBraces :: [Doc] -> Doc -- | The document (tupled xs) comma separates the documents -- xs and encloses them in parenthesis. The documents are -- rendered horizontally if that fits the page. Otherwise they are -- aligned vertically. All comma separators are put in front of the -- elements. tupled :: [Doc] -> Doc -- | The document (list xs) comma separates the documents -- xs and encloses them in square brackets. The documents are -- rendered horizontally if that fits the page. Otherwise they are -- aligned vertically. All comma separators are put in front of the -- elements. list :: [Doc] -> Doc -- | The member prettyList is only used to define the instance -- Pretty a => Pretty [a]. In normal circumstances only the -- pretty function is used. class Pretty a pretty :: Pretty a => a -> Doc prettyList :: Pretty a => [a] -> Doc -- | The abstract data type Doc represents pretty documents. -- -- More specifically, a value of type Doc represents a non-empty -- set of possible renderings of a document. The rendering functions -- select one of these possibilities. -- -- Doc is an instance of the Show class. (show -- doc) pretty prints document doc with a page width of 80 -- characters and a ribbon width of 32 characters. -- --
--   show (text "hello" <$> text "world")
--   
-- -- Which would return the string "hello\nworld", i.e. -- --
--   hello
--   world
--   
data Doc -- | The data type SimpleDoc represents rendered documents and is -- used by the display functions. -- -- Whereas values of the data type Doc represent non-empty sets of -- possible renderings of a document, values of the data type -- SimpleDoc represent single renderings of a document. -- -- The Int in SText contains the length of the string. -- The Int in SLine contains the indentation for that -- line. The library provides two default display functions -- displayS and displayIO. You can provide your own display -- function by writing a function from a SimpleDoc to your own -- output format. data SimpleDoc SFail :: SimpleDoc SEmpty :: SimpleDoc SChar :: Char -> SimpleDoc -> SimpleDoc SText :: !Int -> String -> SimpleDoc -> SimpleDoc SLine :: !Int -> SimpleDoc -> SimpleDoc SSGR :: [SGR] -> SimpleDoc -> SimpleDoc newtype PrettyError PrettyError :: Doc -> PrettyError [getError] :: PrettyError -> Doc -- | pretty print multiple lines of text. pplines :: Text -> Doc -- | pretty print a single line of text. ppline :: Text -> Doc -- | pretty print multiple lines of string. ppstring :: String -> Doc -- | pretty print one line of string pptext :: String -> Doc -- | General puppet language specification. -- -- This module doesn't depend on any other project modules (except for -- XPrelude). It serves as a common bridge that can be used in -- PuppetDB or Facter as well as in -- Puppet.Interpreter or Puppet.Parser. module Puppet.Language showPos :: Position -> Doc -- | showing the first position of a position interval. showPPos :: PPosition -> Doc -- | showing the first position of a position interval as string. showPPos' :: PPosition -> String -- | Generates an initial position interval based on a filename. initialPPos :: FilePath -> PPosition -- | A pair containing the start and end of a given token. type PPosition = Pair Position Position -- | Position in a puppet file. Currently an alias to SourcePos. type Position = SourcePos type NodeName = Text type Scope = Text data CompRegex CompRegex :: !Text -> !Regex -> CompRegex -- | Extremely hacky escaping system for text values. stringEscape :: Text -> Text -- | Capitalize resource type and convert into a Doc. capitalizeR :: Text -> Doc -- | Properly capitalizes resource types. capitalizeRT :: Text -> Text containerComma'' :: Pretty a => [(Doc, a)] -> Doc containerComma' :: Pretty a => [(Doc, a)] -> Doc containerComma :: Pretty a => Container a -> Doc _sourceName :: Lens' Position String _sourceLine :: Lens' Position Pos _sourceColumn :: Lens' Position Pos -- | Generates a PPosition based on a filename and line number. toPPos :: Text -> Int -> PPosition -- | The map of native types. baseNativeTypes :: Container NativeTypeMethods defaulttype :: NativeTypeName -> (NativeTypeName, NativeTypeMethods) -- | Attributes (and providers) of a puppet resource type bundled with -- validation rules data NativeTypeMethods type NativeTypeName = Text class HasNativeTypeMethods c_aWZW nativeTypeMethods :: HasNativeTypeMethods c_aWZW => Lens' c_aWZW NativeTypeMethods puppetFields :: HasNativeTypeMethods c_aWZW => Lens' c_aWZW (HashSet Text) puppetValidate :: HasNativeTypeMethods c_aWZW => Lens' c_aWZW NativeTypeValidate data PuppetDirPaths PuppetDirPaths :: FilePath -> FilePath -> FilePath -> FilePath -> FilePath -> PuppetDirPaths -- | Puppet base working directory [_baseDir] :: PuppetDirPaths -> FilePath -- | The path to the manifests. [_manifestPath] :: PuppetDirPaths -> FilePath -- | The path to the modules. [_modulesPath] :: PuppetDirPaths -> FilePath -- | The path to the template. [_templatesPath] :: PuppetDirPaths -> FilePath -- | The path to a tests folders to hold tests files such as the pdbfiles. [_testPath] :: PuppetDirPaths -> FilePath class HasPuppetDirPaths c_auLv puppetDirPaths :: HasPuppetDirPaths c_auLv => Lens' c_auLv PuppetDirPaths baseDir :: HasPuppetDirPaths c_auLv => Lens' c_auLv FilePath manifestPath :: HasPuppetDirPaths c_auLv => Lens' c_auLv FilePath modulesPath :: HasPuppetDirPaths c_auLv => Lens' c_auLv FilePath templatesPath :: HasPuppetDirPaths c_auLv => Lens' c_auLv FilePath testPath :: HasPuppetDirPaths c_auLv => Lens' c_auLv FilePath puppetPaths :: FilePath -> PuppetDirPaths -- | A fully resolved puppet resource that will be used in the -- FinalCatalog. data Resource Resource :: !RIdentifier -> !(HashSet Text) -> !(Container PValue) -> !(HashMap RIdentifier (HashSet LinkType)) -> ![CurContainerDesc] -> !Virtuality -> !(HashSet Text) -> !PPosition -> !NodeName -> Resource -- | Resource name. [_rid] :: Resource -> !RIdentifier -- | All the resource aliases [_ralias] :: Resource -> !(HashSet Text) -- | Resource parameters. [_rattributes] :: Resource -> !(Container PValue) -- | Resource relations. [_rrelations] :: Resource -> !(HashMap RIdentifier (HashSet LinkType)) -- | Resource scope when it was defined, the real container will be the -- first item [_rscope] :: Resource -> ![CurContainerDesc] -- | Virtuality. [_rvirtuality] :: Resource -> !Virtuality -- | Tags. [_rtags] :: Resource -> !(HashSet Text) -- | Source code position of the resource definition. [_rpos] :: Resource -> !PPosition -- | The node were this resource was created, if remote [_rnode] :: Resource -> !NodeName class HasResource c_aLWa resource :: HasResource c_aLWa => Lens' c_aLWa Resource ralias :: HasResource c_aLWa => Lens' c_aLWa (HashSet Text) rattributes :: HasResource c_aLWa => Lens' c_aLWa (Container PValue) rid :: HasResource c_aLWa => Lens' c_aLWa RIdentifier rnode :: HasResource c_aLWa => Lens' c_aLWa NodeName rpos :: HasResource c_aLWa => Lens' c_aLWa PPosition rrelations :: HasResource c_aLWa => Lens' c_aLWa (HashMap RIdentifier (HashSet LinkType)) rscope :: HasResource c_aLWa => Lens' c_aLWa [CurContainerDesc] rtags :: HasResource c_aLWa => Lens' c_aLWa (HashSet Text) rvirtuality :: HasResource c_aLWa => Lens' c_aLWa Virtuality -- | In Puppet, a resource is identified by a name and a type. data RIdentifier RIdentifier :: !Text -> !Text -> RIdentifier [_itype] :: RIdentifier -> !Text [_iname] :: RIdentifier -> !Text class HasRIdentifier c_aM6t rIdentifier :: HasRIdentifier c_aM6t => Lens' c_aM6t RIdentifier iname :: HasRIdentifier c_aM6t => Lens' c_aM6t Text itype :: HasRIdentifier c_aM6t => Lens' c_aM6t Text -- | Relationship/ordering information between two resources (used in the -- EdgeMap). data LinkInformation LinkInformation :: !RIdentifier -> !RIdentifier -> !LinkType -> !PPosition -> LinkInformation [_linksrc] :: LinkInformation -> !RIdentifier [_linkdst] :: LinkInformation -> !RIdentifier [_linkType] :: LinkInformation -> !LinkType [_linkPos] :: LinkInformation -> !PPosition class HasLinkInformation c_aMMO linkInformation :: HasLinkInformation c_aMMO => Lens' c_aMMO LinkInformation linkPos :: HasLinkInformation c_aMMO => Lens' c_aMMO PPosition linkType :: HasLinkInformation c_aMMO => Lens' c_aMMO LinkType linkdst :: HasLinkInformation c_aMMO => Lens' c_aMMO RIdentifier linksrc :: HasLinkInformation c_aMMO => Lens' c_aMMO RIdentifier -- | Relationship/ordering between resources. data LinkType -- | Applies a resource after the target resource. RRequire :: LinkType -- | Applies a resource before the target resource. RBefore :: LinkType -- | Applies a resource before the target resource. The target resource -- refreshes if the notifying resource changes. RNotify :: LinkType -- | Applies a resource after the target resource. The subscribing resource -- refreshes if the target resource changes. RSubscribe :: LinkType data Virtuality -- | Normal resource, that will be included in the catalog. Normal :: Virtuality -- | Type for virtual resources. Virtual :: Virtuality -- | Type for exported resources. Exported :: Virtuality -- | These are resources that are exported AND realized in the catalog. ExportedRealized :: Virtuality data CurContainerDesc -- | Contained at node or root level. ContRoot :: CurContainerDesc -- | Contained in a class. ContClass :: !Text -> CurContainerDesc -- | Contained in a define, along with the position where this define was -- ... defined ContDefine :: !Text -> !Text -> !PPosition -> CurContainerDesc -- | Dummy container for imported resources, so that we know we must update -- the nodename ContImported :: !CurContainerDesc -> CurContainerDesc -- | This one is used when finalizing imported resources, and contains the -- current node name ContImport :: !NodeName -> !CurContainerDesc -> CurContainerDesc type FinalCatalog = HashMap RIdentifier Resource type EdgeMap = HashMap RIdentifier [LinkInformation] data DataType DTType :: DataType DTString :: (Maybe Int) -> (Maybe Int) -> DataType DTInteger :: (Maybe Int) -> (Maybe Int) -> DataType DTFloat :: (Maybe Double) -> (Maybe Double) -> DataType DTBoolean :: DataType DTArray :: DataType -> Int -> (Maybe Int) -> DataType DTHash :: DataType -> DataType -> Int -> (Maybe Int) -> DataType DTUndef :: DataType DTScalar :: DataType DTData :: DataType DTOptional :: DataType -> DataType NotUndef :: DataType DTVariant :: (NonEmpty DataType) -> DataType DTPattern :: (NonEmpty CompRegex) -> DataType DTEnum :: (NonEmpty Text) -> DataType DTAny :: DataType DTCollection :: DataType DTRegexp :: (Maybe CompRegex) -> DataType -- | A puppet value. data PValue PBoolean :: !Bool -> PValue PUndef :: PValue PString :: !Text -> PValue PResourceReference :: !Text -> !Text -> PValue PArray :: !(Vector PValue) -> PValue PHash :: !(Container PValue) -> PValue PNumber :: !Scientific -> PValue PType :: !DataType -> PValue PRegexp :: !CompRegex -> PValue _PRegexp :: Prism' PValue CompRegex _PType :: Prism' PValue DataType _PNumber :: Prism' PValue Scientific _PHash :: Prism' PValue (Container PValue) _PArray :: Prism' PValue (Vector PValue) _PResourceReference :: Prism' PValue (Text, Text) _PString :: Prism' PValue Text _PUndef :: Prism' PValue () _PBoolean :: Prism' PValue Bool -- | Used to represent a relationship between two resources within the -- wired format (json). -- -- See -- http://docs.puppetlabs.com/puppetdb/2.3/api/wire_format/catalog_format_v5.html#data-type-edge data PuppetEdge PuppetEdge :: RIdentifier -> RIdentifier -> LinkType -> PuppetEdge -- | See puppet reference. data WireCatalog WireCatalog :: !NodeName -> !Text -> !(Vector PuppetEdge) -> !(Vector Resource) -> !Text -> WireCatalog [_wireCatalogNodename] :: WireCatalog -> !NodeName [_wireCatalogVersion] :: WireCatalog -> !Text [_wireCatalogEdges] :: WireCatalog -> !(Vector PuppetEdge) [_wireCatalogResources] :: WireCatalog -> !(Vector Resource) [_wireCatalogTransactionUUID] :: WireCatalog -> !Text class HasWireCatalog c_aVb9 wireCatalog :: HasWireCatalog c_aVb9 => Lens' c_aVb9 WireCatalog wireCatalogEdges :: HasWireCatalog c_aVb9 => Lens' c_aVb9 (Vector PuppetEdge) wireCatalogNodename :: HasWireCatalog c_aVb9 => Lens' c_aVb9 NodeName wireCatalogResources :: HasWireCatalog c_aVb9 => Lens' c_aVb9 (Vector Resource) wireCatalogTransactionUUID :: HasWireCatalog c_aVb9 => Lens' c_aVb9 Text wireCatalogVersion :: HasWireCatalog c_aVb9 => Lens' c_aVb9 Text module Puppet.Parser.Internal -- | Space consumer sc :: Parser () -- | Lexeme consumes spaces after the input parser lexeme :: Parser a -> Parser a -- | Consumes a text then consumes spaces symbol :: Text -> Parser () -- | Consumes a character then consumes spaces symbolic :: Char -> Parser () braces :: Parser a -> Parser a parens :: Parser a -> Parser a brackets :: Parser a -> Parser a comma :: Parser () sepComma :: Parser a -> Parser [a] sepComma1 :: Parser a -> Parser [a] -- | Parses an Expression. expression :: Parser Expression stringLiteral' :: Parser Text identifier :: Parser (Tokens Text) -- | Only Ascii, hyphens (-) are not allowed. isIdentifierChar :: Char -> Bool -- | Like isIndentifierChar but hyphens (-) are allowed. isBarewordChar :: Char -> Bool reserved :: Text -> Parser () qualif :: Parser Text -> Parser Text qualif1 :: Parser Text -> Parser Text -- | Consumes a var $foo and then spaces variableReference :: Parser Text variableName :: Parser Text className :: Parser Text funcName :: Parser Text typeName :: Parser Text moduleName :: Parser Text resourceNameRef :: Parser Text genericModuleName :: Bool -> Parser Text parameterName :: Parser Text -- | Variable expression varExpression :: Parser Expression -- | String interpolation interpolableString :: Parser (Vector Expression) integerOrDouble :: Parser (Either Integer Double) puppetArray :: Parser UnresolvedValue puppetHash :: Parser UnresolvedValue puppetBool :: Parser Bool resourceReferenceRaw :: Parser (Text, [Expression]) resourceReference :: Parser UnresolvedValue -- | Functions that have named that are not valid ... specialFunctions :: Parser Text genFunctionCall :: Bool -> Parser (Text, Vector Expression) literalValue :: Parser UnresolvedValue data TerminalMode FunctionWithoutParens :: TerminalMode StandardMode :: TerminalMode terminalG :: TerminalMode -> Parser Expression regexp :: Parser Text compileRegexp :: Text -> Parser CompRegex termRegexp :: Parser CompRegex terminal :: Parser Expression expressionTable :: [[Operator Parser Expression]] -- | Postfix of a chain of lookup indexes such as -- "[release][major]" indexLookupChain :: Parser (Expression -> Expression) stringExpression :: Parser Expression -- | a = b = 0 chainedVariableReferences :: Parser [Text] varAssign :: Parser VarAssignDecl nodeDecl :: Parser [NodeDecl] defineDecl :: Parser DefineDecl puppetClassParameters :: Parser Parameters puppetIfStyleCondition :: Parser (Pair Expression (Vector Statement)) unlessCondition :: Parser ConditionalDecl ifCondition :: Parser ConditionalDecl caseCondition :: Parser ConditionalDecl data OperatorChain a OperatorChain :: a -> LinkType -> (OperatorChain a) -> OperatorChain a EndOfChain :: a -> OperatorChain a operatorChainStatement :: OperatorChain a -> a zipChain :: OperatorChain a -> [(a, a, LinkType)] depOperator :: Parser LinkType assignment :: Parser AttributeDecl -- | Resource Collector resCollDecl :: Position -> Text -> Parser ResCollDecl classDecl :: Parser ClassDecl mainFuncDecl :: Parser MainFuncDecl hoLambdaDecl :: Parser HigherOrderLambdaDecl dotLambdaDecl :: Parser HigherOrderLambdaDecl resDefaultDecl :: Parser ResDefaultDecl resOverrideDecl :: Parser [ResOverrideDecl] -- | Heterogeneous chain (interleaving resource declarations with resource -- references) needs to be supported: -- -- class { 'docker::service': } -> Class[docker] chainableResources :: Parser [Statement] statement :: Parser [Statement] datatype :: Parser UDataType statementList :: Parser (Vector Statement) lambdaCall :: Parser HOLambdaCall instance Data.Foldable.Foldable Puppet.Parser.Internal.OperatorChain module Facter type Facts = HashMap Text PValue data FactInfo FactInfo :: !NodeName -> !Text -> !PValue -> FactInfo [_factInfoNodename] :: FactInfo -> !NodeName [_factInfoName] :: FactInfo -> !Text [_factInfoVal] :: FactInfo -> !PValue class HasFactInfo c_a1Rm5 factInfo :: HasFactInfo c_a1Rm5 => Lens' c_a1Rm5 FactInfo factInfoName :: HasFactInfo c_a1Rm5 => Lens' c_a1Rm5 Text factInfoNodename :: HasFactInfo c_a1Rm5 => Lens' c_a1Rm5 NodeName factInfoVal :: HasFactInfo c_a1Rm5 => Lens' c_a1Rm5 PValue storageunits :: [(String, Int)] getPrefix :: Int -> String getOrder :: String -> Int normalizeUnit :: (Double, Int) -> Double -> (Double, Int) storagedesc :: (String, String) -> String factRAM :: IO [(String, String)] factNET :: IO [(String, String)] factOS :: IO [(String, String)] factOSDebian :: IO [(String, String)] factOSLSB :: IO [(String, String)] factMountPoints :: IO [(String, String)] fversion :: IO [(String, String)] factUser :: IO [(String, String)] factUName :: IO [(String, String)] fenv :: IO [(String, String)] factProcessor :: IO [(String, String)] instance Facter.HasFactInfo Facter.FactInfo instance Data.Aeson.Types.ToJSON.ToJSON Facter.FactInfo instance Data.Aeson.Types.FromJSON.FromJSON Facter.FactInfo -- | Common data types for PuppetDB. module PuppetDB -- | A dummy implementation of PuppetDBAPI, that will return empty -- responses. dummyPuppetDB :: Monad m => PuppetDBAPI m -- | Given a PDBType, will try return a sane default implementation. getDefaultDB :: PDBType -> IO (Either PrettyError (PuppetDBAPI IO)) -- | Given an URL (ie. http://localhost:8080), will return -- an incomplete PuppetDBAPI. pdbConnect :: Manager -> String -> IO (Either PrettyError (PuppetDBAPI IO)) -- | Initializes the test DB using a file to back its content loadTestDB :: FilePath -> IO (Either PrettyError (PuppetDBAPI IO)) -- | Turns a FinalCatalog and EdgeMap into a document that -- can be serialized and fed to puppet apply. generateWireCatalog :: NodeName -> FinalCatalog -> EdgeMap -> WireCatalog puppetDBFacts :: NodeName -> PuppetDBAPI IO -> IO (HashMap Text PValue) -- | The supported PuppetDB implementations. data PDBType -- | Your standard PuppetDB, queried through the HTTP interface. PDBRemote :: PDBType -- | A stupid stub, this is the default choice. PDBDummy :: PDBType -- | A slow but handy PuppetDB implementation that is backed by a YAML -- file. PDBTest :: PDBType data NodeInfo NodeInfo :: !NodeName -> !Bool -> !(Maybe UTCTime) -> !(Maybe UTCTime) -> !(Maybe UTCTime) -> NodeInfo [_nodeInfoName] :: NodeInfo -> !NodeName [_nodeInfoDeactivated] :: NodeInfo -> !Bool [_nodeInfoCatalogT] :: NodeInfo -> !(Maybe UTCTime) [_nodeInfoFactsT] :: NodeInfo -> !(Maybe UTCTime) [_nodeInfoReportT] :: NodeInfo -> !(Maybe UTCTime) class HasNodeInfo c_a1VoD nodeInfo :: HasNodeInfo c_a1VoD => Lens' c_a1VoD NodeInfo nodeInfoCatalogT :: HasNodeInfo c_a1VoD => Lens' c_a1VoD (Maybe UTCTime) nodeInfoDeactivated :: HasNodeInfo c_a1VoD => Lens' c_a1VoD Bool nodeInfoFactsT :: HasNodeInfo c_a1VoD => Lens' c_a1VoD (Maybe UTCTime) nodeInfoName :: HasNodeInfo c_a1VoD => Lens' c_a1VoD NodeName nodeInfoReportT :: HasNodeInfo c_a1VoD => Lens' c_a1VoD (Maybe UTCTime) -- | Pretty straightforward way to define the various PuppetDB queries data Query a QEqual :: a -> Text -> Query a QG :: a -> Integer -> Query a QL :: a -> Integer -> Query a QGE :: a -> Integer -> Query a QLE :: a -> Integer -> Query a QMatch :: Text -> Text -> Query a QAnd :: [Query a] -> Query a QOr :: [Query a] -> Query a QNot :: (Query a) -> Query a QEmpty :: Query a -- | Fields for the fact endpoint data FactField FName :: FactField FValue :: FactField FCertname :: FactField -- | Fields for the node endpoint data NodeField NName :: NodeField NFact :: Text -> NodeField -- | Fields for the resource endpoint data ResourceField RTag :: ResourceField RCertname :: ResourceField RParameter :: Text -> ResourceField RType :: ResourceField RTitle :: ResourceField RExported :: ResourceField RFile :: ResourceField RLine :: ResourceField data PuppetDBAPI m PuppetDBAPI :: m Doc -> WireCatalog -> ExceptT PrettyError m () -> [(NodeName, Facts)] -> ExceptT PrettyError m () -> NodeName -> ExceptT PrettyError m () -> Query FactField -> ExceptT PrettyError m [FactInfo] -> Query ResourceField -> ExceptT PrettyError m [Resource] -> Query NodeField -> ExceptT PrettyError m [NodeInfo] -> ExceptT PrettyError m () -> NodeName -> Query ResourceField -> ExceptT PrettyError m [Resource] -> PuppetDBAPI m [pdbInformation] :: PuppetDBAPI m -> m Doc -- | -- http://docs.puppetlabs.com/puppetdb/1.5/api/commands.html#replace-catalog-version-3 [replaceCatalog] :: PuppetDBAPI m -> WireCatalog -> ExceptT PrettyError m () -- | -- http://docs.puppetlabs.com/puppetdb/1.5/api/commands.html#replace-facts-version-1 [replaceFacts] :: PuppetDBAPI m -> [(NodeName, Facts)] -> ExceptT PrettyError m () -- | -- http://docs.puppetlabs.com/puppetdb/1.5/api/commands.html#deactivate-node-version-1 [deactivateNode] :: PuppetDBAPI m -> NodeName -> ExceptT PrettyError m () -- | -- http://docs.puppetlabs.com/puppetdb/1.5/api/query/v3/facts.html#get-v3facts [getPDBFacts] :: PuppetDBAPI m -> Query FactField -> ExceptT PrettyError m [FactInfo] -- | -- http://docs.puppetlabs.com/puppetdb/1.5/api/query/v3/resources.html#get-v3resources [getResources] :: PuppetDBAPI m -> Query ResourceField -> ExceptT PrettyError m [Resource] [getNodes] :: PuppetDBAPI m -> Query NodeField -> ExceptT PrettyError m [NodeInfo] -- | This is only here to tell the test PuppetDB to save its content to -- disk. [commitDB] :: PuppetDBAPI m -> ExceptT PrettyError m () [getResourcesOfNode] :: PuppetDBAPI m -> NodeName -> Query ResourceField -> ExceptT PrettyError m [Resource] -- | This module runs a Hiera server that caches Hiera data. There is a -- huge caveat : only the data files are watched for changes, not the -- main configuration file. -- -- A minor bug is that interpolation will not work for inputs containing -- the % character when it isn't used for interpolation. module Hiera.Server -- | The only method you'll ever need. It runs a Hiera server and gives you -- a querying function. | All IO exceptions are thrown directly including -- ParsingException. startHiera :: String -> FilePath -> IO (HieraQueryFunc IO) -- | A dummy hiera function that will be used when hiera is not detected. dummyHiera :: Monad m => HieraQueryFunc m -- | The different kind of hiera queries. data HieraQueryType -- | The first match in the hierarchy is returned. QFirst :: HieraQueryType -- | Combines array and scalar values to return a merged, flattened array -- with all duplicate removed. QUnique :: HieraQueryType -- | Combines the keys and values of any number of hashes to return a -- merged hash. | Use of an Hash to specify the merge behavior QHash :: HieraQueryType QDeep :: Maybe Text -> Bool -> Bool -> HieraQueryType [_knockoutPrefix] :: HieraQueryType -> Maybe Text [_sortMerged] :: HieraQueryType -> Bool [_mergeHashArray] :: HieraQueryType -> Bool readQueryType :: Text -> Maybe HieraQueryType -- | The type of the Hiera API function associated to given hierarchy. type HieraQueryFunc m = Container Text Scope: all variables that Hiera can interpolate (the top level ones are prefixed with '::') -> Text The query -> HieraQueryType -> m (Either PrettyError (Maybe PValue)) instance Data.Aeson.Types.FromJSON.FromJSON Hiera.Server.HieraConfigFile instance GHC.Show.Show Hiera.Server.HieraConfigFile instance GHC.Show.Show Hiera.Server.InterpolableHieraString instance GHC.Show.Show Hiera.Server.HieraStringPart instance GHC.Show.Show Hiera.Server.Backend instance GHC.Show.Show Hiera.Server.HieraQueryType instance Data.Aeson.Types.FromJSON.FromJSON Hiera.Server.InterpolableHieraString instance Text.PrettyPrint.ANSI.Leijen.Internal.Pretty Hiera.Server.HieraStringPart -- | Entry point to general Erb service This module share no dependency -- with Puppet modules module Erb data Value Literal :: !Text -> Value Interpolable :: ![Expression] -> Value Symbol :: !Text -> Value Array :: ![Expression] -> Value data Expression LookupOperation :: !Expression -> !Expression -> Expression PlusOperation :: !Expression -> !Expression -> Expression MinusOperation :: !Expression -> !Expression -> Expression DivOperation :: !Expression -> !Expression -> Expression MultiplyOperation :: !Expression -> !Expression -> Expression ShiftLeftOperation :: !Expression -> !Expression -> Expression ShiftRightOperation :: !Expression -> !Expression -> Expression AndOperation :: !Expression -> !Expression -> Expression OrOperation :: !Expression -> !Expression -> Expression EqualOperation :: !Expression -> !Expression -> Expression DifferentOperation :: !Expression -> !Expression -> Expression AboveOperation :: !Expression -> !Expression -> Expression AboveEqualOperation :: !Expression -> !Expression -> Expression UnderEqualOperation :: !Expression -> !Expression -> Expression UnderOperation :: !Expression -> !Expression -> Expression RegexpOperation :: !Expression -> !Expression -> Expression NotRegexpOperation :: !Expression -> !Expression -> Expression NotOperation :: !Expression -> Expression NegOperation :: !Expression -> Expression ConditionalValue :: !Expression -> !Expression -> Expression Object :: !Expression -> Expression ScopeObject :: !Expression -> Expression MethodCall :: !Expression -> !Expression -> Expression BlockOperation :: !Text -> Expression Value :: !Value -> Expression BTrue :: Expression BFalse :: Expression Error :: !String -> Expression data RubyStatement Puts :: !Expression -> RubyStatement DropPrevSpace :: !RubyStatement -> RubyStatement DropPrevSpace' :: RubyStatement DropNextSpace :: !RubyStatement -> RubyStatement def :: GenLanguageDef String u Identity lexer :: GenTokenParser String u Identity parens :: Parser a -> Parser a braces :: Parser a -> Parser a operator :: Parser String symbol :: String -> Parser String reservedOp :: String -> Parser () whiteSpace :: Parser () naturalOrFloat :: Parser (Either Integer Double) identifier :: Parser String rubyexpression :: Parser Expression table :: [[Operator String () Identity Expression]] term :: Parser Expression scopeLookup :: Parser Expression stringLiteral :: Parser Expression doubleQuoted :: Parser Value singleQuoted :: Parser Value objectterm :: Parser Expression variablereference :: Parser Expression rubystatement :: Parser RubyStatement textblockW :: Maybe Char -> Parser [RubyStatement] textblock :: Parser [RubyStatement] rubyblock :: Parser [RubyStatement] erbparser :: Parser [RubyStatement] parseErbFile :: FilePath -> IO (Either ParseError [RubyStatement]) parseErbString :: String -> Either ParseError [RubyStatement] -- | Parse puppet source code from text. module Puppet.Parser -- | Run a puppet parser against some Text input. runPuppetParser :: String -> Text -> Either (ParseErrorBundle Text Void) (Vector Statement) -- | Parse a collection of puppet Statement. puppetParser :: Parser (Vector Statement) -- | Build a PrettyError from a ParseError given the text -- source. The source is used to display the line on which the error -- occurs. prettyParseError :: ParseErrorBundle Text Void -> PrettyError -- | Pretty print a series of statements. ppStatements :: Vector Statement -> Doc -- | The Expressions data Expression Equal :: !Expression -> !Expression -> Expression Different :: !Expression -> !Expression -> Expression Not :: !Expression -> Expression And :: !Expression -> !Expression -> Expression Or :: !Expression -> !Expression -> Expression LessThan :: !Expression -> !Expression -> Expression MoreThan :: !Expression -> !Expression -> Expression LessEqualThan :: !Expression -> !Expression -> Expression MoreEqualThan :: !Expression -> !Expression -> Expression RegexMatch :: !Expression -> !Expression -> Expression NotRegexMatch :: !Expression -> !Expression -> Expression Contains :: !Expression -> !Expression -> Expression Addition :: !Expression -> !Expression -> Expression Substraction :: !Expression -> !Expression -> Expression Division :: !Expression -> !Expression -> Expression Multiplication :: !Expression -> !Expression -> Expression Modulo :: !Expression -> !Expression -> Expression RightShift :: !Expression -> !Expression -> Expression LeftShift :: !Expression -> !Expression -> Expression -- | Hash lookup $var['key0']['key1'] Lookup :: !Expression -> !Expression -> Expression Negate :: !Expression -> Expression -- | All conditionals are stored in this format. ConditionalValue :: !Expression -> !(Vector (Pair SelectorCase Expression)) -> Expression -- | This is for higher order functions. FunctionApplication :: !Expression -> !Expression -> Expression -- | Terminal object contains no expression Terminal :: !UnresolvedValue -> Expression data SelectorCase SelectorValue :: !UnresolvedValue -> SelectorCase SelectorType :: !UDataType -> SelectorCase SelectorDefault :: SelectorCase -- | An unresolved value, typically the parser's output. data UnresolvedValue -- | Special tokens generated when parsing the true or -- false literals. UBoolean :: !Bool -> UnresolvedValue -- | Raw string. UString :: !Text -> UnresolvedValue -- | A string that might contain variable references. The type should be -- refined at one point. UInterpolable :: !(Vector Expression) -> UnresolvedValue -- | Special token that is generated when parsing the undef -- literal. UUndef :: UnresolvedValue -- | Alike Resource[reference] UResourceReference :: !Text -> !Expression -> UnresolvedValue UArray :: !(Vector Expression) -> UnresolvedValue UHash :: !(Vector (Pair Expression Expression)) -> UnresolvedValue -- | The regular expression compilation is performed during parsing. URegexp :: !CompRegex -> UnresolvedValue UVariableReference :: !Text -> UnresolvedValue UFunctionCall :: !Text -> !(Vector Expression) -> UnresolvedValue UHOLambdaCall :: !HOLambdaCall -> UnresolvedValue UNumber :: !Scientific -> UnresolvedValue UDataType :: UDataType -> UnresolvedValue -- | High Order lambdas. newtype LambdaFunc LambdaFunc :: Text -> LambdaFunc data HOLambdaCall HOLambdaCall :: !LambdaFunc -> !(Vector Expression) -> !LambdaParameters -> !(Vector Statement) -> !(Maybe Expression) -> HOLambdaCall [_hoLambdaFunc] :: HOLambdaCall -> !LambdaFunc [_hoLambdaExpr] :: HOLambdaCall -> !(Vector Expression) [_hoLambdaParams] :: HOLambdaCall -> !LambdaParameters [_hoLambdaStatements] :: HOLambdaCall -> !(Vector Statement) [_hoLambdaLastExpr] :: HOLambdaCall -> !(Maybe Expression) data ChainableRes ChainResColl :: !ResCollDecl -> ChainableRes ChainResDecl :: !ResDecl -> ChainableRes ChainResRefr :: !Text -> [Expression] -> !PPosition -> ChainableRes class HasHOLambdaCall c_a1k2V hOLambdaCall :: HasHOLambdaCall c_a1k2V => Lens' c_a1k2V HOLambdaCall hoLambdaExpr :: HasHOLambdaCall c_a1k2V => Lens' c_a1k2V (Vector Expression) hoLambdaFunc :: HasHOLambdaCall c_a1k2V => Lens' c_a1k2V LambdaFunc hoLambdaLastExpr :: HasHOLambdaCall c_a1k2V => Lens' c_a1k2V (Maybe Expression) hoLambdaParams :: HasHOLambdaCall c_a1k2V => Lens' c_a1k2V LambdaParameters hoLambdaStatements :: HasHOLambdaCall c_a1k2V => Lens' c_a1k2V (Vector Statement) data LambdaParameter LambdaParam :: !(Maybe UDataType) -> !Text -> LambdaParameter -- | Lambda block parameters: type LambdaParameters = Vector LambdaParameter data CompRegex CompRegex :: !Text -> !Regex -> CompRegex data CollectorType -- | Single angle brackets <| |> Collector :: CollectorType -- | Double angle brackets <<| |>> ExportedCollector :: CollectorType data Virtuality -- | Normal resource, that will be included in the catalog. Normal :: Virtuality -- | Type for virtual resources. Virtual :: Virtuality -- | Type for exported resources. Exported :: Virtuality -- | These are resources that are exported AND realized in the catalog. ExportedRealized :: Virtuality data NodeDesc NodeName :: !Text -> NodeDesc NodeMatch :: !CompRegex -> NodeDesc NodeDefault :: NodeDesc -- | Relationship/ordering between resources. data LinkType -- | Applies a resource after the target resource. RRequire :: LinkType -- | Applies a resource before the target resource. RBefore :: LinkType -- | Applies a resource before the target resource. The target resource -- refreshes if the notifying resource changes. RNotify :: LinkType -- | Applies a resource after the target resource. The subscribing resource -- refreshes if the target resource changes. RSubscribe :: LinkType type Parser = Parsec Void Text type PuppetParseError = ParseError Char Void data UDataType UDTType :: UDataType UDTString :: (Maybe Int) -> (Maybe Int) -> UDataType UDTInteger :: (Maybe Int) -> (Maybe Int) -> UDataType UDTFloat :: (Maybe Double) -> (Maybe Double) -> UDataType UDTBoolean :: UDataType UDTArray :: UDataType -> Int -> (Maybe Int) -> UDataType UDTHash :: UDataType -> UDataType -> Int -> (Maybe Int) -> UDataType UDTUndef :: UDataType UDTScalar :: UDataType UDTData :: UDataType UDTOptional :: UDataType -> UDataType UNotUndef :: UDataType UDTVariant :: (NonEmpty UDataType) -> UDataType UDTPattern :: (NonEmpty CompRegex) -> UDataType UDTEnum :: (NonEmpty Expression) -> UDataType UDTAny :: UDataType UDTCollection :: UDataType UDTRegexp :: (Maybe CompRegex) -> UDataType -- | Search expression inside collector <| searchexpr |> data SearchExpression EqualitySearch :: !Text -> !Expression -> SearchExpression NonEqualitySearch :: !Text -> !Expression -> SearchExpression AndSearch :: !SearchExpression -> !SearchExpression -> SearchExpression OrSearch :: !SearchExpression -> !SearchExpression -> SearchExpression AlwaysTrue :: SearchExpression data AttributeDecl AttributeDecl :: !Text -> !ArrowOp -> !Expression -> AttributeDecl AttributeWildcard :: !Expression -> AttributeDecl data ArrowOp -- | +> AppendArrow :: ArrowOp -- | `=>` AssignArrow :: ArrowOp -- | All types of conditional statements : case, if, ... -- -- Stored as an ordered list of pair (condition, statements) . -- Interpreted as "if first cond is true, choose first statements, else -- take the next pair, check the condition ..." data ConditionalDecl ConditionalDecl :: !(Vector (Pair Expression (Vector Statement))) -> !PPosition -> ConditionalDecl -- | Declare a class with -- -- data ClassDecl ClassDecl :: !Text -> !Parameters -> !(Maybe Text) -> !(Vector Statement) -> !PPosition -> ClassDecl -- | Resource default: -- --
--   File { mode => 755 }
--   
-- -- puppet reference. data ResDefaultDecl ResDefaultDecl :: !Text -> !(Vector AttributeDecl) -> !PPosition -> ResDefaultDecl data DepDecl DepDecl :: !(Pair Text Expression) -> !(Pair Text Expression) -> !LinkType -> !PPosition -> DepDecl -- | All possible statements. data Statement ResourceDeclaration :: !ResDecl -> Statement ResourceDefaultDeclaration :: !ResDefaultDecl -> Statement ResourceOverrideDeclaration :: !ResOverrideDecl -> Statement ResourceCollectionDeclaration :: !ResCollDecl -> Statement ClassDeclaration :: !ClassDecl -> Statement DefineDeclaration :: !DefineDecl -> Statement NodeDeclaration :: !NodeDecl -> Statement ConditionalDeclaration :: !ConditionalDecl -> Statement VarAssignmentDeclaration :: !VarAssignDecl -> Statement MainFunctionDeclaration :: !MainFuncDecl -> Statement HigherOrderLambdaDeclaration :: !HigherOrderLambdaDecl -> Statement DependencyDeclaration :: !DepDecl -> Statement -- | Special statement used to include the expressions that are top level. -- Certainly buggy, but probably just like the original implementation. TopContainer :: !(Vector Statement) -> !Statement -> Statement -- | Resource declaration: -- --
--   file { mode => 755}
--   
data ResDecl ResDecl :: !Text -> !Expression -> !(Vector AttributeDecl) -> !Virtuality -> !PPosition -> ResDecl -- | Resource override: -- --
--   File[title] { mode => 755}
--   
-- -- See puppet reference. data ResOverrideDecl ResOverrideDecl :: !Text -> !Expression -> !(Vector AttributeDecl) -> !PPosition -> ResOverrideDecl -- | Declare a define with * a name * a list of parameters * a list of -- statements * a position data DefineDecl DefineDecl :: !Text -> !Parameters -> !(Vector Statement) -> !PPosition -> DefineDecl -- | A node is a collection of statements + maybe an inherit node. data NodeDecl NodeDecl :: !NodeDesc -> !(Vector Statement) -> !(Maybe NodeDesc) -> !PPosition -> NodeDecl -- |
--   $newvar = world
--   
data VarAssignDecl VarAssignDecl :: Maybe UDataType -> [Text] -> !Expression -> !PPosition -> VarAssignDecl [_vadtype] :: VarAssignDecl -> Maybe UDataType [_vadnames] :: VarAssignDecl -> [Text] [_vadvalue] :: VarAssignDecl -> !Expression [_vadpos] :: VarAssignDecl -> !PPosition data MainFuncDecl MainFuncDecl :: !Text -> !(Vector Expression) -> !PPosition -> MainFuncDecl -- | Higher order function call. data HigherOrderLambdaDecl HigherOrderLambdaDecl :: !HOLambdaCall -> !PPosition -> HigherOrderLambdaDecl -- | Resource Collector including exported collector (`<<| -- |>>`) -- --
--   User <| title == jenkins |> { groups +> "docker"}
--   
-- -- See puppet reference data ResCollDecl ResCollDecl :: !CollectorType -> !Text -> !SearchExpression -> !(Vector AttributeDecl) -> !PPosition -> ResCollDecl type Parameters = Vector (Pair (Pair Text (Maybe UDataType)) (Maybe Expression)) _Statements :: Lens' Statement [Statement] _ResDecl :: Prism' Statement ResDecl _ResDefaultDecl :: Prism' Statement ResDefaultDecl _ResOverrDecl :: Prism' Statement ResOverrideDecl _ResCollDecl :: Prism' Statement ResCollDecl _ConditionalDecl :: Prism' Statement ConditionalDecl _ClassDecl :: Prism' Statement ClassDecl _DefineDecl :: Prism' Statement DefineDecl _NodeDecl :: Prism' Statement NodeDecl _VarAssignDecl :: Prism' Statement VarAssignDecl _MainFuncDecl :: Prism' Statement MainFuncDecl _HigherOrderLambdaDecl :: Prism' Statement HigherOrderLambdaDecl _DepDecl :: Prism' Statement DepDecl _Equal :: Prism' Expression (Expression, Expression) _Different :: Prism' Expression (Expression, Expression) _Not :: Prism' Expression Expression _And :: Prism' Expression (Expression, Expression) _Or :: Prism' Expression (Expression, Expression) _LessThan :: Prism' Expression (Expression, Expression) _MoreThan :: Prism' Expression (Expression, Expression) _LessEqualThan :: Prism' Expression (Expression, Expression) _MoreEqualThan :: Prism' Expression (Expression, Expression) _RegexMatch :: Prism' Expression (Expression, Expression) _NotRegexMatch :: Prism' Expression (Expression, Expression) _Contains :: Prism' Expression (Expression, Expression) _Addition :: Prism' Expression (Expression, Expression) _Substraction :: Prism' Expression (Expression, Expression) _Division :: Prism' Expression (Expression, Expression) _Multiplication :: Prism' Expression (Expression, Expression) _Modulo :: Prism' Expression (Expression, Expression) _RightShift :: Prism' Expression (Expression, Expression) _LeftShift :: Prism' Expression (Expression, Expression) _Lookup :: Prism' Expression (Expression, Expression) _Negate :: Prism' Expression Expression _ConditionalValue :: Prism' Expression (Expression, Vector (Pair SelectorCase Expression)) _FunctionApplication :: Prism' Expression (Expression, Expression) _Terminal :: Prism' Expression UnresolvedValue module Puppet.Interpreter -- | Call the operational interpretMonad function to compute the -- catalog. Returns either an error, or a tuple containing all the -- resources, dependency map, exported resources, and defined resources -- alongside with all messages that have been generated by the -- compilation process. -- -- The later defined resources (eg. all class declarations) are pulled -- out of the InterpreterState and might not be up to date. There -- are only useful for coverage testing (checking dependencies for -- instance). interpretCatalog :: Monad m => InterpreterReader m -> NodeName -> Facts -> Container Text -> m (Pair (Either PrettyError (FinalCatalog, EdgeMap, FinalCatalog, [Resource])) [Pair Priority Doc]) -- | Main internal entry point, this function completes the interpretation computeCatalog :: NodeName -> InterpreterMonad (FinalCatalog, EdgeMap, FinalCatalog, [Resource]) evaluateStatement :: Statement -> InterpreterMonad [Resource] initialState :: Facts -> Container Text -> InterpreterState extractScope :: InterpreterState -> Maybe (Text, Container ScopeInformation) containerModName :: CurContainerDesc -> Text -- | Ask the value of a fact given a specified key The fact set comes from -- the reader used by the interpreter monad. askFact :: Text -> InterpreterMonad (Maybe PValue) data InterpreterState InterpreterState :: !(Container ScopeInformation) -> !(Container (Pair ClassIncludeType PPosition)) -> !(HashMap RIdentifier Resource) -> ![CurContainerDesc] -> !PPosition -> !(HashMap (TopLevelType, Text) Statement) -> ![LinkInformation] -> ![ResourceModifier] -> InterpreterState scopes :: Lens' InterpreterState (Container ScopeInformation) definedResources :: Lens' InterpreterState (HashMap RIdentifier Resource) nestedDeclarations :: Lens' InterpreterState (HashMap (TopLevelType, Text) Statement) resModifiers :: Lens' InterpreterState [ResourceModifier] extraRelations :: Lens' InterpreterState [LinkInformation] curScope :: Lens' InterpreterState [CurContainerDesc] curPos :: Lens' InterpreterState PPosition loadedClasses :: Lens' InterpreterState (Container (Pair ClassIncludeType PPosition)) data InterpreterReader m InterpreterReader :: !(Container NativeTypeMethods) -> TopLevelType -> Text -> m (Either PrettyError Statement) -> TemplateSource -> InterpreterState -> InterpreterReader m -> m (Either PrettyError Text) -> PuppetDBAPI m -> Container ([PValue] -> InterpreterMonad PValue) -> Text -> HieraQueryLayers m -> IoMethods m -> HashSet Text -> HashSet Text -> Bool -> PuppetDirPaths -> Maybe FilePath -> Container PValue -> InterpreterReader m readerNativeTypes :: forall m_a2rYj. Lens' (InterpreterReader m_a2rYj) (Container NativeTypeMethods) readerGetStatement :: forall m_a2rYj. Lens' (InterpreterReader m_a2rYj) (TopLevelType -> Text -> m_a2rYj (Either PrettyError Statement)) readerGetTemplate :: forall m_a2rYj. Lens' (InterpreterReader m_a2rYj) (TemplateSource -> InterpreterState -> InterpreterReader m_a2rYj -> m_a2rYj (Either PrettyError Text)) readerPdbApi :: forall m_a2rYj. Lens' (InterpreterReader m_a2rYj) (PuppetDBAPI m_a2rYj) readerExternalFunc :: forall m_a2rYj. Lens' (InterpreterReader m_a2rYj) (Container ([PValue] -> InterpreterMonad PValue)) readerNodename :: forall m_a2rYj. Lens' (InterpreterReader m_a2rYj) Text readerHieraQuery :: forall m_a2rYj. Lens' (InterpreterReader m_a2rYj) (HieraQueryLayers m_a2rYj) readerIoMethods :: forall m_a2rYj. Lens' (InterpreterReader m_a2rYj) (IoMethods m_a2rYj) readerIgnoredModules :: forall m_a2rYj. Lens' (InterpreterReader m_a2rYj) (HashSet Text) readerExternalModules :: forall m_a2rYj. Lens' (InterpreterReader m_a2rYj) (HashSet Text) readerIsStrict :: forall m_a2rYj. Lens' (InterpreterReader m_a2rYj) Bool readerPuppetPaths :: forall m_a2rYj. Lens' (InterpreterReader m_a2rYj) PuppetDirPaths readerFacts :: forall m_a2rYj. Lens' (InterpreterReader m_a2rYj) (Container PValue) readerRebaseFile :: forall m_a2rYj. Lens' (InterpreterReader m_a2rYj) (Maybe FilePath) -- | The main monad type InterpreterMonad = ProgramT InterpreterInstr (State InterpreterState) -- | Log type InterpreterWriter = [Pair Priority Doc] data InterpreterInstr a [GetNativeTypes] :: InterpreterInstr (Container NativeTypeMethods) [GetStatement] :: TopLevelType -> Text -> InterpreterInstr Statement [ComputeTemplate] :: TemplateSource -> InterpreterState -> InterpreterInstr Text [ExternalFunction] :: Text -> [PValue] -> InterpreterInstr PValue [Facts] :: InterpreterInstr (Container PValue) [GetNodeName] :: InterpreterInstr Text [HieraQuery] :: Container Text -> Text -> HieraQueryType -> InterpreterInstr (Maybe PValue) [GetCurrentCallStack] :: InterpreterInstr [String] [IsIgnoredModule] :: Text -> InterpreterInstr Bool [IsExternalModule] :: Text -> InterpreterInstr Bool [IsStrict] :: InterpreterInstr Bool [PuppetPaths] :: InterpreterInstr PuppetDirPaths [RebaseFile] :: InterpreterInstr (Maybe FilePath) [ErrorThrow] :: PrettyError -> InterpreterInstr a [ErrorCatch] :: InterpreterMonad a -> (PrettyError -> InterpreterMonad a) -> InterpreterInstr a [WriterTell] :: InterpreterWriter -> InterpreterInstr () [WriterPass] :: InterpreterMonad (a, InterpreterWriter -> InterpreterWriter) -> InterpreterInstr a [WriterListen] :: InterpreterMonad a -> InterpreterInstr (a, InterpreterWriter) [PDBInformation] :: InterpreterInstr Doc [PDBReplaceCatalog] :: WireCatalog -> InterpreterInstr () [PDBReplaceFacts] :: [(NodeName, Facts)] -> InterpreterInstr () [PDBDeactivateNode] :: NodeName -> InterpreterInstr () [PDBGetFacts] :: Query FactField -> InterpreterInstr [FactInfo] [PDBGetResources] :: Query ResourceField -> InterpreterInstr [Resource] [PDBGetNodes] :: Query NodeField -> InterpreterInstr [NodeInfo] [PDBCommitDB] :: InterpreterInstr () [PDBGetResourcesOfNode] :: NodeName -> Query ResourceField -> InterpreterInstr [Resource] [ReadFile] :: [Text] -> InterpreterInstr Text [TraceEvent] :: String -> InterpreterInstr () -- | The intepreter can run in two modes : a strict mode (recommended), and -- a permissive mode. data Strictness Strict :: Strictness Permissive :: Strictness data IoMethods m IoMethods :: m [String] -> [Text] -> m (Either String Text) -> String -> m () -> IoMethods m ioGetCurrentCallStack :: forall m_a2rYl. Lens' (IoMethods m_a2rYl) (m_a2rYl [String]) ioReadFile :: forall m_a2rYl. Lens' (IoMethods m_a2rYl) ([Text] -> m_a2rYl (Either String Text)) ioTraceEvent :: forall m_a2rYl. Lens' (IoMethods m_a2rYl) (String -> m_a2rYl ()) class Monad m => MonadThrowPos m throwPosError :: MonadThrowPos m => Doc -> m a data ResourceModifier ResourceModifier :: !Text -> !ModifierType -> !ResourceCollectorType -> !RSearchExpression -> !(Resource -> InterpreterMonad Resource) -> !PPosition -> ResourceModifier rmResType :: Lens' ResourceModifier Text rmDeclaration :: Lens' ResourceModifier PPosition rmSearch :: Lens' ResourceModifier RSearchExpression rmType :: Lens' ResourceModifier ResourceCollectorType rmMutation :: Lens' ResourceModifier (Resource -> InterpreterMonad Resource) rmModifierType :: Lens' ResourceModifier ModifierType data ModifierType -- | For collectors, optional resources ModifierCollector :: ModifierType -- | For stuff like realize ModifierMustMatch :: ModifierType data OverrideType -- | Overriding forbidden, will throw an error CantOverride :: OverrideType -- | Can silently replace Replace :: OverrideType -- | Silently ignore errors CantReplace :: OverrideType -- | Can append values AppendAttribute :: OverrideType data ResourceCollectorType RealizeVirtual :: ResourceCollectorType RealizeCollected :: ResourceCollectorType DontRealize :: ResourceCollectorType -- | Puppet has two main ways to declare classes: include-like and -- resource-like. -- -- See puppet reference. data ClassIncludeType -- | Using the include or contain function ClassIncludeLike :: ClassIncludeType -- | Resource like declaration ClassResourceLike :: ClassIncludeType data RSearchExpression REqualitySearch :: !Text -> !PValue -> RSearchExpression RNonEqualitySearch :: !Text -> !PValue -> RSearchExpression RAndSearch :: !RSearchExpression -> !RSearchExpression -> RSearchExpression ROrSearch :: !RSearchExpression -> !RSearchExpression -> RSearchExpression RAlwaysTrue :: RSearchExpression data ScopeInformation ScopeInformation :: !(Container (Pair (Pair PValue PPosition) CurContainerDesc)) -> !(Container ResDefaults) -> !(HashSet Text) -> !CurContainer -> !(HashMap RIdentifier ResRefOverride) -> !(Maybe Text) -> ScopeInformation scopeResDefaults :: Lens' ScopeInformation (Container ResDefaults) scopeVariables :: Lens' ScopeInformation (Container (Pair (Pair PValue PPosition) CurContainerDesc)) scopeParent :: Lens' ScopeInformation (Maybe Text) scopeOverrides :: Lens' ScopeInformation (HashMap RIdentifier ResRefOverride) scopeContainer :: Lens' ScopeInformation CurContainer scopeExtraTags :: Lens' ScopeInformation (HashSet Text) -- | The type of the container together with its tags. data CurContainer CurContainer :: !CurContainerDesc -> !(HashSet Text) -> CurContainer cctype :: Lens' CurContainer CurContainerDesc cctags :: Lens' CurContainer (HashSet Text) -- | From the evaluation of Resource Default Declaration. data ResDefaults ResDefaults :: !Text -> !Text -> !(Container PValue) -> !PPosition -> ResDefaults resDefValues :: Lens' ResDefaults (Container PValue) resDefSrcScope :: Lens' ResDefaults Text resDefPos :: Lens' ResDefaults PPosition resDefType :: Lens' ResDefaults Text -- | From the evaluation of Resource Override Declaration. data ResRefOverride ResRefOverride :: !RIdentifier -> !(Container PValue) -> !PPosition -> ResRefOverride [_rrid] :: ResRefOverride -> !RIdentifier [_rrparams] :: ResRefOverride -> !(Container PValue) [_rrpos] :: ResRefOverride -> !PPosition data ScopeEnteringContext SENormal :: ScopeEnteringContext -- | We enter the scope as the child of another class SEChild :: !Text -> ScopeEnteringContext -- | We enter the scope as the parent of another class SEParent :: !Text -> ScopeEnteringContext -- | Differentiate the distinct top level types such as node, define or -- class. data TopLevelType -- | For node entries TopNode :: TopLevelType -- | For defines TopDefine :: TopLevelType -- | For classes TopClass :: TopLevelType -- | All available queries including the global and module layer The -- environment layer is not implemented. -- -- The datatype belongs to the Puppet.Interpreter module because -- it serves to implement how Hiera is used within Puppet. data HieraQueryLayers m HieraQueryLayers :: HieraQueryFunc m -> HieraQueryFunc m -> Container (HieraQueryFunc m) -> HieraQueryLayers m [_globalLayer] :: HieraQueryLayers m -> HieraQueryFunc m [_environmentLayer] :: HieraQueryLayers m -> HieraQueryFunc m [_moduleLayer] :: HieraQueryLayers m -> Container (HieraQueryFunc m) globalLayer :: forall m_a2rYk. Lens' (HieraQueryLayers m_a2rYk) (HieraQueryFunc m_a2rYk) environmentLayer :: forall m_a2rYk. Lens' (HieraQueryLayers m_a2rYk) (HieraQueryFunc m_a2rYk) moduleLayer :: forall m_a2rYk. Lens' (HieraQueryLayers m_a2rYk) (Container (HieraQueryFunc m_a2rYk)) -- | Whether the template source is specified inline or loaded -- from a file. data TemplateSource Inline :: Text -> TemplateSource Filename :: FilePath -> TemplateSource -- | A pure function for resolving variables. getVariable :: Container ScopeInformation -> Text -> Text -> Either Doc PValue -- | Turns a PValue into a Bool as explained in the reference -- documentation. pValue2Bool :: PValue -> Bool -- | Resolves a variable, or throws an error if it can't. resolveVariable :: Text -> InterpreterMonad PValue -- | The main resolution function : turns an Expression into a -- PValue, if possible. resolveExpression :: Expression -> InterpreterMonad PValue -- | Resolves an UnresolvedValue (terminal for the Expression -- data type) into a PValue resolveValue :: UnresolvedValue -> InterpreterMonad PValue -- | Turns strings, numbers and booleans into Text, or throws an -- error. resolvePValueString :: PValue -> InterpreterMonad Text -- | Turns everything it can into a number, or throws an error resolvePValueNumber :: PValue -> InterpreterMonad Scientific -- |
--   resolveExpressionString = resolveExpression >=> resolvePValueString
--   
resolveExpressionString :: Expression -> InterpreterMonad Text -- | Just like resolveExpressionString, but accepts arrays. resolveExpressionStrings :: Expression -> InterpreterMonad [Text] resolveFunction' :: Text -> [PValue] -> InterpreterMonad PValue resolveDataType :: UDataType -> InterpreterMonad DataType -- | A hiera helper function, that will throw all Hiera errors and log -- messages to the main monad. runHiera :: Text -> HieraQueryType -> InterpreterMonad (Maybe PValue) -- | A simple helper that checks if a given type is native or a define. isNativeType :: Text -> InterpreterMonad Bool -- | Turns an unresolved SearchExpression from the parser into a -- fully resolved RSearchExpression. resolveSearchExpression :: SearchExpression -> InterpreterMonad RSearchExpression -- | Checks whether a given Resource matches a -- RSearchExpression. Note that the expression doesn't check for -- type, so you must filter the resources by type beforehand, if needs -- be. checkSearchExpression :: RSearchExpression -> Resource -> Bool -- | Turns a resource type and RSearchExpression into something that -- can be used in a PuppetDB query. searchExpressionToPuppetDB :: Text -> RSearchExpression -> Query ResourceField -- | Generates variable associations for evaluation of blocks. Each item -- corresponds to an iteration in the calling block. hfGenerateAssociations :: HOLambdaCall -> InterpreterMonad [[(Text, PValue)]] -- | Sets the proper variables, and returns the scope variables the way -- they were before being modified. This is a hack that ensures that -- variables are local to the new scope. -- -- It doesn't work at all like other Puppet parts, but consistency isn't -- really expected here ... hfSetvars :: [(Text, PValue)] -> InterpreterMonad (Container (Pair (Pair PValue PPosition) CurContainerDesc)) -- | Restores what needs restoring. This will erase all allocations. hfRestorevars :: Container (Pair (Pair PValue PPosition) CurContainerDesc) -> InterpreterMonad () -- | Converts class resource names to lowercase (fix for the jenkins -- plugin). fixResourceName :: Text -> Text -> Text -- | Checks that a value matches a puppet datatype datatypeMatch :: DataType -> PValue -> Bool checkMatch :: DataType -> PValue -> InterpreterMonad () typeOf :: PValue -> DataType -- | The operational interpreter function interpretMonad :: Monad m => InterpreterReader m -> InterpreterState -> InterpreterMonad a -> m (Either PrettyError a, InterpreterState, InterpreterWriter) -- | At the top of the abstraction level, the module exposes all high-end -- services: -- -- -- -- Naturally nothing from Puppet.Runner should be used in lower -- abstraction layers. module Puppet.Runner data Preferences m Preferences :: PuppetDirPaths -> PuppetDBAPI m -> Container NativeTypeMethods -> Container ([PValue] -> InterpreterMonad PValue) -> Maybe FilePath -> HashSet Text -> Strictness -> Bool -> [Text] -> [Text] -> HashSet Text -> Container Text -> Container PValue -> Container PValue -> Priority -> Maybe FilePath -> Preferences m prefPuppetPaths :: forall m_a3AAW. Lens' (Preferences m_a3AAW) PuppetDirPaths prefPDB :: forall m_a3AAW m_a3AFS. Lens (Preferences m_a3AAW) (Preferences m_a3AFS) (PuppetDBAPI m_a3AAW) (PuppetDBAPI m_a3AFS) prefNatTypes :: forall m_a3AAW. Lens' (Preferences m_a3AAW) (Container NativeTypeMethods) prefExtFuncs :: forall m_a3AAW. Lens' (Preferences m_a3AAW) (Container ([PValue] -> InterpreterMonad PValue)) prefHieraPath :: forall m_a3AAW. Lens' (Preferences m_a3AAW) (Maybe FilePath) prefIgnoredmodules :: forall m_a3AAW. Lens' (Preferences m_a3AAW) (HashSet Text) prefStrictness :: forall m_a3AAW. Lens' (Preferences m_a3AAW) Strictness prefExtraTests :: forall m_a3AAW. Lens' (Preferences m_a3AAW) Bool prefKnownusers :: forall m_a3AAW. Lens' (Preferences m_a3AAW) [Text] prefKnowngroups :: forall m_a3AAW. Lens' (Preferences m_a3AAW) [Text] prefExternalmodules :: forall m_a3AAW. Lens' (Preferences m_a3AAW) (HashSet Text) prefPuppetSettings :: forall m_a3AAW. Lens' (Preferences m_a3AAW) (Container Text) prefFactsOverride :: forall m_a3AAW. Lens' (Preferences m_a3AAW) (Container PValue) prefFactsDefault :: forall m_a3AAW. Lens' (Preferences m_a3AAW) (Container PValue) prefLogLevel :: forall m_a3AAW. Lens' (Preferences m_a3AAW) Priority prefRebaseFile :: forall m_a3AAW. Lens' (Preferences m_a3AAW) (Maybe FilePath) -- | Generate default preferences. dfPreferences :: FilePath -> IO (Preferences IO) data PuppetDirPaths class HasPuppetDirPaths c_auLv puppetDirPaths :: HasPuppetDirPaths c_auLv => Lens' c_auLv PuppetDirPaths baseDir :: HasPuppetDirPaths c_auLv => Lens' c_auLv FilePath manifestPath :: HasPuppetDirPaths c_auLv => Lens' c_auLv FilePath modulesPath :: HasPuppetDirPaths c_auLv => Lens' c_auLv FilePath templatesPath :: HasPuppetDirPaths c_auLv => Lens' c_auLv FilePath testPath :: HasPuppetDirPaths c_auLv => Lens' c_auLv FilePath -- | A default evaluation function for arbitrary interpreter actions. -- Unlike pureEval, each hiera lookup is evaluated to return the -- string dummy. dummyEval :: InterpreterMonad a -> Either PrettyError a -- | A bunch of facts that can be used for pure evaluation. dummyFacts :: Facts dummyInitialState :: InterpreterState -- | Evaluates with a map of statements in a pure context. Unlike -- dummyEval, each hiera lookup is evaluated to return Nothing. pureEval :: HashMap (TopLevelType, Text) Statement -> InterpreterMonad a -> (Either PrettyError a, InterpreterState, InterpreterWriter) -- | More flexible version of pureEval pureEval' :: HashMap (TopLevelType, Text) Statement -> InterpreterState -> Maybe PValue -> InterpreterMonad a -> (Either PrettyError a, InterpreterState, InterpreterWriter) -- | A pure InterpreterReader, that can only evaluate a subset of -- the templates, and that can include only the supplied top level -- statements. pureReader :: HashMap (TopLevelType, Text) Statement -> Maybe PValue -> InterpreterReader Identity -- | Wraps a computation, and measures related execution statistics. measure :: MStats -> Text -> IO a -> IO a -- | Create a new statistical container. newStats :: IO MStats -- | Returns the actual statistical values. getStats :: MStats -> IO StatsTable data StatsPoint StatsPoint :: !Int -> !Double -> !Double -> !Double -> StatsPoint -- | Total number of calls to a computation [_statspointCount] :: StatsPoint -> !Int -- | Total time spent during this computation [_statspointTotal] :: StatsPoint -> !Double -- | Minimum execution time [_statspointMin] :: StatsPoint -> !Double -- | Maximum execution time [_statspointMax] :: StatsPoint -> !Double data MStats -- | Contains the implementation of the StdLib functions. stdlibFunctions :: Container ([PValue] -> InterpreterMonad PValue) -- | API for the Daemon. The main method is getCatalog: given a node -- and a list of facts, it returns the result of the compilation. This -- will be either an error, or a tuple containing: -- -- -- -- Notes : -- -- data Daemon Daemon :: NodeName -> Facts -> IO (Either PrettyError (FinalCatalog, EdgeMap, FinalCatalog, [Resource])) -> MStats -> MStats -> MStats -> Daemon [getCatalog] :: Daemon -> NodeName -> Facts -> IO (Either PrettyError (FinalCatalog, EdgeMap, FinalCatalog, [Resource])) [parserStats] :: Daemon -> MStats [catalogStats] :: Daemon -> MStats [templateStats] :: Daemon -> MStats -- | Entry point to get a Daemon. It will initialize the parsing and -- interpretation infrastructure from the Preferences. -- -- Cache the AST of every .pp file. It could use a bit of memory. As a -- comparison, it fits in 60 MB with the author's manifests, but really -- breathes when given 300 MB of heap space. In this configuration, even -- if it spawns a ruby process for every template evaluation, it is way -- faster than the puppet stack. -- -- It can optionally talk with PuppetDB, by setting an URL via the -- prefPDB. The recommended way to set it to -- http://localhost:8080 and set a SSH tunnel : -- --
--   ssh -L 8080:localhost:8080 puppet.host
--   
initDaemon :: Preferences IO -> IO Daemon -- | Evaluate a list of ruby statements. rubyEvaluate :: Container ScopeInformation -> ScopeName -> [RubyStatement] -> Either Doc Text