@@ -150,7 +150,6 @@ def build_docker_image_from_base_image(args, verbose=True) -> tuple[int, str]:
150150 return return_code , cloud_docker_image
151151
152152
153-
154153# def setup_docker_image(args) -> tuple[int, str]:
155154# """Does steps to verify docker args, check image, and build image (if asked).
156155
@@ -223,39 +222,42 @@ def setup_docker_image(args) -> tuple[int, str]:
223222 Name of the docker image to use.
224223 """
225224
226- docker_image = args .docker_image
227- if not docker_image or docker_image == DEFAULT_DOCKER_IMAGE :
228- docker_image = args .base_docker_image # fallback for legacy users
229-
230- if not docker_image or docker_image == DEFAULT_DOCKER_IMAGE :
231- xpk_print ("Error: No docker image specified. Please provide --docker-image." )
232- xpk_exit (1 )
233-
234- cloud_prefixes = [
235- "gcr.io" , "docker.pkg.dev" , "us-docker.pkg.dev"
236- ]
237- is_cloud_image = any (docker_image .startswith (prefix ) for prefix in cloud_prefixes )
238-
239- if is_cloud_image :
240- if args .script_dir is not DEFAULT_SCRIPT_DIR :
241- xpk_print (
242- "Error: `--script-dir` cannot be used with a cloud docker image.\n "
243- "Hint: If you need to customize the image with local scripts, "
244- "use a local base image (e.g., `ubuntu:20.04`) instead of a prebuilt cloud image."
245- )
246- xpk_exit (1 )
247-
248- validate_code = validate_docker_image (docker_image , args )
249- if validate_code != 0 :
250- xpk_exit (validate_code )
251-
252- else :
253- validate_code = validate_docker_image (docker_image , args )
254- if validate_code != 0 :
255- xpk_exit (validate_code )
256-
257- build_code , docker_image = build_docker_image_from_base_image (args )
258- if build_code != 0 :
259- xpk_exit (build_code )
260-
261- return 0 , docker_image
225+ docker_image = args .docker_image
226+ if not docker_image or docker_image == DEFAULT_DOCKER_IMAGE :
227+ docker_image = args .base_docker_image # fallback for legacy users
228+
229+ if not docker_image or docker_image == DEFAULT_DOCKER_IMAGE :
230+ xpk_print (
231+ 'Error: No docker image specified. Please provide --docker-image.'
232+ )
233+ xpk_exit (1 )
234+
235+ cloud_prefixes = ['gcr.io' , 'docker.pkg.dev' , 'us-docker.pkg.dev' ]
236+ is_cloud_image = any (
237+ docker_image .startswith (prefix ) for prefix in cloud_prefixes
238+ )
239+
240+ if is_cloud_image :
241+ if args .script_dir is not DEFAULT_SCRIPT_DIR :
242+ xpk_print (
243+ 'Error: `--script-dir` cannot be used with a cloud docker'
244+ ' image.\n Hint: If you need to customize the image with local'
245+ ' scripts, use a local base image (e.g., `ubuntu:20.04`) instead of a'
246+ ' prebuilt cloud image.'
247+ )
248+ xpk_exit (1 )
249+
250+ validate_code = validate_docker_image (docker_image , args )
251+ if validate_code != 0 :
252+ xpk_exit (validate_code )
253+
254+ else :
255+ validate_code = validate_docker_image (docker_image , args )
256+ if validate_code != 0 :
257+ xpk_exit (validate_code )
258+
259+ build_code , docker_image = build_docker_image_from_base_image (args )
260+ if build_code != 0 :
261+ xpk_exit (build_code )
262+
263+ return 0 , docker_image
0 commit comments