diff --git a/samcli/commands/_utils/experimental.py b/samcli/commands/_utils/experimental.py index 41e0f046fb..793fd397f0 100644 --- a/samcli/commands/_utils/experimental.py +++ b/samcli/commands/_utils/experimental.py @@ -54,12 +54,16 @@ class ExperimentalFlag: "experimentalTerraformSupport", EXPERIMENTAL_ENV_VAR_PREFIX + "TERRAFORM_SUPPORT" ) } - RustCargoLambda = ExperimentalEntry("experimentalCargoLambda", EXPERIMENTAL_ENV_VAR_PREFIX + "RUST_CARGO_LAMBDA") + # CargoLambda is no longer experimental - always enabled + CargoLambda = ExperimentalEntry( + "experimentalCargoLambda", EXPERIMENTAL_ENV_VAR_PREFIX + "CARGO_LAMBDA", persistent=True + ) def is_experimental_enabled(config_entry: ExperimentalEntry) -> bool: """Whether a given experimental flag is enabled or not. If experimentalAll is set to True, then it will always return True. + If the config_entry has persistent=True, it will always return True. Parameters ---------- @@ -71,6 +75,9 @@ def is_experimental_enabled(config_entry: ExperimentalEntry) -> bool: bool Whether the experimental flag is enabled or not. """ + # Persistent flags are always enabled (graduated from experimental) + if config_entry.persistent: + return True gc = GlobalConfig() enabled = gc.get_value(config_entry, default=False, value_type=bool, is_flag=True) if not enabled: diff --git a/samcli/commands/build/build_context.py b/samcli/commands/build/build_context.py index 4f133a7009..14e1cff5a7 100644 --- a/samcli/commands/build/build_context.py +++ b/samcli/commands/build/build_context.py @@ -11,7 +11,6 @@ import click from samcli.commands._utils.constants import DEFAULT_BUILD_DIR -from samcli.commands._utils.experimental import ExperimentalFlag, prompt_experimental from samcli.commands._utils.template import ( get_template_data, move_template, @@ -281,7 +280,6 @@ def run(self) -> None: ) self._check_exclude_warning() - self._check_rust_cargo_experimental_flag() for f in self.get_resources_to_build().functions: EventTracker.track_event(EventName.BUILD_FUNCTION_RUNTIME.value, f.runtime) @@ -696,25 +694,6 @@ def _check_exclude_warning(self) -> None: if self._resource_identifier in excludes: LOG.warning(self._EXCLUDE_WARNING_MESSAGE) - def _check_rust_cargo_experimental_flag(self) -> None: - """ - Prints warning message and confirms if user wants to use beta feature - """ - WARNING_MESSAGE = ( - 'Build method "rust-cargolambda" is a beta feature.\n' - "Please confirm if you would like to proceed\n" - 'You can also enable this beta feature with "sam build --beta-features".' - ) - resources_to_build = self.get_resources_to_build() - is_building_rust = False - for function in resources_to_build.functions: - if function.metadata and function.metadata.get("BuildMethod", "") == "rust-cargolambda": - is_building_rust = True - break - - if is_building_rust: - prompt_experimental(ExperimentalFlag.RustCargoLambda, WARNING_MESSAGE) - @property def build_in_source(self) -> Optional[bool]: return self._build_in_source diff --git a/tests/integration/buildcmd/build_integ_base.py b/tests/integration/buildcmd/build_integ_base.py index 44395630c7..05f34abf72 100644 --- a/tests/integration/buildcmd/build_integ_base.py +++ b/tests/integration/buildcmd/build_integ_base.py @@ -1141,7 +1141,7 @@ def _test_with_rust_cargo_lambda( overrides = self.get_override(runtime, code_uri, architecture, handler) if binary: overrides["Binary"] = binary - cmdlist = self.get_command_list(use_container=use_container, parameter_overrides=overrides, beta_features=True) + cmdlist = self.get_command_list(use_container=use_container, parameter_overrides=overrides) newenv = os.environ.copy() if build_mode: diff --git a/tests/unit/commands/_utils/test_experimental.py b/tests/unit/commands/_utils/test_experimental.py index a73760a280..150ae3982b 100644 --- a/tests/unit/commands/_utils/test_experimental.py +++ b/tests/unit/commands/_utils/test_experimental.py @@ -35,22 +35,33 @@ def tearDown(self): def test_is_experimental_enabled(self): config_entry = MagicMock() + config_entry.persistent = False self.gc_mock.return_value.get_value.side_effect = [False, True] result = is_experimental_enabled(config_entry) self.assertTrue(result) def test_is_experimental_enabled_all(self): config_entry = MagicMock() + config_entry.persistent = False self.gc_mock.return_value.get_value.side_effect = [True, False] result = is_experimental_enabled(config_entry) self.assertTrue(result) def test_is_experimental_enabled_false(self): config_entry = MagicMock() + config_entry.persistent = False self.gc_mock.return_value.get_value.side_effect = [False, False] result = is_experimental_enabled(config_entry) self.assertFalse(result) + def test_is_experimental_enabled_persistent(self): + config_entry = MagicMock() + config_entry.persistent = True + result = is_experimental_enabled(config_entry) + self.assertTrue(result) + # GlobalConfig should not be called for persistent flags + self.gc_mock.return_value.get_value.assert_not_called() + def test_set_experimental(self): config_entry = MagicMock() set_experimental(config_entry, False) diff --git a/tests/unit/commands/buildcmd/test_build_context.py b/tests/unit/commands/buildcmd/test_build_context.py index 261d654b32..7a537354f5 100644 --- a/tests/unit/commands/buildcmd/test_build_context.py +++ b/tests/unit/commands/buildcmd/test_build_context.py @@ -1254,14 +1254,12 @@ def test_must_catch_function_not_found_exception( @patch("samcli.commands.build.build_context.BuildContext._is_sam_template") @patch("samcli.commands.build.build_context.BuildContext.get_resources_to_build") @patch("samcli.commands.build.build_context.BuildContext._check_exclude_warning") - @patch("samcli.commands.build.build_context.BuildContext._check_rust_cargo_experimental_flag") @patch("samcli.lib.build.app_builder.ApplicationBuilder.build") @patch("samcli.lib.telemetry.event.EventTracker.track_event") def test_build_in_source_event_sent( self, mock_track_event, mock_builder, - mock_rust, mock_warning, mock_get_resources, mock_is_sam_template,