2222import nuvolaris .kustomize as nku
2323import nuvolaris .template as ntp
2424
25+ def _build (dir ):
26+ res = subprocess .run (["kustomize" , "build" , dir ], capture_output = True )
27+ if res .returncode != 0 :
28+ error = res .stderr .decode ("utf-8" )
29+ raise Exception (error )
30+ return res .stdout .decode ("utf-8" )
31+
2532# execute the kustomization of a folder under "deploy"
2633# specified with `where`
2734# it generate a kustomization.yaml, adding the header
@@ -66,8 +73,7 @@ def kustomize(where, *what, templates=[], data={}):
6673 out = f"deploy/{ where } /__{ template } "
6774 file = ntp .spool_template (template , out , data )
6875 f .write (f"- __{ template } \n " )
69- res = subprocess .run (["kustomize" , "build" , dir ], capture_output = True )
70- return res .stdout .decode ("utf-8" )
76+ return _build (dir )
7177
7278# execute the kustomization of a folder under "deploy"
7379# specified with `where` returning the expanded kustomization
@@ -76,8 +82,7 @@ def kustomize(where, *what, templates=[], data={}):
7682# the nuvolaris operator needs to delete a component
7783def build (where ):
7884 dir = f"deploy/{ where } "
79- res = subprocess .run (["kustomize" , "build" , dir ], capture_output = True )
80- return res .stdout .decode ("utf-8" )
85+ return _build (dir )
8186
8287# execute the kustomization of a folder under "deploy"
8388# specified with `where`
@@ -125,8 +130,7 @@ def restricted_kustomize(where, *what, templates=[], templates_filter=[],data={}
125130 out = f"deploy/{ where } /__{ template } "
126131 file = ntp .spool_template (template , out , data )
127132 f .write (f"- __{ template } \n " )
128- res = subprocess .run (["kustomize" , "build" , dir ], capture_output = True )
129- return res .stdout .decode ("utf-8" )
133+ return _build (dir )
130134
131135# generate image kustomization
132136def image (name , newName = None , newTag = None ):
0 commit comments