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 04ca447
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
20 changes: 20 additions & 0 deletions src/starfleet/worker_ships/plugins/iam/iambic_imports.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"""File to handle the IAMbic imports. This is done to avoid logger issues.
:Module: starfleet.worker_ships.plugins.iam.iambic_imports
:Copyright: (c) 2023 by Gemini Trust Company, LLC., see AUTHORS for more info
:License: See the LICENSE file for details
:Author: Mike Grima <michael.grima@gemini.com>
"""
# pylint: disable=unused-import,wrong-import-position,wrong-import-order
from unittest import mock

from starfleet.utils.logging import LOGGER

# Mock out the iambic logger, as it's bossy and overrides Starfleet's:
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,F401
from iambic.core.models import Variable # noqa: E402,F401
from iambic.plugins.v0_1_0.aws.iam.role.models import AwsIamRoleTemplate # noqa: E402,F401
from iambic.plugins.v0_1_0.aws.models import AWSAccount # noqa: E402,F401
6 changes: 3 additions & 3 deletions src/starfleet/worker_ships/plugins/iam/role_ship.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 @@ -38,6 +37,7 @@
make_iambic_variables,
)
from starfleet.worker_ships.ship_schematics import StarfleetWorkerShip, FanOutStrategy, AlertPriority
from starfleet.worker_ships.plugins.iam.iambic_imports import AWSAccount, AwsIamRoleTemplate, iambic_ctx


class IambicFailedError(Exception):
Expand Down
2 changes: 1 addition & 1 deletion src/starfleet/worker_ships/plugins/iam/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
from enum import Enum
from typing import Any, Dict, List

from iambic.core.models import Variable
from marshmallow import ValidationError, fields, Schema, validate

from starfleet.account_index.resolvers import resolve_account_specification, resolve_include_account_specification
from starfleet.utils.logging import LOGGER
from starfleet.worker_ships.base_payload_schemas import IncludeAccountsSpecificationSchema, AccountsSpecificationSchema, BaseAccountPayloadTemplate
from starfleet.worker_ships.ship_schematics import WorkerShipBaseConfigurationTemplate
from starfleet.worker_ships.plugins.iam.iambic_imports import Variable


class IambicTemplateTypes(Enum):
Expand Down

0 comments on commit 04ca447

Please sign in to comment.