Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
This file is a mapping with this shape:
{
"username/imagename": { "version1": "top layer id", "version2" : "top layer id", }
}
For example:
{
"me/test_image_tar": {"1.0":"de331f94dc3592a39e495432d39ca14ed0cf04a6861c1e7714ff410e8a0225b4"},
"she/image_from_scratch": {"1.0":"a699c18e2119e668e5f1264e97559af65d2111ac0790b6832efeb450fc5193fc"},
"you/secondimage": {"1.2":"1466996a39f8d2af81b92fad37ef15c04fb2ca64b43945a00f6f5943913f6b96"}
}
The top layer id is the name of the layer.tar parent dir and not a digest in
this legacy format.
"""
repositories = load_json(repositories_file)
for image_name, versions in repositories.items():
for version, top_layer_id in versions:
tag = ':'.join([image_name, version])
yield tag, top_layer_id
'rootfs': {
'diff_ids': ['sha256:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef',
'sha256:2436bc321ced91d2f3052a98ff886a2feed0788eb524b2afeb48099d084c33f5',
'sha256:cd141a5beb0ec83004893dfea6ea8508c6d09a0634593c3f35c0d433898c9322',]
'type': u'layers'
}
}
"""
image_id = fileutils.file_base_name(config_file)
config_digest = sha256_digest(config_file)
if image_id != as_bare_id(config_digest):
print('WARNING: image config digest is not consistent.')
config_digest = 'sha256' + image_id
image_config = load_json(config_file)
# merge "configs"
ccnf = image_config.pop('container_config', {})
cnf = image_config.pop('config', {})
config, warns = merge_configs(ccnf, cnf)
if warns and verbose:
print('Warning when loading: %(config_file)r' % locals())
for w in warns:
print(w)
rootfs = image_config.pop('rootfs')
# we only support this for now
assert rootfs['type'] == 'layers'
digests = rootfs['diff_ids']
]
'RepoTags': ['user/image:version'],
"Parent": "sha256:5a00e6ccb81ef304e1bb9995ea9605f199aa96659a44237d58ca96982daf9af8"
},
{'Config': '7043867122e704683c9eaccd7e26abcd5bc9fea413ddfeae66166697bdcbde1f.json',
'Layers': [
'768d4f50f65f00831244703e57f64134771289e3de919a576441c9140e037ea2/layer.tar',
'6a630e46a580e8b2327fc45d9d1f4734ccaeb0afaa094e0f45722a5f1c91e009/layer.tar',
]
'RepoTags': ['user/image:version']
},
]
"""
manifest_file = join(repo_dir, MANIFEST_JSON_FILE)
manifest = load_json(manifest_file)
for image_config in manifest:
config_file = image_config.get('Config')
config_file = join(repo_dir, config_file)
if not exists(config_file):
# FIXME: orphaned manifest entry
image_id = file_base_name(config_file)
image = Image(image_id=image_id)
assert image.image_id not in self.images_by_id
self.images_by_id[image.image_id] = image
continue
image = Image.load_image_config(config_file)
assert image.image_id not in self.images_by_id
self.images_by_id[image.image_id] = image