@@ -68,22 +68,20 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
6868 if err != nil {
6969 return fmt .Errorf ("list Observability credentials: %w" , err )
7070 }
71- credentials := * resp .Credentials
72- if len (credentials ) == 0 {
73- instanceLabel , err := observabilityUtils .GetInstanceName (ctx , apiClient , model .InstanceId , model .ProjectId )
74- if err != nil {
75- params .Printer .Debug (print .ErrorLevel , "get instance name: %v" , err )
76- instanceLabel = model .InstanceId
77- }
78- params .Printer .Info ("No credentials found for instance %q\n " , instanceLabel )
79- return nil
71+
72+ credentials := resp .GetCredentials ()
73+
74+ instanceLabel , err := observabilityUtils .GetInstanceName (ctx , apiClient , model .InstanceId , model .ProjectId )
75+ if err != nil {
76+ params .Printer .Debug (print .ErrorLevel , "get instance name: %v" , err )
77+ instanceLabel = model .InstanceId
8078 }
8179
8280 // Truncate output
8381 if model .Limit != nil && len (credentials ) > int (* model .Limit ) {
8482 credentials = credentials [:* model .Limit ]
8583 }
86- return outputResult (params .Printer , model .OutputFormat , credentials )
84+ return outputResult (params .Printer , model .OutputFormat , instanceLabel , credentials )
8785 },
8886 }
8987 configureFlags (cmd )
@@ -124,8 +122,12 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient *observabili
124122 return req
125123}
126124
127- func outputResult (p * print.Printer , outputFormat string , credentials []observability.ServiceKeysList ) error {
125+ func outputResult (p * print.Printer , outputFormat , instanceLabel string , credentials []observability.ServiceKeysList ) error {
128126 return p .OutputResult (outputFormat , credentials , func () error {
127+ if len (credentials ) == 0 {
128+ p .Outputf ("No credentials found for instance %q\n " , instanceLabel )
129+ return nil
130+ }
129131 table := tables .NewTable ()
130132 table .SetHeader ("USERNAME" )
131133 for i := range credentials {
0 commit comments