From 6551847e7429f8313f492c27a755d4fcc82a3268 Mon Sep 17 00:00:00 2001 From: Sean Hobbs Date: Fri, 15 Dec 2023 10:03:40 -0800 Subject: [PATCH 1/7] Style & Linter updates. --- src/fleet/azext_fleet/__init__.py | 6 +++--- src/fleet/azext_fleet/_help.py | 2 +- src/fleet/azext_fleet/_helpers.py | 12 +++++++----- src/fleet/azext_fleet/_params.py | 2 +- src/fleet/azext_fleet/_validators.py | 7 ++++--- src/fleet/azext_fleet/custom.py | 7 +++---- .../latest/recordings/test_fleet_hubful.yaml | 16 ++++++++-------- .../latest/recordings/test_fleet_hubless.yaml | 12 ++++++------ .../tests/latest/test_fleet_hubful_scenario.py | 3 ++- .../tests/latest/test_fleet_hubless_scenario.py | 2 ++ .../azext_fleet/tests/latest/test_validators.py | 15 +++++++++++++++ src/fleet/setup.py | 2 +- 12 files changed, 53 insertions(+), 33 deletions(-) diff --git a/src/fleet/azext_fleet/__init__.py b/src/fleet/azext_fleet/__init__.py index e4693b0774c..d199355ae5f 100644 --- a/src/fleet/azext_fleet/__init__.py +++ b/src/fleet/azext_fleet/__init__.py @@ -26,9 +26,9 @@ def __init__(self, cli_ctx=None): register_fleet_resource_type() fleet_custom = CliCommandType(operations_tmpl='azext_fleet.custom#{}') - super(FleetCommandsLoader, self).__init__(cli_ctx=cli_ctx, - resource_type=CUSTOM_MGMT_FLEET, - custom_command_type=fleet_custom) + super().__init__(cli_ctx=cli_ctx, + resource_type=CUSTOM_MGMT_FLEET, + custom_command_type=fleet_custom) def load_command_table(self, args): from azext_fleet.commands import load_command_table diff --git a/src/fleet/azext_fleet/_help.py b/src/fleet/azext_fleet/_help.py index de244e31cf8..65b88f757ea 100644 --- a/src/fleet/azext_fleet/_help.py +++ b/src/fleet/azext_fleet/_help.py @@ -27,7 +27,7 @@ text: az fleet create -g MyFleetResourceGroup -l MyLocation -n MyFleetName --enable-hub --tags "TagKey=TagValue" - name: Create a fleet with a system assigned managed service identity. text: az fleet create -g MyFleetResourceGroup -l MyLocation -n MyFleetName --enable-managed-identity - - name: Create a fleet with a user provided managed service identity. + - name: Create a fleet with a user assigned managed service identity. text: az fleet create -g MyFleetResourceGroup -l MyLocation -n MyFleetName --enable-managed-identity --assign-identity "/subscription/00000000-0000-0000-0000-000000000000/resourcegroup/MyFleetResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/MyIdentity" """ diff --git a/src/fleet/azext_fleet/_helpers.py b/src/fleet/azext_fleet/_helpers.py index d25760bb8bd..14cd4ac717c 100644 --- a/src/fleet/azext_fleet/_helpers.py +++ b/src/fleet/azext_fleet/_helpers.py @@ -88,7 +88,7 @@ def _merge_kubernetes_configurations(existing_file, addition_file, replace, cont # check that ~/.kube/config is only read- and writable by its owner if platform.system() != "Windows" and not os.path.islink(existing_file): - existing_file_perms = "{:o}".format(stat.S_IMODE(os.lstat(existing_file).st_mode)) + existing_file_perms = f"{stat.S_IMODE(os.lstat(existing_file).st_mode):o}" if not existing_file_perms.endswith("600"): logger.warning( '%s has permissions "%s".\nIt should be readable and writable only by its owner.', @@ -96,7 +96,7 @@ def _merge_kubernetes_configurations(existing_file, addition_file, replace, cont existing_file_perms, ) - with open(existing_file, 'w+') as stream: + with open(existing_file, 'w+', encoding='utf-8') as stream: yaml.safe_dump(existing, stream, default_flow_style=False) current_context = addition.get('current-context', 'UNKNOWN') @@ -133,10 +133,12 @@ def _handle_merge(existing, addition, key, replace): def _load_kubernetes_configuration(filename): try: - with open(filename) as stream: + with open(filename, encoding='utf-8') as stream: return yaml.safe_load(stream) except (IOError, OSError) as ex: if getattr(ex, 'errno', 0) == errno.ENOENT: - raise CLIError(f'{filename} does not exist') + raise CLIError(f'{filename} does not exist') from ex except (yaml.parser.ParserError, UnicodeDecodeError) as ex: - raise CLIError(f'Error parsing {filename} ({str(ex)})') + raise CLIError(f'Error parsing {filename} ({str(ex)})') from ex + + return None diff --git a/src/fleet/azext_fleet/_params.py b/src/fleet/azext_fleet/_params.py index ceb02d92e71..23c47ddef16 100644 --- a/src/fleet/azext_fleet/_params.py +++ b/src/fleet/azext_fleet/_params.py @@ -30,7 +30,7 @@ def load_arguments(self, _): c.argument('apiserver_subnet_id', validator=validate_apiserver_subnet_id, is_preview=True, help='The subnet to be used when apiserver vnet integration is enabled. It is required when creating a new Fleet with BYO vnet.') c.argument('agent_subnet_id', validator=validate_agent_subnet_id, is_preview=True, help='The ID of the subnet which the Fleet hub node will join on startup. If this is not specified, a vnet and subnet will be generated and used.') c.argument('enable_managed_identity', action='store_true', help='Enable system assigned managed identity (MSI) on the Fleet resource.') - c.argument('assign_identity', validator=validate_assign_identity, help='With --enable-managed-identity, enable user assigned managed identity (MSI) on the Fleet resource. Specify the existing user assigned identity resource.') + c.argument('assign_identity', validator=validate_assign_identity, help='With --enable-managed-identity, enable user assigned managed identity (MSI) on the Fleet resource by specifying the user assigned identity\'s resource Id.') c.argument('enable_hub', action='store_true', is_preview=True, help='If set, the Fleet will be created with a hub cluster.') c.argument('vm_size', is_preview=True, validator=validate_vm_size, help='The virtual machine size of the Fleet hub.') diff --git a/src/fleet/azext_fleet/_validators.py b/src/fleet/azext_fleet/_validators.py index 2d5d6a9da55..e6756eefa78 100644 --- a/src/fleet/azext_fleet/_validators.py +++ b/src/fleet/azext_fleet/_validators.py @@ -23,7 +23,8 @@ def validate_kubernetes_version(namespace): found = k8s_release_regex.findall(namespace.kubernetes_version) if not found: raise InvalidArgumentValueError( - '--kubernetes-version should be the full version number or alias minor version, such as "1.7.12" or "1.7"') + '--kubernetes-version should be the full version number ' + 'or alias minor version, such as "1.7.12" or "1.7"') def validate_apiserver_subnet_id(namespace): @@ -36,12 +37,12 @@ def validate_agent_subnet_id(namespace): def validate_update_strategy_name(namespace): if namespace.update_strategy_name is not None and not namespace.update_strategy_name.strip(): - raise CLIError("--update-strategy-name is not a valid name") + raise CLIError("--update-strategy-name is not a valid name") def validate_vm_size(namespace): if namespace.vm_size is not None and not namespace.vm_size.strip(): - raise CLIError("--vm-size is not a valid value") + raise CLIError("--vm-size is not a valid value") def _validate_subnet_id(subnet_id, name): diff --git a/src/fleet/azext_fleet/custom.py b/src/fleet/azext_fleet/custom.py index c1b45fcea95..067b409a0f5 100644 --- a/src/fleet/azext_fleet/custom.py +++ b/src/fleet/azext_fleet/custom.py @@ -33,7 +33,6 @@ def create_fleet(cmd, enable_managed_identity=False, assign_identity=None, no_wait=False): - fleet_model = cmd.get_models( "Fleet", resource_type=CUSTOM_MGMT_FLEET, @@ -208,8 +207,8 @@ def get_credentials(cmd, # pylint: disable=unused-argument encoding='UTF-8') print_or_merge_credentials( path, kubeconfig, overwrite_existing, context_name) - except (IndexError, ValueError): - raise CLIError("Fail to find kubeconfig file.") + except (IndexError, ValueError) as exc: + raise CLIError("Fail to find kubeconfig file.") from exc def create_fleet_member(cmd, @@ -385,7 +384,7 @@ def get_update_run_strategy(cmd, operation_group, stages): if stages is None: return None - with open(stages, 'r') as fp: + with open(stages, 'r', encoding='utf-8') as fp: data = json.load(fp) fp.close() diff --git a/src/fleet/azext_fleet/tests/latest/recordings/test_fleet_hubful.yaml b/src/fleet/azext_fleet/tests/latest/recordings/test_fleet_hubful.yaml index 3dc7e3abc67..8a9752ce722 100644 --- a/src/fleet/azext_fleet/tests/latest/recordings/test_fleet_hubful.yaml +++ b/src/fleet/azext_fleet/tests/latest/recordings/test_fleet_hubful.yaml @@ -673,7 +673,7 @@ interactions: - AZURECLI/2.53.0 azsdk-python-azure-mgmt-containerservice/25.0.0b Python/3.10.12 (Linux-6.2.0-1012-azure-x86_64-with-glibc2.35) method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003?api-version=2023-08-01 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003?api-version=2023-10-01 response: body: string: '{"error":{"code":"ResourceNotFound","message":"The Resource ''Microsoft.ContainerService/managedClusters/flmc-000003'' @@ -784,7 +784,7 @@ interactions: - AZURECLI/2.53.0 azsdk-python-azure-mgmt-containerservice/25.0.0b Python/3.10.12 (Linux-6.2.0-1012-azure-x86_64-with-glibc2.35) method: PUT - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003?api-version=2023-08-01 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003?api-version=2023-10-01 response: body: string: "{\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003\",\n @@ -1291,7 +1291,7 @@ interactions: - AZURECLI/2.53.0 azsdk-python-azure-mgmt-containerservice/25.0.0b Python/3.10.12 (Linux-6.2.0-1012-azure-x86_64-with-glibc2.35) method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003?api-version=2023-08-01 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003?api-version=2023-10-01 response: body: string: "{\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003\",\n @@ -1759,7 +1759,7 @@ interactions: - AZURECLI/2.53.0 azsdk-python-azure-mgmt-containerservice/25.0.0b Python/3.10.12 (Linux-6.2.0-1012-azure-x86_64-with-glibc2.35) method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003?api-version=2023-08-01 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003?api-version=2023-10-01 response: body: string: "{\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003\",\n @@ -1852,7 +1852,7 @@ interactions: - AZURECLI/2.53.0 azsdk-python-azure-mgmt-containerservice/25.0.0b Python/3.10.12 (Linux-6.2.0-1012-azure-x86_64-with-glibc2.35) method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003?api-version=2023-08-01 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003?api-version=2023-10-01 response: body: string: "{\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003\",\n @@ -1945,7 +1945,7 @@ interactions: - AZURECLI/2.53.0 azsdk-python-azure-mgmt-containerservice/25.0.0b Python/3.10.12 (Linux-6.2.0-1012-azure-x86_64-with-glibc2.35) method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003?api-version=2023-08-01 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003?api-version=2023-10-01 response: body: string: "{\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003\",\n @@ -2038,7 +2038,7 @@ interactions: - AZURECLI/2.53.0 azsdk-python-azure-mgmt-containerservice/25.0.0b Python/3.10.12 (Linux-6.2.0-1012-azure-x86_64-with-glibc2.35) method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003?api-version=2023-08-01 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003?api-version=2023-10-01 response: body: string: "{\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003\",\n @@ -2131,7 +2131,7 @@ interactions: - AZURECLI/2.53.0 azsdk-python-azure-mgmt-containerservice/25.0.0b Python/3.10.12 (Linux-6.2.0-1012-azure-x86_64-with-glibc2.35) method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003?api-version=2023-08-01 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003?api-version=2023-10-01 response: body: string: "{\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003\",\n diff --git a/src/fleet/azext_fleet/tests/latest/recordings/test_fleet_hubless.yaml b/src/fleet/azext_fleet/tests/latest/recordings/test_fleet_hubless.yaml index 141a95aae5a..91472ce27b4 100644 --- a/src/fleet/azext_fleet/tests/latest/recordings/test_fleet_hubless.yaml +++ b/src/fleet/azext_fleet/tests/latest/recordings/test_fleet_hubless.yaml @@ -490,7 +490,7 @@ interactions: - AZURECLI/2.53.0 azsdk-python-azure-mgmt-containerservice/25.0.0b Python/3.10.12 (Linux-6.2.0-1012-azure-x86_64-with-glibc2.35) method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003?api-version=2023-08-01 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003?api-version=2023-10-01 response: body: string: '{"error":{"code":"ResourceNotFound","message":"The Resource ''Microsoft.ContainerService/managedClusters/flmc-000003'' @@ -601,7 +601,7 @@ interactions: - AZURECLI/2.53.0 azsdk-python-azure-mgmt-containerservice/25.0.0b Python/3.10.12 (Linux-6.2.0-1012-azure-x86_64-with-glibc2.35) method: PUT - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003?api-version=2023-08-01 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003?api-version=2023-10-01 response: body: string: "{\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003\",\n @@ -1246,7 +1246,7 @@ interactions: - AZURECLI/2.53.0 azsdk-python-azure-mgmt-containerservice/25.0.0b Python/3.10.12 (Linux-6.2.0-1012-azure-x86_64-with-glibc2.35) method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003?api-version=2023-08-01 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003?api-version=2023-10-01 response: body: string: "{\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003\",\n @@ -1718,7 +1718,7 @@ interactions: - AZURECLI/2.53.0 azsdk-python-azure-mgmt-containerservice/25.0.0b Python/3.10.12 (Linux-6.2.0-1012-azure-x86_64-with-glibc2.35) method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003?api-version=2023-08-01 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003?api-version=2023-10-01 response: body: string: "{\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003\",\n @@ -1811,7 +1811,7 @@ interactions: - AZURECLI/2.53.0 azsdk-python-azure-mgmt-containerservice/25.0.0b Python/3.10.12 (Linux-6.2.0-1012-azure-x86_64-with-glibc2.35) method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003?api-version=2023-08-01 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003?api-version=2023-10-01 response: body: string: "{\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003\",\n @@ -1904,7 +1904,7 @@ interactions: - AZURECLI/2.53.0 azsdk-python-azure-mgmt-containerservice/25.0.0b Python/3.10.12 (Linux-6.2.0-1012-azure-x86_64-with-glibc2.35) method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003?api-version=2023-08-01 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003?api-version=2023-10-01 response: body: string: "{\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli-000001/providers/Microsoft.ContainerService/managedClusters/flmc-000003\",\n diff --git a/src/fleet/azext_fleet/tests/latest/test_fleet_hubful_scenario.py b/src/fleet/azext_fleet/tests/latest/test_fleet_hubful_scenario.py index 512eac45045..0cd15ae3933 100644 --- a/src/fleet/azext_fleet/tests/latest/test_fleet_hubful_scenario.py +++ b/src/fleet/azext_fleet/tests/latest/test_fleet_hubful_scenario.py @@ -10,6 +10,7 @@ class FleetHubfulScenarioTest(ScenarioTest): + @classmethod def generate_ssh_keys(cls): # If the `--ssh-key-value` option is not specified, the validator will try to read the ssh-key from the "~/.ssh" directory, @@ -47,7 +48,7 @@ def test_fleet_hubful(self): 'ssh_key_value': self.generate_ssh_keys() }) - self.cmd('fleet create -g {rg} -n {fleet_name} --enable-hub --vm-size Standard_DS1 ' , checks=[ + self.cmd('fleet create -g {rg} -n {fleet_name} --enable-hub --vm-size Standard_DS1 ', checks=[ self.check('name', '{fleet_name}') ]) diff --git a/src/fleet/azext_fleet/tests/latest/test_fleet_hubless_scenario.py b/src/fleet/azext_fleet/tests/latest/test_fleet_hubless_scenario.py index a65e159b681..bfd3b91078f 100644 --- a/src/fleet/azext_fleet/tests/latest/test_fleet_hubless_scenario.py +++ b/src/fleet/azext_fleet/tests/latest/test_fleet_hubless_scenario.py @@ -8,10 +8,12 @@ from azure.cli.testsdk import (ScenarioTest, ResourceGroupPreparer) from azure.cli.testsdk.scenario_tests import AllowLargeResponse + def _get_test_data_file(filename): curr_dir = os.path.dirname(os.path.realpath(__file__)) return os.path.join(curr_dir, 'data', filename) + class FleetHublessScenarioTest(ScenarioTest): @classmethod diff --git a/src/fleet/azext_fleet/tests/latest/test_validators.py b/src/fleet/azext_fleet/tests/latest/test_validators.py index de2bc3d7c5d..89c4830b148 100644 --- a/src/fleet/azext_fleet/tests/latest/test_validators.py +++ b/src/fleet/azext_fleet/tests/latest/test_validators.py @@ -7,46 +7,55 @@ from azure.cli.core.util import CLIError import azext_fleet._validators as validators + class AgentSubnetIDNamespace: def __init__(self, agent_subnet_id): self.agent_subnet_id = agent_subnet_id + class ApiServerSubnetIDNamespace: def __init__(self, apiserver_subnet_id): self.apiserver_subnet_id = apiserver_subnet_id + class AssignIdentityNamespace: def __init__(self, assign_identity): self.assign_identity = assign_identity + class MemberClusterIDNamespace: def __init__(self, member_cluster_id): self.member_cluster_id = member_cluster_id + class UpgradeTypeNamespace: def __init__(self, upgrade_type): self.upgrade_type = upgrade_type + class NodeImageSelectionNamespace: def __init__(self, node_image_selection): self.node_image_selection = node_image_selection + class UpdateStrategyNamespace: def __init__(self, update_strategy_name): self.update_strategy_name = update_strategy_name + class VMSizeNamespace: def __init__(self, vm_size): self.vm_size = vm_size + class TestValidateMemberClusterId(unittest.TestCase): def test_invalid_member_cluster_id(self): invalid_member_cluster_id = "dummy cluster id" @@ -63,6 +72,7 @@ def test_valid_member_cluster_id(self): self.assertIsNone(validators.validate_member_cluster_id(namespace)) + class TestValidateApiServerSubnetID(unittest.TestCase): def test_invalid_apiserver_subnet_id(self): invalid_apiserver_subnet_id = "an invalid apiserver_subnet_id" @@ -92,6 +102,7 @@ def test_valid_apiserver_subnet_id(self): self.assertIsNone(validators.validate_apiserver_subnet_id(namespace)) + class TestValidateAgentSubnetID(unittest.TestCase): def test_invalid_agent_subnet_id(self): invalid_agent_subnet_id = "an invalid agent_subnet_id" @@ -121,6 +132,7 @@ def test_valid_agent_subnet_id(self): self.assertIsNone(validators.validate_agent_subnet_id(namespace)) + class TestValidateAssignIdentity(unittest.TestCase): def test_invalid_identity_id(self): invalid_identity_id = "an invalid identity id" @@ -149,6 +161,7 @@ def test_empty_identity_id(self): self.assertIsNone(validators.validate_assign_identity(namespace)) + class TestValidateUpdateStrategyName(unittest.TestCase): def test_invalid_update_strategy_name(self): invalid_update_strategy_name = "" @@ -165,6 +178,7 @@ def test_valid_update_strategy_name(self): self.assertIsNone(validators.validate_update_strategy_name(namespace)) + class TestValidateVmSize(unittest.TestCase): def test_invalid_vm_size(self): invalid_vm_size = "" @@ -181,5 +195,6 @@ def test_valid_vm_size(self): self.assertIsNone(validators.validate_vm_size(namespace)) + if __name__ == "__main__": unittest.main() \ No newline at end of file diff --git a/src/fleet/setup.py b/src/fleet/setup.py index d6153c6c39a..c8fa5fdc171 100644 --- a/src/fleet/setup.py +++ b/src/fleet/setup.py @@ -16,7 +16,7 @@ # TODO: Confirm this is the right version number you want and it matches your # HISTORY.rst entry. -VERSION = '1.0.1' +VERSION = '1.0.2' # The full list of classifiers is available at # https://pypi.python.org/pypi?%3Aaction=list_classifiers From 8a20b93180c1b63b693babfe90b7ccabe6b85a81 Mon Sep 17 00:00:00 2001 From: Sean Hobbs Date: Fri, 15 Dec 2023 10:03:52 -0800 Subject: [PATCH 2/7] Updated history.rst --- src/fleet/HISTORY.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/fleet/HISTORY.rst b/src/fleet/HISTORY.rst index 6489cc99f1f..f9b3d9d84ec 100644 --- a/src/fleet/HISTORY.rst +++ b/src/fleet/HISTORY.rst @@ -64,4 +64,8 @@ Release History 1.0.1 ++++++ * Updated help examples. -* Fixed serialization bug. \ No newline at end of file +* Fixed serialization bug. + +1.0.2 +++++++ +* Minor style & linting updates to codebase. \ No newline at end of file From 4c59075eb8b2f1a8301b02aa3841c9d77fe2ee09 Mon Sep 17 00:00:00 2001 From: Sean Hobbs Date: Fri, 15 Dec 2023 10:17:48 -0800 Subject: [PATCH 3/7] Fixes for pipeline detected style issues. --- src/fleet/azext_fleet/tests/__init__.py | 2 +- src/fleet/azext_fleet/tests/latest/__init__.py | 2 +- .../azext_fleet/tests/latest/test_fleet_hubful_scenario.py | 2 +- src/fleet/azext_fleet/tests/latest/test_validators.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/fleet/azext_fleet/tests/__init__.py b/src/fleet/azext_fleet/tests/__init__.py index 2dcf9bb68b3..99c0f28cd71 100644 --- a/src/fleet/azext_fleet/tests/__init__.py +++ b/src/fleet/azext_fleet/tests/__init__.py @@ -2,4 +2,4 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. -# ----------------------------------------------------------------------------- \ No newline at end of file +# ----------------------------------------------------------------------------- diff --git a/src/fleet/azext_fleet/tests/latest/__init__.py b/src/fleet/azext_fleet/tests/latest/__init__.py index 2dcf9bb68b3..99c0f28cd71 100644 --- a/src/fleet/azext_fleet/tests/latest/__init__.py +++ b/src/fleet/azext_fleet/tests/latest/__init__.py @@ -2,4 +2,4 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. -# ----------------------------------------------------------------------------- \ No newline at end of file +# ----------------------------------------------------------------------------- diff --git a/src/fleet/azext_fleet/tests/latest/test_fleet_hubful_scenario.py b/src/fleet/azext_fleet/tests/latest/test_fleet_hubful_scenario.py index 0cd15ae3933..0843ccc0a89 100644 --- a/src/fleet/azext_fleet/tests/latest/test_fleet_hubful_scenario.py +++ b/src/fleet/azext_fleet/tests/latest/test_fleet_hubful_scenario.py @@ -8,8 +8,8 @@ from azure.cli.testsdk import (ScenarioTest, ResourceGroupPreparer) from azure.cli.testsdk.scenario_tests import AllowLargeResponse -class FleetHubfulScenarioTest(ScenarioTest): +class FleetHubfulScenarioTest(ScenarioTest): @classmethod def generate_ssh_keys(cls): diff --git a/src/fleet/azext_fleet/tests/latest/test_validators.py b/src/fleet/azext_fleet/tests/latest/test_validators.py index 89c4830b148..aba26564e0b 100644 --- a/src/fleet/azext_fleet/tests/latest/test_validators.py +++ b/src/fleet/azext_fleet/tests/latest/test_validators.py @@ -197,4 +197,4 @@ def test_valid_vm_size(self): if __name__ == "__main__": - unittest.main() \ No newline at end of file + unittest.main() From aabff8a49dba716029b619ae9e7d66ced89837ea Mon Sep 17 00:00:00 2001 From: Sean Hobbs Date: Fri, 15 Dec 2023 10:26:23 -0800 Subject: [PATCH 4/7] Linter fix from pipeline results. --- src/fleet/azext_fleet/_completers.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/fleet/azext_fleet/_completers.py b/src/fleet/azext_fleet/_completers.py index c5d15ca50f4..7e182106c5f 100644 --- a/src/fleet/azext_fleet/_completers.py +++ b/src/fleet/azext_fleet/_completers.py @@ -15,4 +15,6 @@ def _get_location_from_resource_group(cli_ctx, resource_group_name): # Print a warning if the user hit [TAB] but the `--resource-group` argument was incorrect. # For example: "Warning: Resource group 'bogus' could not be found." from argcomplete import warn - warn('Warning: {}'.format(err.message)) + warn(f'Warning: {err.meesage}') + + return None From 2c129ece95309fb4dddcbdc6bd3ec47736ae29d1 Mon Sep 17 00:00:00 2001 From: Sean Hobbs Date: Fri, 15 Dec 2023 14:23:05 -0800 Subject: [PATCH 5/7] Update src/fleet/azext_fleet/_completers.py Co-authored-by: Jim Minter --- src/fleet/azext_fleet/_completers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fleet/azext_fleet/_completers.py b/src/fleet/azext_fleet/_completers.py index 7e182106c5f..d7388c1b9e8 100644 --- a/src/fleet/azext_fleet/_completers.py +++ b/src/fleet/azext_fleet/_completers.py @@ -15,6 +15,6 @@ def _get_location_from_resource_group(cli_ctx, resource_group_name): # Print a warning if the user hit [TAB] but the `--resource-group` argument was incorrect. # For example: "Warning: Resource group 'bogus' could not be found." from argcomplete import warn - warn(f'Warning: {err.meesage}') + warn(f'Warning: {err.message}') return None From a9687345f98aa20db2e7923ac1073a9ae7f4d1a5 Mon Sep 17 00:00:00 2001 From: Sean Hobbs Date: Fri, 15 Dec 2023 14:31:00 -0800 Subject: [PATCH 6/7] Trying raise --- src/fleet/azext_fleet/_helpers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fleet/azext_fleet/_helpers.py b/src/fleet/azext_fleet/_helpers.py index 14cd4ac717c..302a5d2439a 100644 --- a/src/fleet/azext_fleet/_helpers.py +++ b/src/fleet/azext_fleet/_helpers.py @@ -138,7 +138,7 @@ def _load_kubernetes_configuration(filename): except (IOError, OSError) as ex: if getattr(ex, 'errno', 0) == errno.ENOENT: raise CLIError(f'{filename} does not exist') from ex + raise except (yaml.parser.ParserError, UnicodeDecodeError) as ex: raise CLIError(f'Error parsing {filename} ({str(ex)})') from ex - return None From dae698fcb70b18161e9fb5d83c15fb406f896771 Mon Sep 17 00:00:00 2001 From: Sean Hobbs Date: Fri, 15 Dec 2023 14:39:15 -0800 Subject: [PATCH 7/7] line break --- src/fleet/azext_fleet/_helpers.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/fleet/azext_fleet/_helpers.py b/src/fleet/azext_fleet/_helpers.py index 302a5d2439a..5e7314d7d97 100644 --- a/src/fleet/azext_fleet/_helpers.py +++ b/src/fleet/azext_fleet/_helpers.py @@ -141,4 +141,3 @@ def _load_kubernetes_configuration(filename): raise except (yaml.parser.ParserError, UnicodeDecodeError) as ex: raise CLIError(f'Error parsing {filename} ({str(ex)})') from ex -