ricardozanini commented on code in PR #535:
URL: 
https://github.com/apache/incubator-kie-kogito-serverless-operator/pull/535#discussion_r1792164862


##########
test/testdata/sonataflow.org_v1alpha08_sonataflow-simpleops.yaml:
##########
@@ -26,7 +26,7 @@ spec:
     container:
       # TODO use 
docker.io/apache/incubator-kie-sonataflow-minimal-example:latest
       # when we complete 
https://github.com/apache/incubator-kie-kogito-serverless-operator/issues/504
-      image: quay.io/kiegroup/sonataflow-minimal-example:latest
+      image: kind-registry:5000/testimage/sonataflow-minimal-example:0.1

Review Comment:
   We should replace this in runtime based on the result of the 
`SonataFlowBuild` status.



##########
internal/controller/validation/image_validator.go:
##########
@@ -0,0 +1,165 @@
+// Copyright 2024 Apache Software Foundation (ASF)
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package validation
+
+import (
+       "archive/tar"
+       "context"
+       "crypto/tls"
+       "fmt"
+       "io"
+       "net/http"
+
+       operatorapi 
"github.com/apache/incubator-kie-kogito-serverless-operator/api/v1alpha08"
+       "github.com/google/go-cmp/cmp"
+       "github.com/google/go-containerregistry/pkg/name"
+       v1 "github.com/google/go-containerregistry/pkg/v1"
+       "github.com/google/go-containerregistry/pkg/v1/remote"
+       "k8s.io/apimachinery/pkg/util/yaml"
+       ctrl "sigs.k8s.io/controller-runtime"
+       "sigs.k8s.io/controller-runtime/pkg/client"
+)
+
+type imageValidator struct{}
+
+const workflowName = "deployments/app/workflow.sw.json"

Review Comment:
   The workflow might be YAML, too. And we can't fix the file name. IIRC the 
file name is the same as `.metadata.name`. Investigation needed.



##########
internal/controller/validation/image_validator.go:
##########
@@ -0,0 +1,165 @@
+// Copyright 2024 Apache Software Foundation (ASF)
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package validation
+
+import (
+       "archive/tar"
+       "context"
+       "crypto/tls"
+       "fmt"
+       "io"
+       "net/http"
+
+       operatorapi 
"github.com/apache/incubator-kie-kogito-serverless-operator/api/v1alpha08"
+       "github.com/google/go-cmp/cmp"
+       "github.com/google/go-containerregistry/pkg/name"
+       v1 "github.com/google/go-containerregistry/pkg/v1"
+       "github.com/google/go-containerregistry/pkg/v1/remote"
+       "k8s.io/apimachinery/pkg/util/yaml"
+       ctrl "sigs.k8s.io/controller-runtime"
+       "sigs.k8s.io/controller-runtime/pkg/client"
+)
+
+type imageValidator struct{}
+
+const workflowName = "deployments/app/workflow.sw.json"

Review Comment:
   ```suggestion
   const workflowPath = "deployments/app/workflow.sw.json"
   ```



##########
.github/workflows/e2e.yml:
##########
@@ -76,6 +76,10 @@ jobs:
           make container-build BUILDER=docker IMG=${{ env.OPERATOR_IMAGE_NAME 
}}
           kind load docker-image ${{ env.OPERATOR_IMAGE_NAME }}
 
+      - name: Build and Install SonataFlow worfklow test images
+        run: |
+          make workflow_test_image_build-and-push

Review Comment:
   This is unnecessary. The e2e `BeforeSuite` uses the operator to deploy three 
workflows to build images within the cluster. At the end of the build, the 
suite will fetch the images from the `SonataFlowBuild` `.status.image`. 
   
   During the e2e, we replace the `e2e/testdata` YAML 
`.spec.podTemplate.container.image` attribute. So that when the operator 
deploys the `SonataFlow` custom resource the image is already there in the 
registry.
   
   If you were to add a new e2e make sure to use the 
[kubectlPatchSonataFlowImageAndRollout](https://github.com/apache/incubator-kie-kogito-serverless-operator/blob/main/test/e2e/helpers.go#L97)
 to replace with the right image tag:
   
   ```go
   type E2EWorkflows struct {
        // CallBackPersistence is the prebuilt workflow to use on every use 
case that requires persistence
        CallBackPersistence E2EWorkflowEntry
        // CallBack is the prebuilt workflow to use on every use case that 
requires events or jobs services integration
        CallBack E2EWorkflowEntry
        // Greetings is the general usage image to use on any use case that 
requires a SonataFlow deployment
        Greetings E2EWorkflowEntry
   }
   ```



##########
internal/controller/validation/image_url_sanitizer.go:
##########
@@ -0,0 +1,69 @@
+// Copyright 2024 Apache Software Foundation (ASF)
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package validation
+
+import (
+       "context"
+       "fmt"
+       "net"
+
+       operatorapi 
"github.com/apache/incubator-kie-kogito-serverless-operator/api/v1alpha08"
+       "github.com/google/go-containerregistry/pkg/name"
+       ctrl "sigs.k8s.io/controller-runtime"
+       "sigs.k8s.io/controller-runtime/pkg/client"
+)
+
+type imageUrlSanitizer struct{}
+
+func (v *imageUrlSanitizer) Validate(ctx context.Context, client 
client.Client, sonataflow *operatorapi.SonataFlow, req ctrl.Request) error {
+       isInKindRegistry, kindRegistryUrl, err := 
imageStoredInKindRegistry(ctx, sonataflow.Spec.PodTemplate.Container.Image)

Review Comment:
   I don't think this is necessary; the docker API should be enough since Kind 
implements OCI.



-- 
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]

Reply via email to