Skip to content

Commit

Permalink
Workspaces application - deploy action (#1558)
Browse files Browse the repository at this point in the history
* extract create_or_upgrade_app

* wip action_deploy

* tests

* kwargs actions

* post deploy hooks

* deploy package

* use entity deploy logic in run processor

* update sql mock

* update unit tests

* drop app before upgrade callback

* integration tests

* integration tests
  • Loading branch information
sfc-gh-gbloom authored Sep 12, 2024
1 parent 2fa0a6e commit e4a7a13
Show file tree
Hide file tree
Showing 28 changed files with 1,033 additions and 484 deletions.
34 changes: 8 additions & 26 deletions src/snowflake/cli/_plugins/nativeapp/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,16 @@

import time
from abc import ABC, abstractmethod
from contextlib import contextmanager
from datetime import datetime
from functools import cached_property
from pathlib import Path
from textwrap import dedent
from typing import Generator, List, Optional, TypedDict

from click import ClickException
from snowflake.cli._plugins.connection.util import make_snowsight_url
from snowflake.cli._plugins.nativeapp.artifacts import (
BundleMap,
)
from snowflake.cli._plugins.nativeapp.constants import (
NAME_COL,
)
from snowflake.cli._plugins.nativeapp.exceptions import (
NoEventTableForAccount,
)
Expand All @@ -41,6 +36,9 @@
DiffResult,
)
from snowflake.cli.api.console import cli_console as cc
from snowflake.cli.api.entities.application_entity import (
ApplicationEntity,
)
from snowflake.cli.api.entities.application_package_entity import (
ApplicationPackageEntity,
)
Expand Down Expand Up @@ -137,20 +135,8 @@ def use_package_warehouse(self):
def application_warehouse(self) -> Optional[str]:
return self.na_project.application_warehouse

@contextmanager
def use_application_warehouse(self):
if self.application_warehouse:
with self.use_warehouse(self.application_warehouse):
yield
else:
raise ClickException(
dedent(
f"""\
Application warehouse cannot be empty.
Please provide a value for it in your connection information or your project definition file.
"""
)
)
return ApplicationEntity.use_application_warehouse(self.application_warehouse)

@property
def project_identifier(self) -> str:
Expand Down Expand Up @@ -249,14 +235,10 @@ def sync_deploy_root_with_stage(
)

def get_existing_app_info(self) -> Optional[dict]:
"""
Check for an existing application object by the same name as in project definition, in account.
It executes a 'show applications like' query and returns the result as single row, if one exists.
"""
with self.use_role(self.app_role):
return self.show_specific_object(
"applications", self.app_name, name_col=NAME_COL
)
return ApplicationEntity.get_existing_app_info(
app_name=self.app_name,
app_role=self.app_role,
)

def get_existing_app_pkg_info(self) -> Optional[dict]:
return ApplicationPackageEntity.get_existing_app_pkg_info(
Expand Down
Loading

0 comments on commit e4a7a13

Please sign in to comment.