@@ -8,14 +8,6 @@ import (
88 "github.com/scaleway/terraform-provider-scaleway/v2/internal/types"
99)
1010
11- // getStringSafely safely extracts a string value from an interface
12- func getStringSafely (v any ) string {
13- if s , ok := v .(string ); ok {
14- return s
15- }
16- return ""
17- }
18-
1911func flattenDomainData (data string , recordType domain.RecordType ) any {
2012 switch recordType {
2113 case domain .RecordTypeMX : // API return this format: "{priority} {data}"
@@ -181,34 +173,22 @@ func expandDomainHTTPService(i any, ok bool) *domain.RecordHTTPServiceConfig {
181173 return nil
182174 }
183175
184- lst , ok := i .([]any )
185- if ! ok || len (lst ) == 0 {
186- return nil
187- }
188-
189- rawMap , ok := lst [0 ].(map [string ]any )
190- if ! ok {
191- return nil
192- }
176+ rawMap := i .([]any )[0 ].(map [string ]any )
193177
194178 ips := []net.IP {}
195179
196180 rawIPs , ok := rawMap ["ips" ].([]any )
197181 if ok {
198182 for _ , rawIP := range rawIPs {
199- if s , ok := rawIP .(string ); ok {
200- if ip := net .ParseIP (s ); ip != nil {
201- ips = append (ips , ip )
202- }
203- }
183+ ips = append (ips , net .ParseIP (rawIP .(string )))
204184 }
205185 }
206186
207187 return & domain.RecordHTTPServiceConfig {
208188 MustContain : types .ExpandStringPtr (rawMap ["must_contain" ]),
209- URL : getStringSafely ( rawMap ["url" ]),
189+ URL : rawMap ["url" ].( string ),
210190 UserAgent : types .ExpandStringPtr (rawMap ["user_agent" ]),
211- Strategy : domain .RecordHTTPServiceConfigStrategy (getStringSafely ( rawMap ["strategy" ])),
191+ Strategy : domain .RecordHTTPServiceConfigStrategy (rawMap ["strategy" ].( string )),
212192 IPs : ips ,
213193 }
214194}
0 commit comments