Skip to content

Commit

Permalink
Add fields to support configuring new Media CDN features via Terrafor…
Browse files Browse the repository at this point in the history
…m. (#12902) (#3384)

[upstream:e108fe965dd81ce114643aa917834594eb5c2828]

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Jan 31, 2025
1 parent 888a7ca commit e6a6a09
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
github.com/hashicorp/hcl/v2 v2.20.1
github.com/hashicorp/terraform-json v0.22.1
github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0
github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20250131200031-88dcd513b784
github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20250131210038-b3ab3db47c22
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.9.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0 h1:qHprzXy/As0rxedphECBEQAh
github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0/go.mod h1:H+8tjs9TjV2w57QFVSMBQacf8k/E1XwLXGCARgViC6A=
github.com/hashicorp/terraform-plugin-testing v1.5.1 h1:T4aQh9JAhmWo4+t1A7x+rnxAJHCDIYW9kXyo4sVO92c=
github.com/hashicorp/terraform-plugin-testing v1.5.1/go.mod h1:dg8clO6K59rZ8w9EshBmDp1CxTIPu3yA4iaDpX1h5u0=
github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20250131200031-88dcd513b784 h1:Iftzfuauk/KbEFjZOnw3OQqBeoueAbha2T1YEKa5E+w=
github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20250131200031-88dcd513b784/go.mod h1:IkJf/cFmSb0kvMORnXqL/PqiMSLMSAuOKHzH60Fea58=
github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20250131210038-b3ab3db47c22 h1:qG9l5fyYvOoUwP0Ug6TnV3fYhWoWl3WHDX1Ryn9nJB8=
github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20250131210038-b3ab3db47c22/go.mod h1:IkJf/cFmSb0kvMORnXqL/PqiMSLMSAuOKHzH60Fea58=
github.com/hashicorp/terraform-registry-address v0.2.3 h1:2TAiKJ1A3MAkZlH1YI/aTVcLZRu7JseiXNRHbOAyoTI=
github.com/hashicorp/terraform-registry-address v0.2.3/go.mod h1:lFHA76T8jfQteVfT7caREqguFrW3c4MFSPhZB7HHgUM=
github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S52uzrw4x0jKQ=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,13 @@ func expandNetworkServicesEdgeCacheServiceRoutingPathMatcherRouteRule(v interfac
transformed["matchRules"] = transformedMatchRule
}

transformedRouteMethods, err := expandNetworkServicesEdgeCacheServiceRoutingPathMatcherRouteRuleRouteMethods(original["route_methods"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedRouteMethods); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["routeMethods"] = transformedRouteMethods
}

transformedHeaderAction, err := expandNetworkServicesEdgeCacheServiceRoutingPathMatcherRouteRuleHeaderAction(original["header_action"], d, config)
if err != nil {
return nil, err
Expand Down Expand Up @@ -534,6 +541,29 @@ func expandNetworkServicesEdgeCacheServiceRoutingPathMatcherRouteRuleMatchRuleFu
return v, nil
}

func expandNetworkServicesEdgeCacheServiceRoutingPathMatcherRouteRuleRouteMethods(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.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{})

transformedAllowedMethods, err := expandNetworkServicesEdgeCacheServiceRoutingPathMatcherRouteRuleRouteMethodsAllowedMethods(original["allowed_methods"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedAllowedMethods); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["allowedMethods"] = transformedAllowedMethods
}

return transformed, nil
}

func expandNetworkServicesEdgeCacheServiceRoutingPathMatcherRouteRuleRouteMethodsAllowedMethods(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}

func expandNetworkServicesEdgeCacheServiceRoutingPathMatcherRouteRuleHeaderAction(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
l := v.([]interface{})
if len(l) == 0 || l[0] == nil {
Expand Down Expand Up @@ -752,6 +782,13 @@ func expandNetworkServicesEdgeCacheServiceRoutingPathMatcherRouteRuleRouteAction
transformed["corsPolicy"] = transformedCorsPolicy
}

transformedCompressionMode, err := expandNetworkServicesEdgeCacheServiceRoutingPathMatcherRouteRuleRouteActionCompressionMode(original["compression_mode"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedCompressionMode); val.IsValid() && !tpgresource.IsEmptyValue(val) {
transformed["compressionMode"] = transformedCompressionMode
}

return transformed, nil
}

Expand Down Expand Up @@ -1218,6 +1255,10 @@ func expandNetworkServicesEdgeCacheServiceRoutingPathMatcherRouteRuleRouteAction
return v, nil
}

func expandNetworkServicesEdgeCacheServiceRoutingPathMatcherRouteRuleRouteActionCompressionMode(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}

func expandNetworkServicesEdgeCacheServiceRoutingPathMatcherRouteRuleOrigin(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}
Expand Down

0 comments on commit e6a6a09

Please sign in to comment.