From: Eugene Crosser Date: Thu, 17 Apr 2014 06:57:47 +0000 (+0400) Subject: handle "import" X-Git-Tag: 0.9.0.0~54 X-Git-Url: http://average.org/gitweb/?a=commitdiff_plain;h=553226e595c2b4ecfcb0ae9f9458c79c6d8d3627;p=pdns-pipe-nmc.git handle "import" --- diff --git a/NmcTransform.hs b/NmcTransform.hs index dc5f0ff..ef43006 100644 --- a/NmcTransform.hs +++ b/NmcTransform.hs @@ -39,17 +39,17 @@ mergeImport queryOp depth base = do base' = mbase {domImport = Nothing} -- print base if depth <= 0 then return $ Left "Nesting of imports is too deep" - else case domImport mbase of - Nothing -> return $ Right base' - Just keys -> foldM mergeImport1 (Right base') keys - where - mergeImport1 (Left err) _ = return $ Left err - mergeImport1 (Right acc) key = do - sub <- queryNmcDom queryOp key - case sub of - Left err -> return $ Left err - Right sub' -> mergeImport queryOp (depth - 1) $ - sub' `mergeNmcDom` acc + else case ((domDelegate mbase), (domImport mbase)) of + (Nothing, Nothing ) -> return $ Right base' + (Nothing, Just keys) -> foldM mergeImport1 (Right base') keys + (Just key, _ ) -> mergeImport1 (Right emptyNmcDom) key + where + mergeImport1 (Left err) _ = return $ Left err -- can never happen + mergeImport1 (Right acc) key = do + sub <- queryNmcDom queryOp key + case sub of + Left err -> return $ Left err + Right sub' -> mergeImport queryOp (depth - 1) $ sub' `mergeNmcDom` acc -- | If there is an element in the map with key "", merge the contents -- and remove this element. Do this recursively.