Permalink
Browse files

FEATURE: TENTATIVE support for aliases.

  • Loading branch information...
1 parent 8fedba5 commit 3c358797c70a7c3d68f4a896d2ae40fdc60f4b75 @bartavelle committed Dec 18, 2012
Showing with 20 additions and 10 deletions.
  1. +1 −0 Changelog
  2. +19 −10 Puppet/Interpreter/Catalog.hs
View
@@ -4,6 +4,7 @@ v0.3.3 ()
* Started cleaning imports ...
* It is now possible to write "top level" functions in lua.
* Function getvar (stdlib)
+ * TENTATIVE support for aliases.
Bugs fixed
* Fixed a ton of problems related to exported resources and relations.
* Minor fix about zonerecord.
@@ -277,7 +277,12 @@ finalResolution cat = do
-- collectedRemoteD resource names SHOULD be resolved (coming from
-- PuppetDB)
let addCollectedRemoteResource :: CResource -> CatalogMonad ()
- addCollectedRemoteResource (CResource _ (Right cn) ct _ _ cp) = addDefinedResource (ct, cn) cp
+ addCollectedRemoteResource (CResource _ (Right cn) ct prms _ cp) = do
+ addDefinedResource (ct, cn) cp
+ case Map.lookup (Right "alias") prms of
+ Just (Right (ResolvedString s)) -> addDefinedResource (ct, s) cp
+ Just x -> throwPosError ("Alias must be a single string, not " ++ show x)
+ _ -> return ()
addCollectedRemoteResource x = throwPosError $ "finalResolution/addCollectedRemoteResource the remote resource name was not properly defined: " ++ show (crname x)
mapM_ addCollectedRemoteResource collectedRemoteD
let collected = collectedLocalD ++ collectedRemoteD
@@ -527,16 +532,20 @@ addResource :: String -> [(Expression, Expression)] -> Virtuality -> SourcePos -
addResource rtype parameters virtuality position grname = do
resid <- getNextId
rparameters <- addParameters Map.empty parameters
- srname <- case grname of
+ case grname of
Right e -> do
- rse <- rstring e
- getPos >>= addDefinedResource (rtype, rse)
- return $ Right rse
- Left e -> return $ Left e
- (curdeptype, curdepname) <- fmap (head . currentDependencyStack) get
- let defaultdependency = (RRequire, Right (ResolvedString curdeptype), Right (ResolvedString curdepname))
- addUnresRel ([defaultdependency], (rtype, srname), UNormal, position)
- return [CResource resid srname rtype rparameters virtuality position]
+ rse <- rstring e
+ curpos <- getPos
+ addDefinedResource (rtype, rse) curpos
+ case Map.lookup (Right "alias") rparameters of
+ Just (Right (ResolvedString s)) -> addDefinedResource (rtype, s) curpos
+ Just x -> throwPosError ("Alias must be a single string, not " ++ show x)
+ _ -> return ()
+ (curdeptype, curdepname) <- fmap (head . currentDependencyStack) get
+ let defaultdependency = (RRequire, Right (ResolvedString curdeptype), Right (ResolvedString curdepname))
+ addUnresRel ([defaultdependency], (rtype, Right rse), UNormal, position)
+ return [CResource resid (Right rse) rtype rparameters virtuality position]
+ Left r -> throwPosError ("Could not determine the current resource name: " ++ show r)
-- node
evaluateStatements :: Statement -> CatalogMonad Catalog

0 comments on commit 3c35879

Please sign in to comment.