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

Adding GA api version 2022-11-01 exposing isSystemExtension and suppo… #199

Merged
merged 3 commits into from
Jan 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions src/k8s-extension/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ az k8s-extension create \
--version versionNumber \
--auto-upgrade-minor-version autoUpgrade \
--configuration-settings exampleSetting=exampleValue \
--plan-name examplePlanName \
--plan-publisher examplePublisher \
--plan-product exampleOfferId \

Arif-lakhani marked this conversation as resolved.
Show resolved Hide resolved
```

##### Get a KubernetesExtension
Expand Down
9 changes: 9 additions & 0 deletions src/k8s-extension/azext_k8s_extension/_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,21 @@ def k8s_extension_show_table_format(result):


def __get_table_row(result):
plan_name, plan_publisher, plan_product = '', '', ''
if result['plan']:
plan_name = result['plan']['name']
plan_publisher = result['plan']['publisher']
plan_product = result['plan']['product']
return OrderedDict([
('name', result['name']),
('extensionType', result.get('extensionType', '')),
('version', result.get('version', '')),
('provisioningState', result.get('provisioningState', '')),
('lastModifiedAt', result.get('systemData', {}).get('lastModifiedAt', '')),
('plan_name', plan_name),
{'plan_publisher', plan_publisher},
('plan_product', plan_product),
('isSystemExtension', result.get('isSystemExtension', '')),
])


Expand Down
14 changes: 10 additions & 4 deletions src/k8s-extension/azext_k8s_extension/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,19 @@

helps[f'{consts.EXTENSION_NAME} create'] = f"""
type: command
short-summary: Create a Kubernetes Extension.
short-summary: Create a Kubernetes Cluster Extension, including purchasing an extension Offer from Azure Marketplace (AKS only). Please refer to the example at the end to see how to create an extension or purchase an extension offer.
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
- name: Create a Kubernetes Marketplace Extension
text: |-
az {consts.EXTENSION_NAME} create --resource-group my-resource-group \
--cluster-name mycluster --cluster-type managedClusters --name myextension \
--extension-type Contoso.AzureVoteKubernetesAppTest --scope cluster --release-train stable \
--plan-name testplan --plan-product kubernetest_apps_demo_offer --plan-publisher test_test_mix3pptest0011614206850774
"""

helps[f'{consts.EXTENSION_NAME} list'] = f"""
Expand Down Expand Up @@ -67,9 +73,9 @@
--cluster-name mycluster --cluster-type connectedClusters \
--name myextension --auto-upgrade true/false --version extension-version \
--release-train stable --configuration-settings settings-key=settings-value \
--configuration-protected-settings protected-settings-key=protected-value \
--configuration-settings-file=config-settings-file \
--configuration-protected-settings-file=protected-settings-file
--config-protected-settings protected-settings-key=protected-value \
--config-settings-file=config-settings-file \
--config-protected-file=protected-settings-file
"""

helps[f'{consts.EXTENSION_NAME} extension-types'] = """
Expand Down
23 changes: 17 additions & 6 deletions src/k8s-extension/azext_k8s_extension/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from .action import (
AddConfigurationSettings,
AddConfigurationProtectedSettings
AddConfigurationProtectedSettings,
)


Expand Down Expand Up @@ -52,30 +52,41 @@ def load_arguments(self, _):
help='Specify the release train for the extension type.')
c.argument('configuration_settings',
arg_group="Configuration",
options_list=['--configuration-settings', '--config-settings', '--config'],
Arif-lakhani marked this conversation as resolved.
Show resolved Hide resolved
options_list=['--configuration-settings', '--config'],
action=AddConfigurationSettings,
nargs='+',
help='Configuration Settings as key=value pair. Repeat parameter for each setting')
c.argument('configuration_protected_settings',
arg_group="Configuration",
options_list=['--configuration-protected-settings', '--config-protected-settings', '--config-protected'],
options_list=['--config-protected-settings', '--config-protected'],
action=AddConfigurationProtectedSettings,
nargs='+',
help='Configuration Protected Settings as key=value pair. Repeat parameter for each setting')
c.argument('configuration_settings_file',
arg_group="Configuration",
options_list=['--configuration-settings-file', '--config-settings-file', '--config-file'],
options_list=['--config-settings-file', '--config-file'],
help='JSON file path for configuration-settings')
c.argument('configuration_protected_settings_file',
arg_group="Configuration",
options_list=['--configuration-protected-settings-file', '--config-protected-settings-file', '--config-protected-file'],
options_list=['--config-protected-file', '--protected-settings-file'],
help='JSON file path for configuration-protected-settings')
c.argument('release_namespace',
help='Specify the namespace to install the extension release.')
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\'')

c.argument('plan_name',
arg_group="Marketplace",
options_list=['--plan-name'],
help='The plan name is referring to the Plan ID of the extension that is being taken from Marketplace portal under Usage Information + Support')
c.argument('plan_product',
arg_group="Marketplace",
options_list=['--plan-product'],
Arif-lakhani marked this conversation as resolved.
Show resolved Hide resolved
help='The plan product is referring to the Product ID of the extension that is being taken from Marketplace portal under Usage Information + Support. An example of this is the name of the ISV offering used.')
Arif-lakhani marked this conversation as resolved.
Show resolved Hide resolved
c.argument('plan_publisher',
arg_group="Marketplace",
options_list=['--plan-publisher'],
help='The plan publisher is referring to the Publisher ID of the extension that is being taken from Marketplace portal under Usage Information + Support')
with self.argument_context(f"{consts.EXTENSION_NAME} update") as c:
c.argument('yes',
options_list=['--yes', '-y'],
Expand Down
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 @@ -21,7 +21,7 @@
PROVISIONED_CLUSTER_TYPE = "provisionedclusters"

CONNECTED_CLUSTER_API_VERSION = "2021-10-01"
MANAGED_CLUSTER_API_VERSION = "2021-10-01"
MANAGED_CLUSTER_API_VERSION = "2022-11-01"
Arif-lakhani marked this conversation as resolved.
Show resolved Hide resolved
APPLIANCE_API_VERSION = "2021-10-31-preview"
HYBRIDCONTAINERSERVICE_API_VERSION = "2022-05-01-preview"

Expand Down
6 changes: 6 additions & 0 deletions src/k8s-extension/azext_k8s_extension/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ def create_k8s_extension(
configuration_settings_file=None,
configuration_protected_settings_file=None,
no_wait=False,
plan_name=None,
plan_publisher=None,
plan_product=None
):
"""Create a new Extension Instance."""

Expand Down Expand Up @@ -182,6 +185,9 @@ def create_k8s_extension(
config_protected_settings,
configuration_settings_file,
configuration_protected_settings_file,
plan_name,
plan_publisher,
plan_product
)

# Common validations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ class AzureDefender(DefaultExtension):
def Create(self, cmd, client, resource_group_name, cluster_name, name, cluster_type, cluster_rp,
extension_type, scope, auto_upgrade_minor_version, release_train, version, target_namespace,
release_namespace, configuration_settings, configuration_protected_settings,
configuration_settings_file, configuration_protected_settings_file):
configuration_settings_file, configuration_protected_settings_file, plan_name,
plan_publisher, plan_product):

"""ExtensionType 'microsoft.azuredefender.kubernetes' specific validations & defaults for Create
Must create and return a valid 'Extension' object.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ def __init__(self):
def Create(self, cmd, client, resource_group_name, cluster_name, name, cluster_type, cluster_rp,
extension_type, scope, auto_upgrade_minor_version, release_train, version, target_namespace,
release_namespace, configuration_settings, configuration_protected_settings,
configuration_settings_file, configuration_protected_settings_file):
configuration_settings_file, configuration_protected_settings_file, plan_name,
plan_publisher, plan_product):

logger.warning("Troubleshooting: {}".format(self.TSG_LINK))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ class ContainerInsights(DefaultExtension):
def Create(self, cmd, client, resource_group_name, cluster_name, name, cluster_type, cluster_rp,
extension_type, scope, auto_upgrade_minor_version, release_train, version, target_namespace,
release_namespace, configuration_settings, configuration_protected_settings,
configuration_settings_file, configuration_protected_settings_file):
configuration_settings_file, configuration_protected_settings_file,
plan_name, plan_publisher, plan_product):
"""ExtensionType 'microsoft.azuremonitor.containers' specific validations & defaults for Create
Must create and return a valid 'Extension' object.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ def Create(self, cmd, client, resource_group_name: str, cluster_name: str, name:
cluster_rp: str, extension_type: str, scope: str, auto_upgrade_minor_version: bool,
release_train: str, version: str, target_namespace: str, release_namespace: str,
configuration_settings: dict, configuration_protected_settings: dict,
configuration_settings_file: str, configuration_protected_settings_file: str):
configuration_settings_file: str, configuration_protected_settings_file: str,
plan_name: str, plan_publisher: str, plan_product: str):
"""ExtensionType 'Microsoft.Dapr' specific validations & defaults for Create
Must create and return a valid 'ExtensionInstance' object.
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ def Create(
configuration_settings,
configuration_protected_settings,
configuration_settings_file,
configuration_protected_settings_file
configuration_protected_settings_file,
plan_name,
Arif-lakhani marked this conversation as resolved.
Show resolved Hide resolved
plan_publisher,
plan_product,
):
# Current scope of DataProtection Kubernetes Backup extension is 'cluster' #TODO: add TSGs when they are in place
if scope == 'namespace':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
# pylint: disable=unused-argument

from azure.cli.core.util import user_confirmation
from azure.cli.core.azclierror import ArgumentUsageError

from ..vendored_sdks.models import Extension
from ..vendored_sdks.models import PatchExtension
from ..vendored_sdks.models import ScopeCluster
from ..vendored_sdks.models import ScopeNamespace
from ..vendored_sdks.models import Scope
from ..vendored_sdks.models import Plan

from .PartnerExtensionModel import PartnerExtensionModel

Expand All @@ -37,6 +39,9 @@ def Create(
configuration_protected_settings,
configuration_settings_file,
configuration_protected_settings_file,
plan_name,
plan_publisher,
plan_product
):
"""Default validations & defaults for Create
Must create and return a valid 'Extension' object.
Expand All @@ -50,6 +55,21 @@ def Create(
scope_namespace = ScopeNamespace(target_namespace=target_namespace)
ext_scope = Scope(namespace=scope_namespace, cluster=None)

plan = None
if plan_name is not None or plan_product is not None or plan_publisher is not None:
if plan_name is None:
raise ArgumentUsageError('Usage error: Missing valid plan name. To find the correct plan name please refer to the Marketplace portal under ‘Usage Information + Support.’ The Plan Id listed here will be the valid plan name required.')
if plan_product is None:
raise ArgumentUsageError('Usage error: Missing a valid plan product. To find the correct plan product please refer to the Marketplace portal under ‘Usage Information + Support.’ The Product Id listed here will be the valid plan product required.')
if plan_publisher is None:
raise ArgumentUsageError('Usage error: Missing a valid plan publisher. To find the correct plan publisher please refer to the Marketplace portal under ‘Usage Information + Support.’ The Publisher Id listed here will be the valid plan publisher required')

plan = Plan(
name=plan_name,
publisher=plan_publisher,
product=plan_product
)

create_identity = True
extension = Extension(
extension_type=extension_type,
Expand All @@ -59,6 +79,7 @@ def Create(
scope=ext_scope,
configuration_settings=configuration_settings,
configuration_protected_settings=configuration_protected_settings,
plan=plan
)
return extension, name, create_identity

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class OpenServiceMesh(DefaultExtension):
def Create(self, cmd, client, resource_group_name, cluster_name, name, cluster_type, cluster_rp,
extension_type, scope, auto_upgrade_minor_version, release_train, version, target_namespace,
release_namespace, configuration_settings, configuration_protected_settings,
configuration_settings_file, configuration_protected_settings_file):
configuration_settings_file, configuration_protected_settings_file, plan_name, plan_publisher, plan_product):
"""ExtensionType 'microsoft.openservicemesh' specific validations & defaults for Create
Must create and return a valid 'Extension' object.
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ def Create(
configuration_protected_settings: dict,
configuration_settings_file: str,
configuration_protected_settings_file: str,
plan_name: str,
plan_publisher: str,
plan_product: str,
) -> Extension:
pass

Expand Down
Loading