language-puppet-0.4.0: Tools to parse and evaluate the Puppet DSL.

Safe HaskellSafe-Inferred

Puppet.DSL.Types

Description

Types used when parsing the Puppet DSL. A good knowledge of the Puppet language in required to understand them.

Synopsis

Documentation

data TopLevelType Source

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.

TopSpurious

This one is special. It represents top level statements that are not part of a node, define or class. It is defined as spurious because it is not what you are supposed to be. Also the caching system doesn't like them too much right now.

convertTopLevel :: Statement -> Either Statement (TopLevelType, Text, Statement)Source

This function returns the TopLevelType of a statement if it is either a node, class or define. It returns Nothing otherwise.

data Value Source

The Value type represents a Puppet value. It is the terminal in a puppet Expression

Constructors

Literal !Text

String literal.

Interpolable ![Value]

An interpolable string, represented as a Value list.

PuppetRegexp !Text

A Puppet Regexp. This is very hackish as it alters the behaviour of some functions (such as conditional values).

Double !Double 
Integer !Integer 
VariableReference !Text

Reference to a variable. The string contains what is acutally typed in the manifest.

Empty 
ResourceReference !Text !Expression 
PuppetArray ![Expression] 
PuppetHash !Parameters 
FunctionCall !Text ![Expression] 
PuppetBool Bool 
Undefined

This is special and quite hackish too.

data Statement Source

The actual puppet statements

Constructors

Node Text ![Statement] !SourcePos

This holds the node name and list of statements. | This holds the variable name and the expression that it represents.

VariableAssignment !Text !Expression !SourcePos 
Include !Expression !SourcePos 
Import !Text !SourcePos 
Require !Text !SourcePos 
Resource !Text !Expression ![(Expression, Expression)] !Virtuality !SourcePos

This holds the resource type, name, parameter list and virtuality.

ResourceDefault !Text ![(Expression, Expression)] !SourcePos

This is a resource default declaration, such as File {owner => 'root'; }. It holds the resource type and the list of default parameters.

ResourceOverride !Text !Expression ![(Expression, Expression)] !SourcePos

This works like Resource, but the Expression holds the resource name.

ConditionalStatement ![(Expression, [Statement])] !SourcePos

The pairs hold on the left a value that is resolved as a boolean, and on the right the list of statements that correspond to this. This will be generated by if/then/else statement, but also by the case statement.

ClassDeclaration !Text !(Maybe Text) ![(Text, Maybe Expression)] ![Statement] !SourcePos

The class declaration holds the class name, the optional name of the class it inherits from, a list of parameters with optional default values, and the list of statements it contains.

DefineDeclaration !Text ![(Text, Maybe Expression)] ![Statement] !SourcePos

The define declaration is like the ClassDeclaration except it can't inherit from anything.

ResourceCollection !Text !Expression ![(Expression, Expression)] !SourcePos

This is the resource collection syntax (<<| |>>). It holds the conditional expression, and an eventual list of overrides. This is important as the same token conveys two distinct Puppet concepts : resource collection and resource overrides.

VirtualResourceCollection !Text !Expression ![(Expression, Expression)] !SourcePos

Same as ResourceCollection, but for <| |>.

DependenceChain !(Text, Expression) !(Text, Expression) !SourcePos 
MainFunctionCall !Text ![Expression] !SourcePos 
TopContainer ![(Text, Statement)] !Statement

This is a magic statement that is used to hold the spurious top level statements that comes in the same file as the correct top level statement that is stored in the second field. The first field contains pairs of filenames and statements. This is designed so that the interpreter can know whether it has already been evaluated.