Reading a worker's compatibility date
I see that one can set a worker's compatibility date from wrangler (and by extension the API, although it is not documented).
Is there a way, instead, to just read the compatibility date? It is not displayed in the dashboard and I haven't seen an API route to fetch it. Thanks.
13 Replies
Same question for compatibility flags, by the way
There is as the terraform provider does it. I can parse the code later to find the exact endpoint for it
Never mind found it. Look at the api docs and where it has the depreciated bindings endpoint replace zone with accounts
Thank you very much !
@Cyb3r-Jok3 This doesn't give the compatibility date. I also dug in the Terraform Provider and it turns out that the compatibility date (and flags) are never read from the API. They are marked as both optional and computed. It's basically a write-only field.
Optional means you don't need to set them and Computed means that they can be set by the API
From Terraform's documentation:
Computed is often used to represent values that are not user configurable or can not be known at time of terraform plan or applyhttps://developer.hashicorp.com/terraform/plugin/sdkv2/schemas/schema-behaviors#computed They're the only 2 computed fields on a worker's deployment config. It basically means it is never read from the API. The handler to read the worker script resource also doesn't ever read nor write them So I am pretty confident that these fields are write-only
Write-only I'm going to disagree on but yeah it does look like they are never read
When you create or update a worker they are set
https://github.com/cloudflare/terraform-provider-cloudflare/blob/master/internal/sdkv2provider/resource_cloudflare_workers_script.go#L170-L178
Isn't "write-only" and "never read" the same thing?
It depends what you are refering to by write only. Do you mean something like they are never set locally by remote or they are only set by remote
I meant this is a field that can only be written and that can not be read, so write-only (as opposed to read-write or read-only)
In any case, the question is about "How can I read the compatibility date / flags of a worker?". The conclusion seems to be "you can't".
Yeah after reviewing the code, I was mistaken there is no documented way to read that info
No problem.
How do I make sure that someone from Cloudflare sees this?
You can post this as a feature suggestion in #workers-feature-suggestions
It seems to have been solved with the introduction of Versions: https://developers.cloudflare.com/api/operations/worker-script-get-settings
Cloudflare API Documentation
Interact with Cloudflare's products and services via the Cloudflare API