Skip to content

Commit

Permalink
Trigger bundle before looking for manifest, allow passing BundleMap t…
Browse files Browse the repository at this point in the history
…o cls.deploy
  • Loading branch information
sfc-gh-fcampbell committed Sep 20, 2024
1 parent a5eccc4 commit f4b533a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/snowflake/cli/_plugins/nativeapp/application_package_entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
ApplicationPackageEntityModel,
)
from snowflake.cli._plugins.nativeapp.artifacts import (
BundleMap,
build_bundle,
find_version_info_in_manifest_file,
)
Expand Down Expand Up @@ -121,6 +122,7 @@ def action_deploy(
bundle_root=Path(model.bundle_root),
generated_root=Path(model.generated_root),
artifacts=model.artifacts,
bundle_map=None,
package_name=package_name,
package_role=(model.meta and model.meta.role) or ctx.default_role,
package_distribution=model.distribution,
Expand Down Expand Up @@ -268,6 +270,7 @@ def deploy(
bundle_root: Path,
generated_root: Path,
artifacts: list[PathMapping],
bundle_map: BundleMap | None,
package_name: str,
package_role: str,
package_distribution: str,
Expand All @@ -282,8 +285,8 @@ def deploy(
package_scripts: List[str],
policy: PolicyBase,
) -> DiffResult:
# 1. Create a bundle
bundle_map = cls.bundle(
# 1. Create a bundle if one wasn't passed in
bundle_map = bundle_map or cls.bundle(
project_root=project_root,
deploy_root=deploy_root,
bundle_root=bundle_root,
Expand Down Expand Up @@ -415,11 +418,24 @@ def version_create(

# Make sure version is not None before proceeding any further.
# This will raise an exception if version information is not found. Patch can be None.
bundle_map = None
if not version:
console.message(
"Version was not provided through the Snowflake CLI. Checking version in the manifest.yml instead."
dedent(
f"""\
Version was not provided through the Snowflake CLI. Checking version in the manifest.yml instead.
This step will bundle your app artifacts to determine the location of the manifest.yml file.
"""
)
)
bundle_map = cls.bundle(
project_root=project_root,
deploy_root=deploy_root,
bundle_root=bundle_root,
generated_root=generated_root,
artifacts=artifacts,
package_name=package_name,
)

version, patch = find_version_info_in_manifest_file(deploy_root)
if not version:
raise ClickException(
Expand Down Expand Up @@ -457,6 +473,7 @@ def version_create(
bundle_root=bundle_root,
generated_root=generated_root,
artifacts=artifacts,
bundle_map=bundle_map,
package_name=package_name,
package_role=package_role,
package_distribution=package_distribution,
Expand Down
1 change: 1 addition & 0 deletions src/snowflake/cli/_plugins/nativeapp/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ def deploy(
bundle_root=self.bundle_root,
generated_root=self.generated_root,
artifacts=self.artifacts,
bundle_map=bundle_map,
package_name=self.package_name,
package_role=self.package_role,
package_distribution=self.package_distribution,
Expand Down

0 comments on commit f4b533a

Please sign in to comment.