Skip to content

Commit

Permalink
Laravel 9.8 support (#23)
Browse files Browse the repository at this point in the history
* update packages

* Update composer.json

Co-authored-by: Steve Williamson <[email protected]>

* Laravel 9 Tests

* adding multiple versions

* p8 only with l9

* php version fix

* php fix

* testing

* fixing actions

Co-authored-by: Steve Williamson <[email protected]>
  • Loading branch information
Null78 and swilla authored May 2, 2022
1 parent 7380676 commit 9691aff
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "Run Tests - Current"
name: "Run Tests - L9"

on: [push, pull_request]

Expand All @@ -9,12 +9,19 @@ jobs:
strategy:
fail-fast: false
matrix:
laravel: [8.*, 9.*]
php: [8.0, 7.4, 7.3]
laravel: [8.*]
dependency-version: [prefer-lowest, prefer-stable]
include:
- laravel: 8.*
testbench: 6.*
- laravel: 9.*
testbench: 7.*
exclude:
- laravel: 9.*
php: 7.3
- laravel: 9.*
php: 7.4

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }}

Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
}
],
"require": {
"php": "^7.1 || ^7.3 || ^8.0",
"aws/aws-sdk-php": "^3.145",
"illuminate/support": "5.7.* || 5.8.* ||^6.0 || ^7.0 || ^8.0"
"php": "^7.1 || ^7.3 || ^7.4 || ^8.0",
"aws/aws-sdk-php": "^3.145 || ^3.219",
"illuminate/support": "^6.0 || ^7.0 || ^8.0 || ^9.8"
},
"require-dev": {
"orchestra/testbench": "^3.8 || ^5.0 || ^6.0",
"phpunit/phpunit": "^7.0 || ^8.4 || ^9.3.3"
"orchestra/testbench": "^3.8 || ^5.0 || ^6.0 || ^7.4",
"phpunit/phpunit": "^7.0||^8.4||^9.3.3"
},
"autoload": {
"psr-4": {
Expand Down
21 changes: 13 additions & 8 deletions config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
| Tag used to return list of Secrets
|--------------------------------------------------------------------------
|
| All the secrets with the `dev` tag will be loaded into environment variables
| All the secrets with the `dev` tag will be loaded into environment variables.
|
*/

Expand All @@ -31,7 +31,8 @@
| Environments where this service provider is enabled
|--------------------------------------------------------------------------
|
| List the environment names in an array where this package should be enabled, it will be compared against env('APP_ENV') set in the app.yaml file
| List the environment names in an array where this package should be enabled,
| it will be compared against env('APP_ENV') set in the app.yaml file.
|
*/

Expand All @@ -44,7 +45,8 @@
| Variables that require overwriting the config
|--------------------------------------------------------------------------
|
| Some (not all) variables are set into the config, as such updating the env() will not overwrite the config cached values. The variables below will overwrite the config.
| Some (not all) variables are set into the config, as such updating the env() will not overwrite
| the config cached values. The variables below will overwrite the config.
|
*/
'variables-config' => [
Expand All @@ -56,11 +58,12 @@
| Cache Enabled
|--------------------------------------------------------------------------
|
| Boolean if you would like to enable cache. Datastore requests can add an additional 100-250ms of latency to each request. It is recommended to use caching to significantly reduce this latency.
| Boolean if you would like to enable cache. Datastore requests can add an additional 100-250ms
| of latency to each request. It is recommended to use caching to significantly reduce this latency.
|
*/

'cache-enabled' => true, //boolean
'cache-enabled' => true, // boolean

/*
|--------------------------------------------------------------------------
Expand All @@ -71,14 +74,15 @@
|
*/

'cache-expiry' => 30, //minutes
'cache-expiry' => 30, // minutes

/*
|--------------------------------------------------------------------------
| Cache Store
|--------------------------------------------------------------------------
|
| Define the cache store that you wish to use (this must be configured in your config.cache file). Note you can only use a store that does not require credentials to access it. As such file is suggested.
| Define the cache store that you wish to use (this must be configured in your config.cache file).
| Note: you can only use a store that does not require credentials to access it. As such file is suggested.
|
*/

Expand All @@ -89,7 +93,8 @@
| Debugging
|--------------------------------------------------------------------------
|
| Enable debugging, latency introduced by this package on bootstrapping is calculated and logged to the system log (viewable in stackdriver)
| Enable debugging, latency introduced by this package on bootstrapping is calculated and logged
| to the system log (viewable in stackdriver).
|
*/

Expand Down
10 changes: 6 additions & 4 deletions src/LaravelAwsSecretsManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,19 @@ public function __construct()

public function loadSecrets()
{
//load vars from datastore to env
// Load vars from datastore to env
if ($this->debug) {
$start = microtime(true);
}

//Only run this if the evironment is enabled in the config
// Only run this if the evironment is enabled in the config
if (in_array(config('app.env'), $this->enabledEnvironments)) {
if (! $this->checkCache()) {
//Cache has expired need to refresh the cache from Datastore
// Cache has expired need to refresh the cache from Datastore
$this->getVariables();
}

//Process variables in config that need updating
// Process variables in config that need updating
$this->updateConfigs();
}

Expand All @@ -63,6 +63,7 @@ protected function checkCache()
{
foreach ($this->configVariables as $variable => $configPath) {
$val = Cache::store($this->cacheStore)->get($variable);

if (! is_null($val)) {
putenv("$variable=$val");
} else {
Expand Down Expand Up @@ -105,6 +106,7 @@ protected function getVariables()
$result = $this->client->getSecretValue([
'SecretId' => $secret['ARN'],
]);

$secretValues = json_decode($result['SecretString'], true);

if (is_array($secretValues) && count($secretValues) > 0) {
Expand Down

0 comments on commit 9691aff

Please sign in to comment.