combineProperties no longer stops when a property fails; now it continues trying to satisfy all properties on the list before propigating the failure.

Audited all of my calls to combineProperties and they should be fine with
this behavior.. which suggests it's the right behavior.
This commit is contained in:
Joey Hess 2014-06-07 00:14:05 -04:00
parent 969db1ed56
commit 582be8ebe0
4 changed files with 12 additions and 12 deletions

8
debian/changelog vendored
View File

@ -1,3 +1,11 @@
propellor (0.7.0) UNRELEASED; urgency=medium
* combineProperties no longer stops when a property fails; now it continues
trying to satisfy all properties on the list before propigating the
failure.
-- Joey Hess <joeyh@debian.org> Sat, 07 Jun 2014 00:12:44 -0400
propellor (0.6.0) unstable; urgency=medium propellor (0.6.0) unstable; urgency=medium
* Docker containers now propagate DNS attributes out to the host they're * Docker containers now propagate DNS attributes out to the host they're

View File

@ -1,5 +1,5 @@
Name: propellor Name: propellor
Version: 0.6.0 Version: 0.7.0
Cabal-Version: >= 1.6 Cabal-Version: >= 1.6
License: BSD3 License: BSD3
Maintainer: Joey Hess <joey@kitenet.net> Maintainer: Joey Hess <joey@kitenet.net>

View File

@ -26,7 +26,8 @@ propertyList :: Desc -> [Property] -> Property
propertyList desc ps = Property desc (ensureProperties ps) (combineAttrs ps) propertyList desc ps = Property desc (ensureProperties ps) (combineAttrs ps)
-- | Combines a list of properties, resulting in one property that -- | Combines a list of properties, resulting in one property that
-- ensures each in turn, stopping on failure. -- ensures each in turn. Does not stop on failure; does propigate
-- overall success/failure.
combineProperties :: Desc -> [Property] -> Property combineProperties :: Desc -> [Property] -> Property
combineProperties desc ps = Property desc (go ps NoChange) (combineAttrs ps) combineProperties desc ps = Property desc (go ps NoChange) (combineAttrs ps)
where where
@ -37,15 +38,6 @@ combineProperties desc ps = Property desc (go ps NoChange) (combineAttrs ps)
FailedChange -> return FailedChange FailedChange -> return FailedChange
_ -> go ls (r <> rs) _ -> go ls (r <> rs)
-- | Does not stop on failure (but does propigate failure at the end).
combineProperties' :: Desc -> [Property] -> Property
combineProperties' desc ps = Property desc (go ps NoChange) (combineAttrs ps)
where
go [] rs = return rs
go (l:ls) rs = do
r <- ensureProperty l
go ls (r <> rs)
-- | Combines together two properties, resulting in one property -- | Combines together two properties, resulting in one property
-- that ensures the first, and if the first succeeds, ensures the second. -- that ensures the first, and if the first succeeds, ensures the second.
-- The property uses the description of the first property. -- The property uses the description of the first property.

View File

@ -97,7 +97,7 @@ hostKey keytype = combineProperties desc
-- | Sets up a user with a ssh private key and public key pair -- | Sets up a user with a ssh private key and public key pair
-- from the site's PrivData. -- from the site's PrivData.
keyImported :: SshKeyType -> UserName -> Property keyImported :: SshKeyType -> UserName -> Property
keyImported keytype user = combineProperties' desc keyImported keytype user = combineProperties desc
[ property desc (install writeFile (SshPubKey keytype user) ".pub") [ property desc (install writeFile (SshPubKey keytype user) ".pub")
, property desc (install writeFileProtected (SshPrivKey keytype user) "") , property desc (install writeFileProtected (SshPrivKey keytype user) "")
] ]