From 9d682a8340ce8b8ada18dd378a9869a71a279427 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Wed, 3 Apr 2019 07:49:03 -0700 Subject: rename Propellor.Property.{PropellorRepo -> Localdir} This is to accommodate a new property in that module which is about /usr/local/propellor, but not only about the git repo there. Signed-off-by: Sean Whitton --- src/Propellor/Property/Localdir.hs | 31 +++++++++++++++++++++++++++++++ src/Propellor/Property/PropellorRepo.hs | 29 ----------------------------- src/Propellor/Spin.hs | 2 +- 3 files changed, 32 insertions(+), 30 deletions(-) create mode 100644 src/Propellor/Property/Localdir.hs delete mode 100644 src/Propellor/Property/PropellorRepo.hs (limited to 'src/Propellor') diff --git a/src/Propellor/Property/Localdir.hs b/src/Propellor/Property/Localdir.hs new file mode 100644 index 00000000..5d8e2033 --- /dev/null +++ b/src/Propellor/Property/Localdir.hs @@ -0,0 +1,31 @@ +{-# LANGUAGE DeriveDataTypeable #-} + +-- | Properties to manipulate propellor's @/usr/local/propellor@ on spun hosts + +module Propellor.Property.Localdir 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. +-- +-- 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. +-- +-- 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, Typeable) diff --git a/src/Propellor/Property/PropellorRepo.hs b/src/Propellor/Property/PropellorRepo.hs deleted file mode 100644 index 825efdfd..00000000 --- a/src/Propellor/Property/PropellorRepo.hs +++ /dev/null @@ -1,29 +0,0 @@ -{-# LANGUAGE DeriveDataTypeable #-} - -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. --- --- 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. --- --- 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, Typeable) diff --git a/src/Propellor/Spin.hs b/src/Propellor/Spin.hs index 1fb4d7e4..7f479f10 100644 --- a/src/Propellor/Spin.hs +++ b/src/Propellor/Spin.hs @@ -29,7 +29,7 @@ import Propellor.Gpg import Propellor.Bootstrap import Propellor.Types.CmdLine import Propellor.Types.Info -import Propellor.Property.PropellorRepo (OriginUrl(..)) +import Propellor.Property.Localdir (OriginUrl(..)) import qualified Propellor.Shim as Shim import Utility.SafeCommand import Utility.Process.NonConcurrent -- cgit v1.2.3