From 28a49340094e42ea1319ed5d91b0d8fc811a63a5 Mon Sep 17 00:00:00 2001 From: Dmitrii Tikhomirov Date: Thu, 13 Jun 2024 09:47:53 -0700 Subject: [PATCH 1/5] added isValidProfile to ProfileType (#479) --- api/metadata/annotations.go | 5 +++++ api/metadata/annotations_test.go | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/api/metadata/annotations.go b/api/metadata/annotations.go index a8f560913..f17897ede 100644 --- a/api/metadata/annotations.go +++ b/api/metadata/annotations.go @@ -92,6 +92,11 @@ func GetProfileOrDefault(annotation map[string]string) ProfileType { } } +func (p ProfileType) isValidProfile() bool { + _, ok := supportedProfiles[p] + return ok +} + func IsDevProfile(annotation map[string]string) bool { if annotation == nil { return false diff --git a/api/metadata/annotations_test.go b/api/metadata/annotations_test.go index b0437bb38..f69dbe912 100644 --- a/api/metadata/annotations_test.go +++ b/api/metadata/annotations_test.go @@ -41,3 +41,19 @@ func TestGetProfile(t *testing.T) { }) } } + +func TestIsValidProfile(t *testing.T) { + profiles := []ProfileType{DefaultProfile, GitOpsProfile, DevProfile} + for _, profile := range profiles { + if !profile.isValidProfile() { + t.Errorf("Profile %s is not valid", profile) + } + } + if ProdProfile.isValidProfile() { + t.Errorf("ProdProfile is deprecated and should not be valid") + } + // any random string should not be a valid profile + if ProfileType("random").isValidProfile() { + t.Errorf("random is not a valid profile") + } +} From 575811b5acba8e0cfafd1cd4db5d12c421b44eae Mon Sep 17 00:00:00 2001 From: Ricardo Zanini <1538000+ricardozanini@users.noreply.github.com> Date: Mon, 17 Jun 2024 14:54:06 -0300 Subject: [PATCH 2/5] :suspect: Fix resources display name (#490) Signed-off-by: Ricardo Zanini --- api/v1alpha08/sonataflow_types.go | 1 + api/v1alpha08/sonataflowbuild_types.go | 1 + api/v1alpha08/sonataflowclusterplatform_types.go | 1 + api/v1alpha08/sonataflowplatform_types.go | 1 + .../sonataflow-operator.clusterserviceversion.yaml | 8 ++++---- .../bases/sonataflow-operator.clusterserviceversion.yaml | 8 ++++---- 6 files changed, 12 insertions(+), 8 deletions(-) diff --git a/api/v1alpha08/sonataflow_types.go b/api/v1alpha08/sonataflow_types.go index 7763dc23d..e751e0036 100644 --- a/api/v1alpha08/sonataflow_types.go +++ b/api/v1alpha08/sonataflow_types.go @@ -255,6 +255,7 @@ func (s *SonataFlowStatus) IsBuildFailed() bool { // +operator-sdk:csv:customresourcedefinitions:resources={{Service,v1,"A Service for the Flow"}} // +operator-sdk:csv:customresourcedefinitions:resources={{Route,route.openshift.io/v1,"An OpenShift Route for the Flow"}} // +operator-sdk:csv:customresourcedefinitions:resources={{ConfigMap,v1,"The ConfigMaps with Flow definition and additional configuration files"}} +// +operator-sdk:csv:customresourcedefinitions:displayName="SonataFlow" type SonataFlow struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` diff --git a/api/v1alpha08/sonataflowbuild_types.go b/api/v1alpha08/sonataflowbuild_types.go index 0817936de..4b09ba35b 100644 --- a/api/v1alpha08/sonataflowbuild_types.go +++ b/api/v1alpha08/sonataflowbuild_types.go @@ -145,6 +145,7 @@ func (k *SonataFlowBuildStatus) GetInnerBuild(innerBuild interface{}) error { // +kubebuilder:printcolumn:name="Phase",type=string,JSONPath=`.status.buildPhase` // +kubebuilder:resource:shortName={"sfb", "sfbuild", "sfbuilds"} // +operator-sdk:csv:customresourcedefinitions:resources={{BuildConfig,build.openshift.io/v1,"An Openshift Build Config"}} +// +operator-sdk:csv:customresourcedefinitions:displayName="SonataFlowBuild" type SonataFlowBuild struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` diff --git a/api/v1alpha08/sonataflowclusterplatform_types.go b/api/v1alpha08/sonataflowclusterplatform_types.go index d5205d9ca..1ac3727cf 100644 --- a/api/v1alpha08/sonataflowclusterplatform_types.go +++ b/api/v1alpha08/sonataflowclusterplatform_types.go @@ -93,6 +93,7 @@ func (in *SonataFlowClusterPlatformStatus) IsDuplicated() bool { // +kubebuilder:printcolumn:name="Ready",type=string,JSONPath=`.status.conditions[?(@.type=='Succeed')].status` // +kubebuilder:printcolumn:name="Reason",type=string,JSONPath=`.status.conditions[?(@.type=='Succeed')].reason` // +operator-sdk:csv:customresourcedefinitions:resources={{SonataFlowPlatform,sonataflow.org/v1alpha08,"A SonataFlow Platform"}} +// +operator-sdk:csv:customresourcedefinitions:displayName="SonataFlowClusterPlatform" type SonataFlowClusterPlatform struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` diff --git a/api/v1alpha08/sonataflowplatform_types.go b/api/v1alpha08/sonataflowplatform_types.go index 26276fb8b..a564cde08 100644 --- a/api/v1alpha08/sonataflowplatform_types.go +++ b/api/v1alpha08/sonataflowplatform_types.go @@ -170,6 +170,7 @@ func (in *SonataFlowPlatformStatus) IsFailure() bool { // +kubebuilder:printcolumn:name="Ready",type=string,JSONPath=`.status.conditions[?(@.type=='Succeed')].status` // +kubebuilder:printcolumn:name="Reason",type=string,JSONPath=`.status.conditions[?(@.type=='Succeed')].reason` // +operator-sdk:csv:customresourcedefinitions:resources={{Namespace,v1,"The Namespace controlled by the platform"}} +// +operator-sdk:csv:customresourcedefinitions:displayName="SonataFlowPlatform" type SonataFlowPlatform struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` diff --git a/bundle/manifests/sonataflow-operator.clusterserviceversion.yaml b/bundle/manifests/sonataflow-operator.clusterserviceversion.yaml index 7e78264fa..73037612d 100644 --- a/bundle/manifests/sonataflow-operator.clusterserviceversion.yaml +++ b/bundle/manifests/sonataflow-operator.clusterserviceversion.yaml @@ -135,7 +135,7 @@ spec: owned: - description: SonataFlowBuild is an internal custom resource to control workflow build instances in the target platform - displayName: Sonata Flow Build + displayName: SonataFlowBuild kind: SonataFlowBuild name: sonataflowbuilds.sonataflow.org resources: @@ -182,7 +182,7 @@ spec: version: v1alpha08 - description: SonataFlowClusterPlatform is the Schema for the sonataflowclusterplatforms API - displayName: Sonata Flow Cluster Platform + displayName: SonataFlowClusterPlatform kind: SonataFlowClusterPlatform name: sonataflowclusterplatforms.sonataflow.org resources: @@ -211,7 +211,7 @@ spec: version: v1alpha08 - description: SonataFlowPlatform is the descriptor for the workflow platform infrastructure. - displayName: Sonata Flow Platform + displayName: SonataFlowPlatform kind: SonataFlowPlatform name: sonataflowplatforms.sonataflow.org resources: @@ -281,7 +281,7 @@ spec: version: v1alpha08 - description: SonataFlow is the descriptor representation for a workflow application based on the CNCF Serverless Workflow specification. - displayName: Sonata Flow + displayName: SonataFlow kind: SonataFlow name: sonataflows.sonataflow.org resources: diff --git a/config/manifests/bases/sonataflow-operator.clusterserviceversion.yaml b/config/manifests/bases/sonataflow-operator.clusterserviceversion.yaml index c6fdf4e6a..c8fc4c8aa 100644 --- a/config/manifests/bases/sonataflow-operator.clusterserviceversion.yaml +++ b/config/manifests/bases/sonataflow-operator.clusterserviceversion.yaml @@ -19,7 +19,7 @@ spec: owned: - description: SonataFlowBuild is an internal custom resource to control workflow build instances in the target platform - displayName: Sonata Flow Build + displayName: SonataFlowBuild kind: SonataFlowBuild name: sonataflowbuilds.sonataflow.org resources: @@ -66,7 +66,7 @@ spec: version: v1alpha08 - description: SonataFlowClusterPlatform is the Schema for the sonataflowclusterplatforms API - displayName: Sonata Flow Cluster Platform + displayName: SonataFlowClusterPlatform kind: SonataFlowClusterPlatform name: sonataflowclusterplatforms.sonataflow.org resources: @@ -95,7 +95,7 @@ spec: version: v1alpha08 - description: SonataFlowPlatform is the descriptor for the workflow platform infrastructure. - displayName: Sonata Flow Platform + displayName: SonataFlowPlatform kind: SonataFlowPlatform name: sonataflowplatforms.sonataflow.org resources: @@ -165,7 +165,7 @@ spec: version: v1alpha08 - description: SonataFlow is the descriptor representation for a workflow application based on the CNCF Serverless Workflow specification. - displayName: Sonata Flow + displayName: SonataFlow kind: SonataFlow name: sonataflows.sonataflow.org resources: From 298189f7138bcff9fe31d6173267cfec3beccb0d Mon Sep 17 00:00:00 2001 From: Roy Golan Date: Mon, 17 Jun 2024 20:54:42 +0300 Subject: [PATCH 3/5] Generate stable names for workflow resources (#473) --- workflowproj/workflowproj.go | 19 ++++++++++++++++--- workflowproj/workflowproj_test.go | 10 +++++----- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/workflowproj/workflowproj.go b/workflowproj/workflowproj.go index 44fe83a68..8a7a27728 100644 --- a/workflowproj/workflowproj.go +++ b/workflowproj/workflowproj.go @@ -23,6 +23,7 @@ import ( "context" "fmt" "io" + "sort" "strings" "github.com/pkg/errors" @@ -266,13 +267,25 @@ func (w *workflowProjectHandler) parseRawResources() error { } resourceCount := 1 - for path, resources := range w.rawResources { + paths := []string{} + for k := range w.rawResources { + paths = append(paths, k) + } + // Sort the paths to generate a deterministric list of files. + // Without sorting Golang map iteration on the strings is inconsistent because + // iteration order is not specified, so each time we could get 01-configmap-NAME-resources.yaml + // with schemas, and the next time with subflows, or other way round. + sort.Strings(paths) + for _, path := range paths { + // For better usability also convenience we add the 'path' from which the config map is taken + // so the config map file will have a meaningful name like + // 01-configmap-NAME-resources-specs.yaml or -subflow.yaml or -schemas.yaml cm := &corev1.ConfigMap{ - ObjectMeta: metav1.ObjectMeta{Namespace: w.namespace, Name: fmt.Sprintf("%02d-%s-resources", resourceCount, w.name)}, + ObjectMeta: metav1.ObjectMeta{Namespace: w.namespace, Name: fmt.Sprintf("%02d-%s-resources-%s", resourceCount, w.name, path)}, Data: map[string]string{}, } - for _, r := range resources { + for _, r := range w.rawResources[path] { contents, err := io.ReadAll(r.contents) if err != nil { return err diff --git a/workflowproj/workflowproj_test.go b/workflowproj/workflowproj_test.go index 6e9c876b4..2570802fa 100644 --- a/workflowproj/workflowproj_test.go +++ b/workflowproj/workflowproj_test.go @@ -85,7 +85,7 @@ func Test_Handler_WorkflowMinimalAndPropsAndSpec(t *testing.T) { assert.Equal(t, "hello-props", proj.Properties.Name) assert.NotEmpty(t, proj.Properties.Data) assert.Equal(t, 1, len(proj.Resources)) - assert.Equal(t, "01-hello-resources", proj.Resources[0].Name) + assert.Equal(t, "01-hello-resources-specs", proj.Resources[0].Name) assert.Equal(t, proj.Workflow.Spec.Resources.ConfigMaps[0].ConfigMap.Name, proj.Resources[0].Name) } @@ -114,8 +114,8 @@ func Test_Handler_WorkflowMinimalAndPropsAndSpecAndGeneric(t *testing.T) { assert.Equal(t, "hello-props", proj.Properties.Name) assert.NotEmpty(t, proj.Properties.Data) assert.Equal(t, 2, len(proj.Resources)) - assert.Equal(t, "01-hello-resources", proj.Resources[0].Name) - assert.Equal(t, "02-hello-resources", proj.Resources[1].Name) + assert.Equal(t, "01-hello-resources-files", proj.Resources[0].Name) + assert.Equal(t, "02-hello-resources-specs", proj.Resources[1].Name) assert.Equal(t, proj.Workflow.Spec.Resources.ConfigMaps[0].ConfigMap.Name, proj.Resources[0].Name) assert.Equal(t, proj.Workflow.Spec.Resources.ConfigMaps[1].ConfigMap.Name, proj.Resources[1].Name) data, err := getResourceDataWithFileName(proj.Resources, "myopenapi.json") @@ -158,8 +158,8 @@ func Test_Handler_WorklflowServiceAndPropsAndSpec_SaveAs(t *testing.T) { expectedFiles := []string{ "01-configmap_service-props.yaml", - "02-configmap_01-service-resources.yaml", - "03-configmap_02-service-resources.yaml", + "02-configmap_01-service-resources-files.yaml", + "03-configmap_02-service-resources-specs.yaml", "04-sonataflow_service.yaml", } expectedKinds := []schema.GroupVersionKind{ From a190a9dd681151ca0544f64ef1502e7dc68934cf Mon Sep 17 00:00:00 2001 From: Ricardo Zanini <1538000+ricardozanini@users.noreply.github.com> Date: Mon, 17 Jun 2024 15:02:36 -0300 Subject: [PATCH 4/5] Fix #484 - :link: Add platform reference to workflow status condition (#485) Signed-off-by: Ricardo Zanini --- api/v1alpha08/sonataflow_types.go | 3 +++ api/v1alpha08/sonataflowplatform_types.go | 2 +- api/v1alpha08/zz_generated.deepcopy.go | 5 +++++ .../sonataflow-operator.clusterserviceversion.yaml | 3 +++ bundle/manifests/sonataflow.org_sonataflows.yaml | 14 ++++++++++++++ config/crd/bases/sonataflow.org_sonataflows.yaml | 14 ++++++++++++++ .../sonataflow-operator.clusterserviceversion.yaml | 3 +++ controllers/profiles/common/reconciler.go | 6 ++++++ controllers/sonataflow_controller_test.go | 3 +++ operator.yaml | 14 ++++++++++++++ 10 files changed, 66 insertions(+), 1 deletion(-) diff --git a/api/v1alpha08/sonataflow_types.go b/api/v1alpha08/sonataflow_types.go index e751e0036..66f8e3605 100644 --- a/api/v1alpha08/sonataflow_types.go +++ b/api/v1alpha08/sonataflow_types.go @@ -182,6 +182,9 @@ type SonataFlowStatus struct { // Services displays which platform services are being used by this workflow //+operator-sdk:csv:customresourcedefinitions:type=status,displayName="services" Services *PlatformServicesStatus `json:"services,omitempty"` + // Platform displays which platform is being used by this workflow + //+operator-sdk:csv:customresourcedefinitions:type=status,displayName="platform" + Platform *SonataFlowPlatformRef `json:"platform,omitempty"` } func (s *SonataFlowStatus) GetTopLevelConditionType() api.ConditionType { diff --git a/api/v1alpha08/sonataflowplatform_types.go b/api/v1alpha08/sonataflowplatform_types.go index a564cde08..b9f42c824 100644 --- a/api/v1alpha08/sonataflowplatform_types.go +++ b/api/v1alpha08/sonataflowplatform_types.go @@ -108,7 +108,7 @@ type SonataFlowClusterPlatformRefStatus struct { Services *PlatformServicesStatus `json:"services,omitempty"` } -// PlatformServicesStatus displays which cluster-wide services are being used by a SonataFlowPlatform +// PlatformServicesStatus displays which cluster-wide services are being used by a SonataFlowPlatform or SonataFlow // +k8s:openapi-gen=true type PlatformServicesStatus struct { // DataIndexRef displays information on the cluster-wide Data Index service diff --git a/api/v1alpha08/zz_generated.deepcopy.go b/api/v1alpha08/zz_generated.deepcopy.go index 645d2b60a..b11518893 100644 --- a/api/v1alpha08/zz_generated.deepcopy.go +++ b/api/v1alpha08/zz_generated.deepcopy.go @@ -1302,6 +1302,11 @@ func (in *SonataFlowStatus) DeepCopyInto(out *SonataFlowStatus) { *out = new(PlatformServicesStatus) (*in).DeepCopyInto(*out) } + if in.Platform != nil { + in, out := &in.Platform, &out.Platform + *out = new(SonataFlowPlatformRef) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SonataFlowStatus. diff --git a/bundle/manifests/sonataflow-operator.clusterserviceversion.yaml b/bundle/manifests/sonataflow-operator.clusterserviceversion.yaml index 73037612d..c9a617e2f 100644 --- a/bundle/manifests/sonataflow-operator.clusterserviceversion.yaml +++ b/bundle/manifests/sonataflow-operator.clusterserviceversion.yaml @@ -328,6 +328,9 @@ spec: path: endpoint - displayName: lastTimeRecoverAttempt path: lastTimeRecoverAttempt + - description: Platform displays which platform is being used by this workflow + displayName: platform + path: platform - description: keeps track of how many failure recovers a given workflow had so far displayName: recoverFailureAttempts diff --git a/bundle/manifests/sonataflow.org_sonataflows.yaml b/bundle/manifests/sonataflow.org_sonataflows.yaml index 6f2cb2e75..5ff75cae2 100644 --- a/bundle/manifests/sonataflow.org_sonataflows.yaml +++ b/bundle/manifests/sonataflow.org_sonataflows.yaml @@ -9461,6 +9461,20 @@ spec: description: The generation observed by the deployment controller. format: int64 type: integer + platform: + description: Platform displays which platform is being used by this + workflow + properties: + name: + description: Name of the SonataFlowPlatform + type: string + namespace: + description: Namespace of the SonataFlowPlatform + type: string + required: + - name + - namespace + type: object recoverFailureAttempts: description: keeps track of how many failure recovers a given workflow had so far diff --git a/config/crd/bases/sonataflow.org_sonataflows.yaml b/config/crd/bases/sonataflow.org_sonataflows.yaml index 61002c32f..7ee4675cf 100644 --- a/config/crd/bases/sonataflow.org_sonataflows.yaml +++ b/config/crd/bases/sonataflow.org_sonataflows.yaml @@ -9462,6 +9462,20 @@ spec: description: The generation observed by the deployment controller. format: int64 type: integer + platform: + description: Platform displays which platform is being used by this + workflow + properties: + name: + description: Name of the SonataFlowPlatform + type: string + namespace: + description: Namespace of the SonataFlowPlatform + type: string + required: + - name + - namespace + type: object recoverFailureAttempts: description: keeps track of how many failure recovers a given workflow had so far diff --git a/config/manifests/bases/sonataflow-operator.clusterserviceversion.yaml b/config/manifests/bases/sonataflow-operator.clusterserviceversion.yaml index c8fc4c8aa..8bdae5242 100644 --- a/config/manifests/bases/sonataflow-operator.clusterserviceversion.yaml +++ b/config/manifests/bases/sonataflow-operator.clusterserviceversion.yaml @@ -212,6 +212,9 @@ spec: path: endpoint - displayName: lastTimeRecoverAttempt path: lastTimeRecoverAttempt + - description: Platform displays which platform is being used by this workflow + displayName: platform + path: platform - description: keeps track of how many failure recovers a given workflow had so far displayName: recoverFailureAttempts diff --git a/controllers/profiles/common/reconciler.go b/controllers/profiles/common/reconciler.go index 8af936995..5fb7913ac 100644 --- a/controllers/profiles/common/reconciler.go +++ b/controllers/profiles/common/reconciler.go @@ -57,6 +57,12 @@ func (s *StateSupport) PerformStatusUpdate(ctx context.Context, workflow *operat } workflow.Status.ObservedGeneration = workflow.Generation services.SetServiceUrlsInWorkflowStatus(pl, workflow) + if workflow.Status.Platform == nil { + workflow.Status.Platform = &operatorapi.SonataFlowPlatformRef{} + } + workflow.Status.Platform.Name = pl.Name + workflow.Status.Platform.Namespace = pl.Namespace + if err = s.C.Status().Update(ctx, workflow); err != nil { klog.V(log.E).ErrorS(err, "Failed to update Workflow status") return false, err diff --git a/controllers/sonataflow_controller_test.go b/controllers/sonataflow_controller_test.go index d16e485a7..b2993d0ee 100644 --- a/controllers/sonataflow_controller_test.go +++ b/controllers/sonataflow_controller_test.go @@ -80,5 +80,8 @@ func TestSonataFlowController(t *testing.T) { assert.True(t, ksw.Spec.Flow.Start.StateName == "ChooseOnLanguage") assert.True(t, len(ksw.Spec.Flow.States) == 4) + + assert.Equal(t, ksp.Name, afterReconcileWorkflow.Status.Platform.Name) + assert.Equal(t, ksp.Namespace, afterReconcileWorkflow.Status.Platform.Namespace) }) } diff --git a/operator.yaml b/operator.yaml index debd5bff4..f7d09313e 100644 --- a/operator.yaml +++ b/operator.yaml @@ -26358,6 +26358,20 @@ spec: description: The generation observed by the deployment controller. format: int64 type: integer + platform: + description: Platform displays which platform is being used by this + workflow + properties: + name: + description: Name of the SonataFlowPlatform + type: string + namespace: + description: Namespace of the SonataFlowPlatform + type: string + required: + - name + - namespace + type: object recoverFailureAttempts: description: keeps track of how many failure recovers a given workflow had so far From 1fb05578e62de2f9f6734b459178ffc00f43843d Mon Sep 17 00:00:00 2001 From: Ricardo Zanini <1538000+ricardozanini@users.noreply.github.com> Date: Thu, 20 Jun 2024 11:17:44 -0300 Subject: [PATCH 5/5] Fix kie-issues #1236 - Replace quay.io with docker.io, review version.go (#466) * Fix kie-issues #1236 - Replace quay.io with docker.io, review version.go Signed-off-by: Ricardo Zanini * Fix env.sh and bump-version.sh scripts Signed-off-by: Ricardo Zanini * Fix small typos Signed-off-by: Ricardo Zanini --------- Signed-off-by: Ricardo Zanini --- Makefile | 2 +- .../pkg/api/app/v1beta1/kogitoservices.go | 2 +- bddframework/pkg/framework/util.go | 2 +- ...-operator-builder-config_v1_configmap.yaml | 8 ++--- ...taflow-operator.clusterserviceversion.yaml | 4 +-- .../manager/SonataFlow-Builder.containerfile | 4 +-- config/manager/kustomization.yaml | 2 +- ...taflow-operator.clusterserviceversion.yaml | 2 +- .../builder/kubernetes/builder_kaniko_test.go | 4 +-- .../builder/kubernetes/builder_test.go | 2 +- .../builder/kubernetes/testdata/Dockerfile | 2 +- .../PlatformBuild_usingKanikowithCache.yaml | 2 +- .../dockerfiles/SonataFlow.dockerfile | 2 +- controllers/builder/openshiftbuilder_test.go | 11 ++++-- controllers/platform/platformutils.go | 6 ++++ controllers/platform/platformutils_test.go | 4 +-- controllers/platform/services/services.go | 22 +++--------- .../common/constants/platform_services.go | 8 ++--- controllers/workflowdef/image.go | 18 +++------- docs/CONTRIBUTING.md | 2 +- hack/bump-version.sh | 33 +++++++----------- hack/env.sh | 8 ++--- hack/local/build-simple-workflow.sh | 2 +- main.go | 3 +- operator.yaml | 10 +++--- .../kogito_serverless_operator_pipeline.yaml | 2 +- test/builder/Dockerfile | 2 +- ...ow.org_v1alpha08_sonataflow-simpleops.yaml | 2 +- ...sonataflowplatform_withCache_minikube.yaml | 2 +- testbdd/README.md | 8 ++--- testbdd/installers/sonataflow_installer.go | 2 +- version/version.go | 34 +++++++++---------- 32 files changed, 96 insertions(+), 121 deletions(-) diff --git a/Makefile b/Makefile index d8349ffdb..81eb50597 100644 --- a/Makefile +++ b/Makefile @@ -30,7 +30,7 @@ BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL) # # For example, running 'make bundle-build bundle-push catalog-build catalog-push' will build and push both # kiegroup.org/kogito-serverless-operator-bundle:$VERSION and kiegroup.org/kogito-serverless-operator-catalog:$VERSION. -IMAGE_TAG_BASE ?= quay.io/kiegroup/kogito-serverless-operator-nightly +IMAGE_TAG_BASE ?= docker.io/apache/incubator-kie-sonataflow-operator # BUNDLE_IMG defines the image:tag used for the bundle. # You can use it as an arg. (E.g make bundle-build BUNDLE_IMG=/:) diff --git a/bddframework/pkg/api/app/v1beta1/kogitoservices.go b/bddframework/pkg/api/app/v1beta1/kogitoservices.go index 1d6468846..2bdfa1429 100644 --- a/bddframework/pkg/api/app/v1beta1/kogitoservices.go +++ b/bddframework/pkg/api/app/v1beta1/kogitoservices.go @@ -201,7 +201,7 @@ type KogitoServiceSpec struct { Env []corev1.EnvVar `json:"env,omitempty"` // +optional - // Image definition for the service. Example: "quay.io/kiegroup/kogito-service:latest". + // Image definition for the service. Example: "docker.io/apache/incubator-kie-kogito-service:latest". // // On OpenShift an ImageStream will be created in the current namespace pointing to the given image. // +operator-sdk:csv:customresourcedefinitions:type=spec diff --git a/bddframework/pkg/framework/util.go b/bddframework/pkg/framework/util.go index 2e93a1f70..3c4e52962 100644 --- a/bddframework/pkg/framework/util.go +++ b/bddframework/pkg/framework/util.go @@ -292,7 +292,7 @@ func AppendImageDefaultValues(image *api.Image) { } if len(image.Tag) == 0 { - image.Tag = GetKogitoImageVersion(version.OperatorVersion) + image.Tag = GetKogitoImageVersion(version.GetTagVersion()) } } diff --git a/bundle/manifests/sonataflow-operator-builder-config_v1_configmap.yaml b/bundle/manifests/sonataflow-operator-builder-config_v1_configmap.yaml index d04b6b621..425a8127c 100644 --- a/bundle/manifests/sonataflow-operator-builder-config_v1_configmap.yaml +++ b/bundle/manifests/sonataflow-operator-builder-config_v1_configmap.yaml @@ -1,16 +1,16 @@ apiVersion: v1 data: DEFAULT_WORKFLOW_EXTENSION: .sw.json - Dockerfile: "FROM quay.io/kiegroup/kogito-swf-builder-nightly:latest AS builder\n\n# + Dockerfile: "FROM docker.io/apache/incubator-kie-sonataflow-builder:main AS builder\n\n# variables that can be overridden by the builder\n# To add a Quarkus extension to your application\nARG QUARKUS_EXTENSIONS\n# Args to pass to the Quarkus CLI add extension command\nARG QUARKUS_ADD_EXTENSION_ARGS\n# Additional java/mvn arguments to pass to the builder\nARG MAVEN_ARGS_APPEND\n\n# Copy from build context to skeleton resources project\nCOPY --chown=1001 . ./resources\n\nRUN /home/kogito/launch/build-app.sh ./resources\n \n#=============================\n# Runtime Run\n#=============================\nFROM - registry.access.redhat.com/ubi9/openjdk-17:latest\n\nENV LANG='en_US.UTF-8' LANGUAGE='en_US:en'\n - \ \n# We make four distinct layers so if there are application changes the library - layers can be re-used\nCOPY --from=builder --chown=185 /home/kogito/serverless-workflow-project/target/quarkus-app/lib/ + registry.access.redhat.com/ubi9/openjdk-17-runtime:latest\n\nENV LANG='en_US.UTF-8' + LANGUAGE='en_US:en'\n \n# We make four distinct layers so if there are application + changes the library layers can be re-used\nCOPY --from=builder --chown=185 /home/kogito/serverless-workflow-project/target/quarkus-app/lib/ /deployments/lib/\nCOPY --from=builder --chown=185 /home/kogito/serverless-workflow-project/target/quarkus-app/*.jar /deployments/\nCOPY --from=builder --chown=185 /home/kogito/serverless-workflow-project/target/quarkus-app/app/ /deployments/app/\nCOPY --from=builder --chown=185 /home/kogito/serverless-workflow-project/target/quarkus-app/quarkus/ diff --git a/bundle/manifests/sonataflow-operator.clusterserviceversion.yaml b/bundle/manifests/sonataflow-operator.clusterserviceversion.yaml index c9a617e2f..37ca5da12 100644 --- a/bundle/manifests/sonataflow-operator.clusterserviceversion.yaml +++ b/bundle/manifests/sonataflow-operator.clusterserviceversion.yaml @@ -119,7 +119,7 @@ metadata: ] capabilities: Basic Install categories: Application Runtime - containerImage: quay.io/kiegroup/kogito-serverless-operator-nightly:latest + containerImage: docker.io/apache/incubator-kie-sonataflow-operator:main description: SonataFlow Kubernetes Operator for deploying workflow applications based on the CNCF Serverless Workflow specification operators.operatorframework.io/builder: operator-sdk-v1.25.0 @@ -761,7 +761,7 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace - image: quay.io/kiegroup/kogito-serverless-operator-nightly:latest + image: docker.io/apache/incubator-kie-sonataflow-operator:latest livenessProbe: httpGet: path: /healthz diff --git a/config/manager/SonataFlow-Builder.containerfile b/config/manager/SonataFlow-Builder.containerfile index d95cbf0fd..892d1bdca 100644 --- a/config/manager/SonataFlow-Builder.containerfile +++ b/config/manager/SonataFlow-Builder.containerfile @@ -1,4 +1,4 @@ -FROM quay.io/kiegroup/kogito-swf-builder-nightly:latest AS builder +FROM docker.io/apache/incubator-kie-sonataflow-builder:main AS builder # variables that can be overridden by the builder # To add a Quarkus extension to your application @@ -16,7 +16,7 @@ RUN /home/kogito/launch/build-app.sh ./resources #============================= # Runtime Run #============================= -FROM registry.access.redhat.com/ubi9/openjdk-17:latest +FROM registry.access.redhat.com/ubi9/openjdk-17-runtime:latest ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' diff --git a/config/manager/kustomization.yaml b/config/manager/kustomization.yaml index 3cc8cc8ea..fb3d741dd 100644 --- a/config/manager/kustomization.yaml +++ b/config/manager/kustomization.yaml @@ -21,7 +21,7 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization images: - name: controller - newName: quay.io/kiegroup/kogito-serverless-operator-nightly + newName: docker.io/apache/incubator-kie-sonataflow-operator newTag: latest # Patching the manager deployment file to add an env var with the operator namespace in patchesJson6902: diff --git a/config/manifests/bases/sonataflow-operator.clusterserviceversion.yaml b/config/manifests/bases/sonataflow-operator.clusterserviceversion.yaml index 8bdae5242..094fbfa89 100644 --- a/config/manifests/bases/sonataflow-operator.clusterserviceversion.yaml +++ b/config/manifests/bases/sonataflow-operator.clusterserviceversion.yaml @@ -5,7 +5,7 @@ metadata: alm-examples: '[]' capabilities: Basic Install categories: Application Runtime - containerImage: quay.io/kiegroup/kogito-serverless-operator-nightly:latest + containerImage: docker.io/apache/incubator-kie-sonataflow-operator:main description: SonataFlow Kubernetes Operator for deploying workflow applications based on the CNCF Serverless Workflow specification operators.operatorframework.io/internal-objects: '["sonataflowbuilds.sonataflow.org"]' diff --git a/container-builder/builder/kubernetes/builder_kaniko_test.go b/container-builder/builder/kubernetes/builder_kaniko_test.go index 8603c3712..939170068 100644 --- a/container-builder/builder/kubernetes/builder_kaniko_test.go +++ b/container-builder/builder/kubernetes/builder_kaniko_test.go @@ -68,7 +68,7 @@ func TestNewBuildWithKanikoCustomizations(t *testing.T) { addFlags[0] = "--use-new-run=true" // create the new build, schedule with cache enabled, a specific set of resources and additional flags - build, err := NewBuild(ContainerBuilderInfo{FinalImageName: "quay.io/kiegroup/buildexample:latest", BuildUniqueName: "build1", Platform: platform}). + build, err := NewBuild(ContainerBuilderInfo{FinalImageName: "docker.io/apache/incubator-kie-buildexample:latest", BuildUniqueName: "build1", Platform: platform}). AddResource("Dockerfile", dockerFile). AddResource("greetings.sw.json", workflowDefinition). WithClient(c). @@ -134,7 +134,7 @@ func TestNewBuildWithKanikoWithBuildArgsAndEnv(t *testing.T) { }, } - build, err := NewBuild(ContainerBuilderInfo{FinalImageName: "quay.io/kiegroup/buildexample:latest", BuildUniqueName: "build1", Platform: platform}). + build, err := NewBuild(ContainerBuilderInfo{FinalImageName: "docker.io/apache/incubator-kie-buildexample:latest", BuildUniqueName: "build1", Platform: platform}). AddResource("Dockerfile", dockerFile). AddResource("greetings.sw.json", workflowDefinition). WithClient(c). diff --git a/container-builder/builder/kubernetes/builder_test.go b/container-builder/builder/kubernetes/builder_test.go index a54201f58..70fe52710 100644 --- a/container-builder/builder/kubernetes/builder_test.go +++ b/container-builder/builder/kubernetes/builder_test.go @@ -57,7 +57,7 @@ func TestNewBuild(t *testing.T) { }, } // create the new build, schedule - build, err := NewBuild(ContainerBuilderInfo{FinalImageName: "quay.io/kiegroup/buildexample:latest", BuildUniqueName: "build1", Platform: platform}). + build, err := NewBuild(ContainerBuilderInfo{FinalImageName: "docker.io/apache/incubator-kie-buildexample:latest", BuildUniqueName: "build1", Platform: platform}). WithClient(c). AddResource("Dockerfile", dockerFile). AddResource("greetings.sw.json", workflowDefinition). diff --git a/container-builder/builder/kubernetes/testdata/Dockerfile b/container-builder/builder/kubernetes/testdata/Dockerfile index 80d51e15b..89f941bf7 100644 --- a/container-builder/builder/kubernetes/testdata/Dockerfile +++ b/container-builder/builder/kubernetes/testdata/Dockerfile @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -FROM quay.io/kiegroup/kogito-swf-builder-nightly:latest AS builder +FROM docker.io/apache/incubator-kie-sonataflow-builder:main AS builder # Kogito User USER 1001 diff --git a/container-builder/examples/api/PlatformBuild_usingKanikowithCache.yaml b/container-builder/examples/api/PlatformBuild_usingKanikowithCache.yaml index 788da52bb..5efeea8a7 100644 --- a/container-builder/examples/api/PlatformBuild_usingKanikowithCache.yaml +++ b/container-builder/examples/api/PlatformBuild_usingKanikowithCache.yaml @@ -1,7 +1,7 @@ name: platform-kaniko-using-cache spec: publishStrategy: "Kaniko" - baseImage: quay.io/kiegroup/kogito-swf-builder-nightly:latest + baseImage: docker.io/apache/incubator-kie-sonataflow-builder:main registry: address: quay.io/kiegroup secret: regcred diff --git a/container-builder/examples/dockerfiles/SonataFlow.dockerfile b/container-builder/examples/dockerfiles/SonataFlow.dockerfile index 6ca872b26..82d94abee 100644 --- a/container-builder/examples/dockerfiles/SonataFlow.dockerfile +++ b/container-builder/examples/dockerfiles/SonataFlow.dockerfile @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -FROM quay.io/kiegroup/kogito-swf-builder-nightly:latest AS builder +FROM docker.io/apache/incubator-kie-sonataflow-builder:main AS builder # Kogito User USER 1001 diff --git a/controllers/builder/openshiftbuilder_test.go b/controllers/builder/openshiftbuilder_test.go index 48b6ef3ec..9a7401667 100644 --- a/controllers/builder/openshiftbuilder_test.go +++ b/controllers/builder/openshiftbuilder_test.go @@ -23,6 +23,7 @@ import ( "context" "testing" + "github.com/apache/incubator-kie-kogito-serverless-operator/controllers/platform" buildv1 "github.com/openshift/api/build/v1" imgv1 "github.com/openshift/api/image/v1" buildfake "github.com/openshift/client-go/build/clientset/versioned/fake" @@ -142,15 +143,19 @@ func Test_openshiftbuilder_forcePull(t *testing.T) { // Setup ns := t.Name() workflow := test.GetBaseSonataFlow(ns) - platform := test.GetBasePlatformInReadyPhase(t.Name()) + pl := test.GetBasePlatformInReadyPhase(t.Name()) config := test.GetSonataFlowBuilderConfig(ns) + + dockerFile := config.Data[defaultBuilderResourceName] + config.Data[defaultBuilderResourceName] = platform.ReplaceFromImageTagDockerfile(dockerFile, "FROM image:latest AS builder") + namespacedName := types.NamespacedName{Namespace: workflow.Namespace, Name: workflow.Name} - client := test.NewKogitoClientBuilderWithOpenShift().WithRuntimeObjects(workflow, platform, config).Build() + client := test.NewKogitoClientBuilderWithOpenShift().WithRuntimeObjects(workflow, pl, config).Build() buildClient := buildfake.NewSimpleClientset().BuildV1() managerContext := buildManagerContext{ ctx: context.TODO(), client: client, - platform: platform, + platform: pl, builderConfigMap: config, } diff --git a/controllers/platform/platformutils.go b/controllers/platform/platformutils.go index f3978b742..0b4105497 100644 --- a/controllers/platform/platformutils.go +++ b/controllers/platform/platformutils.go @@ -170,3 +170,9 @@ func GetFromImageTagDockerfile(dockerfile string) string { res := builderDockerfileFromRE.FindAllStringSubmatch(dockerfile, 1) return strings.Trim(res[0][1], " ") } + +// ReplaceFromImageTagDockerfile replaces the "FROM" clause from the given dockerfile with the given fromReplacement. +// For example: "FROM myimage:latest AS builder" +func ReplaceFromImageTagDockerfile(dockerfile string, fromReplacement string) string { + return string(builderDockerfileFromRE.ReplaceAll([]byte(dockerfile), []byte(fromReplacement))) +} diff --git a/controllers/platform/platformutils_test.go b/controllers/platform/platformutils_test.go index 0132bb2ff..c0dc45cb5 100644 --- a/controllers/platform/platformutils_test.go +++ b/controllers/platform/platformutils_test.go @@ -36,9 +36,9 @@ func TestSonataFlowBuildController(t *testing.T) { assert.Fail(t, "Unable to read base Dockerfile") } dockerfile := string(dockerfileBytes) - // 1 - Let's verify that the default image is used (for this unit test is quay.io/kiegroup/kogito-swf-builder-nightly:latest) + // 1 - Let's verify that the default image is used (for this unit test is docker.io/apache/incubator-kie-sonataflow-builder:main) resDefault := GetCustomizedBuilderDockerfile(dockerfile, *platform) - foundDefault, err := regexp.MatchString("FROM quay.io/kiegroup/kogito-swf-builder-nightly:latest AS builder", resDefault) + foundDefault, err := regexp.MatchString("FROM docker.io/apache/incubator-kie-sonataflow-builder:main AS builder", resDefault) assert.NoError(t, err) assert.True(t, foundDefault) diff --git a/controllers/platform/services/services.go b/controllers/platform/services/services.go index aead391eb..50baa8493 100644 --- a/controllers/platform/services/services.go +++ b/controllers/platform/services/services.go @@ -110,15 +110,8 @@ func (d DataIndexHandler) GetServiceImageName(persistenceType constants.Persiste if persistenceType == constants.PersistenceTypeEphemeral && len(cfg.GetCfg().DataIndexEphemeralImageTag) > 0 { return cfg.GetCfg().DataIndexEphemeralImageTag } - var tag = version.GetMajorMinor() - var suffix = "" - if version.IsSnapshot() { - tag = "latest" - //TODO, remove - suffix = constants.ImageNameNightlySuffix - } - // returns "quay.io/kiegroup/kogito-data-index-:" - return fmt.Sprintf("%s-%s-%s:%s", constants.ImageNamePrefix, constants.DataIndexName, persistenceType.String()+suffix, tag) + // returns "docker.io/apache/incubator-kie-kogito-data-index-:" + return fmt.Sprintf("%s-%s-%s:%s", constants.ImageNamePrefix, constants.DataIndexName, persistenceType.String(), version.GetTagVersion()) } func (d DataIndexHandler) GetServiceName() string { @@ -279,15 +272,8 @@ func (j JobServiceHandler) GetServiceImageName(persistenceType constants.Persist if persistenceType == constants.PersistenceTypeEphemeral && len(cfg.GetCfg().JobsServiceEphemeralImageTag) > 0 { return cfg.GetCfg().JobsServiceEphemeralImageTag } - var tag = version.GetMajorMinor() - var suffix = "" - if version.IsSnapshot() { - tag = "latest" - //TODO remove - suffix = constants.ImageNameNightlySuffix - } - // returns "quay.io/kiegroup/kogito-jobs-service-:" - return fmt.Sprintf("%s-%s-%s:%s", constants.ImageNamePrefix, constants.JobServiceName, persistenceType.String()+suffix, tag) + // returns "docker.io/apache/incubator-kie-kogito-jobs-service-:" + return fmt.Sprintf("%s-%s-%s:%s", constants.ImageNamePrefix, constants.JobServiceName, persistenceType.String(), version.GetTagVersion()) } func (j JobServiceHandler) GetServiceName() string { diff --git a/controllers/profiles/common/constants/platform_services.go b/controllers/profiles/common/constants/platform_services.go index 30b25fb2f..4065d9e92 100644 --- a/controllers/profiles/common/constants/platform_services.go +++ b/controllers/profiles/common/constants/platform_services.go @@ -57,12 +57,8 @@ const ( DataIndexServiceName = "data-index-service" JobServiceName = "jobs-service" - ImageNamePrefix = "quay.io/kiegroup/kogito" - //TODO, the usage of this constant was temporary introduced since only the nightly images are being updated for the - //data-index and jobs-service. And this is causing issues at the time of using the workflows integrated with these, etc. - //This will be removed when the CI is fixed. - ImageNameNightlySuffix = "-nightly" - DataIndexName = "data-index" + ImageNamePrefix = "docker.io/apache/incubator-kie-kogito" + DataIndexName = "data-index" DefaultDatabaseName string = "sonataflow" DefaultPostgreSQLPort int = 5432 diff --git a/controllers/workflowdef/image.go b/controllers/workflowdef/image.go index 220aa209b..0174a926a 100644 --- a/controllers/workflowdef/image.go +++ b/controllers/workflowdef/image.go @@ -20,6 +20,8 @@ package workflowdef import ( + "fmt" + "github.com/apache/incubator-kie-kogito-serverless-operator/api/v1alpha08" "github.com/apache/incubator-kie-kogito-serverless-operator/controllers/cfg" "github.com/apache/incubator-kie-kogito-serverless-operator/version" @@ -27,9 +29,8 @@ import ( const ( latestImageTag = "latest" - nightlySuffix = "nightly" - defaultWorkflowDevModeImage = "quay.io/kiegroup/kogito-swf-devmode" - defaultWorkflowBuilderImage = "quay.io/kiegroup/kogito-swf-builder" + defaultWorkflowDevModeImage = "docker.io/apache/incubator-kie-sonataflow-devmode" + defaultWorkflowBuilderImage = "docker.io/apache/incubator-kie-sonataflow-builder" ) // GetWorkflowAppImageNameTag returns the image name with tag to use for the image to be produced for a given workflow. @@ -63,14 +64,5 @@ func GetDefaultWorkflowBuilderImageTag() string { } func GetDefaultImageTag(imgTag string) string { - if version.IsSnapshot() { - imgTag += "-" + nightlySuffix - } - imgTag += ":" - if version.IsLatestVersion() { - imgTag += latestImageTag - } else { - imgTag += version.GetMajorMinor() - } - return imgTag + return fmt.Sprintf("%s:%s", imgTag, version.GetTagVersion()) } diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index 2112d86e4..14dd27e2a 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -175,7 +175,7 @@ when the Operator will be installed, and it contains: At the startup a [Dockerfile](../config/manager/SonataFlow-Builder.containerfile) is placed in a configmap. This Dockerfile uses a base image -called [kogito-swf-builder](https://github.com/kiegroup/kogito-images/tree/master/modules/kogito-swf-builder) with: +called [sonataflow-builder](https://github.com/kiegroup/kogito-images/tree/master/modules/sonataflow-builder) with: - openjdk 11+ - maven 3.8.6+ diff --git a/hack/bump-version.sh b/hack/bump-version.sh index d74fd88ae..d2791f0b2 100755 --- a/hack/bump-version.sh +++ b/hack/bump-version.sh @@ -20,10 +20,9 @@ set -e script_dir_path=$(dirname "${BASH_SOURCE[0]}") source "${script_dir_path}"/env.sh -imageTag='quay.io/kiegroup/kogito-serverless-operator' +imageTag='docker.io/apache/incubator-kie-sonataflow-operator' # shellcheck disable=SC2034 -old_version=$(getOperatorVersion) -latest_version=$(getOperatorLatestVersion) +old_version=$(getImageTagVersion) new_version=$1 if [ -z "${new_version}" ]; then @@ -31,18 +30,10 @@ if [ -z "${new_version}" ]; then exit 1 fi -imageSuffix=$(if [[ "${new_version}" == *snapshot ]]; then echo '-nightly'; else echo ''; fi) - oldMajorMinorVersion=${old_version%.*} newMajorMinorVersion=${new_version%.*} -if [ "${old_version}" = "${latest_version}" ]; then - oldMajorMinorVersion='latest' -fi -if [ "${new_version}" = "${latest_version}" ]; then - newMajorMinorVersion='latest' -fi -echo "Set new version to ${new_version} (img_suffix = '${imageSuffix}', majorMinor = ${newMajorMinorVersion})" +echo "Set new version to ${new_version} (majorMinor = ${newMajorMinorVersion})" sed -i "s|version: ${old_version}|version: ${new_version}|g" image.yaml @@ -50,19 +41,19 @@ sed -i "s|^VERSION ?=.*|VERSION ?= ${new_version}|g" Makefile sed -i "s|^REDUCED_VERSION ?=.*|REDUCED_VERSION ?= ${newMajorMinorVersion}|g" Makefile sed -i "s|newTag:.*|newTag: ${new_version}|g" config/manager/kustomization.yaml -sed -i "s|IMAGE_TAG_BASE ?=.*|IMAGE_TAG_BASE ?= ${imageTag}${imageSuffix}|g" Makefile -sed -i "s|newName:.*|newName: ${imageTag}${imageSuffix}|g" config/manager/kustomization.yaml +sed -i "s|IMAGE_TAG_BASE ?=.*|IMAGE_TAG_BASE ?= ${imageTag}|g" Makefile +sed -i "s|newName:.*|newName: ${imageTag}|g" config/manager/kustomization.yaml -# Update kogito-swf-* images -find . -name "*.yaml" -exec sed -i "s|quay.io/kiegroup/kogito-swf-builder.*:${oldMajorMinorVersion}|quay.io/kiegroup/kogito-swf-builder${imageSuffix}:${newMajorMinorVersion}|" {} + -sed -i "s|quay.io/kiegroup/kogito-swf-builder.*:${oldMajorMinorVersion}|quay.io/kiegroup/kogito-swf-builder${imageSuffix}:${newMajorMinorVersion}|" Dockerfile +# Update sonataflow-* images +find . -name "*.yaml" -exec sed -i "s|docker.io/apache/incubator-kie-sonataflow-builder.*:${oldMajorMinorVersion}|docker.io/apache/incubator-kie-sonataflow-builder:${newMajorMinorVersion}|" {} + +sed -i "s|docker.io/apache/incubator-kie-sonataflow-builder.*:${oldMajorMinorVersion}|docker.io/apache/incubator-kie-sonataflow-builder:${newMajorMinorVersion}|" Dockerfile -find . -name "*.yaml" -exec sed -i "s|quay.io/kiegroup/kogito-swf-devmode.*:${oldMajorMinorVersion}|quay.io/kiegroup/kogito-swf-devmode${imageSuffix}:${newMajorMinorVersion}|" {} + -sed -i "s|quay.io/kiegroup/kogito-swf-devmode.*:${oldMajorMinorVersion}|quay.io/kiegroup/kogito-swf-devmode${imageSuffix}:${newMajorMinorVersion}|" Dockerfile +find . -name "*.yaml" -exec sed -i "s|docker.io/apache/incubator-kie-sonataflow-devmode.*:${oldMajorMinorVersion}|docker.io/apache/incubator-kie-sonataflow-devmode:${newMajorMinorVersion}|" {} + +sed -i "s|docker.io/apache/incubator-kie-sonataflow-devmode.*:${oldMajorMinorVersion}|docker.io/apache/incubator-kie-sonataflow-devmode:${newMajorMinorVersion}|" Dockerfile -sed -i -r "s|OperatorVersion =.*|OperatorVersion = \"${new_version}\"|g" version/version.go +sed -i -r "s|operatorVersion =.*|operatorVersion = \"${new_version}\"|g" version/version.go -sed -i "s|containerImage:.*|containerImage: ${imageTag}${imageSuffix}:${newMajorMinorVersion}|g" $(getCsvFile) +sed -i "s|containerImage:.*|containerImage: ${imageTag}:${newMajorMinorVersion}|g" $(getCsvFile) make generate-all make vet diff --git a/hack/env.sh b/hack/env.sh index 945175db2..c463d26ab 100755 --- a/hack/env.sh +++ b/hack/env.sh @@ -20,13 +20,13 @@ CSV_DIR="config/manifests/bases" BUNDLE_DIR="bundle/manifests" getOperatorVersion() { - local version=$(grep -m 1 'OperatorVersion' version/version.go | awk -F\" '{print $2}') + local version=$(grep -m 1 'operatorVersion = ' version/version.go | awk -F\" '{print $2}') echo "${version}" } -getOperatorLatestVersion() { - local version=$(grep -m 1 'latestVersion' version/version.go | awk -F\" '{print $2}') - echo "${version}" +getImageTagVersion() { + local tag_version=$(grep -m 1 'tagVersion = ' version/version.go | awk -F\" '{print $2}') + echo "${tag_version}" } getOperatorImageName() { diff --git a/hack/local/build-simple-workflow.sh b/hack/local/build-simple-workflow.sh index c0886e453..e008e39b7 100755 --- a/hack/local/build-simple-workflow.sh +++ b/hack/local/build-simple-workflow.sh @@ -17,4 +17,4 @@ mkdir -p /tmp/simpleworkflow cp ./config/manager/sonataflow_builder_dockerfile.yaml /tmp/simpleworkflow/Dockerfile cp ./workflowproj/testdata/workflows/workflow-minimal.sw.json /tmp/simpleworkflow/workflow-minimal.sw.json -docker build -t quay.io/kiegroup/sonataflow-minimal-example:latest /tmp/simpleworkflow/ +docker build -t docker.io/apache/incubator-kie-sonataflow-minimal-example:latest /tmp/simpleworkflow/ diff --git a/main.go b/main.go index e0265ed60..dc290e0ab 100644 --- a/main.go +++ b/main.go @@ -24,6 +24,7 @@ import ( "os" "github.com/apache/incubator-kie-kogito-serverless-operator/controllers/cfg" + "github.com/apache/incubator-kie-kogito-serverless-operator/version" eventingv1 "knative.dev/eventing/pkg/apis/eventing/v1" sourcesv1 "knative.dev/eventing/pkg/apis/sources/v1" servingv1 "knative.dev/serving/pkg/apis/serving/v1" @@ -158,7 +159,7 @@ func main() { os.Exit(1) } - klog.V(log.I).InfoS("starting manager") + klog.V(log.I).InfoS("starting manager", "version:", version.GetOperatorVersion()) if err := mgr.Start(ctrl.SetupSignalHandler()); err != nil { klog.V(log.E).ErrorS(err, "problem running manager") os.Exit(1) diff --git a/operator.yaml b/operator.yaml index f7d09313e..325d30cc5 100644 --- a/operator.yaml +++ b/operator.yaml @@ -26988,16 +26988,16 @@ subjects: apiVersion: v1 data: DEFAULT_WORKFLOW_EXTENSION: .sw.json - Dockerfile: "FROM quay.io/kiegroup/kogito-swf-builder-nightly:latest AS builder\n\n# + Dockerfile: "FROM docker.io/apache/incubator-kie-sonataflow-builder:main AS builder\n\n# variables that can be overridden by the builder\n# To add a Quarkus extension to your application\nARG QUARKUS_EXTENSIONS\n# Args to pass to the Quarkus CLI add extension command\nARG QUARKUS_ADD_EXTENSION_ARGS\n# Additional java/mvn arguments to pass to the builder\nARG MAVEN_ARGS_APPEND\n\n# Copy from build context to skeleton resources project\nCOPY --chown=1001 . ./resources\n\nRUN /home/kogito/launch/build-app.sh ./resources\n \n#=============================\n# Runtime Run\n#=============================\nFROM - registry.access.redhat.com/ubi9/openjdk-17:latest\n\nENV LANG='en_US.UTF-8' LANGUAGE='en_US:en'\n - \ \n# We make four distinct layers so if there are application changes the library - layers can be re-used\nCOPY --from=builder --chown=185 /home/kogito/serverless-workflow-project/target/quarkus-app/lib/ + registry.access.redhat.com/ubi9/openjdk-17-runtime:latest\n\nENV LANG='en_US.UTF-8' + LANGUAGE='en_US:en'\n \n# We make four distinct layers so if there are application + changes the library layers can be re-used\nCOPY --from=builder --chown=185 /home/kogito/serverless-workflow-project/target/quarkus-app/lib/ /deployments/lib/\nCOPY --from=builder --chown=185 /home/kogito/serverless-workflow-project/target/quarkus-app/*.jar /deployments/\nCOPY --from=builder --chown=185 /home/kogito/serverless-workflow-project/target/quarkus-app/app/ /deployments/app/\nCOPY --from=builder --chown=185 /home/kogito/serverless-workflow-project/target/quarkus-app/quarkus/ @@ -27104,7 +27104,7 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace - image: quay.io/kiegroup/kogito-serverless-operator-nightly:latest + image: docker.io/apache/incubator-kie-sonataflow-operator:latest livenessProbe: httpGet: path: /healthz diff --git a/tekton/pipeline/kogito_serverless_operator_pipeline.yaml b/tekton/pipeline/kogito_serverless_operator_pipeline.yaml index 4cff7737c..60c28c1f9 100644 --- a/tekton/pipeline/kogito_serverless_operator_pipeline.yaml +++ b/tekton/pipeline/kogito_serverless_operator_pipeline.yaml @@ -53,7 +53,7 @@ spec: params: - name: script value: > - curl https://raw.githubusercontent.com/apache/incubator-kie-kogito-serverless-operator/main/operator.yaml | sed -E 's|image: quay.io/kiegroup/.*|image: image-registry.openshift-image-registry.svc:5000/sonataflow-operator-system/kogito-serverless-operator:latest|g' | kubectl apply -f - + curl https://raw.githubusercontent.com/apache/incubator-kie-kogito-serverless-operator/main/operator.yaml | sed -E 's|image: docker.io/apache/incubator-kie.*|image: image-registry.openshift-image-registry.svc:5000/sonataflow-operator-system/kogito-serverless-operator:latest|g' | kubectl apply -f - runAfter: - build-image taskRef: diff --git a/test/builder/Dockerfile b/test/builder/Dockerfile index fac640c2f..41dbbae39 100644 --- a/test/builder/Dockerfile +++ b/test/builder/Dockerfile @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -FROM quay.io/kiegroup/kogito-swf-builder-nightly:latest AS builder +FROM docker.io/apache/incubator-kie-sonataflow-builder:main AS builder # Kogito User USER 1001 diff --git a/test/testdata/sonataflow.org_v1alpha08_sonataflow-simpleops.yaml b/test/testdata/sonataflow.org_v1alpha08_sonataflow-simpleops.yaml index d55f427f1..8c8de2a86 100644 --- a/test/testdata/sonataflow.org_v1alpha08_sonataflow-simpleops.yaml +++ b/test/testdata/sonataflow.org_v1alpha08_sonataflow-simpleops.yaml @@ -25,7 +25,7 @@ metadata: spec: podTemplate: container: - image: quay.io/kiegroup/sonataflow-minimal-example:latest + image: docker.io/apache/incubator-kie-sonataflow-minimal-example:latest flow: start: HelloWorld states: diff --git a/test/testdata/sonataflow.org_v1alpha08_sonataflowplatform_withCache_minikube.yaml b/test/testdata/sonataflow.org_v1alpha08_sonataflowplatform_withCache_minikube.yaml index 76a1e026b..adb4de838 100644 --- a/test/testdata/sonataflow.org_v1alpha08_sonataflowplatform_withCache_minikube.yaml +++ b/test/testdata/sonataflow.org_v1alpha08_sonataflowplatform_withCache_minikube.yaml @@ -22,6 +22,6 @@ metadata: spec: build: config: - baseImage: quay.io/kiegroup/kogito-swf-builder-nightly:latest + baseImage: docker.io/apache/incubator-kie-sonataflow-builder:main strategyOptions: KanikoBuildCacheEnabled: "true" diff --git a/testbdd/README.md b/testbdd/README.md index cd31d60a0..00cc3308d 100644 --- a/testbdd/README.md +++ b/testbdd/README.md @@ -88,9 +88,9 @@ make run-tests 2>&1 | tee log.out ``` $ make $ make container-build -$ podman tag quay.io/kiegroup/kogito-serverless-operator-nightly:latest quay.io/{USERNAME}/kogito-serverless-operator-nightly:latest -$ podman push quay.io/{USERNAME}/kogito-serverless-operator-nightly:latest -$ make run-tests cr_deployment_only=true local_cluster=true operator_image_tag=quay.io/{USERNAME}/kogito-serverless-operator-nightly:latest +$ podman tag docker.io/apache/incubator-kie-sonataflow-operator:main quay.io/{USERNAME}/incubator-kie-sonataflow-operator:latest +$ podman push quay.io/{USERNAME}/incubator-kie-sonataflow-operator:latest +$ make run-tests cr_deployment_only=true local_cluster=true operator_image_tag=quay.io/{USERNAME}/incubator-kie-sonataflow-operator:latest ``` **NOTE:** Replace {USERNAME} with the username/group you want to push to. Podman needs to be logged in to quay.io and be able to push to your username/group. If you want to use docker, just append `BUILDER=docker` to the `make container-build` command. @@ -108,7 +108,7 @@ All options from BDD tests do also apply here. #### Running devMode tests ```bash -make run-tests cr_deployment_only=true local_cluster=true show_scenarios=true tags=devMode namespace_name=my-namespace operator_image_tag=quay.io/kiegroup/kogito-serverless-operator-nightly:latest +make run-tests cr_deployment_only=true local_cluster=true show_scenarios=true tags=devMode namespace_name=my-namespace operator_image_tag=docker.io/apache/incubator-kie-sonataflow-operator:latest ``` If you want to have a more readable format, you can specify the `format=pretty` parameter. You can also specify your own operator image. Namespace is always created automatically, however, you can provide its name as in the command above, otherwise it will be automatically generated. diff --git a/testbdd/installers/sonataflow_installer.go b/testbdd/installers/sonataflow_installer.go index 1b528bcbf..aa274154a 100644 --- a/testbdd/installers/sonataflow_installer.go +++ b/testbdd/installers/sonataflow_installer.go @@ -33,7 +33,7 @@ import ( srvframework "github.com/apache/incubator-kie-kogito-serverless-operator/testbdd/framework" ) -const defaultOperatorImage = "quay.io/kiegroup/kogito-serverless-operator" +const defaultOperatorImage = "docker.io/apache/incubator-kie-sonataflow-operator" var ( // sonataFlowYamlClusterInstaller installs SonataFlow operator cluster wide using YAMLs diff --git a/version/version.go b/version/version.go index 942dc66c4..7321fb27d 100644 --- a/version/version.go +++ b/version/version.go @@ -19,28 +19,26 @@ package version -import ( - "strings" -) - const ( - // Current version - OperatorVersion = "999.0.0-snapshot" + // Use the script /hack/ci/bump-version.sh to update these constants. DO NOT UPDATE THEM MANUALLY! - // Should not be changed - snapshotSuffix = "snapshot" - latestVersion = "999.0.0-snapshot" + // operatorVersion is the current BINARY version of the operator, not the image tag. + operatorVersion = "999.0.0" + // tagVersion is the images version tag. + // For example, docker.io/apache/incubator-kie-sonataflow-operator:main + // + // This tag must reflect an existing tag in the registry. In development, must follow the git branch naming. + // When released, this version should reflect the `major.minor` version in the registry. + // For example, docker.io/apache/incubator-kie-sonataflow-operator:10.0 + tagVersion = "main" ) -func IsSnapshot() bool { - return strings.HasSuffix(OperatorVersion, snapshotSuffix) -} - -func IsLatestVersion() bool { - return latestVersion == OperatorVersion +// GetOperatorVersion gets the current binary version of the operator. Do not use it to compose image tags! +func GetOperatorVersion() string { + return operatorVersion } -func GetMajorMinor() string { - v := strings.Split(OperatorVersion, ".") - return v[0] + "." + v[1] +// GetTagVersion gets the current tag version for the operator and platform images. +func GetTagVersion() string { + return tagVersion }