Skip to content

Commit f473b6a

Browse files
committed
🔖 chore: Sync CLI with latest release v1.14
1 parent de4c0e0 commit f473b6a

5 files changed

Lines changed: 22 additions & 11 deletions

File tree

oks_cli/cluster.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def cluster(ctx, project_name, cluster_name, profile):
3131

3232
# LOGIN ON CLUSTER
3333
@cluster.command('login', help="Set a default cluster")
34-
@click.option('--cluster-name', '-c', required=True, help="Name of cluster")
34+
@click.option('--cluster-name', '-c', required=False, help="Name of cluster")
3535
@click.option("--profile", help="Configuration profile to use", shell_complete=profile_completer)
3636
@click.pass_context
3737
def cluster_login(ctx, cluster_name, profile):
@@ -312,8 +312,7 @@ def _create_cluster(project_name, cluster_config, output):
312312
# CLUSTER CREATE BY NAME
313313
@cluster.command('create', help="Create a new cluster")
314314
@click.option('--project-name', '-p', required=False, help="Project Name")
315-
@click.option('--cluster-name', '-c', required=True, help="Cluster Name")
316-
@click.option('--name', 'cluster_name', required=True, help="Cluster Name")
315+
@click.option('--cluster-name', '--name', '-c', required=False, help="Cluster Name")
317316
@click.option('--description', help="Description of the cluster")
318317
@click.option('--admin', help="Admin Whitelist")
319318
@click.option('--version', shell_complete=shell_completions, help="Kubernetes version")
@@ -342,6 +341,9 @@ def cluster_create_command(ctx, project_name, cluster_name, description, admin,
342341
input_data = filename.read()
343342
cluster_config = detect_and_parse_input(input_data)
344343

344+
if not cluster_name and "name" not in cluster_config:
345+
raise click.BadArgumentUsage("Missing option '--cluster-name' / '-c'.")
346+
345347
if cluster_name:
346348
cluster_config['name'] = cluster_name
347349

@@ -646,7 +648,7 @@ def _run_kubectl(project_id, cluster_id, user, group, args, input=None):
646648
kubeconfig_path = save_cache(project_id, cluster_id, 'kubeconfig', kubeconfig_raw, user, group)
647649

648650
env = dict(os.environ)
649-
env['KUBECONFIG'] = kubeconfig_path
651+
env['KUBECONFIG'] = str(kubeconfig_path)
650652
cmd = ['kubectl']
651653
cmd += list(args)
652654
logging.info("running %s", cmd)

oks_cli/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def fullhelp():
7979
def version():
8080
"""Display the current CLI version."""
8181
import importlib.metadata
82-
print(importlib.metadata.version(__package__) + ".KAAS-1014")
82+
print(importlib.metadata.version(__package__))
8383

8484
@cli.command("install-completion", help="Install shell completion scripts.")
8585
@click.option('--type', help="Shell")

oks_cli/profile.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import click
2-
from .utils import set_profile, remove_profile, profile_list, DEFAULT_API_URL
2+
from .utils import set_profile, remove_profile, profile_list, DEFAULT_API_URL, get_profiles
33

44

55
# DEFINE THE PROFILE COMMAND GROUP
@@ -23,6 +23,16 @@ def add_profile(profile_name, access_key, secret_key, username, password, region
2323
if not profile_name:
2424
profile_name = "default"
2525

26+
existing_profiles = get_profiles()
27+
if profile_name in existing_profiles:
28+
confirm = click.confirm(
29+
f"The profile '{profile_name}' already exists. Do you want to replace it?",
30+
default=False
31+
)
32+
if not confirm:
33+
click.echo("Aborted.")
34+
return
35+
2636
obj = {
2737
"region_name": region
2838
}
@@ -47,9 +57,8 @@ def add_profile(profile_name, access_key, secret_key, username, password, region
4757

4858
set_profile(profile_name, obj)
4959

50-
profile_name = click.style(profile_name, bold=True)
51-
52-
click.echo(f"Profile {profile_name} has been successfully added")
60+
profile_name_styled = click.style(profile_name, bold=True)
61+
click.echo(f"Profile {profile_name_styled} has been successfully added")
5362

5463
@profile.command('update', help="Update an existing profile")
5564
@click.option('--profile-name', required=True, help="Name of profile", type=click.STRING)

oks_cli/project.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def project(ctx, project_name, profile):
2020

2121
# LOGIN ON PROJECT
2222
@project.command('login', help="Set a default project by name")
23-
@click.option('--project-name', '-p', required=True, help="Name of project", type=click.STRING)
23+
@click.option('--project-name', '-p', required=False, help="Name of project", type=click.STRING)
2424
@click.option('--profile', help="Configuration profile to use", shell_complete=profile_completer)
2525
@click.pass_context
2626
def project_login(ctx, project_name, profile):

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name="oks-cli",
5-
version="1.13",
5+
version="1.14",
66
packages=['oks_cli'],
77
author="Outscale SAS",
88
author_email="mgrechukh@satelliz.com",

0 commit comments

Comments
 (0)