Skip to content

Commit e49c380

Browse files
committed
fix conflict
Signed-off-by: Romain Demeure <romain.demeure@outscale.com>
2 parents 3a88973 + c865ca6 commit e49c380

File tree

10 files changed

+833
-71
lines changed

10 files changed

+833
-71
lines changed

oks_cli/cache.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import click
2-
from .utils import clear_cache, find_project_id_by_name, find_cluster_id_by_name, get_all_cache, get_expiration_date, ctx_update, login_profile, profile_completer
2+
from .utils import clear_cache, find_project_id_by_name, find_cluster_id_by_name, get_all_cache, get_expiration_date, ctx_update, login_profile, profile_completer, cluster_completer, project_completer
33
import prettytable
44

55
# DEFINE THE CACHE COMMAND GROUP
66
@click.group(help="Cache related commands.")
7-
@click.option('--project-name', '-p', required = False, help="Project Name")
8-
@click.option('--cluster-name', '--name', '-c', required = False, help="Cluster Name")
7+
@click.option('--project-name', '-p', required = False, help="Project Name", shell_complete=project_completer)
8+
@click.option('--cluster-name', '--name', '-c', required = False, help="Cluster Name", shell_complete=cluster_completer)
99
@click.option("--profile", "-pr", help="Configuration profile to use", shell_complete=profile_completer)
1010
@click.pass_context
1111
def cache(ctx, project_name, cluster_name, profile):
@@ -20,8 +20,8 @@ def delete_cache(force):
2020
clear_cache()
2121

2222
@cache.command('kubeconfigs', help="List cached kubeconfigs")
23-
@click.option('--project-name', '-p', required=False, help="Project Name")
24-
@click.option('--cluster-name', '--name', '-c', required=False, help="Cluster Name")
23+
@click.option('--project-name', '-p', required=False, help="Project Name", shell_complete=project_completer)
24+
@click.option('--cluster-name', '--name', '-c', required=False, help="Cluster Name", shell_complete=cluster_completer)
2525
@click.option('--plain', '-pl', is_flag=True, help="Plain table format")
2626
@click.option('--msword', '-mw', is_flag=True, help="Microsoft Word table format")
2727
@click.option('--profile', "-pr", help="Configuration profile to use", shell_complete=profile_completer)

oks_cli/cluster.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@
1212
import prettytable
1313
import logging
1414

15-
from .utils import do_request, print_output, find_project_id_by_name, find_cluster_id_by_name, get_cache, save_cache, detect_and_parse_input, verify_certificate, shell_completions, transform_tuple, profile_list, login_profile, cluster_create_in_background, ctx_update, set_cluster_id, get_cluster_id, get_project_id, get_template, get_cluster_name, format_changed_row, is_interesting_status, profile_completer
15+
from .utils import cluster_completer, do_request, print_output, find_project_id_by_name, find_cluster_id_by_name, get_cache, save_cache, detect_and_parse_input, verify_certificate, shell_completions, transform_tuple, profile_list, login_profile, cluster_create_in_background, ctx_update, set_cluster_id, get_cluster_id, get_project_id, get_template, get_cluster_name, format_changed_row, is_interesting_status, profile_completer, project_completer
1616

1717
from .profile import add_profile
1818
from .project import project_create, project_login
1919

2020
# DEFINE THE CLUSTER GROUP
2121
@click.group(help="Cluster related commands.")
22-
@click.option('--project-name', '-p', required=False, help="Project Name")
23-
@click.option('--cluster-name', '--name', '-c', required=False, help="Cluster Name")
22+
@click.option('--project-name', '-p', required=False, help="Project Name", shell_complete=project_completer)
23+
@click.option('--cluster-name', '--name', '-c', required=False, help="Cluster Name", shell_complete=cluster_completer)
2424
@click.option("--profile", "-pr", help="Configuration profile to use", shell_complete=profile_completer)
2525
@click.pass_context
2626
def cluster(ctx, project_name, cluster_name, profile):
@@ -29,7 +29,7 @@ def cluster(ctx, project_name, cluster_name, profile):
2929

