terraformtestinglib.linting package

Submodules

terraformtestinglib.linting.linting module

Main code for linting.

class terraformtestinglib.linting.linting.LintingResource(filename, resource_type, name, data, original_data)[source]

Bases: object

Manages a resource and provides validation capabilities..

register_positioning_set(positioning_set)[source]

Registers the set of rules with the Resource.

Parameters:positioning_set (dict) – A dictionary with the rules for the positioning convention
Returns:None
register_rules_set(rules_set)[source]

Registers the set of rules with the Resource.

Parameters:rules_set (dict) – A dictionary with the rules for the naming convention
Returns:None
validate()[source]

Validates the resource according to the appropriate rule.

Returns:True upon completion
class terraformtestinglib.linting.linting.Rule(data)[source]

Bases: object

Handles the rule object providing validation capabilities.

errors

List of errors found.

Returns: The errors found

validate(resource_type, resource_name, resource_data, original_data)[source]

Validates the given resource based on the ruleset.

Parameters:
  • resource_type (basestring) – The type of the resource
  • resource_name (basestring) – The name of the resource
  • resource_data (dict) – The interpolated data of the resource
  • original_data (dict) – The original data of the resource, before the interpolation
Returns:

True on successful validation, False otherwise

class terraformtestinglib.linting.linting.RuleSet(rules)[source]

Bases: object

Manages the rules as a group and can search them by name.

get_rule_for_resource(resource_name)[source]

Retrieves the rule for the resource name.

Parameters:resource_name (basestring) – The resource type to retrieve the rule for
Returns:The rule corresponding with the resource type if found, None otherwise
class terraformtestinglib.linting.linting.Stack(configuration_path, naming_file_path, positioning_file_path=None, global_variables_file_path=None, file_to_skip_for_positioning=None, raise_on_missing_variable=True, environment_variables=None)[source]

Bases: terraformtestinglib.terraformtestinglib.Parser

Manages a stack as a collection of resources that can be checked for name convention.

errors

The errors of the validation of the resources of the stack.

Returns:list of possible linting errors
Return type:errors (ResourceError|FilenameError)
validate()[source]

Validates all the resources of the stack.

Returns:None

Module contents

terraformtestinglib.linting package.

Import all parts from terraformtestinglib.linting here