Skip to content
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

Merged
merged 39 commits into from
Aug 23, 2022
Merged

add fleet CLI #5244

merged 39 commits into from
Aug 23, 2022

Conversation

pdaru
Copy link
Member

@pdaru pdaru commented Aug 17, 2022


This checklist is used to make sure that common guidelines for a pull request are followed.

Related command

General Guidelines

  • Have you run azdev style <YOUR_EXT> locally? (pip install azdev required)
  • Have you run 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.

@yonzhan
Copy link
Collaborator

yonzhan commented Aug 17, 2022

fleet

@yonzhan yonzhan added this to the Aug 2022 (2022-09-06) milestone Aug 17, 2022
@pdaru pdaru changed the title add fleet CLI [WIP] add fleet CLI Aug 17, 2022
@wangzelin007
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@wangzelin007
Copy link
Member

/AzurePipelines help

@azure-pipelines
Copy link

Supported commands
  • help:
    • Get descriptions, examples and documentation about supported commands
    • Example: help "command_name"
  • list:
    • List all pipelines for this repository using a comment.
    • Example: "list"
  • run:
    • Run all pipelines or specific pipelines for this repository using a comment. Use this command by itself to trigger all related pipelines, or specify specific pipelines to run.
    • Example: "run" or "run pipeline_name, pipeline_name, pipeline_name"
  • where:
    • Report back the Azure DevOps orgs that are related to this repository and org
    • Example: "where"

See additional documentation.

.github/CODEOWNERS Outdated Show resolved Hide resolved
Comment on lines +10 to +16
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
Copy link
Contributor

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Comment on lines +64 to +66
- name: --file -f
type: string
short-summary: Kubernetes configuration file to update. Use "-" to print YAML to stdout instead.
Copy link
Contributor

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

src/fleet/setup.py Outdated Show resolved Hide resolved
src/fleet/setup.py Outdated Show resolved Hide resolved
pdaru and others added 2 commits August 22, 2022 23:46
Co-authored-by: kai ru <69238381+kairu-ms@users.noreply.github.com>
Co-authored-by: kai ru <69238381+kairu-ms@users.noreply.github.com>
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)
Copy link
Member

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

Copy link
Member Author

Choose a reason for hiding this comment

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

def load_arguments(self, _):

with self.argument_context('fleet') as c:
c.argument('name', options_list=['--name', '-n'], help='Specify the fleet name.')
Copy link
Member

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?

Copy link
Member Author

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

src/fleet/azext_fleet/commands.py Outdated Show resolved Hide resolved
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")
Copy link
Member

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.

Copy link
Member Author

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")
Copy link
Member

Choose a reason for hiding this comment

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

g.wait_command('wait')

Copy link
Member Author

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!

src/fleet/azext_fleet/custom.py Outdated Show resolved Hide resolved
context_name=None):
credentialResults = client.list_credentials(resource_group_name, name)
if not credentialResults:
raise CLIError("No Kubernetes credentials found.")
Copy link
Member

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

Copy link
Member Author

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.")
Copy link
Member

Choose a reason for hiding this comment

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

ResourceNotFoundError.

Copy link
Member Author

Choose a reason for hiding this comment

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

src/fleet/azext_fleet/custom.py Outdated Show resolved Hide resolved
Copy link
Member

@FumingZhang FumingZhang left a comment

Choose a reason for hiding this comment

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

LGTM

@kairu-ms kairu-ms merged commit 1cc87a9 into Azure:main Aug 23, 2022
@azclibot
Copy link
Collaborator

[Release] Update index.json for extension [ fleet ] : https://dev.azure.com/azure-sdk/internal/_build/results?buildId=1799841&view=results

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants