Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 05b25ba

Browse files
committedMar 18, 2025··
fix(workers_script): re-resolve the correct schemas
1 parent aaa36c3 commit 05b25ba

File tree

1 file changed

+318
-387
lines changed

1 file changed

+318
-387
lines changed
 

‎internal/services/workers_script/schema.go

+318-387
Original file line numberDiff line numberDiff line change
@@ -37,461 +37,358 @@ func ResourceSchema(ctx context.Context) schema.Schema {
3737
Required: true,
3838
PlanModifiers: []planmodifier.String{stringplanmodifier.RequiresReplace()},
3939
},
40-
"metadata": schema.SingleNestedAttribute{
41-
Description: "JSON encoded metadata about the uploaded parts and Worker configuration.",
40+
"content": schema.StringAttribute{
41+
Description: "Module or Service Worker contents of the Worker.",
4242
Required: true,
43+
},
44+
"assets": schema.SingleNestedAttribute{
45+
Description: "Configuration for assets within a Worker",
46+
Optional: true,
47+
CustomType: customfield.NewNestedObjectType[WorkersScriptMetadataAssetsModel](ctx),
4348
Attributes: map[string]schema.Attribute{
44-
"assets": schema.SingleNestedAttribute{
45-
Description: "Configuration for assets within a Worker",
49+
"config": schema.SingleNestedAttribute{
50+
Description: "Configuration for assets within a Worker.",
4651
Optional: true,
4752
Attributes: map[string]schema.Attribute{
48-
"config": schema.SingleNestedAttribute{
49-
Description: "Configuration for assets within a Worker.",
53+
"html_handling": schema.StringAttribute{
54+
Description: "Determines the redirects and rewrites of requests for HTML content.\nAvailable values: \"auto-trailing-slash\", \"force-trailing-slash\", \"drop-trailing-slash\", \"none\".",
5055
Optional: true,
51-
Attributes: map[string]schema.Attribute{
52-
"html_handling": schema.StringAttribute{
53-
Description: "Determines the redirects and rewrites of requests for HTML content.\nAvailable values: \"auto-trailing-slash\", \"force-trailing-slash\", \"drop-trailing-slash\", \"none\".",
54-
Optional: true,
55-
Validators: []validator.String{
56-
stringvalidator.OneOfCaseInsensitive(
57-
"auto-trailing-slash",
58-
"force-trailing-slash",
59-
"drop-trailing-slash",
60-
"none",
61-
),
62-
},
63-
},
64-
"not_found_handling": schema.StringAttribute{
65-
Description: "Determines the response when a request does not match a static asset, and there is no Worker script.\nAvailable values: \"none\", \"404-page\", \"single-page-application\".",
66-
Optional: true,
67-
Validators: []validator.String{
68-
stringvalidator.OneOfCaseInsensitive(
69-
"none",
70-
"404-page",
71-
"single-page-application",
72-
),
73-
},
74-
},
75-
"run_worker_first": schema.BoolAttribute{
76-
Description: "When true, requests will always invoke the Worker script. Otherwise, attempt to serve an asset matching the request, falling back to the Worker script.",
77-
Computed: true,
78-
Optional: true,
79-
Default: booldefault.StaticBool(false),
80-
},
81-
"serve_directly": schema.BoolAttribute{
82-
Description: "When true and the incoming request matches an asset, that will be served instead of invoking the Worker script. When false, requests will always invoke the Worker script.",
83-
Computed: true,
84-
Optional: true,
85-
Default: booldefault.StaticBool(true),
86-
},
56+
Validators: []validator.String{
57+
stringvalidator.OneOfCaseInsensitive(
58+
"auto-trailing-slash",
59+
"force-trailing-slash",
60+
"drop-trailing-slash",
61+
"none",
62+
),
63+
},
64+
},
65+
"not_found_handling": schema.StringAttribute{
66+
Description: "Determines the response when a request does not match a static asset, and there is no Worker script.\nAvailable values: \"none\", \"404-page\", \"single-page-application\".",
67+
Optional: true,
68+
Validators: []validator.String{
69+
stringvalidator.OneOfCaseInsensitive(
70+
"none",
71+
"404-page",
72+
"single-page-application",
73+
),
8774
},
8875
},
89-
"jwt": schema.StringAttribute{
90-
Description: "Token provided upon successful upload of all files from a registered manifest.",
76+
"run_worker_first": schema.BoolAttribute{
77+
Description: "When true, requests will always invoke the Worker script. Otherwise, attempt to serve an asset matching the request, falling back to the Worker script.",
78+
Computed: true,
9179
Optional: true,
92-
Sensitive: true,
80+
Default: booldefault.StaticBool(false),
81+
},
82+
"serve_directly": schema.BoolAttribute{
83+
Description: "When true and the incoming request matches an asset, that will be served instead of invoking the Worker script. When false, requests will always invoke the Worker script.",
84+
Computed: true,
85+
Optional: true,
86+
Default: booldefault.StaticBool(true),
9387
},
9488
},
9589
},
96-
"bindings": schema.ListNestedAttribute{
97-
Description: "List of bindings attached to a Worker. You can find more about bindings on our docs: https://developers.cloudflare.com/workers/configuration/multipart-upload-metadata/#bindings.",
90+
"jwt": schema.StringAttribute{
91+
Description: "Token provided upon successful upload of all files from a registered manifest.",
9892
Optional: true,
99-
NestedObject: schema.NestedAttributeObject{
93+
Sensitive: true,
94+
},
95+
},
96+
},
97+
"bindings": schema.ListNestedAttribute{
98+
Description: "List of bindings attached to a Worker. You can find more about bindings on our docs: https://developers.cloudflare.com/workers/configuration/multipart-upload-metadata/#bindings.",
99+
Optional: true,
100+
Computed: true,
101+
CustomType: customfield.NewNestedObjectListType[WorkersScriptMetadataBindingsModel](ctx),
102+
NestedObject: schema.NestedAttributeObject{
103+
Attributes: map[string]schema.Attribute{
104+
"name": schema.StringAttribute{
105+
Description: "A JavaScript variable name for the binding.",
106+
Required: true,
107+
},
108+
"type": schema.StringAttribute{
109+
Description: "The kind of resource that the binding provides.\nAvailable values: \"ai\", \"analytics_engine\", \"assets\", \"browser_rendering\", \"d1\", \"dispatch_namespace\", \"durable_object_namespace\", \"hyperdrive\", \"json\", \"kv_namespace\", \"mtls_certificate\", \"plain_text\", \"queue\", \"r2_bucket\", \"secret_text\", \"service\", \"tail_consumer\", \"vectorize\", \"version_metadata\".",
110+
Required: true,
111+
Validators: []validator.String{
112+
stringvalidator.OneOfCaseInsensitive(
113+
"ai",
114+
"analytics_engine",
115+
"assets",
116+
"browser_rendering",
117+
"d1",
118+
"dispatch_namespace",
119+
"durable_object_namespace",
120+
"hyperdrive",
121+
"json",
122+
"kv_namespace",
123+
"mtls_certificate",
124+
"plain_text",
125+
"queue",
126+
"r2_bucket",
127+
"secret_text",
128+
"service",
129+
"tail_consumer",
130+
"vectorize",
131+
"version_metadata",
132+
),
133+
},
134+
},
135+
"dataset": schema.StringAttribute{
136+
Description: "The name of the dataset to bind to.",
137+
Optional: true,
138+
},
139+
"id": schema.StringAttribute{
140+
Description: "Identifier of the D1 database to bind to.",
141+
Optional: true,
142+
},
143+
"namespace": schema.StringAttribute{
144+
Description: "Namespace to bind to.",
145+
Optional: true,
146+
},
147+
"outbound": schema.SingleNestedAttribute{
148+
Description: "Outbound worker.",
149+
Optional: true,
100150
Attributes: map[string]schema.Attribute{
101-
"name": schema.StringAttribute{
102-
Description: "A JavaScript variable name for the binding.",
103-
Required: true,
104-
},
105-
"type": schema.StringAttribute{
106-
Description: "The kind of resource that the binding provides.\nAvailable values: \"ai\", \"analytics_engine\", \"assets\", \"browser_rendering\", \"d1\", \"dispatch_namespace\", \"durable_object_namespace\", \"hyperdrive\", \"json\", \"kv_namespace\", \"mtls_certificate\", \"plain_text\", \"queue\", \"r2_bucket\", \"secret_text\", \"service\", \"tail_consumer\", \"vectorize\", \"version_metadata\".",
107-
Required: true,
108-
Validators: []validator.String{
109-
stringvalidator.OneOfCaseInsensitive(
110-
"ai",
111-
"analytics_engine",
112-
"assets",
113-
"browser_rendering",
114-
"d1",
115-
"dispatch_namespace",
116-
"durable_object_namespace",
117-
"hyperdrive",
118-
"json",
119-
"kv_namespace",
120-
"mtls_certificate",
121-
"plain_text",
122-
"queue",
123-
"r2_bucket",
124-
"secret_text",
125-
"service",
126-
"tail_consumer",
127-
"vectorize",
128-
"version_metadata",
129-
),
130-
},
131-
},
132-
"dataset": schema.StringAttribute{
133-
Description: "The name of the dataset to bind to.",
134-
Optional: true,
135-
},
136-
"id": schema.StringAttribute{
137-
Description: "Identifier of the D1 database to bind to.",
138-
Optional: true,
139-
},
140-
"namespace": schema.StringAttribute{
141-
Description: "Namespace to bind to.",
151+
"params": schema.ListAttribute{
152+
Description: "Pass information from the Dispatch Worker to the Outbound Worker through the parameters.",
142153
Optional: true,
154+
ElementType: types.StringType,
143155
},
144-
"outbound": schema.SingleNestedAttribute{
156+
"worker": schema.SingleNestedAttribute{
145157
Description: "Outbound worker.",
146158
Optional: true,
147159
Attributes: map[string]schema.Attribute{
148-
"params": schema.ListAttribute{
149-
Description: "Pass information from the Dispatch Worker to the Outbound Worker through the parameters.",
160+
"environment": schema.StringAttribute{
161+
Description: "Environment of the outbound worker.",
150162
Optional: true,
151-
ElementType: types.StringType,
152163
},
153-
"worker": schema.SingleNestedAttribute{
154-
Description: "Outbound worker.",
164+
"service": schema.StringAttribute{
165+
Description: "Name of the outbound worker.",
155166
Optional: true,
156-
Attributes: map[string]schema.Attribute{
157-
"environment": schema.StringAttribute{
158-
Description: "Environment of the outbound worker.",
159-
Optional: true,
160-
},
161-
"service": schema.StringAttribute{
162-
Description: "Name of the outbound worker.",
163-
Optional: true,
164-
},
165-
},
166167
},
167168
},
168169
},
169-
"class_name": schema.StringAttribute{
170-
Description: "The exported class name of the Durable Object.",
171-
Optional: true,
172-
},
173-
"environment": schema.StringAttribute{
174-
Description: "The environment of the script_name to bind to.",
175-
Optional: true,
176-
},
177-
"namespace_id": schema.StringAttribute{
178-
Description: "Namespace identifier tag.",
179-
Optional: true,
180-
},
181-
"script_name": schema.StringAttribute{
182-
Description: "The script where the Durable Object is defined, if it is external to this Worker.",
183-
Optional: true,
184-
},
185-
"json": schema.StringAttribute{
186-
Description: "JSON data to use.",
187-
Optional: true,
188-
},
189-
"certificate_id": schema.StringAttribute{
190-
Description: "Identifier of the certificate to bind to.",
191-
Optional: true,
192-
},
193-
"text": schema.StringAttribute{
194-
Description: "The text value to use.",
195-
Optional: true,
196-
Sensitive: true,
197-
},
198-
"queue_name": schema.StringAttribute{
199-
Description: "Name of the Queue to bind to.",
200-
Optional: true,
201-
},
202-
"bucket_name": schema.StringAttribute{
203-
Description: "R2 bucket to bind to.",
204-
Optional: true,
205-
},
206-
"service": schema.StringAttribute{
207-
Description: "Name of Worker to bind to.",
208-
Optional: true,
209-
},
210-
"index_name": schema.StringAttribute{
211-
Description: "Name of the Vectorize index to bind to.",
212-
Optional: true,
213-
},
214170
},
215171
},
172+
"class_name": schema.StringAttribute{
173+
Description: "The exported class name of the Durable Object.",
174+
Optional: true,
175+
},
176+
"environment": schema.StringAttribute{
177+
Description: "The environment of the script_name to bind to.",
178+
Optional: true,
179+
},
180+
"namespace_id": schema.StringAttribute{
181+
Description: "Namespace identifier tag.",
182+
Optional: true,
183+
},
184+
"script_name": schema.StringAttribute{
185+
Description: "The script where the Durable Object is defined, if it is external to this Worker.",
186+
Optional: true,
187+
},
188+
"json": schema.StringAttribute{
189+
Description: "JSON data to use.",
190+
Optional: true,
191+
},
192+
"certificate_id": schema.StringAttribute{
193+
Description: "Identifier of the certificate to bind to.",
194+
Optional: true,
195+
},
196+
"text": schema.StringAttribute{
197+
Description: "The text value to use.",
198+
Optional: true,
199+
Sensitive: true,
200+
},
201+
"queue_name": schema.StringAttribute{
202+
Description: "Name of the Queue to bind to.",
203+
Optional: true,
204+
},
205+
"bucket_name": schema.StringAttribute{
206+
Description: "R2 bucket to bind to.",
207+
Optional: true,
208+
},
209+
"service": schema.StringAttribute{
210+
Description: "Name of Worker to bind to.",
211+
Optional: true,
212+
},
213+
"index_name": schema.StringAttribute{
214+
Description: "Name of the Vectorize index to bind to.",
215+
Optional: true,
216+
},
216217
},
217-
"body_part": schema.StringAttribute{
218-
Description: "Name of the part in the multipart request that contains the script (e.g. the file adding a listener to the `fetch` event). Indicates a `service worker syntax` Worker.",
219-
Optional: true,
220-
},
221-
"compatibility_date": schema.StringAttribute{
222-
Description: "Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker.",
223-
Optional: true,
224-
},
225-
"compatibility_flags": schema.ListAttribute{
226-
Description: "Flags that enable or disable certain features in the Workers runtime. Used to enable upcoming features or opt in or out of specific changes not included in a `compatibility_date`.",
218+
},
219+
},
220+
"body_part": schema.StringAttribute{
221+
Description: "Name of the part in the multipart request that contains the script (e.g. the file adding a listener to the `fetch` event). Indicates a `service worker syntax` Worker.",
222+
Optional: true,
223+
},
224+
"compatibility_date": schema.StringAttribute{
225+
Description: "Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker.",
226+
Optional: true,
227+
},
228+
"compatibility_flags": schema.ListAttribute{
229+
Description: "Flags that enable or disable certain features in the Workers runtime. Used to enable upcoming features or opt in or out of specific changes not included in a `compatibility_date`.",
230+
Optional: true,
231+
ElementType: types.StringType,
232+
},
233+
"keep_assets": schema.BoolAttribute{
234+
Description: "Retain assets which exist for a previously uploaded Worker version; used in lieu of providing a completion token.",
235+
Optional: true,
236+
},
237+
"keep_bindings": schema.ListAttribute{
238+
Description: "List of binding types to keep from previous_upload.",
239+
Optional: true,
240+
ElementType: types.StringType,
241+
},
242+
"logpush": schema.BoolAttribute{
243+
Description: "Whether Logpush is turned on for the Worker.",
244+
Optional: true,
245+
Computed: true,
246+
},
247+
"main_module": schema.StringAttribute{
248+
Description: "Name of the part in the multipart request that contains the main module (e.g. the file exporting a `fetch` handler). Indicates a `module syntax` Worker.",
249+
Optional: true,
250+
},
251+
"migrations": schema.SingleNestedAttribute{
252+
Description: "Migrations to apply for Durable Objects associated with this Worker.",
253+
Optional: true,
254+
Computed: true,
255+
CustomType: customfield.NewNestedObjectType[WorkersScriptMetadataMigrationsModel](ctx),
256+
Attributes: map[string]schema.Attribute{
257+
"deleted_classes": schema.ListAttribute{
258+
Description: "A list of classes to delete Durable Object namespaces from.",
227259
Optional: true,
228260
ElementType: types.StringType,
229261
},
230-
"keep_assets": schema.BoolAttribute{
231-
Description: "Retain assets which exist for a previously uploaded Worker version; used in lieu of providing a completion token.",
262+
"new_classes": schema.ListAttribute{
263+
Description: "A list of classes to create Durable Object namespaces from.",
232264
Optional: true,
265+
ElementType: types.StringType,
233266
},
234-
"keep_bindings": schema.ListAttribute{
235-
Description: "List of binding types to keep from previous_upload.",
267+
"new_sqlite_classes": schema.ListAttribute{
268+
Description: "A list of classes to create Durable Object namespaces with SQLite from.",
236269
Optional: true,
237270
ElementType: types.StringType,
238271
},
239-
"logpush": schema.BoolAttribute{
240-
Description: "Whether Logpush is turned on for the Worker.",
272+
"new_tag": schema.StringAttribute{
273+
Description: "Tag to set as the latest migration tag.",
241274
Optional: true,
242275
},
243-
"main_module": schema.StringAttribute{
244-
Description: "Name of the part in the multipart request that contains the main module (e.g. the file exporting a `fetch` handler). Indicates a `module syntax` Worker.",
276+
"old_tag": schema.StringAttribute{
277+
Description: "Tag used to verify against the latest migration tag for this Worker. If they don't match, the upload is rejected.",
245278
Optional: true,
246279
},
247-
"migrations": schema.SingleNestedAttribute{
248-
Description: "Migrations to apply for Durable Objects associated with this Worker.",
280+
"renamed_classes": schema.ListNestedAttribute{
281+
Description: "A list of classes with Durable Object namespaces that were renamed.",
249282
Optional: true,
250-
Attributes: map[string]schema.Attribute{
251-
"deleted_classes": schema.ListAttribute{
252-
Description: "A list of classes to delete Durable Object namespaces from.",
253-
Optional: true,
254-
ElementType: types.StringType,
255-
},
256-
"new_classes": schema.ListAttribute{
257-
Description: "A list of classes to create Durable Object namespaces from.",
258-
Optional: true,
259-
ElementType: types.StringType,
260-
},
261-
"new_sqlite_classes": schema.ListAttribute{
262-
Description: "A list of classes to create Durable Object namespaces with SQLite from.",
263-
Optional: true,
264-
ElementType: types.StringType,
265-
},
266-
"new_tag": schema.StringAttribute{
267-
Description: "Tag to set as the latest migration tag.",
268-
Optional: true,
269-
},
270-
"old_tag": schema.StringAttribute{
271-
Description: "Tag used to verify against the latest migration tag for this Worker. If they don't match, the upload is rejected.",
272-
Optional: true,
273-
},
274-
"renamed_classes": schema.ListNestedAttribute{
275-
Description: "A list of classes with Durable Object namespaces that were renamed.",
276-
Optional: true,
277-
NestedObject: schema.NestedAttributeObject{
278-
Attributes: map[string]schema.Attribute{
279-
"from": schema.StringAttribute{
280-
Optional: true,
281-
},
282-
"to": schema.StringAttribute{
283-
Optional: true,
284-
},
285-
},
283+
NestedObject: schema.NestedAttributeObject{
284+
Attributes: map[string]schema.Attribute{
285+
"from": schema.StringAttribute{
286+
Optional: true,
286287
},
287-
},
288-
"transferred_classes": schema.ListNestedAttribute{
289-
Description: "A list of transfers for Durable Object namespaces from a different Worker and class to a class defined in this Worker.",
290-
Optional: true,
291-
NestedObject: schema.NestedAttributeObject{
292-
Attributes: map[string]schema.Attribute{
293-
"from": schema.StringAttribute{
294-
Optional: true,
295-
},
296-
"from_script": schema.StringAttribute{
297-
Optional: true,
298-
},
299-
"to": schema.StringAttribute{
300-
Optional: true,
301-
},
302-
},
288+
"to": schema.StringAttribute{
289+
Optional: true,
303290
},
304291
},
305-
"steps": schema.ListNestedAttribute{
306-
Description: "Migrations to apply in order.",
307-
Optional: true,
308-
NestedObject: schema.NestedAttributeObject{
309-
Attributes: map[string]schema.Attribute{
310-
"deleted_classes": schema.ListAttribute{
311-
Description: "A list of classes to delete Durable Object namespaces from.",
312-
Optional: true,
313-
ElementType: types.StringType,
314-
},
315-
"new_classes": schema.ListAttribute{
316-
Description: "A list of classes to create Durable Object namespaces from.",
317-
Optional: true,
318-
ElementType: types.StringType,
319-
},
320-
"new_sqlite_classes": schema.ListAttribute{
321-
Description: "A list of classes to create Durable Object namespaces with SQLite from.",
322-
Optional: true,
323-
ElementType: types.StringType,
324-
},
325-
"renamed_classes": schema.ListNestedAttribute{
326-
Description: "A list of classes with Durable Object namespaces that were renamed.",
327-
Optional: true,
328-
NestedObject: schema.NestedAttributeObject{
329-
Attributes: map[string]schema.Attribute{
330-
"from": schema.StringAttribute{
331-
Optional: true,
332-
},
333-
"to": schema.StringAttribute{
334-
Optional: true,
335-
},
336-
},
337-
},
338-
},
339-
"transferred_classes": schema.ListNestedAttribute{
340-
Description: "A list of transfers for Durable Object namespaces from a different Worker and class to a class defined in this Worker.",
341-
Optional: true,
342-
NestedObject: schema.NestedAttributeObject{
343-
Attributes: map[string]schema.Attribute{
344-
"from": schema.StringAttribute{
345-
Optional: true,
346-
},
347-
"from_script": schema.StringAttribute{
348-
Optional: true,
349-
},
350-
"to": schema.StringAttribute{
351-
Optional: true,
352-
},
353-
},
354-
},
355-
},
356-
},
357-
},
358-
},
359-
},
360-
},
361-
"observability": schema.SingleNestedAttribute{
362-
Description: "Observability settings for the Worker.",
363-
Optional: true,
364-
Attributes: map[string]schema.Attribute{
365-
"enabled": schema.BoolAttribute{
366-
Description: "Whether observability is enabled for the Worker.",
367-
Required: true,
368-
},
369-
"head_sampling_rate": schema.Float64Attribute{
370-
Description: "The sampling rate for incoming requests. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.",
371-
Optional: true,
372-
},
373292
},
374293
},
375-
"placement": schema.SingleNestedAttribute{
376-
Description: "Configuration for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).",
294+
"transferred_classes": schema.ListNestedAttribute{
295+
Description: "A list of transfers for Durable Object namespaces from a different Worker and class to a class defined in this Worker.",
377296
Optional: true,
378-
Attributes: map[string]schema.Attribute{
379-
"mode": schema.StringAttribute{
380-
Description: "Enables [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).\nAvailable values: \"smart\".",
381-
Optional: true,
382-
Validators: []validator.String{
383-
stringvalidator.OneOfCaseInsensitive("smart"),
297+
NestedObject: schema.NestedAttributeObject{
298+
Attributes: map[string]schema.Attribute{
299+
"from": schema.StringAttribute{
300+
Optional: true,
384301
},
385-
},
386-
"status": schema.StringAttribute{
387-
Description: "Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).\nAvailable values: \"SUCCESS\", \"UNSUPPORTED_APPLICATION\", \"INSUFFICIENT_INVOCATIONS\".",
388-
Computed: true,
389-
Validators: []validator.String{
390-
stringvalidator.OneOfCaseInsensitive(
391-
"SUCCESS",
392-
"UNSUPPORTED_APPLICATION",
393-
"INSUFFICIENT_INVOCATIONS",
394-
),
302+
"from_script": schema.StringAttribute{
303+
Optional: true,
304+
},
305+
"to": schema.StringAttribute{
306+
Optional: true,
395307
},
396308
},
397309
},
398310
},
399-
"tags": schema.ListAttribute{
400-
Description: "List of strings to use as tags for this Worker.",
401-
Optional: true,
402-
ElementType: types.StringType,
403-
},
404-
"tail_consumers": schema.ListNestedAttribute{
405-
Description: "List of Workers that will consume logs from the attached Worker.",
311+
"steps": schema.ListNestedAttribute{
312+
Description: "Migrations to apply in order.",
406313
Optional: true,
407314
NestedObject: schema.NestedAttributeObject{
408315
Attributes: map[string]schema.Attribute{
409-
"service": schema.StringAttribute{
410-
Description: "Name of Worker that is to be the consumer.",
411-
Required: true,
316+
"deleted_classes": schema.ListAttribute{
317+
Description: "A list of classes to delete Durable Object namespaces from.",
318+
Optional: true,
319+
ElementType: types.StringType,
320+
},
321+
"new_classes": schema.ListAttribute{
322+
Description: "A list of classes to create Durable Object namespaces from.",
323+
Optional: true,
324+
ElementType: types.StringType,
325+
},
326+
"new_sqlite_classes": schema.ListAttribute{
327+
Description: "A list of classes to create Durable Object namespaces with SQLite from.",
328+
Optional: true,
329+
ElementType: types.StringType,
412330
},
413-
"environment": schema.StringAttribute{
414-
Description: "Optional environment if the Worker utilizes one.",
331+
"renamed_classes": schema.ListNestedAttribute{
332+
Description: "A list of classes with Durable Object namespaces that were renamed.",
415333
Optional: true,
334+
NestedObject: schema.NestedAttributeObject{
335+
Attributes: map[string]schema.Attribute{
336+
"from": schema.StringAttribute{
337+
Optional: true,
338+
},
339+
"to": schema.StringAttribute{
340+
Optional: true,
341+
},
342+
},
343+
},
416344
},
417-
"namespace": schema.StringAttribute{
418-
Description: "Optional dispatch namespace the script belongs to.",
345+
"transferred_classes": schema.ListNestedAttribute{
346+
Description: "A list of transfers for Durable Object namespaces from a different Worker and class to a class defined in this Worker.",
419347
Optional: true,
348+
NestedObject: schema.NestedAttributeObject{
349+
Attributes: map[string]schema.Attribute{
350+
"from": schema.StringAttribute{
351+
Optional: true,
352+
},
353+
"from_script": schema.StringAttribute{
354+
Optional: true,
355+
},
356+
"to": schema.StringAttribute{
357+
Optional: true,
358+
},
359+
},
360+
},
420361
},
421362
},
422363
},
423364
},
424-
"usage_model": schema.StringAttribute{
425-
Description: "Usage model for the Worker invocations.\nAvailable values: \"standard\".",
426-
Optional: true,
427-
Validators: []validator.String{
428-
stringvalidator.OneOfCaseInsensitive("standard"),
429-
},
430-
},
431-
},
432-
},
433-
"created_on": schema.StringAttribute{
434-
Description: "When the script was created.",
435-
Computed: true,
436-
CustomType: timetypes.RFC3339Type{},
437-
},
438-
"etag": schema.StringAttribute{
439-
Description: "Hashed script content, can be used in a If-None-Match header when updating.",
440-
Computed: true,
441-
},
442-
"has_assets": schema.BoolAttribute{
443-
Description: "Whether a Worker contains assets.",
444-
Computed: true,
445-
},
446-
"has_modules": schema.BoolAttribute{
447-
Description: "Whether a Worker contains modules.",
448-
Computed: true,
449-
},
450-
"logpush": schema.BoolAttribute{
451-
Description: "Whether Logpush is turned on for the Worker.",
452-
Computed: true,
453-
},
454-
"modified_on": schema.StringAttribute{
455-
Description: "When the script was last modified.",
456-
Computed: true,
457-
CustomType: timetypes.RFC3339Type{},
458-
},
459-
"placement_mode": schema.StringAttribute{
460-
Description: "Enables [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).\nAvailable values: \"smart\".",
461-
Computed: true,
462-
Validators: []validator.String{
463-
stringvalidator.OneOfCaseInsensitive("smart"),
464-
},
465-
},
466-
"placement_status": schema.StringAttribute{
467-
Description: "Status of [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).\nAvailable values: \"SUCCESS\", \"UNSUPPORTED_APPLICATION\", \"INSUFFICIENT_INVOCATIONS\".",
468-
Computed: true,
469-
Validators: []validator.String{
470-
stringvalidator.OneOfCaseInsensitive(
471-
"SUCCESS",
472-
"UNSUPPORTED_APPLICATION",
473-
"INSUFFICIENT_INVOCATIONS",
474-
),
475365
},
476366
},
477-
"startup_time_ms": schema.Int64Attribute{
478-
Computed: true,
479-
},
480-
"usage_model": schema.StringAttribute{
481-
Description: "Usage model for the Worker invocations.\nAvailable values: \"standard\".",
367+
"observability": schema.SingleNestedAttribute{
368+
Description: "Observability settings for the Worker.",
369+
Optional: true,
482370
Computed: true,
483-
Validators: []validator.String{
484-
stringvalidator.OneOfCaseInsensitive("standard"),
371+
CustomType: customfield.NewNestedObjectType[WorkersScriptMetadataObservabilityModel](ctx),
372+
Attributes: map[string]schema.Attribute{
373+
"enabled": schema.BoolAttribute{
374+
Description: "Whether observability is enabled for the Worker.",
375+
Required: true,
376+
},
377+
"head_sampling_rate": schema.Float64Attribute{
378+
Description: "The sampling rate for incoming requests. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.",
379+
Optional: true,
380+
},
485381
},
486382
},
487383
"placement": schema.SingleNestedAttribute{
488384
Description: "Configuration for [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).",
385+
Optional: true,
489386
Computed: true,
490-
CustomType: customfield.NewNestedObjectType[WorkersScriptPlacementModel](ctx),
387+
CustomType: customfield.NewNestedObjectType[WorkersScriptMetadataPlacementModel](ctx),
491388
Attributes: map[string]schema.Attribute{
492389
"mode": schema.StringAttribute{
493390
Description: "Enables [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).\nAvailable values: \"smart\".",
494-
Computed: true,
391+
Optional: true,
495392
Validators: []validator.String{
496393
stringvalidator.OneOfCaseInsensitive("smart"),
497394
},
@@ -511,25 +408,59 @@ func ResourceSchema(ctx context.Context) schema.Schema {
511408
},
512409
"tail_consumers": schema.ListNestedAttribute{
513410
Description: "List of Workers that will consume logs from the attached Worker.",
411+
Optional: true,
514412
Computed: true,
515-
CustomType: customfield.NewNestedObjectListType[WorkersScriptTailConsumersModel](ctx),
413+
CustomType: customfield.NewNestedObjectListType[WorkersScriptMetadataTailConsumersModel](ctx),
516414
NestedObject: schema.NestedAttributeObject{
517415
Attributes: map[string]schema.Attribute{
518416
"service": schema.StringAttribute{
519417
Description: "Name of Worker that is to be the consumer.",
520-
Computed: true,
418+
Required: true,
521419
},
522420
"environment": schema.StringAttribute{
523421
Description: "Optional environment if the Worker utilizes one.",
524-
Computed: true,
422+
Optional: true,
525423
},
526424
"namespace": schema.StringAttribute{
527425
Description: "Optional dispatch namespace the script belongs to.",
528-
Computed: true,
426+
Optional: true,
529427
},
530428
},
531429
},
532430
},
431+
"usage_model": schema.StringAttribute{
432+
Description: "Usage model for the Worker invocations.\nAvailable values: \"standard\".",
433+
Optional: true,
434+
Computed: true,
435+
Validators: []validator.String{
436+
stringvalidator.OneOfCaseInsensitive("standard"),
437+
},
438+
},
439+
"created_on": schema.StringAttribute{
440+
Description: "When the script was created.",
441+
Computed: true,
442+
CustomType: timetypes.RFC3339Type{},
443+
},
444+
"etag": schema.StringAttribute{
445+
Description: "Hashed script content, can be used in a If-None-Match header when updating.",
446+
Computed: true,
447+
},
448+
"has_assets": schema.BoolAttribute{
449+
Description: "Whether a Worker contains assets.",
450+
Computed: true,
451+
},
452+
"has_modules": schema.BoolAttribute{
453+
Description: "Whether a Worker contains modules.",
454+
Computed: true,
455+
},
456+
"modified_on": schema.StringAttribute{
457+
Description: "When the script was last modified.",
458+
Computed: true,
459+
CustomType: timetypes.RFC3339Type{},
460+
},
461+
"startup_time_ms": schema.Int64Attribute{
462+
Computed: true,
463+
},
533464
},
534465
}
535466
}
@@ -540,4 +471,4 @@ func (r *WorkersScriptResource) Schema(ctx context.Context, req resource.SchemaR
540471

541472
func (r *WorkersScriptResource) ConfigValidators(_ context.Context) []resource.ConfigValidator {
542473
return []resource.ConfigValidator{}
543-
}
474+
}

0 commit comments

Comments
 (0)
Please sign in to comment.