Skip to content

Commit 5c5092c

Browse files
authored
Merge pull request #13 from Pilotcore/support-json-secrets
Support secrets where multiple values are in a single secret in JSON …
2 parents 5f4d27a + f6c052b commit 5c5092c

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/LaravelAwsSecretsManager.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,19 @@ protected function getVariables()
106106
'SecretId' => $secret['ARN'],
107107
]);
108108
$secretValues = json_decode($result['SecretString'], true);
109-
if (isset($secretValues['name']) && isset($secretValues['value'])) {
110-
$key = $secretValues['name'];
111-
$secret = $secretValues['value'];
112-
putenv("$key=$secret");
113-
$this->storeToCache($key, $secret);
109+
110+
if (is_array($secretValues) && count($secretValues) > 0) {
111+
if (isset($secretValues['name']) && isset($secretValues['value'])) {
112+
$key = $secretValues['name'];
113+
$secret = $secretValues['value'];
114+
putenv("$key=$secret");
115+
$this->storeToCache($key, $secret);
116+
} else {
117+
foreach ($secretValues as $key => $value) {
118+
putenv("$key=$value");
119+
$this->storeToCache($key, $value);
120+
}
121+
}
114122
}
115123
}
116124
}

0 commit comments

Comments
 (0)