Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Bug Bash UX Issues #5387

Merged
merged 3 commits into from
Jun 20, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions samcli/commands/_utils/experimental.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from samcli.cli.context import Context
from samcli.cli.global_config import ConfigEntry, GlobalConfig
from samcli.commands._utils.parameterized_option import parameterized_option
from samcli.lib.utils.colors import Colored
from samcli.lib.utils.colors import Colored, Colors

LOG = logging.getLogger(__name__)

Expand Down Expand Up @@ -162,7 +162,7 @@ def update_experimental_context(show_warning=True):
if not Context.get_current_context().experimental:
Context.get_current_context().experimental = True
if show_warning:
LOG.warning(Colored().yellow(EXPERIMENTAL_WARNING))
LOG.warning(Colored().color_log(EXPERIMENTAL_WARNING, color=Colors.WARNING), extra=dict(markup=True))


def _experimental_option_callback(ctx, param, enabled: Optional[bool]):
Expand Down
17 changes: 9 additions & 8 deletions samcli/commands/local/start_api/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,14 +223,15 @@ def do_cli( # pylint: disable=R0914
) as invoke_context:
service = LocalApiService(lambda_invoke_context=invoke_context, port=port, host=host, static_dir=static_dir)
service.start()
command_suggestions = generate_next_command_recommendation(
[
("Validate SAM template", "sam validate"),
("Test Function in the Cloud", "sam sync --stack-name {{stack-name}} --watch"),
("Deploy", "sam deploy --guided"),
]
)
click.secho(command_suggestions, fg="yellow")
if not hook_name:
command_suggestions = generate_next_command_recommendation(
[
("Validate SAM template", "sam validate"),
("Test Function in the Cloud", "sam sync --stack-name {{stack-name}} --watch"),
("Deploy", "sam deploy --guided"),
]
)
click.secho(command_suggestions, fg="yellow")

except NoApisDefined as ex:
raise UserException(
Expand Down
11 changes: 7 additions & 4 deletions samcli/hook_packages/terraform/hooks/prepare/translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
get_sam_metadata_planned_resource_value_attribute,
)
from samcli.lib.hook.exceptions import PrepareHookException
from samcli.lib.utils.colors import Colored
from samcli.lib.utils.colors import Colored, Colors
from samcli.lib.utils.resources import AWS_LAMBDA_FUNCTION as CFN_AWS_LAMBDA_FUNCTION

SAM_METADATA_RESOURCE_TYPE = "null_resource"
Expand Down Expand Up @@ -134,9 +134,12 @@ def _check_unresolvable_values(root_module: dict, root_tf_module: TFModule) -> N

if config_values and not planned_values:
LOG.warning(
Colored().yellow(
"\nUnresolvable attributes discovered in project, run terraform apply to resolve them.\n"
)
Colored().color_log(
msg="\nUnresolvable attributes discovered in project, "
"run terraform apply to resolve them.\n",
color=Colors.WARNING,
),
extra=dict(markup=True),
)

return
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""Test Terraform prepare translate"""
import copy
from unittest import TestCase
from unittest.mock import Mock, call, patch, MagicMock, ANY
from samcli.lib.utils.colors import Colored
from samcli.lib.utils.colors import Colored, Colors

from tests.unit.hook_packages.terraform.hooks.prepare.prepare_base import PrepareHookUnitBase
from samcli.hook_packages.terraform.hooks.prepare.property_builder import (
Expand Down Expand Up @@ -1112,7 +1113,7 @@ def test_translating_apigw_integration_response_method(self):
self.assertEqual(translated_cfn_properties, self.expected_internal_apigw_integration_response_properties)


class TestUnresolvableAttributeCheck:
class TestUnresolvableAttributeCheck(TestCase):
@patch("samcli.hook_packages.terraform.hooks.prepare.translate.RESOURCE_TRANSLATOR_MAPPING")
@patch("samcli.hook_packages.terraform.hooks.prepare.translate.LOG")
def test_module_contains_unresolvables(self, log_mock, mapping_mock):
Expand All @@ -1136,5 +1137,9 @@ def test_module_contains_unresolvables(self, log_mock, mapping_mock):
_check_unresolvable_values(module, tf_module)

log_mock.warning.assert_called_with(
Colored().yellow("\nUnresolvable attributes discovered in project, run terraform apply to resolve them.\n")
Colored().color_log(
msg="\nUnresolvable attributes discovered in project, " "run terraform apply to resolve them.\n",
mildaniel marked this conversation as resolved.
Show resolved Hide resolved
color=Colors.WARNING,
),
extra=dict(markup=True),
)