This commit is contained in:
Jim Minter 2020-03-18 18:22:53 -06:00
Родитель 0a200a4128
Коммит 84901e0e6c
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 0730CBDA10D1A2D3
3 изменённых файлов: 22 добавлений и 0 удалений

Просмотреть файл

@ -6,6 +6,7 @@ from azext_aro._validators import validate_client_id
from azext_aro._validators import validate_client_secret
from azext_aro._validators import validate_cluster_resource_group
from azext_aro._validators import validate_domain
from azext_aro._validators import validate_pull_secret
from azext_aro._validators import validate_subnet
from azext_aro._validators import validate_visibility
from azext_aro._validators import validate_vnet
@ -28,6 +29,9 @@ def load_arguments(self, _):
c.argument('tags',
tags_type)
c.argument('pull_secret',
help='Pull secret of cluster.',
validator=validate_pull_secret)
c.argument('domain',
help='Domain of cluster.',
validator=validate_domain)

Просмотреть файл

@ -2,18 +2,22 @@
# Licensed under the Apache License 2.0.
import ipaddress
import json
import re
import uuid
from azure.cli.core.commands.client_factory import get_mgmt_service_client
from azure.cli.core.commands.client_factory import get_subscription_id
from azure.cli.core.profiles import ResourceType
from knack.log import get_logger
from knack.util import CLIError
from msrestazure.azure_exceptions import CloudError
from msrestazure.tools import is_valid_resource_id
from msrestazure.tools import parse_resource_id
from msrestazure.tools import resource_id
logger = get_logger(__name__)
def validate_cidr(key):
def _validate_cidr(namespace):
@ -75,6 +79,18 @@ def _validate_int(key, i):
return i
def validate_pull_secret(namespace):
if namespace.pull_secret is None:
logger.warning("No --pull-secret provided: cluster will not include Red Hat or certified samples or operators.")
else:
try:
if not isinstance(json.loads(namespace.pull_secret), dict):
raise Exception()
except:
raise CLIError("Invalid --pull-secret.")
def validate_subnet(key):
def _validate_subnet(cmd, namespace):
subnet = getattr(namespace, key)

Просмотреть файл

@ -25,6 +25,7 @@ def aro_create(cmd, # pylint: disable=too-many-locals
vnet=None,
vnet_resource_group_name=None, # pylint: disable=unused-argument
location=None,
pull_secret=None,
domain=None,
cluster_resource_group=None,
client_id=None,
@ -68,6 +69,7 @@ def aro_create(cmd, # pylint: disable=too-many-locals
location=location,
tags=tags,
cluster_profile=v2019_12_31_preview.ClusterProfile(
pull_secret=pull_secret or "",
domain=domain or random_id,
resource_group_id='/subscriptions/%s/resourceGroups/%s' %
(subscription_id, cluster_resource_group or "aro-" + random_id),