diff --git a/src/k8s-extension/azext_k8s_extension/_help.py b/src/k8s-extension/azext_k8s_extension/_help.py index 862bf4572ac..23601420648 100644 --- a/src/k8s-extension/azext_k8s_extension/_help.py +++ b/src/k8s-extension/azext_k8s_extension/_help.py @@ -10,25 +10,47 @@ helps[f'{consts.EXTENSION_NAME}'] = """ type: group - short-summary: Commands to manage K8s-extensions. + short-summary: Commands to manage Kubernetes Extensions. """ -helps[f'{consts.EXTENSION_NAME} create'] = """ +helps[f'{consts.EXTENSION_NAME} create'] = f""" type: command - short-summary: Create a K8s-extension. + short-summary: Create a Kubernetes Extension. + examples: + - name: Create a Kubernetes Extension + text: |- + az {consts.EXTENSION_NAME} create --resource-group my-resource-group \\ + --cluster-name mycluster --cluster-type connectedClusters \\ + --name myextension --extension-type microsoft.openservicemesh \\ + --scope cluster --release-train stable """ -helps[f'{consts.EXTENSION_NAME} list'] = """ +helps[f'{consts.EXTENSION_NAME} list'] = f""" type: command - short-summary: List K8s-extensions. + short-summary: List Kubernetes Extensions. + examples: + - name: List all Kubernetes Extensions on a cluster + text: |- + az {consts.EXTENSION_NAME} list --resource-group my-resource-group \\ + --cluster-name mycluster --cluster-type connectedClusters """ -helps[f'{consts.EXTENSION_NAME} delete'] = """ +helps[f'{consts.EXTENSION_NAME} delete'] = f""" type: command - short-summary: Delete a K8s-extension. + short-summary: Delete a Kubernetes Extension. + examples: + - name: Delete an existing Kubernetes Extension + text: |- + az {consts.EXTENSION_NAME} delete --resource-group my-resource-group \\ + --cluster-name mycluster --cluster-type connectedClusters --name myextension """ -helps[f'{consts.EXTENSION_NAME} show'] = """ +helps[f'{consts.EXTENSION_NAME} show'] = f""" type: command - short-summary: Show details of a K8s-extension. + short-summary: Show a Kubernetes Extension. + examples: + - name: Show details of a Kubernetes Extension + text: |- + az {consts.EXTENSION_NAME} show --resource-group my-resource-group \\ + --cluster-name mycluster --cluster-type connectedClusters --name myextension """ diff --git a/src/k8s-extension/azext_k8s_extension/_params.py b/src/k8s-extension/azext_k8s_extension/_params.py index 2136d43f0f3..58b252e7a16 100644 --- a/src/k8s-extension/azext_k8s_extension/_params.py +++ b/src/k8s-extension/azext_k8s_extension/_params.py @@ -74,7 +74,8 @@ def load_arguments(self, _): c.argument('target_namespace', help='Specify the target namespace to install to for the extension instance. This' ' parameter is required if extension scope is set to \'namespace\'') + with self.argument_context(f"{consts.EXTENSION_NAME} delete") as c: c.argument('yes', - options_list=['yes', 'y'] - ) + options_list=['--yes', '-y'], + help='Ignore confirmation prompts') diff --git a/src/k8s-extension/azext_k8s_extension/partner_extensions/AzureDefender.py b/src/k8s-extension/azext_k8s_extension/partner_extensions/AzureDefender.py index 59dcab50deb..b8da6a293b6 100644 --- a/src/k8s-extension/azext_k8s_extension/partner_extensions/AzureDefender.py +++ b/src/k8s-extension/azext_k8s_extension/partner_extensions/AzureDefender.py @@ -8,7 +8,6 @@ from knack.log import get_logger from ..vendored_sdks.models import ExtensionInstance -from ..vendored_sdks.models import ExtensionInstanceUpdate from ..vendored_sdks.models import ScopeCluster from ..vendored_sdks.models import Scope diff --git a/src/k8s-extension/azext_k8s_extension/partner_extensions/AzureMLKubernetes.py b/src/k8s-extension/azext_k8s_extension/partner_extensions/AzureMLKubernetes.py index d30a236710e..c85b88c943b 100644 --- a/src/k8s-extension/azext_k8s_extension/partner_extensions/AzureMLKubernetes.py +++ b/src/k8s-extension/azext_k8s_extension/partner_extensions/AzureMLKubernetes.py @@ -28,10 +28,9 @@ from msrestazure.azure_exceptions import CloudError from .._client_factory import cf_resources -from .DefaultExtension import DefaultExtension, default_user_confirmation +from .DefaultExtension import DefaultExtension, user_confirmation_factory from ..vendored_sdks.models import ( ExtensionInstance, - ExtensionInstanceUpdate, Scope, ScopeCluster ) @@ -164,7 +163,7 @@ def Delete(self, cmd, client, resource_group_name, cluster_name, name, cluster_t logger.warning("If nvidia.com/gpu or fuse resource is not recognized by kubernetes after this deletion, " "you probably have installed nvidia-device-plugin or fuse-device-plugin before installing AMLArc extension. " "Please try to reinstall device plugins to fix this issue.") - default_user_confirmation(cmd, yes) + user_confirmation_factory(cmd, yes) def __validate_config(self, configuration_settings, configuration_protected_settings): # perform basic validation of the input config diff --git a/src/k8s-extension/azext_k8s_extension/partner_extensions/ContainerInsights.py b/src/k8s-extension/azext_k8s_extension/partner_extensions/ContainerInsights.py index dcf6d68e1b2..3d4663ace14 100644 --- a/src/k8s-extension/azext_k8s_extension/partner_extensions/ContainerInsights.py +++ b/src/k8s-extension/azext_k8s_extension/partner_extensions/ContainerInsights.py @@ -17,7 +17,6 @@ from msrestazure.tools import parse_resource_id, is_valid_resource_id from ..vendored_sdks.models import ExtensionInstance -from ..vendored_sdks.models import ExtensionInstanceUpdate from ..vendored_sdks.models import ScopeCluster from ..vendored_sdks.models import Scope diff --git a/src/k8s-extension/azext_k8s_extension/partner_extensions/DefaultExtension.py b/src/k8s-extension/azext_k8s_extension/partner_extensions/DefaultExtension.py index 2e38eddcf65..f2128bc7ad1 100644 --- a/src/k8s-extension/azext_k8s_extension/partner_extensions/DefaultExtension.py +++ b/src/k8s-extension/azext_k8s_extension/partner_extensions/DefaultExtension.py @@ -59,10 +59,10 @@ def Update(self, extension, auto_upgrade_minor_version, release_train, version): ) def Delete(self, cmd, client, resource_group_name, cluster_name, name, cluster_type, yes): - default_user_confirmation(cmd, yes) + user_confirmation_factory(cmd, yes) -def default_user_confirmation(cmd, yes): +def user_confirmation_factory(cmd, yes, message="Are you sure you want to perform this operation?"): if cmd.cli_ctx.config.getboolean('core', 'disable_confirm_prompt', fallback=False): return - return user_confirmation("Are you sure you want to perform this operation?", yes=yes) + user_confirmation(message, yes=yes) diff --git a/src/k8s-extension/azext_k8s_extension/partner_extensions/DefaultExtensionWithIdentity.py b/src/k8s-extension/azext_k8s_extension/partner_extensions/DefaultExtensionWithIdentity.py index 52a372f7f84..d65d9f225ad 100644 --- a/src/k8s-extension/azext_k8s_extension/partner_extensions/DefaultExtensionWithIdentity.py +++ b/src/k8s-extension/azext_k8s_extension/partner_extensions/DefaultExtensionWithIdentity.py @@ -11,10 +11,10 @@ from ..vendored_sdks.models import ScopeNamespace from ..vendored_sdks.models import Scope -from .PartnerExtensionModel import PartnerExtensionModel +from .DefaultExtension import DefaultExtension -class DefaultExtensionWithIdentity(PartnerExtensionModel): +class DefaultExtensionWithIdentity(DefaultExtension): def Create(self, cmd, client, resource_group_name, cluster_name, name, cluster_type, extension_type, scope, auto_upgrade_minor_version, release_train, version, target_namespace, release_namespace, configuration_settings, configuration_protected_settings, @@ -55,6 +55,3 @@ def Update(self, extension, auto_upgrade_minor_version, release_train, version): release_train=release_train, version=version ) - - def Delete(self, client, resource_group_name, cluster_name, name, cluster_type): - pass diff --git a/src/k8s-extension/azext_k8s_extension/partner_extensions/PartnerExtensionModel.py b/src/k8s-extension/azext_k8s_extension/partner_extensions/PartnerExtensionModel.py index be9b7bd5a3f..8e89bfa15fc 100644 --- a/src/k8s-extension/azext_k8s_extension/partner_extensions/PartnerExtensionModel.py +++ b/src/k8s-extension/azext_k8s_extension/partner_extensions/PartnerExtensionModel.py @@ -23,5 +23,5 @@ def Update(self, extension: ExtensionInstance, auto_upgrade_minor_version: bool, pass @abstractmethod - def Delete(self, client, resource_group_name: str, cluster_name: str, name: str, cluster_type: str, yes: bool): + def Delete(self, cmd, client, resource_group_name: str, cluster_name: str, name: str, cluster_type: str, yes: bool): pass