Change secscan API endpoints to use new registry model interface
This commit is contained in:
parent
dcaa98a428
commit
46edebe6b0
6 changed files with 81 additions and 37 deletions
|
@ -7,9 +7,10 @@ from urlparse import urljoin
|
|||
|
||||
import requests
|
||||
|
||||
from data.database import CloseForLongOperation
|
||||
from data import model
|
||||
from data.database import CloseForLongOperation, TagManifest, Image
|
||||
from data.model.storage import get_storage_locations
|
||||
from data.registry_model.datatypes import Manifest, LegacyImage
|
||||
from util.abchelpers import nooper
|
||||
from util.failover import failover, FailoverException
|
||||
from util.secscan.validator import SecurityConfigValidator
|
||||
|
@ -61,6 +62,12 @@ _API_METHOD_PING = 'metrics'
|
|||
|
||||
def compute_layer_id(layer):
|
||||
""" Returns the ID for the layer in the security scanner. """
|
||||
# NOTE: this is temporary until we switch to Clair V3.
|
||||
if isinstance(layer, Manifest):
|
||||
layer = TagManifest.get(id=layer._db_id).tag.image
|
||||
elif isinstance(layer, LegacyImage):
|
||||
layer = Image.get(id=layer._db_id)
|
||||
|
||||
return '%s.%s' % (layer.docker_image_id, layer.storage.uuid)
|
||||
|
||||
|
||||
|
|
Reference in a new issue