search updates for base images

master
Clemens Klug 2018-08-06 12:51:17 +02:00
parent c490a0ffcc
commit cef99ba62a
2 changed files with 24 additions and 9 deletions

View File

@ -41,7 +41,7 @@ def parse_dockerfile(build):
return [f] return [f]
keyword = "FROM" keyword = "FROM"
with open(path, "r") as src: with open(path, "r") as src:
sources = [source_to_image(line) for line in src if line.strip().startswith(keyword)] sources = [source_to_image(line) for line in src if line.strip().startswith(keyword)] # TODO lower/upper
return sources return sources
def image_info(image): def image_info(image):

View File

@ -5,6 +5,16 @@ import docker_compose
import image_tags import image_tags
def find_updates(image_ref):
try:
newer_tags = image_tags.get_new_tags(image_ref)
except ValueError as e:
newer_tags = e.args
return {
"updates": newer_tags,
"usages": images[image][tag],
}
def main(args): def main(args):
@ -13,14 +23,19 @@ def main(args):
for image in images: for image in images:
for tag in images[image]: for tag in images[image]:
image_ref = f"{image}:{tag}" image_ref = f"{image}:{tag}"
try: if image_ref in updates:
newer_tags = image_tags.get_new_tags(image_ref) continue
except ValueError as e: updates[image_ref] = find_updates(image_ref)
newer_tags = e.args for usage in images[image][tag:
updates[image_ref] = { if "base_image" in usage:
"updates": newer_tags, continue
"usages": images[image][tag] for base in usage["base_image"]:
} if base in updates:
continue
else:
updates[base] = find_updates(base)
if args.output: if args.output:
with open(args.output, "w") as out: with open(args.output, "w") as out:
json.dump(updates, out, indent=1, sort_keys=True) json.dump(updates, out, indent=1, sort_keys=True)