diff --git a/src/snowflake/cli/_plugins/nativeapp/v2_conversions/compat.py b/src/snowflake/cli/_plugins/nativeapp/v2_conversions/compat.py index 145b3bfc02..ff4dfc32a8 100644 --- a/src/snowflake/cli/_plugins/nativeapp/v2_conversions/compat.py +++ b/src/snowflake/cli/_plugins/nativeapp/v2_conversions/compat.py @@ -315,7 +315,14 @@ def wrapper(*args, **kwargs): is_package = isinstance(entity, ApplicationPackageEntityModel) key = "package_entity_id" if is_package else "app_entity_id" kwargs[key] = entity_id - get_cli_context_manager().override_project_definition = pdfv2 + cm = get_cli_context_manager() + cm.override_project_definition = pdfv2 + pdfv2_dump = pdfv2.model_dump( + exclude_none=True, warnings=False, by_alias=True + ) + cm.override_template_context = cm.template_context | dict( + ctx=pdfv2_dump + ) else: package_entity_id = kwargs.get("package_entity_id", "") app_entity_id = kwargs.get("app_entity_id", "") diff --git a/src/snowflake/cli/api/cli_global_context.py b/src/snowflake/cli/api/cli_global_context.py index 0b53495166..a59cfc4d5d 100644 --- a/src/snowflake/cli/api/cli_global_context.py +++ b/src/snowflake/cli/api/cli_global_context.py @@ -54,10 +54,11 @@ class _CliGlobalContextManager: project_env_overrides_args: dict[str, str] = field(default_factory=dict) # FIXME: this property only exists to help implement - # nativeapp_definition_v2_to_v1. Consider changing the way - # this calculation is provided to commands in order to remove - # this logic (then make project_definition a non-cloned @property) + # nativeapp_definition_v2_to_v1 and single_app_and_package. + # Consider changing the way this calculation is provided to commands + # in order to remove this logic (then make project_definition a non-cloned @property) override_project_definition: ProjectDefinition | None = None + override_template_context: dict | None = None _definition_manager: DefinitionManager | None = None @@ -97,6 +98,8 @@ def project_root(self) -> Path: @property def template_context(self) -> dict: + if self.override_template_context: + return self.override_template_context return self._definition_manager_or_raise().template_context @property