Skip to content

Commit

Permalink
Merge pull request AzureArcForKubernetes#249 from AzureArcForKubernet…
Browse files Browse the repository at this point in the history
…es/revertextensionstype

Reverting changes for extensions type api
  • Loading branch information
Arif-lakhani committed Aug 23, 2023
2 parents a74f76d + 7166e84 commit 6be2701
Show file tree
Hide file tree
Showing 72 changed files with 638 additions and 15,461 deletions.
16 changes: 14 additions & 2 deletions src/k8s-extension/azext_k8s_extension/_client_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,20 @@ def cf_k8s_extension_operation(cli_ctx, *_):
return cf_k8s_extension(cli_ctx).extensions


def cf_k8s_extension_types(cli_ctx, *_):
return cf_k8s_extension(cli_ctx, api_version=consts.EXTENSION_TYPE_API_VERSION).extension_types
def cf_k8s_cluster_extension_types_operation(cli_ctx, *_):
return cf_k8s_extension(cli_ctx, api_version=consts.EXTENSION_TYPE_API_VERSION).cluster_extension_types


def cf_k8s_cluster_extension_type_operation(cli_ctx, *_):
return cf_k8s_extension(cli_ctx, api_version=consts.EXTENSION_TYPE_API_VERSION).cluster_extension_type


def cf_k8s_location_extension_types_operation(cli_ctx, *_):
return cf_k8s_extension(cli_ctx, api_version=consts.EXTENSION_TYPE_API_VERSION).location_extension_types


def cf_k8s_extension_type_versions_operation(cli_ctx, *_):
return cf_k8s_extension(cli_ctx, api_version=consts.EXTENSION_TYPE_API_VERSION).extension_type_versions


def cf_resource_groups(cli_ctx, subscription_id=None):
Expand Down
35 changes: 19 additions & 16 deletions src/k8s-extension/azext_k8s_extension/_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,34 @@ def __get_table_row(result):


def k8s_extension_types_list_table_format(results):
return [__get_extension_type_table_row(result) for result in results]
return [__get_extension_type_table_row(result, False) for result in results]


def k8s_extension_type_show_table_format(result):
return __get_extension_type_table_row(result)
return __get_extension_type_table_row(result, True)


def __get_extension_type_table_row(result):
def __get_extension_type_table_row(result, showReleaseTrains):
# Populate the values to be returned if they are not undefined
clusterTypes = ''
if result['properties']['supportedClusterTypes'] is not None:
clusterTypes = ', '.join(result['properties']['supportedClusterTypes'])

clusterTypes = ', '.join(result['clusterTypes'])
name = result['name']
defaultScope = ''
if result['properties']['supportedScopes']:
defaultScope = result['properties']['supportedScopes']['defaultScope']
defaultScope, allowMultipleInstances, defaultReleaseNamespace = '', '', ''
if result['supportedScopes']:
defaultScope = result['supportedScopes']['defaultScope']
if result['supportedScopes']['clusterScopeSettings']:
allowMultipleInstances = result['supportedScopes']['clusterScopeSettings']['allowMultipleInstances']
defaultReleaseNamespace = result['supportedScopes']['clusterScopeSettings']['defaultReleaseNamespace']

retVal = OrderedDict([
('name', name),
('defaultScope', defaultScope),
('clusterTypes', clusterTypes)
('clusterTypes', clusterTypes),
('allowMultipleInstances', allowMultipleInstances),
('defaultReleaseNamespace', defaultReleaseNamespace)
])
if showReleaseTrains:
releaseTrains = ', '.join(result['releaseTrains'])
retVal['releaseTrains'] = releaseTrains

return retVal

Expand All @@ -65,11 +70,9 @@ def k8s_extension_type_versions_list_table_format(results):
return [__get_extension_type_versions_table_row(result) for result in results]


def k8s_extension_type_version_show_table_format(results):
return __get_extension_type_versions_table_row(results)


