@@ -259,55 +259,64 @@ func resourceFortiadcLoadbalanceVirtualServerRead(d *schema.ResourceData, m inte
259259 if len (crList ) > 1 {
260260 crList = crList [:len (crList )- 1 ]
261261 }
262- if contentRouting == false {
262+ if ! contentRouting {
263263 crList = []string {}
264264 }
265265
266266 rwList := strings .Split (rs .ContentRewritingList , " " )
267267 if len (rwList ) > 1 {
268268 rwList = rwList [:len (rwList )- 1 ]
269269 }
270- if contentRewriting == false {
270+ if ! contentRewriting {
271271 rwList = []string {}
272272 }
273273
274- d .Set ("status" , rs .Status )
275- d .Set ("type" , rs .Type )
276- d .Set ("address_type" , rs .AddrType )
277- d .Set ("address" , rs .Address )
278- d .Set ("packet_forward_method" , rs .PacketFwdMethod )
279- d .Set ("nat_source_pool" , strings .TrimSpace (rs .SrcPool ))
280- d .Set ("content_routing_enable" , contentRouting )
281- d .Set ("content_routing_list" , crList )
282- d .Set ("content_rewriting_enable" , contentRewriting )
283- d .Set ("content_rewriting_list" , rwList )
284- d .Set ("interface" , rs .Interface )
285- d .Set ("profile" , rs .Profile )
286- d .Set ("method" , rs .Method )
287- d .Set ("pool" , rs .Pool )
288- d .Set ("client_ssl_profile" , rs .ClientSSLProfile )
289- d .Set ("http_to_https" , http2https )
290- d .Set ("persistence" , rs .Persistence )
291- d .Set ("error_msg" , rs .ErrorMsg )
292- d .Set ("error_page" , rs .ErrorPage )
274+ arguments := map [string ]interface {}{
275+ "status" : rs .Status ,
276+ "type" : rs .Type ,
277+ "address_type" : rs .AddrType ,
278+ "address" : rs .Address ,
279+ "packet_forward_method" : rs .PacketFwdMethod ,
280+ "nat_source_pool" : strings .TrimSpace (rs .SrcPool ),
281+ "content_routing_enable" : contentRouting ,
282+ "content_routing_list" : crList ,
283+ "content_rewriting_enable" : contentRewriting ,
284+ "content_rewriting_list" : rwList ,
285+ "interface" : rs .Interface ,
286+ "profile" : rs .Profile ,
287+ "method" : rs .Method ,
288+ "pool" : rs .Pool ,
289+ "client_ssl_profile" : rs .ClientSSLProfile ,
290+ "http_to_https" : http2https ,
291+ "persistence" : rs .Persistence ,
292+ "error_msg" : rs .ErrorMsg ,
293+ "error_page" : rs .ErrorPage ,
294+ }
293295
294296 port , err := strconv .ParseInt (strings .TrimSpace (rs .Port ), 10 , 64 )
295297 if err != nil {
296298 return err
297299 }
298- d . Set ( "port" , port )
300+ arguments [ "port" ] = port
299301
300302 connectionLimit , err := strconv .ParseInt (rs .ConnectionLimit , 10 , 64 )
301303 if err != nil {
302304 return err
303305 }
304- d . Set ( "connection_limit" , connectionLimit )
306+ arguments [ "connection_limit" ] = connectionLimit
305307
306308 connectionRateLimit , err := strconv .ParseInt (rs .ConnectionRateLimit , 10 , 64 )
307309 if err != nil {
308310 return err
309311 }
310- d .Set ("connection_rate_limit" , connectionRateLimit )
312+ arguments ["connection_rate_limit" ] = connectionRateLimit
313+
314+ for arg , value := range arguments {
315+ err = d .Set (arg , value )
316+ if err != nil {
317+ return err
318+ }
319+ }
311320
312321 return nil
313322}
0 commit comments