Skip to content
This repository has been archived by the owner on May 15, 2023. It is now read-only.

Add support for cacheKeyPolicy in BackendBuckets #731

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions converters/google/resources/compute_backend_bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@ func expandComputeBackendBucketCdnPolicy(v interface{}, d TerraformResourceData,
original := raw.(map[string]interface{})
transformed := make(map[string]interface{})

transformedCacheKeyPolicy, err := expandComputeBackendBucketCdnPolicyCacheKeyPolicy(original["cache_key_policy"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedCacheKeyPolicy); val.IsValid() && !isEmptyValue(val) {
transformed["cacheKeyPolicy"] = transformedCacheKeyPolicy
}

transformedSignedUrlCacheMaxAgeSec, err := expandComputeBackendBucketCdnPolicySignedUrlCacheMaxAgeSec(original["signed_url_cache_max_age_sec"], d, config)
if err != nil {
return nil, err
Expand Down Expand Up @@ -166,6 +173,40 @@ func expandComputeBackendBucketCdnPolicy(v interface{}, d TerraformResourceData,
return transformed, nil
}

func expandComputeBackendBucketCdnPolicyCacheKeyPolicy(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
l := v.([]interface{})
if len(l) == 0 || l[0] == nil {
return nil, nil
}
raw := l[0]
original := raw.(map[string]interface{})
transformed := make(map[string]interface{})

transformedQueryStringWhitelist, err := expandComputeBackendBucketCdnPolicyCacheKeyPolicyQueryStringWhitelist(original["query_string_whitelist"], d, config)
if err != nil {
return nil, err
} else {
transformed["queryStringWhitelist"] = transformedQueryStringWhitelist
}

transformedIncludeHttpHeaders, err := expandComputeBackendBucketCdnPolicyCacheKeyPolicyIncludeHttpHeaders(original["include_http_headers"], d, config)
if err != nil {
return nil, err
} else {
transformed["includeHttpHeaders"] = transformedIncludeHttpHeaders
}

return transformed, nil
}

func expandComputeBackendBucketCdnPolicyCacheKeyPolicyQueryStringWhitelist(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
return v, nil
}

func expandComputeBackendBucketCdnPolicyCacheKeyPolicyIncludeHttpHeaders(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
return v, nil
}

func expandComputeBackendBucketCdnPolicySignedUrlCacheMaxAgeSec(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
return v, nil
}
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ require (
github.com/hashicorp/errwrap v1.0.0
github.com/hashicorp/go-cleanhttp v0.5.2
github.com/hashicorp/terraform-json v0.13.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.10.1
github.com/hashicorp/terraform-provider-google v1.20.1-0.20220531163602-f4804246ce4c
github.com/hashicorp/terraform-plugin-sdk/v2 v2.16.0
github.com/hashicorp/terraform-provider-google v1.20.1-0.20220531215810-5332c033bfcc
github.com/kr/pretty v0.3.0 // indirect
github.com/mitchellh/go-homedir v1.1.0
github.com/onsi/gomega v1.17.0 // indirect
Expand Down
Loading