Skip to content

Commit ded3bb4

Browse files
authored
Merge pull request #5288 from cloudflare/refine-grit-pattern-for-multiple-matches
chore(grit): refine metadata matches to avoid reuse
2 parents 8ccb372 + 5ed5bbd commit ded3bb4

File tree

1 file changed

+91
-165
lines changed

1 file changed

+91
-165
lines changed

.grit/patterns/cloudflare_terraform_v5_attribute_renames_state.grit

Lines changed: 91 additions & 165 deletions
Original file line numberDiff line numberDiff line change
@@ -4,285 +4,211 @@ pattern cloudflare_terraform_v5_attribute_renames_state() {
44
any {
55
// clear out any previously defined schema bumps
66
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
7-
and {
8-
$resource_type <: r"^cloudflare_.*",
9-
$instances <: contains `"schema_version": $version`=> `"schema_version": 0`
7+
$resource_type <: r"^cloudflare_.*",
8+
$instances <: any {
9+
contains `"schema_version": $version`=> `"schema_version": 0`
1010
}
1111
},
1212

1313
// cloudflare_api_token
1414
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
15-
and {
16-
$resource_type <: contains `cloudflare_api_token`,
17-
$instances <: contains `"policy": $v` => `"policies": $v`
15+
$resource_type <: contains `cloudflare_api_token`,
16+
$instances <: any {
17+
contains `"policy": $policy` => `"policies": $policy`
1818
}
1919
},
2020

2121
// cloudflare_account_member
2222
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
23-
and {
24-
$resource_type <: contains `cloudflare_account_member`,
25-
$instances <: contains `"role_ids": $v` => `"roles": $v`
26-
}
27-
},
28-
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
29-
and {
30-
$resource_type <: contains `cloudflare_account_member`,
31-
$instances <: contains `"email_address": $v` => `"email": $v`
23+
$resource_type <: contains `cloudflare_account_member`,
24+
$instances <: any {
25+
contains `"role_ids": $roles` => `"roles": $roles`,
26+
contains `"email_address": $ea` => `"email": $ea`,
3227
}
3328
},
3429

3530
// cloudflare_byo_ip_prefix
3631
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
37-
and {
38-
$resource_type <: contains `cloudflare_byo_ip_prefix`,
39-
$instances <: contains `"advertisement": $v` => `"advertised": $v`
32+
$resource_type <: contains `cloudflare_byo_ip_prefix`,
33+
$instances <: any {
34+
contains `"advertisement": $ad` => `"advertised": $ad`
4035
}
4136
},
4237

4338
// cloudflare_hostname_tls_setting
4439
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
45-
and {
46-
$resource_type <: contains `cloudflare_hostname_tls_setting`,
47-
$instances <: contains `"setting": $v` => `"setting_id": $v`
40+
$resource_type <: contains `cloudflare_hostname_tls_setting`,
41+
$instances <: any {
42+
contains `"setting": $setting` => `"setting_id": $setting`
4843
}
4944
},
5045

5146
// cloudflare_load_balancer
5247
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
53-
and {
54-
$resource_type <: contains `cloudflare_load_balancer`,
55-
$instances <: contains `"fallback_pool_id": $v` => `"fallback_pool": $v`
56-
}
57-
},
58-
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
59-
and {
60-
$resource_type <: contains `cloudflare_load_balancer`,
61-
$instances <: contains `"default_pool_ids": $v` => `"default_pools": $v`
48+
$resource_type <: contains `cloudflare_load_balancer`,
49+
$instances <: any {
50+
contains `"fallback_pool_id": $fp` => `"fallback_pool": $fp`,
51+
contains `"default_pool_ids": $dp` => `"default_pools": $dp`,
6252
}
6353
},
6454

6555
// cloudflare_queue
6656
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
67-
and {
68-
$resource_type <: contains `cloudflare_queue`,
69-
$instances <: contains `"name": $v` => `"queue_name": $v`
57+
$resource_type <: contains `cloudflare_queue`,
58+
$instances <: any {
59+
contains `"name": $q` => `"queue_name": $q`
7060
}
7161
},
7262

7363
// cloudflare_r2_bucket
7464
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
75-
and {
76-
$resource_type <: contains `cloudflare_r2_bucket`,
77-
$instances <: contains `"location_hint": $v` => `"location": $v`
65+
$resource_type <: contains `cloudflare_r2_bucket`,
66+
$instances <: any {
67+
contains `"location_hint": $lh` => `"location": $lh`
7868
}
7969
},
8070

8171
// cloudflare_worker_kv
8272
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
83-
and {
84-
$resource_type <: contains `cloudflare_worker_kv`,
85-
$instances <: contains `"key": $v` => `"key_name": $v`
73+
$resource_type <: contains `cloudflare_worker_kv`,
74+
$instances <: any {
75+
contains `"key": $key` => `"key_name": $key`
8676
}
8777
},
8878

