Skip to content

Commit

Permalink
SNOW-1706990 Convert snow app diff to v2-native (#1671)
Browse files Browse the repository at this point in the history
Converts `snow app diff` to operate natively on v2 models
  • Loading branch information
sfc-gh-fcampbell authored Oct 4, 2024
1 parent 5fc0c5b commit 8f92b10
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/snowflake/cli/_plugins/nativeapp/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,23 +117,27 @@ def app_bundle(

@app.command("diff", requires_connection=True, hidden=True)
@with_project_definition()
@nativeapp_definition_v2_to_v1()
@single_app_and_package()
def app_diff(
**options,
) -> CommandResult:
) -> CommandResult | None:
"""
Performs a diff between the app's source stage and the local deploy root.
"""
assert_project_type("native_app")

cli_context = get_cli_context()
manager = NativeAppManager(
project_definition=cli_context.project_definition.native_app,
ws = WorkspaceManager(
project_definition=cli_context.project_definition,
project_root=cli_context.project_root,
)
bundle_map = manager.build_bundle()
package_id = options["package_entity_id"]
package = cli_context.project_definition.entities[package_id]
bundle_map = ws.perform_action(
package_id,
EntityActions.BUNDLE,
)
stage_fqn = f"{package.identifier.name}.{package.stage}"
diff: DiffResult = compute_stage_diff(
local_root=Path(manager.deploy_root), stage_fqn=manager.stage_fqn
local_root=Path(package.deploy_root), stage_fqn=stage_fqn
)
if cli_context.output_format == OutputFormat.JSON:
return ObjectResult(diff.to_dict())
Expand Down

0 comments on commit 8f92b10

Please sign in to comment.