Skip to content

Commit

Permalink
Fixed IAMbic logger interference with Starfleet's
Browse files Browse the repository at this point in the history
- The IAMbic logger was replacing the Starfleet logger. Mocked out
  the IAMbic logger so that Starfleet's logger remains the primary logger.
  • Loading branch information
Mike Grima committed Nov 22, 2023
1 parent 0f7a779 commit 112dde5
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/starfleet/worker_ships/plugins/iam/role_ship.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
:License: See the LICENSE file for details
:Author: Mike Grima <michael.grima@gemini.com>
"""
# pylint: disable=too-many-locals,too-many-statements,too-many-branches
# pylint: disable=too-many-locals,too-many-statements,too-many-branches,wrong-import-position,wrong-import-order
import asyncio
import json
import os
Expand All @@ -19,15 +19,14 @@
import click
import yaml
from click import Context
from iambic.core.context import ctx as iambic_ctx
from iambic.plugins.v0_1_0.aws.iam.role.models import AwsIamRoleTemplate
from iambic.plugins.v0_1_0.aws.models import AWSAccount

from marshmallow import ValidationError as MarshmallowError
from pydantic import ValidationError as PydanticError

from starfleet.account_index.loader import ACCOUNT_INDEX
from starfleet.utils.configuration import STARFLEET_CONFIGURATION
from starfleet.utils.logging import LOGGER

from starfleet.worker_ships.cli_utils import StarfleetAccountCommand, StarfleetSingleInvokeCommand
from starfleet.worker_ships.lambda_utils import worker_lambda
from starfleet.worker_ships.plugins.iam.schemas import (
Expand All @@ -39,6 +38,19 @@
)
from starfleet.worker_ships.ship_schematics import StarfleetWorkerShip, FanOutStrategy, AlertPriority

# ####
# Mock out the iambic logger, as it's bossy and override's Starfleet's:
from unittest import mock

mock.patch("iambic.core.logger.log", LOGGER).start()

# Now continue to import the rest:
from iambic.core.context import ctx as iambic_ctx # noqa: E402
from iambic.plugins.v0_1_0.aws.iam.role.models import AwsIamRoleTemplate # noqa: E402
from iambic.plugins.v0_1_0.aws.models import AWSAccount # noqa: E402

# ####


class IambicFailedError(Exception):
"""Raised if there were exceptions in the iambic result's exceptions_seen list."""
Expand Down

0 comments on commit 112dde5

Please sign in to comment.