Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/sidecar.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
* The default architecture your function runs on.
* Available options are: x86_64, arm64
*/
'architecture' => env('SIDECAR_ARCH', Architecture::X86_64),
'architecture' => env('SIDECAR_ARCH', Architecture::X86_64->value),

/*
* The base path for your package files. If you e.g. keep
Expand Down
9 changes: 5 additions & 4 deletions src/Architecture.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?php

declare(strict_types=1);

namespace Hammerstone\Sidecar;

abstract class Architecture
enum Architecture: string
{
public const X86_64 = 'x86_64';

public const ARM_64 = 'arm64';
case X86_64 = 'x86_64';
case ARM_64 = 'arm64';
}
17 changes: 17 additions & 0 deletions src/ArchitectureConstants.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

namespace Hammerstone\Sidecar;

/**
* @deprecated Use the Architecture enum instead. This class will be removed in a future version.
*/
abstract class ArchitectureConstants
{
/** @deprecated Use Architecture::X86_64 instead */
public const X86_64 = Architecture::X86_64->value;

/** @deprecated Use Architecture::ARM_64 instead */
public const ARM_64 = Architecture::ARM_64->value;
}
2 changes: 2 additions & 0 deletions src/Clients/CloudWatchLogsClient.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* @author Aaron Francis <aarondfrancis@gmail.com|https://twitter.com/aarondfrancis>
*/
Expand Down
4 changes: 3 additions & 1 deletion src/Clients/Configurations/AwsClientConfiguration.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
<?php

declare(strict_types=1);

namespace Hammerstone\Sidecar\Clients\Configurations;

use Hammerstone\Sidecar\Contracts\AwsClientConfiguration as AwsClientConfigurationContract;