def __get_extension_type_versions_table_row(result):
versions = ", ".join(result['versions'])
return OrderedDict([
('versions', result['properties']['version'])
('releaseTrain', result['releaseTrain']),
('versions', versions)
])
72 changes: 17 additions & 55 deletions src/k8s-extension/azext_k8s_extension/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,79 +83,41 @@
short-summary: Commands to discover Kubernetes Extension Types.
"""

helps[f'{consts.EXTENSION_NAME} extension-types show-by-cluster'] = f"""
helps[f'{consts.EXTENSION_NAME} extension-types list'] = f"""
type: command
short-summary: Show properties for a Cluster Extension Type for an existing cluster. The properties used for filtering include type of cluster (managed, connected, etc), kubernetes version, location of the cluster.
short-summary: List Kubernetes Extension Types.
examples:
- name: Show properties for a Cluster Extension Type for an existing cluster
- name: List Kubernetes Extension Types
text: |-
az {consts.EXTENSION_NAME} extension-types show-by-cluster --resource-group my-resource-group \
--cluster-name mycluster --cluster-type connectedClusters --extension-type microsoft.openservicemesh
"""

helps[f'{consts.EXTENSION_NAME} extension-types show-by-location'] = f"""
type: command
short-summary: Show properties for a Cluster Extension Type in a region.
examples:
- name: Show properties for a Cluster Extension Type in a region
text: |-
az {consts.EXTENSION_NAME} extension-types show-by-location --location eastus --extension-type microsoft.openservicemesh
"""

helps[f'{consts.EXTENSION_NAME} extension-types show-version-by-cluster'] = f"""
type: command
short-summary: Show properties associated with a Cluster Extension Type version for an existing cluster. The properties used for filtering include type of cluster (managed, connected, etc), kubernetes version, location of the cluster.
examples:
- name: Show properties associated with a Cluster Extension Type version for an existing cluster
text: |-
az {consts.EXTENSION_NAME} extension-types show-version-by-cluster --resource-group my-resource-group \
--cluster-name mycluster --cluster-type connectedClusters --extension-type microsoft.openservicemesh --version 1.0.0
"""

helps[f'{consts.EXTENSION_NAME} extension-types show-version-by-location'] = f"""
type: command
short-summary: Show properties associated with a Cluster Extension Type version in a region.
examples:
- name: Show properties associated with a Cluster Extension Type version in a region.
text: |-
az {consts.EXTENSION_NAME} extension-types show-version-by-location --location eastus --extension-type microsoft.openservicemesh \
--version 1.0.0
"""

helps[f'{consts.EXTENSION_NAME} extension-types list-by-cluster'] = f"""
type: command
short-summary: List available Cluster Extension Types for an existing cluster. The properties used for filtering include type of cluster (managed, connected, etc), kubernetes version, location of the cluster.
examples:
- name: List available Cluster Extension Types for an existing cluster
text: |-
az {consts.EXTENSION_NAME} extension-types list-by-cluster --resource-group my-resource-group \
az {consts.EXTENSION_NAME} extension-types list --resource-group my-resource-group \
--cluster-name mycluster --cluster-type connectedClusters
"""

helps[f'{consts.EXTENSION_NAME} extension-types list-by-location'] = f"""
type: command
short-summary: List available Cluster Extension Types in a region.
short-summary: List available Kubernetes Extension Types in a specified region.
examples:
- name: List available Cluster Extension Types in a region
- name: List Kubernetes Extension Types by location
text: |-
az {consts.EXTENSION_NAME} extension-types list-by-location --location eastus
az {consts.EXTENSION_NAME} extension-types list-by-location --location eastus2euap
"""

helps[f'{consts.EXTENSION_NAME} extension-types list-versions-by-cluster'] = f"""
helps[f'{consts.EXTENSION_NAME} extension-types show'] = f"""
type: command
short-summary: List available versions for a Cluster Extension Type for a given cluster. The properties used for filtering include type of cluster (managed, connected, etc), kubernetes version, location of the cluster.
short-summary: Show properties for a Kubernetes Extension Type.
examples:
- name: List available versions for a Cluster Extension Type for a given cluster
- name: Show Kubernetes Extension Type
text: |-
az {consts.EXTENSION_NAME} extension-types list-versions-by-cluster --resource-group my-resource-group \
--cluster-name mycluster --cluster-type connectedClusters --extension-type microsoft.flux
az {consts.EXTENSION_NAME} extension-types show --resource-group my-resource-group \
--cluster-name mycluster --cluster-type connectedClusters --extension-type cassandradatacenteroperator
"""

helps[f'{consts.EXTENSION_NAME} extension-types list-versions-by-location'] = f"""
helps[f'{consts.EXTENSION_NAME} extension-types list-versions'] = f"""
type: command
short-summary: List available versions for a Cluster Extension Type versions in a region.
short-summary: List available versions for a Kubernetes Extension Type.
examples:
- name: List available versions for a Cluster Extension Type versions in a region
- name: List versions for an Extension Type
text: |-
az {consts.EXTENSION_NAME} extension-types list-versions-by-location --location eastus --extension-type microsoft.flux
az {consts.EXTENSION_NAME} extension-types list-versions --location eastus2euap \
--extension-type cassandradatacenteroperator
"""
40 changes: 19 additions & 21 deletions src/k8s-extension/azext_k8s_extension/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,34 +99,32 @@ def load_arguments(self, _):
c.argument('force',
help='Specify whether to force delete the extension from the cluster.')

