-
Notifications
You must be signed in to change notification settings - Fork 630
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cloudflare worker secret resource #2628
Conversation
…ker script creation.
Co-authored-by: Jacob Bednarz <[email protected]>
changelog detected ✅ |
internal/sdkv2provider/resource_cloudflare_workers_secret_test.go
Outdated
Show resolved
Hide resolved
@jacobbednarz sorry to ping directly, just wondered if this feature is something Cloudflare want to have in the provider? I still have some work to do on the tests, but I'm quite keen to contribute where I can for this. |
yes, happy to review it once it is ready. I don't generally review in progress PRs until they are complete due to limited bandwidth. |
Tests fail with: === RUN TestAccCloudflareWorkerSecret_Import import_cloudflare_worker_secret_test.go:17: Step 2/2 error running import: ImportStateVerify attributes not equivalent. Difference is shown below. The - symbol indicates attributes missing after import. map[string]string{ - "secret_text": "pfeasocioh",
Ok the tests are passing for me locally, I think this is ready for review please 🙏 |
UpdateContext: resourceCloudflareWorkerSecretCreate, | ||
DeleteContext: resourceCloudflareWorkerSecretDelete, | ||
Importer: &schema.ResourceImporter{ | ||
StateContext: schema.ImportStatePassthroughContext, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this won't work with your custom import string of <account_id>/<script_name>/<secret_name>
. you need to define a custom Import
method and handle the import manually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created a custom import method which parses the import string of <account_id>/<script_name>/<secret_name>
return diag.FromErr(errors.Wrap(err, "error creating worker secret")) | ||
} | ||
|
||
d.SetId(fmt.Sprintf("%s/%s/%s", accountID, scriptName, name)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the ID
should be using stringChecksum
to ensure we are storing a hash, not including the values directly which may be dereferenced by other resources.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added the checksum
}, | ||
ProviderFactories: providerFactories, | ||
CheckDestroy: testAccCheckCloudflareWorkerSecretDestroy, | ||
Steps: []resource.TestStep{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should include a ImportState
assertion here too (which would have caught your incorrect Import
ID above).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added back a separate import secret test to be consistent with the other tests. This is currently failing with:
=== RUN TestAccCloudflareWorkerSecret_Import
import_cloudflare_worker_secret_test.go:17: Step 2/2 error running import: exit status 1
Error: invalid id ("0e5935a6b09194ee32e735261911e922") specified, should be in format "accountID/scriptName/secretName"
--- FAIL: TestAccCloudflareWorkerSecret_Import (23.28s)
This is because the Cloudflare API doesn't let you read back the secret text as it's encrypted. I'm not sure how to reconcile this to make the tests pass?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got the tests to pass by ignoring state verification for that field
This reverts commit da3d000.
Co-authored-by: Jacob Bednarz <[email protected]>
This is currently failing because the secret_text is not set, but this is not returned from the API so I'm not sure how to resolve this
… cloudflare_worker_secret
…ecret # Conflicts: # internal/sdkv2provider/provider.go
Marking this pull request as stale due to 14 days of inactivity. This helps our maintainers find and focus on the active pull requests. If this pull request receives no comments in the next 7 days it will automatically be closed. Maintainers can also remove the |
Marking this pull request as stale due to 14 days of inactivity. This helps our maintainers find and focus on the active pull requests. If this pull request receives no comments in the next 7 days it will automatically be closed. Maintainers can also remove the |
This PR was closed because it has been stalled for 7 days with no activity. |
Trying to resurrect #870. I've manually tested the new resource is working, but I may need some help addressing the comments in #870 which were not resolved before.