mirror of
https://github.com/SociallyDev/Spaces-API.git
synced 2025-08-14 02:27:23 -07:00
v2: Updates
* Simplifies & beautifies everything * Introduces a new Class system. * Errors are defaulted to AWS's handler. * New function names & more efficient handling. * Should fix a majority of the errors. Please read the README for more!
This commit is contained in:
parent
ad0726e41e
commit
e6d7753dc8
1095 changed files with 45088 additions and 2911 deletions
|
@ -2,7 +2,6 @@
|
|||
namespace Aws\Credentials;
|
||||
|
||||
use Aws\Exception\CredentialsException;
|
||||
use GuzzleHttp\Promise;
|
||||
use GuzzleHttp\Psr7\Request;
|
||||
use GuzzleHttp\Promise\PromiseInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
@ -15,10 +14,14 @@ class EcsCredentialProvider
|
|||
{
|
||||
const SERVER_URI = 'http://169.254.170.2';
|
||||
const ENV_URI = "AWS_CONTAINER_CREDENTIALS_RELATIVE_URI";
|
||||
const ENV_TIMEOUT = 'AWS_METADATA_SERVICE_TIMEOUT';
|
||||
|
||||
/** @var callable */
|
||||
private $client;
|
||||
|
||||
/** @var float|mixed */
|
||||
private $timeout;
|
||||
|
||||
/**
|
||||
* The constructor accepts following options:
|
||||
* - timeout: (optional) Connection timeout, in seconds, default 1.0
|
||||
|
@ -28,7 +31,7 @@ class EcsCredentialProvider
|
|||
*/
|
||||
public function __construct(array $config = [])
|
||||
{
|
||||
$this->timeout = isset($config['timeout']) ? $config['timeout'] : 1.0;
|
||||
$this->timeout = (float) getenv(self::ENV_TIMEOUT) ?: (isset($config['timeout']) ? $config['timeout'] : 1.0);
|
||||
$this->client = isset($config['client'])
|
||||
? $config['client']
|
||||
: \Aws\default_http_handler();
|
||||
|
@ -45,7 +48,10 @@ class EcsCredentialProvider
|
|||
$request = new Request('GET', self::getEcsUri());
|
||||
return $client(
|
||||
$request,
|
||||
['timeout' => $this->timeout]
|
||||
[
|
||||
'timeout' => $this->timeout,
|
||||
'proxy' => '',
|
||||
]
|
||||
)->then(function (ResponseInterface $response) {
|
||||
$result = $this->decodeResult((string) $response->getBody());
|
||||
return new Credentials(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue