Skip to content

Commit

Permalink
Fixes bug caused by having no files in the env repo
Browse files Browse the repository at this point in the history
  • Loading branch information
spamoom committed Oct 29, 2021
1 parent 7bd13b1 commit 78de9ce
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
24 changes: 14 additions & 10 deletions app/Commands/EditEnvironmentVariables.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class EditEnvironmentVariables extends BaseCommand
protected $serviceName;
protected $taskDefinitionName;

private array $envFiles;
private array $envFiles = [];

private string $fileName;

Expand Down Expand Up @@ -88,15 +88,19 @@ private function processUpdate(string $bucket): void

private function getMenuItem(string $bucket): ?int
{
$this->envFiles = collect($this->helpers->aws()->s3()->listFiles($bucket))
->pluck('Key')
->map(function ($filename) {
return $filename;
})
->reject(function ($filename) {
return !Str::endsWith($filename, '.env');
})
->toArray();
$files = $this->helpers->aws()->s3()->listFiles($bucket);

if ($files) {
$this->envFiles = collect($files)
->pluck('Key')
->map(function ($filename) {
return $filename;
})
->reject(function ($filename) {
return !Str::endsWith($filename, '.env');
})
->toArray();
}

$additionalMenuOptions = ['Create new file'];
$callerArn = $this->helpers->aws()->iam()->getCallerArn();
Expand Down
2 changes: 1 addition & 1 deletion app/Helpers/Aws/S3.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function __construct(Aws $aws)
$this->aws = $aws;
}

public function listFiles(string $bucketName): array
public function listFiles(string $bucketName): ?array
{
$client = new S3Client($this->aws->standardSdkArguments());

Expand Down

0 comments on commit 78de9ce

Please sign in to comment.