Skip to content

Commit

Permalink
Merge pull request #14 from heskymatic/master
Browse files Browse the repository at this point in the history
Read region from config when init s3 bucket
  • Loading branch information
schickling committed Dec 13, 2015
2 parents ecbaa95 + d902d83 commit e60b427
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/GitS3/Console/Application.php
Expand Up @@ -79,7 +79,7 @@ private function getCurrentHash()

private function initBucket()
{
$this->bucket = new Bucket($this->config->getKey(), $this->config->getSecret(), $this->config->getBucket());
$this->bucket = new Bucket($this->config->getKey(), $this->config->getSecret(), $this->config->getBucket(), $this->config->getRegion());
}

private function initRepository()
Expand Down
11 changes: 7 additions & 4 deletions src/GitS3/Wrapper/Bucket.php
Expand Up @@ -12,7 +12,7 @@ class Bucket
private $client;
private $name;

public function __construct($key, $secret, $name)
public function __construct($key, $secret, $name, $region = 'eu-west-1')
{
$this->name = $name;

Expand All @@ -22,11 +22,14 @@ public function __construct($key, $secret, $name)

//If keys are not valid, try a role.
if(!$validKey || !$validSecret)
$this->client = S3Client::factory(array());
$this->client = S3Client::factory(array(
'region' => $region,
));
else
$this->client = S3Client::factory(array(
'key' => $key,
'secret' => $secret,
'key' => $key,
'secret' => $secret,
'region' => $region,
));
}

Expand Down
1 change: 1 addition & 0 deletions tests/Console/ApplicationTest.php
Expand Up @@ -45,6 +45,7 @@ public function testGetBucket()
$this->configMock->shouldReceive('getKey')->once();
$this->configMock->shouldReceive('getSecret')->once();
$this->configMock->shouldReceive('getBucket')->once();
$this->configMock->shouldReceive('getRegion')->once();

$this->assertInstanceOf('GitS3\Wrapper\Bucket', $this->application->getBucket());
}
Expand Down

0 comments on commit e60b427

Please sign in to comment.