Skip to content

Conversation

@ssicard
Copy link
Contributor

@ssicard ssicard commented Jun 10, 2025

Description

Adds validation for wasm processors in the operator webhook

Fixes # (issue)

Quick checks:

  • I have followed the Code Guidelines.
  • There is no other pull request for the same update/change.
  • I have written unit tests.
  • I have made sure that the PR is of reasonable size and can be easily reviewed.

@ssicard ssicard marked this pull request as ready for review June 12, 2025 22:21
@ssicard ssicard requested a review from a team as a code owner June 12, 2025 22:21
@ssicard ssicard force-pushed the ss/processor-wasm-support branch from 714cf14 to 362b3ad Compare June 12, 2025 22:22
@@ -0,0 +1,7 @@
package conduit
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like you are creating this interface to be able to mock it out in the tests. Did you take a look at the built in go package httptest ? You can use it to create a mock server for testing, without having to create your own interface.

https://go.dev/src/net/http/httptest/example_test.go

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I looked into it, but I mocking out net/http gives more control over the return. Looking into httptest, it seems like that would be better for testing our api, but I think since the aim of the http calls in validation is to services external to operator, mock is an easier setup for controlling api response.

Also, if it makes you feel better, this was moving code around, the http mocking was already in place in the validation. I just separated them into different files in this PR so that the different packages being mocked would be in different files for better organization.

return nil
}

var registryFactory = func(r *v1alpha.SchemaRegistry, fp *field.Path) (validation.PluginRegistry, *field.Error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious on your approach around creating the factory function as opposed to having one function that combines the factory implementation directly with the registry function implementation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I purely did this to be able to mock out the registry call in the webhook unit tests.

Co-authored-by: Nathan Stehr <nstehr@gmail.com>
// formatPluginName converts the plugin name into the format
// "conduit-connector-connectorName"
// Returns the github organization and the transformed connector name
// Returns the transformed connector name
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixing outdated comment

@@ -0,0 +1,7 @@
package conduit
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I looked into it, but I mocking out net/http gives more control over the return. Looking into httptest, it seems like that would be better for testing our api, but I think since the aim of the http calls in validation is to services external to operator, mock is an easier setup for controlling api response.

Also, if it makes you feel better, this was moving code around, the http mocking was already in place in the validation. I just separated them into different files in this PR so that the different packages being mocked would be in different files for better organization.

}

func (v *Validator) ValidateProcessorPlugin(p *v1alpha.ConduitProcessor, fp *field.Path) *field.Error {
func (v *Validator) ValidateProcessor(ctx context.Context, p *v1alpha.ConduitProcessor, reg PluginRegistry, fp *field.Path) *field.Error {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since we have one ValidateProcessor call, if we fail on validateProcessorPlugin, only that error will be returned, it is not being returned as a list of all errors.

return nil
}

var registryFactory = func(r *v1alpha.SchemaRegistry, fp *field.Path) (validation.PluginRegistry, *field.Error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I purely did this to be able to mock out the registry call in the webhook unit tests.

@ssicard ssicard merged commit 42550ce into main Jun 17, 2025
4 checks passed
@ssicard ssicard deleted the ss/processor-wasm-support branch June 17, 2025 21:05
nstehr added a commit that referenced this pull request Jun 20, 2025
This builds on #84. It adds the functionality to allow for the download and installation of a custom processor using the ProcessorURL field.

The processor will be saved to the volume used by the conduit pod.

Right now, when the pod is recreated it will download the processor again. There is currently no checking of checksums, versions, etc if any are saved and will overwrite the existing processor, given the name being the same.
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