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

added serverless function and kubectl hyperkube command to remove pem… #41

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
18 changes: 18 additions & 0 deletions cli/kubectl-hyperkube
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this fail with a message?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, Why would it return a 404? It seems to only return a 200 or 500.

except ClientError as e:

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

500 makes sense

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)
Expand Down
7 changes: 7 additions & 0 deletions serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,13 @@ functions:
path: clusters/get-pem
method: get
private: true
remove_pem:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like a test should be added for adding and removing pems.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good!! Now that the Moto framework in place should be no problem

handler: pem.remove_pem
events:
- http:
path: clusters/remove-pem
method: delete
private: true
list_clusters:
handler: list_clusters.list_clusters
events:
Expand Down