Skip to content

Commit

Permalink
Merge 70dc7f7 into ed528fc
Browse files Browse the repository at this point in the history
  • Loading branch information
patricksanders committed Feb 12, 2021
2 parents ed528fc + 70dc7f7 commit c914322
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions repokid/commands/schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def _schedule_repo(
86400 * config.get("repo_schedule_period_days", 7)
)
for role in roles:
role.fetch(fetch_aa_data=True)
if not role.aa_data:
LOGGER.warning("Not scheduling %s; missing Access Advisor data", role.arn)
continue
Expand Down
9 changes: 8 additions & 1 deletion repokid/role.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,12 @@ def fetch_aa_data(self) -> None:
except NotFoundError:
self.aa_data = []

def fetch(self, fields: Optional[List[str]] = None, update: bool = True) -> None:
def fetch(
self,
fields: Optional[List[str]] = None,
update: bool = True,
fetch_aa_data: bool = False,
) -> None:
if self._dirty:
raise IntegrityError(
"role object has unsaved modifications, fetching may overwrite changes"
Expand All @@ -302,6 +307,8 @@ def fetch(self, fields: Optional[List[str]] = None, update: bool = True) -> None
"missing role_id or role_name and account on Role instance"
)

if fetch_aa_data:
self.fetch_aa_data()
if update:
self.update(stored_role_data, store=False)
self._updated_fields - set(stored_role_data.keys())
Expand Down
2 changes: 2 additions & 0 deletions tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ def test_repokid_display_roles(

@patch("repokid.hooks.call_hooks")
@patch("repokid.commands.role_cache.Role.store")
@patch("repokid.role.Role.fetch")
@patch("repokid.commands.role.RoleList.from_ids")
@patch("repokid.commands.schedule.get_all_role_ids_for_account")
@patch("time.time")
Expand All @@ -424,6 +425,7 @@ def test_schedule_repo(
mock_time,
mock_get_all_role_ids_for_account,
mock_role_list_from_ids,
mock_fetch,
mock_role_store,
mock_call_hooks,
):
Expand Down

0 comments on commit c914322

Please sign in to comment.