+ def self.get_compatible_image(readers, pattern, coll_match)
+ if coll_match.nil?
+ return nil
+ end
+ manifest = Keep::Manifest.new(coll_match.manifest_text)
+ if manifest.exact_file_count?(1)
+ if manifest.files[0][1] =~ pattern
+ # Looks like a compatible image
+ return coll_match
+ else
+ # Doesn't match the expected pattern, see if there is a migration link.
+ migrate_pdh = self.docker_migration_pdh(readers, coll_match.portable_data_hash)
+ if migrate_pdh != coll_match.portable_data_hash
+ # See if the migrated image is compatible.
+ coll_match = readable_by(*readers).where(portable_data_hash: migrate_pdh).limit(1).first
+ return get_compatible_image(readers, pattern, coll_match)
+ end
+ end
+ end
+ return nil
+ end
+