@@ -117,6 +117,9 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient *iaas.APICli
117117}
118118
119119func outputResult (p * print.Printer , outputFormat string , nic * iaas.NIC ) error {
120+ if nic == nil {
121+ return fmt .Errorf ("nic is empty" )
122+ }
120123 switch outputFormat {
121124 case print .JSONOutputFormat :
122125 details , err := json .MarshalIndent (nic , "" , " " )
@@ -136,35 +139,35 @@ func outputResult(p *print.Printer, outputFormat string, nic *iaas.NIC) error {
136139 return nil
137140 default :
138141 table := tables .NewTable ()
139- table .AddRow ("ID" , * nic .Id )
142+ table .AddRow ("ID" , utils . PtrString ( nic .Id ) )
140143 table .AddSeparator ()
141- table .AddRow ("NETWORK ID" , * nic .NetworkId )
144+ table .AddRow ("NETWORK ID" , utils . PtrString ( nic .NetworkId ) )
142145 table .AddSeparator ()
143146 if nic .Name != nil {
144- table .AddRow ("NAME" , * nic .Name )
147+ table .AddRow ("NAME" , utils . PtrString ( nic .Name ) )
145148 table .AddSeparator ()
146149 }
147150 if nic .Ipv4 != nil {
148- table .AddRow ("IPV4" , * nic .Ipv4 )
151+ table .AddRow ("IPV4" , utils . PtrString ( nic .Ipv4 ) )
149152 table .AddSeparator ()
150153 }
151154 if nic .Ipv6 != nil {
152- table .AddRow ("IPV6" , * nic .Ipv6 )
155+ table .AddRow ("IPV6" , utils . PtrString ( nic .Ipv6 ) )
153156 table .AddSeparator ()
154157 }
155158 table .AddRow ("MAC" , utils .PtrString (nic .Mac ))
156159 table .AddSeparator ()
157160 table .AddRow ("NIC SECURITY" , utils .PtrString (nic .NicSecurity ))
158161 if nic .AllowedAddresses != nil && len (* nic .AllowedAddresses ) > 0 {
159- allowedAddresses := []string {}
162+ var allowedAddresses []string
160163 for _ , value := range * nic .AllowedAddresses {
161164 allowedAddresses = append (allowedAddresses , * value .String )
162165 }
163166 table .AddSeparator ()
164167 table .AddRow ("ALLOWED ADDRESSES" , strings .Join (allowedAddresses , "\n " ))
165168 }
166169 if nic .Labels != nil && len (* nic .Labels ) > 0 {
167- labels := []string {}
170+ var labels []string
168171 for key , value := range * nic .Labels {
169172 labels = append (labels , fmt .Sprintf ("%s: %s" , key , value ))
170173 }
0 commit comments