3030
# LOGIN ON CLUSTER
3131
@cluster.command('login', help="Set a default cluster")
32-
@click.option('--cluster-name', '--name', '-c', required=False, help="Name of cluster")
32+
@click.option('--cluster-name', '--name', '-c', required=False, help="Name of cluster", shell_complete=cluster_completer)
3333
@click.option("--profile", "-pr", help="Configuration profile to use", shell_complete=profile_completer)
3434
@click.pass_context
3535
def cluster_login(ctx, cluster_name, profile):
@@ -68,8 +68,8 @@ def cluster_logout(ctx, profile):
6868

6969
# LIST CLUSTERS
7070
@cluster.command('list', help="List all clusters")
71-
@click.option('--project-name', '-p', required=False, help="Project Name")
72-
@click.option('--cluster-name', '--name', '-c', required=False, help="Cluster Name")
71+
@click.option('--project-name', '-p', required=False, help="Project Name", shell_complete=project_completer)
72+
@click.option('--cluster-name', '--name', '-c', required=False, help="Cluster Name", shell_complete=cluster_completer)
7373
@click.option('--deleted', '-x', is_flag=True, help="List deleted clusters") # x pour "deleted" / "removed"
7474
@click.option('--plain', '-pl', is_flag=True, help="Plain table format")
7575
@click.option('--msword', '-mw', is_flag=True, help="Microsoft Word table format")
@@ -212,8 +212,8 @@ def format_row(cluster):
212212

213213
# GET CLUSTER BY NAME
214214
@cluster.command('get', help="Get a cluster by name")
215-
@click.option('--project-name', '-p', required=False, help="Project Name")
216-
@click.option('--cluster-name', '--name', '-c', required=False, help="Cluster Name")
215+
@click.option('--project-name', '-p', required=False, help="Project Name", shell_complete=project_completer)
216+
@click.option('--cluster-name', '--name', '-c', required=False, help="Cluster Name", shell_complete=cluster_completer)
217217
@click.option('--output', '-o', type=click.Choice(["json", "yaml"]), help="Specify output format, by default is json")
218218
@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer)
219219
@click.pass_context
@@ -307,8 +307,8 @@ def _create_cluster(project_name, cluster_config, output):
307307

