Skip to content

Commit b9cb20d

Browse files
Merge pull request #56 from catchpoint/http_header_request
[Terraform]HTTP headers is displaying as an empty array while importing the test
2 parents 8473c0e + e197bb9 commit b9cb20d

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

catchpoint/flatten_all_test_type.go

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,25 @@ func flattenThresholds(thresholds Thresholds) []interface{} {
3030
}
3131
return []interface{}{thresholdsMap}
3232
}
33-
34-
func flattenRequestSetting(requestSetting RequestSetting) []interface{} {
35-
httpHeaderRequests := make(map[string]interface{}, len(requestSetting.HttpHeaderRequests))
33+
func flattenHttpHeaderRequests(requestSetting RequestSetting) []interface{} {
34+
httpHeaderRequests := make([]interface{}, 0, len(requestSetting.HttpHeaderRequests))
3635
for _, header := range requestSetting.HttpHeaderRequests {
37-
httpHeaderRequests[getReqHeaderTypeName(header.RequestHeaderType.Id)] = map[string]interface{}{
36+
// get the header type name
37+
key := getReqHeaderTypeName(header.RequestHeaderType.Id)
38+
userAgentHeader := map[string]interface{}{
3839
"value": header.RequestValue,
3940
"child_host_pattern": header.ChildHostPattern,
4041
}
42+
httpHeaderRequests = append(httpHeaderRequests, map[string]interface{}{
43+
key: []interface{}{userAgentHeader},
44+
})
4145
}
42-
46+
return httpHeaderRequests
47+
}
48+
func flattenRequestSetting(requestSetting RequestSetting) []interface{} {
4349
requestSettingMap := map[string]interface{}{
44-
"authentication": flattenAuthenticationStruct(requestSetting.Authentication),
50+
"authentication": flattenAuthenticationStruct(requestSetting.Authentication),
51+
"http_request_headers": flattenHttpHeaderRequests(requestSetting),
4552
}
4653
if len(requestSetting.LibraryCertificateIds) > 0 {
4754
requestSettingMap["library_certificate_ids"] = requestSetting.LibraryCertificateIds

0 commit comments

Comments
 (0)