with self.argument_context(f"{consts.EXTENSION_NAME} extension-types") as c:
with self.argument_context(f"{consts.EXTENSION_NAME} extension-types list") as c:
c.argument('cluster_name',
options_list=['--cluster-name', '-c'],
help='Name of the Kubernetes cluster')
c.argument('cluster_type',
arg_type=get_enum_type(['connectedClusters', 'managedClusters', 'appliances']),
options_list=['--cluster-type', '-t'],
help='Specify Arc clusters or AKS managed clusters or Arc appliances.')

with self.argument_context(f"{consts.EXTENSION_NAME} extension-types list-by-location") as c:
c.argument('location',
validator=get_default_location_from_resource_group)

with self.argument_context(f"{consts.EXTENSION_NAME} extension-types show") as c:
c.argument('extension_type',
help='Name of the extension type.')
c.argument('cluster_name',
options_list=['--cluster-name', '-c'],
help='Name of the Kubernetes cluster')
c.argument('cluster_type',
arg_type=get_enum_type(['connectedClusters', 'managedClusters', 'appliances']),
options_list=['--cluster-type', '-t'],
help='Specify Arc clusters or AKS managed clusters or Arc appliances.')

with self.argument_context(f"{consts.EXTENSION_NAME} extension-types list-versions") as c:
c.argument('extension_type',
help='Name of the extension type.')
c.argument('location',
validator=get_default_location_from_resource_group,
help='Name of the location. Values from: `az account list-locations`')
c.argument('version',
help='Version for the extension type.')
c.argument('plan_name',
arg_group="Marketplace",
options_list=['--plan-name'],
help='The plan name is referring to the Marketplace Plan ID of the extension.')
c.argument('plan_product',
arg_group="Marketplace",
options_list=['--plan-product'],
help='The plan product is referring to the Marketplace Product ID of the extension.')
c.argument('plan_publisher',
arg_group="Marketplace",
options_list=['--plan-publisher'],
help='The plan publisher is referring to the Marketplace Publisher ID of the extension')
c.argument('major_version',
help='Filter results by only the major version of an extension type. For example if 1 is specified, all versions with major version 1 (1.1, 1.1.2) will be shown. The default value is None')
c.argument('show_latest',
help='Filter results by only the latest version. For example, if this flag is used the latest version of the extensionType will be shown.')
validator=get_default_location_from_resource_group)
41 changes: 23 additions & 18 deletions src/k8s-extension/azext_k8s_extension/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

# pylint: disable=line-too-long
from azure.cli.core.commands import CliCommandType, client_factory
from ._client_factory import (cf_k8s_extension, cf_k8s_extension_operation, cf_k8s_extension_types)
from ._format import k8s_extension_list_table_format, k8s_extension_show_table_format, k8s_extension_types_list_table_format, k8s_extension_type_versions_list_table_format, k8s_extension_type_show_table_format, k8s_extension_type_version_show_table_format
from ._client_factory import (cf_k8s_extension, cf_k8s_extension_operation, cf_k8s_cluster_extension_types_operation, cf_k8s_cluster_extension_type_operation, cf_k8s_location_extension_types_operation, cf_k8s_extension_type_versions_operation)
from ._format import k8s_extension_list_table_format, k8s_extension_show_table_format, k8s_extension_types_list_table_format, k8s_extension_type_versions_list_table_format, k8s_extension_type_show_table_format
from . import consts


