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

[k8s-extension] Release for GA v1.0.0 #3991

Merged
merged 160 commits into from
Oct 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
160 commits
Select commit Hold shift + click to select a range
828f9d3
Create pull.yml
jonathan-innis Mar 10, 2021
1436bfc
Update pull.yml
jonathan-innis Mar 10, 2021
6cffd96
Update azure-pipelines.yml
jonathan-innis Mar 10, 2021
db0f4bd
Initial commit of k8s-extension
jonathan-innis Mar 10, 2021
3e2ea64
Update pipelines file
jonathan-innis Mar 10, 2021
9bbc0e4
Update CODEOWNERS
jonathan-innis Mar 10, 2021
8d46cbc
Update private preview pipelines
jonathan-innis Mar 11, 2021
6c3ba41
Remove open service mesh from public release
jonathan-innis Mar 11, 2021
a98e996
Merge pull request #6 from Azure/master
jonathan-innis Mar 11, 2021
43c6796
Update pipeline files
jonathan-innis Mar 11, 2021
009a83e
Update public extension pipeline
jonathan-innis Mar 12, 2021
8e058c5
Change condition variable
jonathan-innis Mar 12, 2021
dea40c1
Add version to public preview/private preview
jonathan-innis Mar 12, 2021
69269e0
Merge branch 'master' of https://github.com/Azure/azure-cli-extension…
jonathan-innis Mar 12, 2021
e81e010
Update pipelines
jonathan-innis Mar 12, 2021
9621a48
Add different testing based on private branch
jonathan-innis Mar 12, 2021
862a035
Add annotations to extension model
jonathan-innis Mar 12, 2021
e1c3d12
Update k8s-custom-pipelines.yml
jonathan-innis Mar 15, 2021
3e309bf
Update SDKs with Updated Swagger Spec for 2020-07-01-preview (#13)
jonathan-innis Mar 16, 2021
1df2ef5
remove py2 bdist support
jonathan-innis Mar 16, 2021
054a903
Add custom table formatting
jonathan-innis Mar 16, 2021
b298252
Remove unnecessary files
jonathan-innis Mar 16, 2021
afb4046
Fix style issues
jonathan-innis Mar 16, 2021
49b7eac
Merge branch 'master' of https://github.com/Azure/azure-cli-extension…
Mar 17, 2021
a13304d
Merge branch 'master' of https://github.com/Azure/azure-cli-extension…
Mar 17, 2021
aa078b0
Merge branch 'release' into k8s-extension/public
jonathan-innis Mar 17, 2021
21dff06
Fix branch based on comments
jonathan-innis Mar 17, 2021
93919f2
Update identity piece manually
jonathan-innis Mar 17, 2021
a88127a
Merge branch 'k8s-extension/public' of github.com:AzureArcForKubernet…
jonathan-innis Mar 17, 2021
7e40b3a
Don't handle defaults at the CLI level
jonathan-innis Mar 17, 2021
483202c
Merge branch 'master' of https://github.com/Azure/azure-cli-extension…
Mar 17, 2021
d1befa8
Remove defaults from CLI client
jonathan-innis Mar 17, 2021
c7bd93f
Merge branch 'release' into k8s-extension/public
jonathan-innis Mar 17, 2021
076827c
Check null target namespace with namespace scope
jonathan-innis Mar 17, 2021
550eea1
Update style
jonathan-innis Mar 17, 2021
1a17f1b
Merge branch 'k8s-extension/public' of github.com:AzureArcForKubernet…
jonathan-innis Mar 17, 2021
fbab3be
Add cassandra operator and location to model
jonathan-innis Mar 17, 2021
9aade9f
Stage Public Version of k8s-extension 0.2.0 for official release (#15)
jonathan-innis Mar 18, 2021
7f79cfb
Remove custom pipelines file
jonathan-innis Mar 18, 2021
1337996
Merge branch 'release' of https://github.com/AzureArcForKubernetes/az…
Mar 19, 2021
f6e68e9
Merge branch 'master' of https://github.com/Azure/azure-cli-extension…
Mar 20, 2021
f57af40
Merge branch 'release' of https://github.com/AzureArcForKubernetes/az…
Mar 20, 2021
e75f329
Merge branch 'master' of https://github.com/Azure/azure-cli-extension…
Mar 23, 2021
a47b63a
Merge branch 'release' of https://github.com/AzureArcForKubernetes/az…
Mar 23, 2021
6c4e0e6
Merge branch 'master' of https://github.com/Azure/azure-cli-extension…
Mar 24, 2021
bb88024
Merge branch 'release' of https://github.com/AzureArcForKubernetes/az…
Mar 24, 2021
9f06b49
Update extension description, remove private const
jonathan-innis Mar 24, 2021
a063594
Merge branch 'release' into k8s-extension/public
jonathan-innis Mar 24, 2021
eb4c58b
Update pipeline file
jonathan-innis Mar 24, 2021
20d809c
Merge branch 'master' of https://github.com/Azure/azure-cli-extension…
Mar 25, 2021
9524cda
Merge branch 'release' of https://github.com/AzureArcForKubernetes/az…
Mar 25, 2021
16489b8
Merge branch 'master' of https://github.com/Azure/azure-cli-extension…
Mar 26, 2021
ee395f2
Merge branch 'release' of https://github.com/AzureArcForKubernetes/az…
Mar 26, 2021
fbd331c
Merge branch 'master' of https://github.com/Azure/azure-cli-extension…
Mar 27, 2021
9c86220
Merge branch 'release' of https://github.com/AzureArcForKubernetes/az…
Mar 27, 2021
89828c5
Merge branch 'master' of https://github.com/Azure/azure-cli-extension…
Mar 31, 2021
bed066c
Merge branch 'release' of https://github.com/AzureArcForKubernetes/az…
Mar 31, 2021
8011213
Merge branch 'master' of https://github.com/Azure/azure-cli-extension…
Apr 1, 2021
491c1e5
Merge branch 'release' of https://github.com/AzureArcForKubernetes/az…
Apr 1, 2021
cfd267d
Merge branch 'master' of https://github.com/Azure/azure-cli-extension…
Apr 2, 2021
b9d1778
Merge branch 'release' of https://github.com/AzureArcForKubernetes/az…
Apr 2, 2021
3290f6e
Disable refs docs
jonathan-innis Apr 2, 2021
22c8e92
Update to include better create warning logs and remove update contex…
jonathan-innis Apr 2, 2021
12212f1
Merge branch 'master' of https://github.com/Azure/azure-cli-extension…
Apr 3, 2021
010e9a8
Merge branch 'release' of https://github.com/AzureArcForKubernetes/az…
Apr 3, 2021
6bbf418
Merge branch 'master' of https://github.com/Azure/azure-cli-extension…
Apr 11, 2021
df82dd8
Fix k8s-extension conflict with private version
jonathan-innis Apr 14, 2021
0228851
Fix style errors
jonathan-innis Apr 14, 2021
db4c5b2
Fix filename
jonathan-innis Apr 14, 2021
2971d69
Merge branch 'master' of https://github.com/Azure/azure-cli-extension…
Apr 18, 2021
5077192
add customization for microsoft.azureml.kubernetes (#23)
yuyue9284 Apr 23, 2021
dc0c178
Merge branch 'master' of https://github.com/Azure/azure-cli-extension…
Apr 25, 2021
3d15151
Add E2E Testing from Separate branch into internal code (#26)
jonathan-innis Apr 26, 2021
1ded405
Inference CLI validation for Scoring FE (#24)
liakaz Apr 27, 2021
53303d5
legal warning added (#27)
liakaz Apr 27, 2021
3370264
Remove deprecated method logger.warn
jonathan-innis Apr 27, 2021
4c66aef
Update k8s-custom-pipelines.yml for Azure Pipelines
jonathan-innis Apr 27, 2021
e8651f2
Update k8s-custom-pipelines.yml for Azure Pipelines
jonathan-innis Apr 27, 2021
9de1e4e
Add Azure Defender to E2E testing (#28)
jonathan-innis Apr 28, 2021
9c0317d
Add configuration testing
jonathan-innis Apr 28, 2021
4c21482
Fix pipeline failures
jonathan-innis Apr 28, 2021
3e2fb15
Make test script more intuitive
jonathan-innis Apr 29, 2021
4dca64d
Remove parameter from testing
jonathan-innis Apr 29, 2021
c93e958
Fix wrong location for k8s config whl
jonathan-innis Apr 29, 2021
27e9b4a
Merge branch 'master' of https://github.com/Azure/azure-cli-extension…
jonathan-innis May 3, 2021
cb30f9d
Merge branch 'master' of https://github.com/Azure/azure-cli-extension…
May 3, 2021
7276f4a
Merge branch 'k8s-extension/public' of github.com:AzureArcForKubernet…
jonathan-innis May 6, 2021
3dafc08
Fix pip upgrade issue
jonathan-innis May 6, 2021
c5bd1c2
Fix pip install upgrade issue
jonathan-innis May 6, 2021
d9e8760
Fix pip install issue
jonathan-innis May 6, 2021
9709504
delete resurce in testcase (#29)
yuyue9284 May 7, 2021
3f620a8
Check Provider is Registered with Subscription Before Making Requests…
jonathan-innis May 7, 2021
cf95612
only validate scoring fe when inference is enabled (#31)
yuyue9284 May 11, 2021
fea6e00
Provider registration case insensitive
jonathan-innis May 11, 2021
877868c
do not validate against scoring fe if inference is not enabled. (#33)
yuyue9284 May 13, 2021
7ea157b
Merge branch 'master' of https://github.com/Azure/azure-cli-extension…
jonathan-innis May 13, 2021
a50ade7
Merge branch 'k8s-extension/public' of github.com:AzureArcForKubernet…
jonathan-innis May 13, 2021
9b1bedd
Add OSM as Public Preview Extension (#34)
jonathan-innis May 13, 2021
257dbf3
Fix release train check in update
jonathan-innis May 14, 2021
a203575
Parallelize E2E Testing (#36)
jonathan-innis May 14, 2021
8d65189
Fix azureml deletion
jonathan-innis May 14, 2021
ec14c6d
Merge branch 'k8s-extension/public' of github.com:AzureArcForKubernet…
jonathan-innis May 14, 2021
918bc02
Fix private build (#40)
jonathan-innis May 21, 2021
8b2490d
change amlk8s to amlarc (#42)
yuyue9284 May 25, 2021
724acde
Merge branch 'master' of https://github.com/Azure/azure-cli-extension…
jonathan-innis May 27, 2021
9100ff5
Servicebus client model changes (#44)
jonathan-innis May 27, 2021
6955567
Read SSL cert and key from files (#38)
liakaz Jun 2, 2021
a46235b
Upgrade release version
jonathan-innis Jun 2, 2021
b0f25af
Merge branch 'master' of https://github.com/Azure/azure-cli-extension…
jonathan-innis Jun 2, 2021
2889d53
Liakaz/inference read ssl from file (#47)
liakaz Jun 3, 2021
67babd8
Fix style issues (#51)
jonathan-innis Jun 4, 2021
590e642
Fixed scoring fe related extension param names (#49)
liakaz Jun 8, 2021
fc661a8
Add distro validation for osm-arc (#50)
nshankar13 Jun 11, 2021
eb466aa
Add distro validation for osm-arc (#50)
nshankar13 Jun 11, 2021
b9b932a
Merge branch 'k8s-extension/public' of github.com:AzureArcForKubernet…
jonathan-innis Jun 11, 2021
b0af598
Add distro validation for osm-arc (#53)
nshankar13 Jun 15, 2021
c355ad5
Add Custom Delete Logic for Partners (#54)
jonathan-innis Jun 22, 2021
cda5e41
Add warning message when deleting amlarc extension (#55)
jingyizhu99 Jun 23, 2021
c423e54
Update release version
jonathan-innis Jun 24, 2021
0080c80
Merge branch 'main' of https://github.com/Azure/azure-cli-extensions …
jonathan-innis Jun 24, 2021
58b4df8
Remove Pyhelm from OSM customization (#58)
jonathan-innis Jul 9, 2021
0b56023
Merge branch 'main' of https://github.com/Azure/azure-cli-extensions …
jonathan-innis Jul 9, 2021
7712f52
Update release message
jonathan-innis Jul 9, 2021
4ca94bd
Remove pyhelm dependency
jonathan-innis Jul 9, 2021
de426d4
Merge branch 'main' of https://github.com/Azure/azure-cli-extensions …
jonathan-innis Jul 9, 2021
0336667
Merge branch 'main' of https://github.com/Azure/azure-cli-extensions …
jonathan-innis Jul 9, 2021
5bfabdb
Merge branch 'main' of https://github.com/Azure/azure-cli-extensions …
jonathan-innis Jul 9, 2021
a5ef607
Update tests to only check extensionconfig creation (#61)
jonathan-innis Jul 9, 2021
79bb7b2
Merge branch 'main' of https://github.com/Azure/azure-cli-extensions …
jonathan-innis Jul 19, 2021
fb8682a
Merge branch 'k8s-extension/public' of github.com:AzureArcForKubernet…
jonathan-innis Jul 19, 2021
d8528be
Increase open service mesh version number
jonathan-innis Jul 19, 2021
64ac05a
Update k8s-extension Models to Track2 (#64)
jonathan-innis Jul 20, 2021
a862b09
Merge branch 'main' of https://github.com/Azure/azure-cli-extensions …
jonathan-innis Jul 20, 2021
bf15d99
Fix identity in wrong place in model (#66)
jonathan-innis Jul 23, 2021
65edba6
Merge branch 'main' of https://github.com/Azure/azure-cli-extensions …
jonathan-innis Jul 23, 2021
bc48fdb
Readd osm-arc distro validation (#62)
nshankar13 Jul 27, 2021
ec40c30
Merge branch 'Azure:main' into k8s-extension/public
jonathan-innis Jul 27, 2021
611b81f
Don't Send Identity Headers If In DF (#67)
jonathan-innis Jul 27, 2021
a0431a6
Use default extension with identity instead of Cassandra specific (#69)
jonathan-innis Jul 28, 2021
6c271d5
Merge branch 'Azure:main' into k8s-extension/public
jonathan-innis Jul 28, 2021
a2a4050
Remove the identity check for now
jonathan-innis Jul 28, 2021
52d3fad
Merge branch 'main' of https://github.com/Azure/azure-cli-extensions …
jonathan-innis Aug 11, 2021
30b407c
Add -t for clusterType parameter (#71)
jonathan-innis Aug 11, 2021
ac02d5a
Adding a flag for AKS to AMLARC migration and set up corresponding FE…
tianchijushi Aug 12, 2021
3a293ed
remove version requirement and auto upgrade minor version check (#72)
trstringer Aug 24, 2021
7deb020
Custom User Confirmation for Partners (#70)
jonathan-innis Aug 24, 2021
dd991f0
Code cleanup and style fixes (#73)
jonathan-innis Aug 27, 2021
01deb1e
Enabled identity by default (#74)
jonathan-innis Aug 27, 2021
8f9386c
Increase version
jonathan-innis Aug 30, 2021
03a376e
Merge branch 'main' of https://github.com/Azure/azure-cli-extensions …
jonathan-innis Aug 30, 2021
e51eb49
Fix df check and add unit test (#77)
jonathan-innis Sep 13, 2021
aa1093a
Merge branch 'main' of https://github.com/Azure/azure-cli-extensions …
jonathan-innis Sep 13, 2021
a69aaa5
Bump extension version
jonathan-innis Sep 13, 2021
1e0c547
Pin helm version
jonathan-innis Sep 20, 2021
f721c84
Merge branch 'Azure:main' into k8s-extension/public
jonathan-innis Oct 14, 2021
bd56e41
Extensions GA changes into Public Branch (#79)
NarayanThiru Oct 19, 2021
30295f7
Remove unneeded files
jonathan-innis Oct 19, 2021
16db052
Fix configuration settings in update
jonathan-innis Oct 20, 2021
89e5e53
Only provide confirmation when specifying settings
jonathan-innis Oct 20, 2021
215b48c
Fix style issues
jonathan-innis Oct 20, 2021
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
7 changes: 7 additions & 0 deletions src/k8s-extension/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
Release History
===============

1.0.0
++++++++++++++++++
* Switch to GA api-version of Extensions (2021-09-01)
* Support Extensions PATCH
* Enable Dapr extension type
* Enable ManagedClusters clusterType

0.7.1
++++++++++++++++++
* Fix DF resource manager endpoint check
Expand Down
16 changes: 15 additions & 1 deletion src/k8s-extension/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,18 @@ az k8s-extension list \
--cluster-type clusterType
```

If you have issues, please give feedback by opening an issue at https://github.com/Azure/azure-cli-extensions/issues.
##### Update an existing KubernetesExtension of a cluster
```
az k8s-extension update \
--resource-group groupName \
--cluster-name clusterName \
--cluster-type clusterType \
--name extensionName \
--auto-upgrade true/false \
--version extensionVersion \
--release-train releaseTrain \
--configuration-settings settingsKey=settingsValue \
--configuration-protected-settings protectedSettingsKey=protectedValue \
--configuration-settings-file configSettingsFile \
--configuration-protected-settings-file protectedSettingsFile
```
8 changes: 4 additions & 4 deletions src/k8s-extension/azext_k8s_extension/_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ def k8s_extension_show_table_format(result):
def __get_table_row(result):
return OrderedDict([
('name', result['name']),
('extensionType', result['extensionType']),
('version', result['version']),
('installState', result['installState']),
('lastModifiedTime', result['lastModifiedTime'])
('extensionType', result.get('extensionType', '')),
('version', result.get('version', '')),
('provisioningState', result.get('provisioningState', '')),
('lastModifiedAt', result.get('systemData', {}).get('lastModifiedAt', '')),
])
37 changes: 27 additions & 10 deletions src/k8s-extension/azext_k8s_extension/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@
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
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'] = f"""
Expand All @@ -31,8 +30,8 @@
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
az {consts.EXTENSION_NAME} list --resource-group my-resource-group \
--cluster-name mycluster --cluster-type connectedClusters
"""

helps[f'{consts.EXTENSION_NAME} delete'] = f"""
Expand All @@ -41,8 +40,8 @@
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
az {consts.EXTENSION_NAME} delete --resource-group my-resource-group \
--cluster-name mycluster --cluster-type connectedClusters --name myextension
"""

helps[f'{consts.EXTENSION_NAME} show'] = f"""
Expand All @@ -51,6 +50,24 @@
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
az {consts.EXTENSION_NAME} show --resource-group my-resource-group \
--cluster-name mycluster --cluster-type connectedClusters --name myextension
"""

helps[f'{consts.EXTENSION_NAME} update'] = f"""
type: command
short-summary: Update mutable properties of a Kubernetes Extension.
long-summary: For update to ConfigSettings and ConfigProtectedSettings, please \
refer to documentation of the cluster extension service to check update to these \
properties is supported before updating these properties.
examples:
- name: Update a Kubernetes Extension
text: |-
az {consts.EXTENSION_NAME} update --resource-group my-resource-group \
--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
"""
11 changes: 8 additions & 3 deletions src/k8s-extension/azext_k8s_extension/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

from azure.cli.core.commands.parameters import (
get_enum_type,
get_three_state_flag,
tags_type
get_three_state_flag
)
from azure.cli.core.commands.validators import get_default_location_from_resource_group
from . import consts
Expand All @@ -19,7 +18,6 @@

def load_arguments(self, _):
with self.argument_context(consts.EXTENSION_NAME) as c:
c.argument('tags', tags_type)
c.argument('location',
validator=get_default_location_from_resource_group)
c.argument('name',
Expand Down Expand Up @@ -75,7 +73,14 @@ def load_arguments(self, _):
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} update") as c:
c.argument('yes',
options_list=['--yes', '-y'],
help='Ignore confirmation prompts')

with self.argument_context(f"{consts.EXTENSION_NAME} delete") as c:
c.argument('yes',
options_list=['--yes', '-y'],
help='Ignore confirmation prompts')
c.argument('force',
help='Specify whether to force delete the extension from the cluster.')
1 change: 0 additions & 1 deletion src/k8s-extension/azext_k8s_extension/azext_metadata.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{
"azext.isPreview": true,
"azext.minCliCoreVersion": "2.24.0"
}
8 changes: 4 additions & 4 deletions src/k8s-extension/azext_k8s_extension/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ def load_command_table(self, _):
operations_tmpl=consts.EXTENSION_PACKAGE_NAME + '.vendored_sdks.operations#K8sExtensionsOperations.{}',
client_factory=cf_k8s_extension)

with self.command_group(consts.EXTENSION_NAME, k8s_extension_sdk, client_factory=cf_k8s_extension_operation,
is_preview=True) \
with self.command_group(consts.EXTENSION_NAME, k8s_extension_sdk, client_factory=cf_k8s_extension_operation) \
as g:
g.custom_command('create', 'create_k8s_extension')
g.custom_command('delete', 'delete_k8s_extension')
g.custom_command('create', 'create_k8s_extension', supports_no_wait=True)
g.custom_command('delete', 'delete_k8s_extension', supports_no_wait=True)
g.custom_command('list', 'list_k8s_extension', table_transformer=k8s_extension_list_table_format)
g.custom_show_command('show', 'show_k8s_extension', table_transformer=k8s_extension_show_table_format)
g.custom_command('update', 'update_k8s_extension', supports_no_wait=True)
109 changes: 65 additions & 44 deletions src/k8s-extension/azext_k8s_extension/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,23 @@
# pylint: disable=unused-argument,too-many-locals

import json
from knack.log import get_logger
from urllib.parse import urlparse
from knack.log import get_logger

from azure.cli.core.azclierror import ResourceNotFoundError, MutuallyExclusiveArgumentError, \
InvalidArgumentValueError, CommandNotFoundError, RequiredArgumentMissingError
InvalidArgumentValueError, RequiredArgumentMissingError
from azure.cli.core.commands.client_factory import get_subscription_id
from azure.cli.core.util import sdk_no_wait
from azure.core.exceptions import HttpResponseError
from .vendored_sdks.models import ConfigurationIdentity, Scope
from .vendored_sdks.models import Identity, Scope
from ._validators import validate_cc_registration

from .partner_extensions.ContainerInsights import ContainerInsights
from .partner_extensions.AzureDefender import AzureDefender
from .partner_extensions.AzureMLKubernetes import AzureMLKubernetes
from .partner_extensions.OpenServiceMesh import OpenServiceMesh
from .partner_extensions.DefaultExtension import DefaultExtension
from .partner_extensions.AzureMLKubernetes import AzureMLKubernetes
from .partner_extensions.Dapr import Dapr
from .partner_extensions.DefaultExtension import DefaultExtension, user_confirmation_factory
from . import consts

from ._client_factory import cf_resources
Expand All @@ -35,6 +37,7 @@ def ExtensionFactory(extension_name):
'microsoft.azuredefender.kubernetes': AzureDefender,
'microsoft.openservicemesh': OpenServiceMesh,
'microsoft.azureml.kubernetes': AzureMLKubernetes,
'microsoft.dapr': Dapr,
}

# Return the extension if we find it in the map, else return the default
Expand All @@ -43,7 +46,6 @@ def ExtensionFactory(extension_name):

def show_k8s_extension(client, resource_group_name, cluster_name, name, cluster_type):
"""Get an existing K8s Extension.

"""
# Determine ClusterRP
cluster_rp = __get_cluster_rp(cluster_type)
Expand Down Expand Up @@ -74,9 +76,8 @@ def create_k8s_extension(cmd, client, resource_group_name, cluster_name, name, c
extension_type, scope=None, auto_upgrade_minor_version=None, release_train=None,
version=None, target_namespace=None, release_namespace=None, configuration_settings=None,
configuration_protected_settings=None, configuration_settings_file=None,
configuration_protected_settings_file=None, tags=None):
configuration_protected_settings_file=None, no_wait=False):
jonathan-innis marked this conversation as resolved.
Show resolved Hide resolved
"""Create a new Extension Instance.

"""

extension_type_lower = extension_type.lower()
Expand Down Expand Up @@ -140,60 +141,78 @@ def create_k8s_extension(cmd, client, resource_group_name, cluster_name, name, c
# Create identity, if required
# We don't create the identity if we are in DF
if create_identity and not is_dogfood_cluster(cmd):
extension_instance.identity, extension_instance.location = \
__create_identity(cmd, resource_group_name, cluster_name, cluster_type, cluster_rp)
identity_object, location = __create_identity(cmd, resource_group_name, cluster_name, cluster_type, cluster_rp)
if identity_object is not None and location is not None:
extension_instance.identity, extension_instance.location = identity_object, location

# Try to create the resource
return client.create(resource_group_name, cluster_rp, cluster_type, cluster_name, name, extension_instance)
return sdk_no_wait(no_wait, client.begin_create, resource_group_name,
cluster_rp, cluster_type, cluster_name, name, extension_instance)


def list_k8s_extension(client, resource_group_name, cluster_name, cluster_type):
cluster_rp = __get_cluster_rp(cluster_type)
return client.list(resource_group_name, cluster_rp, cluster_type, cluster_name)


def update_k8s_extension(client, resource_group_name, cluster_type, cluster_name, name,
auto_upgrade_minor_version='', release_train='', version='', tags=None):

def update_k8s_extension(cmd, client, resource_group_name, cluster_name, name, cluster_type,
auto_upgrade_minor_version='', release_train='', version='',
configuration_settings=None, configuration_protected_settings=None,
configuration_settings_file=None, configuration_protected_settings_file=None,
no_wait=False, yes=False):
"""Patch an existing Extension Instance.

"""

# TODO: Remove this after we eventually get PATCH implemented for update and uncomment
raise CommandNotFoundError(
f"\"{consts.EXTENSION_NAME} update\" currently is not available. "
f"Use \"{consts.EXTENSION_NAME} create\" to update a previously created extension instance."
)
if configuration_settings or \
configuration_protected_settings or \
configuration_settings_file or \
configuration_protected_settings_file:
msg = ('Updating properties in --config-settings or --config-protected-settings may lead to undesirable state'
' if the cluster extension type does not support it. Please refer to the documentation of the'
' cluster extension service to check if updates to these properties is supported.'
' Do you wish to proceed?')
user_confirmation_factory(cmd, yes, msg)

# # Ensure some values are provided for update
# if auto_upgrade_minor_version is None and release_train is None and version is None:
# message = "Error! No values provided for update. Provide new value(s) for one or more of these properties:" \
# " auto-upgrade-minor-version, release-train or version."
# raise RequiredArgumentMissingError(message)
# Determine ClusterRP
cluster_rp = __get_cluster_rp(cluster_type)

# # Determine ClusterRP
# cluster_rp = __get_cluster_rp(cluster_type)
# We need to determine the ExtensionType to call ExtensionFactory and create Extension class
extension = show_k8s_extension(client, resource_group_name, cluster_name, name, cluster_type)
extension_type_lower = extension.extension_type.lower()

# # Get the existing extensionInstance
# extension = client.get(resource_group_name, cluster_rp, cluster_type, cluster_name, name)
config_settings = {}
config_protected_settings = {}
# Get Configuration Settings from file
if configuration_settings_file is not None:
config_settings = __read_config_settings_file(configuration_settings_file)

# extension_type_lower = extension.extension_type.lower()
if configuration_settings is not None:
for dicts in configuration_settings:
for key, value in dicts.items():
config_settings[key] = value

# Get Configuration Protected Settings from file
if configuration_protected_settings_file is not None:
config_protected_settings = __read_config_settings_file(configuration_protected_settings_file)

# # Get the extension class based on the extension name
# extension_class = ExtensionFactory(extension_type_lower)
# upd_extension = extension_class.Update(extension, auto_upgrade_minor_version, release_train, version)
if configuration_protected_settings is not None:
for dicts in configuration_protected_settings:
for key, value in dicts.items():
config_protected_settings[key] = value

# __validate_version_and_auto_upgrade(version, auto_upgrade_minor_version)
# Get the extension class based on the extension type
extension_class = ExtensionFactory(extension_type_lower)

# upd_extension = ExtensionInstanceUpdate(auto_upgrade_minor_version=auto_upgrade_minor_version,
# release_train=release_train, version=version)
upd_extension = extension_class.Update(auto_upgrade_minor_version, release_train, version,
config_settings, config_protected_settings)

# return client.update(resource_group_name, cluster_rp, cluster_type, cluster_name, name, upd_extension)
return sdk_no_wait(no_wait, client.begin_update, resource_group_name, cluster_rp, cluster_type,
cluster_name, name, upd_extension)


def delete_k8s_extension(cmd, client, resource_group_name, cluster_name, name, cluster_type, yes=False):
def delete_k8s_extension(cmd, client, resource_group_name, cluster_name, name, cluster_type,
no_wait=False, yes=False, force=False):
"""Delete an existing Kubernetes Extension.

"""
# Determine ClusterRP
cluster_rp = __get_cluster_rp(cluster_type)
Expand All @@ -206,9 +225,11 @@ def delete_k8s_extension(cmd, client, resource_group_name, cluster_name, name, c
extension_class = ExtensionFactory(extension.extension_type.lower())

# If there is any custom delete logic, this will call the logic
extension_class.Delete(cmd, client, resource_group_name, cluster_name, name, cluster_type, yes)
extension_class.Delete(cmd, client, resource_group_name, cluster_name,
name, cluster_type, yes)

return client.delete(resource_group_name, cluster_rp, cluster_type, cluster_name, name)
return sdk_no_wait(no_wait, client.begin_delete, resource_group_name,
cluster_rp, cluster_type, cluster_name, name, force_delete=force)


def __create_identity(cmd, resource_group_name, cluster_name, cluster_type, cluster_rp):
Expand All @@ -226,7 +247,7 @@ def __create_identity(cmd, resource_group_name, cluster_name, cluster_type, clus
elif cluster_rp == 'Microsoft.ResourceConnector':
parent_api_version = '2020-09-15-privatepreview'
elif cluster_rp == 'Microsoft.ContainerService':
parent_api_version = '2017-07-01'
return None, None
else:
raise InvalidArgumentValueError(
"Error! Cluster type '{}' is not supported for extension identity".format(cluster_type)
Expand All @@ -239,7 +260,7 @@ def __create_identity(cmd, resource_group_name, cluster_name, cluster_type, clus
raise ex
identity_type = "SystemAssigned"

return ConfigurationIdentity(type=identity_type), location
return Identity(type=identity_type), location


def __get_cluster_rp(cluster_type):
Expand All @@ -248,7 +269,7 @@ def __get_cluster_rp(cluster_type):
rp = 'Microsoft.Kubernetes'
elif cluster_type.lower() == 'appliances':
rp = 'Microsoft.ResourceConnector'
elif cluster_type.lower() == '':
elif cluster_type.lower() == '' or cluster_type.lower() == 'managedclusters':
rp = 'Microsoft.ContainerService'
else:
raise InvalidArgumentValueError("Error! Cluster type '{}' is not supported".format(cluster_type))
Expand Down
Loading