Skip to content

Commit

Permalink
Merge pull request #661 from cloudtools/locked-no-deps
Browse files Browse the repository at this point in the history
Locked stacks have no dependencies
  • Loading branch information
ejholmes committed Sep 25, 2018
2 parents 7dd6040 + 296ba41 commit 63b772f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
6 changes: 6 additions & 0 deletions stacker/stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ def required_by(self):

@property
def requires(self):
# By definition, a locked stack has no dependencies, because we won't
# be performing an update operation on the stack. This means, resolving
# outputs from dependencies is unnecessary.
if self.locked and not self.force:
return []

requires = set(self.definition.requires or [])

# Add any dependencies based on output lookups
Expand Down
26 changes: 26 additions & 0 deletions stacker/tests/test_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,32 @@ def test_stack_requires(self):
stack.requires,
)

def test_stack_requires_when_locked(self):
definition = generate_definition(
base_name="vpc",
stack_id=1,
variables={
"Var1": "${noop fakeStack3::FakeOutput}",
"Var2": (
"some.template.value:${output fakeStack2::FakeOutput}:"
"${output fakeStack::FakeOutput}"
),
"Var3": "${output fakeStack::FakeOutput},"
"${output fakeStack2::FakeOutput}",
},
requires=["fakeStack"],
)
stack = Stack(definition=definition, context=self.context)

stack.locked = True
self.assertEqual(len(stack.requires), 0)

# TODO(ejholmes): When the stack is in `--force`, it's not really
# locked. Maybe it would be better if `stack.locked` were false when
# the stack is in `--force`.
stack.force = True
self.assertEqual(len(stack.requires), 2)

def test_stack_requires_circular_ref(self):
definition = generate_definition(
base_name="vpc",
Expand Down

0 comments on commit 63b772f

Please sign in to comment.