refs #1864. Added ssh_port and user in imageRepository
testing/ogcore-api/pipeline/head There was a failure building this commit
Details
testing/ogcore-api/pipeline/head There was a failure building this commit
Details
parent
4578f29349
commit
9a96b04e7f
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20250408140101 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE image_repository ADD user VARCHAR(255) DEFAULT NULL, ADD ssh_port VARCHAR(255) DEFAULT NULL');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE image_repository DROP user, DROP ssh_port');
|
||||
}
|
||||
}
|
|
@ -32,6 +32,7 @@ class BackupImageAction extends AbstractOgRepositoryController
|
|||
public function __invoke(BackupImageInput $input, ImageImageRepository $imageImageRepository): JsonResponse
|
||||
{
|
||||
$image = $imageImageRepository->getImage();
|
||||
$repository = $imageImageRepository->getRepository();
|
||||
|
||||
if (!$image->getName()) {
|
||||
throw new ValidatorException('Name is required');
|
||||
|
@ -41,8 +42,9 @@ class BackupImageAction extends AbstractOgRepositoryController
|
|||
'json' => [
|
||||
'ID_img' => $imageImageRepository->getImageFullsum(),
|
||||
'repo_ip' => $input->repoIp,
|
||||
'ssh_port' => $repository->getSshPort() ?? '22',
|
||||
'remote_path' => $input->remotePath,
|
||||
'user' => 'opengnsys'
|
||||
'user' => $repository->getUser() ?? 'opengnsys',
|
||||
]
|
||||
];
|
||||
|
||||
|
|
|
@ -47,7 +47,8 @@ class TransferAction extends AbstractOgRepositoryController
|
|||
'json' => [
|
||||
'image' => $image->getName().'.img',
|
||||
'repo_ip' => $imageImageRepository->getRepository()->getIp(),
|
||||
'user' => 'opengnsys',
|
||||
'user' => $repository->getUser(),
|
||||
'ssh_port' => $repository->getSshPort()
|
||||
]
|
||||
];
|
||||
|
||||
|
|
|
@ -48,7 +48,8 @@ class TransferGlobalAction extends AbstractOgRepositoryController
|
|||
'json' => [
|
||||
'image' => $image->getName().'.img',
|
||||
'repo_ip' => $imageImageRepository->getRepository()->getIp(),
|
||||
'user' => 'opengnsys',
|
||||
'user' => $repository->getUser(),
|
||||
'ssh_port' => $repository->getSshPort()
|
||||
]
|
||||
];
|
||||
|
||||
|
|
|
@ -27,11 +27,19 @@ final class ImageRepositoryInput
|
|||
#[ApiProperty(description: 'The IP of the repository', example: "")]
|
||||
public ?string $ip = null;
|
||||
|
||||
|
||||
#[Groups(['repository:write'])]
|
||||
#[ApiProperty(description: 'The comments of the repository', example: "Repository 1 comments")]
|
||||
public ?string $comments = null;
|
||||
|
||||
#[Assert\NotBlank]
|
||||
#[Groups(['repository:write'])]
|
||||
#[ApiProperty(description: 'The user of the repository', example: "Repository user")]
|
||||
public ?string $user = 'opengnsys';
|
||||
|
||||
#[Groups(['repository:write'])]
|
||||
#[ApiProperty(description: 'The sshPort of the repository', example: "Repository ssh port")]
|
||||
public ?string $sshPort = '22';
|
||||
|
||||
|
||||
public function __construct(?ImageRepository $repository = null)
|
||||
{
|
||||
|
@ -42,6 +50,8 @@ final class ImageRepositoryInput
|
|||
$this->name = $repository->getName();
|
||||
$this->ip = $repository->getIp();
|
||||
$this->comments = $repository->getComments();
|
||||
$this->user = $repository->getUser();
|
||||
$this->sshPort = $repository->getSshPort();
|
||||
}
|
||||
|
||||
public function createOrUpdateEntity(?ImageRepository $repository = null): ImageRepository
|
||||
|
@ -53,6 +63,8 @@ final class ImageRepositoryInput
|
|||
$repository->setName($this->name);
|
||||
$repository->setIp($this->ip);
|
||||
$repository->setComments($this->comments);
|
||||
$repository->setUser($this->user);
|
||||
$repository->setSshPort($this->sshPort);
|
||||
|
||||
return $repository;
|
||||
}
|
||||
|
|
|
@ -18,6 +18,9 @@ class ImageImageRepositoryOutput extends AbstractOutput
|
|||
#[Groups(['image-image-repository:read', 'image:read'])]
|
||||
public string $status;
|
||||
|
||||
#[Groups(['image-image-repository:read', 'image:read'])]
|
||||
public string $name;
|
||||
|
||||
#[Groups(['image-image-repository:read', 'image:read'])]
|
||||
public ?string $imageFullsum = null;
|
||||
|
||||
|
@ -50,6 +53,7 @@ class ImageImageRepositoryOutput extends AbstractOutput
|
|||
$this->imageRepository = new ImageRepositoryOutput($imageImageRepository->getRepository());
|
||||
}
|
||||
|
||||
$this->name = $imageImageRepository->getName();
|
||||
$this->version = $imageImageRepository->getVersion();
|
||||
$this->status = $imageImageRepository->getStatus();
|
||||
$this->imageFullsum = $imageImageRepository->getImageFullsum();
|
||||
|
|
|
@ -18,6 +18,12 @@ class ImageRepositoryOutput extends AbstractOutput
|
|||
#[Groups(['repository:read'])]
|
||||
public ?string $comments = '';
|
||||
|
||||
#[Groups(['repository:read'])]
|
||||
public ?string $sshPort = '';
|
||||
|
||||
#[Groups(['repository:read'])]
|
||||
public ?string $user = '';
|
||||
|
||||
#[Groups(['repository:read'])]
|
||||
public \DateTime $createdAt;
|
||||
|
||||
|
@ -31,6 +37,8 @@ class ImageRepositoryOutput extends AbstractOutput
|
|||
$this->name = $imageRepository->getName();
|
||||
$this->ip = $imageRepository->getIp();
|
||||
$this->comments = $imageRepository->getComments();
|
||||
$this->sshPort = $imageRepository->getSshPort();
|
||||
$this->user = $imageRepository->getUser();
|
||||
$this->createdAt = $imageRepository->getCreatedAt();
|
||||
$this->createdBy = $imageRepository->getCreatedBy();
|
||||
}
|
||||
|
|
|
@ -35,6 +35,9 @@ class ImageImageRepository extends AbstractEntity
|
|||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $description = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $name = null;
|
||||
|
||||
public function getImage(): ?Image
|
||||
{
|
||||
return $this->image;
|
||||
|
@ -130,4 +133,16 @@ class ImageImageRepository extends AbstractEntity
|
|||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getName(): ?string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName(string $name): static
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,8 @@ use Doctrine\ORM\Mapping as ORM;
|
|||
#[ORM\Entity(repositoryClass: ImageRepositoryRepository::class)]
|
||||
class ImageRepository extends AbstractEntity
|
||||
{
|
||||
const string DEFAULT_USER = 'opengnsys';
|
||||
|
||||
use NameableTrait;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
|
@ -24,6 +26,12 @@ class ImageRepository extends AbstractEntity
|
|||
#[ORM\OneToMany(mappedBy: 'repository', targetEntity: ImageImageRepository::class)]
|
||||
private Collection $imageImageRepositories;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $user = self::DEFAULT_USER;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $sshPort = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
@ -83,4 +91,28 @@ class ImageRepository extends AbstractEntity
|
|||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUser(): ?string
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
public function setUser(?string $user): static
|
||||
{
|
||||
$this->user = $user;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSshPort(): ?string
|
||||
{
|
||||
return $this->sshPort;
|
||||
}
|
||||
|
||||
public function setSshPort(?string $sshPort): static
|
||||
{
|
||||
$this->sshPort = $sshPort;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue