def plot(ctx, run_all, log_level, course_file=None, dry_run=False, debug=False, only=None, helm_args=None, continue_on_error=False, create_namespace=True, update_repos=True): """ Install charts with given arguments as listed in yaml file argument """ coloredlogs.install(level=log_level) Config().update_repos = update_repos if not run_all: if len(only) < 1: logging.error("You must pass either --run-all or --only.") ctx.exit(1) try: # Check Schema of Course FileA with open(course_file.name, 'rb') as course_file_stream: validate_course_file(course_file_stream) # Load Reckoner r = Reckoner(course_file=course_file, dryrun=dry_run, debug=debug, helm_args=helm_args, continue_on_error=continue_on_error, create_namespace=create_namespace) # Convert tuple to list only = list(only) r.install(only) except exception.ReckonerException as err: click.echo( click.style( "⛵🔥 Encountered errors while reading course file ⛵🔥", fg="bright_red")) click.echo(click.style("{}".format(err), fg="red")) logging.debug(traceback.format_exc()) ctx.exit(1) except Exception as err: # This handles exceptions cleanly, no expected stack traces from reckoner code click.echo( click.style( "⛵🔥 Encountered unexpected error in Reckoner! Run with DEBUG log level to see details, for example:\n\nreckoner --log-level=DEBUG plot course.yml -o <heading> --dry-run\n\n(or without heading if running the full chart). ⛵🔥", fg="bright_red")) if 'log_level' in ctx.parent.params and ctx.parent.params[ 'log_level'].lower() in ['debug', 'trace']: click.echo(click.style("{}".format(err), fg='bright_red')) logging.debug(traceback.format_exc()) ctx.exit(1) if r.results.has_errors: click.echo( click.style( "⛵🔥 Encountered errors while running the course ⛵🔥", fg="bright_red")) for result in r.results.results_with_errors: click.echo(click.style("\n* * * * *\n", fg="bright_red")) click.echo(click.style(str(result), fg="bright_red")) ctx.exit(1)
def diff(ctx, only, run_all, log_level, course_file=None, helm_args=None, update_repos=True): """Output diff of the templates that would be installed and the manifests that are currently installed""" coloredlogs.install(level=log_level) if not run_all: if len(only) < 1: logging.error("You must pass either --run-all or --only.") ctx.exit(1) Config().update_repos = update_repos try: # Check Schema of Course FileA with open(course_file.name, 'rb') as course_file_stream: validate_course_file(course_file_stream) # Load Reckoner r = Reckoner(course_file=course_file, helm_args=helm_args) # Convert tuple to list only = list(only) logging.debug(f'Only diffing the following charts: {only}') diff_results = r.diff(only) for result in diff_results: print(result.response) except exception.ReckonerException as err: click.echo( click.style( "⛵🔥 Encountered errors while reading course file ⛵🔥", fg="bright_red")) click.echo(click.style("{}".format(err), fg="red")) logging.debug(traceback.format_exc()) ctx.exit(1) except Exception as err: # This handles exceptions cleanly, no expected stack traces from reckoner code click.echo( click.style( "⛵🔥 Encountered unexpected error in Reckoner! Run with DEBUG log level to see details, for example:\n\nreckoner --log-level=DEBUG plot course.yml -o <heading> --dry-run\n\n(or without heading if running the full chart). ⛵🔥", fg="bright_red")) if 'log_level' in ctx.parent.params and ctx.parent.params[ 'log_level'].lower() in ['debug', 'trace']: click.echo(click.style("{}".format(err), fg='bright_red')) logging.debug(traceback.format_exc()) ctx.exit(1) if r.results.has_errors: click.echo( click.style( "⛵🔥 Encountered errors while running the course ⛵🔥", fg="bright_red")) for result in r.results.results_with_errors: click.echo(click.style("\n* * * * *\n", fg="bright_red")) click.echo(click.style(str(result), fg="bright_red")) ctx.exit(1)
def lint(ctx, log_level, course_file=None): """ Validate the course file schema """ coloredlogs.install(level=log_level) try: with open(course_file.name, 'rb') as course_file_stream: validate_course_file(course_file_stream) except exception.ReckonerException as err: click.echo(click.style("{}".format(err), fg="red")) ctx.exit(1) click.echo(click.style("No schema validation errors found.", fg="green"))
def plot(ctx, course_file=None, dry_run=False, debug=False, only=None, helm_args=None, continue_on_error=False): """ Install charts with given arguments as listed in yaml file argument """ try: # Check Schema of Course FileA with open(course_file.name, 'rb') as course_file_stream: validate_course_file(course_file_stream) # Load Reckoner r = Reckoner(course_file=course_file, dryrun=dry_run, debug=debug, helm_args=helm_args, continue_on_error=continue_on_error) # Convert tuple to list only = list(only) r.install(only) except exception.ReckonerException as err: click.echo( click.style( "⛵🔥 Encountered errors while reading course file ⛵🔥", fg="bright_red")) click.echo(click.style("{}".format(err), fg="red")) ctx.exit(1) except Exception as err: # This handles exceptions cleanly, no expected stack traces from reckoner code click.echo( click.style( "⛵🔥 Encountered unexpected error in Reckoner! Run with --log-level debug to see details! ⛵🔥", fg="bright_red")) if debug: click.echo(click.style("{}".format(err))) ctx.exit(1) if r.results.has_errors: click.echo( click.style( "⛵🔥 Encountered errors while running the course ⛵🔥", fg="bright_red")) for result in r.results.results_with_errors: click.echo(click.style("\n* * * * *\n", fg="bright_red")) click.echo(click.style(str(result), fg="bright_red")) ctx.exit(1)