Mikhail Korobov  committed 46fb0d8

environment defaults can be passed to define_host decorator

  • Participants
  • Parent commits f272ea3

Comments (0)

Files changed (1)

File fab_deploy/

 import os
 import posixpath
 import pprint
+from copy import deepcopy
 from re import match
 from functools import wraps
 from fabric.api import env, prefix, cd, abort, warn, puts, run
         if env.conf.VCS == vcs:
             env.conf.VCS = 'fab_deploy.vcs.' + vcs
-def define_host(host_string):
+def define_host(host_string, defaults=None):
     This decorator populates :attr:`env.hosts`, :attr:`env.conf` and
     calls :func:`update_env() <fab_deploy.utils.update_env>`::
     Decorated function should return a dict with desired :attr:`env.conf`
     def decorator(func):
         def inner(*args, **kwargs):
             env.hosts = [host_string]
-            env.conf = func(*args, **kwargs)
+            if defaults is None:
+                env.conf = dict()
+            else:
+                env.conf = deepcopy(defaults)
+            env.conf.update(func(*args, **kwargs))
         return inner
     return decorator