-
Notifications
You must be signed in to change notification settings - Fork 9
/
repo_init.py
46 lines (35 loc) · 1.01 KB
/
repo_init.py
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
44
45
46
import logging
from tufup.repo import Repository
from myapp.settings import APP_NAME
from repo_settings import (
ENCRYPTED_KEYS,
EXPIRATION_DAYS,
KEY_MAP,
KEYS_DIR,
REPO_DIR,
THRESHOLDS,
)
logger = logging.getLogger(__name__)
"""
DISCLAIMER
For convenience, this example uses a single key pair for all TUF roles,
and the private key is unencrypted and stored locally. This approach is *not*
safe and should *not* be used in production.
"""
if __name__ == '__main__':
logging.basicConfig(level=logging.INFO)
# Create repository instance
repo = Repository(
app_name=APP_NAME,
app_version_attr='myapp.__version__',
repo_dir=REPO_DIR,
keys_dir=KEYS_DIR,
key_map=KEY_MAP,
expiration_days=EXPIRATION_DAYS,
encrypted_keys=ENCRYPTED_KEYS,
thresholds=THRESHOLDS,
)
# Save configuration (JSON file)
repo.save_config()
# Initialize repository (creates keys and root metadata, if necessary)
repo.initialize()