Skip to content
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
7 changes: 5 additions & 2 deletions src/azure-cli/azure/cli/command_modules/acs/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,8 @@ def load_arguments(self, _):

# nodepool paramerters
c.argument('nodepool_name', default='nodepool1',
help='Node pool name, up to 12 alphanumeric characters', validator=validate_nodepool_name)
help='Node pool name, alphanumeric characters only. '
'See https://aka.ms/aks-naming-rules for length limits.', validator=validate_nodepool_name)
c.argument('node_vm_size', options_list=['--node-vm-size', '-s'])
c.argument('vm_sizes')
c.argument('os_sku', arg_type=get_enum_type(node_os_skus_create), validator=validate_os_sku)
Expand Down Expand Up @@ -1155,7 +1156,9 @@ def load_arguments(self, _):
c.argument("tier", arg_type=get_enum_type(sku_tiers), validator=validate_sku_tier)

with self.argument_context('aks scale', resource_type=ResourceType.MGMT_CONTAINERSERVICE, operation_group='managed_clusters') as c:
c.argument('nodepool_name', validator=validate_nodepool_name, help='Node pool name, up to 12 alphanumeric characters.')
c.argument('nodepool_name', validator=validate_nodepool_name,
help='Node pool name, alphanumeric characters only. '
'See https://aka.ms/aks-naming-rules for length limits.')

# managed namespace
with self.argument_context("aks namespace") as c:
Expand Down
10 changes: 5 additions & 5 deletions src/azure-cli/azure/cli/command_modules/acs/_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,21 +184,21 @@ def validate_k8s_version(namespace):


def _validate_nodepool_name(nodepool_name):
"""Validates a nodepool name to be at most 12 characters, alphanumeric only."""
"""Validates a nodepool name to be at most 39 characters, alphanumeric only."""
if nodepool_name != "":
if len(nodepool_name) > 12:
raise InvalidArgumentValueError('--nodepool-name can contain at most 12 characters')
if len(nodepool_name) > 39:
Comment thread
FumingZhang marked this conversation as resolved.
raise InvalidArgumentValueError('--nodepool-name can contain at most 39 characters')
if not nodepool_name.isalnum():
raise InvalidArgumentValueError('--nodepool-name should contain only alphanumeric characters')


def validate_nodepool_name(namespace):
"""Validates a nodepool name to be at most 12 characters, alphanumeric only."""
"""Validates a nodepool name to be at most 39 characters, alphanumeric only."""
_validate_nodepool_name(namespace.nodepool_name)


def validate_agent_pool_name(namespace):
"""Validates a nodepool name to be at most 12 characters, alphanumeric only."""
"""Validates a nodepool name to be at most 39 characters, alphanumeric only."""
_validate_nodepool_name(namespace.agent_pool_name)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -725,21 +725,21 @@ class TestValidateNodepoolName(unittest.TestCase):
def test_invalid_nodepool_name_too_long(self):
namespace = SimpleNamespace(
**{
"nodepool_name": "tooLongNodepoolName",
"nodepool_name": "a" * 40,
}
)
with self.assertRaises(InvalidArgumentValueError):
with self.assertRaisesRegex(InvalidArgumentValueError, "at most 39 characters"):
validators.validate_nodepool_name(
namespace
)

def test_invalid_agent_pool_name_too_long(self):
namespace = SimpleNamespace(
**{
"agent_pool_name": "tooLongNodepoolName",
"agent_pool_name": "a" * 40,
}
)
with self.assertRaises(InvalidArgumentValueError):
with self.assertRaisesRegex(InvalidArgumentValueError, "at most 39 characters"):
validators.validate_agent_pool_name(
namespace
)
Expand Down Expand Up @@ -786,6 +786,24 @@ def test_valid_agent_pool_name(self):
namespace
)

def test_valid_nodepool_name_length_boundaries(self):
for length in (12, 13, 39):
with self.subTest(length=length):
namespace = SimpleNamespace(nodepool_name="a" * length)
validators.validate_nodepool_name(namespace)

def test_valid_agent_pool_name_length_boundaries(self):
for length in (12, 13, 39):
with self.subTest(length=length):
namespace = SimpleNamespace(agent_pool_name="a" * length)
validators.validate_agent_pool_name(namespace)

def test_valid_empty_nodepool_name(self):
validators.validate_nodepool_name(SimpleNamespace(nodepool_name=""))

def test_valid_empty_agent_pool_name(self):
validators.validate_agent_pool_name(SimpleNamespace(agent_pool_name=""))


class GatewayPrefixSizeSpace:
def __init__(self, gateway_prefix_size=None, mode=None):
Expand Down
Loading