Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Commit ec2549f

Browse files
author
svensp
committed
#5 added -p to enable force pulling
1 parent 478c6ab commit ec2549f

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

app/Commands/PushCommand.php

+2
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ protected function configure() {
122122
->addArgument('environment', InputArgument::REQUIRED)
123123
->addArgument('version', InputArgument::REQUIRED)
124124
->addOption('image-exists', 'i', InputOption::VALUE_NONE, 'Do not build and push the image to dockerhub')
125+
->addOption('pull', 'p', InputOption::VALUE_NONE, 'Request rancher to force pull the image before upgrading the service')
125126
;
126127
}
127128

@@ -143,6 +144,7 @@ protected function execute(InputInterface $input, OutputInterface $output) {
143144
$rancher = $this->rancherService;
144145
$rancher->setAccount($account)
145146
->setOutput($output)
147+
->setPullImages($input->getOption('pull'))
146148
->setProcessHelper( $this->getHelper('process'));
147149

148150
$stackName = $environmentConfig->get('rancher.stack');

app/RancherAccess/RancherService.php

+18-3
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ class RancherService {
4343
*/
4444
private $cliMode = false;
4545

46+
/**
47+
* @var bool
48+
*/
49+
protected $pullImages = false;
50+
4651
use ProcessTrait;
4752

4853

@@ -231,7 +236,6 @@ public function start(string $directory, string $stackName, array $serviceNames
231236
'-s',
232237
$stackName,
233238
'-d',
234-
'-p'
235239
];
236240
else
237241
$command = [
@@ -244,8 +248,9 @@ public function start(string $directory, string $stackName, array $serviceNames
244248
$stackName,
245249
'up',
246250
'-d',
247-
'-p'
248251
];
252+
if($this->pullImages)
253+
$command[] = '-p';
249254

250255
if($upgrade)
251256
$command = array_merge($command, ['--upgrade']);
@@ -488,7 +493,7 @@ public function stop(string $directory, string $stackName) {
488493
* @param string $serviceName
489494
* @param StateMatcher $stateMatcher defaults to SingleStateMatcher('active') - wait until active
490495
* @param Delayer $delayer defaults to FixedSleepDelayer(500000) - wait for half a second
491-
* @return string
496+
* @return array
492497
*/
493498
public function wait(string $stackName, string $serviceName, StateMatcher $stateMatcher = null, Delayer $delayer = null) {
494499
if($stateMatcher === null)
@@ -604,4 +609,14 @@ public function setCliMode( bool $cliMode ) {
604609
public function assertStackExists($stackName) {
605610
$this->getStackIdByName($stackName);
606611
}
612+
613+
/**
614+
* @param bool $pullImages
615+
* @return RancherService
616+
*/
617+
public function setPullImages(bool $pullImages): RancherService
618+
{
619+
$this->pullImages = $pullImages;
620+
return $this;
621+
}
607622
}

composer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
"symfony/yaml": "^3.1",
2424
"pimple/pimple": "^3.0",
2525
"symfony/process": "^3.1",
26-
"ipunkt/rancherize-php53": "^1.4.0"
26+
"ipunkt/rancherize-php53": "^1.4.0",
27+
"ext-json": "*"
2728
},
2829
"require-dev": {
2930
"phpunit/phpunit": "^5.6",

0 commit comments

Comments
 (0)