diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ef9923..18fe977 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,3 +3,7 @@ Changelog - [Changelog](#changelog) --- + +# v0.2.0 - Aug 18 2021 + +- Improved logging. diff --git a/README.md b/README.md index acb283f..e119c4d 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ - [In-place Update Against Multiple Files](#in-place-update-against-multiple-files) - [Write to Separate File](#write-to-separate-file) - [Points of Interest](#points-of-interest) - - [Detail About The New API Version's `spec`](#detail-about-the-new-api-versions-spec) + - [Details About The New API Version's `spec`](#details-about-the-new-api-versions-spec) - [Calculate `diff` Between Versions](#calculate-diff-between-versions) - [`v1beta1`](#v1beta1) - [`v1`](#v1) @@ -45,7 +45,7 @@ Requires Python `3.6`+ 1. Get the code ```bash -git clone git clone https://github.com/DaemonDude/kube-inverter.git -b v0.1.0 +git clone git clone https://github.com/DaemonDude/kube-inverter.git -b v0.2.0 ``` 2. Get into that directory ```bash @@ -62,8 +62,8 @@ pip3 install -r ./src/requirements.txt ## CLI Usage -- **By default, this will update your file in place**. If that's not desired, use `--dry-run` to test it, or write to a separate file with `--output-file`. -- Only one file is updated per run. Wrap this script in a loop (see examples further down) to operate it against multiple files. +- **By default, this will update your file in place**. If that's not desired, write to a separate file with `--output-file`. +- Only one file is updated per run. Wrap this script in a loop (see examples further down) to operate against multiple files. ``` usage: kube-inverter [-h] [--debug] [--output-file OUTPUT_FILE] [--path-type PATH_TYPE] [--version] input_file @@ -101,12 +101,12 @@ find ./examples/in-place-update/ -type f -name '*.yaml' -exec kube-inverter '{}' ##### Write to Separate File ```bash -find ./examples/multiple-documents/ -type f -name '*.yaml' -exec kube-inverter '{}' -o '{}'-out \; +find ./examples/multiple-documents/ -type f -name '*.yaml' -exec kube-inverter --path-type Prefix '{}' -o '{}'-out \; ``` ## Points of Interest -### Detail About The New API Version's `spec` +### Details About The New API Version's `spec` #### Calculate `diff` Between Versions diff --git a/src/main.py b/src/main.py index 94931f7..36d225d 100755 --- a/src/main.py +++ b/src/main.py @@ -24,7 +24,7 @@ def init_arg_parser(): try: parser = argparse.ArgumentParser( prog="kube-inverter", - description="Converts Kubernetes Ingress objects from 'networking.k8s.io/v1beta1' to 'networking.k8s.io/v1'", + description="converts Kubernetes Ingress objects from 'networking.k8s.io/v1beta1' to 'networking.k8s.io/v1'", formatter_class=argparse.ArgumentDefaultsHelpFormatter, ) @@ -41,7 +41,7 @@ def init_arg_parser(): "-o", dest="output_file", action="store", - help="Output file path. This disables an in-place update to the input file", + help="output file path. This disables an in-place update to the input file", ) args.add_argument( "--path-type", @@ -49,9 +49,9 @@ def init_arg_parser(): "-p", dest="path_type", action="store", - help="Path Type for Ingress rule. Options: 'Exact', 'ImplementationSpecific', 'Prefix'", + help="path Type for Ingress rule. Options: 'Exact', 'ImplementationSpecific', 'Prefix'", ) - args.add_argument("--version", "-v", action="version", version="v0.1.0") + args.add_argument("--version", "-v", action="version", version="v0.2.0") args.add_argument("input_file", action="store", type=str, help="input file") arguments = parser.parse_args() @@ -173,15 +173,14 @@ def convert(arguments): int_num_of_ingress_v1beta_converted += 1 except KeyError as e: - logging.fatal("Failed to find expected keys in input YAML") - raise e + logging.warning(f"{input_file_path} - Failed to find expected keys in input YAML") yaml.dump(data) # write updates to payload - logging.info(f"Number of documents found: {int_num_of_documents}") - logging.info(f"Number of v1beta Ingress documents found: {int_num_of_ingress_v1beta_documents}") - logging.info(f"Number of v1beta Ingress documents converted to v1: {int_num_of_ingress_v1beta_converted}") - logging.info(f"Number of v1 Ingress documents found: {int_num_of_ingress_v1_documents}") + logging.info(f"{input_file_path} - Number of documents found: {int_num_of_documents}") + logging.info(f"{input_file_path} - Number of v1beta Ingress documents found: {int_num_of_ingress_v1beta_documents}") + logging.info(f"{input_file_path} - Number of v1beta Ingress documents converted to v1: {int_num_of_ingress_v1beta_converted}") + logging.info(f"{input_file_path} - Number of v1 Ingress documents found: {int_num_of_ingress_v1_documents}") if arguments.output_file: ingress_yaml_file.rename(output_file_path)