Safe Haskell | None |
---|---|
Language | Haskell98 |
Puppet.Interpreter.Types
Contents
- class HasResource c where
- data Resource = Resource !RIdentifier !(HashSet Text) !(Container PValue) !(HashMap RIdentifier (HashSet LinkType)) ![CurContainerDesc] !Virtuality !(HashSet Text) !PPosition !NodeName
- class HasResDefaults c where
- data ResDefaults = ResDefaults !Text !Text !(Container PValue) !PPosition
- class HasLinkInformation c where
- data LinkInformation = LinkInformation !RIdentifier !RIdentifier !LinkType !PPosition
- class HasRIdentifier c where
- data RIdentifier = RIdentifier !Text !Text
- class HasScopeInformation c where
- data ScopeInformation = ScopeInformation !(Container (Pair (Pair PValue PPosition) CurContainerDesc)) !(Container ResDefaults) !(HashSet Text) !CurContainer !(HashMap RIdentifier ResRefOverride) !(Maybe Text)
- data ScopeEnteringContext
- class HasResourceModifier c where
- data ResourceModifier = ResourceModifier !Text !ModifierType !ResourceCollectorType !RSearchExpression !(Resource -> InterpreterMonad Resource) !PPosition
- class HasIoMethods c m | c -> m where
- data IoMethods m = IoMethods (m [String]) ([Text] -> m (Either String Text)) (String -> m ())
- class HasCurContainer c where
- data CurContainer = CurContainer !CurContainerDesc !(HashSet Text)
- class HasNativeTypeMethods c where
- data NativeTypeMethods = NativeTypeMethods NativeTypeValidate (HashSet Text)
- data NodeInfo = NodeInfo !NodeName !Bool !(Maybe UTCTime) !(Maybe UTCTime) !(Maybe UTCTime)
- class HasNodeInfo c where
- data FactInfo = FactInfo !NodeName !Text !PValue
- class HasFactInfo c where
- class HasWireCatalog c where
- data InterpreterInstr a where
- GetNativeTypes :: InterpreterInstr (Container NativeTypeMethods)
- GetStatement :: TopLevelType -> Text -> InterpreterInstr Statement
- ComputeTemplate :: Either Text Text -> InterpreterState -> InterpreterInstr Text
- ExternalFunction :: Text -> [PValue] -> InterpreterInstr 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
- 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 ()
- class HasInterpreterReader c m | c -> m where
- data InterpreterReader m = InterpreterReader !(Container NativeTypeMethods) (TopLevelType -> Text -> m (Either PrettyError Statement)) (Either Text Text -> InterpreterState -> InterpreterReader m -> m (Either PrettyError Text)) (PuppetDBAPI m) (Container ([PValue] -> InterpreterMonad PValue)) Text (HieraQueryFunc m) (IoMethods m) (HashSet Text) (HashSet Text) Bool PuppetDirPaths
- class HasInterpreterState c where
- data InterpreterState = InterpreterState !(Container ScopeInformation) !(Container (Pair ClassIncludeType PPosition)) !(HashMap RIdentifier Resource) ![CurContainerDesc] !PPosition !(HashMap (TopLevelType, Text) Statement) ![LinkInformation] ![ResourceModifier]
- data PValue
- _PType :: Prism' PValue DataType
- _PBoolean :: Prism' PValue Bool
- _PString :: Prism' PValue Text
- _PResourceReference :: Prism' PValue (Text, Text)
- _PArray :: Prism' PValue (Vector PValue)
- _PHash :: Prism' PValue (Container PValue)
- _PNumber :: Prism' PValue Scientific
- _PUndef :: Prism' PValue ()
- data CurContainerDesc
- data ResourceCollectorType
- data RSearchExpression
- data Query a
- data ModifierType
- data NodeField
- data Strictness
- = Strict
- | Permissive
- data HieraQueryType
- data WireCatalog = WireCatalog {}
- data TopLevelType
- data FactField
- data ResRefOverride = ResRefOverride {}
- data ResourceField
- data OverrideType
- data ClassIncludeType
- data PuppetEdge = PuppetEdge RIdentifier RIdentifier LinkType
- data PuppetDBAPI m = PuppetDBAPI {
- pdbInformation :: m Doc
- replaceCatalog :: WireCatalog -> ExceptT PrettyError m ()
- replaceFacts :: [(NodeName, Facts)] -> ExceptT PrettyError m ()
- deactivateNode :: NodeName -> ExceptT PrettyError m ()
- getFacts :: Query FactField -> ExceptT PrettyError m [FactInfo]
- getResources :: Query ResourceField -> ExceptT PrettyError m [Resource]
- getNodes :: Query NodeField -> ExceptT PrettyError m [NodeInfo]
- commitDB :: ExceptT PrettyError m ()
- getResourcesOfNode :: NodeName -> Query ResourceField -> ExceptT PrettyError m [Resource]
- newtype PrettyError = PrettyError {}
- type InterpreterMonad = ProgramT InterpreterInstr (State InterpreterState)
- type InterpreterWriter = [Pair Priority Doc]
- type FinalCatalog = HashMap RIdentifier Resource
- type NativeTypeValidate = Resource -> Either PrettyError Resource
- type NodeName = Text
- type Container = HashMap Text
- type HieraQueryFunc m = Container Text -> Text -> HieraQueryType -> m (Either PrettyError (Maybe PValue))
- type Scope = Text
- type Facts = Container PValue
- type EdgeMap = HashMap RIdentifier [LinkInformation]
- class Monad m => MonadThrowPos m where
- class Monad m => MonadError e m | m -> e where
- metaparameters :: HashSet Text
- showPos :: Position -> Doc
Record & lenses
class HasResource c where #
Minimal complete definition
Methods
resource :: Lens' c Resource #
ralias :: Lens' c (HashSet Text) #
rattributes :: Lens' c (Container PValue) #
rid :: Lens' c RIdentifier #
rrelations :: Lens' c (HashMap RIdentifier (HashSet LinkType)) #
rscope :: Lens' c [CurContainerDesc] #
rtags :: Lens' c (HashSet Text) #
rvirtuality :: Lens' c Virtuality #
Instances
A fully resolved puppet resource that will be used in the FinalCatalog
.
Constructors
Resource !RIdentifier !(HashSet Text) !(Container PValue) !(HashMap RIdentifier (HashSet LinkType)) ![CurContainerDesc] !Virtuality !(HashSet Text) !PPosition !NodeName |
class HasResDefaults c where #
Minimal complete definition
Methods
resDefaults :: Lens' c ResDefaults #
resDefPos :: Lens' c PPosition #
resDefSrcScope :: Lens' c Text #
resDefType :: Lens' c Text #
resDefValues :: Lens' c (Container PValue) #
Instances
class HasLinkInformation c where #
Minimal complete definition
Methods
linkInformation :: Lens' c LinkInformation #
linkPos :: Lens' c PPosition #
linkType :: Lens' c LinkType #
linkdst :: Lens' c RIdentifier #
linksrc :: Lens' c RIdentifier #
Instances
data LinkInformation #
Constructors
LinkInformation !RIdentifier !RIdentifier !LinkType !PPosition |
Instances
class HasScopeInformation c where #
Minimal complete definition
Methods
scopeInformation :: Lens' c ScopeInformation #
scopeContainer :: Lens' c CurContainer #
scopeExtraTags :: Lens' c (HashSet Text) #
scopeOverrides :: Lens' c (HashMap RIdentifier ResRefOverride) #
scopeParent :: Lens' c (Maybe Text) #
scopeResDefaults :: Lens' c (Container ResDefaults) #
scopeVariables :: Lens' c (Container (Pair (Pair PValue PPosition) CurContainerDesc)) #
Instances
data ScopeInformation #
Constructors
ScopeInformation !(Container (Pair (Pair PValue PPosition) CurContainerDesc)) !(Container ResDefaults) !(HashSet Text) !CurContainer !(HashMap RIdentifier ResRefOverride) !(Maybe Text) |
Instances
data ScopeEnteringContext #
class HasResourceModifier c where #
Minimal complete definition
Methods
resourceModifier :: Lens' c ResourceModifier #
rmDeclaration :: Lens' c PPosition #
rmModifierType :: Lens' c ModifierType #
rmMutation :: Lens' c (Resource -> InterpreterMonad Resource) #
rmSearch :: Lens' c RSearchExpression #
Instances
data ResourceModifier #
Constructors
ResourceModifier !Text !ModifierType !ResourceCollectorType !RSearchExpression !(Resource -> InterpreterMonad Resource) !PPosition |
Instances
class HasIoMethods c m | c -> m where #
Minimal complete definition
Methods
ioMethods :: Lens' c (IoMethods m) #
ioGetCurrentCallStack :: Lens' c (m [String]) #
ioReadFile :: Lens' c ([Text] -> m (Either String Text)) #
ioTraceEvent :: Lens' c (String -> m ()) #
Instances
HasIoMethods (IoMethods m0) m0 # | |
Instances
HasIoMethods (IoMethods m0) m0 # | |
class HasCurContainer c where #
Minimal complete definition
Methods
curContainer :: Lens' c CurContainer #
cctags :: Lens' c (HashSet Text) #
cctype :: Lens' c CurContainerDesc #
Instances
data CurContainer #
TODO related to Scope: explain ...
Constructors
CurContainer !CurContainerDesc !(HashSet Text) |
Instances
class HasNativeTypeMethods c where #
Minimal complete definition
Instances
data NativeTypeMethods #
Attributes (and providers) of a puppet resource type bundled with validation rules
Constructors
NativeTypeMethods NativeTypeValidate (HashSet Text) |
Instances
class HasNodeInfo c where #
Minimal complete definition
Methods
nodeInfo :: Lens' c NodeInfo #
nodeInfoCatalogT :: Lens' c (Maybe UTCTime) #
nodeInfoDeactivated :: Lens' c Bool #
nodeInfoFactsT :: Lens' c (Maybe UTCTime) #
nodeInfoName :: Lens' c NodeName #
nodeInfoReportT :: Lens' c (Maybe UTCTime) #
Instances
class HasFactInfo c where #
Minimal complete definition
Methods
factInfo :: Lens' c FactInfo #
factInfoName :: Lens' c Text #
factInfoNodename :: Lens' c NodeName #
factInfoVal :: Lens' c PValue #
Instances
class HasWireCatalog c where #
Minimal complete definition
Methods
wireCatalog :: Lens' c WireCatalog #
wireCatalogEdges :: Lens' c (Vector PuppetEdge) #
wireCatalogNodename :: Lens' c NodeName #
wireCatalogResources :: Lens' c (Vector Resource) #
wireCatalogTransactionUUID :: Lens' c Text #
wireCatalogVersion :: Lens' c Text #
Instances
Operational instructions
data InterpreterInstr a where #
Constructors
class HasInterpreterReader c m | c -> m where #
Minimal complete definition
Methods
interpreterReader :: Lens' c (InterpreterReader m) #
readerExternalFunc :: Lens' c (Container ([PValue] -> InterpreterMonad PValue)) #
readerExternalModules :: Lens' c (HashSet Text) #
readerGetStatement :: Lens' c (TopLevelType -> Text -> m (Either PrettyError Statement)) #
readerGetTemplate :: Lens' c (Either Text Text -> InterpreterState -> InterpreterReader m -> m (Either PrettyError Text)) #
readerHieraQuery :: Lens' c (HieraQueryFunc m) #
readerIgnoredModules :: Lens' c (HashSet Text) #
readerIoMethods :: Lens' c (IoMethods m) #
readerIsStrict :: Lens' c Bool #
readerNativeTypes :: Lens' c (Container NativeTypeMethods) #
readerNodename :: Lens' c Text #
readerPdbApi :: Lens' c (PuppetDBAPI m) #
Instances
HasInterpreterReader (InterpreterReader m0) m0 # | |
data InterpreterReader m #
Constructors
InterpreterReader !(Container NativeTypeMethods) (TopLevelType -> Text -> m (Either PrettyError Statement)) (Either Text Text -> InterpreterState -> InterpreterReader m -> m (Either PrettyError Text)) (PuppetDBAPI m) (Container ([PValue] -> InterpreterMonad PValue)) Text (HieraQueryFunc m) (IoMethods m) (HashSet Text) (HashSet Text) Bool PuppetDirPaths |
Instances
HasInterpreterReader (InterpreterReader m0) m0 # | |
class HasInterpreterState c where #
Minimal complete definition
Methods
interpreterState :: Lens' c InterpreterState #
curScope :: Lens' c [CurContainerDesc] #
definedResources :: Lens' c (HashMap RIdentifier Resource) #
extraRelations :: Lens' c [LinkInformation] #
loadedClasses :: Lens' c (Container (Pair ClassIncludeType PPosition)) #
nestedDeclarations :: Lens' c (HashMap (TopLevelType, Text) Statement) #
resMod :: Lens' c [ResourceModifier] #
scopes :: Lens' c (Container ScopeInformation) #
Instances
data InterpreterState #
Constructors
Sum types
PValue
Misc
data CurContainerDesc #
Constructors
ContRoot | Contained at node or root level |
ContClass !Text | Contained in a class |
ContDefine !Text !Text !PPosition | Contained in a define, along with the position where this define was ... defined |
ContImported !CurContainerDesc | Dummy container for imported resources, so that we know we must update the nodename |
ContImport !NodeName !CurContainerDesc | This one is used when finalizing imported resources, and contains the current node name |
Instances
data RSearchExpression #
Constructors
REqualitySearch !Text !PValue | |
RNonEqualitySearch !Text !PValue | |
RAndSearch !RSearchExpression !RSearchExpression | |
ROrSearch !RSearchExpression !RSearchExpression | |
RAlwaysTrue |
Instances
Pretty straightforward way to define the various PuppetDB queries
data ModifierType #
Constructors
ModifierCollector | For collectors, optional resources |
ModifierMustMatch | For stuff like realize |
Instances
data Strictness #
The intepreter can run in two modes : a strict mode (recommended), and a permissive mode. The permissive mode let known antipatterns work with the interpreter.
Constructors
Strict | |
Permissive |
Instances
data HieraQueryType #
The different kind of hiera queries
Constructors
Priority | standard hiera query |
ArrayMerge | hiera_array |
HashMerge | hiera_hash |
data TopLevelType #
This type is used to differenciate the distinct top level types that are exposed by the DSL.
Constructors
TopNode | This is for node entries. |
TopDefine | This is for defines. |
TopClass | This is for classes. |
Instances
Fields for the fact endpoint
data ResRefOverride #
From the evaluation of Resource Override Declaration
Constructors
ResRefOverride | |
Instances
data OverrideType #
Constructors
CantOverride | Overriding forbidden, will throw an error |
Replace | Can silently replace |
CantReplace | Silently ignore errors |
AppendAttribute | Can append values |
Instances
data ClassIncludeType #
Puppet has two main ways to declare classes: include-like and resource-like https://docs.puppetlabs.com/puppet/latest/reference/lang_classes.html#include-like-vs-resource-like
Constructors
ClassIncludeLike | using the include or contain function |
ClassResourceLike | resource like declaration |
Instances
PuppetDB
data PuppetEdge #
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
Constructors
PuppetEdge RIdentifier RIdentifier LinkType |
Instances
data PuppetDBAPI m #
Constructors
PuppetDBAPI | |
Fields
|
newtype & synonym
newtype PrettyError #
Constructors
PrettyError | |
type InterpreterMonad = ProgramT InterpreterInstr (State InterpreterState) #
The main monad
type InterpreterWriter = [Pair Priority Doc] #
Log
type FinalCatalog = HashMap RIdentifier Resource #
type NativeTypeValidate = Resource -> Either PrettyError Resource #
type HieraQueryFunc m #
Arguments
= Container Text | All the variables that Hiera can interpolate, the top level ones being prefixed with :: |
-> Text | The query |
-> HieraQueryType | |
-> m (Either PrettyError (Maybe PValue)) |
The type of the Hiera API function
type EdgeMap = HashMap RIdentifier [LinkInformation] #
Classes
class Monad m => MonadThrowPos m where #
Minimal complete definition
Methods
throwPosError :: Doc -> m a #
Instances
class Monad m => MonadError e m | m -> e where #
The strategy of combining computations that can throw exceptions by bypassing bound functions from the point an exception is thrown to the point that it is handled.
Is parameterized over the type of error information and
the monad type constructor.
It is common to use
as the monad type constructor
for an error monad in which error descriptions take the form of strings.
In that case and many other common cases the resulting monad is already defined
as an instance of the Either
StringMonadError
class.
You can also define your own error type and/or use a monad type constructor
other than
or Either
String
.
In these cases you will have to explicitly define instances of the Either
IOError
Error
and/or MonadError
classes.
Minimal complete definition
Methods
throwError :: e -> m a #
Is used within a monadic computation to begin exception processing.
catchError :: m a -> (e -> m a) -> m a #
A handler function to handle previous errors and return to normal execution. A common idiom is:
do { action1; action2; action3 } `catchError` handler
where the action
functions can call throwError
.
Note that handler
and the do-block must have the same return type.
Instances