@@ -68,12 +68,14 @@ def __init__(self, helmizer_config, arguments):
6868 pass
6969
7070 def sort_keys (self ):
71- try :
72- self .helmizer_config ["helmizer" ]["sort-keys" ].get (bool )
73- for array in ["crds" , "components" , "patchesStrategicMerge" , "resources" ]:
74- self .yaml [array ].sort ()
75- except KeyError :
76- pass
71+ self .helmizer_config ["helmizer" ]["sort-keys" ].get (bool )
72+ for key in ["crds" , "components" , "patchesStrategicMerge" , "resources" ]:
73+ try :
74+ self .yaml [key ].sort ()
75+ except KeyError :
76+ pass
77+ logging .debug ("keys sorted" )
78+
7779
7880 def print_kustomization (self ):
7981 try :
@@ -83,29 +85,35 @@ def print_kustomization(self):
8385
8486 def write_kustomization (self , arguments ):
8587 try :
86- if self .helmizer_config ["helmizer" ]["dry-run" ].get (bool ) or arguments .dry_run :
88+ if arguments .dry_run :
89+ logging .debug ("Performing dry-run, not writing to a file system" )
90+ return 0
91+ elif self .helmizer_config ["helmizer" ]["dry-run" ].get (bool ):
8792 logging .debug ("Performing dry-run, not writing to a file system" )
93+ return 0
8894 except NotFoundError :
89- # identify kustomization file's parent directory
90- str_kustomization_directory = path .dirname (path .abspath (path .normpath (arguments .helmizer_config )))
95+ pass
9196
92- # identify kustomization file name
93- str_kustomization_file_name = str ()
94- try :
95- str_kustomization_file_name = self .helmizer_config ["helmizer" ]["kustomization-file-name" ].get (str )
96- except NotFoundError :
97- str_kustomization_file_name = "kustomization.yaml"
97+ # identify kustomization file's parent directory
98+ str_kustomization_directory = path .dirname (path .abspath (path .normpath (arguments .helmizer_config )))
9899
99- # write to file
100- try :
101- kustomization_file_path = path .normpath (f"{ str_kustomization_directory } /{ str_kustomization_file_name } " )
102- with open (kustomization_file_path , "w" ) as file :
103- file .write (yaml .dump (self .yaml ))
104- logging .debug (f"Successfully wrote to file: { path .abspath (kustomization_file_path )} " )
105- except IsADirectoryError as e :
106- raise e
107- except TypeError :
108- pass
100+ # identify kustomization file name
101+ str_kustomization_file_name = str ()
102+ try :
103+ str_kustomization_file_name = self .helmizer_config ["helmizer" ]["kustomization-file-name" ].get (str )
104+ except NotFoundError :
105+ str_kustomization_file_name = "kustomization.yaml"
106+
107+ # write to file
108+ try :
109+ kustomization_file_path = path .normpath (f"{ str_kustomization_directory } /{ str_kustomization_file_name } " )
110+ with open (kustomization_file_path , "w" ) as file :
111+ file .write (yaml .dump (self .yaml ))
112+ logging .debug (f"Successfully wrote to file: { path .abspath (kustomization_file_path )} " )
113+ except IsADirectoryError as e :
114+ raise e
115+ except TypeError :
116+ pass
109117
110118 def render_template (self , arguments ):
111119 logging .debug ("Rendering template" )
@@ -318,7 +326,7 @@ def init_arg_parser():
318326 help = "quiet output from subprocesses" ,
319327 default = False ,
320328 )
321- args .add_argument ("--version" , "-v" , action = "version" , version = "v0.9.0 " )
329+ args .add_argument ("--version" , "-v" , action = "version" , version = "v0.9.1 " )
322330 args .add_argument (
323331 "helmizer_config" ,
324332 action = "store" ,
0 commit comments