+ end
+
+ # Turn a container request into a container.
+ def resolve
+ # In the future this will do things like resolve symbolic git and keep
+ # references to content addresses.
+ Container.create!({ :command => self.command,
+ :container_image => self.container_image,
+ :cwd => self.cwd,
+ :environment => self.environment,
+ :mounts => self.mounts,
+ :output_path => self.output_path,
+ :runtime_constraints => self.runtime_constraints })
+ end
+
+ def set_container
+ if self.container_uuid_changed?
+ if not current_user.andand.is_admin and not self.container_uuid.nil?
+ errors.add :container_uuid, "can only be updated to nil."
+ end
+ else
+ if self.state_changed?
+ if self.state == Committed and (self.state_was == Uncommitted or self.state_was.nil?)
+ act_as_system_user do
+ self.container_uuid = self.resolve.andand.uuid
+ end
+ end
+ end
+ end