Skip to content
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

Support for attaching a Worker to a Domain #1014

Merged
merged 5 commits into from
Aug 12, 2022

Conversation

sodabrew
Copy link
Contributor

@sodabrew sodabrew commented Aug 3, 2022

Description

Support for the new Custom Domain API at https://api.cloudflare.com/#worker-domain-attach-to-domain

Has your change been tested?

Works for me locally, unit tests will be added in PR review.

Screenshots (if appropriate):

Types of changes

What sort of change does your code introduce/modify?

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • This change is using publicly documented (api.cloudflare.com or developers.cloudflare.com)
  • ... and stable APIs. unclear.

@github-actions
Copy link
Contributor

github-actions bot commented Aug 3, 2022

changelog detected ✅

@codecov-commenter
Copy link

codecov-commenter commented Aug 3, 2022

Codecov Report

Merging #1014 (ee5e98e) into master (6c5ea4a) will increase coverage by 0.66%.
The diff coverage is 58.97%.

@@            Coverage Diff             @@
##           master    #1014      +/-   ##
==========================================
+ Coverage   49.06%   49.72%   +0.66%     
==========================================
  Files         108      115       +7     
  Lines       10428    10862     +434     
==========================================
+ Hits         5116     5401     +285     
- Misses       4200     4299      +99     
- Partials     1112     1162      +50     
Impacted Files Coverage Δ
access_application.go 76.52% <ø> (ø)
access_bookmark.go 72.44% <ø> (ø)
workers_account_settings.go 35.71% <35.71%> (ø)
workers_tail.go 52.00% <52.00%> (ø)
workers.go 69.42% <64.70%> (+0.71%) ⬆️
r2_bucket.go 100.00% <100.00%> (ø)
tunnel_routes.go 37.36% <0.00%> (ø)
workers_subdomain.go 57.14% <0.00%> (ø)
email_routing_rules.go 65.64% <0.00%> (ø)
email_routing_destination.go 66.25% <0.00%> (ø)
... and 6 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@sodabrew
Copy link
Contributor Author

sodabrew commented Aug 10, 2022

Working on tests next.

@jacobbednarz should I switch the arguments to be inside a struct? Some of the methods use a strict while others take direct arguments. I'm leaning towards switching to the struct pattern. Let me know!

@jacobbednarz
Copy link
Member

@sodabrew
Copy link
Contributor Author

sodabrew commented Aug 11, 2022

@jacobbednarz Updated per your examples, please review!

It seems like cloudflare.ZoneIdentifier could be used for this new call, but there's no other user of it in workers.go. https://github.com/cloudflare/cloudflare-go/blob/master/docs/experimental.md

In workers.go, I followed the example of DeleteWorker, DownloadWorker, etc. that have ZoneID in the respective params structs.

@jacobbednarz
Copy link
Member

It seems like cloudflare.ZoneIdentifier could be used for this new call, but there's no other user of it in workers.go.

there are currently no other implementation of ResourceContainer in the workers methods because they 1) predate the change 2) are pretty messy when it comes to what can live at what resource level. it hasn't been touched (but really should be improved) as the Workers API has evolved quite a bit since it was introduced and most of it is no longer needed.

going forward, we want to use the updated method signature for all new methods to help future proof against these issues.

@sodabrew
Copy link
Contributor Author

sodabrew commented Aug 11, 2022

going forward, we want to use the updated method signature for all new methods to help future proof against these issues.

Just to be clear, does that mean I should add the new method using the new style in a manner differently than my latest commit, or that you'll circle back to workers.go at a later date and redo all the method signatures in one go?

PS - I would expect to squash all commits in this PR, let me know if you'd like to do that as part of a review and merge or if I should force push my branch. I am very comfortable with rebase workflow, so this is no hardship at my end.

@jacobbednarz
Copy link
Member

does that mean I should add the new method using the new style in a manner differently than my latest commit

sorry if it wasn't clear. you should do this (i'll add a note inline as a reminder).

PS - I would expect to squash all commits in this PR, let me know if you'd like to do that as part of a review and merge or if I should force push my branch. I am very comfortable with rebase workflow, so this is no hardship at my end.

no need, i'm happy to merge/squash at the end.

workers.go Outdated Show resolved Hide resolved
workers.go Outdated Show resolved Hide resolved
workers_test.go Outdated Show resolved Hide resolved
workers_test.go Outdated Show resolved Hide resolved
workers_test.go Outdated Show resolved Hide resolved
workers_test.go Outdated Show resolved Hide resolved
workers_test.go Outdated
attachWorkerToDomainResponse = `{
"result": {
"id": "e7a57d8746e74ae49c25994dadb421b1",
"zone_id":"foo",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you'll want to use testZoneID here instead.

Copy link
Contributor Author

@sodabrew sodabrew Aug 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to move out of the const block to the var block in order to use fmt.Sprintf here

@jacobbednarz jacobbednarz merged commit b613af6 into cloudflare:master Aug 12, 2022
@jacobbednarz
Copy link
Member

thanks! appreciate the effort here!

@github-actions github-actions bot added this to the v0.47.0 milestone Aug 12, 2022
github-actions bot pushed a commit that referenced this pull request Aug 12, 2022
@sodabrew
Copy link
Contributor Author

Thank you!

@sodabrew sodabrew deleted the astone/attach-worker-domain branch August 17, 2022 03:12
@sodabrew sodabrew mentioned this pull request Aug 17, 2022
10 tasks
@github-actions
Copy link
Contributor

This functionality has been released in v0.47.0.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants