Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita350bb1

Browse files
authored
Merge pull request#25 from betd-claumond/configurable_shared_folder
Add a shared_path configuration on server and using it in Context
2 parents8fc200b +b27d830 commita350bb1

File tree

8 files changed

+151
-1
lines changed

8 files changed

+151
-1
lines changed

‎src/Automate/Context/AbstractContext.php‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,14 @@ public function getReleasesPath(Server $server)
220220
*/
221221
publicfunctiongetSharedPath(Server$server)
222222
{
223-
return$server->getPath().'/shared';
223+
$serverSharedPath =$server->getSharedPath();
224+
225+
// if the shared path is not configured on the server configuration
226+
if (empty($serverSharedPath)) {
227+
$serverSharedPath =$server->getPath().'/shared';
228+
}
229+
230+
return$serverSharedPath;
224231
}
225232

226233
/**

‎src/Automate/Loader.php‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,11 @@ private function getSchema()
150150
'_required' =>true,
151151
'_not_empty' =>true,
152152
],
153+
'shared_path' => [
154+
'_type' =>'text',
155+
'_required' =>false,
156+
'_not_empty' =>true,
157+
],
153158
'port' => [
154159
'_type' =>'number'
155160
],

‎src/Automate/Model/Server.php‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ class Server
4747
*/
4848
private$path;
4949

50+
/**
51+
* @var string
52+
*/
53+
private$sharedPath;
54+
5055
/**
5156
* @var int
5257
*/
@@ -172,6 +177,26 @@ public function setPath($path)
172177
return$this;
173178
}
174179

180+
/**
181+
* @return string
182+
*/
183+
publicfunctiongetSharedPath()
184+
{
185+
return$this->sharedPath;
186+
}
187+
188+
/**
189+
* @param string $sharedPath
190+
*
191+
* @return Server
192+
*/
193+
publicfunctionsetSharedPath($sharedPath)
194+
{
195+
$this->sharedPath =$sharedPath;
196+
197+
return$this;
198+
}
199+
175200
/**
176201
* @return int
177202
*/

‎src/Automate/Serializer/ServerDenormalizer.php‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public function denormalize($data, $class, $format = null, array $context = arra
3434
->setSshKey($this->extractValue($data,'ssh_key'))
3535
->setPassword($this->extractValue($data,'password',""))
3636
->setPath($this->extractValue($data,'path'))
37+
->setSharedPath($this->extractValue($data,'shared_path'))
3738
->setPort($this->extractValue($data,'port',22))
3839
;
3940

‎tests/Automate/AbstractContextTest.php‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,20 @@ protected function createLocalContext(LoggerInterface $logger, $gitRef = null)
5050

5151
return$context;
5252
}
53+
54+
protectedfunctioncreateContextWithServerSharedPath(SessionInterface$session,LoggerInterface$logger,$gitRef =null)
55+
{
56+
$loader =newLoader();
57+
$project =$loader->load(__DIR__ .'/../fixtures/simpleWithSharedPath.yml');
58+
$platform =$project->getPlatform('development');
59+
60+
$sessionFactory = Phake::mock(SessionFactory::class);
61+
Phake::when($sessionFactory)->create(current($platform->getServers()))->thenReturn($session);
62+
63+
$context =newSSHContext($project,$platform,$gitRef,$logger,false);
64+
$context->setSessionFactory($sessionFactory);
65+
$context->connect();
66+
67+
return$context;
68+
}
5369
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
3+
namespaceAutomate\Tests\Context;
4+
5+
useAutomate\Context\ContextInterface;
6+
useAutomate\Logger\ConsoleLogger;
7+
useAutomate\Model\Server;
8+
useAutomate\Session\SSHSession;
9+
useAutomate\Tests\AbstractContextTest;
10+
usePhake;
11+
usephpseclib\Net\SSH2;
12+
13+
class ContextTestextends AbstractContextTest
14+
{
15+
publicfunctiontestSimpleContext()
16+
{
17+
$logger = Phake::mock(ConsoleLogger::class);
18+
19+
$ssh = Phake::mock(SSH2::class);
20+
Phake::when($ssh)->getExitStatus()->thenReturn(1);
21+
22+
$session =newSSHSession($ssh);
23+
$context =$this->createContext($session,$logger);
24+
25+
$server =$this->getServerFromContext($context);
26+
27+
$this->assertEquals('/home/wwwroot/automate/demo/shared',$context->getSharedPath($server));
28+
}
29+
30+
publicfunctiontestSimpleWithSharedPathContext()
31+
{
32+
$logger = Phake::mock(ConsoleLogger::class);
33+
34+
$ssh = Phake::mock(SSH2::class);
35+
Phake::when($ssh)->getExitStatus()->thenReturn(1);
36+
37+
$session =newSSHSession($ssh);
38+
$context =$this->createContextWithServerSharedPath($session,$logger);
39+
40+
$server =$this->getServerFromContext($context);
41+
42+
$this->assertEquals('/home/wwwroot/shared',$context->getSharedPath($server));
43+
}
44+
45+
/**
46+
* @param ContextInterface $context
47+
*
48+
* @return Server
49+
*/
50+
privatefunctiongetServerFromContext(ContextInterface$context)
51+
{
52+
$project =$context->getProject();
53+
54+
$platform =$project->getPlatform('development');
55+
56+
/** @var Server $server */
57+
$server =current($platform->getServers());
58+
59+
return$server;
60+
}
61+
}

‎tests/Automate/LoaderTest.php‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,18 @@ public function testLoader()
7272
$this->assertEquals('%dev_password%',$server->getPassword());
7373
$this->assertEquals('/home/wwwroot/automate/demo',$server->getPath());
7474
}
75+
76+
publicfunctiontestSharedPathLoader()
77+
{
78+
$loder =newLoader();
79+
80+
$project =$loder->load(__DIR__ .'/../fixtures/simpleWithSharedPath.yml');
81+
82+
$platform =$project->getPlatform('development');
83+
84+
/** @var Server $server */
85+
$server =current($platform->getServers());
86+
87+
$this->assertEquals('/home/wwwroot/shared',$server->getSharedPath());
88+
}
7589
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
repository:git@github.com:julienj/symfony-demo.git
2+
3+
platforms:
4+
development:
5+
default_branch:master
6+
max_releases:3
7+
servers:
8+
dddv-exemple-front-01:
9+
host:127.0.0.1
10+
user:automate
11+
password:p@ssw0rd
12+
path:/home/wwwroot/automate/demo
13+
shared_path:/home/wwwroot/shared
14+
shared_files:
15+
-app/config/parameters.yml
16+
shared_folders:
17+
-app/data
18+
pre_deploy:
19+
-"php -v"
20+
on_deploy:
21+
-"composer install"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp