Skip to content

Commit 638eb75

Browse files
committed
resource/cloudflare_tunnel_config: fix duration handling
Due to marshal/unmarshal support lacking in Go 1[1], we were previously sending nanosecond values to the API instead of the required seconds. This would have resulted in higher than usual timeout durations (10 seconds would have been sent as 1000000000 seconds since it duration unmarshals to nanoseconds). Updates all the instances of time duration handling in `cloudflare_tunnel_config` resource to use the newly introduced `TunnelDuration` to ensure we correctly setting the units. [1]: golang/go#10275
1 parent 7cd9097 commit 638eb75

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

internal/sdkv2provider/resource_cloudflare_tunnel_config.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ func resourceCloudflareTunnelConfig() *schema.Resource {
3636
func buildTunnelOriginRequest(originRequest map[string]interface{}) (originConfig cloudflare.OriginRequestConfig) {
3737
if v, ok := originRequest["connect_timeout"]; ok {
3838
timeout, _ := time.ParseDuration(v.(string))
39-
originConfig.ConnectTimeout = &timeout
39+
originConfig.ConnectTimeout = &cloudflare.TunnelDuration{timeout}
4040
}
4141
if v, ok := originRequest["tls_timeout"]; ok {
4242
timeout, _ := time.ParseDuration(v.(string))
43-
originConfig.TLSTimeout = &timeout
43+
originConfig.TLSTimeout = &cloudflare.TunnelDuration{timeout}
4444
}
4545
if v, ok := originRequest["tcp_keep_alive"]; ok {
4646
timeout, _ := time.ParseDuration(v.(string))
47-
originConfig.TCPKeepAlive = &timeout
47+
originConfig.TCPKeepAlive = &cloudflare.TunnelDuration{timeout}
4848
}
4949
if v, ok := originRequest["no_happy_eyeballs"]; ok {
5050
originConfig.NoHappyEyeballs = cloudflare.BoolPtr(v.(bool))
@@ -54,7 +54,7 @@ func buildTunnelOriginRequest(originRequest map[string]interface{}) (originConfi
5454
}
5555
if v, ok := originRequest["keep_alive_timeout"]; ok {
5656
timeout, _ := time.ParseDuration(v.(string))
57-
originConfig.KeepAliveTimeout = &timeout
57+
originConfig.KeepAliveTimeout = &cloudflare.TunnelDuration{timeout}
5858
}
5959
if v, ok := originRequest["http_host_header"]; ok {
6060
originConfig.HTTPHostHeader = cloudflare.StringPtr(v.(string))

0 commit comments

Comments
 (0)