Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions samcli/lib/providers/api_collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from typing import Dict, Iterator, List, Optional, Set, Tuple, Union

from samcli.lib.providers.provider import Api, Cors
from samcli.lib.utils.colors import Colored
from samcli.lib.utils.colors import Colored, Colors
from samcli.local.apigw.authorizers.authorizer import Authorizer
from samcli.local.apigw.route import Route

Expand Down Expand Up @@ -197,7 +197,7 @@ def get_api(self) -> Api:
be validated thoroughly before deploying to production.

Testing application behaviour against authorizers deployed on AWS can be done using the sam sync command.{os.linesep}"""
LOG.warning(Colored().yellow(message))
LOG.warning(Colored().color_log(message, color=Colors.WARNING), extra=dict(markup=True))

break

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",
color=Colors.WARNING,
),
extra=dict(markup=True),
)