Skip to content

Commit

Permalink
Merge branch 'master' into release
Browse files Browse the repository at this point in the history
* master:
  Updated changelog
  Closes #157 Allowing template to include environmental variables
  • Loading branch information
REBELinBLUE committed Jan 28, 2016
2 parents 2c0ae2d + 4cef4c1 commit 112ff0d
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@

**Implemented enhancements:**

- Variables for templates [\#157](https://github.com/REBELinBLUE/deployer/issues/157)
- Add a console command to create a user [\#155](https://github.com/REBELinBLUE/deployer/issues/155)
- Add option to deploy only default branch [\#146](https://github.com/REBELinBLUE/deployer/issues/146)
- Option to include require-dev packages in composer install [\#143](https://github.com/REBELinBLUE/deployer/issues/143)
- Heartbeat should notify on recovery [\#130](https://github.com/REBELinBLUE/deployer/issues/130)
- Add an "Update available" prompt [\#148](https://github.com/REBELinBLUE/deployer/pull/148) ([REBELinBLUE](https://github.com/REBELinBLUE))

**Fixed bugs:**
Expand Down
1 change: 1 addition & 0 deletions app/Http/Controllers/Admin/TemplateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public function show($template_id)
'title' => $template->name,
'sharedFiles' => $template->sharedFiles,
'projectFiles' => $template->projectFiles,
'variables' => $template->variables,
'project' => $template,
'route' => 'template.commands',
]);
Expand Down
8 changes: 8 additions & 0 deletions app/Jobs/SetupProject.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use REBELinBLUE\Deployer\Project;
use REBELinBLUE\Deployer\ProjectFile;
use REBELinBLUE\Deployer\SharedFile;
use REBELinBLUE\Deployer\Variable;

/**
* A class to handle cloning the command templates for the project.
Expand Down Expand Up @@ -45,6 +46,13 @@ public function handle()
Command::create($data);
}

foreach ($template->variables as $variable) {
$data = $variable->toArray();
$data['project_id'] = $variable->project->id;

Variable::create($data);
}

foreach ($template->sharedFiles as $file) {
$data = $file->toArray();
$data['project_id'] = $this->project->id;
Expand Down
2 changes: 1 addition & 1 deletion app/Listeners/Events/NotifyDeploy.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
use Illuminate\Support\Facades\DB;
use REBELinBLUE\Deployer\Events\DeployFinished;
use REBELinBLUE\Deployer\Jobs\MailDeployNotification;
use REBELinBLUE\Deployer\Jobs\SlackNotify;
use REBELinBLUE\Deployer\Jobs\RequestProjectCheckUrl;
use REBELinBLUE\Deployer\Jobs\SlackNotify;

/**
* When a deploy finished, notify the followed user.
Expand Down
25 changes: 23 additions & 2 deletions app/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Template extends Model implements PresentableInterface
*
* @var array
*/
protected $visible = ['id', 'name', 'command_count', 'file_count', 'config_count'];
protected $visible = ['id', 'name', 'command_count', 'file_count', 'config_count', 'variable_count'];

/**
* The attributes that are mass assignable.
Expand All @@ -42,7 +42,7 @@ class Template extends Model implements PresentableInterface
*
* @var array
*/
protected $appends = ['command_count', 'file_count', 'config_count'];
protected $appends = ['command_count', 'file_count', 'config_count', 'variable_count'];

/**
* The attributes that should be casted to native types.
Expand Down Expand Up @@ -97,6 +97,17 @@ public function getConfigCountAttribute()
->count();
}

/**
* Define a accessor for the count of env variables.
*
* @return int
*/
public function getVariableCountAttribute()
{
return $this->variables()
->count();
}

/**
* Has many relationship.
*
Expand Down Expand Up @@ -127,6 +138,16 @@ public function projectFiles()
return $this->hasMany('REBELinBLUE\Deployer\ProjectFile', 'project_id');
}

/**
* Has many relationship.
*
* @return Variable
*/
public function variables()
{
return $this->hasMany('REBELinBLUE\Deployer\Variable', 'project_id');
}

/**
* Gets the view presenter.
*
Expand Down
9 changes: 8 additions & 1 deletion resources/views/admin/templates/details.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@
<div class="nav-tabs-custom">
<ul class="nav nav-tabs">
<li class="active"><a href="#hooks" data-toggle="tab"><span class="fa fa-terminal"></span> {{ Lang::get('commands.label') }}</a></li>
<li><a href="#variables" data-toggle="tab"><span class="fa fa-usd"></span> {{ Lang::get('variables.label') }}</a></li>
<li><a href="#shared-files" data-toggle="tab"><span class="fa fa-folder"></span> {{ Lang::get('sharedFiles.label') }}</a></li>
<li><a href="#project-files" data-toggle="tab"><span class="fa fa-file-code-o"></span> {{ Lang::get('projectFiles.label') }}</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="hooks">
@include('projects._partials.commands')
</div>
<div class="tab-pane" id="variables">
@include('projects._partials.variables')
</div>
<div class="tab-pane" id="shared-files">
@include('projects._partials.shared_files')
</div>
Expand All @@ -25,6 +29,7 @@
</div>

@include('dialogs.server')
@include('dialogs.variable')
@include('dialogs.shared_files')
@include('dialogs.project_files')
@stop
Expand All @@ -33,10 +38,12 @@
<script type="text/javascript">
new app.SharedFilesTab();
new app.ProjectFilesTab();
new app.VariablesTab();

app.SharedFiles.add({!! $sharedFiles->toJson() !!});
app.ProjectFiles.add({!! $projectFiles->toJson() !!});
app.Variables.add({!! $variables->toJson() !!});

app.project_id = {{ $project->id }};
</script>
@stop
@stop
4 changes: 3 additions & 1 deletion resources/views/admin/templates/listing.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<tr>
<th>{{ Lang::get('templates.name') }}</th>
<th>{{ Lang::get('commands.label') }}</th>
<th>{{ Lang::get('variables.label') }}</th>
<th>{{ Lang::get('sharedFiles.label') }}</th>
<th>{{ Lang::get('projectFiles.label') }}</th>
<th>&nbsp;</th>
Expand All @@ -30,6 +31,7 @@
<script type="text/template" id="template-template">
<td><%- name %></td>
<td><%- command_count %></td>
<td><%- variable_count %></td>
<td><%- file_count %></td>
<td><%- config_count %></td>
<td>
Expand Down Expand Up @@ -57,4 +59,4 @@
<div class="pull-right">
<button type="button" class="btn btn-default" title="{{ Lang::get('templates.create') }}" data-toggle="modal" data-target="#template"><span class="fa fa-plus"></span> {{ Lang::get('templates.create') }}</button>
</div>
@stop
@stop

0 comments on commit 112ff0d

Please sign in to comment.