构建使用基础镜像
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
 
 
 

44 lines
1.2 KiB

import k8s
import harbor
import os
import argparse
argparser = argparse.ArgumentParser()
argparser.description = '输入一个参数,--is_first '
argparser.add_argument('-f', '--is_first', dest='is_first', default=False, help='是否是第一次执行')
ns_list = ['anxinyun']
def first_get_all():
for ns in ns_list:
image_list = k8s.list_deployment(ns)
out_file(image_list)
def out_file(image_list):
image_url_list = list(
map(lambda i: "repository.anxinyun.cn/{}/{}:{}".format(i['project'], i['name'], i['tag']), image_list))
if os.path.exists('images.txt'):
os.remove("images.txt")
with open("images.txt", "a") as file:
file.writelines(s + '\n' for s in image_url_list)
def get_latest_images():
pre_image_list = []
for ns in ns_list:
image_list = k8s.list_deployment(ns)
for image in image_list:
tag = harbor.get_image_latest_tag(image['project'], image['name'])
if tag != image['tag']:
pre_image_list.append(image)
out_file(pre_image_list)
if __name__ == '__main__':
args = argparser.parse_args()
if args.is_first:
first_get_all()
else:
get_latest_images()