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

Add support for Service Bindings to Worker uploads #947

Merged
merged 1 commit into from
Jun 23, 2022

Conversation

ObsidianMinor
Copy link

This adds support for Service Bindings to Worker uploads, needed so we can support Service Bindings in our Terraform provider.

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.

@jacobbednarz
Copy link
Member

merging with public docs as the service team has confirmed this is a stable API and we are awaiting some documentation revamps.

@jacobbednarz jacobbednarz merged commit 31124cf into cloudflare:master Jun 23, 2022
@@ -268,6 +270,33 @@ func (b WorkerSecretTextBinding) serialize(bindingName string) (workerBindingMet
}, nil, nil
}

type WorkerServiceBinding struct {
Service string
Environment *string

Choose a reason for hiding this comment

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

Why pass as pointer here?

}

if b.Environment != nil {
meta["environment"] = *b.Environment

Choose a reason for hiding this comment

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

Oh, the pass as pointer required because this may be nil?

Copy link
Author

Choose a reason for hiding this comment

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

Right, if you pass nil or empty string the binding is set to the default environment.

@sodabrew
Copy link

merging with public docs as the service team has confirmed this is a stable API and we are awaiting some documentation revamps.

without public docs 👀

Interesting re: Environment can be nil. A good example why docs are helpful.

@sodabrew
Copy link

@ObsidianMinor In your case for handling Environment-is-nil, does it make sense given the proposal at cloudflare/workers-sdk#382 to use production in the API URL when the value is empty/nil? In this PR’s implementation, the calling code (or the Terraform provider!) would be making that decision. That seems fine, but does it align with the likely deprecation of workers that don’t have an environment value?

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.

3 participants