308308
# CLUSTER CREATE BY NAME
309309
@cluster.command('create', help="Create a new cluster")
310-
@click.option('--project-name', '-p', required=False, help="Project Name")
311-
@click.option('--cluster-name', '--name', '-c', required=False, help="Cluster Name")
310+
@click.option('--project-name', '-p', required=False, help="Project Name", shell_complete=project_completer)
311+
@click.option('--cluster-name', '--name', '-c', required=False, help="Cluster Name", shell_complete=cluster_completer)
312312
@click.option('--description', '-d', help="Description of the cluster")
313313
@click.option('--admin', '-a', help="Admin Whitelist")
314314
@click.option('--version', '-v', shell_complete=shell_completions, help="Kubernetes version")
@@ -407,8 +407,8 @@ def cluster_create_command(ctx, project_name, cluster_name, description, admin,
407407

408408
# UPDATE CLUSTER
409409
@cluster.command('update', help="Update a cluster by name")
410-
@click.option('--project-name', '-p', required=False, help="Project name")
411-
@click.option('--cluster-name', '--name', '-c', required=False, help="Cluster name")
410+
@click.option('--project-name', '-p', required=False, help="Project name", shell_complete=project_completer)
411+
@click.option('--cluster-name', '--name', '-c', required=False, help="Cluster name", shell_complete=cluster_completer)
412412
@click.option('--description', '-d', help="Description of the cluster")
413413
@click.option('--admin', '-a', help="Admin Whitelist")
414414
@click.option('--version', '-v', shell_complete=shell_completions, help="Kubernetes version")
@@ -494,8 +494,8 @@ def cluster_update_command(ctx, project_name, cluster_name, description, admin,
494494

495495
# UPGRADE CLUSTER
496496
@cluster.command('upgrade', help="Upgrade a cluster by name")
497-
@click.option('--project-name', '-p', required=False, help="Project name")
498-
@click.option('--cluster-name', '--name', '-c', required=False, help="Cluster name")
497+
@click.option('--project-name', '-p', required=False, help="Project name", shell_complete=project_completer)
498+
@click.option('--cluster-name', '--name', '-c', required=False, help="Cluster name", shell_complete=cluster_completer)
499499
@click.option('--output', '-o', type=click.Choice(["json", "yaml"]), help="Specify output format, by default is json")
500500
@click.option('--force', is_flag=True, help="Force upgrade")
501501
@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer)
@@ -515,8 +515,8 @@ def cluster_update_command(ctx, project_name, cluster_name, output, force, profi
515515

516516
# DELETE CLUSTER BY NAME
517517
@cluster.command('delete', help="Delete a cluster by name")
518-
@click.option('--project-name', '-p', required=False, help="Project name")
519-
@click.option('--cluster-name', '--name', '-c', required=False, help="Cluster name")
518+
@click.option('--project-name', '-p', required=False, help="Project name", shell_complete=project_completer)
519+
@click.option('--cluster-name', '--name', '-c', required=False, help="Cluster name", shell_complete=cluster_completer)
520520
@click.option('--output', '-o', type=click.Choice(["json", "yaml"]), help="Specify output format, by default is json")
521521
@click.option('--dry-run', is_flag=True, help="Run without any action")
522522
@click.option('--force', is_flag=True, help="Force deletion without confirmation")
@@ -546,8 +546,8 @@ def cluster_delete_command(ctx, project_name, cluster_name, output, dry_run, for
546546

547547
# GET KUBECONFIG
548548
@cluster.command('kubeconfig', help="Fetch the kubeconfig for a cluster")
549-
@click.option('--project-name', '-p', required=False, help="Project Name")
550-
@click.option('--cluster-name', '--name', '-c', required=False, help="Cluster Name")
549+
@click.option('--project-name', '-p', required=False, help="Project Name", shell_complete=project_completer)
550+
@click.option('--cluster-name', '--name', '-c', required=False, help="Cluster Name", shell_complete=cluster_completer)
551551
@click.option('--print-path', '-pp', is_flag=True, help="Print path to saved kubeconfig")
552552
@click.option('--refresh', '--force', is_flag=True, help="Force refresh saved kubeconfig")
553553
@click.option('--nacl', is_flag=True, help="Use public key encryption on wire (require api support)")
@@ -655,8 +655,8 @@ def _run_kubectl(project_id, cluster_id, user, group, args, input=None):
655655

656656

657657
@cluster.command('kubectl', help='Fetch the kubeconfig for a cluster and run kubectl against it', context_settings={"ignore_unknown_options": True})
658-
@click.option('--project-name', '-p', required=False, help="Project Name")
659-
@click.option('--cluster-name', '--name', '-c', required=False, help="Cluster Name")
658+
@click.option('--project-name', '-p', required=False, help="Project Name", shell_complete=project_completer)
659+
@click.option('--cluster-name', '--name', '-c', required=False, help="Cluster Name", shell_complete=cluster_completer)
660660
@click.option('--user', '-u', type=click.STRING, help="User")
661661
@click.option('--group', '-g', type=click.STRING, help="Group")
662662
@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer)
@@ -674,8 +674,8 @@ def cluster_kubectl_command(ctx, project_name, cluster_name, user, group, args,
674674

675675

676676
@click.group(help="Nodepool related commands.")
677-
@click.option('--project-name', '-p', required=False, help="Project Name")
678-
@click.option('--cluster-name', '--name', '-c', required=False, help="Cluster Name")
677+
@click.option('--project-name', '-p', required=False, help="Project Name", shell_complete=project_completer)
678+
@click.option('--cluster-name', '--name', '-c', required=False, help="Cluster Name", shell_complete=cluster_completer)
679679
@click.option('--user', '-u', type=click.STRING, help="User")
680680
@click.option('--group', '-g', type=click.STRING, help="Group")
681681
@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer)

oks_cli/main.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
from .cache import cache
1010
from .quotas import quotas
1111

12-
from .utils import ctx_update, install_completions, profile_completer
12+
from .utils import ctx_update, install_completions, profile_completer, cluster_completer, project_completer
1313

1414
# Main CLI entry point
1515
@click.group(invoke_without_command=True)
1616
@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer)
17-
@click.option('--project-name', '-p', required=False, help="Project Name")
18-
@click.option('--cluster-name', '--name', '-c', required=False, help="Cluster Name")
17+
@click.option('--project-name', '-p', required=False, help="Project Name", shell_complete=project_completer)
18+
@click.option('--cluster-name', '--name', '-c', required=False, help="Cluster Name", shell_complete=cluster_completer)
1919
@click.option('--verbose', '-v', count=True, help="Increase verbosity")
2020
@click.pass_context
2121
def cli(ctx, project_name, cluster_name, profile, verbose):
@@ -82,7 +82,7 @@ def version():
8282
print(importlib.metadata.version(__package__))
8383

8484
@cli.command("install-completion", help="Install shell completion scripts.")
85-
@click.option('--type', required=True, help="Shell, supported [bash,zsh]")
85+
@click.option('--type', help="Shell, supported [bash,zsh]")
8686
def install_completion(type):
8787
"""Install shell completion scripts for the CLI."""
8888
install_completions(type)

oks_cli/project.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66
import prettytable
77
import os
88

9-
from .utils import do_request, print_output, print_table, find_project_id_by_name, get_project_id, set_project_id, detect_and_parse_input, transform_tuple, ctx_update, set_cluster_id, get_template, get_project_name, format_changed_row, is_interesting_status, login_profile, profile_completer
9+
from .utils import do_request, print_output, print_table, find_project_id_by_name, get_project_id, set_project_id, detect_and_parse_input, transform_tuple, ctx_update, set_cluster_id, get_template, get_project_name, format_changed_row, is_interesting_status, login_profile, profile_completer, project_completer
1010

1111
# DEIFNE THE PROJECT COMMAND GROUP
1212
@click.group(help="Project related commands.")
13-
@click.option('--project-name', '-p', required=False, help="Project Name")
13+
@click.option('--project', 'project_name', required = False, help="Project Name")
14+
@click.option('--project-name', '-p', required=False, help="Project Name", shell_complete=project_completer)
1415
@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer)
1516
@click.pass_context
1617
def project(ctx, project_name, profile):
@@ -19,7 +20,7 @@ def project(ctx, project_name, profile):
1920

