Commit Graph

16 Commits

Author SHA1 Message Date
Joey Hess 0ee04ecc43 GADT properties seem to work (untested)
* Property has been converted to a GADT, and will be Property NoInfo
  or Property HasInfo.
  This was done to make sure that ensureProperty is only used on
  properties that do not have Info.
  Transition guide:
  - Change all "Property" to "Property NoInfo" or "Property WithInfo"
    (The compiler can tell you if you got it wrong!)
  - To construct a RevertableProperty, it is useful to use the new
    (<!>) operator
  - Constructing a list of properties can be problimatic, since
    Property NoInto and Property WithInfo are different types and cannot
    appear in the same list. To deal with this, "props" has been added,
    and can built up a list of properties of different types,
    using the same (&) and (!) operators that are used to build
    up a host's properties.
2015-01-24 22:38:51 -04:00
Joey Hess 45c94ffdd7 moving to using the GADT
The problem this exposes has to do with requires. As implemented,
requires yields either a Property HasInfo or a Property NoInfo depending
on its inputs. That works. But look what happens when it's used:

*Propellor.Types> let foo = IProperty "foo" (return NoChange) mempty mempty
*Propellor.Types> let bar = IProperty "bar" (return NoChange) mempty mempty
*Propellor.Types> foo `requires` bar

<interactive>:17:5:
    No instance for (Requires (Property HasInfo) (Property HasInfo) r0)
      arising from a use of `requires'
    The type variable `r0' is ambiguous
    Possible fix: add a type signature that fixes these type variable(s)
    Note: there is a potential instance available:
      instance Requires
                 (Property HasInfo) (Property HasInfo) (Property HasInfo)
        -- Defined at Propellor/Types.hs:167:10
    Possible fix:
      add an instance declaration for
      (Requires (Property HasInfo) (Property HasInfo) r0)
    In the expression: foo `requires` bar
    In an equation for `it': it = foo `requires` bar

This can be avoided by specifying the result type:

*Propellor.Types> (foo `requires` bar) :: Property HasInfo
property "foo"

But then when multiple `requires` are given, the result type has to be
given each time:

*Propellor.Types> (foo `requires` bar `requires` bar) :: Property HasInfo
<interactive>:22:6:
    No instance for (Requires (Property HasInfo) (Property HasInfo) x0)
      arising from a use of `requires'
    The type variable `x0' is ambiguous
    Possible fix: add a type signature that fixes these type variable(s)
    Note: there is a potential instance available:
      instance Requires
                 (Property HasInfo) (Property HasInfo) (Property HasInfo)
        -- Defined at Propellor/Types.hs:167:10
    Possible fix:
      add an instance declaration for
      (Requires (Property HasInfo) (Property HasInfo) x0)
    In the first argument of `requires', namely `foo `requires` bar'
    In the expression:
        (foo `requires` bar `requires` bar) :: Property HasInfo
    In an equation for `it':
        it = (foo `requires` bar `requires` bar) :: Property HasInfo

<interactive>:22:21:
    No instance for (Requires x0 (Property HasInfo) (Property HasInfo))
      arising from a use of `requires'
    The type variable `x0' is ambiguous
    Possible fix: add a type signature that fixes these type variable(s)
    Note: there are several potential instances:
      instance Requires
                 (Property NoInfo) (Property HasInfo) (Property HasInfo)
        -- Defined at Propellor/Types.hs:175:10
      instance Requires
                 (Property HasInfo) (Property HasInfo) (Property HasInfo)
        -- Defined at Propellor/Types.hs:167:10
    Possible fix:
      add an instance declaration for
      (Requires x0 (Property HasInfo) (Property HasInfo))
    In the expression:
        (foo `requires` bar `requires` bar) :: Property HasInfo
    In an equation for `it':
        it = (foo `requires` bar `requires` bar) :: Property HasInfo

*Propellor.Types> (((foo `requires` bar) :: Property HasInfo) `requires` bar) :: Property HasInfo
property "foo"

Yuggh!
2015-01-24 16:54:49 -04:00
Joey Hess 414ee7eee6 added GADT to determine between a property with info and without
Not yet used
2015-01-24 16:53:59 -04:00
Joey Hess 603e6d3406 split out types to improve haddock for Propellor.Types 2015-01-19 15:09:03 -04:00
Joey Hess afee550e70 Property tree
Properties now form a tree, instead of the flat list used before.

This simplifies propigation of Info from the Properties used inside a
container to the outer host; the Property that docks the container on the
host can just have as child properties all the inner Properties, and their
Info can then be gathered recursively. (Although in practice it still needs
to be filtered, since not all Info should propigate out of a container.)

Note that there is no change to how Properties are actually satisfied.
Just because a Property lists some child properties, this does not mean
they always have their propertySatisfy actions run. It's still up to the
parent property to run those actions.

That's necessary so that a container's properties can be satisfied inside
it, not outside. It also allows property combinators to
add the combined Properties to their childProperties list, even if,
like onChange, they don't always run the child properties at all.

Testing: I tested that the exact same Info is calculated before and after
this change, for every Host in my config file.
2015-01-18 18:46:38 -04:00
Joey Hess 8e442f0656 DNS records for hosts with known ssh public keys now automatically include SSHFP records. 2015-01-04 19:24:18 -04:00
Joey Hess 52664e6220 sshPubKey is renamed to Ssh.pubKey 2015-01-04 15:36:53 -04:00
Joey Hess bb7b8e7891 add $INCLUDE of pubkeys before zone file is written, to avoid pogoing 2015-01-04 14:22:44 -04:00
Joey Hess f36443755e
propellor spin 2015-01-04 14:05:42 -04:00
Joey Hess 8172f243d7 DNS WIP 2015-01-04 12:44:05 -04:00
Joey Hess b50f33395e update docs 2015-01-01 13:57:13 -04:00
Joey Hess 5e4c57652c fix docker container provisioning
Since the containers are no longer on the host list, they were not found
while provisioning, oops.

To fix, had to add to a host's info a map of the containers docked to it.

Unfortunately, that required Propellor.Types.Info be glommed into
Propellor.Types, since it needed to refer to Host.
2014-11-20 00:21:40 -04:00
Joey Hess 73a75cbefc Fix loop when a docker host that does not exist was docked.
The problem is it fell back to looking for an alias for the bad hostname,
but to get the aliases, it needs to know which hosts are docked where,
so looped.
2014-10-23 12:11:43 -04:00
Joey Hess 3d617fd98b
propellor spin 2014-07-23 12:33:11 -04:00
Joey Hess ecc275cfeb
propellor spin 2014-07-23 12:23:44 -04:00
Joey Hess fc49d75e4f Attr is renamed to Info. 2014-06-09 01:47:11 -04:00