@@ -127,6 +127,9 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient *iaas.APICli
127127}
128128
129129func outputResult (p * print.Printer , outputFormat string , networkArea * iaas.NetworkArea , attachedProjects []string ) error {
130+ if networkArea == nil {
131+ return fmt .Errorf ("network area is nil" )
132+ }
130133 switch outputFormat {
131134 case print .JSONOutputFormat :
132135 details , err := json .MarshalIndent (networkArea , "" , " " )
@@ -146,16 +149,19 @@ func outputResult(p *print.Printer, outputFormat string, networkArea *iaas.Netwo
146149 return nil
147150 default :
148151 var routes []string
149- if networkArea .Ipv4 .Routes != nil {
150- for _ , route := range * networkArea .Ipv4 .Routes {
151- routes = append (routes , fmt .Sprintf ("next hop: %s\n prefix: %s" , * route .Nexthop , * route .Prefix ))
152+ var networkRanges []string
153+
154+ if networkArea .Ipv4 != nil {
155+ if networkArea .Ipv4 .Routes != nil {
156+ for _ , route := range * networkArea .Ipv4 .Routes {
157+ routes = append (routes , fmt .Sprintf ("next hop: %s\n prefix: %s" , * route .Nexthop , * route .Prefix ))
158+ }
152159 }
153- }
154160
155- var networkRanges [] string
156- if networkArea .Ipv4 .NetworkRanges != nil {
157- for _ , networkRange := range * networkArea . Ipv4 . NetworkRanges {
158- networkRanges = append ( networkRanges , * networkRange . Prefix )
161+ if networkArea . Ipv4 . NetworkRanges != nil {
162+ for _ , networkRange := range * networkArea .Ipv4 .NetworkRanges {
163+ networkRanges = append ( networkRanges , * networkRange . Prefix )
164+ }
159165 }
160166 }
161167
0 commit comments