@@ -158,23 +158,11 @@ func (s *LoadBalancerBackendSetResourceCrud) Get() (e error) {
158158}
159159
160160func (s * LoadBalancerBackendSetResourceCrud ) Update () (e error ) {
161- healthChecker := baremetal.HealthChecker {
162- IntervalInMS : s .D .Get ("health_checker.interval_ms" ).(int ),
163- Port : s .D .Get ("health_checker.port" ).(int ),
164- Protocol : s .D .Get ("health_checker.protocol" ).(string ),
165- ResponseBodyRegex : s .D .Get ("health_checker.response_body_regex" ).(string ),
166- URLPath : s .D .Get ("health_checker.url_path" ).(string ),
167- }
168- sslConfig := baremetal.SSLConfiguration {
169- CertificateName : s .D .Get ("ssl_configuration.certificate_name" ).(string ),
170- VerifyDepth : s .D .Get ("ssl_configuration.verify_depth" ).(int ),
171- VerifyPeerCertificate : s .D .Get ("ssl_configuration.verify_peer_certificate" ).(bool ),
172- }
173- opts := & baremetal.UpdateLoadBalancerBackendSetOptions {
174- Policy : s .D .Get ("policy" ).(string ),
175- SSLConfig : sslConfig ,
176- HealthChecker : healthChecker ,
177- }
161+ opts := & baremetal.UpdateLoadBalancerBackendSetOptions {}
162+
163+ opts .HealthChecker = s .healthChecker ()
164+ opts .SSLConfig = s .sslConfig ()
165+ opts .Policy = s .D .Get ("policy" ).(string )
178166
179167 var workReqID string
180168 workReqID , e = s .Client .UpdateBackendSet (s .D .Get ("load_balancer_id" ).(string ), s .D .Id (), opts )
@@ -191,18 +179,24 @@ func (s *LoadBalancerBackendSetResourceCrud) SetData() {
191179 }
192180 s .D .Set ("policy" , s .Resource .Policy )
193181 s .D .Set ("name" , s .Resource .Name )
194- s .D .Set ("health_checker" , map [string ]interface {}{
195- "interval_ms" : s .Resource .HealthChecker .IntervalInMS ,
196- "port" : s .Resource .HealthChecker .Port ,
197- "protocol" : s .Resource .HealthChecker .Protocol ,
198- "response_body_regex" : s .Resource .HealthChecker .ResponseBodyRegex ,
199- "url_path" : s .Resource .HealthChecker .URLPath ,
200- })
201- s .D .Set ("ssl_configuration" , map [string ]interface {}{
202- "certificate_name" : s .Resource .SSLConfig .CertificateName ,
203- "verify_depth" : s .Resource .SSLConfig .VerifyDepth ,
204- "verify_peer_certificate" : s .Resource .SSLConfig .VerifyPeerCertificate ,
205- })
182+ if s .Resource .HealthChecker != nil {
183+ s .D .Set ("health_checker" , map [string ]interface {}{
184+ "interval_ms" : s .Resource .HealthChecker .IntervalInMS ,
185+ "port" : s .Resource .HealthChecker .Port ,
186+ "protocol" : s .Resource .HealthChecker .Protocol ,
187+ "response_body_regex" : s .Resource .HealthChecker .ResponseBodyRegex ,
188+ "url_path" : s .Resource .HealthChecker .URLPath ,
189+ })
190+ }
191+
192+ if s .Resource .SSLConfig != nil {
193+ s .D .Set ("ssl_configuration" , map [string ]interface {}{
194+ "certificate_name" : s .Resource .SSLConfig .CertificateName ,
195+ "verify_depth" : s .Resource .SSLConfig .VerifyDepth ,
196+ "verify_peer_certificate" : s .Resource .SSLConfig .VerifyPeerCertificate ,
197+ })
198+ }
199+
206200 backends := make ([]map [string ]interface {}, len (s .Resource .Backends ))
207201 for i , v := range s .Resource .Backends {
208202 backends [i ] = map [string ]interface {}{
@@ -229,30 +223,33 @@ func (s *LoadBalancerBackendSetResourceCrud) Delete() (e error) {
229223}
230224
231225func (s * LoadBalancerBackendSetResourceCrud ) sslConfig () (sslConfig * baremetal.SSLConfiguration ) {
232- sslConfig = new (baremetal.SSLConfiguration )
233226 vs := s .D .Get ("ssl_configuration" ).([]interface {})
234227 if len (vs ) == 1 {
228+ sslConfig = new (baremetal.SSLConfiguration )
235229 v := vs [0 ].(map [string ]interface {})
236230 sslConfig .CertificateName = v ["certificate_name" ].(string )
237231 sslConfig .VerifyDepth = v ["verify_depth" ].(int )
238232 sslConfig .VerifyPeerCertificate = v ["verify_peer_certificate" ].(bool )
233+ return sslConfig
239234 }
240235
241- return
236+ return nil
242237}
243238
244239func (s * LoadBalancerBackendSetResourceCrud ) healthChecker () * baremetal.HealthChecker {
245- healthChecker := new (baremetal. HealthChecker )
240+
246241 vs := s .D .Get ("health_checker" ).([]interface {})
247242 if len (vs ) == 1 {
243+ healthChecker := new (baremetal.HealthChecker )
248244 v := vs [0 ].(map [string ]interface {})
249245 healthChecker .IntervalInMS = v ["interval_ms" ].(int )
250246 healthChecker .Port = v ["port" ].(int )
251247 healthChecker .Protocol = v ["protocol" ].(string )
252248 healthChecker .ResponseBodyRegex = v ["response_body_regex" ].(string )
253249 healthChecker .URLPath = v ["url_path" ].(string )
250+ return healthChecker
254251 }
255- return healthChecker
252+ return nil
256253}
257254func (s * LoadBalancerBackendSetResourceCrud ) backends () []baremetal.Backend {
258255 vs := s .D .Get ("backend" ).([]interface {})
0 commit comments