Repository: cloudflare/cloudflare-go
Pull request #1138 (2022-12-03 19:40:02)

feat: adds OriginRequest field to UnvalidatedIngressRule struct.
## Description

Add OriginRequest field to UnvalidatedIngressRule struct documented [here](https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/install-and-setup/tunnel-guide/local/local-management/ingress/#origin-configuration).
Fixes: #1098

I'm aware #1099 but it seems like not active so I created this.

## Has your change been tested?

Yes

## Types of changes

What sort of change does your code introduce/modify?

- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)

## Checklist:

- [x] My code follows the code style of this project.
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [x] I have added tests to cover my changes.
- [x] All new and existing tests passed.
- [x] This change is using publicly documented (api.cloudflare.com or developers.cloudflare.com) and stable APIs.

[1]: https://help.github.com/articles/closing-issues-using-keywords/


Patch:
diff --git a/.changelog/1138.txt b/.changelog/1138.txt
new file mode 100644
index 000000000..69b22055c
--- /dev/null
+++ b/.changelog/1138.txt
@@ -0,0 +1,3 @@
+```release-note:enhancement
+adds OriginRequest field to UnvalidatedIngressRule struct.
+```
diff --git a/tunnel.go b/tunnel.go
index 5d9498e13..702be8fbc 100644
--- a/tunnel.go
+++ b/tunnel.go
@@ -106,9 +106,10 @@ type TunnelUpdateParams struct {
 }
 
 type UnvalidatedIngressRule struct {
-	Hostname string `json:"hostname,omitempty"`
-	Path     string `json:"path,omitempty"`
-	Service  string `json:"service,omitempty"`
+	Hostname      string               `json:"hostname,omitempty"`
+	Path          string               `json:"path,omitempty"`
+	Service       string               `json:"service,omitempty"`
+	OriginRequest *OriginRequestConfig `json:"originRequest,omitempty"`
 }
 
 // OriginRequestConfig is a set of optional fields that users may set to


Test patch:
diff --git a/testdata/fixtures/tunnel/configuration.json b/testdata/fixtures/tunnel/configuration.json
index 3267b8556..41e642cb4 100644
--- a/testdata/fixtures/tunnel/configuration.json
+++ b/testdata/fixtures/tunnel/configuration.json
@@ -7,7 +7,7 @@
       "warp-routing": { "enabled": true },
       "originRequest": { "connectTimeout": 10 },
       "ingress": [
-        { "hostname": "test.example.com", "service": "https://localhost:8000" },
+        { "hostname": "test.example.com", "service": "https://localhost:8000", "originRequest": { "noTLSVerify": true } },
         { "service": "http_status:404" }
       ]
     },
diff --git a/tunnel_test.go b/tunnel_test.go
index ced320c74..cacc12fb6 100644
--- a/tunnel_test.go
+++ b/tunnel_test.go
@@ -198,6 +198,9 @@ func TestUpdateTunnelConfiguration(t *testing.T) {
 				{
 					Hostname: "test.example.com",
 					Service:  "https://localhost:8000",
+					OriginRequest: &OriginRequestConfig{
+						NoTLSVerify: BoolPtr(true),
+					},
 				},
 				{
 					Service: "http_status:404",
@@ -218,6 +221,9 @@ func TestUpdateTunnelConfiguration(t *testing.T) {
 				{
 					Hostname: "test.example.com",
 					Service:  "https://localhost:8000",
+					OriginRequest: &OriginRequestConfig{
+						NoTLSVerify: BoolPtr(true),
+					},
 				},
 				{
 					Service: "http_status:404",
@@ -257,6 +263,9 @@ func TestGetTunnelConfiguration(t *testing.T) {
 				{
 					Hostname: "test.example.com",
 					Service:  "https://localhost:8000",
+					OriginRequest: &OriginRequestConfig{
+						NoTLSVerify: BoolPtr(true),
+					},
 				},
 				{
 					Service: "http_status:404",