Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add add_output helper method on Blueprints #611

Merged
merged 1 commit into from
Jun 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion stacker/blueprints/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
from stacker.variables import Variable

from troposphere import (
Output,
Parameter,
Ref,
Template
Template,
)

from ..exceptions import (
Expand Down Expand Up @@ -522,6 +523,15 @@ def set_template_description(self, description):
"""
self.template.add_description(description)

def add_output(self, name, value):
"""Simple helper for adding outputs.

Args:
name (str): The name of the output to create.
value (str): The value to put in the output.
"""
self.template.add_output(Output(name, Value=value))

@property
def requires_change_set(self):
"""Returns true if the underlying template has transforms."""
Expand Down
19 changes: 19 additions & 0 deletions stacker/tests/blueprints/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,25 @@ def create_template(self):
)


class TestBaseBlueprint(unittest.TestCase):
def test_add_output(self):
output_name = "MyOutput1"
output_value = "OutputValue"

class TestBlueprint(Blueprint):
VARIABLES = {}

def create_template(self):
self.template.add_version('2010-09-09')
self.template.add_description('TestBlueprint')
self.add_output(output_name, output_value)

bp = TestBlueprint(name="test", context=mock_context())
bp.render_template()
self.assertEqual(bp.template.outputs[output_name].properties["Value"],
output_value)


class TestVariables(unittest.TestCase):

def test_defined_variables(self):
Expand Down