Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

containerapp add containerapp-preview extension #6419

Merged
merged 54 commits into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
d0c524e
init containerapp-preview
Greedygre Jun 1, 2023
f7be550
add GA extension dependency
Greedygre Jun 6, 2023
d6d8f7c
add --environment-type
Greedygre Jun 6, 2023
93c8960
fix bug for prompt
Greedygre Jun 7, 2023
62debc5
warning for update extension
Greedygre Jun 7, 2023
a98d7d3
remove useless code
Greedygre Jun 7, 2023
12820f4
fix
Greedygre Jun 7, 2023
d948cdf
remove
Greedygre Jun 8, 2023
1bb1cea
remove setup
Greedygre Jun 8, 2023
2afbe83
fix
Greedygre Jun 8, 2023
42ab370
fix lint
Greedygre Jun 8, 2023
d6beff8
fix test
Greedygre Jun 8, 2023
0cf803f
test tbd
Greedygre Jun 8, 2023
9b9b237
test 0.0.0
Greedygre Jun 8, 2023
7c34333
add create containerapp
Greedygre Jun 13, 2023
1e81de8
fix
Greedygre Jun 13, 2023
ec88eb3
add env and environment type
Greedygre Jun 13, 2023
ac2c33c
set is preview
Greedygre Jun 13, 2023
bd96ab5
fix
Greedygre Jun 14, 2023
724a381
support --yaml with extended-location
Greedygre Jun 14, 2023
88eaa6a
fix extend
Greedygre Jun 15, 2023
94eebe4
add show/delete/list containerapp in preview
Greedygre Jun 16, 2023
6a4fb88
fix preview
Greedygre Jun 19, 2023
2a4a168
fix error
Greedygre Jun 19, 2023
8b17806
fix error
Greedygre Jun 19, 2023
c7410b7
rebase main
Greedygre Jun 19, 2023
4c9f52e
fix delete
Greedygre Jun 19, 2023
8cf2fc8
refactor client and make constants
Greedygre Jun 29, 2023
368fae6
add test for environment type on arc
Greedygre Jul 3, 2023
2618e94
set version
Greedygre Jul 3, 2023
22bb79a
add test yaml
Greedygre Jul 3, 2023
0f0ffb4
fix error
Greedygre Jul 3, 2023
958e075
fix containerapp preview test
Greedygre Jul 3, 2023
c8662e2
add rely GA extension in test
Greedygre Jul 3, 2023
5cd3762
fix test
Greedygre Jul 3, 2023
44e6078
remove useless code
Greedygre Jul 4, 2023
94be4f6
fix install for loading
Greedygre Jul 5, 2023
8cf778f
Update verify_linter.py
wangzelin007 Jul 4, 2023
5446f32
fix recording and set version to 1.0.0b1
Greedygre Jul 5, 2023
52533f7
fix static analysis: blank line at the end
Greedygre Jul 5, 2023
eb2b6e6
Update verify_linter.py
wangzelin007 Jul 5, 2023
fd55f66
fix comments
Greedygre Jul 6, 2023
2e799d9
remove blank line
Greedygre Jul 6, 2023
5faa2ca
remove python 3.6 support in setup and add more comments for command …
Greedygre Jul 6, 2023
37147a9
add test for managed, add helps, parse resource type and compare
Greedygre Jul 7, 2023
8ae8319
add blank line
Greedygre Jul 7, 2023
18f613d
remove prompt logic
Greedygre Jul 10, 2023
fd90a41
fix
Greedygre Jul 10, 2023
c592553
fix
Greedygre Jul 10, 2023
99e67f9
fix help
Greedygre Jul 10, 2023
03aa729
raise error in _get_azext_module
Greedygre Jul 11, 2023
26cf02c
fix comments
Greedygre Jul 11, 2023
a6d4f0d
add a blank line
Greedygre Jul 11, 2023
acecec6
rename _get_azext_containerapp_module
Greedygre Jul 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
remove prompt logic
  • Loading branch information
