File tree Expand file tree Collapse file tree 3 files changed +37
-1
lines changed
Expand file tree Collapse file tree 3 files changed +37
-1
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,13 @@ class TaskMakeCommand extends GeneratorCommand
1818 */
1919 protected $ name = 'make:task ' ;
2020
21+ /**
22+ * The type of class being generated.
23+ *
24+ * @var string
25+ */
26+ protected $ type = 'Task ' ;
27+
2128 /**
2229 * The name of the console command.
2330 *
Original file line number Diff line number Diff line change @@ -86,11 +86,17 @@ public static function fromArray(array $config): static
8686 : "/home/ {$ username }/.laravel-task-runner " ;
8787 }
8888
89+ $ privateKey = $ config ['private_key ' ] ?? null ;
90+
91+ if (is_callable ($ privateKey )) {
92+ $ privateKey = $ privateKey ();
93+ }
94+
8995 return new static (
9096 host: $ config ['host ' ] ?: null ,
9197 port: $ config ['port ' ] ?: null ,
9298 username: $ username ?: null ,
93- privateKey: $ config [ ' private_key ' ] ?? null ,
99+ privateKey: $ privateKey ,
94100 scriptPath: $ scriptPath ,
95101 proxyJump: $ config ['proxy_jump ' ] ?? null ,
96102 );
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ use ProtoneMedia \LaravelTaskRunner \Connection ;
4+
5+ function addConnectionToConfig ()
6+ {
7+ config (['task-runner.connections.production ' => [
8+ 'host ' => '1.1.1.1 ' ,
9+ 'port ' => '21 ' ,
10+ 'username ' => 'root ' ,
11+ 'private_key ' => fn () => 'secret ' ,
12+ 'passphrase ' => 'password ' ,
13+ 'script_path ' => '' ,
14+ ]]);
15+ }
16+
17+ it ('can resolve a private key from a callable ' , function () {
18+ addConnectionToConfig ();
19+
20+ $ connection = Connection::fromConfig ('production ' );
21+
22+ expect ($ connection ->privateKey )->toBe ('secret ' );
23+ });
You can’t perform that action at this time.
0 commit comments