Download image including parent layers
This commit is contained in:
parent
5abbd921cc
commit
a320661727
@ -9,6 +9,4 @@ signing-key = /etc/spoc/publish.key
|
|||||||
|
|
||||||
[repo]
|
[repo]
|
||||||
url = https://repo.spotter.cz/spoc/
|
url = https://repo.spotter.cz/spoc/
|
||||||
username =
|
|
||||||
password =
|
|
||||||
public-key = MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEWJXH4Qm0kt2L86sntQH+C1zOJNQ0qMRt0vx4krTxRs9HQTQYAy//JC92ea2aKleA8OL0JF90b1NYXcQCWdAS+vE/ng9IEAii8C2+5nfuFeZ5YUjbQhfFblwHSM0c7hEG
|
public-key = MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEWJXH4Qm0kt2L86sntQH+C1zOJNQ0qMRt0vx4krTxRs9HQTQYAy//JC92ea2aKleA8OL0JF90b1NYXcQCWdAS+vE/ng9IEAii8C2+5nfuFeZ5YUjbQhfFblwHSM0c7hEG
|
||||||
|
@ -36,7 +36,11 @@ def listing(repo_type):
|
|||||||
print(image)
|
print(image)
|
||||||
|
|
||||||
def download(image_name):
|
def download(image_name):
|
||||||
Image(image_name, False).download()
|
local_images = repo_local.get_images()
|
||||||
|
for layer in repo_online.get_image(image_name)['layers']:
|
||||||
|
if layer not in local_images:
|
||||||
|
print(f'Downloading {layer}...')
|
||||||
|
Image(layer, False).download()
|
||||||
|
|
||||||
def delete(image_name):
|
def delete(image_name):
|
||||||
Image(image_name, False).delete()
|
Image(image_name, False).delete()
|
||||||
|
@ -7,13 +7,6 @@ import urllib.parse
|
|||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
config.read('/etc/spoc/spoc.conf')
|
config.read('/etc/spoc/spoc.conf')
|
||||||
|
|
||||||
def get_repo_auth(config):
|
|
||||||
username = config.get('repo', 'username', fallback='')
|
|
||||||
password = config.get('repo', 'password', fallback='')
|
|
||||||
if not username and not password:
|
|
||||||
return None
|
|
||||||
return (username, password)
|
|
||||||
|
|
||||||
NETWORK_INTERFACE = config.get('general', 'network-interface', fallback='spocbr0')
|
NETWORK_INTERFACE = config.get('general', 'network-interface', fallback='spocbr0')
|
||||||
|
|
||||||
DATA_DIR = config.get('general', 'data-dir', fallback='/var/lib/spoc/')
|
DATA_DIR = config.get('general', 'data-dir', fallback='/var/lib/spoc/')
|
||||||
@ -34,11 +27,11 @@ PUB_SIG_FILE = os.path.join(PUB_DIR, 'repository.sig')
|
|||||||
PUB_PRIVKEY_FILE = config.get('publish', 'signing-key', fallback='/etc/spoc/publish.key')
|
PUB_PRIVKEY_FILE = config.get('publish', 'signing-key', fallback='/etc/spoc/publish.key')
|
||||||
PUB_LOCK_FILE = '/run/lock/spoc-publish.lock'
|
PUB_LOCK_FILE = '/run/lock/spoc-publish.lock'
|
||||||
|
|
||||||
ONLINE_BASE_URL = config.get('repo', 'url', fallback='https://localhost/')
|
# URLs which are an actual directories need to end with trailing slash
|
||||||
|
ONLINE_BASE_URL = '{}/'.format(config.get('repo', 'url', fallback='https://localhost').rstrip('/'))
|
||||||
ONLINE_LAYERS_URL = urllib.parse.urljoin(ONLINE_BASE_URL, 'layers/')
|
ONLINE_LAYERS_URL = urllib.parse.urljoin(ONLINE_BASE_URL, 'layers/')
|
||||||
ONLINE_APPS_URL = urllib.parse.urljoin(ONLINE_BASE_URL, 'apps/')
|
ONLINE_APPS_URL = urllib.parse.urljoin(ONLINE_BASE_URL, 'apps/')
|
||||||
ONLINE_REPO_URL = urllib.parse.urljoin(ONLINE_BASE_URL, 'repository.json')
|
ONLINE_REPO_URL = urllib.parse.urljoin(ONLINE_BASE_URL, 'repository.json')
|
||||||
ONLINE_SIG_URL = urllib.parse.urljoin(ONLINE_BASE_URL, 'repository.sig')
|
ONLINE_SIG_URL = urllib.parse.urljoin(ONLINE_BASE_URL, 'repository.sig')
|
||||||
ONLINE_REPO_FILE = os.path.join(DATA_DIR, 'online.json')
|
ONLINE_REPO_FILE = os.path.join(DATA_DIR, 'online.json')
|
||||||
ONLINE_AUTH = get_repo_auth(config) # TODO: Username + password as part of url?
|
|
||||||
ONLINE_PUBKEY = config.get('repo', 'public-key', fallback='')
|
ONLINE_PUBKEY = config.get('repo', 'public-key', fallback='')
|
||||||
|
@ -14,7 +14,7 @@ from cryptography.hazmat.primitives.asymmetric import ec, utils
|
|||||||
from cryptography.hazmat.primitives.serialization import load_pem_public_key
|
from cryptography.hazmat.primitives.serialization import load_pem_public_key
|
||||||
|
|
||||||
from .exceptions import AppNotFoundError, ImageNotFoundError
|
from .exceptions import AppNotFoundError, ImageNotFoundError
|
||||||
from .config import ONLINE_REPO_FILE, ONLINE_AUTH, ONLINE_PUBKEY, ONLINE_REPO_URL, ONLINE_SIG_URL
|
from .config import ONLINE_REPO_FILE, ONLINE_PUBKEY, ONLINE_REPO_URL, ONLINE_SIG_URL
|
||||||
|
|
||||||
TYPE_APP = 'apps'
|
TYPE_APP = 'apps'
|
||||||
TYPE_IMAGE = 'images'
|
TYPE_IMAGE = 'images'
|
||||||
|
Loading…
Reference in New Issue
Block a user