2021
# LOGIN ON PROJECT
2122
@project.command('login', help="Set a default project by name")
22-
@click.option('--project-name', '-p', required=False, help="Name of project", type=click.STRING)
23+
@click.option('--project-name', '-p', required=False, help="Name of project", type=click.STRING, shell_complete=project_completer)
2324
@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer)
2425
@click.pass_context
2526
def project_login(ctx, project_name, profile):
@@ -57,7 +58,7 @@ def project_logout(ctx, profile):
5758

5859
# LIST PROJECTS
5960
@project.command('list', help="List all projects")
60-
@click.option('--project-name', '-p', help="Name of project", type=click.STRING)
61+
@click.option('--project-name', '-p', help="Name of project", type=click.STRING, shell_complete=project_completer)
6162
@click.option('--deleted', '-x', is_flag=True, help="List deleted projects")
6263
@click.option('--plain', '-pl', is_flag=True, help="Plain table format")
6364
@click.option('--msword', '-mw', is_flag=True, help="Microsoft Word table format")
@@ -192,7 +193,7 @@ def format_row(project):
192193

193194
# CREATE PROJECT BY NAME
194195
@project.command('create', help="Create a new project")
195-
@click.option('--project-name', '-p', help="Name of the project", type=click.STRING)
196+
@click.option('--project-name', '-p', help="Name of the project", type=click.STRING, shell_complete=project_completer)
196197
@click.option('--description', '-d', help="Description of the project")
197198
@click.option('--cidr', help='CIDR for the project')
198199
@click.option('--quirk', '-q', multiple=True, help="Quirk")
@@ -253,7 +254,7 @@ def project_create(ctx, project_name, description, cidr, quirk, tags, disable_ap
253254

254255
# GET PROJECT BY NAME
255256
@project.command('get', help="Get default project or the project by name")
256-
@click.option('--project-name', '-p', help="Name of the project")
257+
@click.option('--project-name', '-p', help="Name of the project", shell_complete=project_completer)
257258
@click.option('--output', '-o', type=click.Choice(["json", "yaml"]), help="Specify output format, by default is json")
258259
@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer)
259260
@click.pass_context
@@ -269,7 +270,7 @@ def project_get(ctx, project_name, output, profile):
269270

