blob: 7f1eeb545397c9f90b2e401bcf4b1231a5abcfa2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
#!/usr/bin/python3
import sys
if sys.version_info[0] >= 3:
import http.client as http_client
import urllib.parse as urllib_parse
else:
import http.client as http_client
import urllib as urllib_parse
if sys.argv[2] == 'add':
detach_icons = '--detach-icons' in sys.argv
if detach_icons:
sys.argv.remove('--detach-icons')
params = {'d': sys.argv[5]}
if detach_icons:
params['detach-icons'] = 1
query = urllib_parse.urlencode(params)
conn = http_client.HTTPConnection(sys.argv[1])
path = "/testing/{repo}/{tag}?{query}".format(repo=sys.argv[3],
tag=sys.argv[4],
query=query)
conn.request("POST", path)
response = conn.getresponse()
if response.status != 200:
print(response.read(), file=sys.stderr)
print("Failed: status={}".format(response.status), file=sys.stderr)
sys.exit(1)
elif sys.argv[2] == 'delete':
conn = http_client.HTTPConnection(sys.argv[1])
path = "/testing/{repo}/{ref}".format(repo=sys.argv[3],
ref=sys.argv[4])
conn.request("DELETE", path)
response = conn.getresponse()
if response.status != 200:
print(response.read(), file=sys.stderr)
print("Failed: status={}".format(response.status), file=sys.stderr)
sys.exit(1)
else:
print("Usage: oci-registry-client.py [add|remove] ARGS", file=sys.stderr)
sys.exit(1)
|