Skip to content

Commit 7927fc6

Browse files
committed
cmd-cloud-prune: Refactor build parsing logic and remove unused vars
1 parent 9708ec5 commit 7927fc6

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

src/cmd-cloud-prune

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ from cosalib.gcp import remove_gcp_image
4949
from cosalib.aws import deregister_aws_resource
5050
from cosalib.builds import BUILDFILES
5151
from cosalib.s3 import s3_copy
52-
from cosalib.cmdlib import parse_fcos_version_to_timestamp_and_stream
52+
from cosalib.cmdlib import parse_fcos_version_to_timestamp
5353
from cosalib.cmdlib import convert_duration_to_days
5454

5555
Build = collections.namedtuple("Build", ["id", "images", "arch", "meta_json"])
@@ -61,8 +61,6 @@ CACHE_MAX_AGE_METADATA = 60 * 5
6161
# is up to date.
6262
SUPPORTED = ["amis", "gcp"]
6363
UNSUPPORTED = ["aliyun", "azure", "ibmcloud", "powervs"]
64-
# list of known streams with containers
65-
STREAMS = {"next", "testing", "stable", "next-devel", "testing-devel", "rawhide", "branched"}
6664

6765

6866
def parse_args():
@@ -126,7 +124,7 @@ def main():
126124
# Iterate through builds from oldest to newest
127125
for build in reversed(builds):
128126
build_id = build["id"]
129-
build_date, _ = parse_fcos_version_to_timestamp_and_stream(build_id)
127+
build_date = parse_fcos_version_to_timestamp(build_id)
130128

131129
# For each build, iterate over arches first to minimize downloads of meta.json per arch
132130
for arch in build["arches"]:

src/cosalib/cmdlib.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ def get_basearch():
339339
return get_basearch.saved
340340

341341

342-
def parse_fcos_version_to_timestamp_and_stream(version):
342+
def parse_fcos_version_to_timestamp(version):
343343
'''
344344
Parses an FCOS build ID and verifies the versioning is accurate. Then
345345
it verifies that the parsed timestamp has %Y%m%d format and returns that.
@@ -351,7 +351,7 @@ def parse_fcos_version_to_timestamp_and_stream(version):
351351
timestamp = datetime.datetime.strptime(m.group(2), '%Y%m%d')
352352
except ValueError:
353353
raise Exception(f"FCOS build {version} has incorrect date format. It should be in (%Y%m%d)")
354-
return (timestamp, m.group(3))
354+
return timestamp
355355

356356

357357
def convert_duration_to_days(duration_arg):

0 commit comments

Comments
 (0)