@@ -66,23 +66,21 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
6666 if err != nil {
6767 return fmt .Errorf ("get Observability service plans: %w" , err )
6868 }
69- plans := * resp .Plans
70- if len (plans ) == 0 {
71- projectLabel , err := projectname .GetProjectName (ctx , params .Printer , params .CliVersion , cmd )
72- if err != nil {
73- params .Printer .Debug (print .ErrorLevel , "get project name: %v" , err )
74- projectLabel = model .ProjectId
75- }
76- params .Printer .Info ("No plans found for project %q\n " , projectLabel )
77- return nil
69+
70+ plans := resp .GetPlans ()
71+
72+ projectLabel , err := projectname .GetProjectName (ctx , params .Printer , params .CliVersion , cmd )
73+ if err != nil {
74+ params .Printer .Debug (print .ErrorLevel , "get project name: %v" , err )
75+ projectLabel = model .ProjectId
7876 }
7977
8078 // Truncate output
8179 if model .Limit != nil && len (plans ) > int (* model .Limit ) {
8280 plans = plans [:* model .Limit ]
8381 }
8482
85- return outputResult (params .Printer , model .OutputFormat , plans )
83+ return outputResult (params .Printer , model .OutputFormat , projectLabel , plans )
8684 },
8785 }
8886
@@ -122,8 +120,12 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient *observabili
122120 return req
123121}
124122
125- func outputResult (p * print.Printer , outputFormat string , plans []observability.Plan ) error {
123+ func outputResult (p * print.Printer , outputFormat , projectLabel string , plans []observability.Plan ) error {
126124 return p .OutputResult (outputFormat , plans , func () error {
125+ if len (plans ) == 0 {
126+ p .Outputf ("No plans found for project %q\n " , projectLabel )
127+ return nil
128+ }
127129 table := tables .NewTable ()
128130 table .SetHeader ("ID" , "PLAN NAME" , "DESCRIPTION" )
129131 for i := range plans {
0 commit comments