270271
# DELETE PROJECT BY NAME
271272
@project.command('delete', help="Delete a project by name")
272-
@click.option('--project-name', '-p', required=False, help="Project Name", type=click.STRING)
273+
@click.option('--project-name', '-p', required=False, help="Project Name", type=click.STRING, shell_complete=project_completer)
273274
@click.option('--output', '-o', type=click.Choice(["json", "yaml"]), help="Specify output format, by default is json")
274275
@click.option('--dry-run', is_flag=True, help="Run without any action")
275276
@click.option('--force', is_flag=True, help="Force deletion without confirmation")
@@ -301,7 +302,7 @@ def project_delete_command(ctx, project_name, output, dry_run, force, profile):
301302

302303
# UPDATE PROJECT BY NAME
303304
@project.command('update', help="Update a project by name")
304-
@click.option('--project-name', '-p', required=False, help="Project Name", type=click.STRING)
305+
@click.option('--project-name', '-p', required=False, help="Project Name", type=click.STRING, shell_complete=project_completer)
305306
@click.option('--description', '-d', help="Description of the project")
306307
@click.option('--quirk', '-q', multiple=True, help="Quirk")
307308
@click.option('--tags', '-t', help="Comma-separated list of tags, example: 'key1=value1,key2=value2'")
@@ -349,7 +350,7 @@ def project_update_command(ctx, project_name, description, quirk, tags, disable_
349350

350351
# GET PROJECT QUOTAS BY PROJECT NAME
351352
@project.command('quotas', help="Get project quotas")
352-
@click.option('--project-name', '-p', help="Name of the project")
353+
@click.option('--project-name', '-p', help="Name of the project", shell_complete=project_completer)
353354
@click.option('--output', '-o', type=click.Choice(["json", "yaml", "table"]), help="Specify output format, by default is json")
354355
@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer)
355356
@click.pass_context
@@ -377,7 +378,7 @@ def project_get_quotas(ctx, project_name, output, profile):
377378

378379
# GET PROJECT SNAPSHOTS BY PROJECT NAME
379380
@project.command('snapshots', help="Get project snapshots")
380-
@click.option('--project-name', '-p', help="Name of the project")
381+
@click.option('--project-name', '-p', help="Name of the project", shell_complete=project_completer)
381382
@click.option('--output', '-o', type=click.Choice(["json", "yaml"]), help="Specify output format, by default is json")
382383
@click.option('--profile', '-pr', help="Configuration profile to use", shell_complete=profile_completer)
383384
@click.pass_context
@@ -393,7 +394,7 @@ def project_get(ctx, project_name, output, profile):
393394

394395
# GET PUBLIC IPS BY PROJECT NAME
395396
@project.command('publicips', help="Get project public ips")
396-
@click.option('--project-name', '-p', help="Name of the project")
397+
@click.option('--project-name', '-p', help="Name of the project", shell_complete=project_completer)
397398
@click.option('--output', '-o', type=click.Choice(["json", "yaml"]), help="Specify output format, by default is json")
398399
@click.option('--profile', '-pr',help="Configuration profile to use")
399400
@click.pass_context

0 commit comments

Comments
 (0)