1717import sys
1818
1919
20- def convert_certified_images_to_text (json_file : str , output_file : str ):
20+ def convert_certified_images_to_text (json_file : str , output_file : str ):
2121 """
2222 Convert certified_images.json to text format expected by update_images.py
2323
2424 Args:
2525 json_file: Path to certified_images.json from Phase 2
2626 output_file: Path to output text file
2727 """
28- with open (json_file , 'r' , encoding = ' utf-8' ) as f :
28+ with open (json_file , "r" , encoding = " utf-8" ) as f :
2929 data = json .load (f )
3030
3131 lines = []
3232 skipped = []
3333
34- for img in data [' certified_images' ]:
34+ for img in data [" certified_images" ]:
3535 # Skip failed or pending certifications
36- if img [' certification_status' ] != ' success' :
36+ if img [" certification_status" ] != " success" :
3737 skipped .append (f"{ img ['name' ]} - Status: { img ['certification_status' ]} " )
3838 continue
3939
4040 # Extract components
41- name = img [' name' ]
42- version = img [' version' ]
43- sha256 = img [' sha256' ]
41+ name = img [" name" ]
42+ version = img [" version" ]
43+ sha256 = img [" sha256" ]
4444
4545 # Validate required fields
4646 if not name or not version or not sha256 :
@@ -53,7 +53,7 @@ def convert_certified_images_to_text(json_file: str, output_file: str):
5353
5454 # Line 2: registry.connect.redhat.com/sumologic/{name}:@{sha256}
5555 # Remove 'sha256:' prefix if present
56- sha256_clean = sha256 .replace (' sha256:' , '' )
56+ sha256_clean = sha256 .replace (" sha256:" , "" )
5757 image_with_sha = f"registry.connect.redhat.com/sumologic/{ name } :@sha256:{ sha256_clean } "
5858
5959 lines .append (image_with_tag )
@@ -63,13 +63,13 @@ def convert_certified_images_to_text(json_file: str, output_file: str):
6363 if skipped :
6464 print ("⚠️ Skipped images:" , file = sys .stderr )
6565 for skip in skipped :
66- print (f" - { skip } " , file = sys . stderr )
66+ print (f" - { skip } " , file = sys .stderr )
6767
6868 # Write to output file
69- with open (output_file , 'w' , encoding = ' utf-8' ) as f :
70- f .write (' \n ' . join (lines ))
69+ with open (output_file , "w" , encoding = " utf-8" ) as f :
70+ f .write (" \n " . join (lines ))
7171 if lines : # Add final newline only if there's content
72- f .write (' \n ' )
72+ f .write (" \n " )
7373
7474 print (f"✅ Converted { len (lines )// 2 } images to { output_file } " )
7575
@@ -79,23 +79,13 @@ def convert_certified_images_to_text(json_file: str, output_file: str):
7979
8080def parse_args ():
8181 """Parse command line arguments"""
82- parser = argparse .ArgumentParser (
83- description = 'Convert certified_images.json to update_images.py format'
84- )
85- parser .add_argument (
86- '--input' ,
87- required = True ,
88- help = 'Path to certified_images.json'
89- )
90- parser .add_argument (
91- '--output' ,
92- default = 'images.txt' ,
93- help = 'Path to output file (default: images.txt)'
94- )
82+ parser = argparse .ArgumentParser (description = "Convert certified_images.json to update_images.py format" )
83+ parser .add_argument ("--input" , required = True , help = "Path to certified_images.json" )
84+ parser .add_argument ("--output" , default = "images.txt" , help = "Path to output file (default: images.txt)" )
9585 return parser .parse_args ()
9686
9787
98- if __name__ == ' __main__' :
88+ if __name__ == " __main__" :
9989 args = parse_args ()
10090 count = convert_certified_images_to_text (args .input , args .output )
10191
0 commit comments