fab-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fab-user] Does require() still make sense?


From: Christian Vest Hansen
Subject: [Fab-user] Does require() still make sense?
Date: Sun, 26 Oct 2008 14:30:34 +0200

In light of the new annotations and the changes to how we execute
commands, let's consider this snip of a fabfile:

def production():
    "Primes the deployment procedure to execute against production."
    config.fab_hosts = ['localhost']

def staging():
    "Primes the deployment procedure to execute against staging."
    config.fab_hosts = ['127.0.0.1']

It is idiomatic Fabric to use commands for specifying the target
environment of a deployment.

But with the changes to how we execute commands, we are now much more
eager to connect and the check for the existance of a `fab_hosts` (and
a need for one) is now done earlier than it used to (in
fabric.py:1300-13002).

So much that this breaks:

def deploy():
    require('fab_hosts', provided_by=[production, staging])
    sudo("whoami")

However, we've also grown an alternative method of providing the same
functionality that works:

@requires('fab_hosts', provided_by=[production, staging])
def deploy():
    sudo("whoami") # the final deployment step.

So that got me thinking; why do we still have `require()`? With the
decorator, we now have two ways to do one thing, except one of these
ways is broken. I suggest that we remove `require()` let the decorator
be the only way to do this.


-- 
Venlig hilsen / Kind regards,
Christian Vest Hansen.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]