class AwsClientConfiguration implements AwsClientConfigurationContract
{
public function getConfiguration()
public function getConfiguration(): array
{
$config = [
'version' => 'latest',
Expand Down
2 changes: 2 additions & 0 deletions src/Clients/LambdaClient.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* @author Aaron Francis <aarondfrancis@gmail.com|https://twitter.com/aarondfrancis>
*/
Expand Down
2 changes: 2 additions & 0 deletions src/Clients/S3Client.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Hammerstone\Sidecar\Clients;

use Aws\S3\S3Client as BaseClient;
Expand Down
26 changes: 8 additions & 18 deletions src/Commands/Actions/BaseAction.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* @author Aaron Francis <aarondfrancis@gmail.com|https://twitter.com/aarondfrancis>
*/
Expand All @@ -10,26 +12,14 @@

abstract class BaseAction
{
/**
* @var Configure
*/
public $command;

/**
* @var string
*/
public $region;

public function __construct($region, Configure $command)
{
$this->region = $region;

$this->command = $command;
}
public function __construct(
public ?string $region,
public Configure $command
) {}

abstract public function invoke();
abstract public function invoke(): mixed;

protected function progress($message)
protected function progress(string $message): void
{
$this->command->text("==> $message");
}
Expand Down
22 changes: 8 additions & 14 deletions src/Commands/Actions/CreateBucket.php
Original file line number Diff line number Diff line change
@@ -1,31 +1,25 @@
<?php

declare(strict_types=1);

/**
* @author Aaron Francis <aarondfrancis@gmail.com|https://twitter.com/aarondfrancis>
*/

namespace Hammerstone\Sidecar\Commands\Actions;

use Aws\S3\S3Client;
use Exception;
use Illuminate\Support\Str;
use Throwable;

class CreateBucket extends BaseAction
{
/**
* @var S3Client
*/
protected $client;

/**
* @var string
*/
protected $bucket;

/**
* @return string
*/
public function invoke()
protected S3Client $client;

protected string $bucket;

public function invoke(): string
{
$this->client = $this->command->client(S3Client::class);

Expand Down
14 changes: 5 additions & 9 deletions src/Commands/Actions/CreateDeploymentUser.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* @author Aaron Francis <aarondfrancis@gmail.com|https://twitter.com/aarondfrancis>
*/
Expand All @@ -12,15 +14,9 @@

class CreateDeploymentUser extends BaseAction
{
/**
* @var IamClient
*/
protected $client;

/**
* @return array
*/
public function invoke()
protected IamClient $client;

public function invoke(): array
{
$this->client = $this->command->client(IamClient::class);

Expand Down
9 changes: 4 additions & 5 deletions src/Commands/Actions/CreateExecutionRole.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* @author Aaron Francis <aarondfrancis@gmail.com|https://twitter.com/aarondfrancis>
*/
Expand All @@ -12,12 +14,9 @@

class CreateExecutionRole extends BaseAction
{
/**
* @var IamClient
*/
protected $client;
protected IamClient $client;

public function invoke()
public function invoke(): string
{
$this->progress('Creating an execution role for your functions...');

Expand Down
14 changes: 9 additions & 5 deletions src/Commands/Actions/DestroyAdminKeys.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* @author Aaron Francis <aarondfrancis@gmail.com|https://twitter.com/aarondfrancis>
*/
Expand All @@ -11,23 +13,23 @@

class DestroyAdminKeys extends BaseAction
{
public $key;
public ?string $key = null;

public function setKey($key)
public function setKey(string $key): static
{
$this->key = $key;

return $this;
}

public function invoke()
public function invoke(): mixed
{
$client = $this->command->client(IamClient::class);

try {
$user = $client->getUser();
} catch (Throwable $e) {
return;
return null;
}

$name = $user['User']['UserName'];
Expand All @@ -52,7 +54,7 @@ public function invoke()
if (!$this->command->confirm($question, $default = $isSidecar)) {
$this->progress('Not deleting keys');

return;
return null;
}

$this->progress('Deleting admin keys...');
Expand All @@ -67,5 +69,7 @@ public function invoke()
}

$this->progress('Admin keys deleted');

return null;
}
}
22 changes: 8 additions & 14 deletions src/Commands/Actions/DetermineRegion.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* @author Aaron Francis <aarondfrancis@gmail.com|https://twitter.com/aarondfrancis>
*/
Expand All @@ -8,23 +10,15 @@

use Aws\S3\S3Client;
use Illuminate\Support\Facades\File;
use Throwable;

class DetermineRegion extends BaseAction
{
/**
* @var S3Client
*/
protected $client;

/**
* @var bool
*/
protected $isVapor;

/**
* @return string
*/
public function invoke()
protected S3Client $client;

protected bool $isVapor = false;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

Remove unused properties $client and $isVapor.

Neither property is used anywhere in this class:

  • $client is declared but never assigned or accessed
  • $isVapor is initialized to false but never read

These appear to be remnants from a prior implementation or copy-paste from another action class.

 class DetermineRegion extends BaseAction
 {
-    protected S3Client $client;
-
-    protected bool $isVapor = false;
-
     public function invoke(): string

Also remove the unused import:

 use Aws\S3\S3Client;
-use Illuminate\Support\Facades\File;
+use Illuminate\Support\Facades\File;

Actually, File is used on line 42. Only remove the S3Client import:

-use Aws\S3\S3Client;
 use Illuminate\Support\Facades\File;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
protected S3Client $client;
protected bool $isVapor = false;
🤖 Prompt for AI Agents
In src/Commands/Actions/DetermineRegion.php around lines 17 to 19, remove the
two unused class properties protected S3Client $client; and protected bool
$isVapor = false; (they are never assigned or read) and also remove the unused
S3Client import at the top of the file; do not remove the File import (it’s used
on line 42). Ensure no other references rely on those properties or the S3Client
import before committing.


public function invoke(): string
{
$region = config('sidecar.aws_region');

Expand Down
2 changes: 2 additions & 0 deletions src/Commands/Activate.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* @author Aaron Francis <aaron@hammerstone.dev>
*/
Expand Down
32 changes: 6 additions & 26 deletions src/Commands/Configure.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* @author Aaron Francis <aaron@hammerstone.dev>
*/
Expand All @@ -17,39 +19,17 @@

class Configure extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'sidecar:configure';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Interactively configure your Sidecar AWS environment variables';

/**
* @var string
*/
protected $key;
protected ?string $key = null;

/**
* @var string
*/
protected $secret;
protected ?string $secret = null;

/**
* @var string
*/
protected $region;
protected ?string $region = null;

/**
* @var int
*/
protected $width = 75;
protected int $width = 75;

/**
* @throws Exception
Expand Down
2 changes: 2 additions & 0 deletions src/Commands/Deploy.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* @author Aaron Francis <aaron@hammerstone.dev>
*/
Expand Down
4 changes: 3 additions & 1 deletion src/Commands/EnvironmentAwareCommand.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* @author Aaron Francis <aarondfrancis@gmail.com|https://twitter.com/aarondfrancis>
*/
Expand All @@ -22,7 +24,7 @@ public function __construct()
$this->getDefinition()->addOptions(Parser::parse($environment)[2]);
}

public function overrideEnvironment()
public function overrideEnvironment(): void
{
if ($environment = $this->option('env')) {
Sidecar::overrideEnvironment($environment);
Expand Down
2 changes: 2 additions & 0 deletions src/Commands/Install.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* @author Aaron Francis <aaron@hammerstone.dev>
*/
Expand Down
Loading