Skip to content

Commit

Permalink
Set file as the default template handler type (#1127)
Browse files Browse the repository at this point in the history
Now that we have template handlers we want to encourage users to
migrate from using `template_path` to `template` in their Sceptre
stack config files.  To make that transition easier we set the
default `template` type to 'file' which will save the user from
having to specify a full `template` block if they just want to
load a file from disk
  • Loading branch information
zaro0508 committed Oct 15, 2021
1 parent 22a4017 commit 7b309ca
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion docs/_source/docs/template_handlers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ file
Loads a template from disk. Supports JSON, YAML, Jinja2 and Python files. Will be used if the ``template_path`` Stack
config property is set, for backwards compatibility reasons.

This is the default template handler type, setting the ``file`` type is option.

Syntax:

.. code-block:: yaml
Expand All @@ -41,7 +43,6 @@ Example:
.. code-block:: yaml
template:
type: file
path: storage/bucket.yaml
s3
Expand Down
2 changes: 2 additions & 0 deletions sceptre/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ def __init__(

self.name = name
self.handler_config = handler_config
if self.handler_config is not None and self.handler_config.get('type') is None:
self.handler_config['type'] = 'file'
self.sceptre_user_data = sceptre_user_data
self.stack_group_config = stack_group_config
self.connection_manager = connection_manager
Expand Down
11 changes: 11 additions & 0 deletions tests/test_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@ def setup_method(self, test_method):
connection_manager=connection_manager,
)

def test_initialise_template_default_handler_type(self):
template = Template(
name="template_name",
handler_config={"path": "/folder/template.py"},
sceptre_user_data={},
stack_group_config={},
connection_manager={},
)

assert template.handler_config == {"type": "file", "path": "/folder/template.py"}

def test_initialise_template(self):
assert self.template.handler_config == {"type": "file", "path": "/folder/template.py"}
assert self.template.name == "template_name"
Expand Down

0 comments on commit 7b309ca

Please sign in to comment.