@@ -134,22 +134,48 @@ func outputResult(p *print.Printer, outputFormat string, securityGroupRule *iaas
134134 table := tables .NewTable ()
135135 table .AddRow ("ID" , * securityGroupRule .Id )
136136 table .AddSeparator ()
137- table .AddRow ("PROTOCOL NAME" , * securityGroupRule .Protocol .Name )
138- table .AddSeparator ()
139- table .AddRow ("PROTOCOL NUMBER" , * securityGroupRule .Protocol .Number )
140- table .AddSeparator ()
137+
138+ if securityGroupRule .Protocol != nil {
139+ if securityGroupRule .Protocol .Name != nil {
140+ table .AddRow ("PROTOCOL NAME" , * securityGroupRule .Protocol .Name )
141+ table .AddSeparator ()
142+ }
143+
144+ if securityGroupRule .Protocol .Number != nil {
145+ table .AddRow ("PROTOCOL NUMBER" , * securityGroupRule .Protocol .Number )
146+ table .AddSeparator ()
147+ }
148+ }
149+
141150 table .AddRow ("DIRECTION" , * securityGroupRule .Direction )
142151 table .AddSeparator ()
143- table .AddRow ("START PORT" , * securityGroupRule .PortRange .Min )
144- table .AddSeparator ()
145- table .AddRow ("END PORT" , * securityGroupRule .PortRange .Max )
146- table .AddSeparator ()
147- table .AddRow ("ETHER TYPE" , * securityGroupRule .Ethertype )
148- table .AddSeparator ()
149- table .AddRow ("IP RANGE" , * securityGroupRule .IpRange )
150- table .AddSeparator ()
151- table .AddRow ("REMOTE SECURITY GROUP" , * securityGroupRule .RemoteSecurityGroupId )
152- table .AddSeparator ()
152+
153+ if securityGroupRule .PortRange != nil {
154+ if securityGroupRule .PortRange .Min != nil {
155+ table .AddRow ("START PORT" , * securityGroupRule .PortRange .Min )
156+ table .AddSeparator ()
157+ }
158+
159+ if securityGroupRule .PortRange .Max != nil {
160+ table .AddRow ("END PORT" , * securityGroupRule .PortRange .Max )
161+ table .AddSeparator ()
162+ }
163+ }
164+
165+ if securityGroupRule .Ethertype != nil {
166+ table .AddRow ("ETHER TYPE" , * securityGroupRule .Ethertype )
167+ table .AddSeparator ()
168+ }
169+
170+ if securityGroupRule .IpRange != nil {
171+ table .AddRow ("IP RANGE" , * securityGroupRule .IpRange )
172+ table .AddSeparator ()
173+ }
174+
175+ if securityGroupRule .RemoteSecurityGroupId != nil {
176+ table .AddRow ("REMOTE SECURITY GROUP" , * securityGroupRule .RemoteSecurityGroupId )
177+ table .AddSeparator ()
178+ }
153179
154180 err := table .Display (p )
155181 if err != nil {
0 commit comments