Greedygre committed Jul 10, 2023
commit 18f613d2eb50aaa4b9d2609cb92ecf0eca07f1b3
4 changes: 2 additions & 2 deletions src/containerapp-preview/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ Release History
1.0.0b1
++++++
* Initial containerapp-preview extension.
* 'az containerapp list/show/delete/create': support for preview extension
* 'az containerapp create': support --environment-type parameter
* `az containerapp list/show/delete/create`: support for preview extension
* `az containerapp create`: support --environment-type parameter
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from azure.cli.core import AzCommandsLoader

from azext_containerapp_preview._help import helps # pylint: disable=unused-import
from azext_containerapp_preview._utils import (_get_or_add_extension, _get_azext_module)
from azext_containerapp_preview._utils import (is_containerapp_extension_available, _get_azext_module)
from azext_containerapp_preview._constants import GA_CONTAINERAPP_EXTENSION_NAME


Expand All @@ -26,7 +26,7 @@ def load_command_table(self, args):
# When the switch core.use_command_index is turned off, possibly unrelated commands may also trigger unnecessary loads.
# Only the containerapp related commands can ask the user to install the containerapp extension with target version
Greedygre marked this conversation as resolved.
Show resolved Hide resolved
if len(args) > 0 and args[0] == GA_CONTAINERAPP_EXTENSION_NAME:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so once there is a command started with az containerapp will trigger the extneion install?

Copy link
Contributor Author

@Greedygre Greedygre Jul 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.
If Cx only has containerapp-preview , without containerapp, once there is a command started with az containerapp will trigger the containerapp install with lastest version.
Other command, such as az version will not trigger containerapp install.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update:
not trigger install, only warnning.

if not _get_or_add_extension(self, GA_CONTAINERAPP_EXTENSION_NAME):
if not is_containerapp_extension_available():
return self.command_table
load_command_table(self, args)
return self.command_table
Expand All @@ -37,7 +37,7 @@ def load_arguments(self, command):
# When the switch core.use_command_index is turned off, possibly unrelated commands may also trigger unnecessary loads.
# Only the containerapp related commands can trigger the user to install the containerapp extension with target version
if command is not None and command.split(' ')[0] == GA_CONTAINERAPP_EXTENSION_NAME:
if not _get_or_add_extension(self, GA_CONTAINERAPP_EXTENSION_NAME):
if not is_containerapp_extension_available():
return
ga_params = _get_azext_module(
GA_CONTAINERAPP_EXTENSION_NAME, "azext_containerapp._params")
Expand Down
21 changes: 20 additions & 1 deletion src/containerapp-preview/azext_containerapp_preview/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,30 @@
from knack.util import CLIError
from knack.log import get_logger

from ._constants import MIN_GA_VERSION
from ._constants import MIN_GA_VERSION, GA_CONTAINERAPP_EXTENSION_NAME

logger = get_logger(__name__)


def is_containerapp_extension_available():
from azure.cli.core.extension import (
ExtensionNotInstalledException, get_extension)
from packaging.version import parse

try:
ext = get_extension(GA_CONTAINERAPP_EXTENSION_NAME)
# Check extension version
if ext and parse(ext.version) < parse(MIN_GA_VERSION):
msg = f"The command requires the version of {GA_CONTAINERAPP_EXTENSION_NAME} >= {MIN_GA_VERSION}. Run 'az extension add --upgrade -n {GA_CONTAINERAPP_EXTENSION_NAME}' to upgrade extension"
logger.warning(msg)
return False
except ExtensionNotInstalledException:
msg = f"The command requires the extension {GA_CONTAINERAPP_EXTENSION_NAME}. Run 'az extension add -n {GA_CONTAINERAPP_EXTENSION_NAME}' to install extension"
logger.warning(msg)
return False
return False


def _get_or_add_extension(cmd, extension_name):
Greedygre marked this conversation as resolved.
Show resolved Hide resolved
from azure.cli.core.extension import (
ExtensionNotInstalledException, get_extension)
Expand Down