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
18
18
*/
19
19
protected $ name = 'make:task ' ;
20
20
21
+ /**
22
+ * The type of class being generated.
23
+ *
24
+ * @var string
25
+ */
26
+ protected $ type = 'Task ' ;
27
+
21
28
/**
22
29
* The name of the console command.
23
30
*
Original file line number Diff line number Diff line change @@ -86,11 +86,17 @@ public static function fromArray(array $config): static
86
86
: "/home/ {$ username }/.laravel-task-runner " ;
87
87
}
88
88
89
+ $ privateKey = $ config ['private_key ' ] ?? null ;
90
+
91
+ if (is_callable ($ privateKey )) {
92
+ $ privateKey = $ privateKey ();
93
+ }
94
+
89
95
return new static (
90
96
host: $ config ['host ' ] ?: null ,
91
97
port: $ config ['port ' ] ?: null ,
92
98
username: $ username ?: null ,
93
- privateKey: $ config [ ' private_key ' ] ?? null ,
99
+ privateKey: $ privateKey ,
94
100
scriptPath: $ scriptPath ,
95
101
proxyJump: $ config ['proxy_jump ' ] ?? null ,
96
102
);
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