mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-11-30 02:48:45 +08:00
[skip e2e] Delete unused code on update file (#14286)
Signed-off-by: wangting0128 <ting.wang@zilliz.com>
This commit is contained in:
parent
4a382d98f0
commit
6c1708d88e
@ -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"}
|
||||
|
Loading…
Reference in New Issue
Block a user