[TASK] Finish building first working release
This commit is contained in:
parent
7df68dc0eb
commit
18061966d7
8
.gitignore
vendored
Normal file
8
.gitignore
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
/env/
|
||||
/check.in.json
|
||||
/in.in.json
|
||||
/out.in.json
|
||||
/tmp.out/*
|
||||
!/tmp.out/.keep
|
||||
/tmp.in/*
|
||||
!/tmp.in/.keep
|
8
Dockerfile
Normal file
8
Dockerfile
Normal file
@ -0,0 +1,8 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
|
||||
FROM python:3.8-slim-buster
|
||||
|
||||
COPY requirements.txt requirements.txt
|
||||
RUN pip3 install -r requirements.txt
|
||||
|
||||
COPY check in out /opt/resource/
|
28
Makefile
Normal file
28
Makefile
Normal file
@ -0,0 +1,28 @@
|
||||
.SILENT:
|
||||
|
||||
make_and_deploy:
|
||||
docker build --tag aptly-resource .
|
||||
docker tag aptly-resource:latest docker.datentonne.net/concourse/aptly-resource:latest
|
||||
docker push docker.datentonne.net/concourse/aptly-resource:latest
|
||||
|
||||
test_check:
|
||||
HTTPS_PROXY="http://localhost:8080" \
|
||||
CURL_CA_BUNDLE="${HOME}/.mitmproxy/mitmproxy-ca-cert.pem" \
|
||||
./check_test.py
|
||||
|
||||
test_in:
|
||||
HTTPS_PROXY="http://localhost:8080" \
|
||||
CURL_CA_BUNDLE="${HOME}/.mitmproxy/mitmproxy-ca-cert.pem" \
|
||||
./in_test.py
|
||||
|
||||
test_out:
|
||||
HTTPS_PROXY="http://localhost:8080" \
|
||||
CURL_CA_BUNDLE="${HOME}/.mitmproxy/mitmproxy-ca-cert.pem" \
|
||||
./out_test.py
|
||||
|
||||
proxy:
|
||||
mitmproxy \
|
||||
--set keep_host_header=true \
|
||||
--set console_flowlist_layout=list \
|
||||
--set console_mouse=false \
|
||||
--set view_order_reversed=true
|
1
check
1
check
@ -20,7 +20,6 @@ import semver
|
||||
|
||||
root = os.path.dirname(os.path.abspath(__file__))
|
||||
config = json.loads(sys.stdin.read())
|
||||
directory = sys.argv[1]
|
||||
|
||||
previous_version = False
|
||||
if 'version' in config and 'version' in config['version']:
|
||||
|
17
check.in.dist.json
Normal file
17
check.in.dist.json
Normal file
@ -0,0 +1,17 @@
|
||||
{
|
||||
"source": {
|
||||
"api_uri": "",
|
||||
"repo_uri": "",
|
||||
"repo": "",
|
||||
"distribution": "debian",
|
||||
"component": "main",
|
||||
"architecture": "amd64",
|
||||
"package": "",
|
||||
"username": "",
|
||||
"password": "",
|
||||
"timeout": 1800
|
||||
},
|
||||
"version": {
|
||||
"version": ""
|
||||
}
|
||||
}
|
15
check_test.py
Executable file
15
check_test.py
Executable file
@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env python3
|
||||
'''
|
||||
aptly-resource test out
|
||||
'''
|
||||
|
||||
from subprocess import run
|
||||
|
||||
with open('check.in.json', 'r', encoding='utf-8') as f:
|
||||
contents = f.read()
|
||||
|
||||
run(['./check tmp'],
|
||||
input = contents.encode(),
|
||||
check = True,
|
||||
shell = True,
|
||||
)
|
17
in.in.dist.json
Normal file
17
in.in.dist.json
Normal file
@ -0,0 +1,17 @@
|
||||
{
|
||||
"source": {
|
||||
"api_uri": "",
|
||||
"repo_uri": "",
|
||||
"repo": "",
|
||||
"distribution": "debian",
|
||||
"component": "main",
|
||||
"architecture": "amd64",
|
||||
"package": "",
|
||||
"username": "",
|
||||
"password": "",
|
||||
"timeout": 1800
|
||||
},
|
||||
"version": {
|
||||
"version": ""
|
||||
}
|
||||
}
|
15
in_test.py
Executable file
15
in_test.py
Executable file
@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env python3
|
||||
'''
|
||||
aptly-resource test out
|
||||
'''
|
||||
|
||||
from subprocess import run
|
||||
|
||||
with open('in.in.json', 'r', encoding='utf-8') as f:
|
||||
contents = f.read()
|
||||
|
||||
run(['./in tmp.in'],
|
||||
input = contents.encode(),
|
||||
check = True,
|
||||
shell = True,
|
||||
)
|
18
out
18
out
@ -58,25 +58,31 @@ archive_filename_parts = archive_filename.split('_')
|
||||
|
||||
|
||||
file_hash = hashlib.sha256()
|
||||
with open(directory + '/' + archive_filename, 'rb') as f:
|
||||
with open(directory + '/' + archive_path, 'rb') as f:
|
||||
fb = f.read(BLOCK_SIZE)
|
||||
while len(fb) > 0:
|
||||
file_hash.update(fb)
|
||||
fb = f.read(BLOCK_SIZE)
|
||||
|
||||
|
||||
#aptly.files.upload(
|
||||
# config['source']['repo'],
|
||||
# directory + '/' + archive_path
|
||||
# )
|
||||
aptly.files.upload(
|
||||
config['source']['repo'],
|
||||
directory + '/' + archive_path
|
||||
)
|
||||
|
||||
aptly.repos.add_uploaded_file(
|
||||
reponame = config['source']['repo'],
|
||||
dir = config['source']['repo'],
|
||||
remove_processed_files = False,
|
||||
remove_processed_files = True,
|
||||
force_replace = True
|
||||
)
|
||||
|
||||
aptly.publish.update(
|
||||
prefix = config['source']['repo'],
|
||||
distribution = config['source']['distribution'],
|
||||
force_overwrite = True
|
||||
)
|
||||
|
||||
print(json.dumps({
|
||||
'version': {'version': archive_filename_parts[1]},
|
||||
'metadata': [
|
||||
|
17
out.in.dist.json
Normal file
17
out.in.dist.json
Normal file
@ -0,0 +1,17 @@
|
||||
{
|
||||
"source": {
|
||||
"api_uri": "",
|
||||
"repo_uri": "",
|
||||
"repo": "",
|
||||
"distribution": "debian",
|
||||
"component": "main",
|
||||
"architecture": "amd64",
|
||||
"package": "",
|
||||
"username": "",
|
||||
"password": "",
|
||||
"timeout": 1800
|
||||
},
|
||||
"params": {
|
||||
"archive_file": "filename"
|
||||
}
|
||||
}
|
15
out_test.py
Executable file
15
out_test.py
Executable file
@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env python3
|
||||
'''
|
||||
aptly-resource test out
|
||||
'''
|
||||
|
||||
from subprocess import run
|
||||
|
||||
with open('out.in.json', 'r', encoding='utf-8') as f:
|
||||
contents = f.read()
|
||||
|
||||
run(['./out tmp.out'],
|
||||
input = contents.encode(),
|
||||
check = True,
|
||||
shell = True,
|
||||
)
|
11
requirements.txt
Normal file
11
requirements.txt
Normal file
@ -0,0 +1,11 @@
|
||||
aptly-api-client==0.2.3
|
||||
certifi==2021.10.8
|
||||
charset-normalizer==2.0.12
|
||||
idna==3.3
|
||||
iso8601==1.0.2
|
||||
pytz==2021.3
|
||||
PyYAML==6.0
|
||||
requests==2.27.1
|
||||
semver==2.13.0
|
||||
typing==3.7.4.3
|
||||
urllib3==1.26.8
|
0
tmp.in/.keep
Normal file
0
tmp.in/.keep
Normal file
0
tmp.out/.keep
Normal file
0
tmp.out/.keep
Normal file
Loading…
x
Reference in New Issue
Block a user