@@ -72,16 +72,12 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
7272 return fmt .Errorf ("list access tokens: %w" , err )
7373 }
7474
75- if resp .Tokens == nil || len (* resp .Tokens ) == 0 {
76- projectLabel , err := projectname .GetProjectName (ctx , params .Printer , params .CliVersion , cmd )
77- if err != nil {
78- params .Printer .Debug (print .ErrorLevel , "get project name: %v" , err )
79- projectLabel = model .ProjectId
80- } else if projectLabel == "" {
81- projectLabel = model .ProjectId
82- }
83- params .Printer .Outputf ("No access token found for project %q\n " , projectLabel )
84- return nil
75+ projectLabel , err := projectname .GetProjectName (ctx , params .Printer , params .CliVersion , cmd )
76+ if err != nil {
77+ params .Printer .Debug (print .ErrorLevel , "get project name: %v" , err )
78+ projectLabel = model .ProjectId
79+ } else if projectLabel == "" {
80+ projectLabel = model .ProjectId
8581 }
8682
8783 // Truncate output
@@ -90,7 +86,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
9086 items = items [:* model .Limit ]
9187 }
9288
93- return outputResult (params .Printer , model .OutputFormat , items )
89+ return outputResult (params .Printer , model .OutputFormat , items , projectLabel )
9490 },
9591 }
9692 configureFlags (cmd )
@@ -133,8 +129,13 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient *logs.APICli
133129 return apiClient .ListAccessTokens (ctx , model .ProjectId , model .Region , model .InstanceId )
134130}
135131
136- func outputResult (p * print.Printer , outputFormat string , tokens []logs.AccessToken ) error {
132+ func outputResult (p * print.Printer , outputFormat string , tokens []logs.AccessToken , projectLabel string ) error {
137133 return p .OutputResult (outputFormat , tokens , func () error {
134+ if len (tokens ) == 0 {
135+ p .Outputf ("No access token found for project %q\n " , projectLabel )
136+ return nil
137+ }
138+
138139 table := tables .NewTable ()
139140 table .SetHeader ("ID" , "NAME" , "DESCRIPTION" , "PERMISSIONS" , "VALID UNTIL" , "STATUS" )
140141
0 commit comments