8979
// cloudflare_logpull_retention
9080
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
91-
and {
92-
$resource_type <: contains `cloudflare_logpull_retention`,
93-
$instances <: contains `"enabled": $v` => `"flag": $v`
81+
$resource_type <: contains `cloudflare_logpull_retention`,
82+
$instances <: any {
83+
contains `"enabled": $flag` => `"flag": $flag`
9484
}
9585
},
9686

9787
// cloudflare_logpush_ownership_challenge
9888
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
99-
and {
100-
$resource_type <: contains `cloudflare_logpush_ownership_challenge`,
101-
$instances <: contains `"ownership_challenge_filename": $v` => `"filename": $v`
89+
$resource_type <: contains `cloudflare_logpush_ownership_challenge`,
90+
$instances <: any {
91+
contains `"ownership_challenge_filename": $ocf` => `"filename": $ocf`
10292
}
10393
},
10494

10595
// cloudflare_zero_trust_tunnel_cloudflared
10696
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
107-
and {
108-
$resource_type <: contains `cloudflare_zero_trust_tunnel_cloudflared`,
109-
$instances <: contains `"secret": $v` => `"tunnel_secret": $v`
97+
$resource_type <: contains `cloudflare_zero_trust_tunnel_cloudflared`,
98+
$instances <: any {
99+
contains `"secret": $ts` => `"tunnel_secret": $ts`
110100
}
111101
},
112102

113103
// cloudflare_zero_trust_access_short_lived_certificate
114104
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
115-
and {
116-
$resource_type <: contains `cloudflare_zero_trust_access_short_lived_certificate`,
117-
$instances <: contains `"application_id": $v` => `"app_id": $v`
105+
$resource_type <: contains `cloudflare_zero_trust_access_short_lived_certificate`,
106+
$instances <: any {
107+
contains `"application_id": $app_id` => `"app_id": $app_id`
118108
}
119109
},
120110

121111
// cloudflare_workers_secret
122112
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
123-
and {
124-
$resource_type <: contains `cloudflare_workers_secret`,
125-
$instances <: contains `"secret_text": $v` => `"text": $v`
113+
$resource_type <: contains `cloudflare_workers_secret`,
114+
$instances <: any {
115+
contains `"secret_text": $st` => `"text": $st`
126116
}
127117
},
128118

129119
// cloudflare_workers_kv
130120
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
131-
and {
132-
$resource_type <: contains `cloudflare_workers_kv`,
133-
$instances <: contains `"key": $v` => `"key_name": $v`
121+
$resource_type <: contains `cloudflare_workers_kv`,
122+
$instances <: any {
123+
contains `"key": $kn` => `"key_name": $kn`
134124
}
135125
},
136126

137127
// cloudflare_tiered_cache
138128
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
139-
and {
140-
$resource_type <: contains `cloudflare_tiered_cache`,
141-
$instances <: contains `"cache_type": $v` => `"value": $v`
129+
$resource_type <: contains `cloudflare_tiered_cache`,
130+
$instances <: any {
131+
contains `"cache_type": $ct` => `"value": $ct`
142132
}
143133
},
144134

145135
// cloudflare_zone
146136
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
147-
and {
148-
$resource_type <: contains `cloudflare_zone`,
149-
$instances <: contains `"zone": $v` => `"name": $v`
150-
}
151-
},
152-
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
153-
and {
154-
$resource_type <: contains `cloudflare_zone`,
155-
$instances <: contains `"account_id": $v` => `"account": {
156-
"id": $v
157-
}`
158-
}
159-
},
160-
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
161-
and {
162-
$resource_type <: contains `cloudflare_zone`,
163-
$instances <: contains `"jump_start": $v` => .
164-
}
165-
},
166-
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
167-
and {
168-
$resource_type <: contains `cloudflare_zone`,
169-
$instances <: contains `"plan": $v` => .
137+
$resource_type <: contains `cloudflare_zone`,
138+
$instances <: any {
139+
contains `"zone": $z` => `"name": $z`,
140+
contains `"account_id": $av` => `"account": {
141+
"id": $av
142+
}`,
143+
contains `"jump_start": $_` => .,
144+
contains `"plan": $_` => .
170145
}
171146
},
172147

