From 556af4146db7d913d38368bd53c16544af74c331 Mon Sep 17 00:00:00 2001 From: swarupdonepudi Date: Wed, 4 Mar 2020 12:20:11 -0800 Subject: [PATCH] added serverless function and kubectl hyperkube command to remove pem file: go --- cli/kubectl-hyperkube | 18 ++++++++++++++++++ serverless.yml | 7 +++++++ 2 files changed, 25 insertions(+) diff --git a/cli/kubectl-hyperkube b/cli/kubectl-hyperkube index 408b999..8ea82f0 100755 --- a/cli/kubectl-hyperkube +++ b/cli/kubectl-hyperkube @@ -194,6 +194,24 @@ def get_pem(ctx, cluster): print(f'Request error: {err}') +@cli.command() +@click.option('--cluster', '-g') +@click.pass_context +def remove_pem(ctx, cluster): + """Removethe pem file for a specific cluster""" + + try: + r = requests.delete( + (f'{ctx.obj["url"]}/{ctx.obj["stage"]}' + f'/clusters/remove-pem?cluster_name={cluster}'), + headers=ctx.obj['headers'] + ) + if r.status_code == 404: + sys.exit(1) + except requests.exceptions.RequestException as err: + print(f'Request error: {err}') + + @cli.command() @click.option('--cluster', '-g', required=True) @click.option('--pem', '-p', required=True) diff --git a/serverless.yml b/serverless.yml index bfd85d4..4b18097 100644 --- a/serverless.yml +++ b/serverless.yml @@ -110,6 +110,13 @@ functions: path: clusters/get-pem method: get private: true + remove_pem: + handler: pem.remove_pem + events: + - http: + path: clusters/remove-pem + method: delete + private: true list_clusters: handler: list_clusters.list_clusters events: