mirror of
https://github.com/nextcloud/all-in-one.git
synced 2025-12-20 14:36:52 +00:00
update constructor
Signed-off-by: Jean-Yves <7360784+docjyJ@users.noreply.github.com>
This commit is contained in:
parent
69d9c925d0
commit
496ec9ba17
13 changed files with 84 additions and 193 deletions
|
|
@ -6,12 +6,12 @@ use AIO\Data\ConfigurationManager;
|
||||||
use AIO\Data\DataConst;
|
use AIO\Data\DataConst;
|
||||||
use \DateTime;
|
use \DateTime;
|
||||||
|
|
||||||
class AuthManager {
|
readonly class AuthManager {
|
||||||
private const string SESSION_KEY = 'aio_authenticated';
|
private const string SESSION_KEY = 'aio_authenticated';
|
||||||
private ConfigurationManager $configurationManager;
|
|
||||||
|
|
||||||
public function __construct(ConfigurationManager $configurationManager) {
|
public function __construct(
|
||||||
$this->configurationManager = $configurationManager;
|
private ConfigurationManager $configurationManager
|
||||||
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function CheckCredentials(string $password) : bool {
|
public function CheckCredentials(string $password) : bool {
|
||||||
|
|
|
||||||
|
|
@ -7,87 +7,38 @@ use AIO\Data\ConfigurationManager;
|
||||||
use AIO\Docker\DockerActionManager;
|
use AIO\Docker\DockerActionManager;
|
||||||
use AIO\ContainerDefinitionFetcher;
|
use AIO\ContainerDefinitionFetcher;
|
||||||
|
|
||||||
class Container {
|
readonly class Container {
|
||||||
private string $identifier;
|
|
||||||
private string $displayName;
|
|
||||||
private string $containerName;
|
|
||||||
private string $restartPolicy;
|
|
||||||
private int $maxShutdownTime;
|
|
||||||
private ContainerPorts $ports;
|
|
||||||
private string $internalPorts;
|
|
||||||
private ContainerVolumes $volumes;
|
|
||||||
private ContainerEnvironmentVariables $containerEnvironmentVariables;
|
|
||||||
/** @var string[] */
|
|
||||||
private array $dependsOn;
|
|
||||||
/** @var string[] */
|
|
||||||
private array $secrets;
|
|
||||||
/** @var string[] */
|
|
||||||
private array $devices;
|
|
||||||
/** @var string[] */
|
|
||||||
private array $capAdd;
|
|
||||||
private int $shmSize;
|
|
||||||
private bool $apparmorUnconfined;
|
|
||||||
/** @var string[] */
|
|
||||||
private array $backupVolumes;
|
|
||||||
private array $nextcloudExecCommands;
|
|
||||||
private bool $readOnlyRootFs;
|
|
||||||
private array $tmpfs;
|
|
||||||
private bool $init;
|
|
||||||
private string $imageTag;
|
|
||||||
private AioVariables $aioVariables;
|
|
||||||
private string $documentation;
|
|
||||||
private DockerActionManager $dockerActionManager;
|
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
string $identifier,
|
private string $identifier,
|
||||||
string $displayName,
|
private string $displayName,
|
||||||
string $containerName,
|
private string $containerName,
|
||||||
string $restartPolicy,
|
private string $restartPolicy,
|
||||||
int $maxShutdownTime,
|
private int $maxShutdownTime,
|
||||||
ContainerPorts $ports,
|
private ContainerPorts $ports,
|
||||||
string $internalPorts,
|
private string $internalPorts,
|
||||||
ContainerVolumes $volumes,
|
private ContainerVolumes $volumes,
|
||||||
ContainerEnvironmentVariables $containerEnvironmentVariables,
|
private ContainerEnvironmentVariables $containerEnvironmentVariables,
|
||||||
array $dependsOn,
|
/** @var string[] */
|
||||||
array $secrets,
|
private array $dependsOn,
|
||||||
array $devices,
|
/** @var string[] */
|
||||||
array $capAdd,
|
private array $secrets,
|
||||||
int $shmSize,
|
/** @var string[] */
|
||||||
bool $apparmorUnconfined,
|
private array $devices,
|
||||||
array $backupVolumes,
|
/** @var string[] */
|
||||||
array $nextcloudExecCommands,
|
private array $capAdd,
|
||||||
bool $readOnlyRootFs,
|
private int $shmSize,
|
||||||
array $tmpfs,
|
private bool $apparmorUnconfined,
|
||||||
bool $init,
|
/** @var string[] */
|
||||||
string $imageTag,
|
private array $backupVolumes,
|
||||||
AioVariables $aioVariables,
|
private array $nextcloudExecCommands,
|
||||||
string $documentation,
|
private bool $readOnlyRootFs,
|
||||||
DockerActionManager $dockerActionManager
|
private array $tmpfs,
|
||||||
|
private bool $init,
|
||||||
|
private string $imageTag,
|
||||||
|
private AioVariables $aioVariables,
|
||||||
|
private string $documentation,
|
||||||
|
private DockerActionManager $dockerActionManager
|
||||||
) {
|
) {
|
||||||
$this->identifier = $identifier;
|
|
||||||
$this->displayName = $displayName;
|
|
||||||
$this->containerName = $containerName;
|
|
||||||
$this->restartPolicy = $restartPolicy;
|
|
||||||
$this->maxShutdownTime = $maxShutdownTime;
|
|
||||||
$this->ports = $ports;
|
|
||||||
$this->internalPorts = $internalPorts;
|
|
||||||
$this->volumes = $volumes;
|
|
||||||
$this->containerEnvironmentVariables = $containerEnvironmentVariables;
|
|
||||||
$this->dependsOn = $dependsOn;
|
|
||||||
$this->secrets = $secrets;
|
|
||||||
$this->devices = $devices;
|
|
||||||
$this->capAdd = $capAdd;
|
|
||||||
$this->shmSize = $shmSize;
|
|
||||||
$this->apparmorUnconfined = $apparmorUnconfined;
|
|
||||||
$this->backupVolumes = $backupVolumes;
|
|
||||||
$this->nextcloudExecCommands = $nextcloudExecCommands;
|
|
||||||
$this->readOnlyRootFs = $readOnlyRootFs;
|
|
||||||
$this->tmpfs = $tmpfs;
|
|
||||||
$this->init = $init;
|
|
||||||
$this->imageTag = $imageTag;
|
|
||||||
$this->aioVariables = $aioVariables;
|
|
||||||
$this->documentation = $documentation;
|
|
||||||
$this->dockerActionManager = $dockerActionManager;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function GetIdentifier() : string {
|
public function GetIdentifier() : string {
|
||||||
|
|
|
||||||
|
|
@ -3,17 +3,10 @@
|
||||||
namespace AIO\Container;
|
namespace AIO\Container;
|
||||||
|
|
||||||
class ContainerPort {
|
class ContainerPort {
|
||||||
public string $port;
|
|
||||||
public string $ipBinding;
|
|
||||||
public string $protocol;
|
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
string $port,
|
public string $port,
|
||||||
string $ipBinding,
|
public string $ipBinding,
|
||||||
string $protocol
|
public string $protocol
|
||||||
) {
|
) {
|
||||||
$this->port = $port;
|
|
||||||
$this->ipBinding = $ipBinding;
|
|
||||||
$this->protocol = $protocol;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,17 +3,10 @@
|
||||||
namespace AIO\Container;
|
namespace AIO\Container;
|
||||||
|
|
||||||
class ContainerVolume {
|
class ContainerVolume {
|
||||||
public string $name;
|
|
||||||
public string $mountPoint;
|
|
||||||
public bool $isWritable;
|
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
string $name,
|
public string $name,
|
||||||
string $mountPoint,
|
public string $mountPoint,
|
||||||
bool $isWritable
|
public bool $isWritable
|
||||||
) {
|
) {
|
||||||
$this->name = $name;
|
|
||||||
$this->mountPoint = $mountPoint;
|
|
||||||
$this->isWritable = $isWritable;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,18 +14,11 @@ use AIO\Data\ConfigurationManager;
|
||||||
use AIO\Data\DataConst;
|
use AIO\Data\DataConst;
|
||||||
use AIO\Docker\DockerActionManager;
|
use AIO\Docker\DockerActionManager;
|
||||||
|
|
||||||
class ContainerDefinitionFetcher
|
readonly class ContainerDefinitionFetcher {
|
||||||
{
|
|
||||||
private ConfigurationManager $configurationManager;
|
|
||||||
private \DI\Container $container;
|
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
ConfigurationManager $configurationManager,
|
private ConfigurationManager $configurationManager,
|
||||||
\DI\Container $container
|
private \DI\Container $container
|
||||||
)
|
) {
|
||||||
{
|
|
||||||
$this->configurationManager = $configurationManager;
|
|
||||||
$this->container = $container;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function GetContainerById(string $id): Container
|
public function GetContainerById(string $id): Container
|
||||||
|
|
|
||||||
|
|
@ -9,14 +9,10 @@ use AIO\Docker\DockerActionManager;
|
||||||
use Psr\Http\Message\ResponseInterface as Response;
|
use Psr\Http\Message\ResponseInterface as Response;
|
||||||
use Psr\Http\Message\ServerRequestInterface as Request;
|
use Psr\Http\Message\ServerRequestInterface as Request;
|
||||||
|
|
||||||
class ConfigurationController
|
readonly class ConfigurationController {
|
||||||
{
|
|
||||||
private ConfigurationManager $configurationManager;
|
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
ConfigurationManager $configurationManager
|
private ConfigurationManager $configurationManager
|
||||||
) {
|
) {
|
||||||
$this->configurationManager = $configurationManager;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function SetConfig(Request $request, Response $response, array $args) : Response {
|
public function SetConfig(Request $request, Response $response, array $args) : Response {
|
||||||
|
|
|
||||||
|
|
@ -9,21 +9,14 @@ use Psr\Http\Message\ResponseInterface as Response;
|
||||||
use Psr\Http\Message\ServerRequestInterface as Request;
|
use Psr\Http\Message\ServerRequestInterface as Request;
|
||||||
use AIO\Data\ConfigurationManager;
|
use AIO\Data\ConfigurationManager;
|
||||||
|
|
||||||
class DockerController
|
readonly class DockerController {
|
||||||
{
|
|
||||||
private DockerActionManager $dockerActionManager;
|
|
||||||
private ContainerDefinitionFetcher $containerDefinitionFetcher;
|
|
||||||
private const string TOP_CONTAINER = 'nextcloud-aio-apache';
|
private const string TOP_CONTAINER = 'nextcloud-aio-apache';
|
||||||
private ConfigurationManager $configurationManager;
|
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
DockerActionManager $dockerActionManager,
|
private DockerActionManager $dockerActionManager,
|
||||||
ContainerDefinitionFetcher $containerDefinitionFetcher,
|
private ContainerDefinitionFetcher $containerDefinitionFetcher,
|
||||||
ConfigurationManager $configurationManager
|
private ConfigurationManager $configurationManager
|
||||||
) {
|
) {
|
||||||
$this->dockerActionManager = $dockerActionManager;
|
|
||||||
$this->containerDefinitionFetcher = $containerDefinitionFetcher;
|
|
||||||
$this->configurationManager = $configurationManager;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function PerformRecursiveContainerStart(string $id, bool $pullImage = true) : void {
|
private function PerformRecursiveContainerStart(string $id, bool $pullImage = true) : void {
|
||||||
|
|
|
||||||
|
|
@ -9,14 +9,11 @@ use AIO\Docker\DockerActionManager;
|
||||||
use Psr\Http\Message\ResponseInterface as Response;
|
use Psr\Http\Message\ResponseInterface as Response;
|
||||||
use Psr\Http\Message\ServerRequestInterface as Request;
|
use Psr\Http\Message\ServerRequestInterface as Request;
|
||||||
|
|
||||||
class LoginController
|
readonly class LoginController {
|
||||||
{
|
public function __construct(
|
||||||
private AuthManager $authManager;
|
private AuthManager $authManager,
|
||||||
private DockerActionManager $dockerActionManager;
|
private DockerActionManager $dockerActionManager,
|
||||||
|
) {
|
||||||
public function __construct(AuthManager $authManager, DockerActionManager $dockerActionManager) {
|
|
||||||
$this->authManager = $authManager;
|
|
||||||
$this->dockerActionManager = $dockerActionManager;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function TryLogin(Request $request, Response $response, array $args) : Response {
|
public function TryLogin(Request $request, Response $response, array $args) : Response {
|
||||||
|
|
|
||||||
|
|
@ -4,16 +4,11 @@ namespace AIO\Data;
|
||||||
|
|
||||||
use AIO\Auth\PasswordGenerator;
|
use AIO\Auth\PasswordGenerator;
|
||||||
|
|
||||||
class Setup
|
readonly class Setup {
|
||||||
{
|
|
||||||
private PasswordGenerator $passwordGenerator;
|
|
||||||
private ConfigurationManager $configurationManager;
|
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
PasswordGenerator $passwordGenerator,
|
private PasswordGenerator $passwordGenerator,
|
||||||
ConfigurationManager $configurationManager) {
|
private ConfigurationManager $configurationManager,
|
||||||
$this->passwordGenerator = $passwordGenerator;
|
) {
|
||||||
$this->configurationManager = $configurationManager;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function Setup() : string {
|
public function Setup() : string {
|
||||||
|
|
|
||||||
|
|
@ -13,34 +13,21 @@ use AIO\Container\State\VersionDifferentState;
|
||||||
use AIO\Container\State\StoppedState;
|
use AIO\Container\State\StoppedState;
|
||||||
use AIO\Container\State\VersionEqualState;
|
use AIO\Container\State\VersionEqualState;
|
||||||
use AIO\Data\ConfigurationManager;
|
use AIO\Data\ConfigurationManager;
|
||||||
|
use GuzzleHttp\Client;
|
||||||
use GuzzleHttp\Exception\RequestException;
|
use GuzzleHttp\Exception\RequestException;
|
||||||
use AIO\ContainerDefinitionFetcher;
|
use AIO\ContainerDefinitionFetcher;
|
||||||
use http\Env\Response;
|
use http\Env\Response;
|
||||||
|
|
||||||
class DockerActionManager
|
readonly class DockerActionManager {
|
||||||
{
|
|
||||||
private const string API_VERSION = 'v1.41';
|
private const string API_VERSION = 'v1.41';
|
||||||
private \GuzzleHttp\Client $guzzleClient;
|
private Client $guzzleClient;
|
||||||
private ConfigurationManager $configurationManager;
|
|
||||||
private ContainerDefinitionFetcher $containerDefinitionFetcher;
|
|
||||||
private DockerHubManager $dockerHubManager;
|
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
ConfigurationManager $configurationManager,
|
private ConfigurationManager $configurationManager,
|
||||||
ContainerDefinitionFetcher $containerDefinitionFetcher,
|
private ContainerDefinitionFetcher $containerDefinitionFetcher,
|
||||||
DockerHubManager $dockerHubManager
|
private DockerHubManager $dockerHubManager
|
||||||
) {
|
) {
|
||||||
$this->configurationManager = $configurationManager;
|
$this->guzzleClient = new Client(['curl' => [CURLOPT_UNIX_SOCKET_PATH => '/var/run/docker.sock']]);
|
||||||
$this->containerDefinitionFetcher = $containerDefinitionFetcher;
|
|
||||||
$this->dockerHubManager = $dockerHubManager;
|
|
||||||
$this->guzzleClient = new \GuzzleHttp\Client(
|
|
||||||
[
|
|
||||||
'curl' => [
|
|
||||||
CURLOPT_UNIX_SOCKET_PATH => '/var/run/docker.sock',
|
|
||||||
|
|
||||||
],
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function BuildApiUrl(string $url) : string {
|
private function BuildApiUrl(string $url) : string {
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,11 @@ use AIO\ContainerDefinitionFetcher;
|
||||||
use AIO\Data\ConfigurationManager;
|
use AIO\Data\ConfigurationManager;
|
||||||
use GuzzleHttp\Client;
|
use GuzzleHttp\Client;
|
||||||
|
|
||||||
class DockerHubManager
|
readonly class DockerHubManager {
|
||||||
{
|
|
||||||
private Client $guzzleClient;
|
private Client $guzzleClient;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct(
|
||||||
{
|
) {
|
||||||
$this->guzzleClient = new Client();
|
$this->guzzleClient = new Client();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,12 +8,10 @@ use Psr\Http\Message\ResponseInterface;
|
||||||
use Psr\Http\Message\ServerRequestInterface;
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
use Psr\Http\Server\RequestHandlerInterface;
|
use Psr\Http\Server\RequestHandlerInterface;
|
||||||
|
|
||||||
class AuthMiddleware
|
readonly class AuthMiddleware {
|
||||||
{
|
public function __construct(
|
||||||
private AuthManager $authManager;
|
private AuthManager $authManager
|
||||||
|
) {
|
||||||
public function __construct(AuthManager $authManager) {
|
|
||||||
$this->authManager = $authManager;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __invoke(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
|
public function __invoke(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
|
||||||
|
|
|
||||||
|
|
@ -3,17 +3,13 @@
|
||||||
namespace AIO\Twig;
|
namespace AIO\Twig;
|
||||||
|
|
||||||
use Slim\Csrf\Guard;
|
use Slim\Csrf\Guard;
|
||||||
|
use Twig\Extension\AbstractExtension;
|
||||||
|
use Twig\Extension\GlobalsInterface;
|
||||||
|
|
||||||
class CsrfExtension extends \Twig\Extension\AbstractExtension implements \Twig\Extension\GlobalsInterface
|
class CsrfExtension extends AbstractExtension implements GlobalsInterface {
|
||||||
{
|
public function __construct(
|
||||||
/**
|
protected Guard $csrf
|
||||||
* @var Guard
|
) {
|
||||||
*/
|
|
||||||
protected Guard $csrf;
|
|
||||||
|
|
||||||
public function __construct(Guard $csrf)
|
|
||||||
{
|
|
||||||
$this->csrf = $csrf;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getGlobals() : array
|
public function getGlobals() : array
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue