Skip to content

Commit

Permalink
v0.9.1
Browse files Browse the repository at this point in the history
  • Loading branch information
DaemonDude23 committed Nov 12, 2021
1 parent 0ea0b32 commit 899ecac
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 29 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

- [Changelog](#changelog)
- [v0.9.1](#v091)
- [v0.9.0](#v090)
- [v0.8.0](#v080)
- [v0.7.0](#v070)
Expand All @@ -13,6 +14,15 @@

---

## [v0.9.1](https://github.com/DaemonDude23/helmizer/releases/tag/v0.9.1)

November 11 2021

**Bugfixes**

- Fixed `kustomization.yaml` not being written to disk... wtf?
- Fixed config property `sort-keys` being unenforced.

## [v0.9.0](https://github.com/DaemonDude23/helmizer/releases/tag/v0.9.0)

November 7 2021
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ The `sealed-secrets` **Helm** chart is used for examples for its small scope.
For local installation/use of the raw script, I use a local virtual environment to isolate dependencies:

```bash
git clone https://github.com/DaemonDude23/helmizer.git -b v0.9.0
git clone https://github.com/DaemonDude23/helmizer.git -b v0.9.1
cd helmizer
```

Expand Down Expand Up @@ -189,7 +189,7 @@ In this example (*Nix OS), we're redirecting program output to the (e.g. `kustom
docker run --name helmizer \
--rm \
-v "$PWD"/examples:/tmp/helmizer -w /tmp/helmizer \
docker.pkg.github.com/DaemonDude23/helmizer/helmizer:v0.9.0 /usr/src/app/helmizer.py \
docker.pkg.github.com/DaemonDude23/helmizer/helmizer:v0.9.1 /usr/src/app/helmizer.py \
./resources/ > ./examples/resources/kustomization.yaml
```

Expand Down
1 change: 0 additions & 1 deletion examples/generatorOptions/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ generatorOptions:
labels:
kustomize.generated.resources: bla-bla
kind: Kustomization
namespace: default
60 changes: 34 additions & 26 deletions src/helmizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,14 @@ def __init__(self, helmizer_config, arguments):
pass

def sort_keys(self):
try:
self.helmizer_config["helmizer"]["sort-keys"].get(bool)
for array in ["crds", "components", "patchesStrategicMerge", "resources"]:
self.yaml[array].sort()
except KeyError:
pass
self.helmizer_config["helmizer"]["sort-keys"].get(bool)
for key in ["crds", "components", "patchesStrategicMerge", "resources"]:
try:
self.yaml[key].sort()
except KeyError:
pass
logging.debug("keys sorted")


def print_kustomization(self):
try:
Expand All @@ -83,29 +85,35 @@ def print_kustomization(self):

def write_kustomization(self, arguments):
try:
if self.helmizer_config["helmizer"]["dry-run"].get(bool) or arguments.dry_run:
if arguments.dry_run:
logging.debug("Performing dry-run, not writing to a file system")
return 0
elif self.helmizer_config["helmizer"]["dry-run"].get(bool):
logging.debug("Performing dry-run, not writing to a file system")
return 0
except NotFoundError:
# identify kustomization file's parent directory
str_kustomization_directory = path.dirname(path.abspath(path.normpath(arguments.helmizer_config)))
pass

# identify kustomization file name
str_kustomization_file_name = str()
try:
str_kustomization_file_name = self.helmizer_config["helmizer"]["kustomization-file-name"].get(str)
except NotFoundError:
str_kustomization_file_name = "kustomization.yaml"
# identify kustomization file's parent directory
str_kustomization_directory = path.dirname(path.abspath(path.normpath(arguments.helmizer_config)))

# write to file
try:
kustomization_file_path = path.normpath(f"{str_kustomization_directory}/{str_kustomization_file_name}")
with open(kustomization_file_path, "w") as file:
file.write(yaml.dump(self.yaml))
logging.debug(f"Successfully wrote to file: {path.abspath(kustomization_file_path)}")
except IsADirectoryError as e:
raise e
except TypeError:
pass
# identify kustomization file name
str_kustomization_file_name = str()
try:
str_kustomization_file_name = self.helmizer_config["helmizer"]["kustomization-file-name"].get(str)
except NotFoundError:
str_kustomization_file_name = "kustomization.yaml"

# write to file
try:
kustomization_file_path = path.normpath(f"{str_kustomization_directory}/{str_kustomization_file_name}")
with open(kustomization_file_path, "w") as file:
file.write(yaml.dump(self.yaml))
logging.debug(f"Successfully wrote to file: {path.abspath(kustomization_file_path)}")
except IsADirectoryError as e:
raise e
except TypeError:
pass

def render_template(self, arguments):
logging.debug("Rendering template")
Expand Down Expand Up @@ -318,7 +326,7 @@ def init_arg_parser():
help="quiet output from subprocesses",
default=False,
)
args.add_argument("--version", "-v", action="version", version="v0.9.0")
args.add_argument("--version", "-v", action="version", version="v0.9.1")
args.add_argument(
"helmizer_config",
action="store",
Expand Down

0 comments on commit 899ecac

Please sign in to comment.