+ def find_docker_image_locator
+ # Find the Collection that holds the Docker image specified in the
+ # runtime constraints, and store its locator in docker_image_locator.
+ unless runtime_constraints.is_a? Hash
+ # We're still in validation stage, so we can't assume
+ # runtime_constraints isn't something horrible like an array or
+ # a string. Treat those cases as "no docker image supplied";
+ # other validations will fail anyway.
+ self.docker_image_locator = nil
+ return true
+ end
+ image_search = runtime_constraints['docker_image']
+ image_tag = runtime_constraints['docker_image_tag']
+ if image_search.nil?
+ self.docker_image_locator = nil
+ true
+ elsif coll = Collection.for_latest_docker_image(image_search, image_tag)
+ self.docker_image_locator = coll.portable_data_hash
+ true
+ else
+ errors.add(:docker_image_locator, "not found for #{image_search}")
+ false
+ end
+ end
+