-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add fleet CLI #5244
add fleet CLI #5244
Conversation
Fleet extension
update live test
file clean up
fleet |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
/AzurePipelines help |
Supported commands
See additional documentation. |
def get_rg_location(ctx, resource_group_name, subscription_id=None): | ||
groups = get_resource_groups_client(ctx, subscription_id=subscription_id) | ||
# Just do the get, we don't need the result, it will error out if the group doesn't exist. | ||
rg = groups.get(resource_group_name) | ||
if rg is None: | ||
raise CLIError(f"Resource group {resource_group_name} not found.") | ||
return rg.location |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usually, we will expose location argument. If you went to get the default location from resource group, please refer this implementation. https://github.com/Azure/azure-cli/blob/76c224121c05f77f6cf6f17130b6c8fde824e10a/src/azure-cli/azure/cli/command_modules/monitor/_params.py#L412
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
borrowed aks-preview implementation
https://github.com/Azure/azure-cli-extensions/blob/main/src/aks-preview/azext_aks_preview/_resourcegroup.py#L10
- name: --file -f | ||
type: string | ||
short-summary: Kubernetes configuration file to update. Use "-" to print YAML to stdout instead. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already have --output -o
argument to support yaml output in stdout.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
borrowed aks-preview implementation
https://github.com/Azure/azure-cli-extensions/blob/main/src/aks-preview/azext_aks_preview/_help.py#L1622
Co-authored-by: kai ru <[email protected]>
Co-authored-by: kai ru <[email protected]>
c.argument('name', options_list=['--name', '-n'], help='Specify the fleet name.') | ||
|
||
with self.argument_context('fleet create') as c: | ||
c.argument('tags', tags_type) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose tags
is supported by CLI framework by default
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unsure, borrowed from aks-preview
https://github.com/Azure/azure-cli-extensions/blob/main/src/aks-preview/azext_aks_preview/_params.py#L186
def load_arguments(self, _): | ||
|
||
with self.argument_context('fleet') as c: | ||
c.argument('name', options_list=['--name', '-n'], help='Specify the fleet name.') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name
is also supported by default?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is, but we needed different contexts associated so followed how aks-preview does for nodepool https://github.com/Azure/azure-cli-extensions/blob/main/src/aks-preview/azext_aks_preview/_params.py#L432
g.custom_show_command("show", "show_fleet") | ||
g.custom_command("list", "list_fleet") | ||
g.custom_command("delete", "delete_fleet", supports_no_wait=True) | ||
g.custom_command("get-credentials", "get_credentials") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since no_wait
is supported, add g.wait_command('wait')
and test case for it? Also need to update _param.py
to align the option with operation parameters provided in SDK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will add as part of next PR!
g.custom_command("create", "create_fleet_member", supports_no_wait=True) | ||
g.custom_command("delete", "delete_fleet_member", supports_no_wait=True) | ||
g.custom_command("list", "list_fleet_member") | ||
g.custom_show_command("show", "show_fleet_member") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
g.wait_command('wait')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will add as part of next PR!
context_name=None): | ||
credentialResults = client.list_credentials(resource_group_name, name) | ||
if not credentialResults: | ||
raise CLIError("No Kubernetes credentials found.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May replace CLIError
with ResourceNotFoundError
.
from azure.cli.core.azclierror import InvalidArgumentValueError
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
print_or_merge_credentials( | ||
path, kubeconfig, overwrite_existing, context_name) | ||
except (IndexError, ValueError): | ||
raise CLIError("Fail to find kubeconfig file.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ResourceNotFoundError
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
[Release] Update index.json for extension [ fleet ] : https://dev.azure.com/azure-sdk/internal/_build/results?buildId=1799841&view=results |
This checklist is used to make sure that common guidelines for a pull request are followed.
Related command
General Guidelines
azdev style <YOUR_EXT>
locally? (pip install azdev
required)python scripts/ci/test_index.py -q
locally?For new extensions:
About Extension Publish
There is a pipeline to automatically build, upload and publish extension wheels.
Once your pull request is merged into main branch, a new pull request will be created to update
src/index.json
automatically.The precondition is to put your code inside this repository and upgrade the version in the pull request but do not modify
src/index.json
.