Skip to content
Merged
Changes from 1 commit
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
9 changes: 6 additions & 3 deletions src/azure-cli/azure/cli/command_modules/vm/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -1879,7 +1879,9 @@ def add_vm_secret(cmd, resource_group_name, vm_name, keyvault, certificate, cert

def list_vm_secrets(cmd, resource_group_name, vm_name):
vm = get_vm(cmd, resource_group_name, vm_name)
return vm.os_profile.secrets
if vm.os_profile:
return vm.os_profile.secrets
return None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return None will show nothing in the output.
how about return []

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. actually I have same confusion on return value when result is None. sometimes az cli returns [], sometimes None. Is there any general guideline?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this command, the output is [] if there is no secret.
Let me search the doc.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested with a VM and the results confirms @qwordy's comment:

az vm secret list -n {} -g {}
[]



def remove_vm_secret(cmd, resource_group_name, vm_name, keyvault, certificate=None):
Expand Down Expand Up @@ -2815,8 +2817,9 @@ def list_vmss_extensions(cmd, resource_group_name, vmss_name):
client = _compute_client_factory(cmd.cli_ctx)
vmss = client.virtual_machine_scale_sets.get(resource_group_name, vmss_name)
# pylint: disable=no-member
return None if not vmss.virtual_machine_profile.extension_profile \
else vmss.virtual_machine_profile.extension_profile.extensions
if vmss.virtual_machine_profile and vmss.virtual_machine_profile.extension_profile:
return vmss.virtual_machine_profile.extension_profile.extensions
return None


def set_vmss_extension(cmd, resource_group_name, vmss_name, extension_name, publisher, version=None,
Expand Down