Skip to content

Commit

Permalink
Merge pull request #56 from catchpoint/http_header_request
Browse files Browse the repository at this point in the history
[Terraform]HTTP headers is displaying as an empty array  while importing the test
  • Loading branch information
EmmanuelPonnudurai authored Oct 30, 2024
2 parents 8473c0e + e197bb9 commit b9cb20d
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions catchpoint/flatten_all_test_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,25 @@ func flattenThresholds(thresholds Thresholds) []interface{} {
}
return []interface{}{thresholdsMap}
}

func flattenRequestSetting(requestSetting RequestSetting) []interface{} {
httpHeaderRequests := make(map[string]interface{}, len(requestSetting.HttpHeaderRequests))
func flattenHttpHeaderRequests(requestSetting RequestSetting) []interface{} {
httpHeaderRequests := make([]interface{}, 0, len(requestSetting.HttpHeaderRequests))
for _, header := range requestSetting.HttpHeaderRequests {
httpHeaderRequests[getReqHeaderTypeName(header.RequestHeaderType.Id)] = map[string]interface{}{
// get the header type name
key := getReqHeaderTypeName(header.RequestHeaderType.Id)
userAgentHeader := map[string]interface{}{
"value": header.RequestValue,
"child_host_pattern": header.ChildHostPattern,
}
httpHeaderRequests = append(httpHeaderRequests, map[string]interface{}{
key: []interface{}{userAgentHeader},
})
}

return httpHeaderRequests
}
func flattenRequestSetting(requestSetting RequestSetting) []interface{} {
requestSettingMap := map[string]interface{}{
"authentication": flattenAuthenticationStruct(requestSetting.Authentication),
"authentication": flattenAuthenticationStruct(requestSetting.Authentication),
"http_request_headers": flattenHttpHeaderRequests(requestSetting),
}
if len(requestSetting.LibraryCertificateIds) > 0 {
requestSettingMap["library_certificate_ids"] = requestSetting.LibraryCertificateIds
Expand Down

0 comments on commit b9cb20d

Please sign in to comment.