@@ -87,53 +87,6 @@ def _add_default_tag_to_tags(config: Union[str, dict], default_tag: str) -> dict
8787 return config
8888
8989
90- def _get_step_tag (default_tag : str , step_name : str , max_length : int = 128 ) -> str :
91- """
92- Get a step-specific tag from a default tag and step name.
93-
94- This function creates unique tags per build step by appending the step name to
95- the default tag. This is necessary when multiple build steps push to the same
96- Docker repository, as it prevents tag collisions (multiple build steps using the same default tag).
97-
98- Args:
99- default_tag: The base default tag (typically a build ID or timestamp)
100- step_name: The name of the build step (e.g., "build-java17")
101- max_length: Maximum allowed tag length (default: 128, Docker image tag name character limit)
102-
103- Returns:
104- A step-specific tag in the format "{default_tag}-{step_name}".
105- If the resulting tag exceeds max_length, the default_tag is truncated
106- to fit while preserving the step_name suffix.
107- """
108- # Create step-specific tag by appending step name to default tag
109- step_tag = f"{ default_tag } -{ step_name } "
110-
111- # If tag is within length limit, return as-is
112- if len (step_tag ) <= max_length :
113- return step_tag
114-
115- # Tag exceeds Docker's maximum length limit (typically 128 characters)
116- # Truncate the default_tag portion while preserving the step_name suffix
117- # This ensures the step name is always included for uniqueness
118- LOGGER .info (
119- f"Step tag { step_tag } is too long, truncating default tag by length of step name"
120- )
121-
122- step_suffix = f"-{ step_name } "
123-
124- # If the step suffix is too long, truncate it
125- if len (step_suffix ) > max_length :
126- step_suffix = step_suffix [:max_length ]
127-
128- # Calculate how much space we have for the default_tag portion
129- available_space = max_length - len (step_suffix )
130- step_tag = f"{ default_tag [:available_space ]} { step_suffix } "
131-
132- LOGGER .info (f"Truncated step tag: { step_tag } " )
133-
134- return step_tag
135-
136-
13790def _set_default_tag (config : dict , default_tag : str ) -> dict :
13891 """
13992 Set default tag if not set for each image
@@ -149,20 +102,18 @@ def _set_default_tag(config: dict, default_tag: str) -> dict:
149102 if not isinstance (steps , dict ):
150103 return config
151104 for step_name , step in steps .items ():
152- step_tag = _get_step_tag (default_tag , step_name )
153-
154105 for substep_name , substep in step .items ():
155106 if substep_name in ["push" , "commit" ]:
156107 # Add default tag to tags list if not in the list
157108 if isinstance (substep , list ):
158109 curr_image_infos = []
159110 for push_config in substep :
160111 curr_image_infos .append (
161- _add_default_tag_to_tags (push_config , step_tag )
112+ _add_default_tag_to_tags (push_config , default_tag )
162113 )
163114 config ["steps" ][step_name ][substep_name ] = curr_image_infos
164115 else :
165- curr_image_info = _add_default_tag_to_tags (substep , step_tag )
116+ curr_image_info = _add_default_tag_to_tags (substep , default_tag )
166117 config ["steps" ][step_name ][substep_name ] = curr_image_info
167118 return config
168119
0 commit comments