-
Notifications
You must be signed in to change notification settings - Fork 86
Expand file tree
/
Copy pathSidecarServiceProvider.php
More file actions
68 lines (56 loc) · 2.12 KB
/
SidecarServiceProvider.php
File metadata and controls
68 lines (56 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
/**
* @author Aaron Francis <aaron@hammerstone.dev>
*/
namespace Hammerstone\Sidecar\Providers;
use Hammerstone\Sidecar\Clients\CloudWatchLogsClient;
use Hammerstone\Sidecar\Clients\Configurations\AwsClientConfiguration;
use Hammerstone\Sidecar\Clients\LambdaClient;
use Hammerstone\Sidecar\Clients\S3Client;
use Hammerstone\Sidecar\Commands\Activate;
use Hammerstone\Sidecar\Commands\Configure;
use Hammerstone\Sidecar\Commands\Deploy;
use Hammerstone\Sidecar\Commands\Install;
use Hammerstone\Sidecar\Commands\MakeLambdaFunction;
use Hammerstone\Sidecar\Commands\Warm;
use Hammerstone\Sidecar\Contracts\AwsClientConfiguration as AwsClientConfigurationContract;
use Hammerstone\Sidecar\Manager;
use Illuminate\Support\ServiceProvider;
class SidecarServiceProvider extends ServiceProvider
{
public function register()
{
$this->app->singleton(Manager::class);
$this->mergeConfigFrom(__DIR__ . '/../../config/sidecar.php', 'sidecar');
$this->app->bind(AwsClientConfigurationContract::class, AwsClientConfiguration::class);
$this->app->singleton(LambdaClient::class, function () {
return new LambdaClient($this->getAwsClientConfiguration());
});
$this->app->singleton(CloudWatchLogsClient::class, function () {
return new CloudWatchLogsClient($this->getAwsClientConfiguration());
});
$this->app->singleton(S3Client::class, function () {
return new S3Client($this->getAwsClientConfiguration());
});
}
protected function getAwsClientConfiguration()
{
return $this->app->make(AwsClientConfigurationContract::class)->getConfiguration();
}
public function boot()
{
if ($this->app->runningInConsole()) {
$this->commands([
Activate::class,
Configure::class,
Warm::class,
Deploy::class,
Install::class,
MakeLambdaFunction::class,
]);
}
$this->publishes([
__DIR__ . '/../../config/sidecar.php' => config_path('sidecar.php')
], 'config');
}
}