Skip to content

Commit 3a69687

Browse files
committed
Merge pull request #373 from pantheon-systems/deploy_live_content
During deploy, ensure only Live content can be cloned to Test
2 parents 92ae6dd + 0ad0a59 commit 3a69687

File tree

5 files changed

+20
-29
lines changed

5 files changed

+20
-29
lines changed

php/Terminus/Environment.php

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -388,21 +388,13 @@ private function element_as_database($element) {
388388
}
389389

390390
/**
391-
* Deploys the given environment
391+
* Deploys the Test or Live environment)
392392
*
393-
* @param [array] $args Arguments for deployment
394-
* [string] $args['from'] Environment from which to deploy
395-
* [string] $args['annotation'] Commit message
396-
* @return [array] Data from the request
393+
* @param [array] $params Parameters for the deploy workflow
394+
*
395+
* @return [workflow] workflow response
397396
*/
398-
public function deploy($args) {
399-
$default_params = array(
400-
'annotation' => 'Terminus deploy',
401-
'clone_database' => array('from_environment' => 'dev'),
402-
'clone_files' => array('from_environment' => 'dev'),
403-
);
404-
$params = array_merge($default_params, $args);
405-
397+
public function deploy($params) {
406398
$workflow = $this->site->workflows->create('deploy', array(
407399
'environment' => $this->id,
408400
'params' => $params

php/Terminus/Site.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -323,11 +323,6 @@ public function removeInstrument() {
323323
return $workflow;
324324
}
325325

326-
/**
327-
* Returns the environment's name
328-
*
329-
}
330-
331326
/**
332327
* Create a multidev environment
333328
*/

php/commands/site.php

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -781,10 +781,13 @@ public function delete_env($args, $assoc_args) {
781781
* : Site to deploy from
782782
*
783783
* [--env=<env>]
784-
* : Environment to deploy to
784+
* : Environment to be deployed (Test or Live)
785+
*
786+
* [--clone-live-content]
787+
* : If deploying test, copy content from Live
785788
*
786789
* [--from=<env>]
787-
* : Environment to deploy from
790+
* : [deprecated] Environment to deploy from (non-functional)
788791
*
789792
* [--cc]
790793
* : Clear cache after deploy?
@@ -803,11 +806,9 @@ public function deploy($args, $assoc_args) {
803806
'env',
804807
'Choose environment to deploy'
805808
));
806-
$from = Input::env(
807-
$assoc_args,
808-
'from',
809-
'Choose environment you want to deploy from'
810-
);
809+
810+
$clone_live_content = ($env->id == 'test' && isset($assoc_args['clone-live-content']));
811+
811812
if(!isset($assoc_args['note'])) {
812813
$annotation = Terminus::prompt(
813814
'Custom note for the deploy log',
@@ -824,10 +825,13 @@ public function deploy($args, $assoc_args) {
824825
'updatedb' => $updatedb,
825826
'clear_cache' => $cc,
826827
'annotation' => $annotation,
827-
'clone_database' => array('from_environment' => $from),
828-
'clone_files' => array('from_environment' => $from),
829828
);
830829

830+
if ($clone_live_content) {
831+
$params['clone_database'] = array('from_environment' => 'live');
832+
$params['clone_files'] = array('from_environment' => 'live');
833+
}
834+
831835
$workflow = $env->deploy($params);
832836
$workflow->wait();
833837

tests/features/deploy.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ Feature: Deploy
44
@vcr site-deploy
55
Given I am authenticated
66
And a site named "[[test_site_name]]"
7-
When I run "terminus site deploy --site=[[test_site_name]] --from=dev --env=test --note='Deploy test'"
7+
When I run "terminus site deploy --site=[[test_site_name]] --env=test --clone-live-content --note='Deploy test'"
88
Then I should get "Woot! Code deployed to test"

tests/fixtures/site-deploy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@
227227
User-Agent: 'Terminus/1.0.0 (php_version=5.5.26&script=boot-fs.php)'
228228
Cookie: 'X-Pantheon-Session=25069e79-eae7-4d41-8925-1f728a114cb8:50d069c4-3ae4-11e5-97ba-bc764e117665:XdwFVyCuTDtq4km6jNjnT'
229229
Content-type: application/json
230-
body: '{"type":"deploy","params":{"annotation":"Deploy test","clone_database":{"from_environment":"dev"},"clone_files":{"from_environment":"dev"},"updatedb":0,"clear_cache":0}}'
230+
body: '{"type":"deploy","params":{"updatedb":0,"clear_cache":0,"annotation":"Deploy test","clone_database":{"from_environment":"live"},"clone_files":{"from_environment":"live"}}}'
231231
response:
232232
status:
233233
http_version: '1.1'

0 commit comments

Comments
 (0)