-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CDN endpoint: Test for Premium_Verizon, optional values fix #9902
Merged
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -245,15 +245,11 @@ func resourceCdnEndpointCreate(d *schema.ResourceData, meta interface{}) error { | |
originPath := d.Get("origin_path").(string) | ||
probePath := d.Get("probe_path").(string) | ||
optimizationType := d.Get("optimization_type").(string) | ||
contentTypes := expandArmCdnEndpointContentTypesToCompress(d) | ||
geoFilters := expandCdnEndpointGeoFilters(d) | ||
t := d.Get("tags").(map[string]interface{}) | ||
|
||
endpoint := cdn.Endpoint{ | ||
Location: &location, | ||
EndpointProperties: &cdn.EndpointProperties{ | ||
ContentTypesToCompress: &contentTypes, | ||
GeoFilters: geoFilters, | ||
IsHTTPAllowed: &httpAllowed, | ||
IsHTTPSAllowed: &httpsAllowed, | ||
QueryStringCachingBehavior: cdn.QueryStringCachingBehavior(cachingBehaviour), | ||
|
@@ -262,6 +258,16 @@ func resourceCdnEndpointCreate(d *schema.ResourceData, meta interface{}) error { | |
Tags: tags.Expand(t), | ||
} | ||
|
||
if _, ok := d.GetOk("content_types_to_compress"); ok { | ||
contentTypes := expandArmCdnEndpointContentTypesToCompress(d) | ||
endpoint.EndpointProperties.ContentTypesToCompress = &contentTypes | ||
} | ||
|
||
if _, ok := d.GetOk("geo_filter"); ok { | ||
geoFilters := expandCdnEndpointGeoFilters(d) | ||
endpoint.EndpointProperties.GeoFilters = geoFilters | ||
} | ||
|
||
if v, ok := d.GetOk("is_compression_enabled"); ok { | ||
endpoint.EndpointProperties.IsCompressionEnabled = utils.Bool(v.(bool)) | ||
} | ||
|
@@ -294,11 +300,13 @@ func resourceCdnEndpointCreate(d *schema.ResourceData, meta interface{}) error { | |
return fmt.Errorf("Error expanding `global_delivery_rule` or `delivery_rule`: %s", err) | ||
} | ||
|
||
if profile.Sku.Name != cdn.StandardMicrosoft && len(*deliveryPolicy.Rules) > 0 { | ||
return fmt.Errorf("`global_delivery_policy` and `delivery_rule` are only allowed when `Standard_Microsoft` sku is used. Profile sku: %s", profile.Sku.Name) | ||
} | ||
if deliveryPolicy != nil { | ||
if profile.Sku.Name != cdn.StandardMicrosoft && len(*deliveryPolicy.Rules) > 0 { | ||
return fmt.Errorf("`global_delivery_policy` and `delivery_rule` are only allowed when `Standard_Microsoft` sku is used. Profile sku: %s", profile.Sku.Name) | ||
} | ||
|
||
endpoint.EndpointProperties.DeliveryPolicy = deliveryPolicy | ||
endpoint.EndpointProperties.DeliveryPolicy = deliveryPolicy | ||
} | ||
} | ||
|
||
future, err := endpointsClient.Create(ctx, resourceGroup, profileName, name, endpoint) | ||
|
@@ -342,14 +350,10 @@ func resourceCdnEndpointUpdate(d *schema.ResourceData, meta interface{}) error { | |
originPath := d.Get("origin_path").(string) | ||
probePath := d.Get("probe_path").(string) | ||
optimizationType := d.Get("optimization_type").(string) | ||
contentTypes := expandArmCdnEndpointContentTypesToCompress(d) | ||
geoFilters := expandCdnEndpointGeoFilters(d) | ||
t := d.Get("tags").(map[string]interface{}) | ||
|
||
endpoint := cdn.EndpointUpdateParameters{ | ||
EndpointPropertiesUpdateParameters: &cdn.EndpointPropertiesUpdateParameters{ | ||
ContentTypesToCompress: &contentTypes, | ||
GeoFilters: geoFilters, | ||
IsHTTPAllowed: utils.Bool(httpAllowed), | ||
IsHTTPSAllowed: utils.Bool(httpsAllowed), | ||
QueryStringCachingBehavior: cdn.QueryStringCachingBehavior(cachingBehaviour), | ||
|
@@ -358,6 +362,16 @@ func resourceCdnEndpointUpdate(d *schema.ResourceData, meta interface{}) error { | |
Tags: tags.Expand(t), | ||
} | ||
|
||
if _, ok := d.GetOk("content_types_to_compress"); ok { | ||
contentTypes := expandArmCdnEndpointContentTypesToCompress(d) | ||
endpoint.EndpointPropertiesUpdateParameters.ContentTypesToCompress = &contentTypes | ||
} | ||
|
||
if _, ok := d.GetOk("geo_filter"); ok { | ||
geoFilters := expandCdnEndpointGeoFilters(d) | ||
endpoint.EndpointPropertiesUpdateParameters.GeoFilters = geoFilters | ||
} | ||
|
||
if v, ok := d.GetOk("is_compression_enabled"); ok { | ||
endpoint.EndpointPropertiesUpdateParameters.IsCompressionEnabled = utils.Bool(v.(bool)) | ||
} | ||
|
@@ -388,11 +402,13 @@ func resourceCdnEndpointUpdate(d *schema.ResourceData, meta interface{}) error { | |
return fmt.Errorf("Error expanding `global_delivery_rule` or `delivery_rule`: %s", err) | ||
} | ||
|
||
if profile.Sku.Name != cdn.StandardMicrosoft && len(*deliveryPolicy.Rules) > 0 { | ||
return fmt.Errorf("`global_delivery_policy` and `delivery_rule` are only allowed when `Standard_Microsoft` sku is used. Profile sku: %s", profile.Sku.Name) | ||
} | ||
if deliveryPolicy != nil { | ||
if profile.Sku.Name != cdn.StandardMicrosoft && len(*deliveryPolicy.Rules) > 0 { | ||
return fmt.Errorf("`global_delivery_policy` and `delivery_rule` are only allowed when `Standard_Microsoft` sku is used. Profile sku: %s", profile.Sku.Name) | ||
} | ||
|
||
endpoint.EndpointPropertiesUpdateParameters.DeliveryPolicy = deliveryPolicy | ||
endpoint.EndpointPropertiesUpdateParameters.DeliveryPolicy = deliveryPolicy | ||
} | ||
} | ||
|
||
future, err := endpointsClient.Update(ctx, id.ResourceGroup, id.ProfileName, id.Name, endpoint) | ||
|
@@ -453,14 +469,18 @@ func resourceCdnEndpointRead(d *schema.ResourceData, meta interface{}) error { | |
} | ||
} | ||
|
||
contentTypes := flattenAzureRMCdnEndpointContentTypes(props.ContentTypesToCompress) | ||
if err := d.Set("content_types_to_compress", contentTypes); err != nil { | ||
return fmt.Errorf("Error setting `content_types_to_compress`: %+v", err) | ||
if _, ok := d.GetOk("content_types_to_compress"); ok { | ||
contentTypes := flattenAzureRMCdnEndpointContentTypes(props.ContentTypesToCompress) | ||
if err := d.Set("content_types_to_compress", contentTypes); err != nil { | ||
return fmt.Errorf("Error setting `content_types_to_compress`: %+v", err) | ||
} | ||
} | ||
|
||
geoFilters := flattenCdnEndpointGeoFilters(props.GeoFilters) | ||
if err := d.Set("geo_filter", geoFilters); err != nil { | ||
return fmt.Errorf("Error setting `geo_filter`: %+v", err) | ||
if _, ok := d.GetOk("geo_filter"); ok { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we need this check? or does the API return a default value? |
||
geoFilters := flattenCdnEndpointGeoFilters(props.GeoFilters) | ||
if err := d.Set("geo_filter", geoFilters); err != nil { | ||
return fmt.Errorf("Error setting `geo_filter`: %+v", err) | ||
} | ||
} | ||
|
||
origins := flattenAzureRMCdnEndpointOrigin(props.Origins) | ||
|
@@ -662,6 +682,10 @@ func flattenAzureRMCdnEndpointOrigin(input *[]cdn.DeepCreatedOrigin) []interface | |
} | ||
|
||
func expandArmCdnEndpointDeliveryPolicy(globalRulesRaw []interface{}, deliveryRulesRaw []interface{}) (*cdn.EndpointPropertiesUpdateParametersDeliveryPolicy, error) { | ||
if len(globalRulesRaw) == 0 && len(deliveryRulesRaw) == 0 { | ||
return nil, nil | ||
} | ||
|
||
deliveryRules := make([]cdn.DeliveryRule, 0) | ||
deliveryPolicy := cdn.EndpointPropertiesUpdateParametersDeliveryPolicy{ | ||
Description: utils.String(""), | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need this check? or does the API return a default value?