This repository was archived by the owner on May 13, 2025. It is now read-only.
forked from Azure/azure-cli-extensions
-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy path_validators.py
More file actions
26 lines (20 loc) · 1.3 KB
/
_validators.py
File metadata and controls
26 lines (20 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
from knack.log import get_logger
from azext_k8s_extension._client_factory import _resource_providers_client
from . import consts
logger = get_logger(__name__)
# pylint: disable=broad-except
def validate_cc_registration(cmd):
try:
rp_client = _resource_providers_client(cmd.cli_ctx)
registration_state = rp_client.get(consts.PROVIDER_NAMESPACE).registration_state
if registration_state.lower() != consts.REGISTERED.lower():
logger.warning("'Extensions' cannot be used because '%s' provider has not been registered."
"More details for registering this provider can be found here - "
"https://aka.ms/RegisterKubernetesConfigurationProvider", consts.PROVIDER_NAMESPACE)
except Exception:
logger.warning("Unable to fetch registration state of '%s' provider. "
"Failed to enable 'extensions' feature...", consts.PROVIDER_NAMESPACE)