Skip to content

Commit 0274775

Browse files
authored
Merge pull request #9 from ByteInternet/configuration_deprecations
Configuration deprecations
2 parents 366aa0d + f8f945e commit 0274775

File tree

4 files changed

+98
-178
lines changed

4 files changed

+98
-178
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
/.idea
33
.DS_Store
44
/*.iml
5+
composer.lock

composer.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,9 @@
1414
},
1515
"conflict": {
1616
"hipex/deploy-configuration": "*"
17+
},
18+
"require": {
19+
"deployer/deployer": "^6.8",
20+
"psr/log": "^1.0"
1721
}
1822
}

src/Configuration.php

Lines changed: 42 additions & 178 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
use Hypernode\DeployConfiguration\Command\Command;
66
use Hypernode\DeployConfiguration\Command\DeployCommand;
7+
use Hypernode\DeployConfiguration\Logging\SimpleLogger;
8+
use Psr\Log\LoggerInterface;
9+
use Psr\Log\LogLevel;
710

811
class Configuration
912
{
@@ -95,13 +98,15 @@ class Configuration
9598
* Server configurations to automatically provision from your repository to the Hypernode platform
9699
*
97100
* @var array
101+
* @deprecated Platform configuration is not supported on the Hypernode platform at the moment and configuration will not be taken into account
98102
*/
99103
private $platformConfigurations = [];
100104

101105
/**
102106
* Addition services to run
103107
*
104108
* @var array
109+
* @deprecated Platform service configuration is not supported on the Hypernode platform at the moment and configuration will not be taken into account
105110
*/
106111
private $platformServices = [];
107112

@@ -137,72 +142,14 @@ class Configuration
137142
private $logDir = 'var/log';
138143

139144
/**
140-
* Docker imaged used as base to build docker image for PHP-FPM container. Used as docker `FROM` directive. When empty
141-
* Hipex base image will be used `registry.hipex.cloud/hipex-services/docker-image-php/<version>-fpm`. The PHP version
142-
* will be replaced based on `$phpVersion` configuration.
143-
*
144-
* @var string|null
145-
* @deprecated DaaS is not supported on Hypernode platform and configuration will not be taken into account
146-
*/
147-
private $dockerBaseImagePhp;
148-
149-
/**
150-
* Docker imaged used as base to build docker image for nginx container. Used as docker `FROM` directive. When empty
151-
* Hipex base image `registry.hipex.cloud/hipex-services/docker-image-nginx` will be used.
152-
*
153-
* @var string|null
154-
* @deprecated DaaS is not supported on Hypernode platform and configuration will not be taken into account
155-
*/
156-
private $dockerBaseImageNginx;
157-
158-
/**
159-
* Name of the docker image to build, excluding registry. When empty will try these env variables:
160-
* - $CI_PROJECT_PATH
161-
* - $BITBUCKET_REPO_SLUG
162-
*
163-
* The final image will have a /php or /nginx added
164-
*
165-
* @var string|null
166-
* @deprecated DaaS is not supported on Hypernode platform and configuration will not be taken into account
167-
*/
168-
private $dockerImage;
169-
170-
/**
171-
* Registry to push build docker image to. When empty will use `$CI_REGISTRY`.
172-
*
173-
* @var string|null
174-
* @deprecated DaaS is not supported on Hypernode platform and configuration will not be taken into account
175-
*/
176-
private $dockerRegistry;
177-
178-
/**
179-
* Docker registry username. When empty will `CI_REGISTRY_USER` env variables or just skip login.
180-
*
181-
* @var string|null
182-
* @deprecated DaaS is not supported on Hypernode platform and configuration will not be taken into account
183-
*/
184-
private $dockerRegistryUsername;
185-
186-
/**
187-
* Docker registry username. When empty will `CI_REGISTRY_PASSWORD` env variables or just skip login.
188-
*
189-
* @var string|null
190-
* @deprecated DaaS is not supported on Hypernode platform and configuration will not be taken into account
191-
*/
192-
private $dockerRegistryPassword;
193-
194-
/**
195-
* When DevOps As A Service is enabled a `.hipex-cloud.json` file is generated and uploaded to the production
196-
* environment. This file is required for features like Hybrid Cloud.
197-
*
198-
* @var bool
199-
* @deprecated DaaS is not supported on Hypernode platform and configuration will not be taken into account
145+
* @var LoggerInterface
200146
*/
201-
private $daasEnabled = false;
147+
private $logger;
202148

203149
public function __construct(string $gitRepository)
204150
{
205151
$this->gitRepository = $gitRepository;
152+
$this->logger = new SimpleLogger(LogLevel::INFO);
206153
}
207154

208155
public function getGitRepository(): string
@@ -444,18 +391,28 @@ public function addAfterDeployTask(TaskConfigurationInterface $taskConfig): self
444391

