-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add release channels list support (#1953)
- Loading branch information
1 parent
dae4e10
commit 0257a0e
Showing
10 changed files
with
627 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/snowflake/cli/_plugins/nativeapp/release_channel/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Copyright (c) 2024 Snowflake Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. |
71 changes: 71 additions & 0 deletions
71
src/snowflake/cli/_plugins/nativeapp/release_channel/commands.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# Copyright (c) 2024 Snowflake Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from __future__ import annotations | ||
|
||
import logging | ||
from typing import Optional | ||
|
||
import typer | ||
from snowflake.cli._plugins.nativeapp.v2_conversions.compat import ( | ||
force_project_definition_v2, | ||
) | ||
from snowflake.cli._plugins.workspace.manager import WorkspaceManager | ||
from snowflake.cli.api.cli_global_context import get_cli_context | ||
from snowflake.cli.api.commands.decorators import with_project_definition | ||
from snowflake.cli.api.commands.snow_typer import SnowTyperFactory | ||
from snowflake.cli.api.entities.common import EntityActions | ||
from snowflake.cli.api.output.formats import OutputFormat | ||
from snowflake.cli.api.output.types import ( | ||
CollectionResult, | ||
CommandResult, | ||
) | ||
|
||
app = SnowTyperFactory( | ||
name="release-channel", | ||
help="Manages release channels of an application package", | ||
) | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
|
||
@app.command("list", requires_connection=True) | ||
@with_project_definition() | ||
@force_project_definition_v2() | ||
def release_channel_list( | ||
channel: Optional[str] = typer.Argument( | ||
default=None, | ||
show_default=False, | ||
help="The release channel to list. If not provided, all release channels are listed.", | ||
), | ||
**options, | ||
) -> CommandResult: | ||
""" | ||
Lists the release channels available for an application package. | ||
""" | ||
|
||
cli_context = get_cli_context() | ||
ws = WorkspaceManager( | ||
project_definition=cli_context.project_definition, | ||
project_root=cli_context.project_root, | ||
) | ||
package_id = options["package_entity_id"] | ||
channels = ws.perform_action( | ||
package_id, | ||
EntityActions.RELEASE_CHANNEL_LIST, | ||
release_channel=channel, | ||
) | ||
|
||
if cli_context.output_format == OutputFormat.JSON: | ||
return CollectionResult(channels) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.