Skip to content
Merged
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
10 changes: 5 additions & 5 deletions oks_cli/cache.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import click
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
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
import prettytable

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

@cache.command('kubeconfigs', help="List cached kubeconfigs")
@click.option('--project-name', '-p', required=False, help="Project Name")
@click.option('--cluster-name', '-c', required=False, help="Cluster Name")
@click.option('--project-name', '-p', required=False, help="Project Name", shell_complete=project_completer)
@click.option('--cluster-name', '-c', required=False, help="Cluster Name", shell_complete=cluster_completer)
@click.option('--plain', is_flag=True, help="Plain table format")
@click.option('--msword', is_flag=True, help="Microsoft Word table format")
@click.option('--profile', help="Configuration profile to use", shell_complete=profile_completer)
Expand Down
46 changes: 23 additions & 23 deletions oks_cli/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@
import prettytable
import logging

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
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

from .profile import add_profile
from .project import project_create, project_login

# DEFINE THE CLUSTER GROUP
@click.group(help="Cluster related commands.")
@click.option('--project', 'project_name', required = False, help="Project Name")
@click.option('--project-name', '-p', required = False, help="Project Name")
@click.option('--project-name', '-p', required = False, help="Project Name", shell_complete=project_completer)
@click.option('--name', 'cluster_name', required = False, help="Cluster Name")
@click.option('--cluster-name', '-c', required = False, help="Cluster Name")
@click.option('--cluster-name', '-c', required = False, help="Cluster Name", shell_complete=cluster_completer)
@click.option("--profile", help="Configuration profile to use", shell_complete=profile_completer)
@click.pass_context
def cluster(ctx, project_name, cluster_name, profile):
Expand All @@ -31,7 +31,7 @@ def cluster(ctx, project_name, cluster_name, profile):

# LOGIN ON CLUSTER
@cluster.command('login', help="Set a default cluster")
@click.option('--cluster-name', '-c', required=False, help="Name of cluster")
@click.option('--cluster-name', '-c', required=False, help="Name of cluster", shell_complete=cluster_completer)
@click.option("--profile", help="Configuration profile to use", shell_complete=profile_completer)
@click.pass_context
def cluster_login(ctx, cluster_name, profile):
Expand Down Expand Up @@ -70,9 +70,9 @@ def cluster_logout(ctx, profile):

# LIST CLUSTERS
@cluster.command('list', help="List all clusters")
@click.option('--project-name', '-p', required=False, help="Project Name")
@click.option('--project-name', '-p', required=False, help="Project Name", shell_complete=project_completer)
@click.option('--name', 'cluster_name', required = False, help="Cluster Name")
@click.option('--cluster-name', '-c', required = False, help="Cluster Name")
@click.option('--cluster-name', '-c', required = False, help="Cluster Name", shell_complete=cluster_completer)
@click.option('--deleted', is_flag=True, help="List deleted clusters")
@click.option('--plain', is_flag=True, help="Plain table format")
@click.option('--msword', is_flag=True, help="Microsoft Word table format")
Expand Down Expand Up @@ -215,9 +215,9 @@ def format_row(cluster):

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

