mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-02 03:48:37 +08:00
[skip e2e]Add python script to get image tag name (#26911)
Signed-off-by: zhuwenxing <wenxing.zhu@zilliz.com>
This commit is contained in:
parent
2a755baaa5
commit
e2528030bb
33
tests/scripts/get_image_tag_by_short_name.py
Normal file
33
tests/scripts/get_image_tag_by_short_name.py
Normal file
@ -0,0 +1,33 @@
|
||||
import requests
|
||||
import argparse
|
||||
|
||||
def get_image_tag_by_short_name(repository, tag):
|
||||
|
||||
# Send API request to get all tags
|
||||
url = f"https://hub.docker.com/v2/repositories/{repository}/tags"
|
||||
response = requests.get(url)
|
||||
data = response.json()
|
||||
# Get the DIGEST of the "master-latest" tag
|
||||
digest = ""
|
||||
for tag_info in data["results"]:
|
||||
if tag_info["name"] == tag:
|
||||
digest = tag_info["images"][0]["digest"]
|
||||
break
|
||||
res = []
|
||||
# Iterate through all tags and find the ones with the same DIGEST
|
||||
for tag_info in data["results"]:
|
||||
if "digest" in tag_info["images"][0] and tag_info["images"][0]["digest"] == digest:
|
||||
# Extract the image name
|
||||
image_name = tag_info["name"].split(":")[0]
|
||||
if image_name != tag:
|
||||
res.append(image_name)
|
||||
assert len(res) > 0
|
||||
return res[0]
|
||||
|
||||
if __name__ == "__main__":
|
||||
argparse = argparse.ArgumentParser()
|
||||
argparse.add_argument("--repository", type=str, default="milvusdb/milvus")
|
||||
argparse.add_argument("--tag", type=str, default="master-latest")
|
||||
args = argparse.parse_args()
|
||||
res = get_image_tag_by_short_name(args.repository, args.tag)
|
||||
print(res)
|
Loading…
Reference in New Issue
Block a user