445392
/**
446393
* @return TaskConfigurationInterface[]
394+
* @deprecated Platform configuration is not supported on the Hypernode platform at the moment and configuration will not be taken into account
447395
*/
448396
public function getPlatformConfigurations(): array
449397
{
398+
$this->logger->warning(
399+
"Platform configuration is not supported on the Hypernode platform at the moment and configuration will not be taken into account"
400+
);
401+
450402
return $this->platformConfigurations;
451403
}
452404

453405
/**
454406
* @param TaskConfigurationInterface[] $platformConfigurations
455407
* @return $this
408+
* @deprecated Platform configuration is not supported on the Hypernode platform at the moment and configuration will not be taken into account
456409
*/
457410
public function setPlatformConfigurations(array $platformConfigurations): self
458411
{
412+
$this->logger->warning(
413+
"Platform configuration is not supported on the Hypernode platform at the moment and configuration will not be taken into account"
414+
);
415+
459416
$this->platformConfigurations = [];
460417
foreach ($platformConfigurations as $serverConfiguration) {
461418
$this->addPlatformConfiguration($serverConfiguration);
@@ -465,27 +422,42 @@ public function setPlatformConfigurations(array $platformConfigurations): self
465422

466423
/**
467424
* @return Configuration
425+
* @deprecated Platform configuration is not supported on the Hypernode platform at the moment and configuration will not be taken into account
468426
*/
469427
public function addPlatformConfiguration(TaskConfigurationInterface $platformConfiguration): self
470428
{
429+
$this->logger->warning(
430+
"Platform configuration is not supported on the Hypernode platform at the moment and configuration will not be taken into account"
431+
);
432+
471433
$this->platformConfigurations[] = $platformConfiguration;
472434
return $this;
473435
}
474436

475437
/**
476438
* @return TaskConfigurationInterface[]
439+
* @deprecated Platform service configuration is not supported on the Hypernode platform at the moment and configuration will not be taken into account
477440
*/
478441
public function getPlatformServices(): array
479442
{
443+
$this->logger->warning(
444+
"Platform service configuration is not supported on the Hypernode platform at the moment and configuration will not be taken into account"
445+
);
446+
480447
return $this->platformServices;
481448
}
482449

483450
/**
484451
* @param TaskConfigurationInterface[] $platformServices
485452
* @return $this
453+
* @deprecated Platform service configuration is not supported on the Hypernode platform at the moment and configuration will not be taken into account
486454
*/
487455
public function setPlatformServices(array $platformServices): self
488456
{
457+
$this->logger->warning(
458+
"Platform service configuration is not supported on the Hypernode platform at the moment and configuration will not be taken into account"
459+
);
460+
489461
$this->platformServices = [];
490462
foreach ($platformServices as $platformService) {
491463
$this->addPlatformService($platformService);
@@ -495,9 +467,14 @@ public function setPlatformServices(array $platformServices): self
495467

496468
/**
497469
* @return Configuration
470+
* @deprecated Platform service configuration is not supported on the Hypernode platform at the moment and configuration will not be taken into account
498471
*/
499472
public function addPlatformService(TaskConfigurationInterface $platformService): self
500473
{
474+
$this->logger->warning(
475+
"Platform service configuration is not supported on the Hypernode platform at the moment and configuration will not be taken into account"
476+
);
477+
501478
$this->platformServices[] = $platformService;
502479
return $this;
503480
}
@@ -569,126 +546,13 @@ public function setLogDir(string $logDir): void
569546
$this->logDir = $logDir;
570547
}
571548

572-
/**
573-
* @return string|null
574-
* @deprecated DaaS is not supported on Hypernode platform and configuration will not be taken into account
575-
*/
576-
public function getDockerBaseImagePhp(): ?string
577-
{
578-
return $this->dockerBaseImagePhp;
579-
}
580-
581-
/**
582-
* @param string|null $dockerBaseImagePhp
583-
* @deprecated DaaS is not supported on Hypernode platform and configuration will not be taken into account
584-
*/
585-
public function setDockerBaseImagePhp(?string $dockerBaseImagePhp): void
586-
{
587-
$this->dockerBaseImagePhp = $dockerBaseImagePhp;
588-
}
589-
590-
/**
591-
* @return string|null
592-
* @deprecated DaaS is not supported on Hypernode platform and configuration will not be taken into account
593-
*/
594-
public function getDockerBaseImageNginx(): ?string
595-
{
596-
return $this->dockerBaseImageNginx;
597-
}
598-
599-
/**
600-
* @param string|null $dockerBaseImageNginx
601-
* @deprecated DaaS is not supported on Hypernode platform and configuration will not be taken into account
602-
*/
603-
public function setDockerBaseImageNginx(?string $dockerBaseImageNginx): void
604-
{
605-
$this->dockerBaseImageNginx = $dockerBaseImageNginx;
606-
}
607-
608-
/**
609-
* @return string|null
610-
* @deprecated DaaS is not supported on Hypernode platform and configuration will not be taken into account
611-
*/
612-
public function getDockerImage(): ?string
613-
{
614-
return $this->dockerImage;
615-
}
616-
617-
/**
618-
* @param string|null $dockerImage
619-
* @deprecated
620-
*/
621-
public function setDockerImage(?string $dockerImage): void
622-
{
623-
$this->dockerImage = $dockerImage;
624-
}
625-
626-
/**
627-
* @return string|null
628-
*/
629-
public function getDockerRegistry(): ?string
630-
{
631-
return $this->dockerRegistry;
632-
}
633-
634-
/**
635-
* @param string|null $dockerRegistry
636-
* @deprecated DaaS is not supported on Hypernode platform and configuration will not be taken into account
637-
*/
638-
public function setDockerRegistry(?string $dockerRegistry): void
639-
{
640-
$this->dockerRegistry = $dockerRegistry;
641-
}
642-
643-
/**
644-
* @return string|null
645-
* @deprecated DaaS is not supported on Hypernode platform and configuration will not be taken into account
646-
*/
647-
public function getDockerRegistryUsername(): ?string
648-
{
649-
return $this->dockerRegistryUsername;
650-
}
651-
652-
/**
653-
* @param string|null $dockerRegistryUsername
654-
* @deprecated DaaS is not supported on Hypernode platform and configuration will not be taken into account
655-
*/
656-
public function setDockerRegistryUsername(?string $dockerRegistryUsername): void
657-
{
658-
$this->dockerRegistryUsername = $dockerRegistryUsername;
659-
}
660-
661-
/**
662-
* @return string|null
663-
* @deprecated DaaS is not supported on Hypernode platform and configuration will not be taken into account
664-
*/
665-
public function getDockerRegistryPassword(): ?string
549+
public function getLogger(): LoggerInterface
666550
{
667-
return $this->dockerRegistryPassword;
551+
return $this->logger;
668552
}
669553

670-
/**
671-
* @param string|null $dockerRegistryPassword
672-
* @deprecated DaaS is not supported on Hypernode platform and configuration will not be taken into account
673-
*/
674-
public function setDockerRegistryPassword(?string $dockerRegistryPassword): void
675-
{
676-
$this->dockerRegistryPassword = $dockerRegistryPassword;
677-
}
678-
679-
/**
680-
* @deprecated DaaS is not supported on Hypernode platform and configuration will not be taken into account
681-
*/
682-
public function isDaasEnabled(): bool
683-
{
684-
return $this->daasEnabled;
685-
}
686-
687-
/**
688-
* @deprecated DaaS is not supported on Hypernode platform and configuration will not be taken into account
689-
*/
690-
public function setDaasEnabled(bool $daasEnabled): void
554+
public function setLogger(LoggerInterface $logger): void
691555
{
692-
$this->daasEnabled = $daasEnabled;
556+
$this->logger = $logger;
693557
}
694558
}

src/Logging/SimpleLogger.php

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
namespace Hypernode\DeployConfiguration\Logging;
4+
5+
use Psr\Log\AbstractLogger;
6+
use Psr\Log\LogLevel;
7+
8+
/**
9+
* Simple logger implementation using printf
10+
*/
11+
class SimpleLogger extends AbstractLogger
12+
{
13+
private const LEVEL_MAPPING = [
14+
LogLevel::DEBUG => 0,
15+
LogLevel::INFO => 1,
16+
LogLevel::NOTICE => 2,
17+
LogLevel::WARNING => 3,
18+
LogLevel::ERROR => 4,
19+
LogLevel::CRITICAL => 5,
20+
LogLevel::ALERT => 6,
21+
LogLevel::EMERGENCY => 7
22+
];
23+
24+
/**
25+
* @var int
26+
*/
27+
private $mappedLevel;
28+
29+
public function __construct(string $level)
30+
{
31+
$this->mappedLevel = self::LEVEL_MAPPING[$level] ?? 1;
32+
}
33+
34+
/**
35+
* @param mixed $level
36+
* @param string|\Stringable $message
37+
* @param mixed[] $context
38+
* @return void
39+
*/
40+
public function log($level, $message, array $context = array())
41+
{
42+
if ($this->mapLevelToNumber($level) ?? 1 >= $this->mappedLevel) {
43+
printf("%s (%s)\n", $message, json_encode($context));
44+
}
45+
}
46+
47+
private static function mapLevelToNumber(string $level): int
48+
{
49+
return self::LEVEL_MAPPING[$level] ?? 1;
50+
}
51+
}

0 commit comments

Comments
 (0)