@@ -514,17 +514,28 @@ func (h *UiHook) PreListQuery(id terraform.HookResourceIdentity, input_config ct
514
514
func (h * UiHook ) PostListQuery (id terraform.HookResourceIdentity , results plans.QueryResults ) (terraform.HookAction , error ) {
515
515
addr := id .Addr
516
516
data := results .Value .GetAttr ("data" )
517
+
518
+ identities := make ([]string , 0 , data .LengthInt ())
519
+ displayNames := make ([]string , 0 , data .LengthInt ())
520
+ maxIdentityLen := 0
517
521
for it := data .ElementIterator (); it .Next (); {
518
522
_ , value := it .Element ()
523
+ identity := tfdiags .ObjectToString (value .GetAttr ("identity" ))
524
+ if len (identity ) > maxIdentityLen {
525
+ maxIdentityLen = len (identity )
526
+ }
527
+ identities = append (identities , identity )
519
528
520
- h .println (fmt .Sprintf (
521
- "%s\t %s\t %s" ,
522
- addr .String (),
523
- // TODO maybe deduplicate common identity attributes?
524
- tfdiags .ObjectToString (value .GetAttr ("identity" )),
525
- value .GetAttr ("display_name" ).AsString (),
526
- ))
529
+ displayNames = append (displayNames , value .GetAttr ("display_name" ).AsString ())
527
530
}
531
+
532
+ result := strings.Builder {}
533
+ for i , identity := range identities {
534
+ result .WriteString (fmt .Sprintf ("%s %-*s %s\n " , addr .String (), maxIdentityLen , identity , displayNames [i ]))
535
+ }
536
+
537
+ h .println (result .String ())
538
+
528
539
return terraform .HookActionContinue , nil
529
540
}
530
541
0 commit comments