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

Safe HaskellNone

Puppet.Interpreter.Types

Synopsis

Documentation

type PuppetTypeName = String

Types for the native type system.

type PuppetTypeValidate = RResource -> Either String RResource

This is a function type than can be bound. It is the type of all subsequent validators.

type Catalog = [CResource]

This is the potentially unsolved list of resources in the catalog.

data LinkType

Relationship link type.

data ResolvedValue

The list of resolved values that are used to define everything in a FinalCatalog and in the resolved parts of a Catalog. They are to be compared with the Values.

type GeneralValue = Either Expression ResolvedValue

This type holds a value that is either from the ASL or fully resolved.

type GeneralString = Either Expression String

This type holds a value that is either from the ASL or a fully resolved String.

data CResource

This describes the resources before the final resolution. This is required as they must somehow be collected while the Statements are interpreted, but the necessary Expressions are not yet available. This is because in Puppet the Statement order should not alter the catalog's content.

The relations are not stored here, as they are pushed into a separate internal data structure by the interpreter.

Constructors

CResource 

Fields

crid :: !Int

Resource ID, used in the Puppet YAML.

crname :: !GeneralString

Resource name.

crtype :: !String

Resource type.

crparams :: !(Map GeneralString GeneralValue)

Resource parameters.

crvirtuality :: !Virtuality

Resource virtuality.

pos :: !SourcePos

Source code position of the resource definition.

type ResIdentifier = (String, String)

Resource identifier, made of a type, name pair.

type Relation = (LinkType, ResIdentifier)

Resource relation, made of a LinkType, ResIdentifier pair.

data RResource

This is a fully resolved resource that will be used in the FinalCatalog.

Constructors

RResource 

Fields

rrid :: !Int

Resource ID.

rrname :: !String

Resource name.

rrtype :: !String

Resource type.

rrparams :: !(Map String ResolvedValue)

Resource parameters.

rrelations :: ![Relation]

Resource relations.

rrpos :: !SourcePos

Source code position of the resource definition.

data RelUpdateType

Type of update/override, so they can be applied in the correct order. This part is probably not behaving like vanilla puppet, as it turns out this are many fairly acceptable behaviours and the correct one is not documented.

Constructors

UNormal 
UOverride 
UDefault 
UPlus 

data ScopeState

The most important data structure for the interpreter. It stores its internal state.

Constructors

ScopeState 

Fields

curScope :: ![[ScopeName]]

The list of scopes. It works like a stack, and its initial value must be [["::"]]. It is a stack of lists of strings. These lists can be one element wide (usual case), or two elements (inheritance), so that variables could be assigned to both scopes.

curVariables :: !(Map String (GeneralValue, SourcePos))

The list of known variables. It should be noted that the interpreter tries to resolve them as soon as it can, so that it can store their current scope.

curClasses :: !(Map String SourcePos)

The list of classes that have already been included, along with the place where this happened.

curDefaults :: !(Map [ScopeName] [ResDefaults])

List of defaults to apply. All defaults are applied at the end of the interpretation of each top level statement.

curResId :: !Int

Stores the value of the current crid.

curPos :: !SourcePos

Current position of the evaluated statement. This is mostly used to give useful error messages.

nestedtoplevels :: !(Map (TopLevelType, String) Statement)

List of "top levels" that have been parsed inside another top level. Their behaviour is curently non canonical as the scoping rules are unclear.

getStatementsFunction :: TopLevelType -> String -> IO (Either String Statement)

This is a function that, given the type of a top level statement and its name, should return it.

getWarnings :: ![String]

List of warnings.

curCollect :: ![(CResource -> CatalogMonad Bool, Map GeneralString GeneralValue, Maybe Query)]

A bit complicated, this stores the collection functions. These are functions that determine whether a resource should be collected or not. It can optionally store overrides, which will be applied in the end on all resources. It can also store a PuppetDB query.

unresolvedRels :: ![([(LinkType, GeneralValue, GeneralValue)], (String, GeneralString), RelUpdateType, SourcePos)]

This stores unresolved relationships, because the original string name can't be resolved. Fieds are [ ( [dstrelations], srcresource, type, pos ) ]

computeTemplateFunction :: String -> String -> Map String GeneralValue -> IO (Either String String)

Function that takes a filename, the current scope and a list of variables. It returns an error or the computed template.

puppetDBFunction :: Maybe (String -> Query -> IO (Either String [CResource]))

Function that takes a request type (resources, nodes, facts, ..), a query, and returns a resolved value from puppetDB.

luaState :: Maybe LuaState

The Lua state, used for user supplied content.

userFunctions :: !(Set String)

The list of registered user functions

nativeTypes :: !(Map PuppetTypeName PuppetTypeMethods)

The list of native types.

definedResources :: !(Map ResIdentifier SourcePos)

Horrible hack to kind of support the defined function

currentDependencyStack :: [ResIdentifier]
 

type CatalogMonad = ErrorT String (StateT ScopeState IO)

The monad all the interpreter lives in. It is ErrorT with a state.

type EdgeMap = Map (ResIdentifier, ResIdentifier) LinkInfo

This is the map of all edges associated with the FinalCatalog. The key is (source, target).

metaparameters :: Set [Char]

This is the set of meta parameters