Skip to content

Commit 94617a7

Browse files
authored
chore(grit): make state replacements more flexible
Updates the state migrations to allow attributes before the `managed` key which has better support for module replacements without compromising on specifics.
1 parent 6c081d9 commit 94617a7

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

.grit/patterns/cloudflare_terraform_v5_attribute_renames_state.grit

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,23 @@ language json
33
pattern cloudflare_terraform_v5_attribute_renames_state() {
44
any {
55
// clear out any previously defined schema bumps
6-
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
6+
`{ $..., "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
77
$resource_type <: r"^cloudflare_.*",
88
$instances <: any {
99
contains `"schema_version": $version`=> `"schema_version": 0`
1010
}
1111
},
1212

1313
// cloudflare_api_token
14-
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
14+
`{ $..., "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
1515
$resource_type <: contains `cloudflare_api_token`,
1616
$instances <: any {
1717
contains `"policy": $policy` => `"policies": $policy`
1818
}
1919
},
2020

2121
// cloudflare_account_member
22-
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
22+
`{ $..., "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
2323
$resource_type <: contains `cloudflare_account_member`,
2424
$instances <: any {
2525
contains `"role_ids": $roles` => `"roles": $roles`,
@@ -28,23 +28,23 @@ pattern cloudflare_terraform_v5_attribute_renames_state() {
2828
},
2929

3030
// cloudflare_byo_ip_prefix
31-
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
31+
`{ $..., "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
3232
$resource_type <: contains `cloudflare_byo_ip_prefix`,
3333
$instances <: any {
3434
contains `"advertisement": $ad` => `"advertised": $ad`
3535
}
3636
},
3737

3838
// cloudflare_hostname_tls_setting
39-
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
39+
`{ $..., "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
4040
$resource_type <: contains `cloudflare_hostname_tls_setting`,
4141
$instances <: any {
4242
contains `"setting": $setting` => `"setting_id": $setting`
4343
}
4444
},
4545

4646
// cloudflare_load_balancer
47-
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
47+
`{ $..., "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
4848
$resource_type <: contains `cloudflare_load_balancer`,
4949
$instances <: any {
5050
contains `"fallback_pool_id": $fp` => `"fallback_pool": $fp`,
@@ -53,87 +53,87 @@ pattern cloudflare_terraform_v5_attribute_renames_state() {
5353
},
5454

5555
// cloudflare_queue
56-
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
56+
`{ $..., "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
5757
$resource_type <: contains `cloudflare_queue`,
5858
$instances <: any {
5959
contains `"name": $q` => `"queue_name": $q`
6060
}
6161
},
6262

6363
// cloudflare_r2_bucket
64-
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
64+
`{ $..., "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
6565
$resource_type <: contains `cloudflare_r2_bucket`,
6666
$instances <: any {
6767
contains `"location_hint": $lh` => `"location": $lh`
6868
}
6969
},
7070

7171
// cloudflare_worker_kv
72-
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
72+
`{ $..., "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
7373
$resource_type <: contains `cloudflare_worker_kv`,
7474
$instances <: any {
7575
contains `"key": $key` => `"key_name": $key`
7676
}
7777
},
7878

7979
// cloudflare_logpull_retention
80-
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
80+
`{ $..., "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
8181
$resource_type <: contains `cloudflare_logpull_retention`,
8282
$instances <: any {
8383
contains `"enabled": $flag` => `"flag": $flag`
8484
}
8585
},
8686

8787
// cloudflare_logpush_ownership_challenge
88-
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
88+
`{ $..., "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
8989
$resource_type <: contains `cloudflare_logpush_ownership_challenge`,
9090
$instances <: any {
9191
contains `"ownership_challenge_filename": $ocf` => `"filename": $ocf`
9292
}
9393
},
9494

9595
// cloudflare_zero_trust_tunnel_cloudflared
96-
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
96+
`{ $..., "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
9797
$resource_type <: contains `cloudflare_zero_trust_tunnel_cloudflared`,
9898
$instances <: any {
9999
contains `"secret": $ts` => `"tunnel_secret": $ts`
100100
}
101101
},
102102

103103
// cloudflare_zero_trust_access_short_lived_certificate
104-
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
104+
`{ $..., "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
105105
$resource_type <: contains `cloudflare_zero_trust_access_short_lived_certificate`,
106106
$instances <: any {
107107
contains `"application_id": $app_id` => `"app_id": $app_id`
108108
}
109109
},
110110

111111
// cloudflare_workers_secret
112-
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
112+
`{ $..., "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
113113
$resource_type <: contains `cloudflare_workers_secret`,
114114
$instances <: any {
115115
contains `"secret_text": $st` => `"text": $st`
116116
}
117117
},
118118

119119
// cloudflare_workers_kv
120-
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
120+
`{ $..., "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
121121
$resource_type <: contains `cloudflare_workers_kv`,
122122
$instances <: any {
123123
contains `"key": $kn` => `"key_name": $kn`
124124
}
125125
},
126126

127127
// cloudflare_tiered_cache
128-
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
128+
`{ $..., "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
129129
$resource_type <: contains `cloudflare_tiered_cache`,
130130
$instances <: any {
131131
contains `"cache_type": $ct` => `"value": $ct`
132132
}
133133
},
134134

135135
// cloudflare_zone
136-
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
136+
`{ $..., "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
137137
$resource_type <: contains `cloudflare_zone`,
138138
$instances <: any {
139139
contains `"zone": $z` => `"name": $z`,
@@ -146,14 +146,14 @@ pattern cloudflare_terraform_v5_attribute_renames_state() {
146146
},
147147

148148
// cloudflare_access_policy & cloudflare_zero_trust_access_group
149-
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
149+
`{ $..., "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
150150
$resource_type <: contains `cloudflare_access_policy`,
151151
$instances <: any {
152152
contains `"application_id": $_` => .,
153153
contains `"precedence": $_` => .,
154154
}
155155
},
156-
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
156+
`{ $..., "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
157157
$resource_type <: contains `cloudflare_zero_trust_access_group`,
158158
$instances <: any {
159159
contains `"application_id": $_` => .,
@@ -162,28 +162,28 @@ pattern cloudflare_terraform_v5_attribute_renames_state() {
162162
},
163163

164164
// cloudflare_access_service_token & cloudflare_zero_trust_access_service_token
165-
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
165+
`{ $..., "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
166166
$resource_type <: contains `cloudflare_access_service_token`,
167167
$instances <: any {
168168
contains `"min_days_for_renewal": $_` => .,
169169
}
170170
},
171-
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
171+
`{ $..., "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
172172
$resource_type <: contains `cloudflare_zero_trust_access_service_token`,
173173
$instances <: any {
174174
contains `"min_days_for_renewal": $_` => .,
175175
}
176176
},
177177

178178
// cloudflare_tunnel & zero_trust_tunnel_cloudflared
179-
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
179+
`{ $..., "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
180180
$resource_type <: contains `cloudflare_tunnel`,
181181
$instances <: any {
182182
contains `"secret": $_` => .,
183183
contains `"cname": $_` => .,
184184
}
185185
},
186-
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
186+
`{ $..., "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
187187
$resource_type <: contains `zero_trust_tunnel_cloudflared`,
188188
$instances <: any {
189189
contains `"secret": $_` => .,
@@ -192,7 +192,7 @@ pattern cloudflare_terraform_v5_attribute_renames_state() {
192192
},
193193

194194
// cloudflare_record
195-
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
195+
`{ $..., "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
196196
$resource_type <: contains `cloudflare_record`,
197197
$instances <: any {
198198
contains `"data": [{$obj}]` => `"data": {
@@ -205,7 +205,7 @@ pattern cloudflare_terraform_v5_attribute_renames_state() {
205205
},
206206

207207
// cloudflare_origin_ca_certificate
208-
`{ "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
208+
`{ $..., "mode": "managed", "type": "$resource_type", $..., "instances":[$instances] }` where {
209209
$resource_type <: contains `cloudflare_origin_ca_certificate`,
210210
$instances <: any {
211211
contains `"min_days_for_renewal": $_` => .

0 commit comments

Comments
 (0)