/** * @Route("/r/{name}/~/webhooks/{id}/remove", requirements={"name"="%regex_name%"}, methods={"GET", "POST"}, name="repository_webhooks_remove") * * @ParamConverter("repository", options={"mapping": {"name": "name"}}) * * @Security("is_granted('REPO_WRITE', repository)") */ public function removeWebhookAction(Request $request, Repository $repository, $id) { if (!$this->isCsrfTokenValid('webhook_remove', $request->query->get('_token'))) { $this->addFlash('error', 'invalid_csrf_token'); return $this->redirectToRoute('repository_webhooks', ['name' => $repository->getName()]); } $webhook = $this->get('doctrine')->getRepository('AppBundle:Webhook')->findOneBy(['repository' => $repository, 'id' => $id]); if (null === $webhook) { $this->addFlash('error', 'webhook.not_found_or_not_granted'); return $this->redirectToRoute('repository_webhooks', ['name' => $repository->getName()]); } $manager = $this->get('doctrine')->getManager(); $manager->remove($webhook); $manager->flush(); $this->addFlash('success', 'webhook.removed'); return $this->redirectToRoute('repository_webhooks', ['name' => $repository->getName()]); }
/** * @Route("/uploads/{uuid}", methods={"PUT"}, name="layer_upload", requirements={"uuid"="[0-9a-z-]+"}) * * @ParamConverter(name="repository", options={"mapping": {"name": "name"}}) * @ParamConverter(name="layer", options={"mapping": {"uuid": "uuid"}}) * * @Security("is_granted('REPO_WRITE', repository)") * * @link http://docs.docker.com/registry/spec/api/#uploading-the-layer */ public function uploadAction(Request $request, Repository $repository, Layer $layer) { if (Layer::STATUS_COMPLETE === $layer->getStatus()) { throw new BadRequestHttpException(sprintf('Layer with uuid "%s" has already been uploaded', $layer->getUuid())); } $finalUpload = $request->query->has('digest'); // TODO: manage chunked uploads $this->get('layer_manager')->write($layer, $request->getContent(true)); if (!$finalUpload) { $layer->setStatus(Layer::STATUS_PARTIAL); return new Response('', Response::HTTP_ACCEPTED, ['Location' => $this->generateUrl('layer_upload', ['name' => $repository->getName(), 'uuid' => $layer->getUuid()], true), 'Docker-Upload-UUID' => $layer->getUuid()]); } $digest = $this->get('layer_manager')->computeDigest($layer); if ($digest !== $request->query->get('digest')) { throw new BadRequestHttpException(sprintf('Digest does not match with received data (computed: "%s")', $digest)); } $layer->setDigest($digest); $this->get('layer_manager')->save($layer); return new Response('', Response::HTTP_CREATED, ['Location' => $this->generateUrl('layer_get', ['name' => $repository->getName(), 'digest' => $layer->getDigest()], true), 'Docker-Content-Digest' => $layer->getDigest()]); }
public function updateRepository(Repository $repository) { // If the owner has not a token, ignore if ($repository->getOwner()->getToken() == null) { return; } // Connecting with Blih $blih = new Blih($repository->getOwner()->getLogin()); $blih->setToken($repository->getOwner()->getToken()); // Getting the repository ACLs $blihRepositoryACLs = $blih->repository($repository->getName())->acl()->get()->body; if (isset($blihRepositoryACLs->error)) { return; } $repositoryACLs = $repository->getAcls(); // Removing the users removed $repositoryACLs->forAll(function ($key, RepositoryACL $repositoryACL) use($blihRepositoryACLs) { if (!array_key_exists($repositoryACL->getUser()->getLogin(), $blihRepositoryACLs)) { $this->entityManager->remove($repositoryACL); } return true; }); // Updating or creating the ACLs for the users already set foreach ($blihRepositoryACLs as $login => $acl) { $user = $this->epitechUserRetriever->retrieve($login); $repositoryACL = $this->retrieveOrCreateRepositoryACL($user, $repository); $repositoryACL->setFromACLString($acl); $this->entityManager->persist($user); $this->entityManager->persist($repositoryACL); } $this->entityManager->flush(); }