Skip to content

Commit

Permalink
Issue manheim#53 - have mugc use configured function prefix instead o…
Browse files Browse the repository at this point in the history
…f hard-coded default
  • Loading branch information
jantman committed Jul 29, 2020
1 parent 5a6975b commit d0e3675
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ Changelog

* Fixes `#53 <https://github.com/manheim/manheim-c7n-tools/issues/53>`__

* Add ``function_prefix`` option to ``manheim-c7n-tools.yml`` to allow passing this option to mugc.
* Add ``function_prefix`` option to ``manheim-c7n-tools.yml`` to allow passing this option to mugc. Default it to the current/default ``custodian-``.
* Have :py:class:`~.runner.MugcStep` use configured ``function_prefix`` instead of hard-coded ``custodian-``.

* Switch from deprecated pep8 / pytest-pep8 to pycodestyle / pytest-pycodestyle.

Expand Down
9 changes: 5 additions & 4 deletions manheim_c7n_tools/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from shutil import rmtree
import os
from copy import deepcopy
import re

from sphinx.cmd.build import main as sphinx_main
import jsonschema
Expand Down Expand Up @@ -181,8 +182,8 @@ def run(self):
conf = Config.empty(
config_files=['custodian_%s.yml' % self.region_name],
regions=[self.region_name],
prefix='custodian-',
policy_regex='^custodian-.*',
prefix=self.config.function_prefix,
policy_regex='^' + re.escape(self.config.function_prefix) + '.*',
assume=None,
policy_filter=None,
log_group=None,
Expand Down Expand Up @@ -212,8 +213,8 @@ def dryrun(self):
conf = Config.empty(
config_files=['custodian_%s.yml' % self.region_name],
regions=[self.region_name],
prefix='custodian-',
policy_regex='^custodian-.*',
prefix=self.config.function_prefix,
policy_regex='^' + re.escape(self.config.function_prefix) + '.*',
assume=None,
policy_filter=None,
log_group=None,
Expand Down
14 changes: 10 additions & 4 deletions manheim_c7n_tools/tests/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ def test_run_in_region(self):
class TestMugcStep(StepTester):

def test_run(self):
type(self.m_conf).function_prefix = PropertyMock(
return_value='foobar-'
)
mock_pol1 = Mock(provider_name='foo')
mock_pol2 = Mock(provider_name='aws')
mock_pol3 = Mock(provider_name='azure')
Expand All @@ -149,8 +152,8 @@ def test_run(self):
call(
config_files=['custodian_rName.yml'],
regions=['rName'],
prefix='custodian-',
policy_regex='^custodian-.*',
prefix='foobar-',
policy_regex='^foobar\\-.*',
assume=None,
policy_filter=None,
log_group=None,
Expand All @@ -175,6 +178,9 @@ def test_run(self):
]

def test_dryrun(self):
type(self.m_conf).function_prefix = PropertyMock(
return_value='foobar-'
)
mock_pol1 = Mock(provider_name='foo')
mock_pol2 = Mock(provider_name='aws')
mock_pol3 = Mock(provider_name='azure')
Expand All @@ -201,8 +207,8 @@ def test_dryrun(self):
call(
config_files=['custodian_rName.yml'],
regions=['rName'],
prefix='custodian-',
policy_regex='^custodian-.*',
prefix='foobar-',
policy_regex='^foobar\\-.*',
assume=None,
policy_filter=None,
log_group=None,
Expand Down

0 comments on commit d0e3675

Please sign in to comment.