173148
// cloudflare_access_policy & cloudflare_zero_trust_access_group
174149
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
175-
and {
176-
$resource_type <: contains `cloudflare_access_policy`,
177-
$instances <: contains `"application_id": $v` => .
178-
}
179-
},
180-
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
181-
and {
182-
$resource_type <: contains `cloudflare_access_policy`,
183-
$instances <: contains `"precedence": $v` => .
184-
}
185-
},
186-
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
187-
and {
188-
$resource_type <: contains `cloudflare_zero_trust_access_group`,
189-
$instances <: contains `"application_id": $v` => .
150+
$resource_type <: contains `cloudflare_access_policy`,
151+
$instances <: any {
152+
contains `"application_id": $_` => .,
153+
contains `"precedence": $_` => .,
190154
}
191155
},
192156
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
193-
and {
194-
$resource_type <: contains `cloudflare_zero_trust_access_group`,
195-
$instances <: contains `"precedence": $v` => .
157+
$resource_type <: contains `cloudflare_zero_trust_access_group`,
158+
$instances <: any {
159+
contains `"application_id": $_` => .,
160+
contains `"precedence": $_` => .,
196161
}
197162
},
198163

199164
// cloudflare_access_service_token & cloudflare_zero_trust_access_service_token
200165
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
201-
and {
202-
$resource_type <: contains `cloudflare_access_service_token`,
203-
$instances <: contains `"min_days_for_renewal": $v` => .
166+
$resource_type <: contains `cloudflare_access_service_token`,
167+
$instances <: any {
168+
contains `"min_days_for_renewal": $_` => .,
204169
}
205170
},
206171
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
207-
and {
208-
$resource_type <: contains `cloudflare_zero_trust_access_service_token`,
209-
$instances <: contains `"min_days_for_renewal": $v` => .
172+
$resource_type <: contains `cloudflare_zero_trust_access_service_token`,
173+
$instances <: any {
174+
contains `"min_days_for_renewal": $_` => .,
210175
}
211176
},
212177

213178
// cloudflare_tunnel & zero_trust_tunnel_cloudflared
214179
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
215-
and {
216-
$resource_type <: contains `cloudflare_tunnel`,
217-
$instances <: contains `"secret": $v` => .
180+
$resource_type <: contains `cloudflare_tunnel`,
181+
$instances <: any {
182+
contains `"secret": $_` => .,
183+
contains `"cname": $_` => .,
218184
}
219185
},
220-
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
221-
and {
222-
$resource_type <: contains `cloudflare_tunnel`,
223-
$instances <: contains `"cname": $v` => .
224-
}
225-
},
226-
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
227-
and {
228-
$resource_type <: contains `zero_trust_tunnel_cloudflared`,
229-
$instances <: contains `"secret": $v` => .
230-
}
231-
},
232-
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
233-
and {
234-
$resource_type <: contains `zero_trust_tunnel_cloudflared`,
235-
$instances <: contains `"cname": $v` => .
236-
}
237-
},
238-
239-
// cloudflare_zone
240186
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
241-
and {
242-
$resource_type <: contains `cloudflare_zone`,
243-
$instances <: contains `"plan": $v` => .
244-
}
245-
},
246-
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
247-
and {
248-
$resource_type <: contains `cloudflare_zone`,
249-
$instances <: contains `"jump_start": $v` => .
187+
$resource_type <: contains `zero_trust_tunnel_cloudflared`,
188+
$instances <: any {
189+
contains `"secret": $_` => .,
190+
contains `"cname": $_` => .,
250191
}
251192
},
252193

253194
// cloudflare_record
254-
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
255-
and {
256-
$resource_type <: contains `cloudflare_record`,
257-
$instances <: contains `"data": [{$obj}]` => `"data": {
258-
$obj
259-
}`
260-
}
261-
},
262-
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
263-
and {
264-
$resource_type <: contains `cloudflare_record`,
265-
$instances <: contains `"data": []` => `"data": {}`
266-
}
267-
},
268-
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
269-
and {
270-
$resource_type <: contains `cloudflare_record`,
271-
$instances <: contains `"hostname": $v` => .
272-
}
273-
},
274195
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
275-
and {
276-
$resource_type <: contains `cloudflare_record`,
277-
$instances <: contains `"allow_overwrite": $v` => .
196+
$resource_type <: contains `cloudflare_record`,
197+
$instances <: any {
198+
contains `"data": [{$obj}]` => `"data": {
199+
$obj
200+
}`,
201+
contains `"data": []` => `"data": {}`,
202+
contains `"hostname": $_` => .,
203+
contains `"allow_overwrite": $_` => .,
278204
}
279205
},
280206

281207
// cloudflare_origin_ca_certificate
282208
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
283-
and {
284-
$resource_type <: contains `cloudflare_origin_ca_certificate`,
285-
$instances <: contains `"min_days_for_renewal": $v` => .
209+
$resource_type <: contains `cloudflare_origin_ca_certificate`,
210+
$instances <: any {
211+
contains `"min_days_for_renewal": $_` => .
286212
}
287213
},
288214
}

0 commit comments

Comments
 (0)