1414
1515# Import mask module for applying masking
1616try :
17- from mask import mask_resource
17+ from mask import mask_data
1818except ImportError :
19- # Fallback if mask module not found
20- mask_resource = None
19+ mask_data = None
2120
2221
2322def split_configmaps (input_file , output_dir = 'configmaps' , apply_mask = False ):
@@ -50,6 +49,9 @@ def split_configmaps(input_file, output_dir='configmaps', apply_mask=False):
5049 configmaps = data .get ('items' , [])
5150 created_files = []
5251
52+ total = len (configmaps )
53+ print (f"Processing { total } ConfigMaps from { input_file } " , flush = True )
54+
5355 # Process each ConfigMap
5456 for i , cm in enumerate (configmaps , 1 ):
5557 # Extract metadata
@@ -60,21 +62,20 @@ def split_configmaps(input_file, output_dir='configmaps', apply_mask=False):
6062 filename = f"{ name } .yaml"
6163 filepath = output_path / filename
6264
63- # Write the ConfigMap to its own file
64- with open (filepath , 'w' ) as f :
65- yaml .dump (cm , f , default_flow_style = False , sort_keys = False )
66-
67- created_files .append (str (filepath ))
65+ print (f" [{ i } /{ total } ] { name } " , flush = True )
6866
69- # Apply masking if requested and mask_resource is available
70- if apply_mask and mask_resource :
71- for file_path in created_files :
67+ if apply_mask and mask_data :
7268 try :
73- mask_resource ( file_path )
69+ mask_data ( cm , str ( filepath ) )
7470 except Exception as e :
75- print (f"Warning: Could not mask { file_path } : { e } " )
76- elif apply_mask and not mask_resource :
77- print ("Warning: Masking requested but mask module not available" )
71+ print (f"Warning: Could not mask { filepath } : { e } " )
72+ elif apply_mask and not mask_data :
73+ print (f"Warning: Masking requested but mask module not available" )
74+ else :
75+ with open (filepath , 'w' ) as f :
76+ yaml .dump (cm , f , default_flow_style = False , sort_keys = False )
77+
78+ created_files .append (str (filepath ))
7879
7980 return created_files
8081
0 commit comments