SYNC
This commit is contained in:
parent
1e5d20d10b
commit
0729c1729b
|
@ -1,12 +1,12 @@
|
|||
import os
|
||||
|
||||
REPO_REPLACE_RULE = {
|
||||
"gcr.io":"gcr-jp.m.daocloud.io",
|
||||
"k8s.gcr.io":"k8s-gcr-jp.m.daocloud.io",
|
||||
"docker.io":"docker-jp.m.daocloud.io",
|
||||
"quay.io":"quay-jp.m.daocloud.io",
|
||||
"ghcr.io":"ghcr-jp.m.daocloud.io",
|
||||
"gcr.io":"gcr-jp.m.daocloud.io",
|
||||
"docker.io":"docker-jp.m.daocloud.io",
|
||||
"quay.io":"quay-jp.m.daocloud.io",
|
||||
"ghcr.io":"ghcr-jp.m.daocloud.io",
|
||||
}
|
||||
# "k8s.gcr.io":"k8s-gcr-jp.m.daocloud.io",
|
||||
|
||||
|
||||
REGISTRY_PASSWORD = os.environ["REGISTRY_PASSWORD"]
|
||||
|
@ -16,23 +16,26 @@ SKEPO_CMD = "docker run -it quay.io/containers/skopeo:latest"
|
|||
# SKEPO_CMD = "skepo" # RUN without docker
|
||||
|
||||
def skepo_sync_cmd(src_img):
|
||||
src_img = src_img.strip()
|
||||
dest_img = "/".join(src_img.split("/")[:-1])
|
||||
cmd = SKEPO_CMD + " sync --src docker --dest %s --dest-tls-verify=false --dest-creds root:%s -f oci %s" %(src_img,REGISTRY_PASSWORD,dest_img)
|
||||
# print(src_img)
|
||||
# print(dest_img)
|
||||
# print(cmd)
|
||||
return cmd
|
||||
src_img = src_img.strip()
|
||||
dest_img = "/".join(src_img.split("/")[:-1])
|
||||
for k,v in REPO_REPLACE_RULE.items():
|
||||
dest_img = dest_img.replace(k,v)
|
||||
cmd = SKEPO_CMD + " sync --src docker --dest docker --dest-tls-verify=false --dest-creds root:%s -f oci %s %s" %(REGISTRY_PASSWORD,src_img,dest_img)
|
||||
# print(src_img)
|
||||
# print(dest_img)
|
||||
# print(cmd)
|
||||
return cmd
|
||||
|
||||
def main():
|
||||
lines = []
|
||||
with open("mirror.txt") as f:
|
||||
lines = f.readlines()
|
||||
sync_cmds = []
|
||||
for l in lines:
|
||||
sync_cmds.append(skepo_sync_cmd(l))
|
||||
for c in sync_cmds:
|
||||
os.system(c)
|
||||
lines = []
|
||||
with open("mirror.txt") as f:
|
||||
lines = f.readlines()
|
||||
sync_cmds = []
|
||||
for l in lines:
|
||||
sync_cmds.append(skepo_sync_cmd(l))
|
||||
for c in sync_cmds:
|
||||
print(c)
|
||||
os.system(c)
|
||||
|
||||
if __name__ == "__main__":
|
||||
# execute only if run as a script
|
||||
|
|
Loading…
Reference in New Issue