1717
1818
1919@click .group ()
20- def image ():
20+ def image () -> None :
2121 """Commands for working with connector Docker images."""
2222 pass
2323
2424
2525@image .command ()
26- @click .argument ("connector_dir" , type = click .Path (exists = True , file_okay = False , dir_okay = True , path_type = Path ))
27- @click .option (
28- "--tag" ,
29- default = "dev" ,
30- help = "Tag to apply to the built image (default: dev)"
26+ @click .argument (
27+ "connector_dir" , type = click .Path (exists = True , file_okay = False , dir_okay = True , path_type = Path )
3128)
29+ @click .option ("--tag" , default = "dev" , help = "Tag to apply to the built image (default: dev)" )
3230@click .option (
3331 "--platform" ,
3432 type = click .Choice (["linux/amd64" , "linux/arm64" ]),
3533 default = "linux/amd64" ,
3634 help = "Platform to build for (default: linux/amd64)" ,
3735)
38- @click .option (
39- "--no-verify" ,
40- is_flag = True ,
41- help = "Skip verification of the built image"
42- )
43- @click .option (
44- "--verbose" , "-v" ,
45- is_flag = True ,
46- help = "Enable verbose logging"
47- )
48- def build (connector_dir , tag , platform , no_verify , verbose ):
36+ @click .option ("--no-verify" , is_flag = True , help = "Skip verification of the built image" )
37+ @click .option ("--verbose" , "-v" , is_flag = True , help = "Enable verbose logging" )
38+ def build (connector_dir : Path , tag : str , platform : str , no_verify : bool , verbose : bool ) -> None :
4939 """Build a connector Docker image.
5040
5141 This command builds a Docker image for a connector, using either
5242 the connector's Dockerfile or a base image specified in the metadata.
5343 """
5444 set_up_logging (verbose )
55-
45+
5646 if not verify_docker_installation ():
57- click .echo ("Docker is not installed or not running. Please install Docker and try again." , err = True )
47+ click .echo (
48+ "Docker is not installed or not running. Please install Docker and try again." , err = True
49+ )
5850 sys .exit (1 )
59-
51+
6052 try :
6153 metadata = read_metadata (connector_dir )
6254 click .echo (f"Connector: { metadata .dockerRepository } " )
6355 click .echo (f"Version: { metadata .dockerImageTag } " )
64-
56+
6557 language = infer_connector_language (metadata , connector_dir )
6658 click .echo (f"Detected connector language: { language } " )
67-
59+
6860 if metadata .connectorBuildOptions and metadata .connectorBuildOptions .baseImage :
6961 image_name = build_from_base_image (connector_dir , metadata , tag , platform )
7062 else :
7163 image_name = build_from_dockerfile (connector_dir , metadata , tag , platform )
72-
64+
7365 if not no_verify :
7466 if verify_image (image_name ):
7567 click .echo (f"Build completed successfully: { image_name } " )
@@ -80,10 +72,11 @@ def build(connector_dir, tag, platform, no_verify, verbose):
8072 else :
8173 click .echo (f"Build completed successfully (without verification): { image_name } " )
8274 sys .exit (0 )
83-
75+
8476 except Exception as e :
8577 click .echo (f"Error: { str (e )} " , err = True )
8678 if verbose :
8779 import traceback
80+
8881 click .echo (traceback .format_exc (), err = True )
8982 sys .exit (1 )
0 commit comments