Skip to content

Commit

Permalink
Check if keys directory exists
Browse files Browse the repository at this point in the history
  • Loading branch information
taleksovska committed Mar 19, 2024
1 parent 4ea959f commit 4d01aef
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 22 deletions.
5 changes: 3 additions & 2 deletions enabler/commands/cmd_kind.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,11 @@ def delete(ctx, kube_context_cli, kube_context):
required=False)
@click.pass_context
@pass_environment
def status(ctx):
def status(ctx, kube_context):
"""Check the status of the kind cluster"""
kube_context = ctx.kube_context
# Check if the cluster exists
if ctx.kube_context is not None:
kube_context = ctx.kube_context
if kind.kind_get(kube_context):
if kube.kubectl_info(kube_context):
logger.info('Kind cluster \'' + kube_context + '\' is running')
Expand Down
10 changes: 6 additions & 4 deletions enabler/commands/cmd_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,11 @@ def keys(ctx, kube_context_cli, bits):
private_key_filename = 'key.pem'
public_key_filename = 'key.pub'

# Create keys directory if it doesn't exist
os.makedirs(keys_dir, exist_ok=True)
# Check if keys directory exists
if not os.path.exists(keys_dir):
logger.info("Creating key directory...")
os.makedirs(keys_dir)
logger.info("Keys directory already exists")

# Check if the keys exist and warn user
if (
Expand Down Expand Up @@ -137,7 +140,6 @@ def keys(ctx, kube_context_cli, bits):
f = open(keys_dir + public_key_filename, 'wb')
f.write(public_key)
f.close()
logger.info('Keys generated successfully.')


@cli.command('release', short_help='Make a platform release')
Expand Down Expand Up @@ -249,4 +251,4 @@ def version(ctx, kube_context_cli, submodules, repopath):
logger.info(u'\u2023' + ' Ahead by: ' + str(sm_details['commits_ahead']) + ' commits') # noqa

if 'commits_behind' in sm_details and sm_details['commits_behind'] > 0:
logger.info(u'\u2023' + ' Behind by: ' + str(sm_details['commits_behind']) + ' commits') # noqa
logger.info(u'\u2023' + ' Behind by: ' + str(sm_details['commits_behind']) + ' commits') # noqa
17 changes: 1 addition & 16 deletions enabler/commands/cmd_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,7 @@
import pkg_resources
import click


# Autocompletion function for the version command
def complete_version(ctx, args, incomplete):
# List of possible completions
completions = ['version']
if incomplete.startswith('v'):
completions.append('version')
return [c for c in completions if c.startswith(incomplete)]


# Command to get the current Enabler version
@click.group('version', short_help='Get current version of Enabler', invoke_without_command=True) # noqa
@click.pass_context
@pass_environment
Expand All @@ -20,9 +11,3 @@ def cli(ctx, kube_context_cli):
distribution = pkg_resources.get_distribution("enabler")
version = distribution.version
logger.info("Enabler "+version)


# Option for autocomplete
@click.option('--autocomplete', is_flag=True, callback=complete_version, expose_value=False, is_eager=True) # noqa
def version(self):
pass

0 comments on commit 4d01aef

Please sign in to comment.