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

Make url configurable on the command call #4

Closed
wants to merge 1 commit into from
Closed
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
35 changes: 21 additions & 14 deletions kio/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,11 @@ def applications():
@click.option('-s', '--since')
@click.option('-t', '--team', help='Filter by team')
@click.option('-a', '--all', is_flag=True, help='List all applications (also disabled)')
@click.option('--url', help='URL for Kio instance', metavar='URI')
@click.pass_obj
def list_apps(config, output, since, team, **kwargs):
def list_apps(config, output, since, team, url, **kwargs):
'''List applications'''
url = get_url(config)
url = url or get_url(config)
token = get_token()

since_str = parse_since(since) if since else ''
Expand Down Expand Up @@ -119,9 +120,10 @@ def list_apps(config, output, since, team, **kwargs):
@output_option
@click.pass_obj
@click.argument('application_id')
def show_app(config, application_id, output):
@click.option('--url', help='URL for Kio instance', metavar='URI')
def show_app(config, application_id, output, url):
'''Show application'''
url = get_url(config)
url = url or get_url(config)
token = get_token()

r = request(url, '/apps/{}'.format(application_id), token)
Expand All @@ -137,11 +139,12 @@ def show_app(config, application_id, output):
@click.pass_obj
@click.argument('application_id')
@click.argument('key_val_pairs', nargs=-1)
def update(config, application_id, key_val_pairs):
@click.option('--url', help='URL for Kio instance', metavar='URI')
def update(config, application_id, key_val_pairs, url):
'''Update a single application

kio app up APPLICATION_ID KEY1=VAL1 ..'''
url = get_url(config)
url = url or get_url(config)
token = get_token()

r = request(url, '/apps/{}'.format(application_id), token)
Expand Down Expand Up @@ -178,10 +181,11 @@ def versions():
@output_option
@click.argument('application_id')
@click.option('-s', '--since', default='60d')
@click.option('--url', help='URL for Kio instance', metavar='URI')
@click.pass_obj
def list_versions(config, application_id, output, since):
def list_versions(config, application_id, output, since, url):
'''List application versions'''
url = get_url(config)
url = url or get_url(config)
token = get_token()

since_str = parse_since(since)
Expand Down Expand Up @@ -213,10 +217,11 @@ def list_versions(config, application_id, output, since):
@click.argument('version')
@click.argument('artifact')
@click.option('-m', '--notes', help='Notes', default='')
@click.option('--url', help='URL for Kio instance', metavar='URI')
@click.pass_obj
def create_version(config, application_id, version, artifact, notes):
def create_version(config, application_id, version, artifact, notes, url):
'''Create a new application version'''
url = get_url(config)
url = url or get_url(config)
token = get_token(['uid', 'application.write'])

data = {'artifact': artifact, 'notes': notes}
Expand All @@ -235,10 +240,11 @@ def create_version(config, application_id, version, artifact, notes):
@click.option('-t', '--approval-types', help='Approval types (comma separated)',
default='SPECIFICATION,CODE_CHANGE,TEST,DEPLOY')
@click.option('-m', '--notes', help='Notes', default='')
@click.option('--url', help='URL for Kio instance', metavar='URI')
@click.pass_obj
def approve_version(config, application_id, version, approval_types, notes):
def approve_version(config, application_id, version, approval_types, notes, url):
'''Approve application version'''
url = get_url(config)
url = url or get_url(config)
token = get_token()

for approval_type in approval_types.split(','):
Expand All @@ -256,10 +262,11 @@ def approve_version(config, application_id, version, approval_types, notes):
@output_option
@click.argument('application_id')
@click.argument('version')
@click.option('--url', help='URL for Kio instance', metavar='URI')
@click.pass_obj
def show_version(config, application_id, version, output):
def show_version(config, application_id, version, output, url):
'''Show version details'''
url = get_url(config)
url = url or get_url(config)
token = get_token()

r = request(url, '/apps/{}/versions/{}'.format(application_id, version), token)
Expand Down