Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Commit

Permalink
v0.2.0
Browse files Browse the repository at this point in the history
- Improved logging
  • Loading branch information
DaemonDude23 committed Aug 19, 2021
1 parent 03103f5 commit 891d65e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ Changelog
- [Changelog](#changelog)

---

# v0.2.0 - Aug 18 2021

- Improved logging.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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

Expand Down
19 changes: 9 additions & 10 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)

Expand All @@ -41,17 +41,17 @@ 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",
"--pathType",
"-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()

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 891d65e

Please sign in to comment.