This repository was archived by the owner on Dec 9, 2024. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What did you implement:
Calling the
UpdateFunction
endpoint in the ConfigAPI updated the function in thedefault
space, even if it was called for a different space. This PR fixes it.How did you implement it:
The initial problem is in the UpdateFunction method in
libkv
package. It's passed aspace
and a*function.Function
instance. Thespace
is used correctly when checking for the function's existence, but then it uses theSpace
attribute on thefunction.Function
instance when actually updating the function. TheSpace
attribute has been set to"default"
when it was sent through thevalidateFunction
method.I was going to just change the line to insert the updated function to use the
space
argument, but it seems like the different space confusion (space
argument vsfn.Space
) could happen again. Instead, I went up to thehttpapi
package and set thefn.Space
there. This is similar to how it's done in the registerFunction handler and makes it easier to reason about.The only change in behavior is that the function is now validated first, then checked for existence in the key-value store, rather than the other way around. This is because the
validateFunction
sets the functionSpace
if it isn't already set, and I needed to do that before checking for existence in a given space. I don't think the switch of order matters.The rest of the changes are just around changing the method signature, service interface, and tests for the new
UpdateFunction
method signature.How can we verify it:
Start the Event Gateway locally:
go run cmd/event-gateway/main.go -dev
Register a function in a space other than "default".
Update the function.
Call GetFunctions to ensure it reflects your update.
Todos:
Is this ready for review?: YES
Is it a breaking change?: NO