summaryrefslogtreecommitdiff
path: root/src/Propellor/Property/PropellorRepo.hs
diff options
context:
space:
mode:
authorJoey Hess2017-10-04 14:04:49 -0400
committerJoey Hess2017-10-04 14:04:49 -0400
commit2865b4c13b699e3fb46729b983f80da59eb8d178 (patch)
treeca3418d8e0af14e11ea7452fcaae0545451ec89d /src/Propellor/Property/PropellorRepo.hs
parent6714b513d2b7c254953cc25a7eddc50e15e22af5 (diff)
override deploy url with PropellorRepo.hasOriginUrl info
* Made the PropellorRepo.hasOriginUrl property override the repository url that --spin passes to a host. * PropellorRepo.hasOriginUrl type changed to include HasInfo. (API change) This commit was sponsored by Jake Vosloo on Patreon.
Diffstat (limited to 'src/Propellor/Property/PropellorRepo.hs')
-rw-r--r--src/Propellor/Property/PropellorRepo.hs30
1 files changed, 19 insertions, 11 deletions
diff --git a/src/Propellor/Property/PropellorRepo.hs b/src/Propellor/Property/PropellorRepo.hs
index e60e7848..504ff395 100644
--- a/src/Propellor/Property/PropellorRepo.hs
+++ b/src/Propellor/Property/PropellorRepo.hs
@@ -2,18 +2,26 @@ module Propellor.Property.PropellorRepo where
import Propellor.Base
import Propellor.Git.Config
+import Propellor.Types.Info
-- | Sets the url to use as the origin of propellor's git repository.
--
--- When propellor --spin is used to update a host, the url is taken from
--- the repository that --spin is run in, and passed to the host. So, you
--- don't need to specifiy this property then.
+-- By default, the url is taken from the deploy or origin remote of
+-- the repository that propellor --spin is run in. Setting this property
+-- overrides that default behavior with a different url.
--
--- This property is useful when hosts are being updated without using
--- --spin, eg when using the `Propellor.Property.Cron.runPropellor` cron job.
-hasOriginUrl :: String -> Property UnixLike
-hasOriginUrl u = property ("propellor repo url " ++ u) $ do
- curru <- liftIO getRepoUrl
- if curru == Just u
- then return NoChange
- else makeChange $ setRepoUrl u
+-- When hosts are being updated without using -- --spin, eg when using
+-- the `Propellor.Property.Cron.runPropellor` cron job, this property can
+-- be set to redirect them to a new git repository url.
+hasOriginUrl :: String -> Property (HasInfo + UnixLike)
+hasOriginUrl u = setInfoProperty p (toInfo (InfoVal (OriginUrl u)))
+ where
+ p :: Property UnixLike
+ p = property ("propellor repo url " ++ u) $ do
+ curru <- liftIO getRepoUrl
+ if curru == Just u
+ then return NoChange
+ else makeChange $ setRepoUrl u
+
+newtype OriginUrl = OriginUrl String
+ deriving (Show)