Skip to content

Commit 08b3716

Browse files
committed
CH-169 implement application build exclusion based on image param
1 parent 5bd4b73 commit 08b3716

3 files changed

Lines changed: 13 additions & 4 deletions

File tree

tools/deployment-cli-tools/ch_cli_tools/codefresh.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,9 @@ def codefresh_steps_from_base_path(base_path, build_step, fixed_context=None, in
173173
# Skip excluded apps
174174
continue
175175

176+
if app_config and not helm_values.apps[app_key].get('build', True):
177+
continue
178+
176179
if app_config and app_config.dependencies and app_config.dependencies.git:
177180
for dep in app_config.dependencies.git:
178181
step_name = f"clone_{basename(dep.url).replace('.', '_')}_{basename(dockerfile_relative_to_root).replace('.', '_')}"

tools/deployment-cli-tools/ch_cli_tools/helm.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,13 +190,15 @@ def create_app_values_spec(self, app_name, app_path, base_image_name=None, helm_
190190
else:
191191
build_dependencies = []
192192

193-
if len(image_paths) > 0:
193+
deployment_values = values[KEY_HARNESS].get(KEY_DEPLOYMENT, {})
194+
deployment_image = deployment_values.get('image', None) or values.get('image', None)
195+
values['build'] = not bool(deployment_image) # Used by skaffold and ci/cd to determine if the image should be built
196+
if len(image_paths) > 0 and not deployment_image:
194197
image_name = image_name_from_dockerfile_path(os.path.relpath(
195198
image_paths[0], os.path.dirname(app_path)), base_image_name)
196-
197-
values['image'] = self.image_tag(
199+
deployment_values['image'] = self.image_tag(
198200
image_name, build_context_path=app_path, dependencies=build_dependencies)
199-
elif KEY_HARNESS in values and not values[KEY_HARNESS].get(KEY_DEPLOYMENT, {}).get('image', None) and values[
201+
elif KEY_HARNESS in values and not deployment_image and values[
200202
KEY_HARNESS].get(KEY_DEPLOYMENT, {}).get('auto', False):
201203
raise Exception(f"At least one Dockerfile must be specified on application {app_name}. "
202204
f"Specify harness.deployment.image value if you intend to use a prebuilt image.")

tools/deployment-cli-tools/ch_cli_tools/skaffold.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ def process_build_dockerfile(
8181
if app_name is None:
8282
app_name = app_name_from_path(basename(dockerfile_path))
8383
app_key = app_name.replace("-", "_")
84+
if app_key in helm_values.apps and not helm_values.apps[app_key]['build']:
85+
return
8486
if app_name in helm_values[KEY_TASK_IMAGES] or app_key in helm_values.apps:
8587
context_path = relpath_if(root_path, output_path) if global_context else relpath_if(dockerfile_path, output_path)
8688

@@ -157,6 +159,8 @@ def process_build_dockerfile(
157159
# app_image_tag, app_relative_to_skaffold, build_requirements)
158160
process_build_dockerfile(dockerfile_path, root_path, requirements=build_requirements, app_name=app_name)
159161
app = apps[app_key]
162+
if not app['build']:
163+
continue
160164
if app[KEY_HARNESS][KEY_DEPLOYMENT]['image']:
161165
release_config['artifactOverrides']['apps'][app_key] = \
162166
{

0 commit comments

Comments
 (0)