1111from .models import HarnessMainConfig , ApplicationTestConfig , ApplicationHarnessConfig
1212from cloudharness_utils .constants import *
1313from .helm import KEY_APPS , KEY_TASK_IMAGES , KEY_TEST_IMAGES , generate_tag_from_content
14- from .utils import find_dockerfiles_paths , get_app_relative_to_base_path , guess_build_dependencies_from_dockerfile , \
14+ from .utils import check_docker_manifest_exists , find_dockerfiles_paths , get_app_relative_to_base_path , guess_build_dependencies_from_dockerfile , \
1515 get_image_name , get_template , dict_merge , app_name_from_path , clean_path
1616from cloudharness_utils .testing .api import get_api_filename , get_schemathesis_command , get_urls_from_api_file
1717
@@ -33,7 +33,7 @@ def literal_presenter(dumper, data):
3333
3434yaml .add_representer (str , literal_presenter )
3535
36- def write_env_file (helm_values : HarnessMainConfig , filename ):
36+ def write_env_file (helm_values : HarnessMainConfig , filename , registry_secret = None ):
3737 env = {}
3838 logging .info ("Create env file with image info %s" , filename )
3939
@@ -45,14 +45,15 @@ def check_image_exists(name, image):
4545 chunks = image .split (":" )[0 ].split ("/" )
4646 registry = chunks [0 ] if "." in chunks [0 ] else "docker.io"
4747 image_name = "/" .join (chunks [1 ::] if "." in chunks [0 ] else chunks [0 ::])
48- api_url = f"https://{ registry } /v2/{ image_name } /manifests/{ tag } "
49- resp = requests .get (api_url )
50- if resp .status_code == 200 :
48+ exists = check_docker_manifest_exists (registry , image_name , tag , registry_secret = registry_secret )
49+ if exists :
5150 # TODO the hash might be the same but not the parent's hash
5251 env [app_specific_tag_variable (name ) + "_EXISTS" ] = 1
5352 else :
5453 env [app_specific_tag_variable (name ) + "_NEW" ] = 1
5554
55+
56+
5657 for app in helm_values .apps .values ():
5758 if app .harness and app .harness .deployment .image :
5859 env [app_specific_tag_variable (app .name )] = extract_tag (app .harness .deployment .image )
0 commit comments