How to use the runway.cfngin.hooks.utils.handle_hooks function in runway

To help you get started, we’ve selected a few runway examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github onicagroup / runway / tests / cfngin / hooks / test_utils.py View on Github external
def test_missing_required_hook_method(self):
        """Test missing required hook method."""
        hooks = [{"path": "runway.cfngin.hooks.blah", "required": True}]
        with self.assertRaises(AttributeError):
            handle_hooks("missing", hooks, self.provider, self.context)
github onicagroup / runway / tests / cfngin / hooks / test_utils.py View on Github external
def test_default_required_hook(self):
        """Test default required hook."""
        hooks = [Hook({"path": "runway.cfngin.hooks.blah"})]
        with self.assertRaises(AttributeError):
            handle_hooks("missing", hooks, self.provider, self.context)
github onicagroup / runway / tests / cfngin / hooks / test_utils.py View on Github external
def test_hook_failure(self):
        """Test hook failure."""
        hooks = [
            Hook({"path": "tests.cfngin.hooks.test_utils.fail_hook",
                  "required": True})]
        with self.assertRaises(SystemExit):
            handle_hooks("fail", hooks, self.provider, self.context)
        hooks = [{"path": "tests.cfngin.hooks.test_utils.exception_hook",
                  "required": True}]
        with self.assertRaises(Exception):
            handle_hooks("fail", hooks, self.provider, self.context)
        hooks = [
            Hook({"path": "tests.cfngin.hooks.test_utils.exception_hook",
                  "required": False})]
        # Should pass
        handle_hooks("ignore_exception", hooks, self.provider, self.context)
github onicagroup / runway / tests / cfngin / hooks / test_utils.py View on Github external
def test_context_provided_to_hook(self):
        """Test context provided to hook."""
        hooks = [
            Hook({"path": "tests.cfngin.hooks.test_utils.context_hook",
                  "required": True})]
        handle_hooks("missing", hooks, "us-east-1", self.context)
github onicagroup / runway / tests / cfngin / hooks / test_utils.py View on Github external
def test_missing_required_hook(self):
        """Test missing required hook."""
        hooks = [Hook({"path": "not.a.real.path", "required": True})]
        with self.assertRaises(ImportError):
            handle_hooks("missing", hooks, self.provider, self.context)
github onicagroup / runway / runway / cfngin / actions / destroy.py View on Github external
def post_run(self, **kwargs):
        """Any steps that need to be taken after running the action."""
        post_destroy = self.context.config.post_destroy
        if not kwargs.get('outline') and post_destroy:
            handle_hooks(
                stage="post_destroy",
                hooks=post_destroy,
                provider=self.provider,
                context=self.context)
github onicagroup / runway / runway / cfngin / actions / build.py View on Github external
def handle_hooks(stage, hooks, provider, context, dump, outline):
    """Handle pre/post hooks.

    Args:
        stage (str): The name of the hook stage - pre_build/post_build.
        hooks (list): A list of dictionaries containing the hooks to execute.
        provider (:class:`runway.cfngin.providers.base.BaseProvider`): The provider
            the current stack is using.
        context (:class:`runway.cfngin.context.Context`): The current CFNgin
            context.
        dump (bool): Whether running with dump set or not.
        outline (bool): Whether running with outline set or not.

    """
    if not outline and not dump and hooks:
        utils.handle_hooks(
            stage=stage,
            hooks=hooks,
            provider=provider,
            context=context
        )