Skip to content

Commit d20d039

Browse files
Merge branch 'next' into ajeffery/list-item-data-source
2 parents f38a7c7 + d7b51a6 commit d20d039

File tree

78 files changed

+8234
-357
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+8234
-357
lines changed

.grit/patterns/cloudflare_terraform_v5_attribute_renames_configuration.grit

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,45 @@ pattern cloudflare_terraform_v5_attribute_renames_configuration() {
5050
}
5151
},
5252

53+
//cloudflare_notification_policy
54+
`resource "cloudflare_notification_policy" $_ { $body }` where {
55+
56+
$body <: contains any {
57+
`webhooks_integration = $webhooks` => ``,
58+
`pagerduty_integration = $pagerduty` => ``,
59+
`email_integration = $email` => ``,
60+
},
61+
$integrations = "",
62+
//Check if the variable is null before adding to the integrations
63+
if (!$webhooks <: .) {
64+
$integrations += `webhooks = $webhooks
65+
`,
66+
},
67+
if (!$pagerduty <: .) {
68+
$integrations += `pagerduty = $pagerduty
69+
`,
70+
},
71+
if (!$email <: .) {
72+
$integrations += `email = $email
73+
`,
74+
},
75+
76+
$body => `$body mechanisms = {
77+
$integrations
78+
}`,
79+
},
80+
81+
// cloudflare_ruleset
82+
`resource "cloudflare_ruleset" $_ { $body }` where {
83+
$body <: any {
84+
contains bubble `rules = $rules` where {
85+
$rules <: contains bubble `action_parameters = $action_parameters` where {
86+
$action_parameters <: contains bubble `rules = { $ruleset_id = $rule_id}` => `rules = { $ruleset_id = [$rule_id]}`,
87+
}
88+
},
89+
}
90+
},
91+
5392
// cloudflare_teams_list & cloudflare_zero_trust_list
5493
`items = [$items]` as $all_items where {
5594
$values = [],

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 1793
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-4df5ed8ddf60ddcd6a01870d3bddce00cefb42270d87ef9900e5e15e8055d0b2.yml
3-
openapi_spec_hash: cabd4c35b0f8e0ccfa2a3d862a1df022
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-d40243b4192f76fb833e15210572c738f55fa868103caf6995ad710b15bae202.yml
3+
openapi_spec_hash: 37b7cfe9904bfd4e13a5b269266df631
44
config_hash: de4c81cee29cd7dd907279e8916b334f

docs/resources/snippet.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
page_title: "cloudflare_snippet Resource - Cloudflare"
3+
subcategory: ""
4+
description: |-
5+
6+
---
7+
8+
# cloudflare_snippet (Resource)
9+
10+
11+
12+
## Example Usage
13+
14+
```terraform
15+
resource "cloudflare_snippet" "example_snippet" {
16+
zone_id = "9f1839b6152d298aca64c4e906b6d074"
17+
snippet_name = "my_snippet"
18+
files = [
19+
{
20+
name = "main.js"
21+
content = <<-EOT
22+
export default {
23+
async fetch(request) {
24+
return new Response('Hello, World!');
25+
}
26+
}
27+
EOT
28+
}
29+
]
30+
metadata = {
31+
main_module = "main.js"
32+
}
33+
}
34+
```
35+
36+
<!-- schema generated by tfplugindocs -->
37+
## Schema
38+
39+
### Required
40+
41+
- `files` (List of String) The list of files belonging to the snippet.
42+
- `metadata` (Attributes) Metadata about the snippet. (see [below for nested schema](#nestedatt--metadata))
43+
- `snippet_name` (String) The identifying name of the snippet.
44+
- `zone_id` (String) The unique ID of the zone.
45+
46+
### Read-Only
47+
48+
- `created_on` (String) The timestamp of when the snippet was created.
49+
- `modified_on` (String) The timestamp of when the snippet was last modified.
50+
51+
<a id="nestedatt--metadata"></a>
52+
### Nested Schema for `metadata`
53+
54+
Required:
55+
56+
- `main_module` (String) Name of the file that contains the main module of the snippet.
57+
58+

examples/resources/cloudflare_snippet/resource.tf

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
11
resource "cloudflare_snippet" "example_snippet" {
2-
zone_id = "9f1839b6152d298aca64c4e906b6d074"
2+
zone_id = "9f1839b6152d298aca64c4e906b6d074"
33
snippet_name = "my_snippet"
4-
files = [null]
4+
files = [
5+
{
6+
name = "main.js"
7+
content = <<-EOT
8+
export default {
9+
async fetch(request) {
10+
return new Response('Hello, World!');
11+
}
12+
}
13+
EOT
14+
}
15+
]
516
metadata = {
617
main_module = "main.js"
718
}

go.mod

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ require (
99
github.com/aws/aws-sdk-go-v2/config v1.27.36
1010
github.com/aws/aws-sdk-go-v2/credentials v1.17.34
1111
github.com/aws/aws-sdk-go-v2/service/s3 v1.63.0
12-
github.com/cloudflare/cloudflare-go v0.104.0
13-
github.com/cloudflare/cloudflare-go/v5 v5.0.0
12+
github.com/cloudflare/cloudflare-go v0.115.0
13+
github.com/cloudflare/cloudflare-go/v5 v5.0.1-0.20250811144937-fd8fec5656c3
1414
github.com/davecgh/go-spew v1.1.1
1515
github.com/hashicorp/go-uuid v1.0.3
1616
github.com/hashicorp/terraform-plugin-docs v0.21.0
@@ -24,11 +24,11 @@ require (
2424
github.com/hashicorp/terraform-plugin-testing v1.13.2
2525
github.com/jinzhu/copier v0.4.0
2626
github.com/pkg/errors v0.9.1
27-
github.com/stretchr/testify v1.9.0
28-
github.com/tidwall/gjson v1.14.4
27+
github.com/stretchr/testify v1.10.0
28+
github.com/tidwall/gjson v1.18.0
2929
github.com/tidwall/sjson v1.2.5
3030
golang.org/x/exp v0.0.0-20230809150735-7b3493d9a819
31-
golang.org/x/text v0.26.0
31+
golang.org/x/text v0.28.0
3232
)
3333

3434
require (
@@ -59,7 +59,7 @@ require (
5959
github.com/bmatcuk/doublestar/v4 v4.8.1 // indirect
6060
github.com/cloudflare/circl v1.6.1 // indirect
6161
github.com/fatih/color v1.16.0 // indirect
62-
github.com/goccy/go-json v0.10.3 // indirect
62+
github.com/goccy/go-json v0.10.5 // indirect
6363
github.com/golang/protobuf v1.5.4 // indirect
6464
github.com/google/go-cmp v0.7.0 // indirect
6565
github.com/google/go-querystring v1.1.0 // indirect
@@ -107,13 +107,13 @@ require (
107107
github.com/yuin/goldmark-meta v1.1.0 // indirect
108108
github.com/zclconf/go-cty v1.16.3 // indirect
109109
go.abhg.dev/goldmark/frontmatter v0.2.0 // indirect
110-
golang.org/x/crypto v0.39.0 // indirect
111-
golang.org/x/mod v0.25.0 // indirect
112-
golang.org/x/net v0.40.0 // indirect
113-
golang.org/x/sync v0.15.0 // indirect
114-
golang.org/x/sys v0.33.0 // indirect
115-
golang.org/x/time v0.6.0 // indirect
116-
golang.org/x/tools v0.33.0 // indirect
110+
golang.org/x/crypto v0.41.0 // indirect
111+
golang.org/x/mod v0.26.0 // indirect
112+
golang.org/x/net v0.43.0 // indirect
113+
golang.org/x/sync v0.16.0 // indirect
114+
golang.org/x/sys v0.35.0 // indirect
115+
golang.org/x/time v0.12.0 // indirect
116+
golang.org/x/tools v0.35.0 // indirect
117117
google.golang.org/appengine v1.6.8 // indirect
118118
google.golang.org/genproto/googleapis/rpc v0.0.0-20250313205543-e70fdf4c4cb4 // indirect
119119
google.golang.org/grpc v1.72.1 // indirect

go.sum

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,12 @@ github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZ
6565
github.com/bufbuild/protocompile v0.4.0/go.mod h1:3v93+mbWn/v3xzN+31nwkJfrEpAUwp+BagBSZWx+TP8=
6666
github.com/cloudflare/circl v1.6.1 h1:zqIqSPIndyBh1bjLVVDHMPpVKqp8Su/V+6MeDzzQBQ0=
6767
github.com/cloudflare/circl v1.6.1/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZh3pJrofs=
68-
github.com/cloudflare/cloudflare-go v0.104.0 h1:R/lB0dZupaZbOgibAH/BRrkFbZ6Acn/WsKg2iX2xXuY=
69-
github.com/cloudflare/cloudflare-go v0.104.0/go.mod h1:pfUQ4PIG4ISI0/Mmc21Bp86UnFU0ktmPf3iTgbSL+cM=
70-
github.com/cloudflare/cloudflare-go/v5 v5.0.0 h1:t1N+0YADVAcnL1HL3FRUqPgDvCtbj2YJwxUYxLnEoyY=
71-
github.com/cloudflare/cloudflare-go/v5 v5.0.0/go.mod h1:C6OjOlDHOk/g7lXehothXJRFZrSIJMLzOZB2SXQhcjk=
68+
github.com/cloudflare/cloudflare-go v0.115.0 h1:84/dxeeXweCc0PN5Cto44iTA8AkG1fyT11yPO5ZB7sM=
69+
github.com/cloudflare/cloudflare-go v0.115.0/go.mod h1:Ds6urDwn/TF2uIU24mu7H91xkKP8gSAHxQ44DSZgVmU=
70+
github.com/cloudflare/cloudflare-go/v5 v5.0.1-0.20250811130229-fc80733ed1bb h1:nDhXAtTgRzRzHbUXJ1V1pBjZhOPnZN22q9qxg1UFj/k=
71+
github.com/cloudflare/cloudflare-go/v5 v5.0.1-0.20250811130229-fc80733ed1bb/go.mod h1:C6OjOlDHOk/g7lXehothXJRFZrSIJMLzOZB2SXQhcjk=
72+
github.com/cloudflare/cloudflare-go/v5 v5.0.1-0.20250811144937-fd8fec5656c3 h1:vmupCTCM/k59MeRYgCOVCVzKEqcBdF4g2j9Dh8n8MUU=
73+
github.com/cloudflare/cloudflare-go/v5 v5.0.1-0.20250811144937-fd8fec5656c3/go.mod h1:C6OjOlDHOk/g7lXehothXJRFZrSIJMLzOZB2SXQhcjk=
7274
github.com/cyphar/filepath-securejoin v0.4.1 h1:JyxxyPEaktOD+GAnqIqTf9A8tHyAG22rowi7HkoSU1s=
7375
github.com/cyphar/filepath-securejoin v0.4.1/go.mod h1:Sdj7gXlvMcPZsbhwhQ33GguGLDGQL7h7bg04C/+u9jI=
7476
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -93,8 +95,8 @@ github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
9395
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
9496
github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68=
9597
github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA=
96-
github.com/goccy/go-json v0.10.3 h1:KZ5WoDbxAIgm2HNbYckL0se1fHD6rz5j4ywS6ebzDqA=
97-
github.com/goccy/go-json v0.10.3/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
98+
github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4=
99+
github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
98100
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 h1:f+oWsMOmNPc8JmEHVZIycC7hBoQxHH9pNKQORJNozsQ=
99101
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8/go.mod h1:wcDNUvekVysuuOpQKo3191zZyTpiI6se1N1ULghS0sw=
100102
github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
@@ -243,11 +245,11 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf
243245
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
244246
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
245247
github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
246-
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
247-
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
248+
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
249+
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
248250
github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
249-
github.com/tidwall/gjson v1.14.4 h1:uo0p8EbA09J7RQaflQ1aBRffTR7xedD2bcIVSYxLnkM=
250-
github.com/tidwall/gjson v1.14.4/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
251+
github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY=
252+
github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
251253
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
252254
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
253255
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
@@ -290,25 +292,25 @@ go.opentelemetry.io/otel/trace v1.34.0/go.mod h1:Svm7lSjQD7kG7KJ/MUHPVXSDGz2OX4h
290292
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
291293
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
292294
golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
293-
golang.org/x/crypto v0.39.0 h1:SHs+kF4LP+f+p14esP5jAoDpHU8Gu/v9lFRK6IT5imM=
294-
golang.org/x/crypto v0.39.0/go.mod h1:L+Xg3Wf6HoL4Bn4238Z6ft6KfEpN0tJGo53AAPC632U=
295+
golang.org/x/crypto v0.41.0 h1:WKYxWedPGCTVVl5+WHSSrOBT0O8lx32+zxmHxijgXp4=
296+
golang.org/x/crypto v0.41.0/go.mod h1:pO5AFd7FA68rFak7rOAGVuygIISepHftHnr8dr6+sUc=
295297
golang.org/x/exp v0.0.0-20230809150735-7b3493d9a819 h1:EDuYyU/MkFXllv9QF9819VlI9a4tzGuCbhG0ExK9o1U=
296298
golang.org/x/exp v0.0.0-20230809150735-7b3493d9a819/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc=
297299
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
298-
golang.org/x/mod v0.25.0 h1:n7a+ZbQKQA/Ysbyb0/6IbB1H/X41mKgbhfv7AfG/44w=
299-
golang.org/x/mod v0.25.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww=
300+
golang.org/x/mod v0.26.0 h1:EGMPT//Ezu+ylkCijjPc+f4Aih7sZvaAr+O3EHBxvZg=
301+
golang.org/x/mod v0.26.0/go.mod h1:/j6NAhSk8iQ723BGAUyoAcn7SlD7s15Dp9Nd/SfeaFQ=
300302
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
301303
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
302304
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
303305
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
304306
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
305-
golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY=
306-
golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds=
307+
golang.org/x/net v0.43.0 h1:lat02VYK2j4aLzMzecihNvTlJNQUq316m2Mr9rnM6YE=
308+
golang.org/x/net v0.43.0/go.mod h1:vhO1fvI4dGsIjh73sWfUVjj3N7CA9WkKJNQm2svM6Jg=
307309
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
308310
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
309311
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
310-
golang.org/x/sync v0.15.0 h1:KWH3jNZsfyT6xfAfKiz6MRNmd46ByHDYaZ7KSkCtdW8=
311-
golang.org/x/sync v0.15.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
312+
golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw=
313+
golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
312314
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
313315
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
314316
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -321,8 +323,8 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc
321323
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
322324
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
323325
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
324-
golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw=
325-
golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
326+
golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI=
327+
golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
326328
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
327329
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
328330
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
@@ -331,15 +333,15 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
331333
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
332334
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
333335
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
334-
golang.org/x/text v0.26.0 h1:P42AVeLghgTYr4+xUnTRKDMqpar+PtX7KWuNQL21L8M=
335-
golang.org/x/text v0.26.0/go.mod h1:QK15LZJUUQVJxhz7wXgxSy/CJaTFjd0G+YLonydOVQA=
336-
golang.org/x/time v0.6.0 h1:eTDhh4ZXt5Qf0augr54TN6suAUudPcawVZeIAPU7D4U=
337-
golang.org/x/time v0.6.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
336+
golang.org/x/text v0.28.0 h1:rhazDwis8INMIwQ4tpjLDzUhx6RlXqZNPEM0huQojng=
337+
golang.org/x/text v0.28.0/go.mod h1:U8nCwOR8jO/marOQ0QbDiOngZVEBB7MAiitBuMjXiNU=
338+
golang.org/x/time v0.12.0 h1:ScB/8o8olJvc+CQPWrK3fPZNfh7qgwCrY0zJmoEQLSE=
339+
golang.org/x/time v0.12.0/go.mod h1:CDIdPxbZBQxdj6cxyCIdrNogrJKMJ7pr37NYpMcMDSg=
338340
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
339341
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
340342
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
341-
golang.org/x/tools v0.33.0 h1:4qz2S3zmRxbGIhDIAgjxvFutSvH5EfnsYrRBj0UI0bc=
342-
golang.org/x/tools v0.33.0/go.mod h1:CIJMaWEY88juyUfo7UbgPqbC8rU2OqfAV1h2Qp0oMYI=
343+
golang.org/x/tools v0.35.0 h1:mBffYraMEf7aa0sB+NuKnuCy8qI/9Bughn8dC2Gu5r0=
344+
golang.org/x/tools v0.35.0/go.mod h1:NKdj5HkL/73byiZSJjqJgKn3ep7KjFkBOkR/Hps3VPw=
343345
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
344346
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
345347
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=

internal/apiform/encoder.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,10 @@ func (e *encoder) newStructTypeEncoder(t reflect.Type) encoderFunc {
326326
if ptag.name == "-" {
327327
continue
328328
}
329+
// Computed fields come from the server
330+
if ptag.computed && !ptag.forceEncode {
331+
continue
332+
}
329333

330334
dateFormat, ok := parseFormatStructTag(field)
331335
oldFormat := e.dateFormat

internal/apiform/tag.go

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,17 @@ const formatStructTag = "format"
1111

1212
type parsedStructTag struct {
1313
name string
14-
required bool
1514
extras bool
16-
metadata bool
15+
computed bool
16+
// Don't skip this value, even if it's computed (no-op for computed optional fields)
17+
// If encodeStateForUnknown is set on a computed field, this flag should also be set;
18+
// otherwise this flag will have no effect
19+
// NOTE: won't work if update behavior is 'patch'
20+
forceEncode bool
21+
// Don't skip this value, even if it's computed (no-op for computed optional fields)
22+
// If encodeStateForUnknown is set on a computed field, this flag should also be set;
23+
// otherwise this flag will have no effect
24+
// NOTE: won't work if update behavior is 'patch'
1725
}
1826

1927
func parseFormStructTag(field reflect.StructField) (tag parsedStructTag, ok bool) {
@@ -31,12 +39,12 @@ func parseFormStructTag(field reflect.StructField) (tag parsedStructTag, ok bool
3139
tag.name = parts[0]
3240
for _, part := range parts[1:] {
3341
switch part {
34-
case "required":
35-
tag.required = true
3642
case "extras":
3743
tag.extras = true
38-
case "metadata":
39-
tag.metadata = true
44+
case "computed":
45+
tag.computed = true
46+
case "force_encode":
47+
tag.forceEncode = true
4048
}
4149
}
4250
return

0 commit comments

Comments
 (0)