Expand All @@ -27,23 +27,28 @@ def load_command_table(self, _):
# Subgroup - k8s-extension extension-types
k8s_cluster_extension_type_sdk = CliCommandType(
operations_tmpl=consts.EXTENSION_PACKAGE_NAME + '.vendored_sdks.operations#ClusterExtensionTypeOperations.{}',
client_factory=cf_k8s_extension_types)
with self.command_group(consts.EXTENSION_NAME + " extension-types", k8s_cluster_extension_type_sdk, client_factory=cf_k8s_extension_types, is_preview=True) \
client_factory=cf_k8s_cluster_extension_type_operation)
with self.command_group(consts.EXTENSION_NAME + " extension-types", k8s_cluster_extension_type_sdk, client_factory=cf_k8s_cluster_extension_type_operation, is_preview=True) \
as g:
g.custom_command('list-by-location', 'list_extension_types_by_location', table_transformer=k8s_extension_types_list_table_format)
g.custom_command('show-by-location', 'show_extension_type_by_location', table_transformer=k8s_extension_type_show_table_format)
g.custom_show_command('show', 'show_k8s_cluster_extension_type', table_transformer=k8s_extension_type_show_table_format)

g.custom_command('list-versions-by-location', 'list_extension_type_versions_by_location', table_transformer=k8s_extension_type_versions_list_table_format)
g.custom_command('show-version-by-location', 'show_extension_type_version_by_location', table_transformer=k8s_extension_type_version_show_table_format)

g.custom_command('list-by-cluster', 'list_extension_types_by_cluster', table_transformer=k8s_extension_types_list_table_format)
g.custom_command('show-by-cluster', 'show_extension_type_by_cluster', table_transformer=k8s_extension_type_show_table_format)

g.custom_command('list-versions-by-cluster', 'list_extension_type_versions_by_cluster', table_transformer=k8s_extension_type_versions_list_table_format)
g.custom_command('show-version-by-cluster', 'show_extension_type_version_by_cluster', table_transformer=k8s_extension_type_version_show_table_format)

g.custom_show_command('show', 'show_extension_type_by_location', deprecate_info=g.deprecate(redirect='az k8s-extension extension-types show-by-cluster', hide=True), table_transformer=k8s_extension_type_show_table_format)
k8s_cluster_extension_types_sdk = CliCommandType(
operations_tmpl=consts.EXTENSION_PACKAGE_NAME + '.vendored_sdks.operations.#ClusterExtensionTypesOperations.{}',
client_factory=cf_k8s_cluster_extension_types_operation)
with self.command_group(consts.EXTENSION_NAME + " extension-types", k8s_cluster_extension_types_sdk, client_factory=cf_k8s_cluster_extension_types_operation, is_preview=True) \
as g:
g.custom_command('list', 'list_k8s_cluster_extension_types', table_transformer=k8s_extension_types_list_table_format)

g.custom_command('list', 'list_extension_types_by_cluster', deprecate_info=g.deprecate(redirect='az k8s-extension extension-types list-by-cluster', hide=True), table_transformer=k8s_extension_types_list_table_format)
k8s_location_extension_types_sdk = CliCommandType(
operations_tmpl=consts.EXTENSION_PACKAGE_NAME + '.vendored_sdks.operations.#LocationExtensionTypesOperations.{}',
client_factory=cf_k8s_location_extension_types_operation)
with self.command_group(consts.EXTENSION_NAME + " extension-types", k8s_location_extension_types_sdk, client_factory=cf_k8s_location_extension_types_operation, is_preview=True) \
as g:
g.custom_command('list-by-location', 'list_k8s_location_extension_types', table_transformer=k8s_extension_types_list_table_format)

g.custom_command('list-versions', 'list_extension_type_versions_by_cluster', deprecate_info=g.deprecate(redirect='az k8s-extension extension-types list-versions-by-cluster', hide=True), table_transformer=k8s_extension_type_versions_list_table_format)
k8s_extension_type_versions_sdk = CliCommandType(
operations_tmpl=consts.EXTENSION_PACKAGE_NAME + '.vendored_sdks.operations.#ExtensionTypeVersionsOperations.{}',
client_factory=cf_k8s_extension_type_versions_operation)
with self.command_group(consts.EXTENSION_NAME + " extension-types", k8s_extension_type_versions_sdk, client_factory=cf_k8s_extension_type_versions_operation, is_preview=True) \
as g:
g.custom_command('list-versions', 'list_k8s_extension_type_versions', table_transformer=k8s_extension_type_versions_list_table_format)
2 changes: 1 addition & 1 deletion src/k8s-extension/azext_k8s_extension/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@
APPLIANCE_API_VERSION = "2021-10-31-preview"
HYBRIDCONTAINERSERVICE_API_VERSION = "2022-05-01-preview"

EXTENSION_TYPE_API_VERSION = "2023-05-01-preview"
EXTENSION_TYPE_API_VERSION = "2022-01-15-preview"
Loading

0 comments on commit 6be2701

Please sign in to comment.