@@ -100,6 +100,9 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient *rabbitmq.AP
100100}
101101
102102func outputResult (p * print.Printer , outputFormat string , instance * rabbitmq.Instance ) error {
103+ if instance == nil {
104+ return fmt .Errorf ("no instance passed" )
105+ }
103106 switch outputFormat {
104107 case print .JSONOutputFormat :
105108 details , err := json .MarshalIndent (instance , "" , " " )
@@ -123,18 +126,22 @@ func outputResult(p *print.Printer, outputFormat string, instance *rabbitmq.Inst
123126 table .AddSeparator ()
124127 table .AddRow ("NAME" , utils .PtrString (instance .Name ))
125128 table .AddSeparator ()
126- table .AddRow ("LAST OPERATION TYPE" , utils .PtrString (instance .LastOperation .Type ))
127- table .AddSeparator ()
128- table .AddRow ("LAST OPERATION STATE" , utils .PtrString (instance .LastOperation .State ))
129- table .AddSeparator ()
129+ if lastOperation := instance .LastOperation ; lastOperation != nil {
130+ table .AddRow ("LAST OPERATION TYPE" , utils .PtrString (lastOperation .Type ))
131+ table .AddSeparator ()
132+ table .AddRow ("LAST OPERATION STATE" , utils .PtrString (lastOperation .State ))
133+ table .AddSeparator ()
134+ }
130135 table .AddRow ("PLAN ID" , utils .PtrString (instance .PlanId ))
131136 // Only show ACL if it's present and not empty
132- acl := (* instance .Parameters )[aclParameterKey ]
133- aclStr , ok := acl .(string )
134- if ok {
135- if aclStr != "" {
136- table .AddSeparator ()
137- table .AddRow ("ACL" , aclStr )
137+ if parameters := instance .Parameters ; parameters != nil {
138+ acl := (* instance .Parameters )[aclParameterKey ]
139+ aclStr , ok := acl .(string )
140+ if ok {
141+ if aclStr != "" {
142+ table .AddSeparator ()
143+ table .AddRow ("ACL" , aclStr )
144+ }
138145 }
139146 }
140147 err := table .Display (p )
0 commit comments