# CLUSTER CREATE BY NAME
@cluster.command('create', help="Create a new cluster")
@click.option('--project-name', '-p', required=False, help="Project Name")
@click.option('--cluster-name', '--name', '-c', required=False, help="Cluster Name")
@click.option('--project-name', '-p', required=False, help="Project Name", shell_complete=project_completer)
@click.option('--cluster-name', '--name', '-c', required=False, help="Cluster Name", shell_complete=cluster_completer)
@click.option('--description', help="Description of the cluster")
@click.option('--admin', help="Admin Whitelist")
@click.option('--version', shell_complete=shell_completions, help="Kubernetes version")
Expand Down Expand Up @@ -411,9 +411,9 @@ def cluster_create_command(ctx, project_name, cluster_name, description, admin,

# UPDATE CLUSTER
@cluster.command('update', help="Update a cluster by name")
@click.option('--project-name', '-p', required=False, help="Project name")
@click.option('--project-name', '-p', required=False, help="Project name", shell_complete=project_completer)
@click.option('--name', 'cluster_name', required=False, help="Cluster name")
@click.option('--cluster-name', '-c', required=False, help="Cluster name")
@click.option('--cluster-name', '-c', required=False, help="Cluster name", shell_complete=cluster_completer)
@click.option('--description', help="Description of the cluster")
@click.option('--admin', help="Admin Whitelist")
@click.option('--version', shell_complete=shell_completions, help="Kubernetes version")
Expand Down Expand Up @@ -499,9 +499,9 @@ def cluster_update_command(ctx, project_name, cluster_name, description, admin,

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

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

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


@cluster.command('kubectl', help='Fetch the kubeconfig for a cluster and run kubectl against it', context_settings={"ignore_unknown_options": True})
@click.option('--project-name', '-p', required=False, help="Project Name")
@click.option('--cluster-name', '-c', required=False, help="Cluster Name")
@click.option('--project-name', '-p', required=False, help="Project Name", shell_complete=project_completer)
@click.option('--cluster-name', '-c', required=False, help="Cluster Name", shell_complete=cluster_completer)
@click.option('--user', type=click.STRING, help="User")
@click.option('--group', type=click.STRING, help="Group")
@click.argument("args", nargs=-1, type=click.UNPROCESSED)
Expand All @@ -682,8 +682,8 @@ def cluster_kubectl_command(ctx, project_name, cluster_name, user, group, args,


@click.group(help="nodepool related commands.")
@click.option('--project-name', '-p', required=False, help="Project Name")
@click.option('--cluster-name', '-c', required=False, help="Cluster Name")
@click.option('--project-name', '-p', required=False, help="Project Name", shell_complete=project_completer)
@click.option('--cluster-name', '-c', required=False, help="Cluster Name", shell_complete=cluster_completer)
@click.option('--user', type=click.STRING, help="User")
@click.option('--group', type=click.STRING, help="Group")
@click.option('--profile', help="Configuration profile to use", shell_complete=profile_completer)
Expand Down
6 changes: 3 additions & 3 deletions oks_cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
from .cache import cache
from .quotas import quotas

from .utils import ctx_update, login_profile, install_completions, profile_completer
from .utils import ctx_update, login_profile, install_completions, profile_completer, cluster_completer, project_completer

# Main CLI entry point
@click.group(invoke_without_command=True)
@click.option("--profile", help="Configuration profile to use", shell_complete=profile_completer)
@click.option('--project-name', '-p', required = False, help="Project Name")
@click.option('--cluster-name', '-c', required = False, help="Cluster Name")
@click.option('--project-name', '-p', required = False, help="Project Name", shell_complete=project_completer)
@click.option('--cluster-name', '-c', required = False, help="Cluster Name", shell_complete=cluster_completer)
@click.option('-v', '--verbose', count=True)
@click.pass_context
def cli(ctx, project_name, cluster_name, profile, verbose):
Expand Down
22 changes: 11 additions & 11 deletions oks_cli/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
import prettytable
import os

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
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

# DEIFNE THE PROJECT COMMAND GROUP
@click.group(help="Project related commands.")
@click.option('--project', 'project_name', required = False, help="Project Name")
@click.option('--project-name', '-p', required = False, help="Project Name")
@click.option('--project-name', '-p', required = False, help="Project Name", shell_complete=project_completer)
@click.option("--profile", help="Configuration profile to use", shell_complete=profile_completer)
@click.pass_context
def project(ctx, project_name, profile):
Expand All @@ -20,7 +20,7 @@ def project(ctx, project_name, profile):

# LOGIN ON PROJECT
@project.command('login', help="Set a default project by name")
@click.option('--project-name', '-p', required=False, help="Name of project", type=click.STRING)
@click.option('--project-name', '-p', required=False, help="Name of project", type=click.STRING, shell_complete=project_completer)
@click.option('--profile', help="Configuration profile to use", shell_complete=profile_completer)
@click.pass_context
def project_login(ctx, project_name, profile):
Expand Down Expand Up @@ -58,7 +58,7 @@ def project_logout(ctx, profile):

# LIST PROJECTS
@project.command('list', help="List all projects")
@click.option('--project-name', '-p', help="Name of project", type=click.STRING)
@click.option('--project-name', '-p', help="Name of project", type=click.STRING, shell_complete=project_completer)
@click.option('--deleted', is_flag=True, help="List deleted projects")
@click.option('--plain', is_flag=True, help="Plain table format")
@click.option('--msword', is_flag=True, help="Microsoft Word table format")
Expand Down Expand Up @@ -193,7 +193,7 @@ def format_row(project):

# CREATE PROJECT BY NAME
@project.command('create', help="Create a new project")
@click.option('--project-name', '-p', help="Name of the project")
@click.option('--project-name', '-p', help="Name of the project", shell_complete=project_completer)
@click.option('--description', help="Description of the project")
@click.option('--cidr', help='CIDR for the project')
@click.option('--quirk', multiple=True, help="Quirk")
Expand Down Expand Up @@ -254,7 +254,7 @@ def project_create(ctx, project_name, description, cidr, quirk, tags, disable_ap

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

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

# UPDATE PROJECT BY NAME
@project.command('update', help="Update a project by name")
@click.option('--project-name', '-p', required=False, help="Project Name")
@click.option('--project-name', '-p', required=False, help="Project Name", shell_complete=project_completer)
@click.option('--description', help="Description of the project")
@click.option('--quirk', multiple=True, help="Quirk")
@click.option('--tags', help="Comma-separated list of tags, example: 'key1=value1,key2=value2'")
Expand Down Expand Up @@ -350,7 +350,7 @@ def project_update_command(ctx, project_name, description, quirk, tags, disable_

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

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

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