dmartinol commented on code in PR #367:
URL:
https://github.com/apache/incubator-kie-kogito-serverless-operator/pull/367#discussion_r1467806685
##########
controllers/profiles/common/ensurer.go:
##########
@@ -62,10 +62,10 @@ type defaultObjectEnsurer struct {
creator ObjectCreator
}
-func (d *defaultObjectEnsurer) Ensure(ctx context.Context, workflow
*operatorapi.SonataFlow, visitors ...MutateVisitor) (client.Object,
controllerutil.OperationResult, error) {
+func (d *defaultObjectEnsurer) Ensure(ctx context.Context, workflow
*operatorapi.SonataFlow, platform *operatorapi.SonataFlowPlatform, visitors
...MutateVisitor) (client.Object, controllerutil.OperationResult, error) {
result := controllerutil.OperationResultNone
- object, err := d.creator(workflow)
+ object, err := d.creator(workflow, platform)
Review Comment:
I investigated this option and ATM I think it's not doable following your
proposal, because the `creator` field is a function of type:
```go
type ObjectCreator func(workflow *operatorapi.SonataFlow) (client.Object,
error)
```
and we cannot pass the `platform` reference to it, the signature is fixed.
What we can do, if you approve it, is to adopt an `interface` type instead,
like:
```go
type ObjectCreator interface {
Create(workflow *operatorapi.SonataFlow) (client.Object, error)
WithPlatform(platform *operatorapi.SonataFlowPlatform) ObjectCreator
}
```
and then use it as:
```go
if (d.platform == nil) {
object, err := d.creator.Create(workflow)
} else {
object, err := d.creator.WithPlatform(platform).Create(workflow)
}
```
Of course, all the existing functions of type `ObjectCreator` have to be
converted to `struct` with some basic implementation to hold the `platform`
reference.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]