Skip to content

Commit

Permalink
Added a new environment variable to change the default Failure error …
Browse files Browse the repository at this point in the history
…heading. #191
  • Loading branch information
eerkunt committed Feb 3, 2020
1 parent 74b61e3 commit 028d8c9
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
10 changes: 7 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# CHANGELOG

## 1.1.2 (2020-02-01)

## 1.1.4 (2020-02-03)
* Added a new environment variable `TFC_ERROR` to change the name of the default `Failure` error message.

### 1.1.2 (2020-02-01)
* Cosmetic and some dependency fixes.

## 1.1.2 (2020-02-01)
### 1.1.2 (2020-02-01)
* Fixed an internal problem where a security group step will fail if there is no `cidr_blocks` definition within the plan. [#198](https://github.com/eerkunt/terraform-compliance/issues/198)

## 1.1.0 (2020-02-01)
### 1.1.0 (2020-02-01)

* New step: [Then it must have "something" referenced](https://terraform-compliance.com/pages/bdd-references/then.html#then-it-must-have-something-referenced). [#195](https://github.com/eerkunt/terraform-compliance/issues/195))
* New step: [Then I flatten all values found](https://terraform-compliance.com/pages/bdd-references/then.html#then-i-flatten-all-values-found). [#193](https://github.com/eerkunt/terraform-compliance/issues/193))
Expand Down
19 changes: 19 additions & 0 deletions docs/pages/usage/environment_variables.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
layout: default
title: Env Variables
nav_order: 2
has_children: false
parent: Usage
---

# Environment Variables

{: .d-inline-block }
1.1.3+
{: .label .label-blue}

`terraform-compliance` allows you to override some internals.

| Variable | Description |
|----------|-------------|
| TFC_ERROR | This variable will change the `Failure` error that is given by `terraform-compliance` by default. It will not change any functionality other than changing the error message.
6 changes: 4 additions & 2 deletions terraform_compliance/common/error_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import colorful
from ast import literal_eval
from mock import MagicMock
import os


class WrapperError(Exception):
Expand All @@ -30,8 +31,9 @@ def __init__(self, step_obj, message, exception=Failure):
else:
self.exit_on_failure = literal_eval(world.config.user_data['exit_on_failure'])
self.no_failure = literal_eval(world.config.user_data['no_failure'])
self.exception = exception
self.exception_name = exception.__name__
_TFC_ERROR = os.environ.get('TFC_ERROR')
self.exception = exception if _TFC_ERROR is None else type(_TFC_ERROR, (Exception, ), {})
self.exception_name = exception.__name__ if _TFC_ERROR is None else _TFC_ERROR
self.step_obj = step_obj

self._process()
Expand Down

0 comments on commit 028d8c9

Please sign in to comment.