Skip to content

Commit

Permalink
fix TC for media RP (hashicorp#11709)
Browse files Browse the repository at this point in the history
  • Loading branch information
njuCZ authored and favoretti committed May 26, 2021
1 parent 484bfb2 commit 43530b9
Showing 1 changed file with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -486,10 +486,9 @@ func expandAccessControl(d *schema.ResourceData) (*media.StreamingEndpointAccess
accessControlResult := new(media.StreamingEndpointAccessControl)
accessControl := accessControls[0].(map[string]interface{})
// Get IP information
if raw, ok := accessControl["ip_allow"]; ok {
ipAllowsList := raw.([]interface{})
if ipAllowsList := accessControl["ip_allow"].([]interface{}); len(ipAllowsList) > 0 {
ipRanges := make([]media.IPRange, 0)
for index, ipAllow := range ipAllowsList {
for _, ipAllow := range ipAllowsList {
if ipAllow == nil {
continue
}
Expand All @@ -505,15 +504,14 @@ func expandAccessControl(d *schema.ResourceData) (*media.StreamingEndpointAccess
if subnetPrefixLengthRaw != "" {
ipRange.SubnetPrefixLength = utils.Int32(int32(subnetPrefixLengthRaw.(int)))
}
ipRanges[index] = ipRange
ipRanges = append(ipRanges, ipRange)
}
accessControlResult.IP = &media.IPAccessControl{
Allow: &ipRanges,
}
}
// Get Akamai information
if raw, ok := accessControl["akamai_signature_header_authentication_key"]; ok {
akamaiSignatureKeyList := raw.([]interface{})
if akamaiSignatureKeyList := accessControl["akamai_signature_header_authentication_key"].([]interface{}); len(akamaiSignatureKeyList) > 0 {
akamaiSignatureHeaderAuthenticationKeyList := make([]media.AkamaiSignatureHeaderAuthenticationKey, 0)
for _, akamaiSignatureKey := range akamaiSignatureKeyList {
if akamaiSignatureKey == nil {
Expand All @@ -538,9 +536,9 @@ func expandAccessControl(d *schema.ResourceData) (*media.StreamingEndpointAccess
}
}
akamaiSignatureHeaderAuthenticationKeyList = append(akamaiSignatureHeaderAuthenticationKeyList, akamaiSignatureHeaderAuthenticationKey)
accessControlResult.Akamai = &media.AkamaiAccessControl{
AkamaiSignatureHeaderAuthenticationKeyList: &akamaiSignatureHeaderAuthenticationKeyList,
}
}
accessControlResult.Akamai = &media.AkamaiAccessControl{
AkamaiSignatureHeaderAuthenticationKeyList: &akamaiSignatureHeaderAuthenticationKeyList,
}
}

Expand Down

0 comments on commit 43530b9

Please sign in to comment.