Skip to content
Closed
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
8 changes: 6 additions & 2 deletions src/fleet/azext_fleet/_client_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,14 @@ def cf_fleet_members(cli_ctx, *_):
return get_container_service_client(cli_ctx).fleet_members


def cf_gates(cli_ctx, *_):
return get_container_service_client(cli_ctx).gates
def cf_managed_namespaces(cli_ctx, *_):
return get_container_service_client(cli_ctx).fleet_managed_namespaces


# Gates functionality - will be available when API supports gates
# def cf_gates(cli_ctx, *_):
# return get_container_service_client(cli_ctx).gates

def cf_update_runs(cli_ctx, *_):
return get_container_service_client(cli_ctx).update_runs

Expand Down
64 changes: 64 additions & 0 deletions src/fleet/azext_fleet/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,3 +432,67 @@
- name: Approves a gate.
text: az fleet gate approve -g MyFleetResourceGroup --fleet-name MyFleetName --gate-name 3fa85f64-5717-4562-b3fc-2c963f66afa6
"""

helps['fleet managednamespace'] = """
type: group
short-summary: Commands to manage managed namespaces.
"""

helps['fleet managednamespace create'] = """
type: command
short-summary: Creates or updates a managed namespace.
parameters:
- name: --namespace-name
type: string
short-summary: The name of the Kubernetes namespace to be created on member clusters.
- name: --labels
type: string
short-summary: Labels to apply to the managed namespace.
- name: --annotations
type: string
short-summary: Annotations to apply to the managed namespace.
examples:
- name: Create a managed namespace.
text: az fleet managednamespace create -g MyFleetResourceGroup -f MyFleetName -n MyManagedNamespace --namespace-name my-namespace
- name: Create a managed namespace with labels and annotations.
text: az fleet managednamespace create -g MyFleetResourceGroup -f MyFleetName -n MyManagedNamespace --namespace-name my-namespace --labels env=production team=devops --annotations description="Production namespace"
"""

helps['fleet managednamespace update'] = """
type: command
short-summary: Update a managed namespace.
parameters:
- name: --labels
type: string
short-summary: Labels to apply to the managed namespace.
- name: --annotations
type: string
short-summary: Annotations to apply to the managed namespace.
examples:
- name: Update a managed namespace's labels.
text: az fleet managednamespace update -g MyFleetResourceGroup -f MyFleetName -n my-namespace --labels env=staging
"""

helps['fleet managednamespace list'] = """
type: command
short-summary: Lists a fleet's managed namespaces.
examples:
- name: List all managed namespaces for a given fleet.
text: az fleet managednamespace list -g MyFleetResourceGroup -f MyFleetName
"""

helps['fleet managednamespace show'] = """
type: command
short-summary: Gets a fleet managed namespace.
examples:
- name: Show the details of a specific managed namespace.
text: az fleet managednamespace show -g MyFleetResourceGroup -f MyFleetName -n my-namespace
"""

helps['fleet managednamespace delete'] = """
type: command
short-summary: Deletes a fleet managed namespace.
examples:
- name: Delete a specific managed namespace.
text: az fleet managednamespace delete -g MyFleetResourceGroup -f MyFleetName -n my-namespace
"""
23 changes: 23 additions & 0 deletions src/fleet/azext_fleet/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,26 @@ def load_arguments(self, _):
c.argument('resource_group_name', options_list=['--resource-group', '-g'], help='Name of the resource group.')
c.argument('fleet_name', options_list=['--fleet-name', '-f'], help='Name of the fleet.')
c.argument('gate_name', options_list=['--gate-name', '--gate', '-n'], help='Name of the gate.')

# Fleet managed namespace arguments
with self.argument_context('fleet managednamespace') as c:
c.argument('resource_group_name', options_list=['--resource-group', '-g'], help='Name of the resource group.')
c.argument('fleet_name', options_list=['--fleet-name', '-f'], help='Name of the fleet.')
c.argument('managed_namespace_name', options_list=['--name', '-n'], help='Name of the managed namespace.')

with self.argument_context('fleet managednamespace create') as c:
c.argument('labels', labels_type, help='Labels to apply to the managed namespace.')
c.argument('annotations', type=validate_labels, metavar='KEY=VALUE', help='Annotations to apply to the managed namespace: key[=value] [key[=value] ...].')

with self.argument_context('fleet managednamespace update') as c:
c.argument('labels', labels_type, help='Labels to apply to the managed namespace.')
c.argument('annotations', type=validate_labels, metavar='KEY=VALUE', help='Annotations to apply to the managed namespace: key[=value] [key[=value] ...].')

with self.argument_context('fleet managednamespace delete') as c:
pass

with self.argument_context('fleet managednamespace show') as c:
pass

with self.argument_context('fleet managednamespace list') as c:
pass
38 changes: 27 additions & 11 deletions src/fleet/azext_fleet/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
cf_fleet_update_strategies,
cf_auto_upgrade_profiles,
cf_auto_upgrade_profile_operations,
cf_gates
cf_managed_namespaces
#cf_gates
)


Expand All @@ -30,6 +31,12 @@ def load_command_table(self, _):
client_factory=cf_fleet_members
)

managed_namespaces_sdk = CliCommandType(
operations_tmpl="azext_fleet.vendored_sdks.operations._operations#FleetManagedNamespacesOperations.{}",
operation_group="fleet_managed_namespaces",
client_factory=cf_managed_namespaces
)

update_runs_sdk = CliCommandType(
operations_tmpl="azext_fleet.vendored_sdks.operations._update_runs_operations#UpdateRunsOperations.{}",
operation_group="update_runs",
Expand All @@ -54,11 +61,11 @@ def load_command_table(self, _):
client_factory=cf_auto_upgrade_profile_operations
)

gates_sdk = CliCommandType(
operations_tmpl="azext_fleet.vendored_sdks.operations._gates_operations#GatesOperations.{}",
operation_group="gates",
client_factory=cf_gates
)
#gates_sdk = CliCommandType(
# operations_tmpl="azext_fleet.vendored_sdks.operations._gates_operations#GatesOperations.{}",
# operation_group="gates",
# client_factory=cf_gates
#)

# fleets command group
with self.command_group("fleet", fleets_sdk, client_factory=cf_fleets) as g:
Expand All @@ -81,6 +88,15 @@ def load_command_table(self, _):
g.custom_command("reconcile", "reconcile_fleet_member", supports_no_wait=True)
g.wait_command("wait")

# fleet managed namespaces command group
with self.command_group("fleet managednamespace", managed_namespaces_sdk, client_factory=cf_managed_namespaces) as g:
g.custom_command("create", "create_managed_namespace", supports_no_wait=True)
g.custom_command("update", "update_managed_namespace", supports_no_wait=True)
g.custom_command("delete", "delete_managed_namespace", supports_no_wait=True, confirmation=True)
g.custom_command("list", "list_managed_namespaces")
g.custom_show_command("show", "show_managed_namespace")
g.wait_command("wait")

# fleet update runs command group
with self.command_group("fleet updaterun", update_runs_sdk, client_factory=cf_update_runs) as g:
g.custom_command("create", "create_update_run", supports_no_wait=True)
Expand Down Expand Up @@ -113,8 +129,8 @@ def load_command_table(self, _):
g.custom_command("generate-update-run", "generate_update_run", supports_no_wait=True)

# fleet gates command group
with self.command_group("fleet gate", gates_sdk, client_factory=cf_gates) as g:
g.custom_command("list", "list_gates_by_fleet")
g.custom_show_command("show", "show_gate")
g.custom_command("update", "update_gate")
g.custom_command("approve", "approve_gate")
#with self.command_group("fleet gate", gates_sdk, client_factory=cf_gates) as g:
# g.custom_command("list", "list_gates_by_fleet")
# g.custom_show_command("show", "show_gate")
# g.custom_command("update", "update_gate")
# g.custom_command("approve", "approve_gate")
4 changes: 2 additions & 2 deletions src/fleet/azext_fleet/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
UPGRADE_TYPE_NODEIMAGEONLY = "NodeImageOnly"
FLEET_1P_APP_ID = "609d2f62-527f-4451-bfd2-ac2c7850822c"

SUPPORTED_GATE_STATES_FILTERS = ["Pending", "Skipped", "Completed"]
SUPPORTED_GATE_STATES_PATCH = ["Completed"]
#SUPPORTED_GATE_STATES_FILTERS = ["Pending", "Skipped", "Completed"]
#SUPPORTED_GATE_STATES_PATCH = ["Completed"]

UPGRADE_TYPE_ERROR_MESSAGES = {
UPGRADE_TYPE_CONTROLPLANEONLY: f"Please set kubernetes version when upgrade type is '{UPGRADE_TYPE_CONTROLPLANEONLY}'.", # pylint: disable=line-too-long
Expand Down
Loading
Loading