Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
layer_id = layer_id.replace('.tar', '')
layer_digest = sha256_digest(layer_dir)
layer_size = filetype.get_size(layer_dir)
return Layer(layer_id=layer_id, layer_digest=layer_digest, layer_size=layer_size)
if not isdir(layer_dir):
return Layer(layer_id=layer_id)
files = listdir(layer_dir)
assert files
logger_debug('load_layer: Layer files: ', files, 'layer_dir: ', layer_dir)
# check that all the files we expect to be in the layer dir are present note:
# we ignore any other files (such as extracted tars, etc)
if LAYER_VERSION_FILE in files:
layer_format_version_file = join(layer_dir, LAYER_VERSION_FILE)
supported_format_version = cls.format_version
with open(layer_format_version_file) as lv:
layer_format_version = lv.read().strip()
assert supported_format_version == layer_format_version, (
'Unknown layer format version: %(layer_format_version)r '
'in: %(layer_format_version_file)r. '
'Supported version: %(supported_format_version)r') % locals()
else:
print('Missing layer VERSION for:', layer_dir)
if not LAYER_JSON_FILE in files:
print('Missing layer json for:', layer_dir)
return Layer(layer_id=layer_id)
# load data
layer_digest = sha256_digest(layer_dir)
layer_size = filetype.get_size(layer_dir)
return Layer(layer_id=layer_id, layer_digest=layer_digest, layer_size=layer_size)
if not isdir(layer_dir):
return Layer(layer_id=layer_id)
files = listdir(layer_dir)
assert files
logger_debug('load_layer: Layer files: ', files, 'layer_dir: ', layer_dir)
# check that all the files we expect to be in the layer dir are present note:
# we ignore any other files (such as extracted tars, etc)
if LAYER_VERSION_FILE in files:
layer_format_version_file = join(layer_dir, LAYER_VERSION_FILE)
supported_format_version = cls.format_version
with open(layer_format_version_file) as lv:
layer_format_version = lv.read().strip()
assert supported_format_version == layer_format_version, (
'Unknown layer format version: %(layer_format_version)r '
'in: %(layer_format_version_file)r. '
'Supported version: %(supported_format_version)r') % locals()
else:
print('Missing layer VERSION for:', layer_dir)
if not LAYER_JSON_FILE in files:
print('Missing layer json for:', layer_dir)
return Layer(layer_id=layer_id)
# load data
with open(join(layer_dir, LAYER_JSON_FILE)) as layer_json: