Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapcache
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
slapcache
Commits
9a8c10e5
Commit
9a8c10e5
authored
May 09, 2022
by
Thomas Gambier
🚴🏼
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rename directory_key to key
parent
12b3f447
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
10 deletions
+10
-10
slapcache/signature.py
slapcache/signature.py
+8
-8
slapcache/test/test_signature.py
slapcache/test/test_signature.py
+2
-2
No files found.
slapcache/signature.py
View file @
9a8c10e5
...
@@ -79,18 +79,18 @@ class NetworkCache:
...
@@ -79,18 +79,18 @@ class NetworkCache:
self
.
shadir_ca_file
=
get_
(
'shadir-ca-file'
)
self
.
shadir_ca_file
=
get_
(
'shadir-ca-file'
)
if
network_cache_info
.
has_section
(
'shacache'
):
if
network_cache_info
.
has_section
(
'shacache'
):
self
.
directory_
key
=
network_cache_info
.
get
(
'shacache'
,
'key'
)
self
.
key
=
network_cache_info
.
get
(
'shacache'
,
'key'
)
else
:
else
:
self
.
directory_
key
=
"slapos-upgrade-testing-key"
self
.
key
=
"slapos-upgrade-testing-key"
def
upload
(
self
,
path
,
metadata_dict
,
is_sha256file
=
False
):
def
upload
(
self
,
path
,
metadata_dict
,
is_sha256file
=
False
):
"""
"""
Upload an existing file, using a file_descriptor.
Upload an existing file, using a file_descriptor.
"""
"""
if
is_sha256file
:
if
is_sha256file
:
key
=
self
.
directory_
key
+
"-sha256-content"
key
=
self
.
key
+
"-sha256-content"
else
:
else
:
key
=
self
.
directory_
key
key
=
self
.
key
file_descriptor
=
open
(
path
,
'rb'
)
file_descriptor
=
open
(
path
,
'rb'
)
if
not
(
self
.
dir_url
and
self
.
cache_url
):
if
not
(
self
.
dir_url
and
self
.
cache_url
):
...
@@ -119,9 +119,9 @@ class NetworkCache:
...
@@ -119,9 +119,9 @@ class NetworkCache:
required_key_list
=
[],
strategy
=
None
,
is_sha256file
=
False
):
required_key_list
=
[],
strategy
=
None
,
is_sha256file
=
False
):
if
is_sha256file
:
if
is_sha256file
:
key
=
self
.
directory_
key
+
"-sha256-content"
key
=
self
.
key
+
"-sha256-content"
else
:
else
:
key
=
self
.
directory_
key
key
=
self
.
key
result
=
helper_download_network_cached
(
result
=
helper_download_network_cached
(
self
.
download_binary_dir_url
,
self
.
download_binary_dir_url
,
...
@@ -246,13 +246,13 @@ class Signature:
...
@@ -246,13 +246,13 @@ class Signature:
if
sha512sum
:
if
sha512sum
:
self
.
log
(
self
.
log
(
'Uploaded %s to cache (using %s key) with SHA512 %s.'
,
path
,
'Uploaded %s to cache (using %s key) with SHA512 %s.'
,
path
,
shacache
.
directory_
key
,
sha512sum
)
shacache
.
key
,
sha512sum
)
sha512sum_path
=
shacache
.
upload
(
sha512sum_path
=
shacache
.
upload
(
path
=
sha256path
,
metadata_dict
=
metadata_dict
,
is_sha256file
=
True
)
path
=
sha256path
,
metadata_dict
=
metadata_dict
,
is_sha256file
=
True
)
if
sha512sum_path
:
if
sha512sum_path
:
self
.
log
(
self
.
log
(
'Uploaded %s to cache (using %s key) with SHA512 %s.'
,
sha256path
,
'Uploaded %s to cache (using %s key) with SHA512 %s.'
,
sha256path
,
shacache
.
directory_
key
,
sha512sum_path
)
shacache
.
key
,
sha512sum_path
)
else
:
else
:
self
.
log
(
'Fail to upload sha256file file to cache.'
)
self
.
log
(
'Fail to upload sha256file file to cache.'
)
else
:
else
:
...
...
slapcache/test/test_signature.py
View file @
9a8c10e5
...
@@ -182,7 +182,7 @@ signature-certificate-list = %(certificate)s
...
@@ -182,7 +182,7 @@ signature-certificate-list = %(certificate)s
self
.
assertEqual
(
shacache
.
download_cache_url
,
'https://www.shacache.org/shacache'
)
self
.
assertEqual
(
shacache
.
download_cache_url
,
'https://www.shacache.org/shacache'
)
self
.
assertEqual
(
shacache
.
download_binary_dir_url
,
'http://www.shacache.org/shadir'
)
self
.
assertEqual
(
shacache
.
download_binary_dir_url
,
'http://www.shacache.org/shadir'
)
self
.
assertEqual
(
shacache
.
signature_certificate_list
,
SIGNATURE
)
self
.
assertEqual
(
shacache
.
signature_certificate_list
,
SIGNATURE
)
self
.
assertEqual
(
shacache
.
directory_
key
,
'slapos-upgrade-testing-key-with-config-file-invalid'
)
self
.
assertEqual
(
shacache
.
key
,
'slapos-upgrade-testing-key-with-config-file-invalid'
)
self
.
assertEqual
(
shacache
.
dir_url
,
None
)
self
.
assertEqual
(
shacache
.
dir_url
,
None
)
self
.
assertEqual
(
shacache
.
cache_url
,
None
)
self
.
assertEqual
(
shacache
.
cache_url
,
None
)
self
.
assertEqual
(
shacache
.
signature_private_key_file
,
None
)
self
.
assertEqual
(
shacache
.
signature_private_key_file
,
None
)
...
@@ -203,7 +203,7 @@ signature-certificate-list = %(certificate)s
...
@@ -203,7 +203,7 @@ signature-certificate-list = %(certificate)s
self
.
assertEqual
(
shacache
.
download_cache_url
,
'https://www.shacache.org/shacache'
)
self
.
assertEqual
(
shacache
.
download_cache_url
,
'https://www.shacache.org/shacache'
)
self
.
assertEqual
(
shacache
.
download_binary_dir_url
,
'http://www.shacache.org/shadir'
)
self
.
assertEqual
(
shacache
.
download_binary_dir_url
,
'http://www.shacache.org/shadir'
)
self
.
assertEqual
(
shacache
.
signature_certificate_list
,
SIGNATURE
)
self
.
assertEqual
(
shacache
.
signature_certificate_list
,
SIGNATURE
)
self
.
assertEqual
(
shacache
.
directory_
key
,
'slapos-upgrade-testing-key-with-config-file-invalid'
)
self
.
assertEqual
(
shacache
.
key
,
'slapos-upgrade-testing-key-with-config-file-invalid'
)
self
.
assertEqual
(
shacache
.
dir_url
,
'https://www.shacache.org/shadir'
)
self
.
assertEqual
(
shacache
.
dir_url
,
'https://www.shacache.org/shadir'
)
self
.
assertEqual
(
shacache
.
cache_url
,
'https://www.shacache.org/shacache'
)
self
.
assertEqual
(
shacache
.
cache_url
,
'https://www.shacache.org/shacache'
)
self
.
assertEqual
(
shacache
.
shacache_cert_file
,
'/etc/opt/slapos/shacache.crt'
)
self
.
assertEqual
(
shacache
.
shacache_cert_file
,
'/etc/opt/slapos/shacache.crt'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment