Allow implicit ResourceListProcessorFunc#760
Open
mozesl-nokia wants to merge 5 commits into
Open
Conversation
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
69b4d4d to
053b537
Compare
There was a problem hiding this comment.
Pull request overview
This PR updates the Go KRM Functions SDK’s AsMain entrypoint to accept more natural processor inputs (including plain functions matching the ResourceListProcessorFunc signature) without requiring explicit wrapping, and adds tests to cover the newly supported input forms.
Changes:
- Extend
AsMainto accept anyResourceListProcessorimplementation and rawfunc(*ResourceList) (bool, error)values. - Remove redundant processor type-casting logic from
Run. - Add a new unit test covering multiple
AsMaininput types (processor struct, implicit/explicit func, runner processor, anonymous func).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| go/fn/run.go | Broaden AsMain input handling and simplify Run by removing prior type switching. |
| go/fn/run_test.go | Add coverage for the expanded AsMain accepted input types. |
Comments suppressed due to low confidence (1)
go/fn/run.go:216
Runno longer validates the processor argument, so callingRun(nil, ...)will now panic whenp.Processis invoked. SinceRunis a public API, it should fail fast with a regular error for a nil processor (maintains the previous behavior of returning an error instead of panicking).
func Run(p ResourceListProcessor, input []byte) ([]byte, error) {
rl, err := ParseResourceList(input)
if err != nil {
return nil, err
}
success, fnErr := p.Process(rl)
out, yamlErr := rl.ToYAML()
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
liamfallon
approved these changes
Jun 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Currently, if you want to pass a function to AsMain, even if it has the correct ResourceListProcessorFunc signature, it will still fail the casting. Thus, it has to be explicitly wrapped.
With this PR, you can now just pass the function pointer or an anonymous/lambda function.
No AI was used in the creation of this PR.