@@ -199,72 +199,32 @@ def is_running_in_evg_pipeline():
199199class MissingEnvironmentVariable (Exception ):
200200 pass
201201
202-
203- # Deprecated: do not use pin_tag_at parameter, this was used to pin the image tag to a specific time,
204- # but resulted in overwritten image tags which causes quay to garbage collect
205- # untagged images. This caused a release image to be missing.
206- def should_pin_at () -> Optional [Tuple [str , str ]]:
207- """Gets the value of the pin_tag_at to tag the images with.
208-
209- Returns its value split on :.
210- """
211- # We need to return something so `partition` does not raise
212- # AttributeError
213- is_patch = is_running_in_patch ()
214-
215- try :
216- pinned = os .environ ["pin_tag_at" ]
217- except KeyError :
218- raise MissingEnvironmentVariable (f"pin_tag_at environment variable does not exist, but is required" )
219- if is_patch :
220- if pinned == "00:00" :
221- raise Exception ("Pinning to midnight during a patch is not supported. Please pin to another date!" )
222-
223- hour , _ , minute = pinned .partition (":" )
224- return hour , minute
225-
226-
227202def is_running_in_patch ():
228203 is_patch = os .environ .get ("is_patch" )
229204 return is_patch is not None and is_patch .lower () == "true"
230205
231206
232207def build_id () -> str :
233- """Returns the current UTC time in ISO8601 date format.
234-
235- If running in Evergreen and `created_at` expansion is defined, use the
236- datetime defined in that variable instead.
237-
238- It is possible to pin this time at midnight (00:00) for periodic builds. If
239- running a manual build, then the Evergreen `pin_tag_at` variable needs to be
240- set to the empty string, in which case, the image tag suffix will correspond
241- to the current timestamp.
242-
208+ """Returns the build id used for the image tag.
209+ The build id is configurable `build_tag_type` and `version_id` in evergreen.
243210 """
244211
212+ build_tag_type = ""
245213 try :
246214 build_tag_type = os .environ ["build_tag_type" ]
247215 except KeyError :
248216 pass
249217
250- date = datetime . now ( timezone . utc )
218+ version_id = ""
251219 try :
252- created_at = os .environ ["created_at" ]
253- date = datetime .strptime (created_at , "%y_%m_%d_%H_%M_%S" )
220+ version_id = os .environ ["version_id" ]
254221 except KeyError :
255- pass
222+ raise MissingEnvironmentVariable ( "Missing environment variable `version_id`" )
256223
257- # Deprecated: do not use should_pin_at(). Use the suffix instead.
258- hour , minute = should_pin_at ()
259- if hour and minute :
260- logger .info (f"we are pinning to, hour: { hour } , minute: { minute } " )
261- date = date .replace (hour = int (hour ), minute = int (minute ), second = 0 )
224+ if build_tag_type == "" :
225+ return version_id
262226 else :
263- logger .warning (f"hour and minute cannot be extracted from provided pin_tag_at env, pinning to now" )
264-
265- string_time = date .strftime ("%Y%m%dT%H%M%SZ" )
266-
267- return f"{ string_time } -{ build_tag_type } "
227+ return f"{ version_id } -{ build_tag_type } "
268228
269229
270230def get_release () -> Dict :
0 commit comments