@@ -514,17 +514,28 @@ func (h *UiHook) PreListQuery(id terraform.HookResourceIdentity, input_config ct
514514func (h * UiHook ) PostListQuery (id terraform.HookResourceIdentity , results plans.QueryResults ) (terraform.HookAction , error ) {
515515 addr := id .Addr
516516 data := results .Value .GetAttr ("data" )
517+
518+ identities := make ([]string , 0 , data .LengthInt ())
519+ displayNames := make ([]string , 0 , data .LengthInt ())
520+ maxIdentityLen := 0
517521 for it := data .ElementIterator (); it .Next (); {
518522 _ , 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 )
519528
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 ())
527530 }
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+
528539 return terraform .HookActionContinue , nil
529540}
530541
0 commit comments