[skip e2e] Delete unused code on update file (#14286)

Signed-off-by: wangting0128 <ting.wang@zilliz.com>
This commit is contained in:
wt 2021-12-27 15:17:35 +08:00 committed by GitHub
parent 4a382d98f0
commit 6c1708d88e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -10,100 +10,6 @@ import requests
import json
def get_token(url):
""" get the request token and return the value """
rep = requests.get(url)
data = json.loads(rep.text)
if 'token' in data:
token = data['token']
else:
token = ''
print("Can not get token.")
return token
def get_tags(url, token):
headers = {'Content-type': "application/json",
"charset": "UTF-8",
"Accept": "application/vnd.docker.distribution.manifest.v2+json",
"Authorization": "Bearer %s" % token}
try:
rep = requests.get(url, headers=headers)
data = json.loads(rep.text)
tags = []
if 'tags' in data:
tags = data["tags"]
else:
print("Can not get the tag list")
return tags
except:
print("Can not get the tag list")
return []
def get_master_tags(tags_list):
_list = []
tag_name = "master"
if not isinstance(tags_list, list):
print("tags_list is not a list.")
return _list
for tag in tags_list:
if tag_name in tag and tag != tag_name + "-latest":
_list.append(tag)
return _list
def get_config_digest(url, token):
headers = {'Content-type': "application/json",
"charset": "UTF-8",
"Accept": "application/vnd.docker.distribution.manifest.v2+json",
"Authorization": "Bearer %s" % token}
try:
rep = requests.get(url, headers=headers)
data = json.loads(rep.text)
digest = ''
if 'config' in data and 'digest' in data["config"]:
digest = data["config"]["digest"]
else:
print("Can not get the digest")
return digest
except:
print("Can not get the digest")
return ""
def get_latest_tag(limit=200):
""" get the latest tag of master """
auth_url = ""
tags_url = ""
tag_url = ""
master_latest = "master-latest"
master_latest_digest = get_config_digest(tag_url + master_latest, get_token(auth_url))
tags = get_tags(tags_url, get_token(auth_url))
tag_list = get_master_tags(tags)
latest_tag = ""
for i in range(1, len(tag_list) + 1):
tag_name = str(tag_list[-i])
tag_digest = get_config_digest(tag_url + tag_name, get_token(auth_url))
if tag_digest == master_latest_digest:
latest_tag = tag_name
break
if i > limit:
break
if latest_tag == "":
raise print("Can't find the latest image name")
print("The image name used is %s" % str(latest_tag))
return latest_tag
def get_image_tag():
url = ""
headers = {"accept": "application/json"}