1313
1414import click
1515
16- from airbyte_cdk .models .connector_metadata import MetadataFile
16+ from airbyte_cdk .models .connector_metadata import ConnectorLanguage , MetadataFile
1717from airbyte_cdk .utils .docker_image_templates import (
1818 DOCKERIGNORE_TEMPLATE ,
1919 MANIFEST_ONLY_DOCKERFILE_TEMPLATE ,
@@ -88,6 +88,7 @@ def _build_image(
8888 try :
8989 run_docker_command (
9090 docker_args ,
91+ check = True ,
9192 )
9293 except subprocess .CalledProcessError as e :
9394 raise ConnectorImageBuildError (
@@ -105,6 +106,9 @@ def _tag_image(
105106 """Build a Docker image for the specified architecture.
106107
107108 Returns the tag of the built image.
109+
110+ Raises:
111+ ConnectorImageBuildError: If the docker tag command fails.
108112 """
109113 if not isinstance (new_tags , list ):
110114 new_tags = [new_tags ]
@@ -117,11 +121,16 @@ def _tag_image(
117121 tag ,
118122 new_tag ,
119123 ]
120- _ = subprocess .run (
121- docker_args ,
122- text = True ,
123- check = True ,
124- )
124+ try :
125+ run_docker_command (
126+ docker_args ,
127+ check = True ,
128+ )
129+ except subprocess .CalledProcessError as e :
130+ raise ConnectorImageBuildError (
131+ error_text = e .stderr ,
132+ build_args = docker_args ,
133+ ) from e
125134
126135
127136def build_connector_image (
@@ -150,7 +159,7 @@ def build_connector_image(
150159
151160 Raises:
152161 ValueError: If the connector build options are not defined in metadata.yaml.
153- ConnectorImageBuildError: If the build fails.
162+ ConnectorImageBuildError: If the image build or tag operation fails.
154163 """
155164 connector_kebab_name = connector_name
156165 connector_snake_name = connector_kebab_name .replace ("-" , "_" )
@@ -228,13 +237,13 @@ def get_dockerfile_template(
228237 Returns:
229238 The Dockerfile template as a string.
230239 """
231- if metadata .data .language == "python" :
240+ if metadata .data .language == ConnectorLanguage . PYTHON :
232241 return PYTHON_CONNECTOR_DOCKERFILE_TEMPLATE
233242
234- if metadata .data .language == "manifest-only" :
243+ if metadata .data .language == ConnectorLanguage . MANIFEST_ONLY :
235244 return MANIFEST_ONLY_DOCKERFILE_TEMPLATE
236245
237- if metadata .data .language == "java" :
246+ if metadata .data .language == ConnectorLanguage . JAVA :
238247 raise ValueError (
239248 f"Java and Kotlin connectors are not yet supported. "
240249 "Please use airbyte-ci or gradle to build your image."
@@ -269,7 +278,7 @@ def run_docker_command(
269278 process = subprocess .run (
270279 cmd ,
271280 text = True ,
272- check = True ,
281+ check = check ,
273282 # If capture_output=True, stderr and stdout are captured and returned to caller:
274283 capture_output = capture_output ,
275284 env = {** os .environ , "DOCKER_BUILDKIT" : "1" },
0 commit comments