33namespace Codinglabs \Yolo \Commands ;
44
55use Codinglabs \Yolo \Paths ;
6+ use Codinglabs \Yolo \Helpers ;
67use Codinglabs \Yolo \Manifest ;
78use Codinglabs \Yolo \Concerns \UsesEc2 ;
89use Codinglabs \Yolo \Enums \ServerGroup ;
@@ -41,17 +42,17 @@ public function handle(): void
4142 return ;
4243 }
4344
44- $ groups = str_contains ($ this ->option ('group ' ), ', ' )
45+ $ serverGroups = str_contains ($ this ->option ('group ' ), ', ' )
4546 ? explode (', ' , $ this ->option ('group ' ))
4647 : [$ this ->option ('group ' )];
4748
48- foreach ($ groups as $ group ) {
49- $ instances = $ this ->findSshPrefixesForGroup ($ group );
49+ foreach ($ serverGroups as $ serverGroup ) {
50+ $ instances = $ this ->findSshPrefixesForGroup (ServerGroup:: from ( $ serverGroup ) );
5051
51- info ("Found " . count ($ instances ) . " instances in group $ group on {$ this ->argument ('environment ' )}" );
52+ info ("Found " . count ($ instances ) . " instances in group $ serverGroup on {$ this ->argument ('environment ' )}" );
5253
5354 foreach ($ instances as $ ipAddress => $ sshCommand ) {
54- warning ("Executing command ' $ command' in group $ group on instance $ ipAddress on {$ this ->argument ('environment ' )}... " );
55+ warning ("Executing command ' $ command' in group $ serverGroup on instance $ ipAddress on {$ this ->argument ('environment ' )}... " );
5556
5657 $ process = new Process (
5758 command: [
@@ -70,11 +71,11 @@ public function handle(): void
7071 }
7172 }
7273
73- protected function findSshPrefixesForGroup (string $ group ): array
74+ protected function findSshPrefixesForGroup (ServerGroup $ serverGroup ): array
7475 {
7576 $ prefixes = [];
7677
77- foreach (static ::ec2IpByName (name: $ group , firstOnly: false ) as $ ipAddress ) {
78+ foreach (static ::ec2IpByName (name: Helpers:: keyedResourceName ( $ serverGroup , exclusive: false ) , firstOnly: false ) as $ ipAddress ) {
7879 $ prefixes [$ ipAddress ] = static ::formatSshCommand (
7980 ipAddress: $ ipAddress ,
8081 sshKey: $ this ->option ('ssh-key ' )
0 commit comments