Skip to content

Commit 9c82b84

Browse files
oshmyheliukshiftedreality
authored andcommitted
MAGECLOUD-2886: [Cloud Docker] Add Redis 3.2 and 4.0 (#376)
1 parent 0035665 commit 9c82b84

File tree

8 files changed

+62
-72
lines changed

8 files changed

+62
-72
lines changed

src/Command/Docker/Build.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class Build extends Command
2727
const OPTION_PHP = 'php';
2828
const OPTION_NGINX = 'nginx';
2929
const OPTION_DB = 'db';
30+
const OPTION_REDIS = 'redis';
3031
const OPTION_ES = 'es';
3132
const OPTION_RABBIT_MQ = 'rmq';
3233

@@ -97,6 +98,12 @@ protected function configure()
9798
InputOption::VALUE_OPTIONAL,
9899
'DB version',
99100
BuilderInterface::DEFAULT_DB_VERSION
101+
)->addOption(
102+
self::OPTION_REDIS,
103+
null,
104+
InputOption::VALUE_OPTIONAL,
105+
'Redis version',
106+
BuilderInterface::DEFAULT_REDIS_VERSION
100107
)->addOption(
101108
self::OPTION_ES,
102109
null,
@@ -151,6 +158,10 @@ public function execute(InputInterface $input, OutputInterface $output)
151158
$builder->setDbVersion($dbVersion);
152159
}
153160

161+
if ($redisVersion = $input->getOption(self::OPTION_REDIS)) {
162+
$builder->setRedisVersion($redisVersion);
163+
}
164+
154165
if ($esVersion = $input->getOption(self::OPTION_ES)) {
155166
$builder->setESVersion($esVersion);
156167
}

src/Docker/BuilderInterface.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,16 @@ interface BuilderInterface
1818

1919
const RABBIT_MQ_VERSIONS = ['3.5', '3.7'];
2020
const DEFAULT_RABBIT_MQ_VERSION = '3.5';
21+
const REDIS_VERSIONS = ['3.2', '4.0'];
2122

2223
const DEFAULT_NGINX_VERSION = 'latest';
2324
const DEFAULT_DB_VERSION = '10';
25+
const DEFAULT_REDIS_VERSION = '3.2';
2426

2527
const PHP_VERSION = 'php.version';
2628
const NGINX_VERSION = 'nginx.version';
2729
const DB_VERSION = 'db.version';
30+
const REDIS_VERSION = 'redis.version';
2831
const ES_VERSION = 'es.version';
2932
const RABBIT_MQ_VERSION = 'rmq.version';
3033

@@ -51,6 +54,12 @@ public function setNginxVersion(string $version);
5154
*/
5255
public function setDbVersion(string $version);
5356

57+
/**
58+
* @param string $version
59+
* @throws ConfigurationMismatchException
60+
*/
61+
public function setRedisVersion(string $version);
62+
5463
/**
5564
* @param string $version
5665
* @throws ConfigurationMismatchException

src/Docker/DevBuilder.php

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,14 @@ public function setDbVersion(string $version)
6363
]);
6464
}
6565

66+
/**
67+
* @inheritdoc
68+
*/
69+
public function setRedisVersion(string $version)
70+
{
71+
$this->setVersion(self::REDIS_VERSION, $version, self::REDIS_VERSIONS);
72+
}
73+
6674
/**
6775
* @inheritdoc
6876
*/
@@ -110,7 +118,7 @@ public function build(): array
110118
'version' => '2',
111119
'services' => [
112120
'varnish' => $this->serviceFactory->create(ServiceFactory::SERVICE_VARNISH)->get(),
113-
'redis' => $this->serviceFactory->create(ServiceFactory::SERVICE_REDIS)->get(),
121+
'redis' => $this->getRedisService(),
114122
'elasticsearch' => $this->getElasticSearchService(),
115123
'rabbitmq' => $this->getRabbitMQService(),
116124
'fpm' => $this->getFpmService(),
@@ -160,6 +168,24 @@ private function getRabbitMQService(): array
160168
];
161169
}
162170

171+
/**
172+
* @return array
173+
*/
174+
private function getRedisService(): array
175+
{
176+
$version = $this->config->get(self::REDIS_VERSION, self::DEFAULT_REDIS_VERSION);
177+
178+
return [
179+
'image' => 'redis:' . $version,
180+
'volumes' => [
181+
'/data',
182+
],
183+
'ports' => [
184+
6379,
185+
],
186+
];
187+
}
188+
163189
/**
164190
* @param bool $isReadOnly
165191
* @return string

src/Docker/IntegrationBuilder.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,17 @@ public function setDbVersion(string $version)
6060
]);
6161
}
6262

63+
/**
64+
* @param string $version
65+
* @throws ConfigurationMismatchException
66+
*/
67+
public function setRedisVersion(string $version)
68+
{
69+
$this->setVersion(self::REDIS_VERSION, $version, [
70+
self::DEFAULT_REDIS_VERSION,
71+
]);
72+
}
73+
6374
/**
6475
* @inheritdoc
6576
*/

src/Docker/Service/RedisService.php

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/Docker/Service/ServiceFactory.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,13 @@
1313
class ServiceFactory
1414
{
1515
const SERVICE_VARNISH = 'varnish';
16-
const SERVICE_REDIS = 'redis';
1716
const SERVICE_RABBITMQ = 'rabbitmq';
1817

1918
/**
2019
* @var array
2120
*/
2221
private static $map = [
2322
self::SERVICE_VARNISH => VarnishService::class,
24-
self::SERVICE_REDIS => RedisService::class,
2523
self::SERVICE_RABBITMQ => RabbitMqService::class,
2624
];
2725

src/Test/Unit/Command/Docker/BuildTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ public function testExecuteWithParams()
139139
[Build::OPTION_PHP, '7.1'],
140140
[Build::OPTION_DB, '10'],
141141
[Build::OPTION_NGINX, '1.9'],
142+
[Build::OPTION_REDIS, '3.2'],
142143
[Build::OPTION_ES, '2.4'],
143144
[Build::OPTION_RABBIT_MQ, '3.5'],
144145
[Build::OPTION_IS_TEST, false],
@@ -149,6 +150,9 @@ public function testExecuteWithParams()
149150
$this->builderMock->expects($this->once())
150151
->method('setNginxVersion')
151152
->with('1.9');
153+
$this->builderMock->expects($this->once())
154+
->method('setRedisVersion')
155+
->with('3.2');
152156
$this->builderMock->expects($this->once())
153157
->method('setDbVersion')
154158
->with('10');

src/Test/Unit/Docker/Service/RedisServiceTest.php

Lines changed: 0 additions & 41 deletions
This file was deleted.

0 commit comments

Comments
 (0)